From 08dc125be616458112368e7154b29d5d23f1126e Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 19 Jul 2012 08:02:41 +0000 Subject: Unicode in status message plugins git-svn-id: http://svn.miranda-ng.org/main/trunk@1033 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/StatusPlugins/StartupStatus/options.cpp | 12 ++++++------ plugins/StatusPlugins/StartupStatus/profiles.cpp | 12 ++++++------ plugins/StatusPlugins/StartupStatus/startupstatus.cpp | 6 +++--- plugins/StatusPlugins/StartupStatus/startupstatus.h | 4 ++-- 4 files changed, 17 insertions(+), 17 deletions(-) (limited to 'plugins/StatusPlugins/StartupStatus') diff --git a/plugins/StatusPlugins/StartupStatus/options.cpp b/plugins/StatusPlugins/StartupStatus/options.cpp index 107cf06e99..410412072c 100644 --- a/plugins/StatusPlugins/StartupStatus/options.cpp +++ b/plugins/StatusPlugins/StartupStatus/options.cpp @@ -442,7 +442,7 @@ static INT_PTR CALLBACK StartupStatusOptDlgProc(HWND hwndDlg,UINT msg,WPARAM wPa GetProfile( defProfile, *ps ); for ( int i=0; i < ps->getCount(); i++ ) if ( (*ps)[i].szMsg != NULL ) - (*ps)[i].szMsg = _strdup( (*ps)[i].szMsg ); + (*ps)[i].szMsg = _tcsdup( (*ps)[i].szMsg ); CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_CMDLOPTIONS), hwndDlg, CmdlOptionsDlgProc, (LPARAM)ps); } @@ -551,7 +551,7 @@ static INT_PTR CALLBACK StatusProfilesOptDlgProc(HWND hwndDlg,UINT msg,WPARAM wP else { for (int j=0; j < ar.getCount(); j++) if ( ar[j].szMsg != NULL) - ar[j].szMsg = _strdup( ar[j].szMsg ); + ar[j].szMsg = _tcsdup( ar[j].szMsg ); ppo->szName = db_get_sa(NULL, MODULENAME, OptName(i, SETTING_PROFILENAME)); if (ppo->szName == NULL) { @@ -662,7 +662,7 @@ static INT_PTR CALLBACK StatusProfilesOptDlgProc(HWND hwndDlg,UINT msg,WPARAM wP CheckRadioButton(hwndDlg, IDC_MIRANDAMSG, IDC_CUSTOMMSG, ps->szMsg!=NULL?IDC_CUSTOMMSG:IDC_MIRANDAMSG); if (ps->szMsg != NULL) - SetDlgItemTextA(hwndDlg, IDC_STATUSMSG, ps->szMsg); + SetDlgItemText(hwndDlg, IDC_STATUSMSG, ps->szMsg); bStatusMsg = ( (((CallProtoService(ps->szName, PS_GETCAPS, (WPARAM)PFLAGNUM_1, 0)&PF1_MODEMSGSEND&~PF1_INDIVMODEMSG)) && (CallProtoService(ps->szName, PS_GETCAPS, (WPARAM)PFLAGNUM_3, 0)&Proto_Status2Flag(ps->status))) || (ps->status == ID_STATUS_CURRENT) || (ps->status == ID_STATUS_LAST)); @@ -754,7 +754,7 @@ static INT_PTR CALLBACK StatusProfilesOptDlgProc(HWND hwndDlg,UINT msg,WPARAM wP ps->szMsg = NULL; if (IsDlgButtonChecked(hwndDlg, IDC_CUSTOMMSG)) { len = SendDlgItemMessage(hwndDlg, IDC_STATUSMSG, WM_GETTEXTLENGTH, 0, 0); - ps->szMsg = (char *)malloc(len+1); + ps->szMsg = (TCHAR*)calloc(sizeof(TCHAR), len+1); memset(ps->szMsg, '\0', len+1); SendDlgItemMessage(hwndDlg, IDC_STATUSMSG, WM_GETTEXT, (WPARAM)len+1, (LPARAM)ps->szMsg); } @@ -774,7 +774,7 @@ static INT_PTR CALLBACK StatusProfilesOptDlgProc(HWND hwndDlg,UINT msg,WPARAM wP ps->szMsg = NULL; } int len = SendDlgItemMessageA(hwndDlg, IDC_STATUSMSG, WM_GETTEXTLENGTH, 0, 0); - ps->szMsg = (char *)malloc(len+1); + ps->szMsg = (TCHAR*)calloc(sizeof(TCHAR), len+1); memset(ps->szMsg, '\0', len+1); SendDlgItemMessageA(hwndDlg, IDC_STATUSMSG, WM_GETTEXT, (WPARAM)len+1, (LPARAM)ps->szMsg); } @@ -851,7 +851,7 @@ static INT_PTR CALLBACK StatusProfilesOptDlgProc(HWND hwndDlg,UINT msg,WPARAM wP for ( j=0; j < ar.getCount(); j++ ) { if ( ar[j].szMsg != NULL ) { mir_snprintf(setting, sizeof(setting), "%s_%s", ar[j].szName, SETTING_PROFILE_STSMSG); - db_set_s(NULL, MODULENAME, OptName(i, setting), ar[j].szMsg); + db_set_ts(NULL, MODULENAME, OptName(i, setting), ar[j].szMsg); } db_set_w(NULL, MODULENAME, OptName(i, ar[j].szName), ar[j].status); } diff --git a/plugins/StatusPlugins/StartupStatus/profiles.cpp b/plugins/StatusPlugins/StartupStatus/profiles.cpp index dbf7ebec82..3cb20918f8 100644 --- a/plugins/StatusPlugins/StartupStatus/profiles.cpp +++ b/plugins/StatusPlugins/StartupStatus/profiles.cpp @@ -183,7 +183,7 @@ INT_PTR GetProfileCount(WPARAM wParam, LPARAM lParam) return count; } -char *GetStatusMessage(int profile, char *szProto) +TCHAR *GetStatusMessage(int profile, char *szProto) { char dbSetting[80]; DBVARIANT dbv; @@ -191,10 +191,10 @@ char *GetStatusMessage(int profile, char *szProto) for ( int i=0; i < pceCount; i++ ) { if ( (pce[i].profile == profile) && (!strcmp(pce[i].szProto, szProto))) { _snprintf(dbSetting, sizeof(dbSetting), "%d_%s_%s", profile, szProto, SETTING_PROFILE_STSMSG); - if (!DBGetContactSetting(NULL, MODULENAME, dbSetting, &dbv)) { // reload from db - pce[i].msg = ( char* )realloc(pce[i].msg, strlen(dbv.pszVal)+1); + if (!DBGetContactSettingTString(NULL, MODULENAME, dbSetting, &dbv)) { // reload from db + pce[i].msg = ( TCHAR* )realloc(pce[i].msg, sizeof(TCHAR)*(_tcslen(dbv.ptszVal)+1)); if (pce[i].msg != NULL) { - strcpy(pce[i].msg, dbv.pszVal); + _tcscpy(pce[i].msg, dbv.ptszVal); } DBFreeVariant(&dbv); } @@ -215,8 +215,8 @@ char *GetStatusMessage(int profile, char *szProto) pce[pceCount].szProto = _strdup(szProto); pce[pceCount].msg = NULL; _snprintf(dbSetting, sizeof(dbSetting), "%d_%s_%s", profile, szProto, SETTING_PROFILE_STSMSG); - if (!DBGetContactSetting(NULL, MODULENAME, dbSetting, &dbv)) { - pce[pceCount].msg = _strdup(dbv.pszVal); + if (!DBGetContactSettingTString(NULL, MODULENAME, dbSetting, &dbv)) { + pce[pceCount].msg = _tcsdup(dbv.ptszVal); DBFreeVariant(&dbv); } pceCount += 1; diff --git a/plugins/StatusPlugins/StartupStatus/startupstatus.cpp b/plugins/StatusPlugins/StartupStatus/startupstatus.cpp index 7028868272..e1445a7704 100644 --- a/plugins/StatusPlugins/StartupStatus/startupstatus.cpp +++ b/plugins/StatusPlugins/StartupStatus/startupstatus.cpp @@ -64,7 +64,7 @@ TSSSetting::TSSSetting( int profile, PROTOACCOUNT* pa ) szMsg = GetStatusMessage(profile, szName); if ( szMsg ) - szMsg = _strdup( szMsg ); + szMsg = _tcsdup( szMsg ); } TSSSetting::~TSSSetting() @@ -178,8 +178,8 @@ static void SetLastStatusMessages(TSettingsList& ps) _snprintf(dbSetting, sizeof(dbSetting), "%s%s", PREFIX_LASTMSG, ps[i].szName); DBVARIANT dbv; - if ( ps[i].szMsg == NULL && !DBGetContactSetting(NULL, MODULENAME, dbSetting, &dbv)) { - ps[i].szMsg = _strdup(dbv.pszVal); // remember this won't be freed + if ( ps[i].szMsg == NULL && !DBGetContactSettingTString(NULL, MODULENAME, dbSetting, &dbv)) { + ps[i].szMsg = _tcsdup(dbv.ptszVal); // remember this won't be freed DBFreeVariant(&dbv); } } } diff --git a/plugins/StatusPlugins/StartupStatus/startupstatus.h b/plugins/StatusPlugins/StartupStatus/startupstatus.h index d6248ba4b2..640638f788 100644 --- a/plugins/StatusPlugins/StartupStatus/startupstatus.h +++ b/plugins/StatusPlugins/StartupStatus/startupstatus.h @@ -45,7 +45,7 @@ struct PROFILECE { int profile; char *szProto; - char *msg; + TCHAR *msg; }; struct PROFILEOPTIONS @@ -152,7 +152,7 @@ TSettingsList* GetCurrentProtoSettings(); // profile int GetProfile(int profileID, TSettingsList& arSettings ); -char *GetStatusMessage(int profile, char *szProto); +TCHAR *GetStatusMessage(int profile, char *szProto); INT_PTR LoadAndSetProfile(WPARAM wParam, LPARAM lParam); INT_PTR GetProfileCount(WPARAM wParam, LPARAM lParam); -- cgit v1.2.3