diff options
-rw-r--r-- | protocols/Sametime/src/conference.cpp | 53 | ||||
-rw-r--r-- | protocols/Sametime/src/files.cpp | 107 | ||||
-rw-r--r-- | protocols/Sametime/src/messaging.cpp | 39 | ||||
-rw-r--r-- | protocols/Sametime/src/options.cpp | 68 | ||||
-rw-r--r-- | protocols/Sametime/src/sametime.cpp | 78 | ||||
-rw-r--r-- | protocols/Sametime/src/sametime_proto.cpp | 114 | ||||
-rw-r--r-- | protocols/Sametime/src/sametime_proto.h | 2 | ||||
-rw-r--r-- | protocols/Sametime/src/sametime_session.cpp | 170 | ||||
-rw-r--r-- | protocols/Sametime/src/session_announce_win.cpp | 196 | ||||
-rw-r--r-- | protocols/Sametime/src/userlist.cpp | 134 | ||||
-rw-r--r-- | protocols/Sametime/src/utils.cpp | 74 |
11 files changed, 461 insertions, 574 deletions
diff --git a/protocols/Sametime/src/conference.cpp b/protocols/Sametime/src/conference.cpp index 7583ad54f8..82d5e3110a 100644 --- a/protocols/Sametime/src/conference.cpp +++ b/protocols/Sametime/src/conference.cpp @@ -1,14 +1,12 @@ #include "StdAfx.h"
#include "sametime.h"
-
-
-void CloseMyConference(CSametimeProto* proto) {
+void CloseMyConference(CSametimeProto* proto)
+{
mwConference_destroy(proto->my_conference, 0, Translate("I'm outa here."));
proto->my_conference = 0;
}
-
CSametimeProto* getProtoFromMwConference(mwConference* conf)
{
mwServiceConference* servConference = mwConference_getServiceConference(conf);
@@ -17,7 +15,6 @@ CSametimeProto* getProtoFromMwConference(mwConference* conf) return (CSametimeProto*)mwSession_getProperty(session, "PROTO_STRUCT_PTR");
}
-
/** triggered when we receive a conference invitation. Call
mwConference_accept to accept the invitation and join the
conference, or mwConference_close to reject the invitation.
@@ -26,8 +23,9 @@ CSametimeProto* getProtoFromMwConference(mwConference* conf) @param inviter the indentity of the user who sent the invitation
@param invite the invitation text
*/
-void mwServiceConf_on_invited(mwConference* conf, mwLoginInfo* inviter, const char* invite) {
+void mwServiceConf_on_invited(mwConference* conf, mwLoginInfo* inviter, const char* invite)
+{
GList *members, *mem;
CSametimeProto* proto = getProtoFromMwConference(conf);
proto->debugLog(_T("mwServiceConf_on_invited() start"));
@@ -53,19 +51,20 @@ void mwServiceConf_on_invited(mwConference* conf, mwLoginInfo* inviter, const ch if (MessageBoxW(0, ws_invite, ws_username, MB_OKCANCEL) == IDOK) {
proto->debugLog(_T("mwServiceConf_on_invited() mwConference_accept"));
mwConference_accept(conf);
- } else {
+ }
+ else {
proto->debugLog(_T("mwServiceConf_on_invited() mwConference_reject"));
char* temp = mir_utf8encodeT(TranslateT("Your invitation has been rejected."));
mwConference_reject(conf, 0, temp);
mir_free(temp);
}
-
}
-void CSametimeProto::ClearInviteQueue() {
-
+void CSametimeProto::ClearInviteQueue()
+{
debugLog(_T("CSametimeProto::ClearInviteQueue() start"));
- if (!my_conference) return;
+ if (!my_conference)
+ return;
mwIdBlock idb;
idb.community = 0;
@@ -170,9 +169,8 @@ void mwServiceConf_conf_opened(mwConference* conf, GList* members) gcd.iType = GC_EVENT_CONTROL;
CallServiceSync(MS_GC_EVENT, SESSION_ONLINE, (LPARAM)&gce);
- if (conf == proto->my_conference) {
+ if (conf == proto->my_conference)
proto->ClearInviteQueue();
- }
mir_free(tszConfId);
}
@@ -199,14 +197,12 @@ void mwServiceConf_conf_closed(mwConference* conf, guint32 reason) }
/** triggered when someone joins the conference */
-void mwServiceConf_on_peer_joined(mwConference* conf, mwLoginInfo* user)
+void mwServiceConf_on_peer_joined(mwConference* conf, mwLoginInfo *user)
{
CSametimeProto* proto = getProtoFromMwConference(conf);
proto->debugLog(_T("mwServiceConf_on_peer_joined() start"));
- TCHAR* tszConfId = mir_utf8decodeT(mwConference_getName(conf));
-
- MCONTACT hContact = proto->FindContactByUserId(((mwLoginInfo*)user)->user_id);
+ MCONTACT hContact = proto->FindContactByUserId(user->user_id);
if (!hContact) {
mwIdBlock idb;
idb.user = ((mwLoginInfo *)user)->user_id;
@@ -223,6 +219,10 @@ void mwServiceConf_on_peer_joined(mwConference* conf, mwLoginInfo* user) mir_free(utfs);
}
+ ptrT tszConfId(mir_utf8decodeT(mwConference_getName(conf)));
+ ptrT tszUserName(mir_utf8decodeT(user->user_name));
+ ptrT tszUserId(mir_utf8decodeT(user->login_id));
+
// add user
GCDEST gcd = { proto->m_szModuleName };
gcd.ptszID = tszConfId;
@@ -230,8 +230,6 @@ void mwServiceConf_on_peer_joined(mwConference* conf, mwLoginInfo* user) GCEVENT gce = { sizeof(gce), &gcd };
gce.dwFlags = GCEF_ADDTOLOG;
- TCHAR* tszUserName = mir_utf8decodeT(((mwLoginInfo*)user)->user_name);
- TCHAR* tszUserId = mir_utf8decodeT(((mwLoginInfo*)user)->login_id);
gce.ptszNick = tszUserName;
gce.ptszUID = tszUserId;
gce.ptszStatus = _T("Normal");
@@ -250,7 +248,9 @@ void mwServiceConf_on_peer_parted(mwConference* conf, mwLoginInfo* user) CSametimeProto* proto = getProtoFromMwConference(conf);
proto->debugLog(_T("mwServiceConf_on_peer_parted() start"));
- TCHAR* tszConfId = mir_utf8decodeT(mwConference_getName(conf));
+ ptrT tszConfId(mir_utf8decodeT(mwConference_getName(conf)));
+ ptrT tszUserName(mir_utf8decodeT(user->user_name));
+ ptrT tszUserId(mir_utf8decodeT(user->login_id));
// remove user
GCDEST gcd = { proto->m_szModuleName };
@@ -259,18 +259,11 @@ void mwServiceConf_on_peer_parted(mwConference* conf, mwLoginInfo* user) GCEVENT gce = { sizeof(gce), &gcd };
gce.dwFlags = GCEF_ADDTOLOG;
- TCHAR* tszUserName = mir_utf8decodeT(((mwLoginInfo*)user)->user_name);
- TCHAR* tszUserId = mir_utf8decodeT(((mwLoginInfo*)user)->login_id);
gce.ptszNick = tszUserName;
gce.ptszUID = tszUserId;
gce.ptszStatus = _T("Normal");
gce.time = (DWORD)time(0);
-
- CallServiceSync(MS_GC_EVENT, 0, (LPARAM)(GCEVENT *) &gce);
-
- mir_free(tszUserName);
- mir_free(tszUserId);
- mir_free(tszConfId);
+ CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
}
/** triggered when someone says something */
@@ -289,8 +282,8 @@ void mwServiceConf_on_text(mwConference* conf, mwLoginInfo* user, const char* wh gce.dwFlags = GCEF_ADDTOLOG;
TCHAR* textT = mir_utf8decodeT(what);
- TCHAR* tszUserName = mir_utf8decodeT(((mwLoginInfo*)user)->user_name);
- TCHAR* tszUserId = mir_utf8decodeT(((mwLoginInfo*)user)->login_id);
+ TCHAR* tszUserName = mir_utf8decodeT(user->user_name);
+ TCHAR* tszUserId = mir_utf8decodeT(user->login_id);
gce.ptszText = textT;
gce.ptszNick = tszUserName;
gce.ptszUID = tszUserId;
diff --git a/protocols/Sametime/src/files.cpp b/protocols/Sametime/src/files.cpp index a08fa49968..cfbc52d824 100644 --- a/protocols/Sametime/src/files.cpp +++ b/protocols/Sametime/src/files.cpp @@ -1,7 +1,6 @@ #include "StdAfx.h"
#include "sametime.h"
-
CSametimeProto* getProtoFromMwFileTransfer(mwFileTransfer* ft)
{
mwServiceFileTransfer* serviceFT = mwFileTransfer_getService(ft);
@@ -10,7 +9,6 @@ CSametimeProto* getProtoFromMwFileTransfer(mwFileTransfer* ft) return (CSametimeProto*)mwSession_getProperty(session, "PROTO_STRUCT_PTR");
}
-
/** an incoming file transfer has been offered */
void mwFileTransfer_offered(mwFileTransfer* ft) {
@@ -37,9 +35,8 @@ void mwFileTransfer_offered(mwFileTransfer* ft) { TCHAR* messageT = mir_utf8decodeT(message);
mir_sntprintf(descriptionT, SIZEOF(descriptionT), _T("%s - %s"), filenameT, messageT);
mir_free(messageT);
- } else {
- mir_sntprintf(descriptionT, SIZEOF(descriptionT), _T("%s"), filenameT);
}
+ else mir_sntprintf(descriptionT, SIZEOF(descriptionT), _T("%s"), filenameT);
PROTORECVFILET pre = {0};
pre.flags = PREF_TCHAR;
@@ -52,13 +49,11 @@ void mwFileTransfer_offered(mwFileTransfer* ft) { ProtoChainRecvFile(hContact, &pre);
mir_free(filenameT);
-
}
//returns 0 if finished with current file
int SendFileChunk(CSametimeProto* proto, mwFileTransfer* ft, FileTransferClientData* ftcd) {
DWORD bytes_read;
- mwOpaque o;
if (!ftcd || !ftcd->buffer)
return 0;
@@ -68,9 +63,10 @@ int SendFileChunk(CSametimeProto* proto, mwFileTransfer* ft, FileTransferClientD mwFileTransfer_close(ft, mwFileTransfer_SUCCESS);
return 0;
}
+
+ mwOpaque o;
o.data = (unsigned char*)ftcd->buffer;
o.len = bytes_read;
-
mwFileTransfer_send(ft, &o);
return bytes_read;
@@ -90,15 +86,14 @@ void __cdecl SendThread(LPVOID param) { pfts.cbSize = sizeof(pfts);
pfts.flags = PFTS_UTF;
pfts.hContact = ftcd->hContact;
- if (ftcd->sending == 1){
+ if (ftcd->sending == 1)
pfts.flags |= PFTS_SENDING;
- }
+
pfts.pszFiles = NULL;
pfts.totalFiles = ftcd->first->ft_count;
pfts.totalBytes = ftcd->first->totalSize;
while(SendFileChunk(proto, ft, ftcd) && !Miranda_Terminated()) {
-
pfts.currentFileNumber = ftcd->ft_number;
pfts.totalProgress = ftcd->sizeToHere + mwFileTransfer_getSent(ft);
pfts.szWorkingDir = ftcd->save_path;
@@ -124,8 +119,8 @@ void __cdecl SendThread(LPVOID param) { }
/** a file transfer has been fully initiated */
-void mwFileTransfer_opened(mwFileTransfer* ft) {
-
+void mwFileTransfer_opened(mwFileTransfer* ft)
+{
CSametimeProto* proto = getProtoFromMwFileTransfer(ft);
FileTransferClientData* ftcd = (FileTransferClientData*)mwFileTransfer_getClientData(ft);
@@ -140,8 +135,8 @@ void mwFileTransfer_opened(mwFileTransfer* ft) { /** a file transfer has been closed. Check the status of the file
transfer to determine if the transfer was complete or if it had
been interrupted */
-void mwFileTransfer_closed(mwFileTransfer* ft, guint32 code) {
-
+void mwFileTransfer_closed(mwFileTransfer* ft, guint32 code)
+{
CSametimeProto* proto = getProtoFromMwFileTransfer(ft);
FileTransferClientData* ftcd = (FileTransferClientData*)mwFileTransfer_getClientData(ft);
proto->debugLog(_T("mwFileTransfer_closed() start"));
@@ -160,11 +155,10 @@ void mwFileTransfer_closed(mwFileTransfer* ft, guint32 code) { DeleteFileA(fn);
}
- if (code == mwFileTransfer_REJECTED) {
+ if (code == mwFileTransfer_REJECTED)
proto->ProtoBroadcastAck(ftcd->hContact, ACKTYPE_FILE, ACKRESULT_DENIED, ftcd->hFt, 0);
- } else {
+ else
proto->ProtoBroadcastAck(ftcd->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ftcd->hFt, 0);
- }
if (ftcd->sending) {
FileTransferClientData* ftcd_next = ftcd->next, *ftcd_temp;
@@ -180,7 +174,8 @@ void mwFileTransfer_closed(mwFileTransfer* ft, guint32 code) { delete ftcd_next;
ftcd_next = ftcd_temp;
}
- } else {
+ }
+ else {
mwFileTransfer_removeClientData(ft);
if (ftcd->save_path) free(ftcd->save_path);
if (ftcd->buffer) delete[] ftcd->buffer;
@@ -188,15 +183,16 @@ void mwFileTransfer_closed(mwFileTransfer* ft, guint32 code) { mwFileTransfer_free(ft);
}
-
- } else {
+ }
+ else {
if (ftcd->sending) {
// check if we have more files to send...
if (ftcd->next) {
proto->ProtoBroadcastAck(ftcd->hContact, ACKTYPE_FILE, ACKRESULT_NEXTFILE, ftcd->hFt, 0);
mwFileTransfer_offer(ftcd->next->ft);
}
- } else {
+ }
+ else {
proto->ProtoBroadcastAck(ftcd->hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, ftcd->hFt, 0);
mwFileTransfer_removeClientData(ft);
@@ -207,14 +203,12 @@ void mwFileTransfer_closed(mwFileTransfer* ft, guint32 code) { mwFileTransfer_free(ft);
}
}
-
}
-
}
/** receive a chunk of a file from an inbound file transfer. */
-void mwFileTransfer_recv(mwFileTransfer* ft, struct mwOpaque* data) {
-
+void mwFileTransfer_recv(mwFileTransfer* ft, struct mwOpaque* data)
+{
CSametimeProto* proto = getProtoFromMwFileTransfer(ft);
FileTransferClientData* ftcd = (FileTransferClientData*)mwFileTransfer_getClientData(ft);
proto->debugLog(_T("mwFileTransfer_recv() start"));
@@ -225,15 +219,15 @@ void mwFileTransfer_recv(mwFileTransfer* ft, struct mwOpaque* data) { mwFileTransfer_cancel(ft);
proto->ProtoBroadcastAck(ftcd->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ftcd->hFt, 0);
proto->debugLog(_T("mwFileTransfer_recv() ACKRESULT_FAILED"));
- } else {
- //if (mwFileTransfer_isOpen(ft))
- mwFileTransfer_ack(ft); // acknowledge chunk
+ }
+ else {
+ mwFileTransfer_ack(ft); // acknowledge chunk
- PROTOFILETRANSFERSTATUS pfts = {0};
+ PROTOFILETRANSFERSTATUS pfts = { 0 };
pfts.cbSize = sizeof(pfts);
pfts.flags = PFTS_UTF;
pfts.hContact = ftcd->hContact;
- if (ftcd->sending == 1){
+ if (ftcd->sending == 1) {
pfts.flags |= PFTS_SENDING;
}
pfts.pszFiles = NULL;
@@ -250,18 +244,18 @@ void mwFileTransfer_recv(mwFileTransfer* ft, struct mwOpaque* data) { proto->ProtoBroadcastAck(ftcd->hContact, ACKTYPE_FILE, ACKRESULT_DATA, ftcd->hFt, (LPARAM)&pfts);
proto->debugLog(_T("mwFileTransfer_recv() ACKRESULT_DATA"));
- if (mwFileTransfer_isDone(ft)){
+ if (mwFileTransfer_isDone(ft)) {
proto->ProtoBroadcastAck(ftcd->hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, ftcd->hFt, 0);
proto->debugLog(_T("mwFileTransfer_recv() ACKRESULT_SUCCESS"));
}
}
-
}
/** received an ack for a sent chunk on an outbound file transfer.
this indicates that a previous call to mwFileTransfer_send has
reached the target and that the target has responded. */
-void mwFileTransfer_handle_ack(mwFileTransfer* ft) {
+void mwFileTransfer_handle_ack(mwFileTransfer* ft)
+{
// see SendThread above - not all clients send us acks
CSametimeProto* proto = getProtoFromMwFileTransfer(ft);
//FileTransferClientData* ftcd = (FileTransferClientData*)mwFileTransfer_getClientData(ft);
@@ -269,8 +263,8 @@ void mwFileTransfer_handle_ack(mwFileTransfer* ft) { }
/** optional. called from mwService_free */
-void mwFileTransfer_clear(mwServiceFileTransfer* srvc) {
-
+void mwFileTransfer_clear(mwServiceFileTransfer* srvc)
+{
}
mwFileTransferHandler mwFileTransfer_handler = {
@@ -292,28 +286,25 @@ HANDLE CSametimeProto::SendFilesToUser(MCONTACT hContact, PROTOCHAR** files, con idb.user = id_block.user;
idb.community = id_block.community;
- HANDLE hFile;
- DWORD filesize;
FileTransferClientData *ftcd, *prev_ftcd = 0, *first_ftcd = 0;
mwFileTransfer *ft, *first_ft = 0;
- TCHAR* fn;
-
for (int i = 0; files[i]; i++) {
- hFile = CreateFile(files[i], GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
+ HANDLE hFile = CreateFile(files[i], GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
if (hFile != INVALID_HANDLE_VALUE) {
- filesize = GetFileSize(hFile, 0);
+ DWORD filesize = GetFileSize(hFile, 0);
- fn = _tcsrchr(files[i], '\\');
- if (fn) fn++;
+ TCHAR *fn = _tcsrchr(files[i], '\\');
+ if (fn)
+ fn++;
char* pszDesc_utf8 = mir_utf8encodeT(ptszDesc);
char* pszFile_utf8;
- if (fn) {
+ if (fn)
pszFile_utf8 = mir_utf8encodeT(fn);
- } else {
+ else
pszFile_utf8 = mir_utf8encodeT(files[i]);
- }
+
ft = mwFileTransfer_new(service_files, &idb, pszDesc_utf8, pszFile_utf8, filesize);
mir_free(pszFile_utf8);
mir_free(pszDesc_utf8);
@@ -323,16 +314,15 @@ HANDLE CSametimeProto::SendFilesToUser(MCONTACT hContact, PROTOCHAR** files, con ftcd->ft = ft;
ftcd->hContact = hContact;
-
+
ftcd->next = 0;
if (prev_ftcd) {
prev_ftcd->next = ftcd; // link into list
// each node contains a pointer to the first - it will contain infor linke the count etc
- ftcd->first = prev_ftcd->first;
- } else {
- ftcd->first = ftcd;
+ ftcd->first = prev_ftcd->first;
}
+ else ftcd->first = ftcd;
if (!first_ft) first_ft = ft;
@@ -347,7 +337,7 @@ HANDLE CSametimeProto::SendFilesToUser(MCONTACT hContact, PROTOCHAR** files, con ftcd->first->ft_count++;
ftcd->sizeToHere = ftcd->first->totalSize;
ftcd->first->totalSize += filesize;
-
+
mwFileTransfer_setClientData(ft, (gpointer)ftcd, 0);
prev_ftcd = ftcd;
@@ -360,7 +350,6 @@ HANDLE CSametimeProto::SendFilesToUser(MCONTACT hContact, PROTOCHAR** files, con mwFileTransfer_offer(first_ft);
return (HANDLE)first_ft;
}
-
}
return 0;
@@ -381,11 +370,11 @@ HANDLE CSametimeProto::AcceptFileTransfer(MCONTACT hContact, HANDLE hFt, char* s if (save_path) // save path
ftcd->save_path = _strdup(save_path);
- else
+ else
ftcd->save_path = 0;
mwFileTransfer_setClientData(ft, (gpointer)ftcd, 0);
-
+
char fp[MAX_PATH];
char* fn = strrchr((char*)mwFileTransfer_getFileName(ft), '\\');
if (fn) fn++;
@@ -404,7 +393,7 @@ HANDLE CSametimeProto::AcceptFileTransfer(MCONTACT hContact, HANDLE hFt, char* s mwFileTransfer_close(ft, mwFileTransfer_ERROR);
return 0;
}
-
+
ftcd->hContact = hContact;
mwFileTransfer_setClientData(ft, (gpointer)ftcd, 0);
@@ -413,7 +402,6 @@ HANDLE CSametimeProto::AcceptFileTransfer(MCONTACT hContact, HANDLE hFt, char* s return hFt;
}
-
void CSametimeProto::RejectFileTransfer(HANDLE hFt)
{
mwFileTransfer* ft = (mwFileTransfer*)hFt;
@@ -423,7 +411,6 @@ void CSametimeProto::RejectFileTransfer(HANDLE hFt) mwFileTransfer_reject(ft);
}
-
void CSametimeProto::CancelFileTransfer(HANDLE hFt)
{
mwFileTransfer* ft = (mwFileTransfer*)hFt;
@@ -433,12 +420,12 @@ void CSametimeProto::CancelFileTransfer(HANDLE hFt) FileTransferClientData* ftcd = (FileTransferClientData*)mwFileTransfer_getClientData(ft);
if (ftcd) {
- while(mwFileTransfer_isDone(ftcd->ft) && ftcd)
+ while (mwFileTransfer_isDone(ftcd->ft) && ftcd)
ftcd = ftcd->next;
if (ftcd) mwFileTransfer_cancel(ftcd->ft);
- } else
- mwFileTransfer_cancel(ft);
+ }
+ else mwFileTransfer_cancel(ft);
}
void CSametimeProto::InitFiles()
diff --git a/protocols/Sametime/src/messaging.cpp b/protocols/Sametime/src/messaging.cpp index 7825a9f2e0..a82a574f82 100644 --- a/protocols/Sametime/src/messaging.cpp +++ b/protocols/Sametime/src/messaging.cpp @@ -1,7 +1,6 @@ #include "StdAfx.h"
#include "sametime.h"
-
CSametimeProto* getProtoFromMwConversation(mwConversation* conv)
{
mwServiceIm* serviceIM = mwConversation_getService(conv);
@@ -10,7 +9,6 @@ CSametimeProto* getProtoFromMwConversation(mwConversation* conv) return (CSametimeProto*)mwSession_getProperty(session, "PROTO_STRUCT_PTR");
}
-
void mwIm_conversation_opened(mwConversation* conv)
{
CSametimeProto* proto = getProtoFromMwConversation(conv);
@@ -28,11 +26,11 @@ void mwIm_conversation_opened(mwConversation* conv) proto->AddContact(stuser, (proto->options.add_contacts ? false : true));
proto->GetMoreDetails(idb->user);
}
-
+
ContactMessageQueue::iterator i;
EnterCriticalSection(&proto->q_cs);
if ((i = proto->contact_message_queue.find(hContact)) != proto->contact_message_queue.end()) {
- while(i->second.size()) {
+ while (i->second.size()) {
mwConversation_send(conv, mwImSend_PLAIN, (gconstpointer)i->second.front().c_str());
i->second.pop();
}
@@ -48,25 +46,24 @@ void mwIm_conversation_opened(mwConversation* conv) void mwIm_conversation_closed(mwConversation* conv, guint32 err)
{
CSametimeProto* proto = getProtoFromMwConversation(conv);
- proto->debugLog(_T("mwIm_conversation_closed() start err=[%d]"),err);
+ proto->debugLog(_T("mwIm_conversation_closed() start err=[%d]"), err);
if (err & ERR_FAILURE && err != CONNECTION_RESET) {
char* msg = mwError(err);
proto->showPopup(TranslateTS(_A2T(msg)), SAMETIME_POPUP_ERROR);
g_free(msg);
- if (err == ERR_NO_COMMON_ENCRYPT && !(proto->options.encrypt_session)) {
+ if (err == ERR_NO_COMMON_ENCRYPT && !(proto->options.encrypt_session))
proto->showPopup(TranslateT("No common encryption method. Try to enable encryption in protocol options."), SAMETIME_POPUP_INFO);
- }
}
mwIdBlock* idb = mwConversation_getTarget(conv);
MCONTACT hContact = proto->FindContactByUserId(idb->user);
if (hContact) {
- ContactMessageQueue::iterator i;
EnterCriticalSection(&proto->q_cs);
- if ((i = proto->contact_message_queue.find(hContact)) != proto->contact_message_queue.end()) {
+ ContactMessageQueue::iterator i = proto->contact_message_queue.find(hContact);
+ if (i != proto->contact_message_queue.end())
proto->contact_message_queue.erase(i);
- }
+
LeaveCriticalSection(&proto->q_cs);
}
}
@@ -86,18 +83,17 @@ void mwIm_conversation_recv(mwConversation* conv, mwImSendType type, gconstpoint return;
}
- if (type != mwImSend_PLAIN) return;
+ if (type != mwImSend_PLAIN)
+ return;
- PROTORECVEVENT pre = {0};
+ PROTORECVEVENT pre = { 0 };
time_t t = time(NULL);
pre.timestamp = t;
pre.flags = PREF_UTF;
pre.szMessage = (char*)msg;
ProtoChainRecvMsg(hContact, &pre);
-
}
-
void mwIm_place_invite(struct mwConversation* conv, const char* message, const char* title, const char* name)
{
CSametimeProto* proto = getProtoFromMwConversation(conv);
@@ -114,7 +110,6 @@ void mwIm_place_invite(struct mwConversation* conv, const char* message, const c mir_free(tszMessage);
}
-
mwImHandler mwIm_handler = {
mwIm_conversation_opened,
mwIm_conversation_closed,
@@ -123,14 +118,12 @@ mwImHandler mwIm_handler = { NULL
};
-
HANDLE CSametimeProto::SendMessageToUser(MCONTACT hContact, char* msg_utf8)
{
debugLog(_T("CSametimeProto::SendMessageToUser() hContact=[%x]"), hContact);
mwAwareIdBlock id_block;
if (GetAwareIdFromContact(hContact, &id_block)) {
-
mwIdBlock idb;
idb.user = id_block.user;
idb.community = id_block.community;
@@ -143,7 +136,8 @@ HANDLE CSametimeProto::SendMessageToUser(MCONTACT hContact, char* msg_utf8) contact_message_queue[hContact].push(msg_utf8);
LeaveCriticalSection(&q_cs);
mwConversation_open(conv);
- } else {
+ }
+ else {
debugLog(_T("CSametimeProto::SendMessageToUser() !mwConversation_isOpen"));
mwConversation_send(conv, mwImSend_PLAIN, (gconstpointer)msg_utf8);
}
@@ -158,11 +152,10 @@ HANDLE CSametimeProto::SendMessageToUser(MCONTACT hContact, char* msg_utf8) return 0;
}
-
void CSametimeProto::SendTyping(MCONTACT hContact, bool typing)
{
debugLog(_T("CSametimeProto::SendTyping() hContact=[%x] type=[%d]"), hContact, typing);
-
+
mwAwareIdBlock id_block;
if (GetAwareIdFromContact(hContact, &id_block)) {
mwIdBlock idb;
@@ -171,7 +164,7 @@ void CSametimeProto::SendTyping(MCONTACT hContact, bool typing) mwConversation* conv = mwServiceIm_getConversation(service_im, &idb);
if (conv) {
- if (mwConversation_isOpen(conv)){
+ if (mwConversation_isOpen(conv)) {
debugLog(_T("CSametimeProto::SendTyping() send"));
mwConversation_send(conv, mwImSend_TYPING, (gconstpointer)GUINT_TO_POINTER(typing ? 1 : 0));
}
@@ -181,7 +174,6 @@ void CSametimeProto::SendTyping(MCONTACT hContact, bool typing) }
}
-
void CSametimeProto::CloseIm(MCONTACT hContact)
{
debugLog(_T("CSametimeProto::CloseIm() hContact=[%x]"), hContact);
@@ -194,7 +186,7 @@ void CSametimeProto::CloseIm(MCONTACT hContact) mwConversation* conv = mwServiceIm_getConversation(service_im, &idb);
if (conv) {
- if (mwConversation_isOpen(conv)){
+ if (mwConversation_isOpen(conv)) {
debugLog(_T("CSametimeProto::CloseIm() mwConversation_close"));
mwConversation_close(conv, 0);
}
@@ -219,4 +211,3 @@ void CSametimeProto::DeinitMessaging() service_im = 0;
DeleteCriticalSection(&q_cs);
}
-
diff --git a/protocols/Sametime/src/options.cpp b/protocols/Sametime/src/options.cpp index 0b73c398d3..ec2de559ea 100644 --- a/protocols/Sametime/src/options.cpp +++ b/protocols/Sametime/src/options.cpp @@ -51,14 +51,12 @@ int client_ids[NUM_IDS] = { 0xFFFF
};
-
static INT_PTR CALLBACK DlgProcOptNet(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
CSametimeProto* proto = (CSametimeProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- switch ( msg ) {
+ switch (msg) {
case WM_INITDIALOG: {
-
TranslateDialogDefault(hwndDlg);
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
@@ -87,11 +85,11 @@ static INT_PTR CALLBACK DlgProcOptNet(HWND hwndDlg, UINT msg, WPARAM wParam, LPA CheckDlgButton(hwndDlg, IDC_CHK_ADDCONTACTS, proto->options.add_contacts ? TRUE : FALSE);
CheckDlgButton(hwndDlg, IDC_CHK_IDLEAWAY, proto->options.idle_as_away ? TRUE : FALSE);
CheckDlgButton(hwndDlg, IDC_CHK_OLDDEFAULTVER, proto->options.use_old_default_client_ver ? TRUE : FALSE);
-
+
SendDlgItemMessage(hwndDlg, IDC_CMB_CLIENT, CB_RESETCONTENT, 0, 0);
int pos = 0;
bool found = false;
-
+
for (int i = 0; i < NUM_IDS; i++) {
pos = SendDlgItemMessage(hwndDlg, IDC_CMB_CLIENT, CB_ADDSTRING, -1, (LPARAM)client_names[i]);
SendDlgItemMessage(hwndDlg, IDC_CMB_CLIENT, CB_SETITEMDATA, pos, client_ids[i]);
@@ -99,13 +97,13 @@ static INT_PTR CALLBACK DlgProcOptNet(HWND hwndDlg, UINT msg, WPARAM wParam, LPA found = true;
SendDlgItemMessage(hwndDlg, IDC_CMB_CLIENT, CB_SETCURSEL, pos, 0);
SetDlgItemInt(hwndDlg, IDC_ED_CLIENTID, client_ids[i], FALSE);
- if (i != sizeof(client_ids) / sizeof(int) - 1) {
+ if (i != sizeof(client_ids) / sizeof(int)-1) {
HWND hw = GetDlgItem(hwndDlg, IDC_ED_CLIENTID);
EnableWindow(hw, false);
}
}
}
-
+
if (!found) {
SendDlgItemMessage(hwndDlg, IDC_CMB_CLIENT, CB_SETCURSEL, pos, 0); // pos is last item, i.e. custom
SetDlgItemInt(hwndDlg, IDC_ED_CLIENTID, proto->options.client_id, FALSE);
@@ -122,27 +120,27 @@ static INT_PTR CALLBACK DlgProcOptNet(HWND hwndDlg, UINT msg, WPARAM wParam, LPA }
switch (proto->options.err_method) {
- case ED_POP: CheckDlgButton(hwndDlg, IDC_RAD_ERRPOP, TRUE); break;
- case ED_MB: CheckDlgButton(hwndDlg, IDC_RAD_ERRMB, TRUE); break;
- case ED_BAL: CheckDlgButton(hwndDlg, IDC_RAD_ERRBAL, TRUE); break;
+ case ED_POP: CheckDlgButton(hwndDlg, IDC_RAD_ERRPOP, TRUE); break;
+ case ED_MB: CheckDlgButton(hwndDlg, IDC_RAD_ERRMB, TRUE); break;
+ case ED_BAL: CheckDlgButton(hwndDlg, IDC_RAD_ERRBAL, TRUE); break;
}
if (proto->options.encrypt_session)
CheckDlgButton(hwndDlg, IDC_RAD_ENC, TRUE);
else
CheckDlgButton(hwndDlg, IDC_RAD_NOENC, TRUE);
-
+
return FALSE;
}
case WM_COMMAND:
- if (HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus()) {
+ if (HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus())
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
+
if (HIWORD(wParam) == CBN_SELCHANGE) {
int sel = SendDlgItemMessage(hwndDlg, IDC_CMB_CLIENT, CB_GETCURSEL, 0, 0);
int id = SendDlgItemMessage(hwndDlg, IDC_CMB_CLIENT, CB_GETITEMDATA, sel, 0);
- bool custom = (id == client_ids[sizeof(client_ids) / sizeof(int) - 1]);
+ bool custom = (id == client_ids[sizeof(client_ids) / sizeof(int)-1]);
if (!custom)
SetDlgItemInt(hwndDlg, IDC_ED_CLIENTID, id, FALSE);
@@ -155,26 +153,24 @@ static INT_PTR CALLBACK DlgProcOptNet(HWND hwndDlg, UINT msg, WPARAM wParam, LPA SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
- if (HIWORD(wParam) == BN_CLICKED ) {
+ if (HIWORD(wParam) == BN_CLICKED) {
switch (LOWORD(wParam)) {
case IDC_BTN_UPLOADCONTACTS:
{
- HWND hBut = GetDlgItem(hwndDlg, IDC_BTN_UPLOADCONTACTS);
- EnableWindow(hBut, FALSE);
- hBut = GetDlgItem(hwndDlg, IDC_BTN_IMPORTCONTACTS);
- EnableWindow(hBut, FALSE);
-
+ EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_UPLOADCONTACTS), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_IMPORTCONTACTS), FALSE);
+
proto->ExportContactsToServer();
SendMessage(hwndDlg, WMU_STORECOMPLETE, 0, 0);
}
return TRUE;
+
case IDC_BTN_IMPORTCONTACTS:
{
- OPENFILENAME ofn = {0};
- TCHAR import_filename[MAX_PATH];
- import_filename[0] = 0;
+ TCHAR import_filename[MAX_PATH]; import_filename[0] = 0;
+ OPENFILENAME ofn = { 0 };
ofn.lStructSize = sizeof(ofn);
ofn.lpstrFile = import_filename;
ofn.hwndOwner = hwndDlg;
@@ -199,6 +195,7 @@ static INT_PTR CALLBACK DlgProcOptNet(HWND hwndDlg, UINT msg, WPARAM wParam, LPA }
}
return TRUE;
+
case IDC_CHK_GETSERVERCONTACTS:
case IDC_CHK_ENCMESSAGES:
case IDC_RAD_ERRMB:
@@ -217,10 +214,9 @@ static INT_PTR CALLBACK DlgProcOptNet(HWND hwndDlg, UINT msg, WPARAM wParam, LPA case IDC_RAD_OEM:
case IDC_RAD_UTF7:
case IDC_RAD_USERCP:
- {
- HWND hw = GetDlgItem(hwndDlg, IDC_CHK_USERCP);
- EnableWindow(hw, !IsDlgButtonChecked(hwndDlg, IDC_RAD_USERCP));
- }
+ HWND hw = GetDlgItem(hwndDlg, IDC_CHK_USERCP);
+ EnableWindow(hw, !IsDlgButtonChecked(hwndDlg, IDC_RAD_USERCP));
+
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
return TRUE;
}
@@ -228,12 +224,8 @@ static INT_PTR CALLBACK DlgProcOptNet(HWND hwndDlg, UINT msg, WPARAM wParam, LPA break;
case WMU_STORECOMPLETE:
- {
- HWND hBut = GetDlgItem(hwndDlg, IDC_BTN_UPLOADCONTACTS);
- EnableWindow(hBut, TRUE);
- hBut = GetDlgItem(hwndDlg, IDC_BTN_IMPORTCONTACTS);
- EnableWindow(hBut, TRUE);
- }
+ EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_UPLOADCONTACTS), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_IMPORTCONTACTS), TRUE);
return TRUE;
case WM_NOTIFY:
@@ -258,13 +250,13 @@ static INT_PTR CALLBACK DlgProcOptNet(HWND hwndDlg, UINT msg, WPARAM wParam, LPA int sel = SendDlgItemMessage(hwndDlg, IDC_CMB_CLIENT, CB_GETCURSEL, 0, 0);
int id = SendDlgItemMessage(hwndDlg, IDC_CMB_CLIENT, CB_GETITEMDATA, sel, 0);
- if (id == client_ids[sizeof(client_ids) / sizeof(int) - 1]) {
+ if (id == client_ids[sizeof(client_ids) / sizeof(int)-1]) {
BOOL trans;
id = GetDlgItemInt(hwndDlg, IDC_ED_CLIENTID, &trans, FALSE);
if (trans)
proto->options.client_id = id;
- } else
- proto->options.client_id = id;
+ }
+ else proto->options.client_id = id;
if (IsDlgButtonChecked(hwndDlg, IDC_RAD_ERRMB)) proto->options.err_method = ED_MB;
else if (IsDlgButtonChecked(hwndDlg, IDC_RAD_ERRBAL)) proto->options.err_method = ED_BAL;
@@ -336,14 +328,14 @@ void CSametimeProto::LoadOptions() // if want baloons but no balloons, try popups
// if want popups but no popups, try baloons
// if, after that, you want balloons but no balloons, revert to message boxes
- if (options.err_method == ED_BAL && !ServiceExists(MS_CLIST_SYSTRAY_NOTIFY)) options.err_method = ED_POP;
+ if (options.err_method == ED_BAL && !ServiceExists(MS_CLIST_SYSTRAY_NOTIFY)) options.err_method = ED_POP;
if (options.err_method == ED_POP && !ServiceExists(MS_POPUP_SHOWMESSAGE)) options.err_method = ED_BAL;
if (options.err_method == ED_BAL && !ServiceExists(MS_CLIST_SYSTRAY_NOTIFY)) options.err_method = ED_MB;
debugLog(_T("LoadOptions() loaded: ServerName:len=[%d], id:len=[%d], pword:len=[%d]"), options.server_name == NULL ? -1 : strlen(options.server_name), options.id == NULL ? -1 : strlen(options.id), options.pword == NULL ? -1 : strlen(options.pword));
debugLog(_T("LoadOptions() loaded: port=[%d], encrypt_session=[%d], client_id=[%d], use_old_default_client_ver=[%d]"), options.port, options.encrypt_session, options.client_id, options.use_old_default_client_ver);
debugLog(_T("LoadOptions() loaded: get_server_contacts=[%d], add_contacts=[%d], idle_as_away=[%d], err_method=[%d]"), options.get_server_contacts, options.add_contacts, options.idle_as_away, options.err_method);
-
+
}
void CSametimeProto::SaveOptions()
diff --git a/protocols/Sametime/src/sametime.cpp b/protocols/Sametime/src/sametime.cpp index 133d173ffa..b0b50a6e52 100644 --- a/protocols/Sametime/src/sametime.cpp +++ b/protocols/Sametime/src/sametime.cpp @@ -3,7 +3,8 @@ #include "version.h"
// plugin stuff
-PLUGININFOEX pluginInfo={
+PLUGININFOEX pluginInfo =
+{
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
@@ -21,7 +22,6 @@ HINSTANCE hInst; LIST<CSametimeProto> g_Instances(1, PtrKeySortT);
int hLangpack;
-
// sametime.cpp: Defines the entry point for the DLL application.
extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
@@ -36,11 +36,8 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD miranda extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_PROTOCOL, MIID_LAST};
-
-
// protocol related services
-
/** Copy the name of the protocole into lParam
* @param wParam : max size of the name
* @param lParam : reference to a char *, which will hold the name
@@ -70,31 +67,29 @@ INT_PTR CSametimeProto::SametimeLoadIcon(WPARAM wParam, LPARAM lParam) {
UINT id;
- switch (wParam & 0xFFFF)
- {
- case PLI_PROTOCOL:
- id = IDI_ICON_PROTO;
- break;
- default:
- return NULL;
+ switch (wParam & 0xFFFF) {
+ case PLI_PROTOCOL:
+ id = IDI_ICON_PROTO;
+ break;
+ default:
+ return NULL;
}
return (INT_PTR) LoadImage(hInst, MAKEINTRESOURCE(id), IMAGE_ICON,
GetSystemMetrics(wParam & PLIF_SMALL ? SM_CXSMICON : SM_CXICON),
GetSystemMetrics(wParam & PLIF_SMALL ? SM_CYSMICON : SM_CYICON), 0);
- return 0;
}
//icolib stuff
static IconItem iconList[] =
{
- { LPGEN("Protocol icon"), "protoicon", IDI_ICON_PROTO, 0 }
- , { LPGEN("Start conference"), "leaveconference", IDI_ICON_INVITE, 0 }
- , { LPGEN("Leave conference"), "startconference", IDI_ICON_LEAVE, 0 }
- , { LPGEN("Announce"), "announce", IDI_ICON_ANNOUNCE, 0 }
- , { LPGEN("Notification"), "notify", IDI_ICON_NOTIFY, 0 }
- , { LPGEN("Error"), "error", IDI_ICON_ERROR, 0 }
+ { LPGEN("Protocol icon"), "protoicon", IDI_ICON_PROTO, 0 },
+ { LPGEN("Start conference"), "leaveconference", IDI_ICON_INVITE, 0 },
+ { LPGEN("Leave conference"), "startconference", IDI_ICON_LEAVE, 0 },
+ { LPGEN("Announce"), "announce", IDI_ICON_ANNOUNCE, 0 },
+ { LPGEN("Notification"), "notify", IDI_ICON_NOTIFY, 0 },
+ { LPGEN("Error"), "error", IDI_ICON_ERROR, 0 }
};
void SametimeInitIcons(void)
@@ -124,7 +119,6 @@ void ReleaseIconEx(const char* name, BOOL big) Skin_ReleaseIcon(szSettingName, big);
}
-
// Copied from MSN plugin - sent acks need to be from different thread
void __cdecl sttFakeAckInfoSuccessThread(void *param)
{
@@ -137,7 +131,6 @@ void __cdecl sttFakeAckInfoSuccessThread(void *param) proto->debugLog(_T("sttFakeAckInfoSuccessThread() end"));
mir_free(tParam);
- return;
}
void __cdecl sttFakeAckMessageSuccessThread(void *param)
@@ -147,11 +140,10 @@ void __cdecl sttFakeAckMessageSuccessThread(void *param) proto->debugLog(_T("sttFakeAckMessageSuccessThread() start"));
Sleep(100);
- proto->ProtoBroadcastAck(tParam->hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)tParam->lParam, 0 );
+ proto->ProtoBroadcastAck(tParam->hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)tParam->lParam, 0);
proto->debugLog(_T("sttFakeAckMessageSuccessThread() end"));
mir_free(tParam);
- return;
}
void __cdecl sttFakeAckMessageFailedThread(void *param)
@@ -165,7 +157,6 @@ void __cdecl sttFakeAckMessageFailedThread(void *param) proto->debugLog(_T("sttFakeAckMessageFailedThread() end"));
mir_free(tParam);
- return;
}
void __cdecl sttRecvAwayThread(void *param)
@@ -179,10 +170,8 @@ void __cdecl sttRecvAwayThread(void *param) proto->debugLog(_T("sttRecvAwayThread() end"));
free(tParam);
- return;
}
-
int CSametimeProto::OnWindowEvent(WPARAM, LPARAM lParam)
{
MessageWindowEventData* mwed = (MessageWindowEventData*)lParam;
@@ -206,26 +195,32 @@ int CSametimeProto::OnIdleChanged(WPARAM, LPARAM lParam) return 0;
}
+int CSametimeProto::OnModulesLoaded(WPARAM, LPARAM)
+{
+ // register with chat module
+ GCREGISTER gcr = { sizeof(gcr) };
+ gcr.pszModule = m_szModuleName;
+ gcr.ptszDispName = m_tszUserName;
+ gcr.iMaxText = MAX_MESSAGE_SIZE;
+ CallService(MS_GC_REGISTER, 0, (LPARAM)&gcr);
+ return 0;
+}
-int CSametimeProto::OnPreShutdown(WPARAM wParam, LPARAM lParam)
+int CSametimeProto::OnPreShutdown(WPARAM, LPARAM)
{
- if (m_iStatus != ID_STATUS_OFFLINE){
+ if (m_iStatus != ID_STATUS_OFFLINE)
LogOut();
- }
return 0;
}
-
-int CSametimeProto::OnSametimeContactDeleted(WPARAM wParam, LPARAM)
+int CSametimeProto::OnSametimeContactDeleted(WPARAM hContact, LPARAM)
{
- MCONTACT hContact = wParam;
ContactDeleted(hContact);
ChatDeleted(hContact);
return 0;
}
-
void CSametimeProto::SetAllOffline()
{
debugLog(_T("SetAllOffline() start"));
@@ -234,20 +229,17 @@ void CSametimeProto::SetAllOffline() if (db_get_b(hContact, m_szModuleName, "ChatRoom", 0)) {
CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0);
continue;
- } else {
- db_set_w(hContact, m_szModuleName, "Status", ID_STATUS_OFFLINE);
- db_set_dw(hContact, m_szModuleName, "IdleTS", 0);
}
- }
+ db_set_w(hContact, m_szModuleName, "Status", ID_STATUS_OFFLINE);
+ db_set_dw(hContact, m_szModuleName, "IdleTS", 0);
+ }
}
-
void CSametimeProto::BroadcastNewStatus(int iNewStatus)
{
- if (m_iStatus == iNewStatus){
+ if (m_iStatus == iNewStatus)
return;
- }
debugLog(_T("BroadcastNewStatus() m_iStatus=[%d], iNewStatus=[%d]"), m_iStatus, iNewStatus);
@@ -256,7 +248,6 @@ void CSametimeProto::BroadcastNewStatus(int iNewStatus) ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)previous_status, m_iStatus);
}
-
static CSametimeProto* sametime_proto_init(const char* pszProtoName, const TCHAR* tszUserName)
{
CSametimeProto* proto = new CSametimeProto(pszProtoName, tszUserName);
@@ -274,23 +265,18 @@ static int sametime_proto_uninit(PROTO_INTERFACE* ppro) extern "C" int __declspec(dllexport) Load(void)
{
-
PROTOCOLDESCRIPTOR pd = { sizeof(pd) };
pd.type = PROTOTYPE_PROTOCOL;
pd.szName = "Sametime";
pd.fnInit = (pfnInitProto)sametime_proto_init;
pd.fnUninit = (pfnUninitProto)sametime_proto_uninit;
CallService(MS_PROTO_REGISTERMODULE, 0, (LPARAM)&pd);
-
return 0;
}
extern "C" int __declspec(dllexport) Unload()
{
-
g_Instances.destroy();
-
return 0;
-
}
diff --git a/protocols/Sametime/src/sametime_proto.cpp b/protocols/Sametime/src/sametime_proto.cpp index d3f3435705..86fe836557 100644 --- a/protocols/Sametime/src/sametime_proto.cpp +++ b/protocols/Sametime/src/sametime_proto.cpp @@ -1,21 +1,18 @@ #include "StdAfx.h"
#include "sametime.h"
-
-CSametimeProto::CSametimeProto(const char* pszProtoName, const TCHAR* tszUserName)
- : PROTO<CSametimeProto>(pszProtoName, tszUserName)
- , is_idle(false)
- , idle_status(false)
- , first_online(true)
- , idle_timerid(0)
- , session(NULL)
- , my_login_info(NULL)
- , my_conference(NULL)
- , service_places(NULL)
- , service_conference(NULL)
- , server_connection(0)
+CSametimeProto::CSametimeProto(const char* pszProtoName, const TCHAR* tszUserName) :
+ PROTO<CSametimeProto>(pszProtoName, tszUserName),
+ is_idle(false), idle_status(false),
+ first_online(true),
+ idle_timerid(0),
+ session(NULL),
+ my_login_info(NULL),
+ my_conference(NULL),
+ service_places(NULL),
+ service_conference(NULL),
+ server_connection(0)
{
-
// Register m_hNetlibUser user
TCHAR name[128];
mir_sntprintf(name, SIZEOF(name), TranslateT("%s connection"), m_tszUserName);
@@ -36,6 +33,7 @@ CSametimeProto::CSametimeProto(const char* pszProtoName, const TCHAR* tszUserNam CreateProtoService(PS_GETSTATUS, &CSametimeProto::GetStatus);
CreateProtoService(PS_LOADICON, &CSametimeProto::SametimeLoadIcon);
+ HookProtoEvent(ME_SYSTEM_MODULESLOADED, &CSametimeProto::OnModulesLoaded);
HookProtoEvent(ME_SYSTEM_PRESHUTDOWN, &CSametimeProto::OnPreShutdown);
HookProtoEvent(ME_MSG_WINDOWEVENT, &CSametimeProto::OnWindowEvent);
HookProtoEvent(ME_IDLE_CHANGED, &CSametimeProto::OnIdleChanged);
@@ -55,11 +53,10 @@ CSametimeProto::CSametimeProto(const char* pszProtoName, const TCHAR* tszUserNam previous_status = ID_STATUS_OFFLINE;
SetAllOffline();
- DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &mainThread, THREAD_SET_CONTEXT, FALSE, 0 );
+ DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &mainThread, THREAD_SET_CONTEXT, FALSE, 0);
InitConferenceMenu();
InitSessionMenu();
- InitGroupChats();
LoadOptions();
@@ -68,7 +65,6 @@ CSametimeProto::CSametimeProto(const char* pszProtoName, const TCHAR* tszUserNam CSametimeProto::~CSametimeProto()
{
-
debugLog(_T("CSametimeProto::~CSametimeProto() start"));
DeinitSessionMenu();
@@ -82,10 +78,10 @@ CSametimeProto::~CSametimeProto() UnRegisterGLibLogger();
Netlib_CloseHandle(m_hNetlibUser);
-
}
+
MCONTACT CSametimeProto::AddToList(int flags, PROTOSEARCHRESULT* psr)
{
MYPROTOSEARCHRESULT* sr = (MYPROTOSEARCHRESULT*)psr;
@@ -99,7 +95,6 @@ MCONTACT CSametimeProto::AddToListByEvent(int flags, int iContact, HANDLE hDbEve return 0;
}
-
int CSametimeProto::Authorize(HANDLE hDbEvent)
{
debugLog(_T("CSametimeProto::Authorize()"));
@@ -112,7 +107,6 @@ int CSametimeProto::AuthDeny(HANDLE hDbEvent, const PROTOCHAR* szReason) return 1;
}
-
int CSametimeProto::AuthRecv(MCONTACT hContact, PROTORECVEVENT*)
{
debugLog(_T("CSametimeProto::AuthRecv()"));
@@ -125,7 +119,6 @@ int CSametimeProto::AuthRequest(MCONTACT hContact, const PROTOCHAR* szMessage) return 1;
}
-
HANDLE CSametimeProto::FileAllow(MCONTACT hContact, HANDLE hTransfer, const PROTOCHAR* szPath)
{
debugLog(_T("CSametimeProto::FileAllow() hContact=[%x], szPath=[%s]"), hContact, szPath);
@@ -160,30 +153,30 @@ DWORD_PTR CSametimeProto::GetCaps(int type, MCONTACT hContact) {
int ret = 0;
switch (type) {
- case PFLAGNUM_1:
- ret = PF1_IM | PF1_BASICSEARCH | PF1_EXTSEARCHUI | PF1_ADDSEARCHRES | PF1_MODEMSG | PF1_FILE | PF1_CHAT;
- break;
- case PFLAGNUM_2:
- ret = PF2_ONLINE | PF2_SHORTAWAY | PF2_HEAVYDND | PF2_LIGHTDND;
- break;
- case PFLAGNUM_3:
- ret = PF2_ONLINE | PF2_SHORTAWAY | PF2_HEAVYDND;
- break;
- case PFLAGNUM_4:
- ret = PF4_SUPPORTTYPING | PF4_IMSENDUTF;
- break;
- case PFLAGNUM_5:
- ret = PF2_LIGHTDND;
- break;
- case PFLAG_UNIQUEIDTEXT:
- ret = (DWORD_PTR) Translate("ID");
- break;
- case PFLAG_MAXLENOFMESSAGE:
- ret = MAX_MESSAGE_SIZE;
- break;
- case PFLAG_UNIQUEIDSETTING:
- ret = (DWORD_PTR) "stid";
- break;
+ case PFLAGNUM_1:
+ ret = PF1_IM | PF1_BASICSEARCH | PF1_EXTSEARCHUI | PF1_ADDSEARCHRES | PF1_MODEMSG | PF1_FILE | PF1_CHAT;
+ break;
+ case PFLAGNUM_2:
+ ret = PF2_ONLINE | PF2_SHORTAWAY | PF2_HEAVYDND | PF2_LIGHTDND;
+ break;
+ case PFLAGNUM_3:
+ ret = PF2_ONLINE | PF2_SHORTAWAY | PF2_HEAVYDND;
+ break;
+ case PFLAGNUM_4:
+ ret = PF4_SUPPORTTYPING | PF4_IMSENDUTF;
+ break;
+ case PFLAGNUM_5:
+ ret = PF2_LIGHTDND;
+ break;
+ case PFLAG_UNIQUEIDTEXT:
+ ret = (DWORD_PTR)Translate("ID");
+ break;
+ case PFLAG_MAXLENOFMESSAGE:
+ ret = MAX_MESSAGE_SIZE;
+ break;
+ case PFLAG_UNIQUEIDSETTING:
+ ret = (DWORD_PTR) "stid";
+ break;
}
return ret;
}
@@ -192,7 +185,7 @@ int CSametimeProto::GetInfo(MCONTACT hContact, int infoType) {
// GetInfo - retrieves a contact info
debugLog(_T("CSametimeProto::GetInfo() hContact=[%x], infoType=[%d]"), hContact, infoType);
-
+
if (getByte(hContact, "ChatRoom", 0))
return 1;
@@ -210,7 +203,6 @@ int CSametimeProto::GetInfo(MCONTACT hContact, int infoType) return 0;
}
-
HANDLE CSametimeProto::SearchBasic(const PROTOCHAR* id)
{
debugLog(_T("CSametimeProto::SearchBasic() id:len=[%d]"), id == NULL ? -1 : _tcslen(id));
@@ -304,9 +296,9 @@ HANDLE CSametimeProto::SendFile(MCONTACT hContact, const PROTOCHAR* szDescriptio int CSametimeProto::SendMsg(MCONTACT hContact, int flags, const char* msg)
{
-
debugLog(_T("CSametimeProto::SendMsg() hContact=[%x], flags=[%d]"), hContact, flags);
- char* proto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+
+ char *proto = GetContactProto(hContact);
int ret;
if (!proto || strcmp(proto, m_szModuleName) != 0 || db_get_w(hContact, m_szModuleName, "Status", ID_STATUS_OFFLINE) == ID_STATUS_OFFLINE) {
@@ -318,9 +310,9 @@ int CSametimeProto::SendMsg(MCONTACT hContact, int flags, const char* msg) return 0;
}
- char* msg_utf8;
+ char *msg_utf8;
if (flags & PREF_UNICODE)
- msg_utf8 = mir_utf8encodeW((wchar_t*)&msg[ strlen( msg )+1 ] );
+ msg_utf8 = mir_utf8encodeW((wchar_t*)&msg[strlen(msg) + 1]);
else if (flags & PREF_UTF)
msg_utf8 = mir_strdup(msg);
else
@@ -332,7 +324,7 @@ int CSametimeProto::SendMsg(MCONTACT hContact, int flags, const char* msg) ret = (int)SendMessageToUser(hContact, msg_utf8);
mir_free(msg_utf8);
- TFakeAckParams* tfap = (TFakeAckParams*)mir_alloc(sizeof(TFakeAckParams));
+ TFakeAckParams *tfap = (TFakeAckParams*)mir_alloc(sizeof(TFakeAckParams));
tfap->proto = this;
tfap->hContact = hContact;
tfap->lParam = (LPARAM)ret;
@@ -347,7 +339,6 @@ int CSametimeProto::SendUrl(MCONTACT hContact, int flags, const char* url) return 1;
}
-
int CSametimeProto::SetApparentMode(MCONTACT hContact, int mode)
{
debugLog(_T("CSametimeProto::SetApparentMode() mode=[%d]"), mode);
@@ -363,7 +354,8 @@ int CSametimeProto::SetStatus(int iNewStatus) LogIn(iNewStatus, m_hNetlibUser);
else
SetSessionStatus(iNewStatus);
- } else if (m_iStatus != ID_STATUS_OFFLINE && iNewStatus == ID_STATUS_OFFLINE) {
+ }
+ else if (m_iStatus != ID_STATUS_OFFLINE && iNewStatus == ID_STATUS_OFFLINE) {
LogOut();
}
@@ -381,7 +373,7 @@ HANDLE CSametimeProto::GetAwayMsg(MCONTACT hContact) mir_forkthread(sttRecvAwayThread, (void*)tfap);
return (HANDLE)1;
}
- return (HANDLE)0;
+ return NULL;
}
int CSametimeProto::RecvAwayMsg(MCONTACT hContact, int mode, PROTORECVEVENT* evt)
@@ -392,21 +384,19 @@ int CSametimeProto::RecvAwayMsg(MCONTACT hContact, int mode, PROTORECVEVENT* evt TCHAR* pszMsg = mir_utf8decodeT(evt->szMessage);
ProtoBroadcastAck(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)evt->lParam, (LPARAM)pszMsg);
mir_free(pszMsg);
- } else {
- ProtoBroadcastAck(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)evt->lParam, (LPARAM)(TCHAR*)_A2T(evt->szMessage));
}
+ else ProtoBroadcastAck(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)evt->lParam, (LPARAM)(TCHAR*)_A2T(evt->szMessage));
return 0;
}
int CSametimeProto::SetAwayMsg(int iStatus, const PROTOCHAR* msg)
{
- debugLog(_T("CSametimeProto::SetAwayMsg() iStatus=[%d], msg:len=[%d]"), iStatus, msg == NULL ? -1 :_tcslen(msg));
+ debugLog(_T("CSametimeProto::SetAwayMsg() iStatus=[%d], msg:len=[%d]"), iStatus, msg == NULL ? -1 : _tcslen(msg));
SetSessionAwayMessage(iStatus, msg);
return 0;
}
-
int CSametimeProto::UserIsTyping(MCONTACT hContact, int type)
{
debugLog(_T("CSametimeProto::UserIsTyping() hContact=[%x], type=[%d]"), hContact, type);
@@ -414,15 +404,13 @@ int CSametimeProto::UserIsTyping(MCONTACT hContact, int type) return 0;
}
-
int CSametimeProto::OnEvent(PROTOEVENTTYPE iEventType, WPARAM wParam, LPARAM lParam)
{
- switch(iEventType) {
- case EV_PROTO_ONOPTIONS: {
+ switch (iEventType) {
+ case EV_PROTO_ONOPTIONS:
debugLog(_T("CSametimeProto::OnEvent() EV_PROTO_ONOPTIONS"));
OptInit(wParam, lParam);
break;
- }
}
return TRUE;
diff --git a/protocols/Sametime/src/sametime_proto.h b/protocols/Sametime/src/sametime_proto.h index 16cbeb17b0..fd4e3a43c8 100644 --- a/protocols/Sametime/src/sametime_proto.h +++ b/protocols/Sametime/src/sametime_proto.h @@ -66,6 +66,7 @@ struct CSametimeProto : public PROTO<CSametimeProto> INT_PTR __cdecl GetStatus(WPARAM wParam, LPARAM lParam);
INT_PTR __cdecl SametimeLoadIcon(WPARAM wParam, LPARAM lParam);
int __cdecl OnWindowEvent(WPARAM wParam, LPARAM lParam);
+ int __cdecl OnModulesLoaded(WPARAM wParam, LPARAM lParam);
int __cdecl OnPreShutdown(WPARAM wParam, LPARAM lParam);
int __cdecl OnIdleChanged(WPARAM wParam, LPARAM lParam);
void SetAllOffline();
@@ -136,7 +137,6 @@ struct CSametimeProto : public PROTO<CSametimeProto> WORD GetClientVersion();
WORD GetServerVersion();
INT_PTR __cdecl SessionAnnounce(WPARAM wParam, LPARAM lParam);
- void InitGroupChats();
void InitAwayMsg();
void DeinitAwayMsg();
void InitMeanwhileServices();
diff --git a/protocols/Sametime/src/sametime_session.cpp b/protocols/Sametime/src/sametime_session.cpp index 9ddfaf9f88..ceeb2d97a8 100644 --- a/protocols/Sametime/src/sametime_session.cpp +++ b/protocols/Sametime/src/sametime_session.cpp @@ -13,7 +13,6 @@ struct { char* szDND;
} AwayMessages;
-
void __cdecl SessionClear(mwSession* session)
{
CSametimeProto* proto = (CSametimeProto*)mwSession_getProperty(session, "PROTO_STRUCT_PTR");
@@ -41,7 +40,8 @@ void __cdecl SessionClose(mwSession* session) void CSametimeProto::SessionStarted()
{
UserListCreate();
- if (options.get_server_contacts) UserListAddStored();
+ if (options.get_server_contacts)
+ UserListAddStored();
}
void CSametimeProto::SessionStopping()
@@ -73,11 +73,11 @@ void CSametimeProto::InitMeanwhileServices() if (options.use_old_default_client_ver) {
mwSession_setProperty(session, mwSession_CLIENT_VER_MAJOR, GUINT_TO_POINTER(db_get_w(0, m_szModuleName, "ClientVersionMajor", MW_PROTOCOL_VERSION_MAJOR)), 0);
mwSession_setProperty(session, mwSession_CLIENT_VER_MINOR, GUINT_TO_POINTER(db_get_w(0, m_szModuleName, "ClientVersionMinor", MW_PROTOCOL_VERSION_MINOR)), 0);
- } else {
+ }
+ else {
mwSession_setProperty(session, mwSession_CLIENT_VER_MAJOR, GUINT_TO_POINTER(db_get_w(0, m_szModuleName, "ClientVersionMajor", 0x001e)), 0);
mwSession_setProperty(session, mwSession_CLIENT_VER_MINOR, GUINT_TO_POINTER(db_get_w(0, m_szModuleName, "ClientVersionMinor", 0x196f)), 0);
}
-
}
void CSametimeProto::DeinitMeanwhileServices()
@@ -96,8 +96,7 @@ void __cdecl SessionStateChange(mwSession* session, mwSessionState state, gpoint CSametimeProto* proto = (CSametimeProto*)mwSession_getProperty(session, "PROTO_STRUCT_PTR");
proto->debugLog(_T("SessionStateChange() state=[%d]"), state);
- switch(state) {
-
+ switch (state) {
case mwSession_STARTING:
break;
@@ -107,7 +106,7 @@ void __cdecl SessionStateChange(mwSession* session, mwSessionState state, gpoint case mwSession_HANDSHAKE_ACK:
break;
- case mwSession_STARTED:
+ case mwSession_STARTED:
proto->SessionStarted();
break;
@@ -124,7 +123,7 @@ void __cdecl SessionStateChange(mwSession* session, mwSessionState state, gpoint case mwSession_STOPPED:
break;
-
+
case mwSession_LOGIN_REDIR:
proto->debugLog(_T("SessionStateChange() mwSession_LOGIN_REDIR info=[%s]"), _A2T((char*)info));
//options.server_name = str((char*)info);
@@ -144,7 +143,6 @@ void __cdecl SessionStateChange(mwSession* session, mwSessionState state, gpoint case mwSession_UNKNOWN:
break;
-
}
}
@@ -181,21 +179,20 @@ void __cdecl SessionSetPrivacyInfo(struct mwSession* session) void __cdecl SessionSetUserStatus(struct mwSession* session)
{
CSametimeProto* proto = (CSametimeProto*)mwSession_getProperty(session, "PROTO_STRUCT_PTR");
-
+
int new_status;
struct mwUserStatus us;
mwUserStatus_clone(&us, mwSession_getUserStatus(session));
proto->debugLog(_T("SessionSetUserStatus() us.status=[%d]"), us.status);
- switch(us.status) {
-
+ switch (us.status) {
case mwStatus_ACTIVE:
- new_status = ID_STATUS_ONLINE;
+ new_status = ID_STATUS_ONLINE;
break;
case mwStatus_AWAY:
- new_status = ID_STATUS_AWAY;
+ new_status = ID_STATUS_AWAY;
if (proto->idle_status) {
// ignore setting to away by idle module, after we've set ourselves idle
// most standard clients represent idle and away the same way anyway,
@@ -208,11 +205,11 @@ void __cdecl SessionSetUserStatus(struct mwSession* session) break;
case mwStatus_BUSY:
- new_status = ID_STATUS_DND;
+ new_status = ID_STATUS_DND;
break;
case mwStatus_IDLE:
- new_status = ID_STATUS_AWAY;
+ new_status = ID_STATUS_AWAY;
if (!proto->first_online && !proto->options.idle_as_away) { // show our status in clist as away if idle when going online or treating idle as away
mwUserStatus_clear(&us);
return;
@@ -224,17 +221,15 @@ void __cdecl SessionSetUserStatus(struct mwSession* session) break;
default:
- {
- TCHAR buff[512];
- mir_sntprintf(buff, 512, TranslateT("Unknown user status: %d"), us.status);
- proto->showPopup(buff, SAMETIME_POPUP_ERROR);
- proto->debugLog(buff);
- }
+ TCHAR buff[512];
+ mir_sntprintf(buff, 512, TranslateT("Unknown user status: %d"), us.status);
+ proto->showPopup(buff, SAMETIME_POPUP_ERROR);
+ proto->debugLog(buff);
+
mwUserStatus_clear(&us);
// just go online...to prevent us getting stuck 'connecting'
new_status = ID_STATUS_ONLINE;
break;
-
}
proto->m_iDesiredStatus = new_status;
@@ -244,9 +239,8 @@ void __cdecl SessionSetUserStatus(struct mwSession* session) //proto->showPopup(TranslateT("Setting login status"), SAMETIME_POPUP_INFO);
proto->debugLog(_T("Setting login status"));
proto->SetSessionStatus(proto->login_status);
- } else {
- proto->BroadcastNewStatus(new_status);
}
+ else proto->BroadcastNewStatus(new_status);
mwUserStatus_clear(&us);
}
@@ -268,25 +262,25 @@ int CSametimeProto::SetSessionStatus(int status) us.time = (DWORD)time(0);
//us.time = 0;
- switch(status) {
- case ID_STATUS_FREECHAT:
- case ID_STATUS_ONLINE:
- us.desc = AwayMessages.szOnline; us.status = mwStatus_ACTIVE;
- break;
- case ID_STATUS_NA:
- case ID_STATUS_INVISIBLE:
- case ID_STATUS_ONTHEPHONE:
- case ID_STATUS_OUTTOLUNCH:
- case ID_STATUS_AWAY:
- us.desc = AwayMessages.szAway; us.status = mwStatus_AWAY;
- break;
- case ID_STATUS_OCCUPIED:
- case ID_STATUS_DND:
- us.desc = AwayMessages.szDND; us.status = mwStatus_BUSY;
- break;
- default:
- // act as online for unsupported status
- us.desc = AwayMessages.szOnline; us.status = mwStatus_ACTIVE; break;
+ switch (status) {
+ case ID_STATUS_FREECHAT:
+ case ID_STATUS_ONLINE:
+ us.desc = AwayMessages.szOnline; us.status = mwStatus_ACTIVE;
+ break;
+ case ID_STATUS_NA:
+ case ID_STATUS_INVISIBLE:
+ case ID_STATUS_ONTHEPHONE:
+ case ID_STATUS_OUTTOLUNCH:
+ case ID_STATUS_AWAY:
+ us.desc = AwayMessages.szAway; us.status = mwStatus_AWAY;
+ break;
+ case ID_STATUS_OCCUPIED:
+ case ID_STATUS_DND:
+ us.desc = AwayMessages.szDND; us.status = mwStatus_BUSY;
+ break;
+ default:
+ // act as online for unsupported status
+ us.desc = AwayMessages.szOnline; us.status = mwStatus_ACTIVE; break;
}
debugLog(_T("SetSessionStatus() mwSession_setUserStatus us.status=[%d], us.desc:len=[%d]"), us.status, us.desc == NULL ? -1 : strlen(us.desc));
@@ -308,22 +302,22 @@ VOID CALLBACK IdleTimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime us.status = mwStatus_IDLE;
us.desc = 0;
mwSession_setUserStatus(proto->session, &us);
- } else {
- proto->SetSessionStatus(proto->m_iStatus);
}
+ else proto->SetSessionStatus(proto->m_iStatus);
}
int CSametimeProto::SetIdle(bool idle)
{
- // set a timer, to wait for any autoaway module which might set our status
+ // set a timer, to wait for any autoaway module which might set our status
debugLog(_T("CSametimeProto::SetIdle() idle=[%d], idle_status=[%d], idle_timerid=[%d]"), idle, idle_status, idle_timerid);
if (idle && !idle_status) {
idle_status = true;
- if (!idle_timerid)
+ if (!idle_timerid)
idle_timerid = SetTimer(0, (UINT_PTR)this, 200, IdleTimerProc);
- } else if (idle_status) {
+ }
+ else if (idle_status) {
idle_status = false;
- if (!idle_timerid)
+ if (!idle_timerid)
idle_timerid = SetTimer(0, (UINT_PTR)this, 200, IdleTimerProc);
}
return 0;
@@ -334,30 +328,20 @@ void CSametimeProto::SetSessionAwayMessage(int status, const PROTOCHAR* msgT) debugLog(_T("SetSessionAwayMessage() status=[%d], msgT:len=[%d]"), status, msgT == NULL ? -1 : _tcslen(msgT));
ptrA msg(mir_utf8encodeT(msgT));
- if (status == ID_STATUS_ONLINE) {
- mir_free(AwayMessages.szOnline);
- if (msg) {
- AwayMessages.szOnline = mir_strdup(msg);
- } else AwayMessages.szOnline = 0;
- } else if (status == ID_STATUS_AWAY) {
- mir_free(AwayMessages.szAway);
- if (msg) {
- AwayMessages.szAway = mir_strdup(msg);
- } else AwayMessages.szAway = 0;
- } else if (status == ID_STATUS_DND) {
- mir_free(AwayMessages.szDND);
- if (msg) {
- AwayMessages.szDND = mir_strdup(msg);
- } else AwayMessages.szDND = 0;
- } else
+ if (status == ID_STATUS_ONLINE)
+ replaceStr(AwayMessages.szOnline, msg);
+ else if (status == ID_STATUS_AWAY)
+ replaceStr(AwayMessages.szAway, msg);
+ else if (status == ID_STATUS_DND)
+ replaceStr(AwayMessages.szDND, msg);
+ else
return; // unsupported status
- if (session){
+ if (session)
SetSessionStatus(status); // update current away message
- }
}
-static VOID CALLBACK NullAPC (DWORD_PTR)
+static VOID CALLBACK NullAPC(DWORD_PTR)
{
// This function intentionally left blank
}
@@ -373,20 +357,20 @@ void __cdecl KeepAliveThread(LPVOID param) int i = 120;
proto->debugLog(_T("KeepAliveThread() start"));
- while(1) {
-
- if (i <= 0){
+ while (1) {
+
+ if (i <= 0) {
i = 120;
// send keepalive every 120 * 250 = 30000[ms]
- if (mwSession_isStarted(proto->session) && proto->session){
+ if (mwSession_isStarted(proto->session) && proto->session) {
mwSession_sendKeepalive(proto->session);
}
}
-
+
i--;
-
+
SleepEx(250, TRUE);
-
+
EnterCriticalSection(&(proto->session_cs));
if (Miranda_Terminated() || !proto->session) {
LeaveCriticalSection(&(proto->session_cs));
@@ -406,7 +390,6 @@ int waitcallback(unsigned int* timeout) void __cdecl SessionThread(LPVOID param)
{
-
CSametimeProto* proto = (CSametimeProto*)param;
HANDLE hNetlibUser = proto->m_hNetlibUser;
proto->debugLog(_T("SessionThread() start"));
@@ -414,7 +397,7 @@ void __cdecl SessionThread(LPVOID param) continue_connect = true;
//setup
- NETLIBOPENCONNECTION conn_data = {0};
+ NETLIBOPENCONNECTION conn_data = { 0 };
conn_data.cbSize = sizeof(NETLIBOPENCONNECTION);
conn_data.flags = NLOCF_V2;
conn_data.szHost = proto->options.server_name;
@@ -439,7 +422,7 @@ void __cdecl SessionThread(LPVOID param) return;
}
- mwSessionHandler handler = {0};
+ mwSessionHandler handler = { 0 };
handler.clear = SessionClear;
handler.io_write = SessionWrite;
handler.io_close = SessionClose;
@@ -448,7 +431,7 @@ void __cdecl SessionThread(LPVOID param) handler.on_announce = SessionAnnounce;
handler.on_setPrivacyInfo = SessionSetPrivacyInfo;
handler.on_setUserStatus = SessionSetUserStatus;
-
+
EnterCriticalSection(&proto->session_cs);
proto->session = mwSession_new(&handler);
@@ -462,16 +445,18 @@ void __cdecl SessionThread(LPVOID param) unsigned char* recv_buffer = (unsigned char*)mir_alloc(1024 * 32);
int bytes;
//while(session && server_connection && mwSession_getState(session) != mwSession_STOPPED) {
- while(proto->server_connection) {// && session) {// && !mwSession_isStopped(session)) { // break on error
+ while (proto->server_connection) {// && session) {// && !mwSession_isStopped(session)) { // break on error
bytes = Netlib_Recv(proto->server_connection, (char *)recv_buffer, 1024 * 32, 0);
proto->debugLog(_T("SessionThread() Netlib_Recv'ed bytes=[%d]"), bytes);
if (bytes == 0) {
break;
- } else if (bytes == SOCKET_ERROR) {
+ }
+ else if (bytes == SOCKET_ERROR) {
// this is normal - e.g. socket closed due to log off, during blocking read above
break;
- } else {
+ }
+ else {
EnterCriticalSection(&proto->session_cs);
mwSession_recv(proto->session, recv_buffer, bytes);
LeaveCriticalSection(&proto->session_cs);
@@ -544,7 +529,7 @@ int CSametimeProto::LogOut() mwSession_stop(session, 0);
}
LeaveCriticalSection(&session_cs);
-
+
return 0;
}
@@ -566,7 +551,7 @@ void SendAnnouncement(SendAnnouncementFunc_arg* arg) {
CSametimeProto* proto = arg->proto;
char* utfs = mir_utf8encodeT(arg->msg);
- if (proto->session && arg->recipients) mwSession_sendAnnounce(proto->session, false , utfs, arg->recipients);
+ if (proto->session && arg->recipients) mwSession_sendAnnounce(proto->session, false, utfs, arg->recipients);
mir_free(utfs);
}
@@ -617,18 +602,3 @@ void CSametimeProto::DeinitCritSection() debugLog(_T("CSametimeProto::DeinitCritSection()"));
DeleteCriticalSection(&session_cs);
}
-
-void CSametimeProto::InitGroupChats()
-{
- debugLog(_T("CSametimeProto::InitGroupChats()"));
-
- // register with chat module
- GCREGISTER gcr = { sizeof(gcr) };
- gcr.pszModule = m_szModuleName;
- gcr.ptszDispName = m_tszUserName;
- gcr.dwFlags = 0;
- gcr.iMaxText = MAX_MESSAGE_SIZE;
- gcr.nColors = 0;
- gcr.pColors = 0;
- CallService(MS_GC_REGISTER, 0, (LPARAM)(GCREGISTER*) &gcr);
-}
diff --git a/protocols/Sametime/src/session_announce_win.cpp b/protocols/Sametime/src/session_announce_win.cpp index 8cf9cecb8f..fbc163677b 100644 --- a/protocols/Sametime/src/session_announce_win.cpp +++ b/protocols/Sametime/src/session_announce_win.cpp @@ -1,38 +1,37 @@ #include "StdAfx.h"
#include "sametime.h"
-INT_PTR CALLBACK SessionAnnounceDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) {
-
+INT_PTR CALLBACK SessionAnnounceDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
SessionAnnounceDialogProc_arg* arg = (SessionAnnounceDialogProc_arg*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- CSametimeProto* proto;
- if (arg != NULL) proto = arg->proto;
-
- switch(uMsg) {
- case WM_INITDIALOG: {
+ CSametimeProto *proto;
+ if (arg != NULL)
+ proto = arg->proto;
- TranslateDialogDefault(hwndDlg);
+ switch (uMsg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+ {
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
SessionAnnounceDialogProc_arg* arg = (SessionAnnounceDialogProc_arg*)lParam;
proto = arg->proto;
proto->debugLog(_T("SessionAnnounceDialogProc WM_INITDIALOG"));
- SendMessage(GetDlgItem(hwndDlg, IDC_LST_ANTO),LVM_SETEXTENDEDLISTVIEWSTYLE, 0,LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES);
-
+ SendMessage(GetDlgItem(hwndDlg, IDC_LST_ANTO), LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES);
{
- LVCOLUMN lvc;
+ LVCOLUMN lvc;
// Initialize the LVCOLUMN structure.
// The mask specifies that the format, width, text, and
// subitem members of the structure are valid.
- lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
+ lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
lvc.fmt = LVCFMT_LEFT;
-
+
lvc.iSubItem = 0;
- lvc.pszText = TranslateT("Recipients");
+ lvc.pszText = TranslateT("Recipients");
lvc.cx = 300; // width of column in pixels
ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_LST_ANTO), 0, &lvc);
}
-
//enumerate plugins, fill in list
{
ListView_DeleteAllItems(GetDlgItem(hwndDlg, IDC_LST_ANTO));
@@ -40,13 +39,12 @@ INT_PTR CALLBACK SessionAnnounceDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wPara // Some code to create the list-view control.
// Initialize LVITEM members that are common to all items.
lvI.mask = LVIF_TEXT | LVIF_PARAM;// | LVIF_NORECOMPUTE;// | LVIF_IMAGE;
- lvI.iItem=0;
- lvI.iSubItem=0;
+ lvI.iItem = 0;
+ lvI.iSubItem = 0;
for (MCONTACT hContact = db_find_first(proto->m_szModuleName); hContact; hContact = db_find_next(hContact, proto->m_szModuleName)) {
if (db_get_b(hContact, proto->m_szModuleName, "ChatRoom", 0) == 0
- && db_get_w(hContact, proto->m_szModuleName, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE)
- {
+ && db_get_w(hContact, proto->m_szModuleName, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) {
lvI.lParam = (LPARAM)hContact;
lvI.pszText = (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR);
ListView_InsertItem(GetDlgItem(hwndDlg, IDC_LST_ANTO), &lvI);
@@ -54,94 +52,92 @@ INT_PTR CALLBACK SessionAnnounceDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wPara }
}
}
-
- return 0;
- }
-
- case WM_CLOSE:
- proto->debugLog(_T("SessionAnnounceDialogProc WM_CLOSE"));
- mir_free(arg);
- DestroyWindow(hwndDlg);
- break;
-
- case WM_COMMAND:
- if (HIWORD(wParam) == BN_CLICKED ) {
- switch(LOWORD(wParam)) {
-
- case IDC_BUT_SELALL: {
- int size = ListView_GetItemCount(GetDlgItem(hwndDlg, IDC_LST_ANTO));
- for (int i = 0; i < size; i++) ListView_SetCheckState(GetDlgItem(hwndDlg, IDC_LST_ANTO), i, true);
- }
- return 0;
-
- case IDC_BUT_SELINV: {
- int size = ListView_GetItemCount(GetDlgItem(hwndDlg, IDC_LST_ANTO));
- for (int i = 0; i < size; i++)
- ListView_SetCheckState(GetDlgItem(hwndDlg, IDC_LST_ANTO), i,
- !ListView_GetCheckState(GetDlgItem(hwndDlg, IDC_LST_ANTO), i)
- );
- }
- return 0;
-
- case IDOK: {
- proto->debugLog(_T("SessionAnnounceDialogProc IDOK BN_CLICKED"));
- // build SendAnnouncementFunc_arg
- SendAnnouncementFunc_arg* safArg = (SendAnnouncementFunc_arg*)mir_calloc(sizeof(SendAnnouncementFunc_arg));
- DBVARIANT dbv;
- LVITEM lvI = {0};
-
- char id[1024];
- strcpy(id, "@U"); // documentation says prepend '@U' to usernames and '@G' to notes group names - but
- char *p = id + 2; // it's wrong - it works for a list of user id's with no prefix - so we'll do both
-
- // build recipient list
- safArg->recipients = 0;
-
- int size = ListView_GetItemCount(GetDlgItem(hwndDlg, IDC_LST_ANTO));
- int send_count = 0;
- for (int i = 0; i < size; i++) {
- if (ListView_GetCheckState(GetDlgItem(hwndDlg, IDC_LST_ANTO), i)) {
- lvI.iItem = i;
- lvI.iSubItem = 0;
- lvI.mask = LVIF_PARAM;
- ListView_GetItem(GetDlgItem(hwndDlg, IDC_LST_ANTO), &lvI);
-
- if (!db_get_utf((MCONTACT)lvI.lParam, proto->m_szModuleName, "stid", &dbv)) {
- safArg->recipients = g_list_prepend(safArg->recipients, _strdup(dbv.pszVal));
- strcpy(p, dbv.pszVal);
- safArg->recipients = g_list_prepend(safArg->recipients, _strdup(id));
- send_count++;
- db_free(&dbv);
- }
- }
- }
-
- if (send_count > 0) {
- GetWindowText(GetDlgItem(hwndDlg, IDC_ED_ANMSG), safArg->msg, MAX_MESSAGE_SIZE);
- safArg->proto = proto;
- SendAnnouncementFunc sendAnnouncementFunc = arg->sendAnnouncementFunc;
- sendAnnouncementFunc(safArg);
+ }
+ return 0;
+
+ case WM_CLOSE:
+ proto->debugLog(_T("SessionAnnounceDialogProc WM_CLOSE"));
+ mir_free(arg);
+ DestroyWindow(hwndDlg);
+ break;
+
+ case WM_COMMAND:
+ if (HIWORD(wParam) == BN_CLICKED) {
+ int size;
+ switch (LOWORD(wParam)) {
+ case IDC_BUT_SELALL:
+ size = ListView_GetItemCount(GetDlgItem(hwndDlg, IDC_LST_ANTO));
+ for (int i = 0; i < size; i++)
+ ListView_SetCheckState(GetDlgItem(hwndDlg, IDC_LST_ANTO), i, true);
+ return 0;
+
+ case IDC_BUT_SELINV:
+ size = ListView_GetItemCount(GetDlgItem(hwndDlg, IDC_LST_ANTO));
+ for (int i = 0; i < size; i++)
+ ListView_SetCheckState(GetDlgItem(hwndDlg, IDC_LST_ANTO), i,
+ !ListView_GetCheckState(GetDlgItem(hwndDlg, IDC_LST_ANTO), i));
+ return 0;
+
+ case IDOK:
+ proto->debugLog(_T("SessionAnnounceDialogProc IDOK BN_CLICKED"));
+ {
+ // build SendAnnouncementFunc_arg
+ SendAnnouncementFunc_arg* safArg = (SendAnnouncementFunc_arg*)mir_calloc(sizeof(SendAnnouncementFunc_arg));
+ DBVARIANT dbv;
+ LVITEM lvI = { 0 };
+
+ char id[1024];
+ strcpy(id, "@U"); // documentation says prepend '@U' to usernames and '@G' to notes group names - but
+ char *p = id + 2; // it's wrong - it works for a list of user id's with no prefix - so we'll do both
+
+ // build recipient list
+ safArg->recipients = 0;
+
+ int size = ListView_GetItemCount(GetDlgItem(hwndDlg, IDC_LST_ANTO));
+ int send_count = 0;
+ for (int i = 0; i < size; i++) {
+ if (ListView_GetCheckState(GetDlgItem(hwndDlg, IDC_LST_ANTO), i)) {
+ lvI.iItem = i;
+ lvI.iSubItem = 0;
+ lvI.mask = LVIF_PARAM;
+ ListView_GetItem(GetDlgItem(hwndDlg, IDC_LST_ANTO), &lvI);
+
+ if (!db_get_utf((MCONTACT)lvI.lParam, proto->m_szModuleName, "stid", &dbv)) {
+ safArg->recipients = g_list_prepend(safArg->recipients, _strdup(dbv.pszVal));
+ strcpy(p, dbv.pszVal);
+ safArg->recipients = g_list_prepend(safArg->recipients, _strdup(id));
+ send_count++;
+ db_free(&dbv);
}
+ }
+ }
- // clean up recipient list
- if (safArg->recipients){
- for (GList *rit = safArg->recipients; rit; rit = rit->next) {
- free(rit->data);
- }
- g_list_free(safArg->recipients);
- }
+ if (send_count > 0) {
+ GetWindowText(GetDlgItem(hwndDlg, IDC_ED_ANMSG), safArg->msg, MAX_MESSAGE_SIZE);
+ safArg->proto = proto;
+ SendAnnouncementFunc sendAnnouncementFunc = arg->sendAnnouncementFunc;
+ sendAnnouncementFunc(safArg);
+ }
- DestroyWindow(hwndDlg);
+ // clean up recipient list
+ if (safArg->recipients) {
+ for (GList *rit = safArg->recipients; rit; rit = rit->next) {
+ free(rit->data);
}
- return 0;
+ g_list_free(safArg->recipients);
+ }
- case IDCANCEL:
- DestroyWindow(hwndDlg);
- return 0;
+ DestroyWindow(hwndDlg);
}
+ return 0;
+
+ case IDCANCEL:
+ DestroyWindow(hwndDlg);
+ return 0;
}
- break;
+ }
+ break;
}
return 0;
-}
\ No newline at end of file +}
diff --git a/protocols/Sametime/src/userlist.cpp b/protocols/Sametime/src/userlist.cpp index f5a7f4cccc..9791033b00 100644 --- a/protocols/Sametime/src/userlist.cpp +++ b/protocols/Sametime/src/userlist.cpp @@ -18,9 +18,9 @@ MCONTACT CSametimeProto::FindContactByUserId(const char* id) bool CSametimeProto::GetAwareIdFromContact(MCONTACT hContact, mwAwareIdBlock* id_block)
{
- char* proto = (char*)CallService( MS_PROTO_GETCONTACTBASEPROTO, ( WPARAM )hContact,0 );
+ char *proto = GetContactProto(hContact);
DBVARIANT dbv;
- if ( proto && !strcmp(m_szModuleName, proto)) {
+ if (proto && !strcmp(m_szModuleName, proto)) {
if (!db_get_utf(hContact, m_szModuleName, "stid", &dbv)) {
if (dbv.pszVal) {
id_block->type = mwAware_USER;
@@ -59,9 +59,8 @@ void CSametimeProto::AddGroup(const char* name, bool expanded) }
}
-MCONTACT CSametimeProto::AddContact(mwSametimeUser* user, bool temporary)
+MCONTACT CSametimeProto::AddContact(mwSametimeUser* user, bool temporary)
{
-
debugLog(_T("CSametimeProto::AddContact() start"));
const char* id = mwSametimeUser_getUser(user);
const char* name = mwSametimeUser_getShortName(user);
@@ -77,13 +76,14 @@ MCONTACT CSametimeProto::AddContact(mwSametimeUser* user, bool temporary) debugLog(_T("AddContact(): Failed to create Sametime contact"));
return NULL; ///TODO error handling
}
- if (CallService(MS_PROTO_ADDTOCONTACT, (WPARAM) hContact, (LPARAM) m_szModuleName) != 0) {
- CallService(MS_DB_CONTACT_DELETE, (WPARAM) hContact, 0);
+ if (CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)hContact, (LPARAM)m_szModuleName) != 0) {
+ CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0);
debugLog(_T("AddContact(): Failed to register Sametime contact"));
return NULL; ///TODO error handling
}
new_contact = true;
- } else if (!temporary) {
+ }
+ else if (!temporary) {
db_unset(hContact, "CList", "NotOnList");
db_unset(hContact, "CList", "Hidden");
}
@@ -97,9 +97,11 @@ MCONTACT CSametimeProto::AddContact(mwSametimeUser* user, bool temporary) if (nick && strlen(nick)) {
db_set_utf(hContact, m_szModuleName, "Nick", nick);
- } else if (name && strlen(name)) {
+ }
+ else if (name && strlen(name)) {
db_set_utf(hContact, m_szModuleName, "Nick", name);
- } else {
+ }
+ else {
db_set_utf(hContact, m_szModuleName, "Nick", id);
}
@@ -111,7 +113,7 @@ MCONTACT CSametimeProto::AddContact(mwSametimeUser* user, bool temporary) if (GetAwareIdFromContact(hContact, &id_block)) {
GList* gl = g_list_prepend(NULL, &id_block);
mwAwareList_addAware(aware_list, gl);
- g_list_free(gl);
+ g_list_free(gl);
free(id_block.user);
}
}
@@ -119,7 +121,8 @@ MCONTACT CSametimeProto::AddContact(mwSametimeUser* user, bool temporary) if (temporary) {
db_set_b(hContact, "CList", "NotOnList", 1);
db_set_b(hContact, "CList", "Hidden", 1);
- } else {
+ }
+ else {
db_unset(hContact, "CList", "NotOnList");
db_unset(hContact, "CList", "Hidden");
}
@@ -172,7 +175,7 @@ void CSametimeProto::ImportContactsFromList(mwSametimeList* user_list, bool temp GList* gl = g_list_prepend(NULL, &id_block);
mwAwareList_addAware(aware_list, gl);
- g_list_free(gl);
+ g_list_free(gl);
}
ul = utl = mwSametimeGroup_getUsers(stgroup);
@@ -215,7 +218,8 @@ void CSametimeProto::ExportContactsToList(mwSametimeList* user_list) if (!db_get_utf(hContact, "CList", "Group", &dbv2)) {
group_alias = _strdup(dbv2.pszVal);
db_free(&dbv2);
- } else
+ }
+ else
group_alias = _strdup(Translate("None"));
if (group_alias) {
@@ -234,9 +238,10 @@ void CSametimeProto::ExportContactsToList(mwSametimeList* user_list) if (!db_get_utf(0, szProtoGroups, buff, &dbv2)) {
group_name = _strdup(dbv2.pszVal);
db_free(&dbv2);
- } else
+ }
+ else
group_name = _strdup(group_alias);
-
+
//group_open = (db_get_b(0, szProtoGroups, buff, 0) == 1);
ptrT ptszGroup(mir_utf8decodeT(group_alias));
@@ -245,7 +250,8 @@ void CSametimeProto::ExportContactsToList(mwSametimeList* user_list) int expanded;
CallService(MS_CLIST_GROUPGETNAME, (WPARAM)hGroup, (LPARAM)&expanded);
group_open = (expanded != 0);
- } else {
+ }
+ else {
mir_snprintf(buff, SIZEOF(buff), "GO_%s", group_alias);
group_open = (db_get_b(0, szProtoGroups, buff, 0) == 1);
}
@@ -264,13 +270,15 @@ void CSametimeProto::ExportContactsToList(mwSametimeList* user_list) if (!db_get_utf(hContact, m_szModuleName, "Name", &dbv2)) {
user_shortName = _strdup(dbv2.pszVal);
db_free(&dbv2);
- } else
+ }
+ else
user_shortName = 0;
if (!db_get_utf(hContact, "CList", "MyHandle", &dbv2)) {
user_alias = _strdup(dbv2.pszVal);
db_free(&dbv2);
- } else
+ }
+ else
user_alias = 0;
user_type = (mwSametimeUserType)db_get_b(hContact, m_szModuleName, "type", (BYTE)mwSametimeUser_NORMAL);
@@ -304,7 +312,7 @@ void CSametimeProto::ImportContactsFromFile(TCHAR* filename) std::string text;
std::string line;
if (in.is_open()) {
- while(!in.eof()) {
+ while (!in.eof()) {
std::getline(in, line);
text += line;
text += "\r\n";
@@ -381,7 +389,7 @@ void CSametimeProto::UserListAddStored() int CSametimeProto::ContactDeleted(MCONTACT hContact)
{
mwAwareIdBlock id_block;
-
+
if (db_get_b(hContact, m_szModuleName, "ChatRoom", 0))
return 0;
@@ -458,23 +466,23 @@ void mwAwareList_on_aware(mwAwareList* list, mwAwareSnapshot* aware) MCONTACT hContact = proto->FindContactByUserId(aware->id.user);
char* group = 0;
DBVARIANT dbv;
-
+
// update self - necessary for some servers
if (aware->online && !db_get_utf(0, proto->m_szModuleName, "stid", &dbv) && strcmp(aware->id.user, dbv.pszVal) == 0) {
int new_status = ID_STATUS_OFFLINE;
- switch(aware->status.status) {
+ switch (aware->status.status) {
case mwStatus_ACTIVE:
- new_status = ID_STATUS_ONLINE;
+ new_status = ID_STATUS_ONLINE;
break;
case mwStatus_AWAY:
- new_status = ID_STATUS_AWAY;
+ new_status = ID_STATUS_AWAY;
break;
case mwStatus_IDLE:
new_status = ID_STATUS_IDLE;
break;
case mwStatus_BUSY:
- new_status = ID_STATUS_DND;
+ new_status = ID_STATUS_DND;
break;
}
if (new_status != ID_STATUS_IDLE) //SetSessionStatus(new_status);
@@ -487,8 +495,8 @@ void mwAwareList_on_aware(mwAwareList* list, mwAwareSnapshot* aware) group = _strdup(dbv.pszVal);
db_free(&dbv);
}
-
- if (aware->group && (!group || strcmp(aware->group, group) || !hContact)) {
+
+ if (aware->group && (!group || strcmp(aware->group, group) || !hContact)) {
// dynamic group member we're not already aware of
// resolve server alias to user id via resolver
mwSametimeList* user_list = mwSametimeList_new();
@@ -504,19 +512,20 @@ void mwAwareList_on_aware(mwAwareList* list, mwAwareSnapshot* aware) mwServiceResolve_resolve(proto->service_resolve, query, mwResolveFlag_USERS, mwResolve_handler_dyngroup_callback, (gpointer)stgroup, 0);
g_list_free(query);
- } else if (hContact) {
+ }
+ else if (hContact) {
if (aware->online) {
int new_status = ID_STATUS_OFFLINE;
- switch(aware->status.status) {
+ switch (aware->status.status) {
case mwStatus_ACTIVE:
- new_status = ID_STATUS_ONLINE;
+ new_status = ID_STATUS_ONLINE;
db_set_dw(hContact, proto->m_szModuleName, "IdleTS", 0);
db_set_w(hContact, proto->m_szModuleName, "Status", new_status);
break;
case mwStatus_AWAY:
- new_status = ID_STATUS_AWAY;
+ new_status = ID_STATUS_AWAY;
db_set_dw(hContact, proto->m_szModuleName, "IdleTS", 0);
db_set_w(hContact, proto->m_szModuleName, "Status", new_status);
break;
@@ -528,12 +537,13 @@ void mwAwareList_on_aware(mwAwareList* list, mwAwareSnapshot* aware) db_set_dw(hContact, proto->m_szModuleName, "IdleTS", (DWORD)time(0));
break;
case mwStatus_BUSY:
- new_status = ID_STATUS_DND;
+ new_status = ID_STATUS_DND;
db_set_w(hContact, proto->m_szModuleName, "Status", new_status);
db_set_dw(hContact, proto->m_szModuleName, "IdleTS", 0);
break;
}
- } else
+ }
+ else
db_set_w(hContact, proto->m_szModuleName, "Status", ID_STATUS_OFFLINE);
if (proto->service_aware) {
@@ -553,22 +563,19 @@ void mwAwareList_on_aware(mwAwareList* list, mwAwareSnapshot* aware) void mwAwareList_on_attrib(mwAwareList* list, mwAwareIdBlock* id, mwAwareAttribute* attrib)
-{
-}
+{}
void mwAwareList_clear(mwAwareList* list)
-{
-}
-
+{}
-mwAwareListHandler mwAwareList_handler = {
+mwAwareListHandler mwAwareList_handler =
+{
&mwAwareList_on_aware,
&mwAwareList_on_attrib,
&mwAwareList_clear
};
-
void CSametimeProto::UserListCreate()
{
debugLog(_T("CSametimeProto::UserListCreate() start"));
@@ -630,9 +637,8 @@ void CSametimeProto::UserRecvAwayMessage(MCONTACT hContact) if (!db_get_s((MCONTACT)hContact, "CList", "StatusMsg", &dbv, DBVT_TCHAR)) {
ProtoBroadcastAck((MCONTACT)hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, (LPARAM)dbv.ptszVal);
db_free(&dbv);
- } else {
- ProtoBroadcastAck((MCONTACT)hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, (LPARAM)NULL);
}
+ else ProtoBroadcastAck((MCONTACT)hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, (LPARAM)NULL);
}
void mwResolve_handler_callback(mwServiceResolve* srvc, guint32 id, guint32 code, GList* results, gpointer data)
@@ -640,7 +646,7 @@ void mwResolve_handler_callback(mwServiceResolve* srvc, guint32 id, guint32 code CSametimeProto* proto = getProtoFromMwServiceResolve(srvc);
BOOL advanced = (BOOL)data;
- MYCUSTOMSEARCHRESULTS mcsr = {0};
+ MYCUSTOMSEARCHRESULTS mcsr = { 0 };
mcsr.nSize = sizeof(MYCUSTOMSEARCHRESULTS);
//MYPROTOSEARCHRESULT mpsr = {0};
//mpsr.cbSize = sizeof(MYPROTOSEARCHRESULT);
@@ -669,9 +675,9 @@ void mwResolve_handler_callback(mwServiceResolve* srvc, guint32 id, guint32 code if (code == mwResolveCode_SUCCESS) {
GList *ri = results, *mri;
- for (;ri;ri = ri->next) {
+ for (; ri; ri = ri->next) {
mri = ((mwResolveResult *)ri->data)->matches;
- for (;mri;mri = mri->next) {
+ for (; mri; mri = mri->next) {
strncpy(mcsr.psr.stid, ((mwResolveMatch *)mri->data)->id, 256);
mcsr.psr.stid[255] = 0;
MultiByteToWideChar(CP_UTF8, 0, mcsr.psr.stid, -1, mcsr.pszFields[0], 512);
@@ -689,7 +695,7 @@ void mwResolve_handler_callback(mwServiceResolve* srvc, guint32 id, guint32 code //MultiByteToWideChar(CP_UTF8, 0, mcsr.psr.name, -1, mcsr.pszFields[1], 512);
_tcsncpy(mcsr.pszFields[3], mcsr.psr.group ? TranslateT("True") : TranslateT("False"), 512);
- if (advanced == TRUE)
+ if (advanced == TRUE)
proto->ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SEARCHRESULT, (HANDLE)id, (LPARAM)&mcsr);
else
proto->ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)id, (LPARAM)&mcsr.psr);
@@ -699,20 +705,19 @@ void mwResolve_handler_callback(mwServiceResolve* srvc, guint32 id, guint32 code }
}
-
void mwResolve_handler_details_callback(mwServiceResolve* srvc, guint32 id, guint32 code, GList* results, gpointer data)
{
CSametimeProto* proto = getProtoFromMwServiceResolve(srvc);
- MYPROTOSEARCHRESULT mpsr = {0};
+ MYPROTOSEARCHRESULT mpsr = { 0 };
mpsr.cbSize = sizeof(mpsr);
mpsr.nick = mpsr.name;
if (code == mwResolveCode_SUCCESS) {
GList *ri = results, *mri;
- for (;ri;ri = ri->next) {
+ for (; ri; ri = ri->next) {
mri = ((mwResolveResult *)ri->data)->matches;
- for (;mri;mri = mri->next) {
+ for (; mri; mri = mri->next) {
MCONTACT hContact = proto->FindContactByUserId(((mwResolveMatch*)mri->data)->id);
if (hContact) {
@@ -728,7 +733,6 @@ void mwResolve_handler_details_callback(mwServiceResolve* srvc, guint32 id, guin }
}
-
int CSametimeProto::SearchForUser(const char* name, BOOLEAN advanced)
{
if (m_iStatus != ID_STATUS_OFFLINE && service_resolve) {
@@ -740,7 +744,6 @@ int CSametimeProto::SearchForUser(const char* name, BOOLEAN advanced) return 0; // fail
}
-
int CSametimeProto::GetMoreDetails(const char* name)
{
if (m_iStatus != ID_STATUS_OFFLINE && service_resolve) {
@@ -752,20 +755,16 @@ int CSametimeProto::GetMoreDetails(const char* name) return 0; // fail
}
-
INT_PTR CALLBACK CALLBACK SearchDialogFunc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg) {
- case WM_INITDIALOG:
- {
- TranslateDialogDefault(hwndDlg);
- return TRUE;
- }
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+ return TRUE;
}
return FALSE;
}
-
MCONTACT CSametimeProto::AddSearchedUser(MYPROTOSEARCHRESULT* mpsr, bool temporary)
{
MCONTACT hContact = 0;
@@ -773,10 +772,11 @@ MCONTACT CSametimeProto::AddSearchedUser(MYPROTOSEARCHRESULT* mpsr, bool tempora mwSametimeList* user_list = mwSametimeList_new();
mwSametimeGroup* stgroup = 0;
if (mpsr->group) {
- stgroup = mwSametimeGroup_new(user_list, mwSametimeGroup_DYNAMIC, mpsr->stid);
- mwSametimeGroup_setAlias(stgroup, mpsr->name);
- ImportContactsFromList(user_list, temporary);
- } else {
+ stgroup = mwSametimeGroup_new(user_list, mwSametimeGroup_DYNAMIC, mpsr->stid);
+ mwSametimeGroup_setAlias(stgroup, mpsr->name);
+ ImportContactsFromList(user_list, temporary);
+ }
+ else {
stgroup = mwSametimeGroup_new(user_list, mwSametimeGroup_NORMAL, Translate("None"));
mwIdBlock uid;
@@ -787,12 +787,11 @@ MCONTACT CSametimeProto::AddSearchedUser(MYPROTOSEARCHRESULT* mpsr, bool tempora hContact = AddContact(stuser, temporary);
mwSametimeList_free(mwSametimeGroup_getList(stgroup));
- }
+ }
return hContact;
}
-
void mwServiceAware_on_attrib_callback(mwServiceAware* srvc, mwAwareAttribute* attrib)
{
}
@@ -801,20 +800,18 @@ void mwServiceAware_clear_callback(mwServiceAware* srvc) {
}
-
void CSametimeProto::InitUserList()
{
debugLog(_T("CSametimeProto::InitUserList()"));
mwSession_addService(session, (mwService*)(service_storage = mwServiceStorage_new(session)));
mwSession_addService(session, (mwService*)(service_resolve = mwServiceResolve_new(session)));
-
+
mwAwareHandler mwAware_handler = {
&mwServiceAware_on_attrib_callback,
&mwServiceAware_clear_callback
};
mwSession_addService(session, (mwService*)(service_aware = mwServiceAware_new(session, &mwAware_handler)));
-
}
void CSametimeProto::DeinitUserList()
@@ -833,4 +830,3 @@ void CSametimeProto::DeinitUserList() mwService_free((mwService*)service_storage);
service_storage = 0;
}
-
diff --git a/protocols/Sametime/src/utils.cpp b/protocols/Sametime/src/utils.cpp index 40e23fbe4a..6c8964e8a0 100644 --- a/protocols/Sametime/src/utils.cpp +++ b/protocols/Sametime/src/utils.cpp @@ -4,29 +4,23 @@ LRESULT CALLBACK PopupWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch (msg)
- {
- case WM_COMMAND:
- {
- PUDeletePopup(hWnd);
- break;
- }
-
- case WM_CONTEXTMENU:
- PUDeletePopup(hWnd);
- break;
-
- case UM_FREEPLUGINDATA:
- {
- PopupData* puData = (PopupData*)PUGetPluginData(hWnd);
- if (puData != NULL && puData != (PopupData*)CALLSERVICE_NOTFOUND)
- {
- mir_free(puData->title);
- mir_free(puData->text);
- mir_free(puData);
- }
- break;
+ switch (msg) {
+ case WM_COMMAND:
+ PUDeletePopup(hWnd);
+ break;
+
+ case WM_CONTEXTMENU:
+ PUDeletePopup(hWnd);
+ break;
+
+ case UM_FREEPLUGINDATA:
+ PopupData* puData = (PopupData*)PUGetPluginData(hWnd);
+ if (puData != NULL && puData != (PopupData*)CALLSERVICE_NOTFOUND) {
+ mir_free(puData->title);
+ mir_free(puData->text);
+ mir_free(puData);
}
+ break;
}
return DefWindowProc(hWnd, msg, wParam, lParam);
@@ -63,7 +57,6 @@ void CSametimeProto::RegisterPopups() puc.colorBack = GetSysColor(COLOR_BTNFACE);
puc.colorText = GetSysColor(COLOR_WINDOWTEXT);
hPopupError = Popup_RegisterClass(&puc);
-
}
@@ -90,51 +83,46 @@ void CALLBACK sttMainThreadCallback(PVOID dwParam) if (disp == ED_POP && !ServiceExists(MS_POPUP_ADDPOPUPCLASS)) disp = ED_BAL;
if (disp == ED_BAL && !ServiceExists(MS_CLIST_SYSTRAY_NOTIFY)) disp = ED_MB;
- if (disp == ED_POP){
-
- POPUPDATACLASS ppd = {sizeof(ppd)};
+ if (disp == ED_POP) {
+ POPUPDATACLASS ppd = { sizeof(ppd) };
char szName[256];
ppd.ptszTitle = puData->title;
ppd.ptszText = puData->text;
- if (puData->flag == SAMETIME_POPUP_ERROR){
+ if (puData->flag == SAMETIME_POPUP_ERROR)
mir_snprintf(szName, SIZEOF(szName), "%s_%s", proto->m_szModuleName, "Error");
- } else {
+ else
mir_snprintf(szName, SIZEOF(szName), "%s_%s", proto->m_szModuleName, "Notify");
- }
+ ppd.pszClassName = szName;
CallService(MS_POPUP_ADDPOPUPCLASS, 0, (LPARAM)&ppd);
-
- } else if (disp == ED_BAL) {
-
+ }
+ else if (disp == ED_BAL) {
MIRANDASYSTRAYNOTIFY sn = { sizeof(sn) };
sn.szProto = proto->m_szModuleName;
sn.tszInfoTitle = puData->title;
sn.tszInfo = puData->text;
sn.dwInfoFlags = NIIF_INTERN_UNICODE;
- if (puData->flag == SAMETIME_POPUP_ERROR){
+ if (puData->flag == SAMETIME_POPUP_ERROR) {
sn.dwInfoFlags = sn.dwInfoFlags | NIIF_WARNING;
sn.uTimeout = 1000 * 10;
- } else {
+ }
+ else {
sn.dwInfoFlags = sn.dwInfoFlags | NIIF_INFO;
sn.uTimeout = 1000 * 8;
}
CallService(MS_CLIST_SYSTRAY_NOTIFY, 0, (LPARAM)&sn);
-
- } else { //disp == ED_MB
-
- if (puData->flag == SAMETIME_POPUP_ERROR){
+ }
+ else { //disp == ED_MB
+ if (puData->flag == SAMETIME_POPUP_ERROR)
MessageBox(NULL, puData->text, puData->title, MB_OK | MB_ICONWARNING);
- } else {
+ else
MessageBox(NULL, puData->text, puData->title, MB_OK | MB_ICONINFORMATION);
- }
-
}
- if (disp != ED_POP){
+ if (disp != ED_POP) {
mir_free(puData->title);
mir_free(puData->text);
mir_free(puData);
}
-
}
void CSametimeProto::showPopup(const TCHAR* msg, SametimePopupEnum flag)
|