Changeset 7


Ignore:
Timestamp:
Jan 12, 2006, 6:40:47 PM (16 years ago)
Author:
root
Message:

Update 2005-11-24

Location:
trunk
Files:
5 added
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/AUTHORS

    r6 r7  
    99
    1010Josh Elsasser <josh@elsasser.org>
    11  + GTK interface
     11 + GTK+ interface
    1212
    1313Michael Demars <keul@m0k.org>
  • trunk/Jamfile

    r6 r7  
    77if $(OS) = MACOSX
    88{
    9     OSXLinks macosx/Frameworks/Growl.framework/Growl ;
    109    OSXInfoPlist macosx/Info.plist : macosx/Info.plist.in ;
    1110    OSXBundle Transmission.app : libtransmission.a
     
    1716        macosx/English.lproj/MainMenu.nib/info.nib
    1817        macosx/English.lproj/MainMenu.nib/keyedobjects.nib
    19         macosx/Frameworks/Growl.framework/Growl
    2018        macosx/Images/Info.png
    2119        macosx/Images/Open.png
     
    3836        macosx/TorrentTableView.h
    3937        macosx/TorrentTableView.m
     38        macosx/Transmission.sdef
    4039        macosx/Transmission.xcodeproj/project.pbxproj
    4140        macosx/Transmission_Prefix.pch
  • trunk/Jamrules

    r6 r7  
    99VERSION_MINOR  = 4 ;
    1010# VERSION_STRING = $(VERSION_MAJOR).$(VERSION_MINOR) ;
    11 VERSION_STRING = 0.5-cvs ;
     11VERSION_STRING = CVS-20051124 ;
    1212
    1313DEFINES += VERSION_MAJOR=$(VERSION_MAJOR)
     
    3939    {
    4040        libtool -static $(>) -o $(<) ;
    41     }
    42 
    43     rule OSXLinks
    44     {
    45     }
    46     actions OSXLinks
    47     {
    48         ( cd macosx/Frameworks/Growl.framework/ && \
    49           ln -s Versions/Current/Growl && \
    50           ln -s Versions/Current/Headers && \
    51           ln -s Versions/Current/Resources && \
    52           ln -s A Versions/Current )
    5341    }
    5442
  • trunk/gtk/Jamfile

    r6 r7  
    11SubDir TOP gtk ;
    22
    3 GTK_SRC = conf.c main.c util.c ;
     3GTK_SRC = conf.c main.c prefs.c util.c ;
    44
    55Main          transmission-gtk   : $(GTK_SRC) ;
  • trunk/gtk/conf.c

    r5 r7  
    4040#include "conf.h"
    4141#include "transmission.h"
     42#include "util.h"
    4243
    4344#define FILE_LOCK               "gtk_lock"
     
    160161    goto done;
    161162  }
    162   /*g_io_channel_set_encoding(io, NULL, NULL);*/
    163163  g_io_channel_set_line_term(io, &term, 1);
    164164
     
    210210  g_tree_insert(prefs, g_strdup(name), g_strdup(value));
    211211
    212   return writeprefs(errstr);
     212  if(NULL != errstr)
     213    return writeprefs(errstr);
     214  else
     215    return TRUE;
    213216}
    214217
     
    237240  }
    238241
     242#ifdef NDEBUG
     243  ftruncate(fd, 0);
     244#else
     245  assert(0 == ftruncate(fd, 0));
     246#endif
     247
    239248  info.err = NULL;
    240249  io = g_io_channel_unix_new(fd);
    241   /*g_io_channel_set_encoding(io, NULL, NULL);*/
    242250  g_io_channel_set_close_on_unref(io, TRUE);
    243251
     
    319327    goto done;
    320328  }
    321   /*g_io_channel_set_encoding(io, NULL, NULL);*/
    322329  g_io_channel_set_line_term(io, &term, 1);
    323330
     
    368375  char *start, *end;
    369376
     377  /* skip any leading whitespace */
    370378  while(isspace(*line))
    371379    line++;
    372380
    373   if(NULL == (start = strchr(line, '=')))
     381  /* walk over the key, which may be alphanumerics as well as - or _ */
     382  for(start = line; isalnum(*start) || '_' == *start || '-' == *start; start++)
     383    ;
     384
     385  /* they key must be immediately followed by an = */
     386  if('=' != *start)
    374387    return NULL;
    375 
    376   while(isspace(*(++start)))
    377     ;
    378 
    379   if('"' != *start)
     388  *(start++) = '\0';
     389
     390  /* then the opening quote for the value */
     391  if('"' != *(start++))
    380392    return NULL;
    381393
    382   for(end = ++start; '\0' != *end && '"' != *end; end++)
     394  /* walk over the value */
     395  for(end = start; '\0' != *end && '"' != *end; end++)
     396    /* skip over escaped quotes */
    383397    if('\\' == *end && '\0' != *(end + 1))
    384398      end++;
    385399
     400  /* make sure we didn't hit the end of the string */
    386401  if('"' != *end)
    387402    return NULL;
    388 
    389   if(0 == memcmp(line, "torrent", sizeof("torrent") - 1)) {
    390     state->ts_torrent = g_new(char, end - start + 1);
    391     memcpy(state->ts_torrent, start, end - start);
    392     state->ts_torrent[end - start] = '\0';
    393   }
    394   else if(0 == memcmp(line, "dir", sizeof("dir") - 1)) {
    395     state->ts_directory = g_new(char, end - start + 1);
    396     memcpy(state->ts_directory, start, end - start);
    397     state->ts_directory[end - start] = '\0';
    398   }
    399   else if(0 == memcmp(line, "paused", sizeof("paused") - 1)) {
    400     state->ts_paused = (0 == memcmp("yes", start, end - start));
    401   }
    402 
     403  *end = '\0';
     404
     405  /* if it's a key we recognize then save the data */
     406  if(0 == strcmp(line, "torrent"))
     407    state->ts_torrent = g_strcompress(start);
     408  else if(0 == strcmp(line, "dir"))
     409    state->ts_directory = g_strcompress(start);
     410  else if(0 == strcmp(line, "paused"))
     411    state->ts_paused = strbool(start);
     412
     413  /* return a pointer to just past the end of the value */
    403414  return end + 1;
    404415}
    405416
    406 /* XXX need to save download directory, also maybe running/stopped state */
    407417gboolean
    408418cf_savestate(int count, tr_stat_t *torrents, char **errstr) {
     
    426436  }
    427437
     438#ifdef NDEBUG
     439  ftruncate(fd, 0);
     440#else
     441  assert(0 == ftruncate(fd, 0));
     442#endif
     443
    428444  io = g_io_channel_unix_new(fd);
     445  g_io_channel_set_close_on_unref(io, TRUE);
     446
    429447  /* XXX what the hell should I be doing about unicode? */
    430   /*g_io_channel_set_encoding(io, NULL, NULL);*/
    431   g_io_channel_set_close_on_unref(io, TRUE);
    432448
    433449  err = NULL;
  • trunk/gtk/conf.h

    r5 r7  
    4444const char *
    4545cf_getpref(const char *name);
     46/* if errstr is NULL then prefs will not be saved */
    4647gboolean
    4748cf_setpref(const char *name, const char *value, char **errstr);
  • trunk/gtk/main.c

    r5 r7  
    2525*/
    2626
     27#include <sys/param.h>
    2728#include <assert.h>
     29#include <errno.h>
    2830#include <string.h>
    2931#include <stdio.h>
    3032#include <stdlib.h>
    31 #include <sys/param.h>
    3233#include <time.h>
    3334#include <unistd.h>
     
    3637
    3738#include "conf.h"
     39#include "prefs.h"
    3840#include "transmission.h"
    3941#include "util.h"
     
    4345struct cbdata {
    4446  tr_handle_t *tr;
    45   GtkWidget *wind;
     47  GtkWindow *wind;
    4648  GtkListStore *model;
    4749  GtkTreeView *view;
     
    6062
    6163void
    62 readargs(int argc, char **argv, int *port, int *limit);
    63 void
    6464maketypes(void);
    6565gpointer
     
    9393makeaddwind(struct cbdata *data);
    9494gboolean
    95 addtorrent(tr_handle_t *tr, GtkWidget *parentwind, const char *torrent,
     95addtorrent(tr_handle_t *tr, GtkWindow *parentwind, const char *torrent,
    9696           const char *dir, gboolean paused);
    9797void
     
    102102makeinfowind(struct cbdata *data, int index);
    103103gboolean
    104 savetorrents(tr_handle_t *tr, GtkWidget *wind, int count, tr_stat_t *stat);
     104savetorrents(tr_handle_t *tr, GtkWindow *wind, int count, tr_stat_t *stat);
    105105
    106106#define TR_TYPE_PIECES_NAME     "tr-type-pieces"
     
    110110
    111111#define LIST_ACTION           "torrent-list-action"
    112 enum listact { ACT_OPEN, ACT_START, ACT_STOP, ACT_DELETE, ACT_INFO };
     112enum listact { ACT_OPEN, ACT_START, ACT_STOP, ACT_DELETE, ACT_INFO, ACT_PREF };
    113113#define LIST_ACTION_FROM      "torrent-list-action-from"
    114114enum listfrom { FROM_BUTTON, FROM_POPUP };
     
    129129  {4,  "Properties",  GTK_STOCK_PROPERTIES,   ACT_INFO,
    130130   "Get additional information for a torrent", "XXX"},
     131  {5,  "Preferences", GTK_STOCK_PREFERENCES,  ACT_PREF,
     132   "Open preferences dialog", "XXX"},
    131133};
    132134
     
    136138  GtkWidget *mainwind, *preferr, *stateerr;
    137139  char *err;
    138   int port, limit;
    139140  tr_handle_t *tr;
    140141  GList *saved;
     142  const char *pref;
     143  long intval;
    141144
    142145  gtk_init(&argc, &argv);
    143   readargs(argc, argv, &port, &limit);
    144146
    145147  tr = tr_init();
     
    153155
    154156      if(!cf_loadprefs(&err)) {
    155         preferr = errmsg(mainwind, "%s", err);
     157        preferr = errmsg(GTK_WINDOW(mainwind), "%s", err);
    156158        g_free(err);
    157159      }
    158160      saved = cf_loadstate(&err);
    159161      if(NULL != err) {
    160         stateerr = errmsg(mainwind, "%s", err);
     162        stateerr = errmsg(GTK_WINDOW(mainwind), "%s", err);
    161163        g_free(err);
    162164      }
    163165
    164       /* XXX need to remove port and limit options and make them prefs */
    165       /* XXX need prefs gui */
    166       /* XXX need default save dir pref */
    167 
    168       if(0 != port)
    169         tr_setBindPort(tr, port);
    170       if(0 != limit)
    171         tr_setUploadLimit(tr, limit);
     166      /* set the upload limit */
     167      setlimit(tr);
     168
     169      /* set the listening port */
     170      if(NULL != (pref = cf_getpref(PREF_PORT)) &&
     171         0 < (intval = strtol(pref, NULL, 10)) && 0xffff >= intval)
     172        tr_setBindPort(tr, intval);
    172173
    173174      maketypes();
     
    179180        gtk_widget_show_all(stateerr);
    180181    } else {
    181       errmsg_full(NULL, (errfunc_t)gtk_main_quit, NULL, "%s", err);
     182      gtk_widget_show(errmsg_full(NULL, (errfunc_t)gtk_main_quit,
     183                                  NULL, "%s", err));
    182184      g_free(err);
    183185    }
    184186  } else {
    185     errmsg_full(NULL, (errfunc_t)gtk_main_quit, NULL, "%s", err);
     187    gtk_widget_show(errmsg_full(NULL, (errfunc_t)gtk_main_quit,
     188                                NULL, "%s", err));
    186189    g_free(err);
    187190  }
     
    190193
    191194  return 0;
    192 }
    193 
    194 void
    195 readargs(int argc, char **argv, int *port, int *limit) {
    196   char *name;
    197   int opt, num;
    198 
    199   *port = 0;
    200   *limit = 0;
    201 
    202   if(NULL == (name = strrchr(argv[0], '/')) || '\0' == *(++name))
    203     name = argv[0];
    204 
    205   for(num = 1; num < argc; num++)
    206     if(0 == strcmp(argv[num], "-help") || 0 == strcmp(argv[num], "--help"))
    207       goto usage;
    208 
    209   while(0 <= (opt = getopt(argc, argv, "hp:u:"))) {
    210     switch(opt) {
    211       case 'p':
    212         num = atoi(optarg);
    213         if(0 < num && 0xffff > num)
    214           *port = num;
    215         break;
    216       case 'u':
    217         num = atoi(optarg);
    218         if(0 != num)
    219           *limit = num;
    220         break;
    221       default:
    222         goto usage;
    223     }
    224   }
    225 
    226   return;
    227 
    228  usage:
    229   printf("usage: %s [-h] [-p port] [-u limit]\n", name);
    230   exit(1);
    231195}
    232196
     
    258222
    259223  data->tr = tr;
    260   data->wind = wind;
     224  data->wind = GTK_WINDOW(wind);
    261225  data->timer = -1;
    262226  /* filled in by makewind_list */
     
    278242  for(ii = g_list_first(saved); NULL != ii; ii = ii->next) {
    279243    ts = ii->data;
    280     addtorrent(tr, wind, ts->ts_torrent, ts->ts_directory, ts->ts_paused);
     244    addtorrent(tr, GTK_WINDOW(wind),
     245               ts->ts_torrent, ts->ts_directory, ts->ts_paused);
    281246    cf_freestate(ts);
    282247  }
     
    323288  fprintf(stderr, "quit: starting timeout at %i\n", edata->started);
    324289
    325   //exitcheck(edata);
    326 
    327290  /* returning FALSE means to destroy the window */
    328291  return TRUE;
     
    364327  data->timer = -1;
    365328
    366   gtk_widget_destroy(data->cbdata->wind);
     329  gtk_widget_destroy(GTK_WIDGET(data->cbdata->wind));
    367330  tr_close(data->cbdata->tr);
    368331  g_free(data->cbdata);
     
    382345  gtk_toolbar_set_style(GTK_TOOLBAR(bar), GTK_TOOLBAR_BOTH);
    383346
    384   for(ii = 0; ii < sizeof(actionitems) / sizeof(actionitems[0]); ii++) {
     347  for(ii = 0; ii < ALEN(actionitems); ii++) {
    385348    item = gtk_tool_button_new_from_stock(actionitems[ii].id);
    386349    gtk_tool_button_set_label(GTK_TOOL_BUTTON(item), actionitems[ii].name);
     
    420383  GtkCellRenderer *rendprog;
    421384
    422   assert(MC_ROW_COUNT == sizeof(types) / sizeof(types[0]));
     385  assert(MC_ROW_COUNT == ALEN(types));
    423386
    424387  model = gtk_list_store_newv(MC_ROW_COUNT, types);
     
    433396  g_object_set(rendprog, "text", "", NULL);
    434397
    435 /*
    436   col = gtk_tree_view_column_new_with_attributes(
    437     "Name", rend, "text", MC_NAME, NULL);
    438   gtk_tree_view_column_add_attribute(col, rend, "text", MC_SIZE);
    439   gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);
    440 
    441   col = gtk_tree_view_column_new_with_attributes(
    442     "Status", rend, "text", MC_STAT, NULL);
    443   gtk_tree_view_column_add_attribute(col, rend, "text", MC_ERR);
    444   gtk_tree_view_column_add_attribute(col, rend, "text", MC_DPEERS);
    445   gtk_tree_view_column_add_attribute(col, rend, "text", MC_UPEERS);
    446   gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);
    447 
    448   col = gtk_tree_view_column_new_with_attributes(
    449     "Progress", rendprog, "value", MC_PROG, NULL);
    450   gtk_tree_view_column_pack_start(col, rend, TRUE);
    451   gtk_tree_view_column_add_attribute(col, rend, "text", MC_ETA);
    452   gtk_tree_view_column_add_attribute(col, rend, "text", MC_DRATE);
    453   gtk_tree_view_column_add_attribute(col, rend, "text", MC_URATE);
    454   gtk_tree_view_column_add_attribute(col, rend, "text", MC_DOWN);
    455   gtk_tree_view_column_add_attribute(col, rend, "text", MC_UP);
    456   gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);
    457 */
    458 
    459398  gtk_tree_view_append_column(GTK_TREE_VIEW(view),
    460399    gtk_tree_view_column_new_with_attributes("Name", rend,
     
    490429    gtk_tree_view_column_new_with_attributes("Leechers", rend,
    491430                                             "text", MC_DPEERS, NULL));
    492   /*gtk_tree_view_append_column(GTK_TREE_VIEW(view),
    493     gtk_tree_view_column_new_with_attributes("", rend,
    494                                              "text", MC_PIECES, NULL));*/
    495431  gtk_tree_view_append_column(GTK_TREE_VIEW(view),
    496432    gtk_tree_view_column_new_with_attributes("Downloaded", rend,
     
    533469      MC_URATE, st[ii].rateUpload, MC_ETA, st[ii].eta, MC_PEERS, st[ii].peersTotal,
    534470      MC_UPEERS, st[ii].peersUploading, MC_DPEERS, st[ii].peersDownloading,
    535       /*MC_PIECES, st[ii].pieces,*/ MC_DOWN, st[ii].downloaded, MC_UP, st[ii].uploaded, -1);
     471      MC_DOWN, st[ii].downloaded, MC_UP, st[ii].uploaded, -1);
    536472  }
    537473  free(st);
     
    579515  /* XXX am I leaking references here? */
    580516  /* XXX can I cache this in cbdata? */
    581   for(ii = 0; ii < sizeof(actionitems) / sizeof(actionitems[0]); ii++) {
     517  for(ii = 0; ii < ALEN(actionitems); ii++) {
    582518    item = gtk_menu_item_new_with_label(actionitems[ii].name);
    583519    g_object_set_data(G_OBJECT(item), LIST_ACTION,
     
    611547  tr_stat_t *sb;
    612548
    613   if(ACT_OPEN == act) {
    614     makeaddwind(data);
    615     return;
     549  switch(act) {
     550    case ACT_OPEN:
     551      makeaddwind(data);
     552      return;
     553    case ACT_PREF:
     554      makeprefwindow(data->wind, data->tr);
     555      return;
     556    default:
     557      break;
    616558  }
    617559
     
    674616  g_signal_connect_swapped(GTK_FILE_SELECTION(wind)->cancel_button, "clicked",
    675617                           G_CALLBACK(gtk_widget_destroy), wind);
    676   gtk_window_set_transient_for(GTK_WINDOW(wind), GTK_WINDOW(data->wind));
     618  gtk_window_set_transient_for(GTK_WINDOW(wind), data->wind);
    677619  gtk_window_set_destroy_with_parent(GTK_WINDOW(wind), TRUE);
    678620  gtk_window_set_modal(GTK_WINDOW(wind), TRUE);
     
    681623
    682624gboolean
    683 addtorrent(tr_handle_t *tr, GtkWidget *parentwind, const char *torrent,
     625addtorrent(tr_handle_t *tr, GtkWindow *parentwind, const char *torrent,
    684626           const char *dir, gboolean paused) {
    685627  char *wd;
     628
     629  if(NULL == dir) {
     630    dir = cf_getpref(PREF_DIR);
     631    if(!mkdir_p(dir, 0777)) {
     632      errmsg(parentwind, "Failed to create download directory %s:\n%s",
     633             dir, strerror(errno));
     634      return FALSE;
     635    }
     636  }
    686637
    687638  if(0 != tr_torrentInit(tr, torrent)) {
     
    694645    tr_torrentSetFolder(tr, tr_torrentCount(tr) - 1, dir);
    695646  else {
    696     /* XXX need pref for download directory */
    697647    wd = g_new(char, MAXPATHLEN + 1);
    698648    if(NULL == getcwd(wd, MAXPATHLEN + 1))
     
    748698    assert(!"XXX i'm tired");
    749699  }
    750   wind = gtk_dialog_new_with_buttons(sb[index].info.name, GTK_WINDOW(data->wind),
     700  wind = gtk_dialog_new_with_buttons(sb[index].info.name, data->wind,
    751701    GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL);
    752702
     
    856806
    857807gboolean
    858 savetorrents(tr_handle_t *tr, GtkWidget *wind, int count, tr_stat_t *stat) {
     808savetorrents(tr_handle_t *tr, GtkWindow *wind, int count, tr_stat_t *stat) {
    859809  char *errstr;
    860810  tr_stat_t *st;
  • trunk/gtk/util.c

    r5 r7  
    2525*/
    2626
     27#include <sys/types.h>
     28#include <sys/stat.h>
     29#include <errno.h>
    2730#include <stdarg.h>
     31#include <string.h>
     32
    2833#include <gtk/gtk.h>
    2934
     
    3136
    3237static void
    33 errcb(GtkWidget *widget, int resp, gpointer data);
     38errcb(GtkWidget *wind, int resp, gpointer data);
    3439
    3540gboolean
     
    5156}
    5257
     58gboolean
     59mkdir_p(const char *name, mode_t mode) {
     60  struct stat sb;
     61  char *parent;
     62  gboolean ret;
     63  int oerrno;
     64
     65  if(0 != stat(name, &sb)) {
     66    if(ENOENT != errno)
     67      return FALSE;
     68    parent = g_path_get_dirname(name);
     69    ret = mkdir_p(parent, mode);
     70    oerrno = errno;
     71    g_free(parent);
     72    errno = oerrno;
     73    return (ret ? (0 == mkdir(name, mode)) : FALSE);
     74  }
     75
     76  if(!S_ISDIR(sb.st_mode)) {
     77    errno = ENOTDIR;
     78    return FALSE;
     79  }
     80
     81  return TRUE;
     82}
     83
    5384GtkWidget *
    54 errmsg(GtkWidget *wind, const char *format, ...) {
     85errmsg(GtkWindow *wind, const char *format, ...) {
    5586  GtkWidget *dialog;
    5687  va_list ap;
     
    6495
    6596GtkWidget *
    66 errmsg_full(GtkWidget *wind, errfunc_t func, void *data,
     97errmsg_full(GtkWindow *wind, errfunc_t func, void *data,
    6798            const char *format, ...) {
    6899  GtkWidget *dialog;
     
    77108
    78109GtkWidget *
    79 verrmsg(GtkWidget *wind, errfunc_t func, void *data,
     110verrmsg(GtkWindow *wind, errfunc_t func, void *data,
    80111        const char *format, va_list ap) {
    81112  GtkWidget *dialog;
     
    89120      NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "%s", msg);
    90121  else
    91     dialog = gtk_message_dialog_new(
    92       GTK_WINDOW(wind), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
     122    dialog = gtk_message_dialog_new(wind,
     123      GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
    93124      GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "%s", msg);
    94125
     
    99130  g_signal_connect(dialog, "response", G_CALLBACK(errcb), funcdata);
    100131  if(NULL != wind)
    101     gtk_widget_show_all(dialog);
     132    gtk_widget_show(dialog);
    102133  g_free(msg);
    103134
  • trunk/gtk/util.h

    r5 r7  
    2828#define TG_UTIL_H
    2929
     30#include <sys/types.h>
    3031#include <stdarg.h>
    3132
     
    3738#endif
    3839
     40/* return number of items in array */
     41#define ALEN(a)                 (sizeof(a) / sizeof((a)[0]))
     42
    3943gboolean
    4044strbool(const char *str);
     45
     46gboolean
     47mkdir_p(const char *name, mode_t mode);
    4148
    4249typedef void (*errfunc_t)(void*);
     
    4552
    4653GtkWidget *
    47 errmsg(GtkWidget *wind, const char *format, ...)
     54errmsg(GtkWindow *wind, const char *format, ...)
    4855#ifdef __GNUC__
    4956  __attribute__ ((format (printf, 2, 3)))
     
    5259
    5360GtkWidget *
    54 errmsg_full(GtkWidget *wind, errfunc_t func, void *data,
     61errmsg_full(GtkWindow *wind, errfunc_t func, void *data,
    5562            const char *format, ...)
    5663#ifdef __GNUC__
     
    6067
    6168GtkWidget *
    62 verrmsg(GtkWidget *wind, errfunc_t func, void *data,
     69verrmsg(GtkWindow *wind, errfunc_t func, void *data,
    6370        const char *format, va_list ap);
    6471
  • trunk/libtransmission/transmission.c

    r6 r7  
    6666    h->fdlimit = tr_fdInit();
    6767
    68     h->bindPort = 9090;
     68    h->bindPort = TR_DEFAULT_PORT;
    6969
    7070    snprintf( h->prefsDirectory, sizeof( h->prefsDirectory ),
  • trunk/libtransmission/transmission.h

    r6 r7  
    3030#define TR_MAX_TORRENT_COUNT 50
    3131
     32#define TR_DEFAULT_PORT      9090
     33
    3234/***********************************************************************
    3335 * tr_init
  • trunk/libtransmission/upload.c

    r1 r7  
    102102        now  = tr_date();
    103103
    104         /* Check the last four times we sent something and decide if
     104        /* Check the last FOO times we sent something and decide if
    105105           we must wait */
    106106        for( i = 0; i < FOO; i++ )
    107107        {
    108108            size += u->sizes[i];
    109             if( (uint64_t) size < 1024ULL *
    110                     u->limit * ( now - u->dates[i] ) / 1000 )
     109            if( (uint64_t) size * 1000 <
     110                    ( now - u->dates[i] ) * u->limit * 1024 )
    111111            {
    112112                ret = 1;
  • trunk/libtransmission/utils.h

    r3 r7  
    4343    struct timeval tv;
    4444    gettimeofday( &tv, NULL );
    45     return( (uint64_t) tv.tv_sec * 1000 + (uint64_t) tv.tv_usec / 1000 );
     45    return (uint64_t) tv.tv_sec * 1000 + ( tv.tv_usec / 1000 );
    4646}
    4747
  • trunk/macosx/Controller.h

    r6 r7  
    2727#include <transmission.h>
    2828#include "PrefsController.h"
    29 #include <Growl/Growl.h>
    3029
    3130@class TorrentTableView;
    3231
    33 @interface Controller : NSObject <GrowlApplicationBridgeDelegate>
     32@interface Controller : NSObject
    3433{
    3534    tr_handle_t                  * fHandle;
     
    9998- (void) linkHomepage:    (id) sender;
    10099- (void) linkForums:      (id) sender;
    101 - (void) notifyGrowl:     (NSString *) file folder: (NSString *) folder;
    102 - (void) revealInFinder:  (NSString *) path;
     100- (void) notifyGrowl:     (NSString *) file;
     101- (void) finderReveal:    (NSString *) path;
     102- (void) finderTrash:     (NSString *) path;
     103- (void) growlRegister:   (id) sender;
    103104
    104105@end
  • trunk/macosx/Controller.m

    r6 r7  
    192192   
    193193    /*  Register with the growl system */
    194     [GrowlApplicationBridge setGrowlDelegate:self];
     194    [self growlRegister: self];
    195195   
    196196    /* Update the interface every 500 ms */
     
    468468                     deleteData: (BOOL) deleteData
    469469{
    470     BOOL torrentWarning = ![[NSUserDefaults standardUserDefaults]
    471                             boolForKey:@"SkipTorrentDeletionWarning"];
    472     BOOL dataWarning = ![[NSUserDefaults standardUserDefaults]
    473                             boolForKey:@"SkipDataDeletionWarning"];
    474    
    475     if ( ( torrentWarning && deleteTorrent ) || (dataWarning && deleteData ) )
    476     {
    477         NSAlert *alert = [[[NSAlert alloc] init] autorelease];
    478        
    479         [alert addButtonWithTitle:@"Delete"];
    480         [alert addButtonWithTitle:@"Cancel"];
    481         [alert setAlertStyle:NSWarningAlertStyle];
    482         [alert setMessageText:@"Do you want to remove this torrent from Transmission?"];
    483        
    484         if ( (deleteTorrent && torrentWarning) &&
    485              !( dataWarning && deleteData ) )
    486         {
    487             /* delete torrent warning YES, delete data warning NO */
    488             [alert setInformativeText:@"This will delete the .torrent file only. "
    489                 "This can not be undone!"];
    490         }
    491         else if( (deleteData && dataWarning) &&
    492                  !( torrentWarning && deleteTorrent ) )
    493         {
    494             /* delete torrent warning NO, delete data warning YES */
    495             [alert setInformativeText:@"This will delete the downloaded data. "
    496                 "This can not be undone!"];
    497         }
    498         else
    499         {
    500             /* delete torrent warning YES, delete data warning YES */
    501             [alert setInformativeText:@"This will delete the downloaded data and "
    502                 ".torrent file. This can not be undone!"];
    503         }
    504        
    505         if ( [alert runModal] == NSAlertSecondButtonReturn )
    506             return;
    507     }
    508    
    509     if ( deleteData )
    510     {
    511         tr_file_t * files = fStat[idx].info.files;
    512         int i;
    513        
    514         for ( i = 0; i < fStat[idx].info.fileCount; i++ )
    515         {
    516             if ( -1 == remove([[NSString stringWithFormat:@"%s/%s",
    517                                         fStat[idx].folder,
    518                                         files[i].name]
    519                                 cString]) )
    520             {
    521                 NSLog(@"remove(%s) failed, errno = %i",
    522                       files[i].name,
    523                       errno);
    524             }
    525         }
    526        
    527         /* in some cases, we should remove fStat[idx].folder also. When? */
    528     }
    529    
    530     if ( deleteTorrent )
    531     {
    532         if ( -1 == remove( fStat[idx].info.torrent ) )
    533         {
    534             NSLog(@"remove(%s) failed, errno = %i",
    535                   fStat[idx].info.torrent,
    536                   errno);
    537         }
     470    if( deleteData )
     471    {
     472        [self finderTrash: [NSString stringWithFormat: @"%@/%@",
     473            [NSString stringWithUTF8String: fStat[idx].folder],
     474            [NSString stringWithUTF8String: fStat[idx].info.name]]];
     475    }
     476    if( deleteTorrent )
     477    {
     478        [self finderTrash: [NSString stringWithUTF8String:
     479            fStat[idx].info.torrent]];
    538480    }
    539481   
     
    612554        }
    613555        [self notifyGrowl: [NSString stringWithUTF8String:
    614             fStat[i].info.name] folder: [NSString stringWithUTF8String:
    615             fStat[i].folder]];
     556            fStat[i].info.name]];
    616557        tr_setFinished( fHandle, i, 0 );
    617558    }
     
    910851}
    911852
    912 - (void) notifyGrowl: (NSString * ) file folder: (NSString *) folder
    913 {
    914     [GrowlApplicationBridge
    915         notifyWithTitle: @"Download complete."
    916         description: [NSString stringWithFormat: @"Seeding: %@", file]
    917         notificationName: @"Download complete."
    918         iconData: nil
    919         priority: 0
    920         isSticky: FALSE
    921         clickContext: [NSString stringWithFormat: @"%@/%@", folder, file]];
    922 }
    923 
    924 - (NSDictionary *)registrationDictionaryForGrowl
     853- (void) notifyGrowl: (NSString * ) file
     854{
     855    NSString * growlScript;
     856    NSAppleScript * appleScript;
     857    NSDictionary * error;
     858   
     859    growlScript = [NSString stringWithFormat:
     860        @"tell application \"System Events\"\n"
     861         "  if exists application process \"GrowlHelperApp\" then\n"
     862         "    tell application \"GrowlHelperApp\"\n "
     863         "      notify with name \"Download Complete\""
     864         "        title \"Download Complete\""
     865         "        description \"%@\""
     866         "        application name \"Transmission\"\n"
     867         "    end tell\n"
     868         "  end if\n"
     869         "end tell", file];
     870    appleScript = [[NSAppleScript alloc] initWithSource: growlScript];
     871    if( ![appleScript executeAndReturnError: &error] )
     872    {
     873        printf( "Growl notify failed\n" );
     874    }
     875    [appleScript release];
     876}
     877
     878- (void) growlRegister: (id) sender
    925879{   
    926     NSString *title        = [NSString stringWithUTF8String: "Download complete."];
    927     NSMutableArray *defNotesArray = [NSMutableArray array];
    928     NSMutableArray *allNotesArray = [NSMutableArray array];
    929 
    930     [allNotesArray addObject:title];
    931     [defNotesArray addObject:[NSNumber numberWithUnsignedInt:0]];   
    932 
    933     NSDictionary *regDict = [NSDictionary dictionaryWithObjectsAndKeys:
    934         @"Transmission", GROWL_APP_NAME,
    935         allNotesArray, GROWL_NOTIFICATIONS_ALL,
    936         defNotesArray, GROWL_NOTIFICATIONS_DEFAULT,
    937         nil];
    938    
    939     return regDict;
    940 }
    941 
    942 - (NSString *) applicationNameForGrowl
    943 {
    944     return [NSString stringWithUTF8String: "Transmission"];
    945 }
    946 
    947 - (void) growlNotificationWasClicked: (id) clickContext
    948 {
    949     [self revealInFinder: (NSString *) clickContext];
    950 }
     880    NSString * growlScript;
     881    NSAppleScript * appleScript;
     882    NSDictionary * error;
     883   
     884    growlScript = [NSString stringWithFormat:
     885        @"tell application \"System Events\"\n"
     886         "  if exists application process \"GrowlHelperApp\" then\n"
     887         "    tell application \"GrowlHelperApp\"\n"
     888         "      register as application \"Transmission\" "
     889         "        all notifications {\"Download Complete\"}"
     890         "        default notifications {\"Download Complete\"}"
     891         "        icon of application \"Transmission\"\n"
     892         "    end tell\n"
     893         "  end if\n"
     894         "end tell"];
     895    appleScript = [[NSAppleScript alloc] initWithSource: growlScript];
     896    if( ![appleScript executeAndReturnError: &error] )
     897    {
     898        printf( "Growl registration failed\n" );
     899    }
     900    [appleScript release];
     901}
     902
    951903
    952904- (void) revealFromMenu: (id) sender
    953905{
    954     [fTableView revealInFinder: [fTableView selectedRow]];
    955 }
    956 
    957 - (void) revealInFinder: (NSString *) path
     906    int row;
     907
     908    row = [fTableView selectedRow];
     909    if( row < 0 )
     910    {
     911        return;
     912    }
     913    [self finderReveal: [NSString stringWithFormat: @"%@/%@",
     914        [NSString stringWithUTF8String: fStat[row].folder],
     915        [NSString stringWithUTF8String: fStat[row].info.name]]];
     916}
     917
     918- (void) finderReveal: (NSString *) path
    958919{
    959920    NSString * string;
     
    961922    NSDictionary * error;
    962923   
    963     string = [NSString stringWithFormat: @"tell application "
    964         "\"Finder\"\nactivate\nreveal (POSIX file \"%@\")\nend tell",
    965         path];
     924    string = [NSString stringWithFormat:
     925        @"tell application \"Finder\"\n"
     926         "  activate\n"
     927         "  reveal (POSIX file \"%@\")\n"
     928         "end tell", path];
     929
    966930    appleScript = [[NSAppleScript alloc] initWithSource: string];
    967931    if( ![appleScript executeAndReturnError: &error] )
    968932    {
    969         printf( "Reveal in Finder: AppleScript failed\n" );
     933        printf( "finderReveal failed\n" );
    970934    }
    971935    [appleScript release];
    972936}
    973937
     938- (void) finderTrash: (NSString *) path
     939{
     940    NSString * string;
     941    NSAppleScript * appleScript;
     942    NSDictionary * error;
     943
     944    string = [NSString stringWithFormat:
     945        @"tell application \"Finder\"\n"
     946         "  move (POSIX file \"%@\") to trash\n"
     947         "end tell", path];
     948
     949    appleScript = [[NSAppleScript alloc] initWithSource: string];
     950    if( ![appleScript executeAndReturnError: &error] )
     951    {
     952        printf( "finderTrash failed\n" );
     953    }
     954    [appleScript release];
     955}
    974956
    975957@end
  • trunk/macosx/PrefsController.m

    r1 r7  
    4545    NSUserDefaults * defaults;
    4646    NSDictionary   * appDefaults;
     47    NSString       * desktop, * port;
    4748
    4849    fHandle = handle;
     
    5152        - Simple bar
    5253        - Always download to Desktop
    53         - Port 9090
     54        - Port TR_DEFAULT_PORT
    5455        - 20 KB/s upload limit */
    55     NSString * desktopPath
    56         = [NSString stringWithFormat: @"%@/Desktop",
    57                             NSHomeDirectory()];
     56    desktop = [NSHomeDirectory() stringByAppendingString: @"/Desktop"];
     57    port    = [NSString stringWithFormat: @"%d", TR_DEFAULT_PORT];
    5858
    5959    defaults    = [NSUserDefaults standardUserDefaults];
     
    6161                    @"NO",       @"UseAdvancedBar",
    6262                    @"Constant", @"DownloadChoice",
    63                     desktopPath, @"DownloadFolder",
    64                     @"9090",     @"BindPort",
     63                    desktop,    @"DownloadFolder",
     64                    port,        @"BindPort",
    6565                    @"20",       @"UploadLimit",
    6666                    NULL];
  • trunk/macosx/ProgressCell.h

    r6 r7  
    3131    tr_stat_t * fStat;
    3232
    33     NSString  * fProgressString;
    3433    NSString  * fDlString;
    3534    NSString  * fUlString;
    3635
    37     NSBitmapImageRep * fBgBmp;
    38     NSBitmapImageRep * fBmp;
     36    NSBitmapImageRep * fBackgroundBmp;
     37    NSBitmapImageRep * fProgressBmp;
    3938}
    4039- (id)   init;
  • trunk/macosx/ProgressCell.m

    r6 r7  
    2323#include "ProgressCell.h"
    2424
     25@implementation ProgressCell
     26
     27/***********************************************************************
     28 * Static tables
     29 ***********************************************************************
     30 * We use these tables to optimize the drawing. They contain packed
     31 * RGBA pixels for every color we might need.
     32 **********************************************************************/
    2533#if 0
    2634/* Coefficients for the "3D effect" */
     
    7280      0x00ED00FF, 0x00F200FF, 0x00F400FF, 0x00B500FF };
    7381
    74 @implementation ProgressCell
    75 
     82/***********************************************************************
     83 * init
     84 ***********************************************************************
     85 * Prepares the NSBitmapImageReps we are going to need in order to
     86 * draw.
     87 **********************************************************************/
    7688- (id) init
    7789{
    78     NSImage * bgImg;
    79     NSSize    size;
    80 
    8190    self = [super init];
    8291
    83     /* Have a NSBitmapImageRep ready to draw the progression bar */
    84     bgImg  = [NSImage imageNamed: @"Progress.png"];
    85     fBgBmp = [[bgImg representations] objectAtIndex: 0];
    86     size   = [bgImg size];
    87     fBmp   = [[NSBitmapImageRep alloc]
    88         initWithBitmapDataPlanes: NULL pixelsWide: size.width
    89         pixelsHigh: size.height bitsPerSample: 8 samplesPerPixel: 4
    90         hasAlpha: YES isPlanar: NO
     92    /* Load the background image for the progress bar and get it as a
     93       32-bit bitmap */
     94    fBackgroundBmp = [[[NSImage imageNamed: @"Progress.png"]
     95                        representations] objectAtIndex: 0];
     96
     97    /* Allocate another bitmap of the same size. We will draw the
     98       progress bar in it */
     99    fProgressBmp = [[NSBitmapImageRep alloc]
     100        initWithBitmapDataPlanes: NULL pixelsWide:
     101        [fBackgroundBmp size].width pixelsHigh:
     102        [fBackgroundBmp size].height bitsPerSample: 8
     103        samplesPerPixel: 4 hasAlpha: YES isPlanar: NO
    91104        colorSpaceName: NSCalibratedRGBColorSpace
    92105        bytesPerRow: 0 bitsPerPixel: 0];
     
    95108}
    96109
     110/***********************************************************************
     111 * setStat
     112 ***********************************************************************
     113 * Readies ourselves to draw updated info.
     114 **********************************************************************/
    97115- (void) setStat: (tr_stat_t *) stat
    98116{
    99117    int i;
     118    uint8_t * in, * out;
    100119
    101120    fStat = stat;
    102121
    103     fProgressString = [NSString stringWithFormat:
    104         @"%.2f %%", 100.0 * fStat->progress];
     122    /* Update the strings to be displayed */
    105123    fDlString = [NSString stringWithFormat:
    106124        @"DL: %.2f KB/s", fStat->rateDownload];
     
    108126        @"UL: %.2f KB/s", fStat->rateUpload];
    109127
    110     for( i = 0; i < [fBmp size].height; i++ )
    111     {
    112         memcpy( [fBmp bitmapData] + i * [fBmp bytesPerRow],
    113                 [fBgBmp bitmapData] + i * [fBgBmp bytesPerRow],
    114                 [fBmp size].width * 4 );
    115     }
    116 
     128    /* Reset our bitmap to the background image... */
     129    in  = [fBackgroundBmp bitmapData];
     130    out = [fProgressBmp bitmapData];
     131    for( i = 0; i < [fProgressBmp size].height; i++ )
     132    {
     133        memcpy( out, in, [fProgressBmp size].width * 4 );
     134        in  += [fBackgroundBmp bytesPerRow];
     135        out += [fProgressBmp bytesPerRow];
     136    }
     137
     138    /* ...and redraw the progress bar on the top of it */
    117139    if( [[NSUserDefaults standardUserDefaults]
    118140            boolForKey:@"UseAdvancedBar"])
     
    126148}
    127149
     150/***********************************************************************
     151 * buildSimpleBar
     152 **********************************************************************/
    128153- (void) buildSimpleBar
    129154{
    130     int        h, w;
     155    int        h, w, end, pixelsPerRow;
    131156    uint32_t * p;
     157    uint32_t * colors;
     158
     159    pixelsPerRow = [fProgressBmp bytesPerRow] / 4;
     160
     161    /* The background image is 124*18 pixels, but the actual
     162       progress bar is 120*14 : the first two columns, the last
     163       two columns and the last four lines contain the shadow. */
     164
     165    p      = (uint32_t *) [fProgressBmp bitmapData];
     166    p     += 2;
     167    end    = lrintf( floor( fStat->progress * 120 ) );
     168    colors = ( fStat->status & TR_STATUS_SEED ) ? kGreen : kBlue2;
    132169
    133170    for( h = 0; h < 14; h++ )
    134171    {
    135         p = (uint32_t *) ( [fBmp bitmapData] +
    136                 h * [fBmp bytesPerRow] ) + 2;
    137 
    138         for( w = 0; w < 120; w++ )
    139         {
    140             if( w >= (int) ( fStat->progress * 120 ) )
    141             {
    142                 break;
    143             }
    144 
    145             if( fStat->status & TR_STATUS_SEED )
    146             {
    147                 *p = kGreen[h];
    148             }
    149             else
    150             {
    151                 *p = kBlue2[h];
    152             }
    153             p++;
    154         }
    155     }
    156 }
    157 
     172        for( w = 0; w < end; w++ )
     173        {
     174            p[w] = colors[h];
     175        }
     176        p += pixelsPerRow;
     177    }
     178}
     179
     180/***********************************************************************
     181 * buildAdvancedBar
     182 **********************************************************************/
    158183- (void) buildAdvancedBar
    159184{
    160     int        h, w;
     185    int        h, w, end, pixelsPerRow;
    161186    uint32_t * p;
    162 
    163     for( h = 0; h < 14; h++ )
    164     {
    165         p = (uint32_t *) ( [fBmp bitmapData] +
    166                 h * [fBmp bytesPerRow] ) + 2;
    167 
    168         for( w = 0; w < 120; w++ )
    169         {
    170             if( fStat->status & TR_STATUS_SEED )
    171             {
    172                 *p = kGreen[h];
    173             }
    174             else
    175             {
    176                 /* Download is not finished yet */
    177                 if( h < 2 )
    178                 {
    179                     /* First two lines: dark blue to show progression */
    180                     if( w >= (int) ( fStat->progress * 120 ) )
    181                     {
    182                         break;
    183                     }
    184                     *p = kBlue4[h];
    185                 }
    186                 else
    187                 {
    188                     /* Lines 2 to X: blue or grey depending on whether
    189                        we have the piece or not */
    190                     if( fStat->pieces[w] < 0 )
    191                     {
    192                         *p = kGray[h];
    193                     }
    194                     else if( fStat->pieces[w] < 1 )
    195                     {
    196                         *p = kRed[h];
    197                     }
    198                     else if( fStat->pieces[w] < 2 )
    199                     {
    200                         *p = kBlue1[h];
    201                     }
    202                     else if( fStat->pieces[w] < 3 )
    203                     {
    204                         *p = kBlue2[h];
    205                     }
    206                     else
    207                     {
    208                         *p = kBlue3[h];
    209                     }
    210                 }
    211             }
    212 
    213             p++;
    214         }
    215     }
    216 }
    217 
     187    uint32_t * colors;
     188
     189    if( fStat->status & TR_STATUS_SEED )
     190    {
     191        /* All green, same as the simple bar */
     192        [self buildSimpleBar];
     193        return;
     194    }
     195
     196    pixelsPerRow = [fProgressBmp bytesPerRow] / 4;
     197
     198    /* First two lines: dark blue to show progression */
     199    p    = (uint32_t *) [fProgressBmp bitmapData];
     200    p   += 2;
     201    end  = lrintf( floor( fStat->progress * 120 ) );
     202    for( h = 0; h < 2; h++ )
     203    {
     204        for( w = 0; w < end; w++ )
     205        {
     206            p[w] = kBlue4[h];
     207        }
     208        p += pixelsPerRow;
     209    }
     210
     211    /* Lines 2 to 14: blue or grey depending on whether
     212       we have the piece or not */
     213    for( w = 0; w < 120; w++ )
     214    {
     215        /* Point to pixel ( 2 + w, 2 ). We will then draw
     216           "vertically" */
     217        p  = (uint32_t *) ( [fProgressBmp bitmapData] +
     218                2 * [fProgressBmp bytesPerRow] );
     219        p += 2 + w;
     220
     221        if( fStat->pieces[w] < 0 )
     222        {
     223            colors = kGray;
     224        }
     225        else if( fStat->pieces[w] < 1 )
     226        {
     227            colors = kRed;
     228        }
     229        else if( fStat->pieces[w] < 2 )
     230        {
     231            colors = kBlue1;
     232        }
     233        else if( fStat->pieces[w] < 3 )
     234        {
     235            colors = kBlue2;
     236        }
     237        else
     238        {
     239            colors = kBlue3;
     240        }
     241
     242        for( h = 2; h < 14; h++ )
     243        {
     244            p[0]  = colors[h];
     245            p    += pixelsPerRow;
     246        }
     247    }
     248}
     249
     250/***********************************************************************
     251 * drawWithFrame
     252 ***********************************************************************
     253 * We have the strings, we have the bitmap. Let's just draw them where
     254 * they belong.
     255 **********************************************************************/
    218256- (void) drawWithFrame: (NSRect) cellFrame inView: (NSView *) view
    219257{
    220258    NSImage * img;
     259    NSMutableDictionary * attributes;
     260    NSPoint pen;
    221261
    222262    if( ![view lockFocusIfCanDraw] )
     
    225265    }
    226266
    227     NSMutableDictionary * attributes;
    228     NSPoint pen = cellFrame.origin;
    229 
    230     attributes = [NSMutableDictionary dictionaryWithCapacity: 1];
    231     [attributes setObject: [NSFont messageFontOfSize:12.0]
    232         forKey: NSFontAttributeName];
    233 
     267    pen = cellFrame.origin;
     268
     269    /* Init an NSImage with our bitmap in order to draw it. We need to
     270       do this every time, or for some reason it won't draw if the
     271       display is set to thousands of colors when Transmission was
     272       started */
     273    img = [[NSImage alloc] initWithSize: [fProgressBmp size]];
     274    [img addRepresentation: fProgressBmp];
     275    [img setFlipped: YES];
     276
     277    /* Actually draw the bar */
    234278    pen.x += 5; pen.y += 5;
    235 
    236     img = [[NSImage alloc] initWithSize: [fBmp size]];
    237     [img addRepresentation: fBmp];
    238     [img setFlipped: YES];
    239     [img drawAtPoint: pen fromRect:
    240         NSMakeRect( 0, 0, [fBmp size].width, [fBmp size].height )
     279    [img drawAtPoint: pen fromRect: NSMakeRect( 0, 0,
     280            [fProgressBmp size].width, [fProgressBmp size].height )
    241281        operation: NSCompositeSourceOver fraction: 1.0];
     282
    242283    [img release];
    243284
    244     [attributes setObject: [NSFont messageFontOfSize:10.0]
    245         forKey: NSFontAttributeName];
    246 
     285    /* Draw the strings with font 10 */
     286    attributes = [NSDictionary dictionaryWithObject:
     287        [NSFont messageFontOfSize: 10.0] forKey: NSFontAttributeName];
    247288    pen.x += 5; pen.y += 20;
    248289    [fDlString drawAtPoint: pen withAttributes: attributes];
    249 
    250290    pen.x += 0; pen.y += 15;
    251291    [fUlString drawAtPoint: pen withAttributes: attributes];
  • trunk/macosx/TorrentTableView.m

    r6 r7  
    88    fStat = stat;
    99    [self reloadData];
    10 }
    11 
    12 - (void) revealInFinder: (int) row
    13 {
    14     NSString * string;
    15     NSAppleScript * appleScript;
    16     NSDictionary * error;
    17 
    18     string = [NSString stringWithFormat: @"tell application "
    19         "\"Finder\"\nactivate\nreveal (POSIX file \"%@/%@\")\nend tell",
    20         [NSString stringWithUTF8String: fStat[row].folder],
    21         [NSString stringWithUTF8String: fStat[row].info.name]];
    22     appleScript = [[NSAppleScript alloc] initWithSource: string];
    23     if( ![appleScript executeAndReturnError: &error] )
    24     {
    25         printf( "Reveal in Finder: AppleScript failed\n" );
    26     }
    27     [appleScript release];
    2810}
    2911
     
    10789    else if( [self pointInRevealRect: point] )
    10890    {
    109         [fController revealInFinder: [NSString stringWithFormat:
     91        [fController finderReveal: [NSString stringWithFormat:
    11092            @"%@/%@", [NSString stringWithUTF8String: fStat[row].folder],
    11193            [NSString stringWithUTF8String: fStat[row].info.name]]];
  • trunk/macosx/Transmission.xcodeproj/project.pbxproj

    r6 r7  
    1919                4D752E930913C949008EAAD4 /* Preferences.png in Resources */ = {isa = PBXBuildFile; fileRef = 4D752E920913C949008EAAD4 /* Preferences.png */; };
    2020                4D813EB508AA43AC00191DB4 /* Progress.png in Resources */ = {isa = PBXBuildFile; fileRef = 4D813EB408AA43AC00191DB4 /* Progress.png */; };
    21                 4D81E2E4092EF0CB00F24127 /* Growl.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4D81E2E3092EF0CB00F24127 /* Growl.framework */; };
    22                 4D81E309092EF26F00F24127 /* Growl.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4D81E2E3092EF0CB00F24127 /* Growl.framework */; };
    2321                4DA6FDBA0911233800450CB1 /* PauseOn.png in Resources */ = {isa = PBXBuildFile; fileRef = 4DA6FDB80911233800450CB1 /* PauseOn.png */; };
    2422                4DA6FDBB0911233800450CB1 /* PauseOff.png in Resources */ = {isa = PBXBuildFile; fileRef = 4DA6FDB90911233800450CB1 /* PauseOff.png */; };
     
    6260                };
    6361/* End PBXBuildStyle section */
    64 
    65 /* Begin PBXCopyFilesBuildPhase section */
    66                 4D81E301092EF24500F24127 /* CopyFiles */ = {
    67                         isa = PBXCopyFilesBuildPhase;
    68                         buildActionMask = 2147483647;
    69                         dstPath = "";
    70                         dstSubfolderSpec = 10;
    71                         files = (
    72                                 4D81E309092EF26F00F24127 /* Growl.framework in CopyFiles */,
    73                         );
    74                         runOnlyForDeploymentPostprocessing = 0;
    75                 };
    76 /* End PBXCopyFilesBuildPhase section */
    7762
    7863/* Begin PBXFileReference section */
     
    10085                4D752E920913C949008EAAD4 /* Preferences.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Preferences.png; path = Images/Preferences.png; sourceTree = "<group>"; };
    10186                4D813EB408AA43AC00191DB4 /* Progress.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Progress.png; path = Images/Progress.png; sourceTree = "<group>"; };
    102                 4D81E2E3092EF0CB00F24127 /* Growl.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Growl.framework; path = Frameworks/Growl.framework; sourceTree = "<group>"; };
    10387                4DA6FDB80911233800450CB1 /* PauseOn.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = PauseOn.png; path = Images/PauseOn.png; sourceTree = "<group>"; };
    10488                4DA6FDB90911233800450CB1 /* PauseOff.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = PauseOff.png; path = Images/PauseOff.png; sourceTree = "<group>"; };
     
    123107                                4DF0C5AE08991C1600DD8943 /* libtransmission.a in Frameworks */,
    124108                                4D3EA0AA08AE13C600EA10C2 /* IOKit.framework in Frameworks */,
    125                                 4D81E2E4092EF0CB00F24127 /* Growl.framework in Frameworks */,
    126109                        );
    127110                        runOnlyForDeploymentPostprocessing = 0;
     
    151134                        children = (
    152135                                1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */,
    153                                 4D81E2E3092EF0CB00F24127 /* Growl.framework */,
    154136                        );
    155137                        name = "Linked Frameworks";
     
    239221                                8D11072C0486CEB800E47090 /* Sources */,
    240222                                8D11072E0486CEB800E47090 /* Frameworks */,
    241                                 4D81E301092EF24500F24127 /* CopyFiles */,
    242223                        );
    243224                        buildRules = (
  • trunk/transmissioncli.c

    r3 r7  
    4040"  -s, --scrape         Print counts of seeders/leechers and exit\n" \
    4141"  -v, --verbose <int>  Verbose level (0 to 2, default = 0)\n" \
    42 "  -p, --port <int>     Port we should listen on (default = 9090)\n" \
     42"  -p, --port <int>     Port we should listen on (default = %d)\n" \
    4343"  -u, --upload <int>   Maximum upload rate (-1 = no limit, default = 20)\n"
    4444
     
    4747static int             showScrape   = 0;
    4848static int             verboseLevel = 0;
    49 static int             bindPort     = 9090;
     49static int             bindPort     = TR_DEFAULT_PORT;
    5050static int             uploadLimit  = 20;
    5151static char          * torrentPath  = NULL;
     
    6767    if( parseCommandLine( argc, argv ) )
    6868    {
    69         printf( USAGE, argv[0] );
     69        printf( USAGE, argv[0], TR_DEFAULT_PORT );
    7070        return 1;
    7171    }
     
    7373    if( showHelp )
    7474    {
    75         printf( USAGE, argv[0] );
     75        printf( USAGE, argv[0], TR_DEFAULT_PORT );
    7676        return 0;
    7777    }
Note: See TracChangeset for help on using the changeset viewer.