871 |
} |
} |
872 |
|
|
873 |
|
|
|
|
|
874 |
(*************** |
(*************** |
875 |
|
|
876 |
Decoding of messages from the GUI to the Core |
Decoding of messages from the GUI to the Core |
880 |
let from_gui (proto : int array) opcode s = |
let from_gui (proto : int array) opcode s = |
881 |
try |
try |
882 |
|
|
883 |
let proto = if opcode > from_gui_last_opcode then 0 else proto.(opcode) in |
let proto = if opcode > from_gui_last_opcode then 0 else proto.(opcode) in |
884 |
if !verbose_gui_decoding then |
if !verbose_gui_decoding then |
885 |
lprintf "FROM GUI: Opcode %d\n" opcode; |
lprintf_nl "FROM GUI: Opcode %d" opcode; |
886 |
match opcode with |
match opcode with |
887 |
0 -> GuiProtocol (get_int s 2) |
0 -> GuiProtocol (get_int s 2) |
888 |
|
|
889 |
| 1 -> ConnectMore_query |
| 1 -> ConnectMore_query |
890 |
|
|
891 |
| 2 -> CleanOldServers |
| 2 -> CleanOldServers |
892 |
|
|
893 |
| 3 -> KillServer |
| 3 -> KillServer |
894 |
|
|
895 |
| 4 -> ExtendedSearch (-1, ExtendSearchRemotely) |
| 4 -> ExtendedSearch (-1, ExtendSearchRemotely) |
896 |
|
|
897 |
| 5 |
| 5 |
898 |
| 52 -> |
| 52 -> |
899 |
if proto < 14 then |
if proto < 14 then |
900 |
let pass,_ = get_string s 2 in Password ("admin", pass) |
let pass,_ = get_string s 2 in Password ("admin", pass) |
901 |
else |
else |
902 |
let pass,pos = get_string s 2 in |
let pass,pos = get_string s 2 in |
903 |
let login,pos = get_string s pos in |
let login,pos = get_string s pos in |
904 |
Password (login, pass) |
Password (login, pass) |
905 |
| 6 -> |
|
906 |
|
| 6 -> |
907 |
let local = get_bool s 2 in |
let local = get_bool s 2 in |
908 |
let search, pos = get_search get_query proto s 3 in |
let search, pos = get_search get_query proto s 3 in |
909 |
search.search_type <- if local then LocalSearch else RemoteSearch; |
search.search_type <- if local then LocalSearch else RemoteSearch; |
910 |
Search_query search |
Search_query search |
911 |
| 7 -> |
|
912 |
|
| 7 -> |
913 |
let list, pos = get_list get_string s 2 in |
let list, pos = get_list get_string s 2 in |
914 |
let result_num = get_int s pos in |
let result_num = get_int s pos in |
915 |
Download_query (list, result_num, false) |
Download_query (list, result_num, false) |
916 |
|
|
917 |
| 8 -> let string, pos = get_string s 2 in |
| 8 -> let string, pos = get_string s 2 in |
918 |
lprintf "Received string: [%s]\n" (String.escaped string); |
lprintf_nl "Received string: [%s]" (String.escaped string); |
919 |
Url string |
Url string |
920 |
|
|
921 |
| 9 -> let int = get_int s 2 in RemoveServer_query int |
| 9 -> let int = get_int s 2 in RemoveServer_query int |
922 |
|
|
923 |
| 10 -> |
| 10 -> |
924 |
let list, pos = get_list (fun s pos -> |
let list, pos = get_list (fun s pos -> |
925 |
let s1, pos = get_string s pos in |
let s1, pos = get_string s pos in |
926 |
let s2, pos = get_string s pos in |
let s2, pos = get_string s pos in |
927 |
(s1,s2), pos) s 2 in |
(s1,s2), pos) s 2 in |
928 |
SaveOptions_query list |
SaveOptions_query list |
929 |
|
|
930 |
| 11 -> |
| 11 -> |
931 |
let int = get_int s 2 in |
let int = get_int s 2 in |
932 |
RemoveDownload_query int |
RemoveDownload_query int |
933 |
|
|
934 |
| 12 -> |
| 12 -> |
935 |
let int = get_int s 2 in |
let int = get_int s 2 in |
936 |
ServerUsers_query int |
ServerUsers_query int |
937 |
|
|
938 |
| 13 -> |
| 13 -> |
939 |
let int = get_int s 2 in |
let int = get_int s 2 in |
940 |
let s, pos = get_string s 6 in |
let s, pos = get_string s 6 in |
941 |
SaveFile (int, s) |
SaveFile (int, s) |
942 |
|
|
943 |
| 14 -> |
| 14 -> |
944 |
let int = get_int s 2 in |
let int = get_int s 2 in |
945 |
AddClientFriend int |
AddClientFriend int |
946 |
|
|
947 |
| 15 -> |
| 15 -> |
948 |
let int = get_int s 2 in |
let int = get_int s 2 in |
949 |
AddUserFriend int |
AddUserFriend int |
950 |
|
|
951 |
| 16 -> |
| 16 -> |
952 |
let int = get_int s 2 in |
let int = get_int s 2 in |
953 |
RemoveFriend int |
RemoveFriend int |
954 |
|
|
955 |
| 17 -> RemoveAllFriends |
| 17 -> RemoveAllFriends |
956 |
|
|
957 |
| 18 -> |
| 18 -> |
958 |
let string, pos = get_string s 2 in |
let string, pos = get_string s 2 in |
959 |
FindFriend string |
FindFriend string |
960 |
|
|
961 |
| 19 -> |
| 19 -> |
962 |
let int = get_int s 2 in |
let int = get_int s 2 in |
963 |
ViewUsers int |
ViewUsers int |
964 |
|
|
965 |
| 20 -> |
| 20 -> |
966 |
let int = get_int s 2 in |
let int = get_int s 2 in |
967 |
ConnectAll int |
ConnectAll int |
968 |
|
|
969 |
| 21 -> |
| 21 -> |
970 |
let int = get_int s 2 in |
let int = get_int s 2 in |
971 |
ConnectServer int |
ConnectServer int |
972 |
|
|
973 |
| 22 -> |
| 22 -> |
974 |
let int = get_int s 2 in |
let int = get_int s 2 in |
975 |
DisconnectServer int |
DisconnectServer int |
976 |
|
|
977 |
| 23 -> |
| 23 -> |
978 |
let int = get_int s 2 in |
let int = get_int s 2 in |
979 |
let bool = get_bool s 6 in |
let bool = get_bool s 6 in |
980 |
SwitchDownload (int, bool) |
SwitchDownload (int, bool) |
981 |
|
|
982 |
| 24 -> |
| 24 -> |
983 |
let int = get_int s 2 in |
let int = get_int s 2 in |
984 |
VerifyAllChunks int |
VerifyAllChunks int |
985 |
|
|
986 |
| 25 -> |
| 25 -> |
987 |
let int = get_int s 2 in |
let int = get_int s 2 in |
988 |
QueryFormat int |
QueryFormat int |
989 |
|
|
990 |
| 26 -> |
| 26 -> |
991 |
let int = get_int s 2 in |
let int = get_int s 2 in |
992 |
let tag, pos = get_mp3 s 6 in |
let tag, pos = get_mp3 s 6 in |
993 |
ModifyMp3Tags (int, tag) |
ModifyMp3Tags (int, tag) |
994 |
|
|
995 |
| 27 -> |
| 27 -> |
996 |
let int = get_int s 2 in |
let int = get_int s 2 in |
997 |
CloseSearch (int, true) |
CloseSearch (int, true) |
998 |
|
|
999 |
| 28 -> |
| 28 -> |
1000 |
let s1, pos = get_string s 2 in |
let s1, pos = get_string s 2 in |
1001 |
let s2, pos = get_string s pos in |
let s2, pos = get_string s pos in |
1002 |
SetOption (s1, s2) |
SetOption (s1, s2) |
1003 |
|
|
1004 |
| 29 -> |
| 29 -> |
1005 |
let s1, pos = get_string s 2 in |
let s1, pos = get_string s 2 in |
1006 |
Command s1 |
Command s1 |
1007 |
|
|
1008 |
| 30 -> |
| 30 -> |
1009 |
let int = get_int s 2 in |
let int = get_int s 2 in |
1010 |
Preview int |
Preview int |
1011 |
|
|
1012 |
| 31 -> |
| 31 -> |
1013 |
let int = get_int s 2 in |
let int = get_int s 2 in |
1014 |
ConnectFriend int |
ConnectFriend int |
1015 |
|
|
1016 |
| 32 -> |
| 32 -> |
1017 |
let int = get_int s 2 in |
let int = get_int s 2 in |
1018 |
GetServer_users int |
GetServer_users int |
1019 |
|
|
1020 |
| 33 -> |
| 33 -> |
1021 |
let int = get_int s 2 in |
let int = get_int s 2 in |
1022 |
GetClient_files int |
GetClient_files int |
1023 |
|
|
1024 |
| 34 -> |
| 34 -> |
1025 |
let int = get_int s 2 in |
let int = get_int s 2 in |
1026 |
GetFile_locations int |
GetFile_locations int |
1027 |
|
|
1028 |
| 35 -> |
| 35 -> |
1029 |
let int = get_int s 2 in |
let int = get_int s 2 in |
1030 |
GetServer_info int |
GetServer_info int |
1031 |
|
|
1032 |
| 36 -> |
| 36 -> |
1033 |
let int = get_int s 2 in |
let int = get_int s 2 in |
1034 |
GetClient_info int |
GetClient_info int |
1035 |
|
|
1036 |
| 37 -> |
| 37 -> |
1037 |
let int = get_int s 2 in |
let int = get_int s 2 in |
1038 |
GetFile_info int |
GetFile_info int |
1039 |
|
|
1040 |
| 38 -> |
| 38 -> |
1041 |
let int = get_int s 2 in |
let int = get_int s 2 in |
1042 |
GetUser_info int |
GetUser_info int |
1043 |
|
|
1044 |
| 39 -> |
| 39 -> |
1045 |
let int = get_int s 2 in |
let int = get_int s 2 in |
1046 |
let room_message, pos = get_message s 6 in |
let room_message, pos = get_message s 6 in |
|
|
|
1047 |
let msg = SendMessage (int, room_message) in |
let msg = SendMessage (int, room_message) in |
|
|
|
1048 |
begin |
begin |
1049 |
match msg with |
match msg with |
1050 |
(* Change private message from former GUIs to MessageToClient ! *) |
(* Change private message from former GUIs to MessageToClient ! *) |
1052 |
MessageToClient (num,s) |
MessageToClient (num,s) |
1053 |
| _ -> msg |
| _ -> msg |
1054 |
end |
end |
1055 |
|
|
1056 |
| 40 -> |
| 40 -> |
1057 |
let int = get_int s 2 in |
let int = get_int s 2 in |
1058 |
let bool = get_bool s 6 in |
let bool = get_bool s 6 in |
1059 |
EnableNetwork (int, bool) |
EnableNetwork (int, bool) |
1060 |
|
|
1061 |
| 41 -> |
| 41 -> |
1062 |
let int = get_int s 2 in |
let int = get_int s 2 in |
1063 |
BrowseUser int |
BrowseUser int |
1064 |
|
|
1065 |
| 42 -> let s, pos = get_search get_query proto s 2 in Search_query s |
| 42 -> let s, pos = get_search get_query proto s 2 in Search_query s |
1066 |
|
|
1067 |
| 43 -> |
| 43 -> |
1068 |
let int = get_int s 2 in |
let int = get_int s 2 in |
1069 |
let message, pos = get_string s 6 in |
let message, pos = get_string s 6 in |
1070 |
MessageToClient (int, message) |
MessageToClient (int, message) |
1071 |
|
|
1072 |
| 44 -> GetConnectedServers |
| 44 -> GetConnectedServers |
1073 |
|
|
1074 |
| 45 -> GetDownloadFiles |
| 45 -> GetDownloadFiles |
1075 |
|
|
1076 |
| 46 -> GetDownloadedFiles |
| 46 -> GetDownloadedFiles |
1077 |
| 47 -> |
|
1078 |
|
| 47 -> |
1079 |
let list, pos = get_list (fun s pos -> |
let list, pos = get_list (fun s pos -> |
1080 |
(get_int s pos, 1 = get_uint8 s (pos+4)), pos+5) s 2 in |
(get_int s pos, 1 = get_uint8 s (pos+4)), pos+5) s 2 in |
1081 |
GuiExtensions list |
GuiExtensions list |
1082 |
|
|
1083 |
| 48 -> |
| 48 -> |
1084 |
SetRoomState (get_int s 2, get_room_state s 6) |
SetRoomState (get_int s 2, get_room_state s 6) |
1085 |
|
|
1086 |
| 49 -> RefreshUploadStats |
| 49 -> RefreshUploadStats |
1087 |
|
|
1088 |
| 50 -> |
| 50 -> |
1089 |
let list, pos = get_list get_string s 2 in |
let list, pos = get_list get_string s 2 in |
1090 |
let result_num = get_int s pos in |
let result_num = get_int s pos in |
1093 |
|
|
1094 |
| 51 -> |
| 51 -> |
1095 |
SetFilePriority(get_int s 2, get_int s 6) |
SetFilePriority(get_int s 2, get_int s 6) |
1096 |
|
|
1097 |
|
(* 52 -> see 5 *) |
1098 |
|
|
1099 |
| 53 -> |
| 53 -> |
1100 |
let int = get_int s 2 in |
let int = get_int s 2 in |
1101 |
let bool = get_bool s 6 in |
let bool = get_bool s 6 in |
1106 |
let ip = get_ip s 6 in |
let ip = get_ip s 6 in |
1107 |
let port = get_int16 s 10 in |
let port = get_int16 s 10 in |
1108 |
AddServer_query (net, ip, port) |
AddServer_query (net, ip, port) |
1109 |
|
|
1110 |
| 55 -> |
| 55 -> |
1111 |
let list, pos = get_list (fun s pos -> |
let list, pos = get_list (fun s pos -> |
1112 |
let opcode = get_int16 s pos in |
let opcode = get_int16 s pos in |
1116 |
) s 2 in |
) s 2 in |
1117 |
MessageVersions list |
MessageVersions list |
1118 |
|
|
|
|
|
1119 |
| 56 -> |
| 56 -> |
1120 |
let num = get_int s 2 in |
let num = get_int s 2 in |
1121 |
let new_name, pos = get_string s 6 in |
let new_name, pos = get_string s 6 in |
1129 |
|
|
1130 |
| 59 -> |
| 59 -> |
1131 |
GetSearches |
GetSearches |
1132 |
|
|
1133 |
| 60 -> |
| 60 -> |
1134 |
GetSearch (get_int s 2) |
GetSearch (get_int s 2) |
1135 |
|
|
1136 |
| 61 -> |
| 61 -> |
1137 |
ConnectClient (get_int s 2) |
ConnectClient (get_int s 2) |
1138 |
|
|
1139 |
| 62 -> |
| 62 -> |
1140 |
DisconnectClient (get_int s 2) |
DisconnectClient (get_int s 2) |
1141 |
|
|
1142 |
| 63 -> |
| 63 -> |
1143 |
let n = get_int s 2 in |
let n = get_int s 2 in |
1144 |
let s, pos = get_string s 6 in |
let s, pos = get_string s 6 in |
1145 |
NetworkMessage (n, s) |
NetworkMessage (n, s) |
1146 |
|
|
1147 |
| 64 -> |
| 64 -> |
1148 |
InterestedInSources (get_bool s 2) |
InterestedInSources (get_bool s 2) |
1149 |
|
|
1150 |
| 65 -> |
| 65 -> |
1151 |
GetVersion |
GetVersion |
1152 |
|
|
1162 |
ServerSetPreferred (num, b) |
ServerSetPreferred (num, b) |
1163 |
|
|
1164 |
| _ -> |
| _ -> |
1165 |
lprintf "FROM GUI:Unknown message %d\n" opcode; |
lprintf_nl "FROM GUI:Unknown message %d" opcode; |
1166 |
raise FromGuiMessageNotImplemented |
raise FromGuiMessageNotImplemented |
1167 |
|
|
|
|
|
1168 |
with e -> |
with e -> |
1169 |
lprintf "Decoding gui proto[%d]: exception %s, opcode %d\n" proto.(opcode) |
lprintf_nl "Decoding gui proto[%d]: exception %s, opcode %d" proto.(opcode) |
1170 |
(Printexc2.to_string e) opcode; |
(Printexc2.to_string e) opcode; |
1171 |
dump s; |
dump s; |
|
lprint_newline (); |
|
1172 |
raise e |
raise e |
1173 |
|
|
1174 |
(*************** |
(*************** |
1175 |
|
|
1176 |
Decoding of messages from the Core to the GUI |
Decoding of messages from the Core to the GUI |
1189 |
M.option_type = ""; |
M.option_type = ""; |
1190 |
M.option_advanced = false; |
M.option_advanced = false; |
1191 |
} |
} |
1192 |
|
|
1193 |
let to_gui (proto : int array) opcode s = |
let to_gui (proto : int array) opcode s = |
1194 |
try |
try |
1195 |
let proto = if opcode > to_gui_last_opcode then 0 else proto.(opcode) in |
let proto = if opcode > to_gui_last_opcode then 0 else proto.(opcode) in |
1196 |
|
|
1197 |
if !verbose_gui_decoding then |
if !verbose_gui_decoding then |
1198 |
lprintf "TO GUI: Opcode %d\n" opcode; |
lprintf_nl "TO GUI: Opcode %d" opcode; |
1199 |
match opcode with |
match opcode with |
1200 |
| 0 -> |
| 0 -> |
1201 |
let version = get_int s 2 in |
let version = get_int s 2 in |
1616 |
Version s |
Version s |
1617 |
|
|
1618 |
| _ -> |
| _ -> |
1619 |
lprintf "TO GUI:Unknown message %d\n" opcode; |
lprintf_nl "TO GUI:Unknown message %d" opcode; |
1620 |
raise Not_found |
raise Not_found |
1621 |
|
|
1622 |
|
|
1623 |
with e -> |
with e -> |
1624 |
lprintf "Decoding gui proto[%d]: exception %s, opcode %d\n" proto.(opcode) |
lprintf_nl "Decoding gui proto[%d]: exception %s, opcode %d" proto.(opcode) |
1625 |
(Printexc2.to_string e) opcode; |
(Printexc2.to_string e) opcode; |
1626 |
|
|
1627 |
dump s; |
dump s; |
|
lprint_newline (); |
|
1628 |
raise e |
raise e |