summaryrefslogtreecommitdiff
path: root/plugins/MirOTR/src
diff options
context:
space:
mode:
authorRené Schümann <white06tiger@gmail.com>2015-03-26 20:42:04 +0000
committerRené Schümann <white06tiger@gmail.com>2015-03-26 20:42:04 +0000
commite3dac6207e1bc1c0194e236a058a5eef12627d2c (patch)
tree2d3cf5af79a301f5511cb72c537daf430779577d /plugins/MirOTR/src
parentb2f75299d07e7dd789c62584e034aba712e21735 (diff)
MirOTR: cleaned-up our OTR messages and other string stuff (such as using mir_strncpy instead of unsafe strncpy)
git-svn-id: http://svn.miranda-ng.org/main/trunk@12512 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirOTR/src')
-rw-r--r--plugins/MirOTR/src/language.h7
-rw-r--r--plugins/MirOTR/src/options.cpp9
-rw-r--r--plugins/MirOTR/src/otr.cpp26
3 files changed, 18 insertions, 24 deletions
diff --git a/plugins/MirOTR/src/language.h b/plugins/MirOTR/src/language.h
index 7cbc127b1d..a64c2e0b31 100644
--- a/plugins/MirOTR/src/language.h
+++ b/plugins/MirOTR/src/language.h
@@ -35,13 +35,6 @@
#define LANG_OTR_INFO LPGEN("OTR Information")
#define LANG_INLINE_PREFIX LPGEN("[OTR INFO] ")
-#define LANG_SMP_AUTH_FROM LPGEN("Authentication from %s")
-#define LANG_SMP_AUTH LPGEN("Authenticate %s")
-
-#define LANG_UNKNOWN LPGEN("Unknown")
-#define LANG_OTR_USERMESSAGE LPGEN("OTR: %s (%s)")
-#define LANG_OTR_NOTIFY LPGEN("OTR %s (%s)")
-
#define LANG_FINGERPRINT_VERIFIED LPGEN("OTR encrypted session with '%s' is now using a VERIFIED fingerprint")
#define LANG_FINGERPRINT_NOT_VERIFIED LPGEN("OTR encrypted session with '%s' is now using a NOT VERIFIED fingerprint")
diff --git a/plugins/MirOTR/src/options.cpp b/plugins/MirOTR/src/options.cpp
index c547d7afde..fed648e2c4 100644
--- a/plugins/MirOTR/src/options.cpp
+++ b/plugins/MirOTR/src/options.cpp
@@ -86,11 +86,10 @@ void LoadOptions() {
DBVARIANT dbv;
if (!db_get_utf(0, MODULENAME, "Prefix", &dbv)) {
- strncpy(options.prefix, dbv.pszVal, OPTIONS_PREFIXLEN-1);
- options.prefix[OPTIONS_PREFIXLEN-1] = 0;
+ mir_strncpy(options.prefix, dbv.pszVal, OPTIONS_PREFIXLEN);
db_free(&dbv);
} else
- strncpy(options.prefix, OPTIONS_DEFAULT_PREFIX, OPTIONS_PREFIXLEN-1);
+ mir_strncpy(options.prefix, OPTIONS_DEFAULT_PREFIX, OPTIONS_PREFIXLEN);
options.end_offline = (db_get_b(0, MODULENAME, "EndOffline", 1) == 1);
options.end_window_close = (db_get_b(0, MODULENAME, "EndWindowClose", 0) == 1);
@@ -267,9 +266,9 @@ static INT_PTR CALLBACK DlgProcMirOTROpts(HWND hwndDlg, UINT msg, WPARAM wParam,
mir_free(prefix);
if(!prefix_utf[0]){
SetDlgItemTextA(hwndDlg, IDC_ED_PREFIX, OPTIONS_DEFAULT_PREFIX);
- strncpy(options.prefix, OPTIONS_DEFAULT_PREFIX, OPTIONS_PREFIXLEN-1);
+ mir_strncpy(options.prefix, OPTIONS_DEFAULT_PREFIX, OPTIONS_PREFIXLEN);
} else
- strncpy(options.prefix, prefix_utf, OPTIONS_PREFIXLEN-1);
+ mir_strncpy(options.prefix, prefix_utf, OPTIONS_PREFIXLEN);
mir_free(prefix_utf);
SaveOptions();
diff --git a/plugins/MirOTR/src/otr.cpp b/plugins/MirOTR/src/otr.cpp
index 8873dfc23b..9d2d5867a0 100644
--- a/plugins/MirOTR/src/otr.cpp
+++ b/plugins/MirOTR/src/otr.cpp
@@ -301,6 +301,8 @@ extern "C" {
MCONTACT hContact = (MCONTACT)opdata;
const TCHAR* contact = contact_get_nameT(hContact);
+ typedef void (*msgfunc_t)(const MCONTACT,const TCHAR*);
+ msgfunc_t msgfunc=ShowMessage;
// TCHAR* title = NULL;
TCHAR msg[512];
msg[0] = '\0';
@@ -311,16 +313,16 @@ extern "C" {
case OTRL_MSGEVENT_RCVDMSG_UNRECOGNIZED:
break;
case OTRL_MSGEVENT_ENCRYPTION_REQUIRED:
-// title = TranslateT("OTR Policy Violation");
+ msgfunc=ShowMessageInline;
mir_tstrncpy(msg,TranslateT("Attempting to start a private conversation..."),SIZEOF(msg));
break;
case OTRL_MSGEVENT_ENCRYPTION_ERROR:
-// title = TranslateT("Error encrypting message");
- mir_tstrncpy(msg,TranslateT("An error occurred when encrypting your message.\nThe message was not sent."),SIZEOF(msg));
+ msgfunc=ShowMessageInline;
+ mir_tstrncpy(msg,TranslateT("An error occurred when encrypting your message.\nThe message was not sent"),SIZEOF(msg));
break;
case OTRL_MSGEVENT_CONNECTION_ENDED:
-// title = TranslateT("Your message was not sent.");
- mir_snwprintf(msg,SIZEOF(msg),TranslateT("%s has already closed his/her private connection to you; you should do the same."),contact);
+ msgfunc=ShowMessageInline;
+ mir_snwprintf(msg,SIZEOF(msg),TranslateT("'%s' has already closed his/her private connection to you; you should do the same"),contact);
break;
case OTRL_MSGEVENT_SETUP_ERROR:
// title = TranslateT("OTR Error");
@@ -337,23 +339,23 @@ extern "C" {
break;
case OTRL_MSGEVENT_MSG_REFLECTED:
// title = TranslateT("OTR Error");
- mir_tstrncpy(msg,TranslateT("We are receiving our own OTR messages.\nYou are either trying to talk to yourself, or someone is reflecting your messages back at you."),SIZEOF(msg));
+ mir_tstrncpy(msg,TranslateT("We are receiving our own OTR messages.\nYou are either trying to talk to yourself, or someone is reflecting your messages back at you"),SIZEOF(msg));
break;
case OTRL_MSGEVENT_MSG_RESENT:
// title = TranslateT("Message resent");
- mir_snwprintf(msg,SIZEOF(msg),TranslateT("The last message to %s was resent."),contact);
+ mir_snwprintf(msg,SIZEOF(msg),TranslateT("The last message to '%s' was resent"),contact);
break;
case OTRL_MSGEVENT_RCVDMSG_NOT_IN_PRIVATE:
// title = TranslateT("Unreadable message");
- mir_snwprintf(msg,SIZEOF(msg),TranslateT("The encrypted message received from %s is unreadable, as you are not currently communicating privately."),contact);
+ mir_snwprintf(msg,SIZEOF(msg),TranslateT("The encrypted message received from '%s' is unreadable, as you are not currently communicating privately"),contact);
break;
case OTRL_MSGEVENT_RCVDMSG_UNREADABLE:
// title = TranslateT("OTR Error");
- mir_snwprintf(msg,SIZEOF(msg),TranslateT("We received an unreadable encrypted message from %s."),contact);
+ mir_snwprintf(msg,SIZEOF(msg),TranslateT("We received an unreadable encrypted message from '%s'"),contact);
break;
case OTRL_MSGEVENT_RCVDMSG_MALFORMED:
// title = TranslateT("OTR Error");
- mir_snwprintf(msg,SIZEOF(msg),TranslateT("We received a malformed data message from %s."),contact);
+ mir_snwprintf(msg,SIZEOF(msg),TranslateT("We received a malformed data message from '%s'"),contact);
break;
case OTRL_MSGEVENT_RCVDMSG_GENERAL_ERR:{
// title = TranslateT("OTR Error");
@@ -369,14 +371,14 @@ extern "C" {
break;}
case OTRL_MSGEVENT_RCVDMSG_FOR_OTHER_INSTANCE:
// title = TranslateT("Received message for a different session");
- mir_snwprintf(msg,SIZEOF(msg),TranslateT("%s has sent a message intended for a different session. If you are logged in multiple times, another session may have received the message."),contact);
+ mir_snwprintf(msg,SIZEOF(msg),TranslateT("'%s' has sent a message intended for a different session. If you are logged in multiple times, another session may have received the message."),contact);
break;
default:
// title = TranslateT("OTR Error");
mir_tstrncpy(msg,TranslateT("unknown OTR message received, please report that to Miranda NG"),SIZEOF(msg));
}
if(msg[0])
- ShowMessage(hContact,msg);
+ msgfunc(hContact,msg);
}
void otr_create_instag(void *opdata, const char *accountname, const char *protocol){