summaryrefslogtreecommitdiff
path: root/utilities.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'utilities.cpp')
-rw-r--r--utilities.cpp65
1 files changed, 62 insertions, 3 deletions
diff --git a/utilities.cpp b/utilities.cpp
index 649b4e1..a64abae 100644
--- a/utilities.cpp
+++ b/utilities.cpp
@@ -358,9 +358,6 @@ int GetJabberInterface(WPARAM w, LPARAM l) //get interface for all jabber accoun
static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, HXML node, void *pUserData)
{
- extern bool bJabberAPI, bIsMiranda09;
- if(!bJabberAPI || !bIsMiranda09)
- return FALSE;
HXML local_node = node;
for(int n = 0; n <= xi.getChildCount(node); n++)
{
@@ -544,6 +541,63 @@ static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, HXML node, void *pU
return FALSE;
}
+HANDLE sign_file_mutex = NULL;
+
+static JABBER_HANDLER_FUNC PrescenseHandler(IJabberInterface *ji, HXML node, void *pUserData)
+{
+ HXML local_node = node;
+ for(int n = 0; n <= xi.getChildCount(node); n++)
+ {
+ LPCTSTR str = xi.getText(local_node);
+ LPCTSTR nodename = xi.getName(local_node);
+ if(nodename)
+ {
+ if(_tcsstr(nodename, _T("x")))
+ {
+ for(int n = 0; n < xi.getAttrCount(local_node); n++)
+ {
+ LPCTSTR name = xi.getAttrName(local_node, n);
+ LPCTSTR value = xi.getAttrValue(local_node, name);
+ if(_tcsstr(value, _T("jabber:x:signed")))
+ {
+ LPCTSTR data = xi.getText(local_node);
+ wstring sign = _T("-----BEGIN PGP MESSAGE-----\n\n");
+ sign += data;
+ sign += _T("\n-----END PGP MESSAGE-----\n");
+ TCHAR *path_c = UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", _T(""));
+ wstring path_out = path_c;
+ mir_free(path_c);
+ path_out += _T("\\sign.asc");
+ WaitForSingleObject(sign_file_mutex, INFINITE);
+ sign_file_mutex = CreateMutex(NULL, FALSE, NULL);
+ DeleteFile(path_out.c_str());
+ wfstream f(path_out.c_str(), std::ios::out);
+ char *tmp = mir_utf8encodeW(sign.c_str());
+ f<<tmp;
+ mir_free(tmp);
+ f.close();
+ if(_waccess(path_out.c_str(), 0) == -1)
+ {
+ if(errno == ENOENT)
+ {
+ ReleaseMutex(sign_file_mutex);
+ debuglog<<"info: Failed to write sign in file\n";
+ return FALSE;
+ }
+ }
+
+ DeleteFile(path_out.c_str());
+ ReleaseMutex(sign_file_mutex);
+ return FALSE;
+ }
+ }
+ }
+ }
+ local_node = xi.getChild(node, n);
+ }
+ return FALSE;
+}
+
void AddHandlers()
{
@@ -557,6 +611,11 @@ void AddHandlers()
{
(*p)->setSendHandler((*p)->getJabberInterface()->Net()->AddSendHandler((JABBER_HANDLER_FUNC)SendHandler));
}
+ if((*p)->getPrescenseHandler() == INVALID_HANDLE_VALUE)
+ {
+ (*p)->setPrescenseHandler((*p)->getJabberInterface()->Net()->AddPresenceHandler((JABBER_HANDLER_FUNC)PrescenseHandler));
+ }
+
}
}