summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGluzskiy Alexandr <sss@sss.chaoslab.ru>2012-09-11 01:33:53 +0300
committerGluzskiy Alexandr <sss@sss.chaoslab.ru>2012-09-11 01:33:53 +0300
commitdf91299c0082a489e3a45f06b1cb52f2162b883d (patch)
tree45ca826f58126f43c7563b4a4e5880d2b67818c7
parent5631c9efc283f72fdaf4eb3ed6212b0d3dee8d7f (diff)
ported changes from miranda_ng branch
-rwxr-xr-xicons.cpp3
-rwxr-xr-xinit.cpp25
-rwxr-xr-xmain.cpp380
-rwxr-xr-xmessages.cpp4
-rwxr-xr-xoptions.cpp20
-rwxr-xr-xutilities.cpp23
6 files changed, 281 insertions, 174 deletions
diff --git a/icons.cpp b/icons.cpp
index 58a24c9..671be13 100755
--- a/icons.cpp
+++ b/icons.cpp
@@ -139,10 +139,9 @@ void setSrmmIcon(HANDLE h)
void RefreshContactListIcons()
{
- HANDLE hContact;
extern HANDLE g_hCLIcon;
CallService(MS_CLUI_LISTBEGINREBUILD,0,0);
- hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
+ HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
while (hContact)
{
setClistIcon(hContact);
diff --git a/init.cpp b/init.cpp
index 43f12d5..1ba5ab1 100755
--- a/init.cpp
+++ b/init.cpp
@@ -79,11 +79,11 @@ extern "C" __declspec(dllexport) const MUUID* MirandaPluginInterfaces(void)
return interfaces;
}
-int LoadKey(WPARAM w, LPARAM l);
-int ToggleEncryption(WPARAM w, LPARAM l);
-int SendKey(WPARAM w, LPARAM l);
-int ExportGpGKeys(WPARAM w, LPARAM l);
-int ImportGpGKeys(WPARAM w, LPARAM l);
+INT_PTR LoadKey(WPARAM w, LPARAM l);
+INT_PTR ToggleEncryption(WPARAM w, LPARAM l);
+INT_PTR SendKey(WPARAM w, LPARAM l);
+INT_PTR ExportGpGKeys(WPARAM w, LPARAM l);
+INT_PTR ImportGpGKeys(WPARAM w, LPARAM l);
void init_vars()
{
@@ -125,11 +125,12 @@ extern "C" int __declspec(dllexport) Load(PLUGINLINK *link)
mir_getUTFI(&utfi);
mir_getXI(&xi); //TODO: check if we have access to api
init_vars();
- CreateServiceFunction("/LoadPubKey",(MIRANDASERVICE)LoadKey);
- CreateServiceFunction("/ToggleEncryption",(MIRANDASERVICE)ToggleEncryption);
- CreateServiceFunction("/SendKey",(MIRANDASERVICE)SendKey);
- CreateServiceFunction("/ExportGPGKeys",(MIRANDASERVICE)ExportGpGKeys);
- CreateServiceFunction("/ImportGPGKeys",(MIRANDASERVICE)ImportGpGKeys);
+ CreateServiceFunction("/LoadPubKey",LoadKey);
+ CreateServiceFunction("/ToggleEncryption",ToggleEncryption);
+ CreateServiceFunction("/SendKey",SendKey);
+ CreateServiceFunction("/ExportGPGKeys",ExportGpGKeys);
+ CreateServiceFunction("/ImportGPGKeys",ImportGpGKeys);
+
CLISTMENUITEM mi = {0};
mi.cbSize=sizeof(mi);
mi.position=-0x7FFFFFFF;
@@ -237,7 +238,7 @@ static int OnModulesLoaded(WPARAM wParam,LPARAM lParam)
if(bJabberAPI && bIsMiranda09)
HookEvent(ME_PROTO_ACCLISTCHANGED, GetJabberInterface);
- HookEvent(ME_PROTO_ACK, onProtoAck); //filetransfer unimplemented now
+ HookEvent(ME_PROTO_ACK, onProtoAck);
HookEvent(ME_CLIST_PREBUILDCONTACTMENU, OnPreBuildContactMenu);
@@ -289,6 +290,6 @@ extern "C" int __declspec(dllexport) Unload(void)
mir_free(outopentag);
mir_free(outclosetag);
if(password)
- delete [] password;
+ mir_free(password);
return 0;
}
diff --git a/main.cpp b/main.cpp
index e28114c..a673e54 100755
--- a/main.cpp
+++ b/main.cpp
@@ -27,7 +27,7 @@ int itemnum = 0;
HWND hwndList_g = NULL;
BOOL CheckStateStoreDB(HWND hwndDlg, int idCtrl, const char* szSetting);
-static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam)
+static INT_PTR CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam)
{
HWND hwndList=GetDlgItem(hwndDlg, IDC_KEY_LIST);
hwndList_g = hwndList;
@@ -159,7 +159,12 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM
continue;
if(StriStr(accounts[i]->szModuleName, "weather"))
continue;
- SendMessageA(GetDlgItem(hwndDlg, IDC_ACCOUNT), CB_ADDSTRING, 0, (LPARAM)accounts[i]->szModuleName);
+ std::string acc = toUTF8(accounts[i]->tszAccountName);
+ acc += "(";
+ acc += accounts[i]->szModuleName;
+ acc += ")";
+ acc += "_KeyID";
+ SendMessageA(GetDlgItem(hwndDlg, IDC_ACCOUNT), CB_ADDSTRING, 0, (LPARAM)acc.c_str());
}
SendMessageA(GetDlgItem(hwndDlg, IDC_ACCOUNT), CB_SELECTSTRING, 0, (LPARAM)Translate("Default"));
string keyinfo = Translate("key id");
@@ -234,15 +239,29 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM
else
{
char setting[64];
- strcpy(setting, buf);
- strcat(setting, "_GPGPubKey");
- DBWriteContactSettingString(NULL, szGPGModuleName, setting, out.c_str());
- strcpy(setting, buf);
- strcat(setting, "_KeyMainName");
- DBWriteContactSettingTString(NULL, szGPGModuleName, setting, name);
- strcpy(setting, buf);
- strcat(setting, "_KeyID");
- DBWriteContactSettingTString(NULL, szGPGModuleName, setting, fp);
+ PROTOACCOUNT *acc = (PROTOACCOUNT*)CallService(MS_PROTO_GETCONTACTBASEPROTO, 0, (LPARAM)buf);
+ std::string acc_str;
+ if(acc)
+ {
+ acc_str = toUTF8(acc->tszAccountName);
+ acc_str += "(";
+ acc_str += acc->szModuleName;
+ acc_str += ")" ;
+ acc_str += "_GPGPubKey";
+ DBWriteContactSettingString(NULL, szGPGModuleName, acc_str.c_str(), out.c_str());
+ acc_str = toUTF8(acc->tszAccountName);
+ acc_str += "(";
+ acc_str += acc->szModuleName;
+ acc_str += ")" ;
+ acc_str += "_KeyMainName";
+ DBWriteContactSettingTString(NULL, szGPGModuleName, acc_str.c_str(), name);
+ acc_str = toUTF8(acc->tszAccountName);
+ acc_str += "(";
+ acc_str += acc->szModuleName;
+ acc_str += ")" ;
+ acc_str += "_KeyID";
+ DBWriteContactSettingTString(NULL, szGPGModuleName, acc_str.c_str(), fp);
+ }
}
}
TCHAR passwd[64];
@@ -427,24 +446,47 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM
else
{
char setting[64];
- strcpy(setting, buf);
- strcat(setting, "_GPGPubKey");
- DBDeleteContactSetting(NULL, szGPGModuleName, setting);
- strcpy(setting, buf);
- strcat(setting, "_KeyMainName");
- DBDeleteContactSetting(NULL, szGPGModuleName, setting);
- strcpy(setting, buf);
- strcat(setting, "_KeyID");
- DBDeleteContactSetting(NULL, szGPGModuleName, setting);
- strcpy(setting, buf);
- strcat(setting, "_KeyComment");
- DBDeleteContactSetting(NULL, szGPGModuleName, setting);
- strcpy(setting, buf);
- strcat(setting, "_KeyMainEmail");
- DBDeleteContactSetting(NULL, szGPGModuleName, setting);
- strcpy(setting, buf);
- strcat(setting, "_KeyType");
- DBDeleteContactSetting(NULL, szGPGModuleName, setting);
+ PROTOACCOUNT *acc = (PROTOACCOUNT*)CallService(MS_PROTO_GETCONTACTBASEPROTO, 0, (LPARAM)buf);
+ std::string acc_str;
+ if(acc)
+ {
+ acc_str = toUTF8(acc->tszAccountName);
+ acc_str += "(";
+ acc_str += acc->szModuleName;
+ acc_str += ")" ;
+ acc_str += "_GPGPubKey";
+ DBDeleteContactSetting(NULL, szGPGModuleName, acc_str.c_str());
+ acc_str = toUTF8(acc->tszAccountName);
+ acc_str += "(";
+ acc_str += acc->szModuleName;
+ acc_str += ")" ;
+ acc_str += "_KeyMainName";
+ DBDeleteContactSetting(NULL, szGPGModuleName, acc_str.c_str());
+ acc_str = toUTF8(acc->tszAccountName);
+ acc_str += "(";
+ acc_str += acc->szModuleName;
+ acc_str += ")" ;
+ acc_str += "_KeyID";
+ DBDeleteContactSetting(NULL, szGPGModuleName, acc_str.c_str());
+ acc_str = toUTF8(acc->tszAccountName);
+ acc_str += "(";
+ acc_str += acc->szModuleName;
+ acc_str += ")" ;
+ acc_str += "_KeyComment";
+ DBDeleteContactSetting(NULL, szGPGModuleName, acc_str.c_str());
+ acc_str = toUTF8(acc->tszAccountName);
+ acc_str += "(";
+ acc_str += acc->szModuleName;
+ acc_str += ")" ;
+ acc_str += "_KeyMainEmail";
+ DBDeleteContactSetting(NULL, szGPGModuleName, acc_str.c_str());
+ acc_str = toUTF8(acc->tszAccountName);
+ acc_str += "(";
+ acc_str += acc->szModuleName;
+ acc_str += ")" ;
+ acc_str += "_KeyType";
+ DBDeleteContactSetting(NULL, szGPGModuleName, acc_str.c_str());
+ }
}
}
ListView_DeleteItem(hwndList, itemnum);
@@ -560,12 +602,23 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM
else
{
char setting[64];
- strcpy(setting, buf);
- strcat(setting, "_GPGPubKey");
- DBWriteContactSettingString(NULL, szGPGModuleName, setting, out.c_str());
- strcpy(setting, buf);
- strcat(setting, "_KeyID");
- DBWriteContactSettingTString(NULL, szGPGModuleName, setting, fp);
+ PROTOACCOUNT *acc = (PROTOACCOUNT*)CallService(MS_PROTO_GETCONTACTBASEPROTO, 0, (LPARAM)buf);
+ std::string acc_str;
+ if(acc)
+ {
+ acc_str = toUTF8(acc->tszAccountName);
+ acc_str += "(";
+ acc_str += acc->szModuleName;
+ acc_str += ")" ;
+ acc_str += "_GPGPubKey";
+ DBWriteContactSettingString(NULL, szGPGModuleName, acc_str.c_str(), out.c_str());
+ acc_str = toUTF8(acc->tszAccountName);
+ acc_str += "(";
+ acc_str += acc->szModuleName;
+ acc_str += ")" ;
+ acc_str += "_KeyID";
+ DBWriteContactSettingTString(NULL, szGPGModuleName, acc_str.c_str(), fp);
+ }
}
}
extern HWND hwndCurKey_p;
@@ -592,12 +645,21 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM
string keyinfo = Translate("key id");
keyinfo += ": ";
char setting[64];
- strcpy(setting, buf);
- strcat(setting, "_KeyID");
- char *keyid = UniGetContactSettingUtf(NULL, szGPGModuleName, setting, "");
- keyinfo += (strlen(keyid) > 0)?keyid:Translate("not set");
- mir_free(keyid);
- SetDlgItemTextA(hwndDlg, IDC_KEY_ID, keyinfo.c_str());
+ PROTOACCOUNT *acc = (PROTOACCOUNT*)CallService(MS_PROTO_GETCONTACTBASEPROTO, 0, (LPARAM)buf);
+ std::string acc_str;
+ if(acc)
+ {
+ acc_str = toUTF8(acc->tszAccountName);
+ acc_str += "(";
+ acc_str += acc->szModuleName;
+ acc_str += ")" ;
+ acc_str += "_KeyID";
+ char *keyid = UniGetContactSettingUtf(NULL, szGPGModuleName, acc_str.c_str(), "");
+ keyinfo += (strlen(keyid) > 0)?keyid:Translate("not set");
+ mir_free(keyid);
+ SetDlgItemTextA(hwndDlg, IDC_KEY_ID, keyinfo.c_str());
+ }
+
}
}
break;
@@ -647,7 +709,7 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM
void ShowFirstRunDialog();
-static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+static INT_PTR CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
TCHAR *tmp = NULL;
switch (msg)
@@ -1109,7 +1171,7 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
return FALSE;
}
-static BOOL CALLBACK DlgProcNewKeyDialog(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+static INT_PTR CALLBACK DlgProcNewKeyDialog(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
extern HANDLE new_key_hcnt;
extern boost::mutex new_key_hcnt_mutex;
@@ -1189,7 +1251,7 @@ static BOOL CALLBACK DlgProcNewKeyDialog(HWND hwndDlg, UINT msg, WPARAM wParam,
}
return FALSE;
}
-static BOOL CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+static INT_PTR CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
@@ -1509,7 +1571,7 @@ static BOOL CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wParam,
int itemnum2 = 0;
-static BOOL CALLBACK DlgProcLoadExistingKey(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam)
+static INT_PTR CALLBACK DlgProcLoadExistingKey(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam)
{
HWND hwndList=GetDlgItem(hwndDlg, IDC_EXISTING_KEY_LIST);
hwndList_g = hwndList;
@@ -1769,7 +1831,7 @@ static BOOL CALLBACK DlgProcLoadExistingKey(HWND hwndDlg,UINT msg,WPARAM wParam,
return FALSE;
}
-static BOOL CALLBACK DlgProcImportKeyDialog(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+static INT_PTR CALLBACK DlgProcImportKeyDialog(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
extern HANDLE new_key_hcnt;
extern boost::mutex new_key_hcnt_mutex;
@@ -1863,7 +1925,7 @@ void ShowFirstRunDialog()
{
if (hwndFirstRun == NULL)
{
- hwndFirstRun = CreateDialog(hInst, MAKEINTRESOURCE(IDD_FIRST_RUN), NULL, (DLGPROC)DlgProcFirstRun);
+ hwndFirstRun = CreateDialog(hInst, MAKEINTRESOURCE(IDD_FIRST_RUN), NULL, DlgProcFirstRun);
}
SetForegroundWindow(hwndFirstRun);
}
@@ -1873,14 +1935,14 @@ void ShowSetDirsDialog()
{
if (hwndSetDirs == NULL)
{
- hwndSetDirs = CreateDialog(hInst, MAKEINTRESOURCE(IDD_BIN_PATH), NULL, (DLGPROC)DlgProcGpgBinOpts);
+ hwndSetDirs = CreateDialog(hInst, MAKEINTRESOURCE(IDD_BIN_PATH), NULL, DlgProcGpgBinOpts);
}
SetForegroundWindow(hwndSetDirs);
}
void ShowNewKeyDialog()
{
- hwndNewKey = CreateDialog(hInst, MAKEINTRESOURCE(IDD_NEW_KEY), NULL, (DLGPROC)DlgProcNewKeyDialog);
+ hwndNewKey = CreateDialog(hInst, MAKEINTRESOURCE(IDD_NEW_KEY), NULL, DlgProcNewKeyDialog);
SetForegroundWindow(hwndNewKey);
}
@@ -1888,7 +1950,7 @@ void ShowKeyGenDialog()
{
if (hwndKeyGen == NULL)
{
- hwndKeyGen = CreateDialog(hInst, MAKEINTRESOURCE(IDD_KEY_GEN), NULL, (DLGPROC)DlgProcKeyGenDialog);
+ hwndKeyGen = CreateDialog(hInst, MAKEINTRESOURCE(IDD_KEY_GEN), NULL, DlgProcKeyGenDialog);
}
SetForegroundWindow(hwndKeyGen);
}
@@ -1897,14 +1959,14 @@ void ShowSelectExistingKeyDialog()
{
if (hwndSelectExistingKey == NULL)
{
- hwndSelectExistingKey = CreateDialog(hInst, MAKEINTRESOURCE(IDD_LOAD_EXISTING_KEY), NULL, (DLGPROC)DlgProcLoadExistingKey);
+ hwndSelectExistingKey = CreateDialog(hInst, MAKEINTRESOURCE(IDD_LOAD_EXISTING_KEY), NULL, DlgProcLoadExistingKey);
}
SetForegroundWindow(hwndSelectExistingKey);
}
void ShowImportKeyDialog()
{
- CreateDialog(hInst, MAKEINTRESOURCE(IDD_IMPORT_KEY), NULL, (DLGPROC)DlgProcImportKeyDialog);
+ CreateDialog(hInst, MAKEINTRESOURCE(IDD_IMPORT_KEY), NULL, DlgProcImportKeyDialog);
}
@@ -2137,7 +2199,6 @@ void ImportKey()
string::size_type s = output.find("gpg: key ") + strlen("gpg: key ");
string::size_type s2 = output.find(":", s);
DBWriteContactSettingString(hcnt, szGPGModuleName, "KeyID", output.substr(s,s2-s).c_str());
- s2+=2;
s = output.find("“", s2);
if(s == string::npos)
{
@@ -2146,42 +2207,59 @@ void ImportKey()
}
else
s += 3;
+ bool uncommon = false;
if((s2 = output.find("(", s)) == string::npos)
- s2 = output.find("<", s);
+ {
+ if((s2 = output.find("<", s)) == string::npos)
+ {
+ s2 = output.find("”", s);
+ uncommon = true;
+ }
+ }
else if(s2 > output.find("<", s))
s2 = output.find("<", s);
- tmp = new char [output.substr(s,s2-s-1).length()+1];
- strcpy(tmp, output.substr(s,s2-s-1).c_str());
- mir_utf8decode(tmp, 0);
- DBWriteContactSettingString(hcnt, szGPGModuleName, "KeyMainName", tmp);
- mir_free(tmp);
+ if(s != string::npos && s2 != string::npos)
+ {
+ tmp = (char*)mir_alloc(sizeof(char)*(output.substr(s,s2-s-(uncommon?1:0)).length()+1));
+ strcpy(tmp, output.substr(s,s2-s-(uncommon?1:0)).c_str());
+ mir_utf8decode(tmp, 0);
+ DBWriteContactSettingString(hcnt, szGPGModuleName, "KeyMainName", tmp);
+ mir_free(tmp);
+ }
+
if((s = output.find(")", s2)) == string::npos)
s = output.find(">", s2);
else if(s > output.find(">", s2))
s = output.find(">", s2);
s2++;
- if(output[s] == ')')
+ if(s != string::npos && s2 != string::npos)
{
- tmp = new char [output.substr(s2,s-s2).length()+1];
- strcpy(tmp, output.substr(s2,s-s2).c_str());
- mir_utf8decode(tmp, 0);
- DBWriteContactSettingString(hcnt, szGPGModuleName, "KeyComment", tmp);
- mir_free(tmp);
- s+=3;
- s2 = output.find(">", s);
- tmp = new char [output.substr(s,s2-s).length()+1];
- strcpy(tmp, output.substr(s,s2-s).c_str());
- mir_utf8decode(tmp, 0);
- DBWriteContactSettingString(hcnt, szGPGModuleName, "KeyMainEmail", tmp);
- mir_free(tmp);
- }
- else
- {
- tmp = new char [output.substr(s2,s-s2).length()+1];
- strcpy(tmp, output.substr(s2,s-s2).c_str());
- mir_utf8decode(tmp, 0);
- DBWriteContactSettingString(hcnt, szGPGModuleName, "KeyMainEmail", output.substr(s2,s-s2).c_str());
- mir_free(tmp);
+ if(output[s] == ')')
+ {
+ tmp = (char*)mir_alloc(sizeof(char)* (output.substr(s2,s-s2).length()+1));
+ strcpy(tmp, output.substr(s2,s-s2).c_str());
+ mir_utf8decode(tmp, 0);
+ DBWriteContactSettingString(hcnt, szGPGModuleName, "KeyComment", tmp);
+ mir_free(tmp);
+ s+=3;
+ s2 = output.find(">", s);
+ if(s != string::npos && s2 != string::npos)
+ {
+ tmp = (char*) mir_alloc(sizeof(char)*(output.substr(s,s2-s).length()+1));
+ strcpy(tmp, output.substr(s,s2-s).c_str());
+ mir_utf8decode(tmp, 0);
+ DBWriteContactSettingString(hcnt, szGPGModuleName, "KeyMainEmail", tmp);
+ mir_free(tmp);
+ }
+ }
+ else
+ {
+ tmp = (char*)mir_alloc(sizeof(char)* (output.substr(s2,s-s2).length()+1));
+ strcpy(tmp, output.substr(s2,s-s2).c_str());
+ mir_utf8decode(tmp, 0);
+ DBWriteContactSettingString(hcnt, szGPGModuleName, "KeyMainEmail", output.substr(s2,s-s2).c_str());
+ mir_free(tmp);
+ }
}
DBDeleteContactSetting(hcnt, szGPGModuleName, "bAlwatsTrust");
}
@@ -2193,7 +2271,6 @@ void ImportKey()
string::size_type s = output.find("gpg: key ") + strlen("gpg: key ");
string::size_type s2 = output.find(":", s);
DBWriteContactSettingString(metaGetMostOnline(hContact), szGPGModuleName, "KeyID", output.substr(s,s2-s).c_str());
- s2+=2;
s = output.find("“", s2);
if(s == string::npos)
{
@@ -2202,42 +2279,58 @@ void ImportKey()
}
else
s += 3;
+ bool uncommon = false;
if((s2 = output.find("(", s)) == string::npos)
- s2 = output.find("<", s);
+ {
+ if((s2 = output.find("<", s)) == string::npos)
+ {
+ s2 = output.find("”", s);
+ uncommon = true;
+ }
+ }
else if(s2 > output.find("<", s))
s2 = output.find("<", s);
- tmp = new char [output.substr(s,s2-s-1).length()+1];
- strcpy(tmp, output.substr(s,s2-s-1).c_str());
- mir_utf8decode(tmp, 0);
- DBWriteContactSettingString(metaGetMostOnline(hContact), szGPGModuleName, "KeyMainName", tmp);
- mir_free(tmp);
+ if(s != string::npos && s2 != string::npos)
+ {
+ tmp = (char*)mir_alloc(sizeof(char)*(output.substr(s,s2-s-(uncommon?1:0)).length()+1));
+ strcpy(tmp, output.substr(s,s2-s-(uncommon?1:0)).c_str());
+ mir_utf8decode(tmp, 0);
+ DBWriteContactSettingString(metaGetMostOnline(hContact), szGPGModuleName, "KeyMainName", tmp);
+ mir_free(tmp);
+ }
if((s = output.find(")", s2)) == string::npos)
s = output.find(">", s2);
else if(s > output.find(">", s2))
s = output.find(">", s2);
s2++;
- if(output[s] == ')')
- {
- tmp = new char [output.substr(s2,s-s2).length()+1];
- strcpy(tmp, output.substr(s2,s-s2).c_str());
- mir_utf8decode(tmp, 0);
- DBWriteContactSettingString(metaGetMostOnline(hContact), szGPGModuleName, "KeyComment", tmp);
- mir_free(tmp);
- s+=3;
- s2 = output.find(">", s);
- tmp = new char [output.substr(s,s2-s).length()+1];
- strcpy(tmp, output.substr(s,s2-s).c_str());
- mir_utf8decode(tmp, 0);
- DBWriteContactSettingString(metaGetMostOnline(hContact), szGPGModuleName, "KeyMainEmail", tmp);
- mir_free(tmp);
- }
- else
+ if(s != string::npos && s2 != string::npos)
{
- tmp = new char [output.substr(s2,s-s2).length()+1];
- strcpy(tmp, output.substr(s2,s-s2).c_str());
- mir_utf8decode(tmp, 0);
- DBWriteContactSettingString(metaGetMostOnline(hContact), szGPGModuleName, "KeyMainEmail", output.substr(s2,s-s2).c_str());
- mir_free(tmp);
+ if(output[s] == ')')
+ {
+ tmp = (char*)mir_alloc(sizeof(char)* (output.substr(s2,s-s2).length()+1));
+ strcpy(tmp, output.substr(s2,s-s2).c_str());
+ mir_utf8decode(tmp, 0);
+ DBWriteContactSettingString(metaGetMostOnline(hContact), szGPGModuleName, "KeyComment", tmp);
+ mir_free(tmp);
+ s+=3;
+ s2 = output.find(">", s);
+ if(s != string::npos && s2 != string::npos)
+ {
+ tmp = (char*) mir_alloc(sizeof(char)*(output.substr(s,s2-s).length()+1));
+ strcpy(tmp, output.substr(s,s2-s).c_str());
+ mir_utf8decode(tmp, 0);
+ DBWriteContactSettingString(metaGetMostOnline(hContact), szGPGModuleName, "KeyMainEmail", tmp);
+ mir_free(tmp);
+ }
+ }
+ else
+ {
+ tmp = (char*)mir_alloc(sizeof(char)* (output.substr(s2,s-s2).length()+1));
+ strcpy(tmp, output.substr(s2,s-s2).c_str());
+ mir_utf8decode(tmp, 0);
+ DBWriteContactSettingString(metaGetMostOnline(hContact), szGPGModuleName, "KeyMainEmail", output.substr(s2,s-s2).c_str());
+ mir_free(tmp);
+ }
}
DBDeleteContactSetting(metaGetMostOnline(hContact), szGPGModuleName, "bAlwatsTrust");
}
@@ -2248,7 +2341,6 @@ void ImportKey()
string::size_type s = output.find("gpg: key ") + strlen("gpg: key ");
string::size_type s2 = output.find(":", s);
DBWriteContactSettingString(hContact, szGPGModuleName, "KeyID", output.substr(s,s2-s).c_str());
- s2+=2;
s = output.find("“", s2);
if(s == string::npos)
{
@@ -2257,42 +2349,58 @@ void ImportKey()
}
else
s += 3;
+ bool uncommon = false;
if((s2 = output.find("(", s)) == string::npos)
- s2 = output.find("<", s);
+ {
+ if((s2 = output.find("<", s)) == string::npos)
+ {
+ s2 = output.find("”", s);
+ uncommon = true;
+ }
+ }
else if(s2 > output.find("<", s))
s2 = output.find("<", s);
- tmp = (char*)mir_alloc(sizeof(char)*(output.substr(s,s2-s-1).length()+1));
- strcpy(tmp, output.substr(s,s2-s-1).c_str());
- mir_utf8decode(tmp, 0);
- DBWriteContactSettingString(hContact, szGPGModuleName, "KeyMainName", tmp);
- mir_free(tmp);
+ if(s != string::npos && s2 != string::npos)
+ {
+ tmp = (char*)mir_alloc(sizeof(char)*(output.substr(s,s2-s-(uncommon?1:0)).length()+1));
+ strcpy(tmp, output.substr(s,s2-s-(uncommon?1:0)).c_str());
+ mir_utf8decode(tmp, 0);
+ DBWriteContactSettingString(hContact, szGPGModuleName, "KeyMainName", tmp);
+ mir_free(tmp);
+ }
if((s = output.find(")", s2)) == string::npos)
s = output.find(">", s2);
else if(s > output.find(">", s2))
s = output.find(">", s2);
s2++;
- if(output[s] == ')')
+ if(s != string::npos && s2 != string::npos)
{
- tmp = (char*)mir_alloc(sizeof(char)* (output.substr(s2,s-s2).length()+1));
- strcpy(tmp, output.substr(s2,s-s2).c_str());
- mir_utf8decode(tmp, 0);
- DBWriteContactSettingString(hContact, szGPGModuleName, "KeyComment", tmp);
- mir_free(tmp);
- s+=3;
- s2 = output.find(">", s);
- tmp = (char*) mir_alloc(sizeof(char)*(output.substr(s,s2-s).length()+1));
- strcpy(tmp, output.substr(s,s2-s).c_str());
- mir_utf8decode(tmp, 0);
- DBWriteContactSettingString(hContact, szGPGModuleName, "KeyMainEmail", tmp);
- mir_free(tmp);
- }
- else
- {
- tmp = (char*)mir_alloc(sizeof(char)* (output.substr(s2,s-s2).length()+1));
- strcpy(tmp, output.substr(s2,s-s2).c_str());
- mir_utf8decode(tmp, 0);
- DBWriteContactSettingString(hContact, szGPGModuleName, "KeyMainEmail", output.substr(s2,s-s2).c_str());
- mir_free(tmp);
+ if(output[s] == ')')
+ {
+ tmp = (char*)mir_alloc(sizeof(char)* (output.substr(s2,s-s2).length()+1));
+ strcpy(tmp, output.substr(s2,s-s2).c_str());
+ mir_utf8decode(tmp, 0);
+ DBWriteContactSettingString(hContact, szGPGModuleName, "KeyComment", tmp);
+ mir_free(tmp);
+ s+=3;
+ s2 = output.find(">", s);
+ if(s != string::npos && s2 != string::npos)
+ {
+ tmp = (char*) mir_alloc(sizeof(char)*(output.substr(s,s2-s).length()+1));
+ strcpy(tmp, output.substr(s,s2-s).c_str());
+ mir_utf8decode(tmp, 0);
+ DBWriteContactSettingString(hContact, szGPGModuleName, "KeyMainEmail", tmp);
+ mir_free(tmp);
+ }
+ }
+ else
+ {
+ tmp = (char*)mir_alloc(sizeof(char)* (output.substr(s2,s-s2).length()+1));
+ strcpy(tmp, output.substr(s2,s-s2).c_str());
+ mir_utf8decode(tmp, 0);
+ DBWriteContactSettingString(hContact, szGPGModuleName, "KeyMainEmail", output.substr(s2,s-s2).c_str());
+ mir_free(tmp);
+ }
}
DBDeleteContactSetting(hContact, szGPGModuleName, "bAlwatsTrust");
}
diff --git a/messages.cpp b/messages.cpp
index 5dc673c..07aad1f 100755
--- a/messages.cpp
+++ b/messages.cpp
@@ -972,7 +972,7 @@ int HookSendMsg(WPARAM w, LPARAM l)
}
-static BOOL CALLBACK DlgProcKeyPassword(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+static INT_PTR CALLBACK DlgProcKeyPassword(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
char *inkeyid = NULL;
switch (msg)
@@ -1067,5 +1067,5 @@ static BOOL CALLBACK DlgProcKeyPassword(HWND hwndDlg, UINT msg, WPARAM wParam, L
void ShowLoadKeyPasswordWindow()
{
extern HINSTANCE hInst;
- DialogBox(hInst, MAKEINTRESOURCE(IDD_KEY_PASSWD), NULL, (DLGPROC)DlgProcKeyPassword);
+ DialogBox(hInst, MAKEINTRESOURCE(IDD_KEY_PASSWD), NULL, DlgProcKeyPassword);
}
diff --git a/options.cpp b/options.cpp
index 5cd837d..dc7a934 100755
--- a/options.cpp
+++ b/options.cpp
@@ -18,10 +18,10 @@
extern HINSTANCE hInst;
-static BOOL CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
-static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
-static BOOL CALLBACK DlgProcGpgMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
-static BOOL CALLBACK DlgProcGpgAdvOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+static INT_PTR CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+static INT_PTR CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+static INT_PTR CALLBACK DlgProcGpgMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+static INT_PTR CALLBACK DlgProcGpgAdvOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
BOOL CheckStateLoadDB(HWND hwndDlg, int idCtrl, const char* szSetting, BYTE bDef)
{
@@ -97,7 +97,7 @@ HWND hwndList_p = NULL;
HWND hwndCurKey_p = NULL;
void ShowLoadPublicKeyDialog();
-static BOOL CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+static INT_PTR CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
HWND hwndList=GetDlgItem(hwndDlg, IDC_USERLIST);
hwndList_p = hwndList;
@@ -481,7 +481,7 @@ static BOOL CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
}
-static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+static INT_PTR CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
TCHAR *tmp = NULL;
switch (msg)
@@ -614,7 +614,7 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
return FALSE;
}
-static BOOL CALLBACK DlgProcGpgMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+static INT_PTR CALLBACK DlgProcGpgMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
@@ -696,7 +696,7 @@ static BOOL CALLBACK DlgProcGpgMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
return FALSE;
}
-static BOOL CALLBACK DlgProcGpgAdvOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+static INT_PTR CALLBACK DlgProcGpgAdvOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
@@ -754,7 +754,7 @@ static BOOL CALLBACK editctrl_ctrl_a(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM
return ret;
}
-static BOOL CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam)
+static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam)
{
static HANDLE hContact = user_data[item_num+1];
@@ -1383,5 +1383,5 @@ static BOOL CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam,LP
void ShowLoadPublicKeyDialog()
{
- DialogBox(hInst, MAKEINTRESOURCE(IDD_LOAD_PUBLIC_KEY), NULL, (DLGPROC)DlgProcLoadPublicKey);
+ DialogBox(hInst, MAKEINTRESOURCE(IDD_LOAD_PUBLIC_KEY), NULL, DlgProcLoadPublicKey);
}
diff --git a/utilities.cpp b/utilities.cpp
index e071aaf..54cee7a 100755
--- a/utilities.cpp
+++ b/utilities.cpp
@@ -197,19 +197,18 @@ int SendKey(WPARAM w, LPARAM l)
hContact = metaGetMostOnline(hContact);
char *szMessage;
{
- char *proto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
- char setting[64];
- if(proto)
+ LPSTR proto = (LPSTR)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+ PROTOACCOUNT *acc = (PROTOACCOUNT*)CallService(MS_PROTO_GETCONTACTBASEPROTO, 0, (LPARAM)proto);
+ std::string acc_str;
+ if(acc)
{
- strcpy(setting, proto);
- strcat(setting, "_GPGPubKey");
- szMessage = UniGetContactSettingUtf(NULL, szGPGModuleName, setting, "");
- }
- if(!szMessage[0])
- {
- mir_free(szMessage);
- szMessage = UniGetContactSettingUtf(NULL, szGPGModuleName, "GPGPubKey", "");
+ acc_str = toUTF8(acc->tszAccountName);
+ acc_str += "(";
+ acc_str += acc->szModuleName;
+ acc_str += ")" ;
+ acc_str += "_GPGPubKey";
}
+ char *szMessage = UniGetContactSettingUtf(hContact, szGPGModuleName, acc_str.empty()?"GPGPubKey":acc_str.c_str(), "");
}
if(szMessage[0])
{
@@ -1199,7 +1198,7 @@ int SendBroadcast( HANDLE hContact, int type, int result, HANDLE hProcess, LPARA
ACKDATA ack;
memset(&ack,0,sizeof(ack));
ack.cbSize = sizeof( ACKDATA );
- ack.szModule = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+ ack.szModule = szGPGModuleName;// (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
ack.hContact = hContact;
ack.type = type;
ack.result = result;