Changeset 269 for trunk/gtk/tr_torrent.c


Ignore:
Timestamp:
May 31, 2006, 11:20:59 PM (16 years ago)
Author:
joshe
Message:

Wait and try to send a stopped event when removing a torrent.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/tr_torrent.c

    r261 r269  
    9191tr_torrent_class_init(gpointer g_class, gpointer g_class_data SHUTUP) {
    9292  GObjectClass *gobject_class = G_OBJECT_CLASS(g_class);
    93   //TrTorrentClass *klass = TR_TORRENT_CLASS(g_class);
     93  TrTorrentClass *klass = TR_TORRENT_CLASS(g_class);
    9494  GParamSpec *pspec;
    9595
     
    118118                               G_PARAM_READWRITE);
    119119  g_object_class_install_property(gobject_class, TR_TORRENT_PAUSED, pspec);
     120
     121  klass->paused_signal_id = g_signal_newv("politely-stopped",
     122                                          G_TYPE_FROM_CLASS(g_class),
     123                                          G_SIGNAL_RUN_LAST, NULL, NULL, NULL,
     124                                          g_cclosure_marshal_VOID__VOID,
     125                                          G_TYPE_NONE, 0, NULL);
    120126}
    121127
     
    127133  self->back = NULL;
    128134  self->dir = NULL;
     135  self->closing = FALSE;
    129136  self->disposed = FALSE;
    130137}
     
    341348    return;
    342349
     350  if(tor->closing)
     351    return;
     352
    343353  state->type = TYPE_DICT;
    344354  state->val.l.vals = g_new0(benc_val_t, len);
     
    379389  return (TR_STATUS_INACTIVE & st->status ? TRUE : FALSE);
    380390}
     391
     392void
     393tr_torrent_stop_politely(TrTorrent *tor) {
     394  tr_stat_t *st;
     395
     396  TR_IS_TORRENT(tor);
     397
     398  if(tor->disposed)
     399    return;
     400
     401  if(!tor->closing) {
     402    st = tr_torrent_stat(tor);
     403    tor->closing = TRUE;
     404    if(TR_STATUS_ACTIVE & st->status)
     405      tr_torrentStop(tor->handle);
     406  }
     407}
     408
     409tr_stat_t *
     410tr_torrent_stat_polite(TrTorrent *tor) {
     411  TrTorrentClass *klass;
     412  tr_stat_t *st = tr_torrentStat(tor->handle);
     413
     414  if(tor->disposed)
     415    return st;
     416
     417  if(tor->closing && TR_STATUS_PAUSE & st->status) {
     418    tor->closing = FALSE;
     419    klass = g_type_class_peek(TR_TORRENT_TYPE);
     420    g_signal_emit(tor, klass->paused_signal_id, 0, NULL);
     421  }
     422
     423  return st;
     424}
Note: See TracChangeset for help on using the changeset viewer.