Changeset 14077
- Timestamp:
- May 22, 2013, 8:35:38 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cli/cli.c
r14070 r14077 223 223 main (int argc, char ** argv) 224 224 { 225 int error;226 225 tr_session * h; 227 226 tr_ctor * ctor; … … 311 310 tr_free (fileContents); 312 311 313 tor = tr_torrentNew (ctor, &error);312 tor = tr_torrentNew (ctor, NULL, NULL); 314 313 tr_ctorFree (ctor); 315 314 if (!tor) -
trunk/daemon/daemon.c
r13969 r14077 264 264 if (!err) 265 265 { 266 tr_torrentNew (ctor, &err );266 tr_torrentNew (ctor, &err, NULL); 267 267 268 268 if (err == TR_PARSE_ERR) -
trunk/extras/rpc-spec.txt
r14025 r14077 383 383 <http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTCOOKIE> 384 384 385 Response arguments: on success, a "torrent-added" object in the385 Response arguments: On success, a "torrent-added" object in the 386 386 form of one of 3.3's tr_info objects with the 387 387 fields for id, name, and hashString. 388 389 On failure due to a duplicate torrent existing, 390 a "torrent-duplicate" object in the same form. 388 391 389 392 3.5. Removing a Torrent … … 762 765 | | yes | torrent-rename-path | new method 763 766 | | yes | free-space | new method 767 | | yes | torrent-add | new return return arg "torrent-duplicate" 764 768 765 769 5.1. Upcoming Breakage -
trunk/gtk/open-dialog.c
r14018 r14077 187 187 int err = 0; 188 188 int new_file = 0; 189 int duplicate_id = 0; 189 190 tr_torrent * torrent; 190 191 … … 201 202 tr_ctorSetDeleteSource (o->ctor, FALSE); 202 203 203 if ((torrent = tr_torrentNew (o->ctor, &err )))204 if ((torrent = tr_torrentNew (o->ctor, &err, &duplicate_id))) 204 205 { 205 206 removeOldTorrent (o); … … 208 209 else if (new_file) 209 210 { 210 gtr_add_torrent_error_dialog (GTK_WIDGET (b), err, o->filename); 211 tr_torrent * tor; 212 213 if (duplicate_id) 214 tor = gtr_core_find_torrent (o->core, duplicate_id); 215 else 216 tor = NULL; 217 218 gtr_add_torrent_error_dialog (GTK_WIDGET (b), err, tor, o->filename); 211 219 } 212 220 -
trunk/gtk/tr-core.c
r14018 r14077 1103 1103 core_create_new_torrent (TrCore * core, tr_ctor * ctor) 1104 1104 { 1105 int errcode = 0;1106 1105 tr_torrent * tor; 1107 1106 bool do_trash = false; … … 1112 1111 tr_ctorGetDeleteSource (ctor, &do_trash); 1113 1112 tr_ctorSetDeleteSource (ctor, FALSE); 1114 tor = tr_torrentNew (ctor, &errcode);1113 tor = tr_torrentNew (ctor, NULL, NULL); 1115 1114 1116 1115 if (tor && do_trash) … … 1128 1127 } 1129 1128 1130 1129 return tor; 1131 1130 } 1132 1131 -
trunk/gtk/util.c
r14018 r14077 218 218 219 219 void 220 gtr_add_torrent_error_dialog (GtkWidget * child, int err, const char * file) 220 gtr_add_torrent_error_dialog (GtkWidget * child, 221 int err, 222 tr_torrent * duplicate_torrent, 223 const char * filename) 221 224 { 222 225 char * secondary; 223 const char * fmt;224 226 GtkWidget * w; 225 227 GtkWindow * win = getWindow (child); 226 228 227 switch (err) 228 { 229 case TR_PARSE_ERR: fmt = _("The torrent file \"%s\" contains invalid data."); break; 230 case TR_PARSE_DUPLICATE: fmt = _("The torrent file \"%s\" is already in use."); break; 231 default: fmt = _("The torrent file \"%s\" encountered an unknown error."); break; 232 } 233 234 secondary = g_strdup_printf (fmt, file); 229 if (err == TR_PARSE_ERR) 230 secondary = g_strdup_printf (_("The torrent file \"%s\" contains invalid data."), filename); 231 else if (err == TR_PARSE_DUPLICATE) 232 secondary = g_strdup_printf (_("The torrent file \"%s\" is already in use by \"%s.\""), filename, tr_torrentName (duplicate_torrent)); 233 else 234 secondary = g_strdup_printf (_("The torrent file \"%s\" encountered an unknown error."), filename); 235 235 236 236 w = gtk_message_dialog_new (win, -
trunk/gtk/util.h
r13991 r14077 126 126 void gtr_add_torrent_error_dialog (GtkWidget * window_or_child, 127 127 int err, 128 tr_torrent * duplicate_torrent, 128 129 const char * filename); 129 130 -
trunk/libtransmission/libtransmission-test.c
r13969 r14077 328 328 /* create the torrent */ 329 329 err = 0; 330 tor = tr_torrentNew (ctor, &err );330 tor = tr_torrentNew (ctor, &err, NULL); 331 331 assert (!err); 332 332 -
trunk/libtransmission/quark.c
r14067 r14077 345 345 { "torrent-complete-sound-command", 30 }, 346 346 { "torrent-complete-sound-enabled", 30 }, 347 { "torrent-duplicate", 17 }, 347 348 { "torrent-get", 11 }, 348 349 { "torrent-set", 11 }, -
trunk/libtransmission/quark.h
r14009 r14077 355 355 TR_KEY_torrent_complete_sound_command, 356 356 TR_KEY_torrent_complete_sound_enabled, 357 TR_KEY_torrent_duplicate, 357 358 TR_KEY_torrent_get, 358 359 TR_KEY_torrent_set, -
trunk/libtransmission/rename-test.c
r13969 r14077 134 134 /* create the torrent */ 135 135 err = 0; 136 tor = tr_torrentNew (ctor, &err );136 tor = tr_torrentNew (ctor, &err, NULL); 137 137 assert (!err); 138 138 -
trunk/libtransmission/rpcimpl.c
r14070 r14077 1516 1516 addTorrentImpl (struct tr_rpc_idle_data * data, tr_ctor * ctor) 1517 1517 { 1518 int err = 0; 1519 const char * result = NULL; 1520 tr_torrent * tor = tr_torrentNew (ctor, &err); 1521 1522 tr_ctorFree (ctor); 1523 1524 if (tor) 1525 { 1526 tr_variant fields; 1527 tr_variantInitList (&fields, 3); 1528 tr_variantListAddStr (&fields, "id"); 1529 tr_variantListAddStr (&fields, "name"); 1530 tr_variantListAddStr (&fields, "hashString"); 1531 addInfo (tor, tr_variantDictAdd (data->args_out, TR_KEY_torrent_added), &fields); 1532 notify (data->session, TR_RPC_TORRENT_ADDED, tor); 1533 tr_variantFree (&fields); 1534 } 1535 else if (err == TR_PARSE_DUPLICATE) 1536 { 1537 result = "duplicate torrent"; 1538 } 1539 else if (err == TR_PARSE_ERR) 1540 { 1541 result = "invalid or corrupt torrent file"; 1542 } 1543 1544 tr_idle_function_done (data, result); 1518 int err; 1519 int duplicate_id; 1520 const char * result; 1521 tr_torrent * tor; 1522 tr_quark key; 1523 1524 err = 0; 1525 duplicate_id = 0; 1526 tor = tr_torrentNew (ctor, &err, &duplicate_id); 1527 tr_ctorFree (ctor); 1528 1529 if (!err) 1530 { 1531 key = TR_KEY_torrent_added; 1532 result = NULL; 1533 } 1534 else if (err == TR_PARSE_ERR) 1535 { 1536 result = "invalid or corrupt torrent file"; 1537 } 1538 else if (err == TR_PARSE_DUPLICATE) 1539 { 1540 tor = tr_torrentFindFromId (data->session, duplicate_id); 1541 key = TR_KEY_torrent_duplicate; 1542 result = "duplicate torrent"; 1543 } 1544 1545 if (tor != NULL) 1546 { 1547 tr_variant fields; 1548 tr_variantInitList (&fields, 3); 1549 tr_variantListAddStr (&fields, "id"); 1550 tr_variantListAddStr (&fields, "name"); 1551 tr_variantListAddStr (&fields, "hashString"); 1552 addInfo (tor, tr_variantDictAdd (data->args_out, key), &fields); 1553 notify (data->session, TR_RPC_TORRENT_ADDED, tor); 1554 tr_variantFree (&fields); 1555 } 1556 1557 tr_idle_function_done (data, result); 1545 1558 } 1546 1559 -
trunk/libtransmission/session.c
r14023 r14077 1938 1938 char * path = tr_buildPath (dirname, d->d_name, NULL); 1939 1939 tr_ctorSetMetainfoFromFile (data->ctor, path); 1940 if ((tor = tr_torrentNew (data->ctor, NULL )))1940 if ((tor = tr_torrentNew (data->ctor, NULL, NULL))) 1941 1941 { 1942 1942 tr_list_prepend (&list, tor); -
trunk/libtransmission/torrent.c
r13991 r14077 972 972 973 973 static tr_parse_result 974 torrentParseImpl (const tr_ctor * ctor, tr_info * setmeInfo, 975 bool * setmeHasInfo, int * dictLength) 976 { 977 int doFree; 978 bool didParse; 979 bool hasInfo = false; 980 tr_info tmp; 974 torrentParseImpl (const tr_ctor * ctor, 975 tr_info * setmeInfo, 976 bool * setmeHasInfo, 977 int * dictLength, 978 int * setme_duplicate_id) 979 { 980 bool doFree; 981 bool didParse; 982 bool hasInfo = false; 983 tr_info tmp; 981 984 const tr_variant * metainfo; 982 tr_session 985 tr_session * session = tr_ctorGetSession (ctor); 983 986 tr_parse_result result = TR_PARSE_OK; 984 987 … … 1000 1003 result = TR_PARSE_ERR; 1001 1004 1002 if (didParse && session && tr_torrentExists (session, setmeInfo->hash)) 1003 result = TR_PARSE_DUPLICATE; 1005 if (didParse && session && (result == TR_PARSE_OK)) 1006 { 1007 const tr_torrent * const tor = tr_torrentFindFromHash (session, setmeInfo->hash); 1008 1009 if (tor != NULL) 1010 { 1011 result = TR_PARSE_DUPLICATE; 1012 1013 if (setme_duplicate_id != NULL) 1014 *setme_duplicate_id = tr_torrentId (tor); 1015 } 1016 } 1004 1017 1005 1018 if (doFree) … … 1015 1028 tr_torrentParse (const tr_ctor * ctor, tr_info * setmeInfo) 1016 1029 { 1017 return torrentParseImpl (ctor, setmeInfo, NULL, NULL );1030 return torrentParseImpl (ctor, setmeInfo, NULL, NULL, NULL); 1018 1031 } 1019 1032 1020 1033 tr_torrent * 1021 tr_torrentNew (const tr_ctor * ctor, int * setmeError) 1022 { 1023 int len; 1024 bool hasInfo; 1025 tr_info tmpInfo; 1026 tr_parse_result r; 1027 tr_torrent * tor = NULL; 1028 1029 assert (ctor != NULL); 1030 assert (tr_isSession (tr_ctorGetSession (ctor))); 1031 1032 r = torrentParseImpl (ctor, &tmpInfo, &hasInfo, &len); 1033 if (r == TR_PARSE_OK) 1034 { 1035 tor = tr_new0 (tr_torrent, 1); 1036 tor->info = tmpInfo; 1037 if (hasInfo) 1038 tor->infoDictLength = len; 1039 torrentInit (tor, ctor); 1034 tr_torrentNew (const tr_ctor * ctor, int * setme_error, int * setme_duplicate_id) 1035 { 1036 int len; 1037 bool hasInfo; 1038 tr_info tmpInfo; 1039 tr_parse_result r; 1040 tr_torrent * tor = NULL; 1041 1042 assert (ctor != NULL); 1043 assert (tr_isSession (tr_ctorGetSession (ctor))); 1044 1045 r = torrentParseImpl (ctor, &tmpInfo, &hasInfo, &len, setme_duplicate_id); 1046 if (r == TR_PARSE_OK) 1047 { 1048 tor = tr_new0 (tr_torrent, 1); 1049 tor->info = tmpInfo; 1050 1051 if (hasInfo) 1052 tor->infoDictLength = len; 1053 1054 torrentInit (tor, ctor); 1040 1055 } 1041 1056 else 1042 1057 { 1043 1044 1045 1046 if (setmeError)1047 *setmeError = r;1048 } 1049 1050 1058 if (r == TR_PARSE_DUPLICATE) 1059 tr_metainfoFree (&tmpInfo); 1060 1061 if (setme_error != NULL) 1062 *setme_error = r; 1063 } 1064 1065 return tor; 1051 1066 } 1052 1067 -
trunk/libtransmission/transmission.h
r13991 r14077 1062 1062 1063 1063 1064 /** Instantiate a single torrent. 1065 @return 0 on success, 1066 TR_EINVALID if the torrent couldn't be parsed, or 1067 TR_EDUPLICATE if there's already a matching torrent object. */ 1064 /** 1065 * Instantiate a single torrent. 1066 * 1067 * Returns a pointer to the torrent on success, or NULL on failure. 1068 * 1069 * @param setme_error: TR_PARSE_ERR if the parsing failed; 1070 * TR_PARSE_OK if parsing succeeded and it's not a duplicate; 1071 * TR_PARSE_DUPLICATE if parsing succeeded but it's a duplicate. 1072 * 1073 * @param setme_duplicate_id: when setmeError is TR_PARSE_DUPLICATE, 1074 * this field is set to the duplicate torrent's id. 1075 */ 1068 1076 tr_torrent * tr_torrentNew (const tr_ctor * ctor, 1069 int * setmeError); 1077 int * setme_error, 1078 int * setme_duplicate_id); 1070 1079 1071 1080 /** @} */ -
trunk/macosx/Torrent.m
r14037 r14077 1667 1667 1668 1668 if (result == TR_PARSE_OK) 1669 fHandle = tr_torrentNew(ctor, NULL );1669 fHandle = tr_torrentNew(ctor, NULL, NULL); 1670 1670 1671 1671 tr_ctorFree(ctor);
Note: See TracChangeset
for help on using the changeset viewer.