Changeset 1708 for branches/daemon/daemon/client.c
- Timestamp:
- Apr 12, 2007, 2:41:19 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/daemon/daemon/client.c
r1696 r1708 76 76 { 77 77 int64_t tag; 78 cl_listfunc listcb;79 78 cl_infofunc infocb; 80 cl_hashfunc hashcb;81 79 cl_statfunc statcb; 82 80 RB_ENTRY( resp ) links; … … 546 544 547 545 int 548 client_list( cl_ listfunc func )546 client_list( cl_infofunc func ) 549 547 { 550 548 struct req * req; … … 557 555 } 558 556 559 resp-> listcb = func;557 resp->infocb = func; 560 558 req->types = IPC_INF_NAME | IPC_INF_HASH; 561 559 … … 582 580 583 581 int 584 client_hashids( cl_ hashfunc func )582 client_hashids( cl_infofunc func ) 585 583 { 586 584 struct req * req; … … 593 591 } 594 592 595 resp-> hashcb = func;593 resp->infocb = func; 596 594 req->types = IPC_INF_HASH; 597 595 … … 613 611 resp->statcb = func; 614 612 req->types = IPC_ST_STATE | IPC_ST_ETA | IPC_ST_COMPLETED | 615 IPC_ST_DOWNSPEED | IPC_ST_UPSPEED | IPC_ST_ERROR | IPC_ST_ERRMSG; 613 IPC_ST_DOWNSPEED | IPC_ST_UPSPEED | IPC_ST_DOWNTOTAL | IPC_ST_UPTOTAL | 614 IPC_ST_ERROR | IPC_ST_ERRMSG; 616 615 617 616 return 0; … … 869 868 void * arg UNUSED ) 870 869 { 871 benc_val_t * dict;872 int ii;873 int64_t id, size;874 char * name, * hash;875 struct resp * resp, key;870 benc_val_t * dict; 871 int ii; 872 struct cl_info inf; 873 int64_t id; 874 struct resp * resp, key; 876 875 877 876 assert( IPC_MSG_INFO == msgid ); 878 877 879 if( TYPE_LIST != list->type )878 if( TYPE_LIST != list->type || NULL == resp->infocb ) 880 879 { 881 880 return; … … 899 898 } 900 899 901 id = getinfoint( msgid, dict, IPC_INF_ID, -1 );902 name = getinfostr( msgid, dict, IPC_INF_NAME, NULL );903 hash = getinfostr( msgid, dict, IPC_INF_HASH, NULL );904 size = getinfoint( msgid, dict, IPC_INF_SIZE, -1 );900 id = getinfoint( msgid, dict, IPC_INF_ID, -1 ); 901 inf.name = getinfostr( msgid, dict, IPC_INF_NAME, NULL ); 902 inf.hash = getinfostr( msgid, dict, IPC_INF_HASH, NULL ); 903 inf.size = getinfoint( msgid, dict, IPC_INF_SIZE, -1 ); 905 904 906 905 if( !TORRENT_ID_VALID( id ) ) … … 909 908 } 910 909 911 if( NULL != resp->infocb ) 912 { 913 resp->infocb( id, name, size ); 914 } 915 else if( NULL != resp->listcb ) 916 { 917 resp->listcb( id, name, hash ); 918 } 919 else if( NULL != resp->hashcb ) 920 { 921 resp->hashcb( id, hash ); 922 } 910 inf.id = id; 911 resp->infocb( &inf ); 923 912 } 924 913 … … 931 920 void * arg UNUSED ) 932 921 { 933 benc_val_t * dict;934 int ii;935 int64_t id, eta, done, down, up;936 char * state, * error, * errmsg;937 struct resp * resp, key;922 benc_val_t * dict; 923 int ii; 924 int64_t id; 925 struct cl_stat st; 926 struct resp * resp, key; 938 927 939 928 assert( IPC_MSG_STAT == msgid ); 940 929 941 if( TYPE_LIST != list->type )930 if( TYPE_LIST != list->type || NULL == resp->statcb ) 942 931 { 943 932 return; … … 961 950 } 962 951 963 id = getinfoint( msgid, dict, IPC_ST_ID, -1 ); 964 state = getinfostr( msgid, dict, IPC_ST_STATE, NULL ); 965 eta = getinfoint( msgid, dict, IPC_ST_ETA, -1 ); 966 done = getinfoint( msgid, dict, IPC_ST_COMPLETED, -1 ); 967 down = getinfoint( msgid, dict, IPC_ST_DOWNSPEED, -1 ); 968 up = getinfoint( msgid, dict, IPC_ST_UPSPEED, -1 ); 969 error = getinfostr( msgid, dict, IPC_ST_ERROR, NULL ); 970 errmsg = getinfostr( msgid, dict, IPC_ST_ERRMSG, NULL ); 952 id = getinfoint( msgid, dict, IPC_ST_ID, -1 ); 953 st.state = getinfostr( msgid, dict, IPC_ST_STATE, NULL ); 954 st.eta = getinfoint( msgid, dict, IPC_ST_ETA, -1 ); 955 st.done = getinfoint( msgid, dict, IPC_ST_COMPLETED, -1 ); 956 st.ratedown = getinfoint( msgid, dict, IPC_ST_DOWNSPEED, -1 ); 957 st.rateup = getinfoint( msgid, dict, IPC_ST_UPSPEED, -1 ); 958 st.totaldown = getinfoint( msgid, dict, IPC_ST_DOWNTOTAL, -1 ); 959 st.totalup = getinfoint( msgid, dict, IPC_ST_UPTOTAL, -1 ); 960 st.error = getinfostr( msgid, dict, IPC_ST_ERROR, NULL ); 961 st.errmsg = getinfostr( msgid, dict, IPC_ST_ERRMSG, NULL ); 971 962 972 963 if( !TORRENT_ID_VALID( id ) ) … … 975 966 } 976 967 977 if( NULL != resp->statcb ) 978 { 979 resp->statcb( id, state, eta, done, down, up, error, errmsg ); 980 } 968 st.id = id; 969 resp->statcb( &st ); 981 970 } 982 971 … … 1027 1016 if( NULL != resp->infocb ) 1028 1017 { 1029 resp->infocb( -1, NULL, -1 ); 1030 } 1031 else if( NULL != resp->listcb ) 1032 { 1033 resp->listcb( -1, NULL, NULL ); 1034 } 1035 else if( NULL != resp->hashcb ) 1036 { 1037 resp->hashcb( -1, NULL ); 1018 resp->infocb( NULL ); 1038 1019 } 1039 1020 else if( NULL != resp->statcb ) 1040 1021 { 1041 resp->statcb( -1, NULL, -1, -1, -1, -1, NULL,NULL );1022 resp->statcb( NULL ); 1042 1023 } 1043 1024 }
Note: See TracChangeset
for help on using the changeset viewer.