From f1bbd65bbaa4291c194244424668aa16c357ca0f Mon Sep 17 00:00:00 2001 From: Tobias Weimer Date: Fri, 4 Jul 2014 21:02:05 +0000 Subject: CommandLine: -translation fixes -fixed message encoding -fixed timestamps -fixed: "sounds" command without params returned popup NewGPG: -translation fixes git-svn-id: http://svn.miranda-ng.org/main/trunk@9681 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/CmdLine/src/mimcmd_handlers.cpp | 1000 +++++++++++-------------------- plugins/CmdLine/src/mimcmd_handlers.h | 18 - plugins/New_GPG/src/main.cpp | 50 +- plugins/New_GPG/src/options.cpp | 24 +- plugins/New_GPG/src/utilities.cpp | 40 +- 5 files changed, 419 insertions(+), 713 deletions(-) diff --git a/plugins/CmdLine/src/mimcmd_handlers.cpp b/plugins/CmdLine/src/mimcmd_handlers.cpp index 20c6c63b4a..55c6f37ce9 100644 --- a/plugins/CmdLine/src/mimcmd_handlers.cpp +++ b/plugins/CmdLine/src/mimcmd_handlers.cpp @@ -107,145 +107,6 @@ int AccountName2Protocol(const char *accountName, OUT char *uniqueProtocolName, return 1; } -void HandleCommand(PCommand command, TArgument *argv, int argc, PReply reply) -{ - switch (command->ID) - { - case MIMCMD_STATUS: - { - HandleStatusCommand(command, argv, argc, reply); - - break; - } - - case MIMCMD_AWAYMSG: - { - HandleAwayMsgCommand(command, argv, argc, reply); - - break; - } - // - //case MIMCMD_XSTATUS: - //{ - // - // break; - //} - - case MIMCMD_POPUPS: - { - HandlePopupsCommand(command, argv, argc, reply); - - break; - } - - case MIMCMD_SOUNDS: - { - HandleSoundsCommand(command, argv, argc, reply); - - break; - } - - case MIMCMD_CLIST: - { - HandleClistCommand(command, argv, argc, reply); - - break; - } - - case MIMCMD_QUIT: - { - HandleQuitCommand(command, argv, argc, reply); - - break; - } - - case MIMCMD_EXCHANGE: - { - HandleExchangeCommand(command, argv, argc, reply); - - break; - } - - case MIMCMD_YAMN: - { - HandleYAMNCommand(command, argv, argc, reply); - - break; - } - - case MIMCMD_CALLSERVICE: - { - HandleCallServiceCommand(command, argv, argc, reply); - - break; - } - - case MIMCMD_MESSAGE: - { - HandleMessageCommand(command, argv, argc, reply); - - break; - } - - case MIMCMD_DATABASE: - { - HandleDatabaseCommand(command, argv, argc, reply); - - break; - } - - case MIMCMD_PROXY: - { - HandleProxyCommand(command, argv, argc, reply); - - break; - } - - case MIMCMD_CONTACTS: - { - HandleContactsCommand(command, argv, argc, reply); - - break; - } - - case MIMCMD_HISTORY: - { - HandleHistoryCommand(command, argv, argc, reply); - - break; - } - - case MIMCMD_VERSION: - { - HandleVersionCommand(command, argv, argc, reply); - - break; - } - - case MIMCMD_SETNICKNAME: - { - HandleSetNicknameCommand(command, argv, argc, reply); - - break; - } - - case MIMCMD_IGNORE: - { - HandleIgnoreCommand(command, argv, argc, reply); - - break; - } - - default: - { - reply->code = MIMRES_NOTFOUND; - mir_snprintf(reply->message, reply->cMessage, Translate("Command '%s' is not currently supported."), command->command); - - break; - } - } -} - void HandleWrongParametersCount(PCommand command, PReply reply) { reply->code = MIMRES_WRONGPARAMSCOUNT; @@ -274,7 +135,7 @@ int ParseValueParam(char *param, void *&result) ok = VALUE_STRING; - break; + return ok; } case 'w': @@ -290,35 +151,33 @@ int ParseValueParam(char *param, void *&result) ok = VALUE_WIDE; - break; + return ok; } case 'b': { result = (char *) malloc(sizeof(char)); - long tmp; char *stop; - tmp = strtol(param + 1, &stop, 10); + long tmp = strtol(param + 1, &stop, 10); * ((char *) result) = tmp; ok = (*stop == 0) ? VALUE_BYTE : VALUE_ERROR; - break; + return ok; } case 'i': { result = (int *) malloc(sizeof(int)); - long tmp; char *stop; - tmp = strtol(param + 1, &stop, 10); + long tmp = strtol(param + 1, &stop, 10); * ((int *) result) = tmp; ok = (*stop == 0) ? VALUE_WORD : VALUE_ERROR; - break; + return ok; } case 'd': @@ -329,12 +188,12 @@ int ParseValueParam(char *param, void *&result) ok = (*stop == 0) ? VALUE_DWORD : VALUE_ERROR; - break; + return ok; } + default: + return ok; } } - - return ok; } int ParseStatusParam(char *status) @@ -342,17 +201,28 @@ int ParseStatusParam(char *status) char *lower = NEWSTR_ALLOCA(status); _strlwr(lower); - if ( !strcmp(lower, "offline")) return ID_STATUS_OFFLINE; - if ( !strcmp(lower, "online")) return ID_STATUS_ONLINE; - if ( !strcmp(lower, "away")) return ID_STATUS_AWAY; - if ( !strcmp(lower, "dnd")) return ID_STATUS_DND; - if ( !strcmp(lower, "na")) return ID_STATUS_NA; - if ( !strcmp(lower, "occupied")) return ID_STATUS_OCCUPIED; - if ( !strcmp(lower, "freechat")) return ID_STATUS_FREECHAT; - if ( !strcmp(lower, "invisible")) return ID_STATUS_INVISIBLE; - if ( !strcmp(lower, "onthephone")) return ID_STATUS_ONTHEPHONE; - if ( !strcmp(lower, "outtolunch")) return ID_STATUS_OUTTOLUNCH; - return 0; + if ( !strcmp(lower, "offline")) + return ID_STATUS_OFFLINE; + else if ( !strcmp(lower, "online")) + return ID_STATUS_ONLINE; + else if ( !strcmp(lower, "away")) + return ID_STATUS_AWAY; + else if ( !strcmp(lower, "dnd")) + return ID_STATUS_DND; + else if ( !strcmp(lower, "na")) + return ID_STATUS_NA; + else if ( !strcmp(lower, "occupied")) + return ID_STATUS_OCCUPIED; + else if ( !strcmp(lower, "freechat")) + return ID_STATUS_FREECHAT; + else if ( !strcmp(lower, "invisible")) + return ID_STATUS_INVISIBLE; + else if ( !strcmp(lower, "onthephone")) + return ID_STATUS_ONTHEPHONE; + else if ( !strcmp(lower, "outtolunch")) + return ID_STATUS_OUTTOLUNCH; + else + return 0; } char *PrettyStatusMode(int status, char *buffer, int size) @@ -410,7 +280,7 @@ void HandleStatusCommand(PCommand command, TArgument *argv, int argc, PReply rep free(perAccountStatus); - break; + return; } case 3: @@ -437,7 +307,7 @@ void HandleStatusCommand(PCommand command, TArgument *argv, int argc, PReply rep HandleUnknownParameter(command, argv[2], reply); } - break; + return; } case 4: @@ -464,43 +334,30 @@ void HandleStatusCommand(PCommand command, TArgument *argv, int argc, PReply rep switch (res) { case 0: - { reply->code = MIMRES_SUCCESS; mir_snprintf(reply->message, reply->cMessage, Translate("Changed '%s' status to '%s' (previous status was '%s')."), account, pn, po); - - break; - } + return; case CALLSERVICE_NOTFOUND: - { reply->code = MIMRES_FAILURE; mir_snprintf(reply->message, reply->cMessage, Translate("'%s' doesn't seem to be a valid account."), account); - - break; - } + return; default: - { reply->code = MIMRES_FAILURE; mir_snprintf(reply->message, reply->cMessage, Translate("Failed to change status for account '%s' to '%s'."), account, pn); - - break; - } + return; } } else{ HandleUnknownParameter(command, argv[2], reply); } - break; + return; } default: - { HandleWrongParametersCount(command, reply); - - break; - } } } @@ -555,7 +412,7 @@ void HandleAwayMsgCommand(PCommand command, TArgument *argv, int argc, PReply re } reply->code = MIMRES_SUCCESS; - break; + return; } case 4: @@ -565,69 +422,49 @@ void HandleAwayMsgCommand(PCommand command, TArgument *argv, int argc, PReply re char *account = argv[3]; AccountName2Protocol(account, protocol, sizeof(protocol)); - INT_PTR res = 0; char pn[128]; - if ((res = CallProtoService(protocol, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND) != 0) //if the protocol supports away messages + INT_PTR res = CallProtoService(protocol, PS_GETCAPS, PFLAGNUM_1, 0); + if ((res & PF1_MODEMSGSEND) != 0) //if the protocol supports away messages { INT_PTR status = CallProtoService(protocol, PS_GETSTATUS, 0, 0); res = CallProtoService(protocol, PS_SETAWAYMSG, status, (LPARAM) awayMsg); PrettyStatusMode(status, pn, sizeof(pn)); } - else{ - if (CallProtoService(protocol, PS_GETSTATUS, 0, 0) == CALLSERVICE_NOTFOUND) - { - res = CALLSERVICE_NOTFOUND; - } - else { - res = -2; - } + else if (CallProtoService(protocol, PS_GETSTATUS, 0, 0) == CALLSERVICE_NOTFOUND) + { + res = CALLSERVICE_NOTFOUND; + } + else { + res = -2; } switch (res) { case 0: - { reply->code = MIMRES_SUCCESS; mir_snprintf(reply->message, reply->cMessage, Translate("Changed '%s' status message to '%s' (status is '%s')."), account, awayMsg, pn); - - break; - } + return; case CALLSERVICE_NOTFOUND: - { reply->code = MIMRES_FAILURE; mir_snprintf(reply->message, reply->cMessage, Translate("'%s' doesn't seem to be a valid account."), account); - - break; - } + return; case -2: - { reply->code = MIMRES_FAILURE; mir_snprintf(reply->message, reply->cMessage, Translate("Account '%s' does not support away messages, skipping."), account); - - break; - } + return; default: - { reply->code = MIMRES_FAILURE; mir_snprintf(reply->message, reply->cMessage, Translate("Failed to change status message for account '%s' to '%s' (status is '%s')."), account, awayMsg, pn); - - break; - } - } - - break; + return; + } } default: - { HandleWrongParametersCount(command, reply); - - break; - } } } @@ -665,67 +502,49 @@ void HandlePopupsCommand(PCommand command, TArgument *argv, int argc, PReply rep case 2: { int state = CallService(MS_POPUP_QUERY, PUQS_GETSTATUS, 0); - Set2StateReply(reply, state, 0, "Popups are currently enabled.", "", "Popups are currently disabled.", ""); + Set2StateReply(reply, state, 0, LPGEN("Popups are currently enabled."), "", LPGEN("Popups are currently disabled."), ""); - break; + return; } case 3: { int failure; int state = 0; - int error = 0; switch (Get2StateValue(argv[2])) { case STATE_ON: - { failure = CallService(MS_POPUP_QUERY, PUQS_ENABLEPOPUPS, 0); state = TRUE; - break; - } case STATE_OFF: - { failure = CallService(MS_POPUP_QUERY, PUQS_DISABLEPOPUPS, 0); state = FALSE; - break; - } case STATE_TOGGLE: { int state = CallService(MS_POPUP_QUERY, PUQS_GETSTATUS, 0); failure = CallService(MS_POPUP_QUERY, (state) ? PUQS_DISABLEPOPUPS : PUQS_ENABLEPOPUPS, 0); state = 1 - state; - break; } default: - { HandleUnknownParameter(command, argv[2], reply); - error = 1; - - break; - } - } - if (!error) - { - Set2StateReply(reply, state, failure, "Popups were enabled successfully.", "Popups could not be enabled.", "Popups were disabled successfully.", "Popups could not be disabled."); + return; } - break; + Set2StateReply(reply, state, failure, LPGEN("Popups were enabled successfully."), LPGEN("Popups could not be enabled."), + LPGEN("Popups were disabled successfully."), LPGEN("Popups could not be disabled.")); + + return; } default: - { HandleWrongParametersCount(command, reply); - - break; - } - } } @@ -735,71 +554,45 @@ void HandleSoundsCommand(PCommand command, TArgument *argv, int argc, PReply rep { case 2: { - int state = CallService(MS_POPUP_QUERY, PUQS_GETSTATUS, 0); - Set2StateReply(reply, state, 0, "Sounds are currently enabled.", "", "Sounds are currently disabled.", ""); - - break; + int state = db_get_b(NULL, "Skin", "UseSound", 1); + Set2StateReply(reply, state, 0, LPGEN("Sounds are currently enabled."), "", LPGEN("Sounds are currently disabled."), ""); + return; } case 3: { - int failure; int state = 0; - int error = 0; switch (Get2StateValue(argv[2])) { case STATE_ON: - { - failure = 0; db_set_b(NULL, "Skin", "UseSound", 1); state = TRUE; - break; - } case STATE_OFF: - { - failure = 0; db_set_b(NULL, "Skin", "UseSound", 0); state = FALSE; - break; - } case STATE_TOGGLE: - { state = db_get_b(NULL, "Skin", "UseSound", 1); - - failure = 0; state = 1 - state; db_set_b(NULL, "Skin", "UseSound", state); - break; - } default: - { HandleUnknownParameter(command, argv[2], reply); - error = 1; - - break; - } - } - if (!error) - { - Set2StateReply(reply, state, failure, "Sounds were enabled successfully.", "Sounds could not be enabled.", "Sounds were disabled successfully.", "Sounds could not be disabled."); + return; } + + Set2StateReply(reply, state, 0, LPGEN("Sounds were enabled successfully."), "", LPGEN("Sounds were disabled successfully."), ""); - break; + return; } default: - { HandleWrongParametersCount(command, reply); - - break; - } } } @@ -811,23 +604,20 @@ void HandleClistCommand(PCommand command, TArgument *argv, int argc, PReply repl { HWND hClist = (HWND) CallService(MS_CLUI_GETHWND, 0, 0); int state = IsWindowVisible(hClist); - Set2StateReply(reply, state, 0, "Contact list is currectly shown.", "", "Contact list is currently hidden.", ""); + Set2StateReply(reply, state, 0, LPGEN("Contact list is currectly shown."), "", LPGEN("Contact list is currently hidden."), ""); - break; + return; } case 3: { - int failure; int state = 0; - int error = 0; HWND hClist = (HWND) CallService(MS_CLUI_GETHWND, 0, 0); switch (Get2StateValue(argv[2])) { case STATE_ON: { - failure = 0; ShowWindow(hClist, SW_SHOW); state = TRUE; @@ -837,7 +627,6 @@ void HandleClistCommand(PCommand command, TArgument *argv, int argc, PReply repl case STATE_OFF: { - failure = 0; ShowWindow(hClist, SW_HIDE); state = FALSE; @@ -848,7 +637,6 @@ void HandleClistCommand(PCommand command, TArgument *argv, int argc, PReply repl { state = IsWindowVisible(hClist); - failure = 0; state = 1 - state; ShowWindow(hClist, (state) ? SW_SHOW : SW_HIDE); @@ -856,27 +644,19 @@ void HandleClistCommand(PCommand command, TArgument *argv, int argc, PReply repl } default: - { HandleUnknownParameter(command, argv[2], reply); - error = 1; - - break; - } - } - if (!error) - { - Set2StateReply(reply, state, failure, "Contact list was shown successfully.", "Contact list could not be shown.", "Contact list was hidden successfully.", "Contact list could not be hidden."); + return; } - break; + + Set2StateReply(reply, state, 0, LPGEN("Contact list was shown successfully."), "", + LPGEN("Contact list was hidden successfully."), ""); + + return; } default: - { HandleWrongParametersCount(command, reply); - - break; - } } } @@ -893,7 +673,7 @@ void HandleQuitCommand(PCommand command, TArgument *argv, int argc, PReply reply PostMessage(hWndMiranda, WM_COMMAND, ID_ICQ_EXIT, 0); reply->code = MIMRES_SUCCESS; - mir_snprintf(reply->message, reply->cMessage, "Issued a quit command."); + mir_snprintf(reply->message, reply->cMessage, TranslateT("Issued a quit command.")); break; } @@ -913,7 +693,7 @@ void HandleQuitCommand(PCommand command, TArgument *argv, int argc, PReply reply PostMessage(hWndMiranda, WM_COMMAND, ID_ICQ_EXIT, 0); reply->code = MIMRES_SUCCESS; - mir_snprintf(reply->message, reply->cMessage, "Issued a quit and wait command."); + mir_snprintf(reply->message, reply->cMessage, TranslateT("Issued a quit and wait command.")); SetEvent(heServerBufferFull); @@ -932,11 +712,7 @@ void HandleQuitCommand(PCommand command, TArgument *argv, int argc, PReply reply } default: - { HandleWrongParametersCount(command, reply); - - break; - } } } @@ -951,10 +727,9 @@ void HandleExchangeCommand(PCommand command, TArgument *argv, int argc, PReply r _strlwr(lower); if (strcmp(lower, "check") == 0) { - if (ServiceExists(MS_EXCHANGE_CHECKEMAIL)) + INT_PTR ret = CallService(MS_EXCHANGE_CHECKEMAIL, 0, 0); + if (ret != CALLSERVICE_NOTFOUND) { - CallService(MS_EXCHANGE_CHECKEMAIL, 0, 0); - reply->code = MIMRES_SUCCESS; mir_snprintf(reply->message, reply->cMessage, Translate("Issued check email command to Exchange plugin.")); } @@ -967,16 +742,11 @@ void HandleExchangeCommand(PCommand command, TArgument *argv, int argc, PReply r HandleUnknownParameter(command, argv[2], reply); } - break; + return; } default: - { HandleWrongParametersCount(command, reply); - - break; - } - } } @@ -1007,16 +777,11 @@ void HandleYAMNCommand(PCommand command, TArgument *argv, int argc, PReply reply HandleUnknownParameter(command, argv[2], reply); } - break; + return; } default: - { HandleWrongParametersCount(command, reply); - - break; - } - } } @@ -1059,9 +824,7 @@ void HandleCallServiceCommand(PCommand command, TArgument *argv, int argc, PRepl } default: - { HandleWrongParametersCount(command, reply); - } } } @@ -1176,73 +939,55 @@ void HandleMessageCommand(PCommand command, TArgument *argv, int argc, PReply re } } -int ParseDatabaseData(DBVARIANT *var, char *buffer, int size, int free) +bool ParseDatabaseData(DBVARIANT *var, char *buffer, int size, int free) { - int ok = 1; switch (var->type) { case DBVT_BYTE: - { - mir_snprintf(buffer, size, "byte:%d", var->bVal); - - break; - } + mir_snprintf(buffer, size, Translate("byte:%d"), var->bVal); + return true; case DBVT_WORD: - { - mir_snprintf(buffer, size, "word:%d", var->wVal); - - break; - } + mir_snprintf(buffer, size, Translate("word:%d"), var->wVal); + return true; case DBVT_DWORD: - { - mir_snprintf(buffer, size, "dword:%ld", var->dVal); - - break; - } + mir_snprintf(buffer, size, Translate("dword:%ld"), var->dVal); + return true; case DBVT_ASCIIZ: - { - mir_snprintf(buffer, size, "string:'%s'", var->pszVal); - if (free) { mir_free(var->pszVal); } + mir_snprintf(buffer, size, Translate("string:'%s'"), var->pszVal); + if (free) { + mir_free(var->pszVal); + } - break; - } + return true; case DBVT_WCHAR: - { - mir_snprintf(buffer, size, "wide string:'%S'", var->pwszVal); - if (free) { mir_free(var->pwszVal); } - - break; - } + mir_snprintf(buffer, size, Translate("wide string:'%S'"), var->pwszVal); + if (free) { + mir_free(var->pwszVal); + } + return true; case DBVT_UTF8: - { - mir_snprintf(buffer, size, "utf8:'%s'", var->pszVal); - if (free) { mir_free(var->pszVal); } - } + mir_snprintf(buffer, size, Translate("utf8:'%s'"), var->pszVal); + if (free) { + mir_free(var->pszVal); + } + return true; case DBVT_BLOB: - { - mir_snprintf(buffer, size, "blob:N/A"); - if (free) { mir_free(var->pbVal); } - - break; - } - + mir_snprintf(buffer, size, Translate("blob:N/A")); + if (free) { + mir_free(var->pbVal); + } + return true; default: - { - ok = 0; - mir_snprintf(buffer, size, "unknown value"); - - break; - } + mir_snprintf(buffer, size, Translate("unknown value")); + return false; } - - return ok; } void HandleDatabaseCommand(PCommand command, TArgument *argv, int argc, PReply reply) @@ -1269,126 +1014,98 @@ void HandleDatabaseCommand(PCommand command, TArgument *argv, int argc, PReply r HandleWrongParametersCount(command, reply); } } - else{ - if (strcmp(dbcmd, "set") == 0) + else if (strcmp(dbcmd, "set") == 0) + { + if (argc == 6) { - if (argc == 6) - { - char *module = argv[3]; - char *key = argv[4]; - - int ok = 1; + char *module = argv[3]; + char *key = argv[4]; - void *value = NULL; - char *wrote = NULL; - int type = ParseValueParam(argv[5], value); + int ok = 1; + void *value = NULL; + char *wrote = NULL; + int type = ParseValueParam(argv[5], value); - switch (type) - { - case VALUE_STRING: - { - db_set_s(NULL, module, key, (char *) value); - wrote = "string"; + switch (type) + { + case VALUE_STRING: + db_set_s(NULL, module, key, (char *) value); + wrote = Translate("string"); - break; - } + break; - case VALUE_BYTE: - { - db_set_b(NULL, module, key, (* (char *) value)); - wrote = "byte"; - - break; - } + case VALUE_BYTE: + db_set_b(NULL, module, key, (* (char *) value)); + wrote = Translate("byte"); + break; - case VALUE_WORD: - { - db_set_w(NULL, module, key, (* (WORD *) value)); - wrote = "word"; - - break; - } + case VALUE_WORD: + db_set_w(NULL, module, key, (* (WORD *) value)); + wrote = Translate("word"); + break; - case VALUE_DWORD: - { - db_set_dw(NULL, module, key, (* (DWORD *) value)); - wrote = "dword"; - - break; - } + case VALUE_DWORD: + db_set_dw(NULL, module, key, (* (DWORD *) value)); + wrote = Translate("dword"); + break; - case VALUE_WIDE: - { - db_set_ws(NULL, module, key, (WCHAR *) value); - wrote = "wide string"; - - break; - } + case VALUE_WIDE: + db_set_ws(NULL, module, key, (WCHAR *) value); + wrote = Translate("wide string"); + break; - default: - { - HandleUnknownParameter(command, argv[5], reply); - ok = 0; - - break; - } - } - - if (ok) - { - reply->code = MIMRES_SUCCESS; - mir_snprintf(reply->message, reply->cMessage, Translate("Wrote '%s:%s' to database entry '%s/%s'."), wrote, argv[5] + 1, module, key); - } - - free(value); - } - else{ - HandleWrongParametersCount(command, reply); + default: + HandleUnknownParameter(command, argv[5], reply); + return; } + + reply->code = MIMRES_SUCCESS; + mir_snprintf(reply->message, reply->cMessage, Translate("Wrote '%s:%s' to database entry '%s/%s'."), wrote, argv[5] + 1, module, key); + + free(value); } else{ - if (strcmp(dbcmd, "get") == 0) - { - if (argc == 5) - { - char *module = argv[3]; - char *key = argv[4]; + HandleWrongParametersCount(command, reply); + } + } + else if (strcmp(dbcmd, "get") == 0) + { + if (argc == 5) + { + char *module = argv[3]; + char *key = argv[4]; - DBVARIANT var = {0}; + DBVARIANT var = {0}; - int res = db_get(NULL, module, key, &var); - if (!res) - { - char buffer[1024]; + int res = db_get(NULL, module, key, &var); + if (!res) + { + char buffer[1024]; - if (ParseDatabaseData(&var, buffer, sizeof(buffer), TRUE)) - { - reply->code = MIMRES_SUCCESS; - mir_snprintf(reply->message, reply->cMessage, "'%s/%s' - %s.", module, key, buffer); - } - else{ - reply->code = MIMRES_FAILURE; - mir_snprintf(reply->message, reply->cMessage, Translate("Could not retrieve setting '%s/%s': %s."), module, key, buffer); - } - } - else{ - reply->code = MIMRES_FAILURE; - mir_snprintf(reply->message, reply->cMessage, Translate("Setting '%s/%s' was not found."), module, key); - } - + if (ParseDatabaseData(&var, buffer, sizeof(buffer), TRUE)) + { + reply->code = MIMRES_SUCCESS; + mir_snprintf(reply->message, reply->cMessage, "'%s/%s' - %s.", module, key, buffer); } else{ - HandleWrongParametersCount(command, reply); + reply->code = MIMRES_FAILURE; + mir_snprintf(reply->message, reply->cMessage, Translate("Could not retrieve setting '%s/%s': %s."), module, key, buffer); } } else{ - HandleUnknownParameter(command, dbcmd, reply); + reply->code = MIMRES_FAILURE; + mir_snprintf(reply->message, reply->cMessage, Translate("Setting '%s/%s' was not found."), module, key); } + + } + else{ + HandleWrongParametersCount(command, reply); } - } - + else{ + HandleUnknownParameter(command, dbcmd, reply); + } } else{ HandleWrongParametersCount(command, reply); @@ -1401,26 +1118,25 @@ int ParseProxyType(char *type) STRNCPY(lower, type, sizeof(lower)); lower[sizeof(lower) - 1] = 0; _strlwr(lower); - int proxy = 0; if (strcmp(lower, "socks4") == 0) { - proxy = PROXY_SOCKS4; + return PROXY_SOCKS4; } else if (strcmp(lower, "socks5") == 0) { - proxy = PROXY_SOCKS5; + return PROXY_SOCKS5; } else if (strcmp(lower, "http") == 0) { - proxy = PROXY_HTTP; + return PROXY_HTTP; } else if (strcmp(lower, "https") == 0) { - proxy = PROXY_HTTPS; + return PROXY_HTTPS; } - - return proxy; + else + return 0; } char *PrettyProxyType(int type, char *buffer, int size) @@ -1429,39 +1145,23 @@ char *PrettyProxyType(int type, char *buffer, int size) switch (type) { case PROXY_SOCKS4: - { pretty = "SOCKS4"; - break; - } case PROXY_SOCKS5: - { pretty = "SOCKS5"; - break; - } case PROXY_HTTP: - { pretty = "HTTP"; - break; - } case PROXY_HTTPS: - { pretty = "HTTPS"; - break; - } default: - { pretty = "Unknown"; - - break; - } } STRNCPY(buffer, pretty, size); @@ -1476,8 +1176,7 @@ void HandleProtocolProxyCommand(PCommand command, TArgument *argv, int argc, PRe proxycmd[sizeof(proxycmd) - 1] = 0; _strlwr(proxycmd); - char buffer[1024]; - int ok = 1; + char buffer[1024]; if (strcmp(proxycmd, "status") == 0) @@ -1532,96 +1231,80 @@ void HandleProtocolProxyCommand(PCommand command, TArgument *argv, int argc, PRe } default: - { HandleUnknownParameter(command, argv[4], reply); - - break; - } + return; } break; } default: - { HandleWrongParametersCount(command, reply); - ok = 0; - - break; - } + return; } } - else{ - if (strcmp(proxycmd, "server") == 0) + else if (strcmp(proxycmd, "server") == 0) + { + switch (argc) { - switch (argc) + case 4: { - case 4: - { - char host[256], type[256]; - GetStringFromDatabase(NULL, module, "NLProxyServer", "", host, sizeof(host)); - int port = db_get_w(NULL, module, "NLProxyPort", 0); - PrettyProxyType(db_get_b(NULL, module, "NLProxyType", 0), type, sizeof(type)); + char host[256], type[256]; + GetStringFromDatabase(NULL, module, "NLProxyServer", "", host, sizeof(host)); + int port = db_get_w(NULL, module, "NLProxyPort", 0); + PrettyProxyType(db_get_b(NULL, module, "NLProxyType", 0), type, sizeof(type)); - reply->code = MIMRES_SUCCESS; - mir_snprintf(buffer, sizeof(buffer), Translate("%s proxy server: %s %s:%d."), protocol, type, host, port); + reply->code = MIMRES_SUCCESS; + mir_snprintf(buffer, sizeof(buffer), Translate("%s proxy server: %s %s:%d."), protocol, type, host, port); - break; - } + break; + } - case 7: - { - int type = ParseProxyType(argv[4]); - char *host = argv[5]; - long port; - char *stop = NULL; - port = strtol(argv[6], &stop, 10); + case 7: + { + int type = ParseProxyType(argv[4]); + char *host = argv[5]; + long port; + char *stop = NULL; + port = strtol(argv[6], &stop, 10); - if ((*stop == 0) && (type > 0)) - { - db_set_s(NULL, module, "NLProxyServer", host); - db_set_w(NULL, module, "NLProxyPort", port); - db_set_b(NULL, module, "NLProxyType", type); + if ((*stop == 0) && (type > 0)) + { + db_set_s(NULL, module, "NLProxyServer", host); + db_set_w(NULL, module, "NLProxyPort", port); + db_set_b(NULL, module, "NLProxyType", type); - reply->code = MIMRES_SUCCESS; - mir_snprintf(buffer, sizeof(buffer), Translate("%s proxy set to %s %s:%d."), protocol, argv[4], host, port); - } - else { - reply->code = MIMRES_FAILURE; - mir_snprintf(buffer, sizeof(buffer), Translate("%s The port or the proxy type parameter is invalid."), protocol); - } - - break; + reply->code = MIMRES_SUCCESS; + mir_snprintf(buffer, sizeof(buffer), Translate("%s proxy set to %s %s:%d."), protocol, argv[4], host, port); } - - default: - { - HandleWrongParametersCount(command, reply); - ok = 0; - - break; + else { + reply->code = MIMRES_FAILURE; + mir_snprintf(buffer, sizeof(buffer), Translate("%s The port or the proxy type parameter is invalid."), protocol); } + + break; } + + default: + HandleWrongParametersCount(command, reply); + return; } - else{ - ok = 0; - HandleUnknownParameter(command, proxycmd, reply); - } + } + else{ + HandleUnknownParameter(command, proxycmd, reply); + return; } - if (ok) + if (reply->message[0] != 0) { - if (reply->message[0] != 0) - { - strncat(reply->message, "\n", reply->cMessage); - strncat(reply->message, buffer, reply->cMessage); - reply->message[reply->cMessage - 1] = 0; - } - else{ - mir_snprintf(reply->message, reply->cMessage, buffer); - } - } + strncat(reply->message, "\n", reply->cMessage); + strncat(reply->message, buffer, reply->cMessage); + reply->message[reply->cMessage - 1] = 0; + } + else{ + mir_snprintf(reply->message, reply->cMessage, buffer); + } } void HandleProxyCommand(PCommand command, TArgument *argv, int argc, PReply reply) @@ -1680,7 +1363,6 @@ void HandleProxyCommand(PCommand command, TArgument *argv, int argc, PReply repl int ContactMatchSearch(MCONTACT hContact, char *contact, char *id, char *account, TArgument *argv, int argc) { int matches = 1; - int i; char lwrName[2048] = "\0"; char lwrAccount[128] = "\0"; @@ -1697,7 +1379,7 @@ int ContactMatchSearch(MCONTACT hContact, char *contact, char *id, char *account _strlwr(lwrAccount); _strlwr(lwrID); - for (i = 0; i < argc; i++) + for (int i = 0; i < argc; i++) { STRNCPY(lwrKeyword, argv[i], sizeof(lwrKeyword)); _strlwr(lwrKeyword); @@ -1726,7 +1408,6 @@ int ContactMatchSearch(MCONTACT hContact, char *contact, char *id, char *account if (searchStatus != contactStatus) { matches = 0; - break; } } @@ -1738,17 +1419,13 @@ int ContactMatchSearch(MCONTACT hContact, char *contact, char *id, char *account if (strstr(lwrID, pos) == NULL) { matches = 0; - break; } } - else{ - if ((strstr(lwrName, lwrKeyword) == NULL)) - { - matches = 0; - - break; - } + else if ((strstr(lwrName, lwrKeyword) == NULL)) + { + matches = 0; + break; } } } @@ -1813,70 +1490,61 @@ void HandleContactsCommand(PCommand command, TArgument *argv, int argc, PReply r free(id); } } - else{ - if (_stricmp(argv[2], "open") == 0) + else if (_stricmp(argv[2], "open") == 0) + { + if (argc > 3) { - if (argc > 3) - { - char protocol[128]; + char protocol[128]; - reply->code = MIMRES_SUCCESS; - *reply->message = 0; - for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { - GetContactProto(hContact, protocol, sizeof(protocol)); - - char *contact = GetContactName(hContact, protocol); - char *id = GetContactID(hContact, protocol); - if (ContactMatchSearch(hContact, contact, id, protocol, &argv[3], argc - 3)) - { - DWORD threadID; - HANDLE thread = CreateThread(NULL, NULL, OpenMessageWindowThread, (void*)hContact, NULL, &threadID); - } + reply->code = MIMRES_SUCCESS; + *reply->message = 0; + for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { + GetContactProto(hContact, protocol, sizeof(protocol)); - free(contact); - free(id); + char *contact = GetContactName(hContact, protocol); + char *id = GetContactID(hContact, protocol); + if (ContactMatchSearch(hContact, contact, id, protocol, &argv[3], argc - 3)) + { + DWORD threadID; + HANDLE thread = CreateThread(NULL, NULL, OpenMessageWindowThread, (void*)hContact, NULL, &threadID); } + + free(contact); + free(id); } - else if (argc == 3) { - reply->code = MIMRES_SUCCESS; - *reply->message = 0; + } + else if (argc == 3) { + reply->code = MIMRES_SUCCESS; + *reply->message = 0; - for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { - HANDLE hUnreadEvent = db_event_firstUnread(hContact); - if (hUnreadEvent != NULL) { - DWORD threadID; - HANDLE thread = CreateThread(NULL, NULL, OpenMessageWindowThread, (void*)hContact, NULL, &threadID); - } + for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { + HANDLE hUnreadEvent = db_event_firstUnread(hContact); + if (hUnreadEvent != NULL) { + DWORD threadID; + HANDLE thread = CreateThread(NULL, NULL, OpenMessageWindowThread, (void*)hContact, NULL, &threadID); } } - else HandleWrongParametersCount(command, reply); } - else HandleUnknownParameter(command, argv[2], reply); + else HandleWrongParametersCount(command, reply); } + else HandleUnknownParameter(command, argv[2], reply); } else HandleWrongParametersCount(command, reply); } void AddHistoryEvent(DBEVENTINFO *dbEvent, char *contact, PReply reply) { - struct tm * tEvent = localtime((time_t *) &dbEvent->timestamp); char timestamp[256]; + DBTIMETOSTRING tts = {0}; + tts.szDest = timestamp; + tts.cbDest = sizeof(timestamp); + tts.szFormat = "D, s"; + CallService(MS_DB_TIME_TIMESTAMPTOSTRING, dbEvent->timestamp,(LPARAM) &tts); - strftime(timestamp, sizeof(timestamp), "%H:%M:%S %d/%b/%Y", tEvent); - - static char buffer[6144]; char *sender = (dbEvent->flags & DBEF_SENT) ? Translate("[me]") : contact; + char *message = DbGetEventTextA(dbEvent,CP_ACP); - char message[4096] = {0}; - STRNCPY(message, (char *) dbEvent->pBlob, sizeof(message)); - message[dbEvent->cbBlob] = message[strlen(message)] = 0; - - //if ((strlen(message) <= 0) && (dbEvent->cbBlob > 0)) - //{ - // WCHAR *tmp = (WCHAR *) dbEvent->pBlob[dbEvent->cbBlob + 1]; - // WideCharToMultiByte(CP_ACP, 0, tmp, -1, message, sizeof(message), NULL, NULL); - //} - + static char buffer[6144]; mir_snprintf(buffer, sizeof(buffer), "[%s] %15s: %s", timestamp, sender, message); @@ -1896,6 +1564,7 @@ void AddHistoryEvent(DBEVENTINFO *dbEvent, char *contact, PReply reply) Sleep(750); strcpy(reply->message, "\n"); } + mir_free(message); } void HandleHistoryCommand(PCommand command, TArgument *argv, int argc, PReply reply) @@ -1946,12 +1615,10 @@ void HandleHistoryCommand(PCommand command, TArgument *argv, int argc, PReply re } } } - else { - if (_stricmp(cmd, "show") == 0) - HandleWrongParametersCount(command, reply); - else - HandleUnknownParameter(command, cmd, reply); - } + else if (_stricmp(cmd, "show") == 0) + HandleWrongParametersCount(command, reply); + else + HandleUnknownParameter(command, cmd, reply); break; } @@ -2041,12 +1708,10 @@ void HandleHistoryCommand(PCommand command, TArgument *argv, int argc, PReply re } else HandleUnknownParameter(command, (*stop1) ? argv[4] : argv[5], reply); } - else{ - if (_stricmp(cmd, "unread") == 0) - HandleWrongParametersCount(command, reply); - else - HandleUnknownParameter(command, cmd, reply); - } + else if (_stricmp(cmd, "unread") == 0) + HandleWrongParametersCount(command, reply); + else + HandleUnknownParameter(command, cmd, reply); } else{ reply->code = MIMRES_FAILURE; @@ -2078,11 +1743,9 @@ void HandleVersionCommand(PCommand command, TArgument *argv, int argc, PReply re } else{ char miranda[512]; - char cmdline[512]; DWORD v = pluginInfo.version; CallService(MS_SYSTEM_GETVERSIONTEXT, (WPARAM) sizeof(miranda), (LPARAM) miranda); - mir_snprintf(cmdline, sizeof(cmdline), "%d.%d.%d.%d", ((v >> 24) & 0xFF), ((v >> 16) & 0xFF), ((v >> 8) & 0xFF), (v & 0xFF)); - mir_snprintf(reply->message, reply->cMessage, "Miranda %s\nCmdLine v.%s", miranda, cmdline); + mir_snprintf(reply->message, reply->cMessage, "Miranda %s\nCmdLine v.%d.%d.%d.%d", miranda, ((v >> 24) & 0xFF), ((v >> 16) & 0xFF), ((v >> 8) & 0xFF), (v & 0xFF)); } } else{ @@ -2093,8 +1756,7 @@ void HandleSetNicknameCommand(PCommand command, TArgument *argv, int argc, PRepl { if (argc == 4) { - char protocol[512]; - char nickname[512]; + char protocol[512], nickname[512]; strcpy(protocol, argv[2]); strcpy(nickname, argv[3]); @@ -2120,34 +1782,23 @@ void HandleIgnoreCommand(PCommand command, TArgument *argv, int argc, PReply rep if (argc >= 4) { BOOL block = FALSE; - BOOL goodCommand = FALSE; if (_stricmp(argv[2], "block") == 0) { block = TRUE; - goodCommand = TRUE; } - - if (_stricmp(argv[2], "unblock") == 0) + else if (_stricmp(argv[2], "unblock") == 0) { block = FALSE; - goodCommand = TRUE; } - - if (!goodCommand) + else { HandleUnknownParameter(command, argv[2], reply); - return; } - MCONTACT hContact = NULL; - char *contact; - for (int i = 3; i < argc; i++) { - contact = argv[i]; - hContact = ParseContactParam(contact); - + MCONTACT hContact = ParseContactParam(argv[i]); if (hContact) { CallService(block ? MS_IGNORE_IGNORE : MS_IGNORE_UNIGNORE, (WPARAM) hContact, IGNOREEVENT_ALL); @@ -2160,4 +1811,83 @@ void HandleIgnoreCommand(PCommand command, TArgument *argv, int argc, PReply rep else { HandleWrongParametersCount(command, reply); } +} + + +void HandleCommand(PCommand command, TArgument *argv, int argc, PReply reply) +{ + switch (command->ID) + { + case MIMCMD_STATUS: + HandleStatusCommand(command, argv, argc, reply); + return; + + case MIMCMD_AWAYMSG: + HandleAwayMsgCommand(command, argv, argc, reply); + return; + + case MIMCMD_POPUPS: + HandlePopupsCommand(command, argv, argc, reply); + return; + + case MIMCMD_SOUNDS: + HandleSoundsCommand(command, argv, argc, reply); + return; + + case MIMCMD_CLIST: + HandleClistCommand(command, argv, argc, reply); + return; + + case MIMCMD_QUIT: + HandleQuitCommand(command, argv, argc, reply); + return; + + case MIMCMD_EXCHANGE: + HandleExchangeCommand(command, argv, argc, reply); + return; + + case MIMCMD_YAMN: + HandleYAMNCommand(command, argv, argc, reply); + return; + + case MIMCMD_CALLSERVICE: + HandleCallServiceCommand(command, argv, argc, reply); + return; + + case MIMCMD_MESSAGE: + HandleMessageCommand(command, argv, argc, reply); + return; + + case MIMCMD_DATABASE: + HandleDatabaseCommand(command, argv, argc, reply); + return; + + case MIMCMD_PROXY: + HandleProxyCommand(command, argv, argc, reply); + return; + + case MIMCMD_CONTACTS: + HandleContactsCommand(command, argv, argc, reply); + return; + + case MIMCMD_HISTORY: + HandleHistoryCommand(command, argv, argc, reply); + break; + + case MIMCMD_VERSION: + HandleVersionCommand(command, argv, argc, reply); + return; + + case MIMCMD_SETNICKNAME: + HandleSetNicknameCommand(command, argv, argc, reply); + return; + + case MIMCMD_IGNORE: + HandleIgnoreCommand(command, argv, argc, reply); + return; + + default: + reply->code = MIMRES_NOTFOUND; + mir_snprintf(reply->message, reply->cMessage, Translate("Command '%s' is not currently supported."), command->command); + } } \ No newline at end of file diff --git a/plugins/CmdLine/src/mimcmd_handlers.h b/plugins/CmdLine/src/mimcmd_handlers.h index 565c7e3ec5..1a30ccaeae 100644 --- a/plugins/CmdLine/src/mimcmd_handlers.h +++ b/plugins/CmdLine/src/mimcmd_handlers.h @@ -34,22 +34,4 @@ extern PLUGININFOEX pluginInfo; void HandleCommand(PCommand command, TArgument *argv, int argc, PReply reply); -void HandleStatusCommand(PCommand command, TArgument *argv, int argc, PReply reply); -void HandleAwayMsgCommand(PCommand command, TArgument *argv, int argc, PReply reply); -void HandlePopupsCommand(PCommand command, TArgument *argv, int argc, PReply reply); -void HandleSoundsCommand(PCommand command, TArgument *argv, int argc, PReply reply); -void HandleClistCommand(PCommand command, TArgument *argv, int argc, PReply reply); -void HandleQuitCommand(PCommand command, TArgument *argv, int argc, PReply reply); -void HandleExchangeCommand(PCommand command, TArgument *argv, int argc, PReply reply); -void HandleYAMNCommand(PCommand command, TArgument *argv, int argc, PReply reply); -void HandleCallServiceCommand(PCommand command, TArgument *argv, int argc, PReply reply); -void HandleMessageCommand(PCommand command, TArgument *argv, int argc, PReply reply); -void HandleDatabaseCommand(PCommand command, TArgument *argv, int argc, PReply reply); -void HandleProxyCommand(PCommand command, TArgument *argv, int argc, PReply reply); -void HandleContactsCommand(PCommand command, TArgument *argv, int argc, PReply reply); -void HandleHistoryCommand(PCommand command, TArgument *argv, int argc, PReply reply); -void HandleVersionCommand(PCommand command, TArgument *argv, int argc, PReply reply); -void HandleSetNicknameCommand(PCommand command, TArgument *argv, int argc, PReply reply); -void HandleIgnoreCommand(PCommand command, TArgument *argv, int argc, PReply reply); - #endif //M_MIMCMD_HANDLERS_H \ No newline at end of file diff --git a/plugins/New_GPG/src/main.cpp b/plugins/New_GPG/src/main.cpp index 29783517fa..d8aef76a1e 100755 --- a/plugins/New_GPG/src/main.cpp +++ b/plugins/New_GPG/src/main.cpp @@ -14,11 +14,12 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - - #include "commonheaders.h" +extern HFONT bold_font; +extern bool bAutoExchange; + +void ShowFirstRunDialog(); HWND hwndFirstRun = NULL, hwndSetDirs = NULL, hwndNewKey = NULL, hwndKeyGen = NULL, hwndSelectExistingKey = NULL; @@ -249,7 +250,7 @@ static INT_PTR CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR } } { - SendMessageA(GetDlgItem(hwndDlg, IDC_ACCOUNT), CB_ADDSTRING, 0, (LPARAM)Translate("Default")); + SendDlgItemMessageA(hwndDlg, IDC_ACCOUNT, CB_ADDSTRING, 0, (LPARAM)Translate("Default")); int count = 0; PROTOACCOUNT **accounts; ProtoEnumAccounts(&count, &accounts); @@ -264,9 +265,9 @@ static INT_PTR CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR acc += accounts[i]->szModuleName; acc += ")"; //acc += "_KeyID"; - SendMessageA(GetDlgItem(hwndDlg, IDC_ACCOUNT), CB_ADDSTRING, 0, (LPARAM)acc.c_str()); + SendDlgItemMessageA(hwndDlg, IDC_ACCOUNT, CB_ADDSTRING, 0, (LPARAM)acc.c_str()); } - SendMessageA(GetDlgItem(hwndDlg, IDC_ACCOUNT), CB_SELECTSTRING, 0, (LPARAM)Translate("Default")); + SendDlgItemMessageA(hwndDlg, IDC_ACCOUNT, CB_SELECTSTRING, 0, (LPARAM)Translate("Default")); string keyinfo = Translate("key ID"); keyinfo += ": "; char *keyid = UniGetContactSettingUtf(NULL, szGPGModuleName, "KeyID", ""); @@ -577,7 +578,7 @@ static INT_PTR CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR params.result = &result; extern HFONT bold_font; SendMessage(GetDlgItem(hwndDlg, IDC_GENERATING_KEY), WM_SETFONT, (WPARAM)bold_font, true); - SetWindowTextA(GetDlgItem(hwndDlg, IDC_GENERATING_KEY), Translate("Generating new random key, please wait")); + SetWindowText(GetDlgItem(hwndDlg, IDC_GENERATING_KEY), TranslateT("Generating new random key, please wait")); EnableWindow(GetDlgItem(hwndDlg, IDC_GENERATE_KEY), 0); EnableWindow(GetDlgItem(hwndDlg, IDC_OTHER), 0); EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE_KEY), 0); @@ -705,9 +706,9 @@ static INT_PTR CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR char *szKey = (char*)GlobalLock(hMem); if(!szKey) { - char msg[64]; - mir_snprintf(msg, 64, "Failed to lock memory with error %d", GetLastError()); - MessageBoxA(0, msg, "Error", MB_OK); + TCHAR msg[64]; + mir_sntprintf(msg, 64, TranslateT("Failed to lock memory with error %d"), GetLastError()); + MessageBox(0, msg, TranslateT("Error"), MB_OK); GlobalFree(hMem); } memcpy(szKey, out.c_str(), out.size()); @@ -717,9 +718,9 @@ static INT_PTR CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR if(!SetClipboardData(CF_OEMTEXT, hMem)) { GlobalFree(hMem); - char msg[64]; - mir_snprintf(msg, 64, "Failed write to clipboard with error %d", GetLastError()); - MessageBoxA(0, msg, "Error", MB_OK); + TCHAR msg[64]; + mir_sntprintf(msg, 64, TranslateT("Failed write to clipboard with error %d"), GetLastError()); + MessageBox(0, msg, TranslateT("Error"), MB_OK); } CloseClipboard(); } @@ -845,8 +846,6 @@ static INT_PTR CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR return FALSE; } -void ShowFirstRunDialog(); - static INT_PTR CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { TCHAR *tmp = NULL; @@ -1298,8 +1297,7 @@ static INT_PTR CALLBACK DlgProcNewKeyDialog(HWND hwndDlg, UINT msg, WPARAM wPara SetDlgItemText(hwndDlg, ID_IMPORT, tmp[0]?TranslateT("Replace"):TranslateT("Accept")); mir_free(tmp); tmp = new TCHAR [256]; - _tcscpy(tmp, TranslateT("Received key from ")); - _tcscat(tmp, (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, (LPARAM)GCDNF_TCHAR)); + mir_sntprintf(tmp, SIZEOF(tmp),TranslateT("Received key from %s"), CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, (LPARAM)GCDNF_TCHAR)); SetDlgItemText(hwndDlg, IDC_KEY_FROM, tmp); delete [] tmp; } @@ -1526,9 +1524,8 @@ static INT_PTR CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wPara params.out = &out; params.code = &code; params.result = &result; - extern HFONT bold_font; SendMessage(GetDlgItem(hwndDlg, IDC_GENERATING_TEXT), WM_SETFONT, (WPARAM)bold_font, true); - SetWindowTextA(GetDlgItem(hwndDlg, IDC_GENERATING_TEXT), Translate("Generating new key, please wait...")); + SetWindowText(GetDlgItem(hwndDlg, IDC_GENERATING_TEXT), TranslateT("Generating new key, please wait...")); EnableWindow(GetDlgItem(hwndDlg, IDCANCEL), 0); EnableWindow(GetDlgItem(hwndDlg, IDOK), 0); EnableWindow(GetDlgItem(hwndDlg, IDC_KEY_TYPE), 0); @@ -2049,13 +2046,13 @@ void InitCheck() } if(!home_dir_access || !temp_access || !gpg_valid) { - char buf[4096]; - strcpy(buf, gpg_valid?Translate("GPG binary is set and valid (this is good).\n"):Translate("GPG binary unset or invalid (plugin will not work).\n")); - strcat(buf, home_dir_access?Translate("Home dir write access granted (this is good).\n"):Translate("Home dir has no write access (plugin most probably will not work).\n")); - strcat(buf, temp_access?Translate("Temp dir write access granted (this is good).\n"):Translate("Temp dir has no write access (plugin should work, but may have some problems, file transfers will not work).")); + TCHAR buf[4096]; + _tcsncpy(buf, gpg_valid?TranslateT("GPG binary is set and valid (this is good).\n"):TranslateT("GPG binary unset or invalid (plugin will not work).\n"), SIZEOF(buf)); + _tcsncat(buf, home_dir_access?TranslateT("Home dir write access granted (this is good).\n"):TranslateT("Home dir has no write access (plugin most probably will not work).\n"), SIZEOF(buf)); + _tcsncat(buf, temp_access?TranslateT("Temp dir write access granted (this is good).\n"):TranslateT("Temp dir has no write access (plugin should work, but may have some problems, file transfers will not work)."), SIZEOF(buf)); if(!gpg_valid) - strcat(buf, Translate("\nGPG will be disabled until you solve these problems")); - MessageBoxA(0, buf, Translate("GPG plugin problems"), MB_OK); + _tcsncat(buf, TranslateT("\nGPG will be disabled until you solve these problems")); + MessageBox(0, buf, TranslateT("GPG plugin problems"), MB_OK); } if(!gpg_valid) return; @@ -2105,7 +2102,6 @@ void InitCheck() mir_free(keyid); keyid = UniGetContactSettingUtf(NULL, szGPGModuleName, "KeyID", ""); key = UniGetContactSettingUtf(NULL, szGPGModuleName, "GPGPubKey", ""); - void ShowFirstRunDialog(); if((p = out.find(keyid)) == string::npos) { question += keyid; @@ -2169,7 +2165,6 @@ void InitCheck() question = Translate("Your secret key with ID: "); keyid = UniGetContactSettingUtf(NULL, szGPGModuleName, "KeyID", ""); key = UniGetContactSettingUtf(NULL, szGPGModuleName, "GPGPubKey", ""); - void ShowFirstRunDialog(); if(!db_get_b(NULL, szGPGModuleName, "FirstRun", 1) && (!keyid[0] || !key[0])) { question = Translate("You didn't set a private key.\nWould you like to set it now?"); @@ -2239,7 +2234,6 @@ void InitCheck() } mir_free(path); } - extern bool bAutoExchange; if(bAutoExchange) { int count = 0; diff --git a/plugins/New_GPG/src/options.cpp b/plugins/New_GPG/src/options.cpp index b7db869e86..a8f5ff9193 100755 --- a/plugins/New_GPG/src/options.cpp +++ b/plugins/New_GPG/src/options.cpp @@ -355,9 +355,9 @@ static INT_PTR CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP szKey = (char*)GlobalLock(hMem); if(!szKey) { - char msg[64]; - mir_snprintf(msg, 64, "Failed to lock memory with error %d", GetLastError()); - MessageBoxA(0, msg, "Error", MB_OK); + TCHAR msg[64]; + mir_sntprintf(msg, 64, TranslateT("Failed to lock memory with error %d"), GetLastError()); + MessageBox(0, msg, TranslateT("Error"), MB_OK); GlobalFree(hMem); } memcpy(szKey, str.c_str(), str.size()); @@ -368,17 +368,17 @@ static INT_PTR CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP if(!SetClipboardData(CF_OEMTEXT, hMem)) { GlobalFree(hMem); - char msg[64]; - mir_snprintf(msg, 64, "Failed write to clipboard with error %d", GetLastError()); - MessageBoxA(0, msg, "Error", MB_OK); + TCHAR msg[64]; + mir_sntprintf(msg, 64, TranslateT("Failed write to clipboard with error %d"), GetLastError()); + MessageBox(0, msg, TranslateT("Error"), MB_OK); } CloseClipboard(); } else { - char msg[64]; - mir_snprintf(msg, 64, "Failed to open clipboard with error %d", GetLastError()); - MessageBoxA(0, msg, "Error", MB_OK); + TCHAR msg[64]; + mir_sntprintf(msg, 64, TranslateT("Failed to open clipboard with error %d"), GetLastError()); + MessageBox(0, msg, TranslateT("Error"), MB_OK); } } break; @@ -734,9 +734,9 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam hcnt = metaGetMostOnline(hcnt); TranslateDialogDefault(hwndDlg); { - string msg = Translate("Load Public GPG Key for "); - msg += (char*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hcnt, 0); - SetWindowTextA(hwndDlg, msg.c_str()); + wstring msg = TranslateT("Load Public GPG Key for "); + msg += (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hcnt, GCDNF_TCHAR); + SetWindowText(hwndDlg, msg.c_str()); } if(!hcnt) { diff --git a/plugins/New_GPG/src/utilities.cpp b/plugins/New_GPG/src/utilities.cpp index dcbebe2379..e5f67a539b 100755 --- a/plugins/New_GPG/src/utilities.cpp +++ b/plugins/New_GPG/src/utilities.cpp @@ -17,6 +17,12 @@ #include "commonheaders.h" +void ShowExportKeysDlg(); +void ShowLoadPublicKeyDialog(); + +extern HINSTANCE hInst; +extern HANDLE hLoadPublicKey; +extern HGENMENU hToggleEncryption, hSendKey; TCHAR* __stdcall UniGetContactSettingUtf(MCONTACT hContact, const char *szModule,const char* szSetting, TCHAR* szDef) { @@ -135,9 +141,8 @@ void GetFolderPath(TCHAR *WindowTittle, char *szSetting) } } -INT_PTR LoadKey(WPARAM w, LPARAM l) +INT_PTR LoadKey(WPARAM w, LPARAM) { - void ShowLoadPublicKeyDialog(); user_data[1] = (MCONTACT)w; ShowLoadPublicKeyDialog(); return 0; @@ -196,9 +201,6 @@ INT_PTR SendKey(WPARAM w, LPARAM l) return 0; } -extern HANDLE hLoadPublicKey; -extern HGENMENU hToggleEncryption, hSendKey; - INT_PTR ToggleEncryption(WPARAM w, LPARAM l) { MCONTACT hContact = (MCONTACT)w; @@ -1244,9 +1246,9 @@ __forceinline int SendBroadcast(MCONTACT hContact, int type, int result, HANDLE return ProtoBroadcastAck( GetContactProto(hContact), hContact, type, result, hProcess, lParam); } -unsigned __stdcall sttFakeAck( LPVOID param ) +unsigned __stdcall sttFakeAck(void *param) { - TFakeAckParams* tParam = ( TFakeAckParams* )param; + TFakeAckParams *tParam = ( TFakeAckParams* )param; WaitForSingleObject( tParam->hEvent, INFINITE ); Sleep( 100 ); @@ -1368,7 +1370,7 @@ bool isTabsrmmUsed() DBCONTACTENUMSETTINGS enm = {0}; bool found = false; enm.lParam = (LPARAM)&found; - enm.pfnEnumProc = (DBSETTINGENUMPROC)&handleEnum; + enm.pfnEnumProc = handleEnum; enm.szModule = "PluginDisable"; if(CallService(MS_DB_CONTACT_ENUMSETTINGS, 0, (LPARAM)&enm) == -1) return false; @@ -1546,19 +1548,18 @@ void ExportGpGKeysFunc(int type) } if(file.is_open()) file.close(); - char msg[512]; + TCHAR msg[512]; if(type == 2) - mir_snprintf(msg, 512, "%s %d %s %s %s", Translate("we have successfully exported"), exported_keys, Translate("public keys"), Translate("and"), Translate("all private keys")); + mir_sntprintf(msg, 512, TranslateT("We have successfully exported %d public keys and all private keys."), exported_keys); else if(type == 1) - mir_snprintf(msg, 512, "%s %s", Translate("we have successfully exported"), Translate("all private keys")); + mir_sntprintf(msg, 512, TranslateT("We have successfully exported all private keys.")); else if(!type) - mir_snprintf(msg, 512, "%s %d %s",Translate("we have successfully exported"), exported_keys, Translate("public keys")); - MessageBoxA(NULL, msg, Translate("Keys export result"), MB_OK); + mir_sntprintf(msg, 512, TranslateT("We have successfully exported %d public keys."), exported_keys); + MessageBox(NULL, msg, TranslateT("Keys export result"), MB_OK); } -INT_PTR ExportGpGKeys(WPARAM w, LPARAM l) +INT_PTR ExportGpGKeys(WPARAM, LPARAM) { - void ShowExportKeysDlg(); ShowExportKeysDlg(); return 0; } @@ -1896,12 +1897,12 @@ INT_PTR ImportGpGKeys(WPARAM w, LPARAM l) } if(file.is_open()) file.close(); - char msg[512]; + TCHAR msg[512]; if(processed_private_keys) - mir_snprintf(msg, 512, "we have successfully processed %d public keys and some private keys", processed_keys); + mir_sntprintf(msg, 512, TranslateT("We have successfully processed %d public keys and some private keys."), processed_keys); else - mir_snprintf(msg, 512, "we have successfully processed %d public keys", processed_keys); - MessageBoxA(NULL, msg, Translate("Keys import result"), MB_OK); + mir_sntprintf(msg, 512, TranslateT("We have successfully processed %d public keys."), processed_keys); + MessageBox(NULL, msg, TranslateT("Keys import result"), MB_OK); return 0; } @@ -2068,7 +2069,6 @@ static INT_PTR CALLBACK DlgProcExportKeys(HWND hwndDlg, UINT msg, WPARAM wParam, void ShowExportKeysDlg() { - extern HINSTANCE hInst; DialogBox(hInst, MAKEINTRESOURCE(IDD_EXPORT_TYPE), NULL, DlgProcExportKeys); } -- cgit v1.2.3