summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGluzskiy Alexandr <sss123next@list.ru>2010-10-11 15:17:14 +0300
committerGluzskiy Alexandr <sss123next@list.ru>2010-10-11 15:17:14 +0300
commita5086db857e474538a24df4b05e5aab831d4c2fe (patch)
tree63d0c958ddac5ab004ec65286896e51e81386112
parent768f905339476a2780df46a60ed852ed583970de (diff)
modified: main.cpp
modified: messages.cpp modified: new_gpg.rc modified: new_gpg.vcproj
-rw-r--r--main.cpp239
-rw-r--r--messages.cpp2
-rw-r--r--new_gpg.rc6
-rw-r--r--new_gpg.vcproj8
4 files changed, 200 insertions, 55 deletions
diff --git a/main.cpp b/main.cpp
index c6b899c..1cefa44 100644
--- a/main.cpp
+++ b/main.cpp
@@ -845,7 +845,7 @@ static BOOL CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wParam,
f<<"\n";
tmp = new TCHAR [64]; //i hope this is enough for password
GetDlgItemText(hwndDlg, IDC_KEY_PASSWD, tmp, 64);
- if(_tcslen(tmp) > 0)
+ if(!tmp[0])
{
f<<"Passphrase: ";
tmp2 = mir_utf8encodeW(tmp);
@@ -864,7 +864,7 @@ static BOOL CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wParam,
f<<"\n";
tmp = new TCHAR [512];
GetDlgItemText(hwndDlg, IDC_KEY_COMMENT, tmp, 512);
- if(_tcslen(tmp) > 0)
+ if(!tmp[0])
{
tmp2 = mir_utf8encodeW(tmp);
f<<"Name-Comment: ";
@@ -1428,7 +1428,29 @@ void ImportKey()
extern boost::mutex new_key_hcnt_mutex;
HANDLE hContact = new_key_hcnt;
new_key_hcnt_mutex.unlock();
- DBWriteContactSettingTString(hContact, szGPGModuleName, "GPGPubKey", new_key.c_str());
+ bool for_all_sub = false;
+ if(metaIsProtoMetaContacts(hContact))
+ if(MessageBox(0, _T("Do you want load key for all subcontacts ?"), _T("Metacontact detected"), MB_YESNO) == IDYES)
+ for_all_sub = true;
+
+ if(metaIsProtoMetaContacts(hContact))
+ {
+ HANDLE hcnt = NULL;
+ if(for_all_sub)
+ {
+ int count = metaGetContactsNum(hContact);
+ for(int i = 0; i < count; i++)
+ {
+ hcnt = metaGetSubcontact(hContact, i);
+ if(hcnt)
+ DBWriteContactSettingTString(hcnt, szGPGModuleName, "GPGPubKey", new_key.c_str());
+ }
+ }
+ else
+ DBWriteContactSettingTString(metaGetCurrent(hContact), szGPGModuleName, "GPGPubKey", new_key.c_str());
+ }
+ else
+ DBWriteContactSettingTString(hContact, szGPGModuleName, "GPGPubKey", new_key.c_str());
new_key.clear();
{ //gpg execute block
wstring cmd;
@@ -1473,57 +1495,180 @@ void ImportKey()
MessageBox(0, _T("Set path to gpg.exe first!"), _T("Warning"), MB_OK);
return;
}
- DBDeleteContactSetting(hContact, szGPGModuleName, "bAlwatsTrust");
{
- char *tmp = NULL;
- 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)
+ if(metaIsProtoMetaContacts(hContact))
{
- s = output.find("\"", s2);
- s += 1;
- }
- else
- s += 3;
- if((s2 = output.find("(", s)) == string::npos)
- s2 = output.find("<", s);
- 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(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(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(hContact, szGPGModuleName, "KeyMainEmail", tmp);
- mir_free(tmp);
+ HANDLE hcnt = NULL;
+ if(for_all_sub)
+ {
+ int count = metaGetContactsNum(hContact);
+ for(int i = 0; i < count; i++)
+ {
+ hcnt = metaGetSubcontact(hContact, i);
+ if(hcnt)
+ {
+ char *tmp = NULL;
+ 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)
+ {
+ s = output.find("\"", s2);
+ s += 1;
+ }
+ else
+ s += 3;
+ if((s2 = output.find("(", s)) == string::npos)
+ s2 = output.find("<", s);
+ 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 = 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(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);
+ }
+ DBDeleteContactSetting(hcnt, szGPGModuleName, "bAlwatsTrust");
+ }
+ }
+ }
+ else
+ {
+ char *tmp = NULL;
+ string::size_type s = output.find("gpg: key ") + strlen("gpg: key ");
+ string::size_type s2 = output.find(":", s);
+ DBWriteContactSettingString(metaGetCurrent(hContact), szGPGModuleName, "KeyID", output.substr(s,s2-s).c_str());
+ s2+=2;
+ s = output.find("“", s2);
+ if(s == string::npos)
+ {
+ s = output.find("\"", s2);
+ s += 1;
+ }
+ else
+ s += 3;
+ if((s2 = output.find("(", s)) == string::npos)
+ s2 = output.find("<", s);
+ 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(metaGetCurrent(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(metaGetCurrent(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(metaGetCurrent(hContact), 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(metaGetCurrent(hContact), szGPGModuleName, "KeyMainEmail", output.substr(s2,s-s2).c_str());
+ mir_free(tmp);
+ }
+ DBDeleteContactSetting(metaGetCurrent(hContact), szGPGModuleName, "bAlwatsTrust");
+ }
}
else
{
- tmp = new char [output.substr(s2,s-s2).length()+1];
- strcpy(tmp, output.substr(s2,s-s2).c_str());
+ char *tmp = NULL;
+ 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)
+ {
+ s = output.find("\"", s2);
+ s += 1;
+ }
+ else
+ s += 3;
+ if((s2 = output.find("(", s)) == string::npos)
+ s2 = output.find("<", s);
+ 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(hContact, szGPGModuleName, "KeyMainEmail", output.substr(s2,s-s2).c_str());
+ 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] == ')')
+ {
+ tmp = new 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 = new 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 = new 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");
}
}
ptmp = mir_utf8decodeW(output.c_str());
diff --git a/messages.cpp b/messages.cpp
index 505dc5a..7e6886f 100644
--- a/messages.cpp
+++ b/messages.cpp
@@ -59,7 +59,7 @@ int RecvMsgSvc(WPARAM w, LPARAM l)
}
if((s2 != wstring::npos) && (s1 != wstring::npos))
{ //this is public key
- if(metaIsProtoMetaContacts(hContact))
+ if(metaIsSubcontact(hContact))
return CallService(MS_PROTO_CHAINRECV, w, l); //yet another metacontacts problem
debuglog<<"info: "<<"received key from: "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)<<"\n";
void ShowNewKeyDialog();
diff --git a/new_gpg.rc b/new_gpg.rc
index 4925e14..59ce1fc 100644
--- a/new_gpg.rc
+++ b/new_gpg.rc
@@ -317,13 +317,13 @@ BEGIN
CTEXT "Userlist:",IDC_STATIC,25,7,201,8
PUSHBUTTON "Export PubKey",IDC_SAVE_KEY_BUTTON,8,135,66,14
PUSHBUTTON "Delete key",IDC_DELETE_KEY_BUTTON,78,135,70,14
- PUSHBUTTON "Select own key",IDC_SELECT_KEY,222,193,57,14
+ PUSHBUTTON "Select own key",IDC_SELECT_KEY,170,193,109,14
CONTROL "Turn on debug log",IDC_DEBUG_LOG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,181,159,89,10
EDITTEXT IDC_LOG_FILE_EDIT,11,157,98,14,ES_AUTOHSCROLL
PUSHBUTTON "Browse",IDC_LOG_FILE_SET,119,156,50,14
CONTROL "Use jabber api on Miranda IM >= 0.9 (recomended)",IDC_JABBER_API,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,175,181,10
- LTEXT "Ñòàòè÷åñêèé",IDC_CURRENT_KEY,97,196,116,8
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,175,251,10
+ LTEXT "Ñòàòè÷åñêèé",IDC_CURRENT_KEY,48,196,116,8
CONTROL "Encrypt file transfers",IDC_FILE_TRANSFERS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,185,137,10
END
diff --git a/new_gpg.vcproj b/new_gpg.vcproj
index 559cafe..e9eaa83 100644
--- a/new_gpg.vcproj
+++ b/new_gpg.vcproj
@@ -151,7 +151,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="D:\work\libs\boost_1_44_0;&quot;X:\install\git\miranda\miranda-im\miranda\include&quot;;X:\install\git\miranda\mim_plugs;../../include"
+ AdditionalIncludeDirectories="D:\work\libs\boost;&quot;X:\install\git\miranda\miranda-im\miranda\include&quot;;X:\install\git\miranda\mim_plugs;../../include"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;TESTPLUG_EXPORTS;_CRT_SECURE_NO_WARNINGS;_UNICODE;UNICODE;_CRT_SECURE_NO_DEPRECATE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@@ -184,7 +184,7 @@
AdditionalDependencies="shlwapi.lib"
LinkIncremental="2"
SuppressStartupBanner="true"
- AdditionalLibraryDirectories="D:\work\libs\boost_1_44_0\stage\lib"
+ AdditionalLibraryDirectories="D:\work\libs\boost\stage\lib"
GenerateDebugInformation="true"
AssemblyDebug="1"
ProgramDatabaseFile="./$(TargetName).pdb"
@@ -258,7 +258,7 @@
FavorSizeOrSpeed="2"
OmitFramePointers="true"
WholeProgramOptimization="true"
- AdditionalIncludeDirectories="D:\work\libs\boost_1_44_0;&quot;X:\install\git\miranda\miranda-im\miranda\include&quot;;X:\install\git\miranda\mim_plugs;../../include"
+ AdditionalIncludeDirectories="D:\work\libs\boost;&quot;X:\install\git\miranda\miranda-im\miranda\include&quot;;X:\install\git\miranda\mim_plugs;../../include"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;_UNICODE"
StringPooling="true"
RuntimeLibrary="0"
@@ -290,7 +290,7 @@
AdditionalDependencies="shlwapi.lib"
LinkIncremental="1"
SuppressStartupBanner="true"
- AdditionalLibraryDirectories="D:\work\libs\boost_1_44_0\stage\lib"
+ AdditionalLibraryDirectories="D:\work\libs\boost\stage\lib"
GenerateDebugInformation="false"
SubSystem="0"
OptimizeReferences="2"