Changeset 13790
- Timestamp:
- Jan 15, 2013, 6:10:16 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/daemon/remote.c
r13736 r13790 553 553 554 554 static void 555 addIdArg (tr_variant * args, const char * id) 556 { 557 if (!*id) 558 { 559 fprintf (stderr, "No torrent specified! Please use the -t option first.\n"); 560 id = "-1"; /* no torrent will have this ID, so should be a no-op */ 561 } 562 else if (!tr_strcmp0 (id, "active")) 555 addIdArg (tr_variant * args, const char * id, const char * fallback) 556 { 557 if (!id || !*id) 558 { 559 id = fallback; 560 561 if (!id || !*id) 562 { 563 fprintf (stderr, "No torrent specified! Please use the -t option first.\n"); 564 id = "-1"; /* no torrent will have this ID, so will act as a no-op */ 565 } 566 } 567 568 if (!tr_strcmp0 (id, "active")) 563 569 { 564 570 tr_variantDictAddStr (args, TR_KEY_ids, "recently-active"); … … 1895 1901 if (sset != 0) status |= flush (rpcurl, &sset); 1896 1902 if (tadd != 0) status |= flush (rpcurl, &tadd); 1897 if (tset != 0) { addIdArg (tr_variantDictFind (tset, ARGUMENTS), id ); status |= flush (rpcurl, &tset); }1903 if (tset != 0) { addIdArg (tr_variantDictFind (tset, ARGUMENTS), id, NULL); status |= flush (rpcurl, &tset); } 1898 1904 tadd = tr_new0 (tr_variant, 1); 1899 1905 tr_variantInitDict (tadd, 3); … … 1932 1938 case 't': /* set current torrent */ 1933 1939 if (tadd != 0) status |= flush (rpcurl, &tadd); 1934 if (tset != 0) { addIdArg (tr_variantDictFind (tset, ARGUMENTS), id ); status |= flush (rpcurl, &tset); }1940 if (tset != 0) { addIdArg (tr_variantDictFind (tset, ARGUMENTS), id, NULL); status |= flush (rpcurl, &tset); } 1935 1941 tr_strlcpy (id, optarg, sizeof (id)); 1936 1942 break; … … 1974 1980 fields = tr_variantDictAddList (args, TR_KEY_fields, 0); 1975 1981 1976 if (tset != 0) { addIdArg (tr_variantDictFind (tset, ARGUMENTS), id ); status |= flush (rpcurl, &tset); }1982 if (tset != 0) { addIdArg (tr_variantDictFind (tset, ARGUMENTS), id, NULL); status |= flush (rpcurl, &tset); } 1977 1983 1978 1984 switch (c) … … 1981 1987 n = TR_N_ELEMENTS (details_keys); 1982 1988 for (i=0; i<n; ++i) tr_variantListAddQuark (fields, details_keys[i]); 1983 addIdArg (args, id );1989 addIdArg (args, id, NULL); 1984 1990 break; 1985 1991 case 'l': tr_variantDictAddInt (top, TR_KEY_tag, TAG_LIST); 1986 1992 n = TR_N_ELEMENTS (list_keys); 1987 1993 for (i=0; i<n; ++i) tr_variantListAddQuark (fields, list_keys[i]); 1988 addIdArg (args, id );1994 addIdArg (args, id, "all"); 1989 1995 break; 1990 1996 case 940: tr_variantDictAddInt (top, TR_KEY_tag, TAG_FILES); 1991 1997 n = TR_N_ELEMENTS (files_keys); 1992 1998 for (i=0; i<n; ++i) tr_variantListAddQuark (fields, files_keys[i]); 1993 addIdArg (args, id );1999 addIdArg (args, id, NULL); 1994 2000 break; 1995 2001 case 941: tr_variantDictAddInt (top, TR_KEY_tag, TAG_PEERS); 1996 2002 tr_variantListAddStr (fields, "peers"); 1997 addIdArg (args, id );2003 addIdArg (args, id, NULL); 1998 2004 break; 1999 2005 case 942: tr_variantDictAddInt (top, TR_KEY_tag, TAG_PIECES); 2000 2006 tr_variantListAddStr (fields, "pieces"); 2001 2007 tr_variantListAddStr (fields, "pieceCount"); 2002 addIdArg (args, id );2008 addIdArg (args, id, NULL); 2003 2009 break; 2004 2010 case 943: tr_variantDictAddInt (top, TR_KEY_tag, TAG_TRACKERS); 2005 2011 tr_variantListAddStr (fields, "trackerStats"); 2006 addIdArg (args, id );2012 addIdArg (args, id, NULL); 2007 2013 break; 2008 2014 default: assert ("unhandled value" && 0); … … 2213 2219 tr_variantDictAddStr (args, TR_KEY_location, optarg); 2214 2220 tr_variantDictAddBool (args, TR_KEY_move, false); 2215 addIdArg (args, id );2221 addIdArg (args, id, NULL); 2216 2222 status |= flush (rpcurl, &top); 2217 2223 break; … … 2237 2243 tr_variantInitDict (top, 2); 2238 2244 tr_variantDictAddStr (top, TR_KEY_method, "torrent-start"); 2239 addIdArg (tr_variantDictAddDict (top, ARGUMENTS, 1), id );2245 addIdArg (tr_variantDictAddDict (top, ARGUMENTS, 1), id, NULL); 2240 2246 status |= flush (rpcurl, &top); 2241 2247 } … … 2250 2256 tr_variantInitDict (top, 2); 2251 2257 tr_variantDictAddStr (top, TR_KEY_method, "torrent-stop"); 2252 addIdArg (tr_variantDictAddDict (top, ARGUMENTS, 1), id );2258 addIdArg (tr_variantDictAddDict (top, ARGUMENTS, 1), id, NULL); 2253 2259 status |= flush (rpcurl, &top); 2254 2260 } … … 2304 2310 { 2305 2311 tr_variant * top; 2306 if (tset != 0) { addIdArg (tr_variantDictFind (tset, ARGUMENTS), id ); status |= flush (rpcurl, &tset); }2312 if (tset != 0) { addIdArg (tr_variantDictFind (tset, ARGUMENTS), id, NULL); status |= flush (rpcurl, &tset); } 2307 2313 top = tr_new0 (tr_variant, 1); 2308 2314 tr_variantInitDict (top, 2); 2309 2315 tr_variantDictAddStr (top, TR_KEY_method, "torrent-reannounce"); 2310 addIdArg (tr_variantDictAddDict (top, ARGUMENTS, 1), id );2316 addIdArg (tr_variantDictAddDict (top, ARGUMENTS, 1), id, NULL); 2311 2317 status |= flush (rpcurl, &top); 2312 2318 break; … … 2315 2321 { 2316 2322 tr_variant * top; 2317 if (tset != 0) { addIdArg (tr_variantDictFind (tset, ARGUMENTS), id ); status |= flush (rpcurl, &tset); }2323 if (tset != 0) { addIdArg (tr_variantDictFind (tset, ARGUMENTS), id, NULL); status |= flush (rpcurl, &tset); } 2318 2324 top = tr_new0 (tr_variant, 1); 2319 2325 tr_variantInitDict (top, 2); 2320 2326 tr_variantDictAddStr (top, TR_KEY_method, "torrent-verify"); 2321 addIdArg (tr_variantDictAddDict (top, ARGUMENTS, 1), id );2327 addIdArg (tr_variantDictAddDict (top, ARGUMENTS, 1), id, NULL); 2322 2328 status |= flush (rpcurl, &top); 2323 2329 break; … … 2332 2338 args = tr_variantDictAddDict (top, ARGUMENTS, 2); 2333 2339 tr_variantDictAddBool (args, TR_KEY_delete_local_data, c=='R'); 2334 addIdArg (args, id );2340 addIdArg (args, id, NULL); 2335 2341 status |= flush (rpcurl, &top); 2336 2342 break; … … 2345 2351 tr_variantDictAddStr (args, TR_KEY_location, optarg); 2346 2352 tr_variantDictAddBool (args, TR_KEY_move, true); 2347 addIdArg (args, id );2353 addIdArg (args, id, NULL); 2348 2354 status |= flush (rpcurl, &top); 2349 2355 break; … … 2359 2365 2360 2366 if (tadd != 0) status |= flush (rpcurl, &tadd); 2361 if (tset != 0) { addIdArg (tr_variantDictFind (tset, ARGUMENTS), id ); status |= flush (rpcurl, &tset); }2367 if (tset != 0) { addIdArg (tr_variantDictFind (tset, ARGUMENTS), id, NULL); status |= flush (rpcurl, &tset); } 2362 2368 if (sset != 0) status |= flush (rpcurl, &sset); 2363 2369 return status;
Note: See TracChangeset
for help on using the changeset viewer.