Changeset 13810 for trunk/libtransmission/rpcimpl.c
- Timestamp:
- Jan 20, 2013, 1:31:58 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/rpcimpl.c
r13807 r13810 354 354 } 355 355 356 static void357 torrentRenamePathDone (tr_torrent * tor UNUSED,358 const char * oldpath UNUSED,359 const char * newname UNUSED,360 int error,361 void * user_data)362 {363 *(int*)user_data = error;364 }365 366 static const char *367 torrentRenamePath (tr_session * session,368 tr_variant * args_in,369 tr_variant * args_out UNUSED,370 struct tr_rpc_idle_data * idle_data UNUSED)371 {372 const char * oldpath;373 const char * newname;374 const char * ret = NULL;375 376 if (!tr_variantDictFindStr (args_in, TR_KEY_path, &oldpath, NULL))377 {378 ret = "no path specified";379 }380 else if (!tr_variantDictFindStr (args_in, TR_KEY_name, &newname, NULL))381 {382 ret = "no name specified";383 }384 else385 {386 int torrentCount;387 tr_torrent ** torrents = getTorrents (session, args_in, &torrentCount);388 389 if (torrentCount != 1)390 {391 ret = "torent-rename-path requires 1 torrent";392 }393 else394 {395 int error = -1;396 tr_torrentRenamePath (torrents[0], oldpath, newname, torrentRenamePathDone, &error);397 assert (error != -1);398 399 if (error != 0)400 ret = tr_strerror (error);401 }402 403 tr_free (torrents);404 }405 406 return ret;407 }408 409 356 static const char* 410 357 torrentReannounce (tr_session * session, … … 479 426 480 427 static void 481 addFiles (const tr_torrent * tor, 482 tr_variant * list) 428 addFiles (const tr_torrent * tor, tr_variant * list) 483 429 { 484 430 tr_file_index_t i; … … 1367 1313 1368 1314 static void 1315 torrentRenamePathDone (tr_torrent * tor, 1316 const char * oldpath, 1317 const char * newname, 1318 int error, 1319 void * user_data) 1320 { 1321 const char * result; 1322 struct tr_rpc_idle_data * data = user_data; 1323 1324 tr_variantDictAddInt (data->args_out, TR_KEY_id, tr_torrentId(tor)); 1325 tr_variantDictAddStr (data->args_out, TR_KEY_path, oldpath); 1326 tr_variantDictAddStr (data->args_out, TR_KEY_name, newname); 1327 1328 if (error == 0) 1329 result = NULL; 1330 else 1331 result = tr_strerror (error); 1332 1333 tr_idle_function_done (data, result); 1334 } 1335 1336 static const char* 1337 torrentRenamePath (tr_session * session, 1338 tr_variant * args_in, 1339 tr_variant * args_out UNUSED, 1340 struct tr_rpc_idle_data * idle_data) 1341 { 1342 int torrentCount; 1343 tr_torrent ** torrents; 1344 const char * oldpath = NULL; 1345 const char * newname = NULL; 1346 1347 tr_variantDictFindStr (args_in, TR_KEY_path, &oldpath, NULL); 1348 tr_variantDictFindStr (args_in, TR_KEY_name, &newname, NULL); 1349 torrents = getTorrents (session, args_in, &torrentCount); 1350 1351 if (torrentCount == 1) 1352 tr_torrentRenamePath (torrents[0], oldpath, newname, torrentRenamePathDone, idle_data); 1353 else 1354 tr_idle_function_done (idle_data, "torrent-rename-path requires 1 torrent"); 1355 1356 /* cleanup */ 1357 tr_free (torrents); 1358 return NULL; /* ignored */ 1359 } 1360 1361 /*** 1362 **** 1363 ***/ 1364 1365 static void 1369 1366 portTested (tr_session * session UNUSED, 1370 1367 bool did_connect UNUSED, … … 1395 1392 static const char* 1396 1393 portTest (tr_session * session, 1397 tr_variant 1398 tr_variant 1394 tr_variant * args_in UNUSED, 1395 tr_variant * args_out UNUSED, 1399 1396 struct tr_rpc_idle_data * idle_data) 1400 1397 { … … 1613 1610 static const char* 1614 1611 torrentAdd (tr_session * session, 1615 tr_variant 1616 tr_variant 1612 tr_variant * args_in, 1613 tr_variant * args_out UNUSED, 1617 1614 struct tr_rpc_idle_data * idle_data) 1618 1615 { … … 1987 1984 { "torrent-get", true, torrentGet }, 1988 1985 { "torrent-remove", true, torrentRemove }, 1989 { "torrent-rename-path", true,torrentRenamePath },1986 { "torrent-rename-path", false, torrentRenamePath }, 1990 1987 { "torrent-set", true, torrentSet }, 1991 1988 { "torrent-set-location", true, torrentSetLocation }, … … 2070 2067 2071 2068 buf = tr_variantToBuf (&response, TR_VARIANT_FMT_JSON_LEAN); 2072 (*callback)(session, buf, callback_user_data);2069 (*callback)(session, buf, callback_user_data); 2073 2070 evbuffer_free (buf); 2074 2071 … … 2087 2084 data->callback = callback; 2088 2085 data->callback_user_data = callback_user_data; 2089 (*methods[i].func)(session, args_in, data->args_out, data);2086 (*methods[i].func)(session, args_in, data->args_out, data); 2090 2087 } 2091 2088 }
Note: See TracChangeset
for help on using the changeset viewer.