summaryrefslogtreecommitdiff
path: root/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'main.cpp')
-rwxr-xr-xmain.cpp380
1 files changed, 244 insertions, 136 deletions
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");
}