diff options
author | George Hazan <george.hazan@gmail.com> | 2015-06-07 13:12:43 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-06-07 13:12:43 +0000 |
commit | a5184b5e19951983bb9f699807cd9c5cf206c7ce (patch) | |
tree | 2f6d73676790a44dd3e194f7825abb36864de6f8 | |
parent | 1d18d087d47d7a54f68950f983029642a54d6f43 (diff) |
YAHOO search -> utf8
git-svn-id: http://svn.miranda-ng.org/main/trunk@14049 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | protocols/Yahoo/src/avatar.cpp | 338 | ||||
-rw-r--r-- | protocols/Yahoo/src/chat.cpp | 240 | ||||
-rw-r--r-- | protocols/Yahoo/src/file_transfer.cpp | 447 | ||||
-rw-r--r-- | protocols/Yahoo/src/http_gateway.cpp | 34 | ||||
-rw-r--r-- | protocols/Yahoo/src/icolib.cpp | 20 | ||||
-rw-r--r-- | protocols/Yahoo/src/ignore.cpp | 22 | ||||
-rw-r--r-- | protocols/Yahoo/src/im.cpp | 34 | ||||
-rw-r--r-- | protocols/Yahoo/src/links.cpp | 63 | ||||
-rw-r--r-- | protocols/Yahoo/src/main.cpp | 52 | ||||
-rw-r--r-- | protocols/Yahoo/src/options.cpp | 244 | ||||
-rw-r--r-- | protocols/Yahoo/src/proto.cpp | 87 | ||||
-rw-r--r-- | protocols/Yahoo/src/search.cpp | 124 | ||||
-rw-r--r-- | protocols/Yahoo/src/server.cpp | 53 | ||||
-rw-r--r-- | protocols/Yahoo/src/services.cpp | 170 | ||||
-rw-r--r-- | protocols/Yahoo/src/user_info.cpp | 39 | ||||
-rw-r--r-- | protocols/Yahoo/src/util.cpp | 82 | ||||
-rw-r--r-- | protocols/Yahoo/src/webcam.cpp | 6 | ||||
-rw-r--r-- | protocols/Yahoo/src/yahoo.cpp | 967 |
18 files changed, 1500 insertions, 1522 deletions
diff --git a/protocols/Yahoo/src/avatar.cpp b/protocols/Yahoo/src/avatar.cpp index 436b133066..35af086732 100644 --- a/protocols/Yahoo/src/avatar.cpp +++ b/protocols/Yahoo/src/avatar.cpp @@ -20,21 +20,14 @@ #include "avatar.h"
#include "resource.h"
-/*
- *31 bit hash function - this is based on g_string_hash function from glib
- */
-
+// 31 bit hash function - this is based on g_string_hash function from glib
int YAHOO_avt_hash(const char *key, DWORD len)
{
- /*
- Thank you Pidgin and Kopete devs. It seems that both clients are using this code now.
-
- */
-
+ // Thank you Pidgin and Kopete devs. It seems that both clients are using this code now.
const unsigned char *p = (const unsigned char *)key;
int checksum = 0, g, i = len;
- while(i--) {
+ while (i--) {
checksum = (checksum << 4) + *p++;
if ((g = (checksum & 0xf0000000)) != 0)
@@ -62,9 +55,9 @@ void upload_avt(int id, INT_PTR fd, int error, void *data) return;
}
- myhFile = CreateFileA(sf->filename,
+ myhFile = CreateFileA(sf->filename,
GENERIC_READ,
- FILE_SHARE_READ|FILE_SHARE_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN,
@@ -105,7 +98,7 @@ void upload_avt(int id, INT_PTR fd, int error, void *data) void __cdecl CYahooProto::send_avt_thread(void *psf)
{
- struct yahoo_file_info *sf = ( yahoo_file_info* )psf;
+ struct yahoo_file_info *sf = (yahoo_file_info*)psf;
if (sf == NULL) {
debugLogA("[yahoo_send_avt_thread] SF IS NULL!!!");
return;
@@ -124,7 +117,7 @@ void __cdecl CYahooProto::send_avt_thread(void *psf) void CYahooProto::SendAvatar(const TCHAR *szFile)
{
struct _stat statbuf;
- if (_tstat( szFile, &statbuf ) != 0) {
+ if (_tstat(szFile, &statbuf) != 0) {
LOG(("[YAHOO_SendAvatar] Error reading File information?!"));
return;
}
@@ -133,7 +126,7 @@ void CYahooProto::SendAvatar(const TCHAR *szFile) sf->filesize = statbuf.st_size;
wchar_t tszFilename[MAX_PATH];
- wcsncpy(tszFilename, szFile, SIZEOF(tszFilename)-1);
+ wcsncpy(tszFilename, szFile, SIZEOF(tszFilename) - 1);
GetShortPathNameW(szFile, tszFilename, SIZEOF(tszFilename));
char szFilename[MAX_PATH];
WideCharToMultiByte(CP_ACP, 0, tszFilename, -1, szFilename, MAX_PATH, 0, 0);
@@ -152,7 +145,7 @@ struct avatar_info{ void __cdecl CYahooProto::recv_avatarthread(void *pavt)
{
- struct avatar_info *avt = ( avatar_info* )pavt;
+ struct avatar_info *avt = (avatar_info*)pavt;
int error = 0;
TCHAR buf[4096];
@@ -175,21 +168,22 @@ void __cdecl CYahooProto::recv_avatarthread(void *pavt) if (!hContact) {
LOG(("ERROR: Can't find buddy: %s", avt->who));
error = 1;
- } else if (!error) {
+ }
+ else if (!error) {
setDword(hContact, "PictCK", avt->cksum);
setDword(hContact, "PictLoading", 1);
}
if (!error) {
- NETLIBHTTPREQUEST nlhr={0},*nlhrReply;
+ NETLIBHTTPREQUEST nlhr = { 0 }, *nlhrReply;
- nlhr.cbSize = sizeof(nlhr);
- nlhr.requestType= REQUEST_GET;
- nlhr.flags = NLHRF_NODUMP|NLHRF_GENERATEHOST|NLHRF_SMARTAUTHHEADER;
- nlhr.szUrl = avt->pic_url;
+ nlhr.cbSize = sizeof(nlhr);
+ nlhr.requestType = REQUEST_GET;
+ nlhr.flags = NLHRF_NODUMP | NLHRF_GENERATEHOST | NLHRF_SMARTAUTHHEADER;
+ nlhr.szUrl = avt->pic_url;
- nlhrReply=(NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION,(WPARAM)m_hNetlibUser,(LPARAM)&nlhr);
+ nlhrReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)m_hNetlibUser, (LPARAM)&nlhr);
if (nlhrReply) {
@@ -198,10 +192,12 @@ void __cdecl CYahooProto::recv_avatarthread(void *pavt) // make sure it's a real problem and not a problem w/ our connection
yahoo_send_picture_info(m_id, avt->who, 3, avt->pic_url, avt->cksum);
error = 1;
- } else if (nlhrReply->dataLength < 1 || nlhrReply->pData == NULL) {
+ }
+ else if (nlhrReply->dataLength < 1 || nlhrReply->pData == NULL) {
LOG(("No data??? Got %d bytes.", nlhrReply->dataLength));
error = 1;
- } else {
+ }
+ else {
GetAvatarFileName(hContact, buf, 1024, getByte(hContact, "AvatarType", 0));
DeleteFile(buf);
@@ -209,21 +205,22 @@ void __cdecl CYahooProto::recv_avatarthread(void *pavt) HANDLE myhFile = CreateFile(buf,
GENERIC_WRITE,
FILE_SHARE_WRITE,
- NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
+ NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
- if (myhFile !=INVALID_HANDLE_VALUE) {
+ if (myhFile != INVALID_HANDLE_VALUE) {
DWORD c;
WriteFile(myhFile, nlhrReply->pData, nlhrReply->dataLength, &c, NULL);
CloseHandle(myhFile);
setDword(hContact, "PictLastCheck", 0);
- } else {
+ }
+ else {
LOG(("Can not open file for writing: %s", buf));
error = 1;
}
}
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,(LPARAM)nlhrReply);
+ CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply);
}
}
@@ -236,12 +233,12 @@ void __cdecl CYahooProto::recv_avatarthread(void *pavt) LOG(("File download complete!?"));
if (error)
- buf[0]='\0';
+ buf[0] = '\0';
free(avt->who);
free(avt->pic_url);
free(avt);
-
+
PROTO_AVATAR_INFORMATION ai;
ai.format = PA_FORMAT_PNG;
ai.hContact = hContact;
@@ -250,7 +247,7 @@ void __cdecl CYahooProto::recv_avatarthread(void *pavt) if (error)
setDword(hContact, "PictCK", 0);
- ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, !error ? ACKRESULT_SUCCESS:ACKRESULT_FAILED,(HANDLE) &ai, 0);
+ ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, !error ? ACKRESULT_SUCCESS : ACKRESULT_FAILED, (HANDLE)&ai, 0);
}
void CYahooProto::ext_got_picture(const char *me, const char *who, const char *pic_url, int cksum, int type)
@@ -262,18 +259,18 @@ void CYahooProto::ext_got_picture(const char *me, const char *who, const char *p /*
Type:
- 1 - Send Avatar Info
- 2 - Got Avatar Info
- 3 - YIM6 didn't like my avatar? Expired? We need to invalidate and re-load
- */
+ 1 - Send Avatar Info
+ 2 - Got Avatar Info
+ 3 - YIM6 didn't like my avatar? Expired? We need to invalidate and re-load
+ */
switch (type) {
case 1:
{
- int cksum=0;
+ int cksum = 0;
DBVARIANT dbv;
/* need to send avatar info */
- if (!getByte("ShowAvatars", 1 )) {
+ if (!getByte("ShowAvatars", 1)) {
LOG(("[ext_yahoo_got_picture] We are not using/showing avatars!"));
yahoo_send_picture_update(m_id, who, 0); // no avatar (disabled)
return;
@@ -289,7 +286,8 @@ void CYahooProto::ext_got_picture(const char *me, const char *who, const char *p yahoo_send_picture_info(m_id, who, 2, dbv.pszVal, cksum);
db_free(&dbv);
break;
- } else
+ }
+ else
LOG(("No AvatarURL???"));
/*
@@ -300,84 +298,84 @@ void CYahooProto::ext_got_picture(const char *me, const char *who, const char *p if (!getTString("AvatarFile", &dbv)) {
struct _stat statbuf;
- if (_tstat( dbv.ptszVal, &statbuf ) != 0) {
+ if (_tstat(dbv.ptszVal, &statbuf) != 0) {
LOG(("[ext_yahoo_got_picture] Avatar File Missing? Can't find file: %s", dbv.ptszVal));
- } else {
+ }
+ else {
setString("AvatarInv", who);
SendAvatar(dbv.ptszVal);
}
db_free(&dbv);
- } else {
+ }
+ else {
LOG(("[ext_yahoo_got_picture] No Local Avatar File??? "));
}
- } else
- LOG(("[ext_yahoo_got_picture] Another avatar upload in progress?"));
+ }
+ else
+ LOG(("[ext_yahoo_got_picture] Another avatar upload in progress?"));
}
}
break;
case 2: /*
- * We got Avatar Info for our buddy.
- */
- if (!getByte("ShowAvatars", 1 )) {
- LOG(("[ext_yahoo_got_picture] We are not using/showing avatars!"));
- return;
- }
-
- /* got avatar info, so set miranda up */
- hContact = getbuddyH(who);
+ * We got Avatar Info for our buddy.
+ */
+ if (!getByte("ShowAvatars", 1)) {
+ LOG(("[ext_yahoo_got_picture] We are not using/showing avatars!"));
+ return;
+ }
- if (!hContact) {
- LOG(("[ext_yahoo_got_picture] Buddy not on my buddy list?."));
- return;
- }
+ /* got avatar info, so set miranda up */
+ hContact = getbuddyH(who);
+ if (!hContact) {
+ LOG(("[ext_yahoo_got_picture] Buddy not on my buddy list?."));
+ return;
+ }
- if (!cksum && pic_url) {
- const char *chk = strstr(pic_url, "chksum=");
- if (chk)
- cksum = strtol(chk + 7, NULL, 10);
- }
+ if (!cksum && pic_url) {
+ const char *chk = strstr(pic_url, "chksum=");
+ if (chk)
+ cksum = strtol(chk + 7, NULL, 10);
+ }
- if (!cksum || cksum == -1) {
- LOG(("[ext_yahoo_got_picture] Resetting avatar."));
- setDword(hContact, "PictCK", 0);
- reset_avatar(hContact);
+ if (!cksum || cksum == -1) {
+ LOG(("[ext_yahoo_got_picture] Resetting avatar."));
+ setDword(hContact, "PictCK", 0);
+ reset_avatar(hContact);
+ }
+ else {
+ if (pic_url == NULL) {
+ LOG(("[ext_yahoo_got_picture] WARNING: Empty URL for avatar?"));
+ return;
}
- else {
- if (pic_url == NULL) {
- LOG(("[ext_yahoo_got_picture] WARNING: Empty URL for avatar?"));
- return;
- }
- TCHAR z[1024];
- GetAvatarFileName(hContact, z, 1024, getByte(hContact, "AvatarType", 0));
+ TCHAR z[1024];
+ GetAvatarFileName(hContact, z, 1024, getByte(hContact, "AvatarType", 0));
- if (getDword(hContact, "PictCK", 0) != cksum || _taccess( z, 0) != 0) {
+ if (getDword(hContact, "PictCK", 0) != cksum || _taccess(z, 0) != 0) {
- debugLogA("[ext_yahoo_got_picture] Checksums don't match or avatar file is missing. Current: %d, New: %d",
- getDword(hContact, "PictCK", 0), cksum);
+ debugLogA("[ext_yahoo_got_picture] Checksums don't match or avatar file is missing. Current: %d, New: %d",
+ getDword(hContact, "PictCK", 0), cksum);
- struct avatar_info *avt = ( avatar_info* )malloc(sizeof(struct avatar_info));
- avt->who = strdup(who);
- avt->pic_url = strdup(pic_url);
- avt->cksum = cksum;
+ struct avatar_info *avt = (avatar_info*)malloc(sizeof(struct avatar_info));
+ avt->who = strdup(who);
+ avt->pic_url = strdup(pic_url);
+ avt->cksum = cksum;
- ForkThread(&CYahooProto::recv_avatarthread, avt);
- }
+ ForkThread(&CYahooProto::recv_avatarthread, avt);
}
+ }
break;
case 3:
- /*
- * Our Avatar is not good anymore? Need to re-upload??
- */
- /* who, pic_url, cksum */
+ // Our Avatar is not good anymore? Need to re-upload??
+ /* who, pic_url, cksum */
{
- int mcksum=0;
+ int mcksum = 0;
DBVARIANT dbv;
/* need to send avatar info */
- if (!getByte("ShowAvatars", 1 )) {
+ if (!getByte("ShowAvatars", 1)) {
LOG(("[ext_yahoo_got_picture] We are not using/showing avatars!"));
yahoo_send_picture_update(m_id, who, 0); // no avatar (disabled)
return;
@@ -396,44 +394,47 @@ void CYahooProto::ext_got_picture(const char *me, const char *who, const char *p LOG(("[ext_yahoo_got_picture] My Checksum: %d", mcksum));
if (!getString("AvatarURL", &dbv)) {
- if (mir_strcmpi(pic_url, dbv.pszVal) == 0) {
- DBVARIANT dbv2;
- /*time_t ts;
- DWORD ae;*/
+ if (mir_strcmpi(pic_url, dbv.pszVal) == 0) {
+ DBVARIANT dbv2;
+ /*time_t ts;
+ DWORD ae;*/
- if (mcksum != cksum)
- LOG(("[ext_yahoo_got_picture] WARNING: Checksums don't match!"));
+ if (mcksum != cksum)
+ LOG(("[ext_yahoo_got_picture] WARNING: Checksums don't match!"));
- /*time(&ts);
- ae = getDword("AvatarExpires", 0);
+ /*time(&ts);
+ ae = getDword("AvatarExpires", 0);
- if (ae != 0 && ae > (ts - 300)) {
- LOG(("[ext_yahoo_got_picture] Current Time: %lu Expires: %lu ", ts, ae));
- LOG(("[ext_yahoo_got_picture] We just reuploaded! Stop screwing with Yahoo FT. "));
+ if (ae != 0 && ae > (ts - 300)) {
+ LOG(("[ext_yahoo_got_picture] Current Time: %lu Expires: %lu ", ts, ae));
+ LOG(("[ext_yahoo_got_picture] We just reuploaded! Stop screwing with Yahoo FT. "));
- // don't leak stuff
- db_free(&dbv);
+ // don't leak stuff
+ db_free(&dbv);
- break;
- }*/
+ break;
+ }*/
- LOG(("[ext_yahoo_got_picture] Buddy: %s told us this is bad??Expired??. Re-uploading", who));
- delSetting("AvatarURL");
+ LOG(("[ext_yahoo_got_picture] Buddy: %s told us this is bad??Expired??. Re-uploading", who));
+ delSetting("AvatarURL");
- if (!getTString("AvatarFile", &dbv2)) {
- setString("AvatarInv", who);
- SendAvatar(dbv2.ptszVal);
- db_free(&dbv2);
- } else {
- LOG(("[ext_yahoo_got_picture] No Local Avatar File??? "));
- }
- } else {
- LOG(("[ext_yahoo_got_picture] URL doesn't match? Tell them the right thing!!!"));
- yahoo_send_picture_info(m_id, who, 2, dbv.pszVal, mcksum);
+ if (!getTString("AvatarFile", &dbv2)) {
+ setString("AvatarInv", who);
+ SendAvatar(dbv2.ptszVal);
+ db_free(&dbv2);
}
- // don't leak stuff
- db_free(&dbv);
- } else {
+ else {
+ LOG(("[ext_yahoo_got_picture] No Local Avatar File??? "));
+ }
+ }
+ else {
+ LOG(("[ext_yahoo_got_picture] URL doesn't match? Tell them the right thing!!!"));
+ yahoo_send_picture_info(m_id, who, 2, dbv.pszVal, mcksum);
+ }
+ // don't leak stuff
+ db_free(&dbv);
+ }
+ else {
LOG(("[ext_yahoo_got_picture] no AvatarURL?"));
}
}
@@ -467,7 +468,7 @@ void CYahooProto::ext_got_picture_checksum(const char *me, const char *who, int // Need to delete the Avatar File!!
TCHAR szFile[MAX_PATH];
- GetAvatarFileName(hContact, szFile, SIZEOF(szFile)-1, 0);
+ GetAvatarFileName(hContact, szFile, SIZEOF(szFile) - 1, 0);
DeleteFile(szFile);
// Reset the avatar and cleanup.
@@ -515,7 +516,7 @@ void CYahooProto::ext_got_picture_status(const char *me, const char *who, int bu reset_avatar(hContact);
}
-void CYahooProto::ext_got_picture_upload(const char *me, const char *url,unsigned int ts)
+void CYahooProto::ext_got_picture_upload(const char *me, const char *url, unsigned int ts)
{
int cksum = 0;
DBVARIANT dbv;
@@ -540,13 +541,14 @@ void CYahooProto::ext_got_picture_upload(const char *me, const char *url,unsigne // need to tell the stupid Yahoo that our icon updated
//YAHOO_bcast_picture_update(2);
- }else
+ }
+ else
cksum = getDword("AvatarHash", 0);
setString("AvatarURL", url);
//YAHOO_SetDword("AvatarExpires", ts);
- if (!getString("AvatarInv", &dbv)) {
+ if (!getString("AvatarInv", &dbv)) {
LOG(("[ext_yahoo_got_picture_upload] Buddy: %s told us this is bad??", dbv.pszVal));
LOG(("[ext_yahoo_got_picture] Sending url: %s checksum: %d to '%s'!", url, cksum, dbv.pszVal));
@@ -562,7 +564,7 @@ void CYahooProto::ext_got_avatar_share(int buddy_icon) {
LOG(("[ext_yahoo_got_avatar_share] buddy icon: %d", buddy_icon));
- setByte("ShareAvatar", buddy_icon );
+ setByte("ShareAvatar", buddy_icon);
}
void CYahooProto::reset_avatar(MCONTACT hContact)
@@ -574,7 +576,7 @@ void CYahooProto::reset_avatar(MCONTACT hContact) void CYahooProto::request_avatar(const char* who)
{
- if (!getByte("ShowAvatars", 1 )) {
+ if (!getByte("ShowAvatars", 1)) {
LOG(("Avatars disabled, but available for: %s", who));
return;
}
@@ -601,34 +603,36 @@ void CYahooProto::request_avatar(const char* who) void CYahooProto::GetAvatarFileName(MCONTACT hContact, TCHAR* pszDest, int cbLen, int type)
{
- int tPathLen = mir_sntprintf(pszDest, cbLen, _T("%s\\%S"), VARST( _T("%miranda_avatarcache%")), m_szModuleName);
+ int tPathLen = mir_sntprintf(pszDest, cbLen, _T("%s\\%S"), VARST(_T("%miranda_avatarcache%")), m_szModuleName);
- if ( _taccess(pszDest, 0))
+ if (_taccess(pszDest, 0))
CreateDirectoryTreeT(pszDest);
if (hContact != NULL) {
int ck_sum = getDword(hContact, "PictCK", 0);
tPathLen += mir_sntprintf(pszDest + tPathLen, cbLen - tPathLen, _T("\\%lX"), ck_sum);
- } else
+ }
+ else
tPathLen += mir_sntprintf(pszDest + tPathLen, cbLen - tPathLen, _T("\\%S avatar"), m_szModuleName);
- _tcsncpy_s((pszDest + tPathLen), (cbLen - tPathLen), (type == 1 ? _T(".swf") : _T(".png")), _TRUNCATE);
+ _tcsncpy_s((pszDest + tPathLen), (cbLen - tPathLen), (type == 1 ? _T(".swf") : _T(".png")), _TRUNCATE);
}
-INT_PTR __cdecl CYahooProto::GetAvatarInfo(WPARAM wParam,LPARAM lParam)
+INT_PTR __cdecl CYahooProto::GetAvatarInfo(WPARAM wParam, LPARAM lParam)
{
- PROTO_AVATAR_INFORMATION* pai = ( PROTO_AVATAR_INFORMATION* )lParam;
+ PROTO_AVATAR_INFORMATION* pai = (PROTO_AVATAR_INFORMATION*)lParam;
DBVARIANT dbv;
int avtType;
if (!getString(pai->hContact, YAHOO_LOGINID, &dbv)) {
debugLogA("[YAHOO_GETAVATARINFO] For: %s", dbv.pszVal);
db_free(&dbv);
- }else {
+ }
+ else {
debugLogA("[YAHOO_GETAVATARINFO]");
}
- if (!getByte("ShowAvatars", 1 ) || !m_bLoggedIn) {
+ if (!getByte("ShowAvatars", 1) || !m_bLoggedIn) {
debugLogA("[YAHOO_GETAVATARINFO] %s", m_bLoggedIn ? "We are not using/showing avatars!" : "We are not logged in. Can't load avatars now!");
return GAIR_NOAVATAR;
@@ -637,7 +641,7 @@ INT_PTR __cdecl CYahooProto::GetAvatarInfo(WPARAM wParam,LPARAM lParam) avtType = getByte(pai->hContact, "AvatarType", 0);
debugLogA("[YAHOO_GETAVATARINFO] Avatar Type: %d", avtType);
- if ( avtType != 2) {
+ if (avtType != 2) {
if (avtType != 0)
debugLogA("[YAHOO_GETAVATARINFO] Not handling this type yet!");
@@ -651,16 +655,17 @@ INT_PTR __cdecl CYahooProto::GetAvatarInfo(WPARAM wParam,LPARAM lParam) pai->format = PA_FORMAT_PNG;
debugLogA("[YAHOO_GETAVATARINFO] filename: %s", pai->filename);
- if (_taccess( pai->filename, 0) == 0)
+ if (_taccess(pai->filename, 0) == 0)
return GAIR_SUCCESS;
- if (( wParam & GAIF_FORCE ) != 0 && pai->hContact != NULL) {
+ if ((wParam & GAIF_FORCE) != 0 && pai->hContact != NULL) {
/* need to request it again? */
if (getDword(pai->hContact, "PictLoading", 0) != 0 &&
(time(NULL) - getDword(pai->hContact, "PictLastCheck", 0) < 500)) {
- debugLogA("[YAHOO_GETAVATARINFO] Waiting for avatar to load!");
- return GAIR_WAITFOR;
- } else if ( m_bLoggedIn ) {
+ debugLogA("[YAHOO_GETAVATARINFO] Waiting for avatar to load!");
+ return GAIR_WAITFOR;
+ }
+ else if (m_bLoggedIn) {
DBVARIANT dbv;
if (!getString(pai->hContact, YAHOO_LOGINID, &dbv)) {
@@ -670,7 +675,8 @@ INT_PTR __cdecl CYahooProto::GetAvatarInfo(WPARAM wParam,LPARAM lParam) db_free(&dbv);
return GAIR_WAITFOR;
- } else {
+ }
+ else {
debugLogA("[YAHOO_GETAVATARINFO] Can't retrieve user id?!");
}
}
@@ -710,7 +716,7 @@ INT_PTR __cdecl CYahooProto::GetAvatarCaps(WPARAM wParam, LPARAM lParam) case AF_ENABLED:
LOG(("[YahooGetAvatarCaps] AF_ENABLED"));
- res = (getByte("ShowAvatars", 1 )) ? 1 : 0;
+ res = (getByte("ShowAvatars", 1)) ? 1 : 0;
break;
case AF_DONTNEEDDELAYS:
@@ -740,7 +746,7 @@ return=0 on success, else on error */
INT_PTR __cdecl CYahooProto::GetMyAvatar(WPARAM wParam, LPARAM lParam)
{
- TCHAR *buffer = ( TCHAR* )wParam;
+ TCHAR *buffer = (TCHAR*)wParam;
int size = (int)lParam;
debugLogA("[YahooGetMyAvatar]");
@@ -748,7 +754,7 @@ INT_PTR __cdecl CYahooProto::GetMyAvatar(WPARAM wParam, LPARAM lParam) if (buffer == NULL || size <= 0)
return -1;
- if (!getByte("ShowAvatars", 1 ))
+ if (!getByte("ShowAvatars", 1))
return -2;
DBVARIANT dbv;
@@ -757,8 +763,8 @@ INT_PTR __cdecl CYahooProto::GetMyAvatar(WPARAM wParam, LPARAM lParam) if (getDword("AvatarHash", 0)) {
if (!getTString("AvatarFile", &dbv)) {
if (_taccess(dbv.ptszVal, 0) == 0) {
- mir_tstrncpy(buffer, dbv.ptszVal, size-1);
- buffer[size-1] = '\0';
+ mir_tstrncpy(buffer, dbv.ptszVal, size - 1);
+ buffer[size - 1] = '\0';
ret = 0;
}
@@ -778,8 +784,8 @@ return=0 for sucess INT_PTR __cdecl CYahooProto::SetMyAvatar(WPARAM wParam, LPARAM lParam)
{
- TCHAR* tszFile = ( TCHAR* )lParam;
- TCHAR tszMyFile[MAX_PATH+1];
+ TCHAR* tszFile = (TCHAR*)lParam;
+ TCHAR tszMyFile[MAX_PATH + 1];
GetAvatarFileName(NULL, tszMyFile, MAX_PATH, 2);
@@ -795,31 +801,32 @@ INT_PTR __cdecl CYahooProto::SetMyAvatar(WPARAM wParam, LPARAM lParam) /* Send a Yahoo packet saying we don't got an avatar anymore */
yahoo_send_picture_status(m_id, 0);
- setByte("ShareAvatar",0);
+ setByte("ShareAvatar", 0);
DeleteFile(tszMyFile);
- } else {
+ }
+ else {
HANDLE hFile = CreateFile(tszFile,
GENERIC_READ,
- FILE_SHARE_READ|FILE_SHARE_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN,
0);
- if ( hFile == INVALID_HANDLE_VALUE )
+ if (hFile == INVALID_HANDLE_VALUE)
return 1;
- DWORD dwPngSize = GetFileSize( hFile, NULL);
- BYTE *pResult = ( BYTE* )malloc(dwPngSize);
+ DWORD dwPngSize = GetFileSize(hFile, NULL);
+ BYTE *pResult = (BYTE*)malloc(dwPngSize);
if (pResult == NULL) {
CloseHandle(hFile);
return 2;
}
DWORD dw;
- ReadFile( hFile, pResult, dwPngSize, &dw, NULL);
- CloseHandle( hFile );
+ ReadFile(hFile, pResult, dwPngSize, &dw, NULL);
+ CloseHandle(hFile);
hFile = CreateFile(tszMyFile,
GENERIC_WRITE,
@@ -827,17 +834,17 @@ INT_PTR __cdecl CYahooProto::SetMyAvatar(WPARAM wParam, LPARAM lParam) NULL,
OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL, 0);
- if ( hFile == INVALID_HANDLE_VALUE )
+ if (hFile == INVALID_HANDLE_VALUE)
return 1;
- WriteFile( hFile, pResult, dwPngSize, &dw, NULL);
- SetEndOfFile( hFile);
- CloseHandle( hFile );
+ WriteFile(hFile, pResult, dwPngSize, &dw, NULL);
+ SetEndOfFile(hFile);
+ CloseHandle(hFile);
- unsigned int hash = YAHOO_avt_hash(( const char* )pResult, dwPngSize);
- free( pResult );
+ unsigned int hash = YAHOO_avt_hash((const char*)pResult, dwPngSize);
+ free(pResult);
- if ( hash ) {
+ if (hash) {
LOG(("[YAHOO_SetAvatar] File: '%s' CK: %d", tszMyFile, hash));
/* now check and make sure we don't reupload same thing over again */
@@ -847,18 +854,15 @@ INT_PTR __cdecl CYahooProto::SetMyAvatar(WPARAM wParam, LPARAM lParam) /* Set Sharing to ON if it's OFF */
if (getByte("ShareAvatar", 0) != 2) {
- setByte("ShareAvatar", 2 );
+ setByte("ShareAvatar", 2);
yahoo_send_picture_status(m_id, 2);
}
SendAvatar(tszMyFile);
}
else LOG(("[YAHOO_SetAvatar] Same checksum and avatar on YahooFT. Not Reuploading."));
- } }
+ }
+ }
return 0;
}
-
-/*
- * --=[ ]=--
- */
diff --git a/protocols/Yahoo/src/chat.cpp b/protocols/Yahoo/src/chat.cpp index 6cb48c658e..f29c2b99cb 100644 --- a/protocols/Yahoo/src/chat.cpp +++ b/protocols/Yahoo/src/chat.cpp @@ -10,6 +10,7 @@ * I want to thank Robert Rainwater and George Hazan for their code and support
* and for answering some of my questions during development of this plugin.
*/
+
#include "yahoo.h"
#include "resource.h"
#include <m_protosvc.h>
@@ -53,7 +54,7 @@ void CALLBACK ConferenceRequestCB(PVOID dwParam); void ext_yahoo_got_conf_invite(int id, const char *me, const char *who, const char *room, const char *msg, YList *members)
{
char z[1024];
- mir_snprintf(z, SIZEOF(z), Translate("[miranda] Got conference invite to room: %s with msg: %s"), room ?room:"", msg ?msg:"");
+ mir_snprintf(z, SIZEOF(z), Translate("[miranda] Got conference invite to room: %s with msg: %s"), room ? room : "", msg ? msg : "");
LOG(("[ext_yahoo_got_conf_invite] %s", z));
CYahooProto* ppro = getProtoById(id);
@@ -61,10 +62,8 @@ void ext_yahoo_got_conf_invite(int id, const char *me, const char *who, const ch bool freeList = true;
CYahooProto::ChatRoom *cm = ppro->m_chatrooms.find((CYahooProto::ChatRoom*)&room);
- if (!cm)
- {
- if (mir_strcmp(who, me))
- {
+ if (!cm) {
+ if (mir_strcmp(who, me)) {
cm = new CYahooProto::ChatRoom(room, members);
ppro->m_chatrooms.insert(cm);
@@ -72,8 +71,7 @@ void ext_yahoo_got_conf_invite(int id, const char *me, const char *who, const ch CallFunctionAsync(ConferenceRequestCB, req);
freeList = false;
}
- else
- {
+ else {
cm = new CYahooProto::ChatRoom(room, NULL);
ppro->m_chatrooms.insert(cm);
ppro->ChatStart(room);
@@ -82,8 +80,7 @@ void ext_yahoo_got_conf_invite(int id, const char *me, const char *who, const ch }
}
- if (freeList)
- {
+ if (freeList) {
for (YList *l = members; l; l = l->next) free(l->data);
y_list_free(members);
}
@@ -107,8 +104,7 @@ void ext_yahoo_conf_userjoin(int id, const char *me, const char *who, const char CYahooProto::ChatRoom *cm = ppro->m_chatrooms.find((CYahooProto::ChatRoom*)&room);
if (!cm) return;
- for (YList *l = cm->members; l; l = l->next)
- {
+ for (YList *l = cm->members; l; l = l->next) {
if (!mir_strcmp(who, (char*)l->data))
return;
}
@@ -125,10 +121,8 @@ void ext_yahoo_conf_userleave(int id, const char *me, const char *who, const cha CYahooProto::ChatRoom *cm = ppro->m_chatrooms.find((CYahooProto::ChatRoom*)&room);
if (!cm) return;
- for (YList *l = cm->members; l; l = l->next)
- {
- if (mir_strcmp((char*)l->data, who) == 0)
- {
+ for (YList *l = cm->members; l; l = l->next) {
+ if (mir_strcmp((char*)l->data, who) == 0) {
free(l->data);
y_list_remove_link(cm->members, l);
y_list_free_1(l);
@@ -148,8 +142,7 @@ void ext_yahoo_conf_message(int id, const char *me, const char *who, const char /* chat handlers */
void ext_yahoo_chat_cat_xml(int id, const char *xml)
-{
-}
+{}
void ext_yahoo_chat_join(int id, const char *me, const char *room, const char * topic, YList *members, INT_PTR fd)
{
@@ -158,26 +151,24 @@ void ext_yahoo_chat_join(int id, const char *me, const char *room, const char * }
void ext_yahoo_chat_userjoin(int id, const char *me, const char *room, struct yahoo_chat_member *who)
-{
-}
+{}
void ext_yahoo_chat_userleave(int id, const char *me, const char *room, const char *who)
-{
-}
+{}
+
void ext_yahoo_chat_message(int id, const char *me, const char *who, const char *room, const char *msg, int msgtype, int utf8)
-{
-}
+{}
void ext_yahoo_chat_yahoologout(int id, const char *me)
{
- LOG(("got chat logout"));
+ LOG(("got chat logout"));
}
void ext_yahoo_chat_yahooerror(int id, const char *me)
{
- LOG(("got chat error"));
+ LOG(("got chat error"));
}
-static const COLORREF crCols[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
+static const COLORREF crCols[16] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
void CYahooProto::ChatRegister(void)
{
@@ -215,8 +206,8 @@ void CYahooProto::ChatStart(const char* room) gcd.iType = GC_EVENT_CONTROL;
CallServiceSync(MS_GC_EVENT, SESSION_INITDONE, (LPARAM)&gce);
- CallServiceSync(MS_GC_EVENT, SESSION_ONLINE, (LPARAM)&gce);
- CallServiceSync(MS_GC_EVENT, WINDOW_VISIBLE, (LPARAM)&gce);
+ CallServiceSync(MS_GC_EVENT, SESSION_ONLINE, (LPARAM)&gce);
+ CallServiceSync(MS_GC_EVENT, WINDOW_VISIBLE, (LPARAM)&gce);
mir_free(idt);
}
@@ -265,78 +256,73 @@ void CYahooProto::ChatEvent(const char* room, const char* who, int evt, const TC int __cdecl CYahooProto::OnGCEventHook(WPARAM, LPARAM lParam)
{
- GCHOOK *gch = (GCHOOK*) lParam;
+ GCHOOK *gch = (GCHOOK*)lParam;
if (!gch) return 1;
if (mir_strcmp(gch->pDest->pszModule, m_szModuleName)) return 0;
- char* room = mir_t2a(gch->pDest->ptszID);
- char* who = mir_t2a(gch->ptszUID);
+ char *room = mir_t2a(gch->pDest->ptszID);
+ char *who = mir_t2a(gch->ptszUID);
- switch (gch->pDest->iType)
- {
- case GC_SESSION_TERMINATE:
- {
- ChatRoom *cm = m_chatrooms.find((ChatRoom*)&room);
- if (cm)
- {
- yahoo_conference_logoff(m_id, NULL, cm->members, room);
- m_chatrooms.remove((ChatRoom*)&room);
- }
+ switch (gch->pDest->iType) {
+ case GC_SESSION_TERMINATE:
+ {
+ ChatRoom *cm = m_chatrooms.find((ChatRoom*)&room);
+ if (cm) {
+ yahoo_conference_logoff(m_id, NULL, cm->members, room);
+ m_chatrooms.remove((ChatRoom*)&room);
}
- break;
+ }
+ break;
- case GC_USER_MESSAGE:
- if (gch->ptszText && gch->ptszText[0])
- {
- ChatRoom *cm = m_chatrooms.find((ChatRoom*)&room);
- if (cm)
- yahoo_conference_message(m_id, NULL, cm->members, room, T2Utf(gch->ptszText), 1);
- }
- break;
+ case GC_USER_MESSAGE:
+ if (gch->ptszText && gch->ptszText[0]) {
+ ChatRoom *cm = m_chatrooms.find((ChatRoom*)&room);
+ if (cm)
+ yahoo_conference_message(m_id, NULL, cm->members, room, T2Utf(gch->ptszText), 1);
+ }
+ break;
+
+ case GC_USER_CHANMGR:
+ DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_CHATROOM_INVITE), NULL, InviteToChatDialog,
+ LPARAM(new InviteChatParam(room, this)));
+ break;
- case GC_USER_CHANMGR:
+ case GC_USER_PRIVMESS:
+ CallService(MS_MSG_SENDMESSAGE, (WPARAM)getbuddyH(who), 0);
+ break;
+
+ case GC_USER_LOGMENU:
+ switch (gch->dwData) {
+ case 10:
DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_CHATROOM_INVITE), NULL, InviteToChatDialog,
LPARAM(new InviteChatParam(room, this)));
break;
- case GC_USER_PRIVMESS:
- CallService(MS_MSG_SENDMESSAGE, (WPARAM)getbuddyH(who), 0);
+ case 20:
+ ChatLeave(room);
break;
+ }
+ break;
- case GC_USER_LOGMENU:
- switch(gch->dwData)
- {
- case 10:
- DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_CHATROOM_INVITE), NULL, InviteToChatDialog,
- LPARAM(new InviteChatParam(room, this)));
- break;
-
- case 20:
- ChatLeave(room);
- break;
- }
+ case GC_USER_NICKLISTMENU:
+ switch (gch->dwData) {
+ case 10:
+ CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)getbuddyH(who), 0);
break;
- case GC_USER_NICKLISTMENU:
- switch (gch->dwData)
- {
- case 10:
- CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)getbuddyH(who), 0);
- break;
-
- case 20:
- CallService(MS_HISTORY_SHOWCONTACTHISTORY, (WPARAM)getbuddyH(who), 0);
- break;
-
- case 110:
- ChatLeave(room);
- break;
- }
+ case 20:
+ CallService(MS_HISTORY_SHOWCONTACTHISTORY, (WPARAM)getbuddyH(who), 0);
break;
- case GC_USER_TYPNOTIFY:
+ case 110:
+ ChatLeave(room);
break;
+ }
+ break;
+
+ case GC_USER_TYPNOTIFY:
+ break;
}
mir_free(who);
mir_free(room);
@@ -346,12 +332,11 @@ int __cdecl CYahooProto::OnGCEventHook(WPARAM, LPARAM lParam) int __cdecl CYahooProto::OnGCMenuHook(WPARAM, LPARAM lParam)
{
- GCMENUITEMS *gcmi = (GCMENUITEMS*) lParam;
+ GCMENUITEMS *gcmi = (GCMENUITEMS*)lParam;
if (gcmi == NULL || _stricmp(gcmi->pszModule, m_szModuleName)) return 0;
- if (gcmi->Type == MENU_ON_LOG)
- {
+ if (gcmi->Type == MENU_ON_LOG) {
static const struct gc_item Items[] =
{
{ TranslateT("&Invite user..."), 10, MENU_ITEM, FALSE },
@@ -360,11 +345,9 @@ int __cdecl CYahooProto::OnGCMenuHook(WPARAM, LPARAM lParam) gcmi->nItems = SIZEOF(Items);
gcmi->Item = (gc_item*)Items;
}
- else if (gcmi->Type == MENU_ON_NICKLIST)
- {
+ else if (gcmi->Type == MENU_ON_NICKLIST) {
char* id = mir_t2a(gcmi->pszUID);
- if (!_stricmp(m_yahoo_id, id))
- {
+ if (!_stricmp(m_yahoo_id, id)) {
static const struct gc_item Items[] =
{
{ TranslateT("User &details"), 10, MENU_ITEM, FALSE },
@@ -375,8 +358,7 @@ int __cdecl CYahooProto::OnGCMenuHook(WPARAM, LPARAM lParam) gcmi->nItems = SIZEOF(Items);
gcmi->Item = (gc_item*)Items;
}
- else
- {
+ else {
static const struct gc_item Items[] =
{
{ TranslateT("User &details"), 10, MENU_ITEM, FALSE },
@@ -400,28 +382,22 @@ static void clist_chat_invite_send(MCONTACT hItem, HWND hwndList, YList* &who, c if (root)
hItem = (MCONTACT)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_ROOT, 0);
- while (hItem)
- {
- if (IsHContactGroup(hItem))
- {
+ while (hItem) {
+ if (IsHContactGroup(hItem)) {
MCONTACT hItemT = (MCONTACT)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem);
if (hItemT)
clist_chat_invite_send(hItemT, hwndList, who, room, ppro, msg);
}
- else
- {
+ else {
int chk = SendMessage(hwndList, CLM_GETCHECKMARK, (WPARAM)hItem, 0);
- if (chk)
- {
- if (IsHContactInfo(hItem))
- {
+ if (chk) {
+ if (IsHContactInfo(hItem)) {
TCHAR buf[128] = _T("");
SendMessage(hwndList, CLM_GETITEMTEXT, (WPARAM)hItem, (LPARAM)buf);
who = y_list_append(who, mir_t2a(buf));
}
- else
- {
+ else {
DBVARIANT dbv;
if (!ppro->getString(hItem, YAHOO_LOGINID, &dbv))
who = y_list_append(who, dbv.pszVal);
@@ -431,8 +407,7 @@ static void clist_chat_invite_send(MCONTACT hItem, HWND hwndList, YList* &who, c hItem = (MCONTACT)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXT, (LPARAM)hItem);
}
- if (root && who)
- {
+ if (root && who) {
T2Utf msg8(msg);
CYahooProto::ChatRoom *cm = ppro->m_chatrooms.find((CYahooProto::ChatRoom*)&room);
if (cm) {
@@ -470,15 +445,14 @@ static void ClistChatPrepare(MCONTACT hItem, HWND hwndList, CYahooProto* ppro) ClistValidateContact(hItem, hwndList, ppro);
hItem = hItemN;
- }
+ }
}
INT_PTR CALLBACK InviteToChatDialog(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
InviteChatParam* param = (InviteChatParam*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- switch (msg)
- {
+ switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
@@ -503,37 +477,33 @@ INT_PTR CALLBACK InviteToChatDialog(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA break;
case WM_NOTIFY:
- {
- NMCLISTCONTROL* nmc = (NMCLISTCONTROL*)lParam;
- if (nmc->hdr.idFrom == IDC_CCLIST)
{
- switch (nmc->hdr.code)
- {
- case CLN_NEWCONTACT:
- if (param && (nmc->flags & (CLNF_ISGROUP | CLNF_ISINFO)) == 0)
- ClistValidateContact((MCONTACT)nmc->hItem, nmc->hdr.hwndFrom, param->ppro);
- break;
-
- case CLN_LISTREBUILT:
- if (param)
- ClistChatPrepare(NULL, nmc->hdr.hwndFrom, param->ppro);
- break;
+ NMCLISTCONTROL* nmc = (NMCLISTCONTROL*)lParam;
+ if (nmc->hdr.idFrom == IDC_CCLIST) {
+ switch (nmc->hdr.code) {
+ case CLN_NEWCONTACT:
+ if (param && (nmc->flags & (CLNF_ISGROUP | CLNF_ISINFO)) == 0)
+ ClistValidateContact((MCONTACT)nmc->hItem, nmc->hdr.hwndFrom, param->ppro);
+ break;
+
+ case CLN_LISTREBUILT:
+ if (param)
+ ClistChatPrepare(NULL, nmc->hdr.hwndFrom, param->ppro);
+ break;
+ }
}
}
- }
- break;
+ break;
case WM_COMMAND:
{
- switch (LOWORD(wParam))
- {
+ switch (LOWORD(wParam)) {
case IDC_ADDSCR:
- if (param->ppro->m_bLoggedIn)
- {
+ if (param->ppro->m_bLoggedIn) {
TCHAR sn[64];
GetDlgItemText(hwndDlg, IDC_EDITSCR, sn, SIZEOF(sn));
- CLCINFOITEM cii = {0};
+ CLCINFOITEM cii = { 0 };
cii.cbSize = sizeof(cii);
cii.flags = CLCIIF_CHECKBOX | CLCIIF_BELOWCONTACTS;
cii.pszText = sn;
@@ -575,8 +545,7 @@ INT_PTR CALLBACK ChatRequestDialog(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM {
InviteChatReqParam* param = (InviteChatReqParam*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- switch (msg)
- {
+ switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
@@ -604,11 +573,9 @@ INT_PTR CALLBACK ChatRequestDialog(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM case WM_COMMAND:
{
CYahooProto::ChatRoom *cm = param->ppro->m_chatrooms.find((CYahooProto::ChatRoom*)¶m->room);
- switch (LOWORD(wParam))
- {
+ switch (LOWORD(wParam)) {
case IDOK:
- if (cm)
- {
+ if (cm) {
param->ppro->ChatStart(param->room);
for (YList *l = cm->members; l; l = l->next)
@@ -620,8 +587,7 @@ INT_PTR CALLBACK ChatRequestDialog(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM break;
case IDCANCEL:
- if (cm)
- {
+ if (cm) {
TCHAR msg[1024];
GetDlgItemText(hwndDlg, IDC_MSG2, msg, SIZEOF(msg));
yahoo_conference_decline(param->ppro->m_id, NULL, cm->members, param->room, T2Utf(msg));
@@ -640,7 +606,7 @@ INT_PTR CALLBACK ChatRequestDialog(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM static void CALLBACK ConferenceRequestCB(PVOID pParam)
{
CreateDialogParam(hInstance, MAKEINTRESOURCE(IDD_CHATROOM_INVITE_REQ),
- NULL, ChatRequestDialog, (LPARAM)pParam);
+ NULL, ChatRequestDialog, (LPARAM)pParam);
}
INT_PTR __cdecl CYahooProto::CreateConference(WPARAM /*wParam*/, LPARAM /*lParam*/)
diff --git a/protocols/Yahoo/src/file_transfer.cpp b/protocols/Yahoo/src/file_transfer.cpp index f49661869c..fc6a6ae290 100644 --- a/protocols/Yahoo/src/file_transfer.cpp +++ b/protocols/Yahoo/src/file_transfer.cpp @@ -19,14 +19,14 @@ YList *file_transfers=NULL;
-static y_filetransfer* new_ft(CYahooProto* ppro, int id, MCONTACT hContact, const char *who, const char *msg,
- const char *url, const char *ft_token, int y7, YList *fs, int sending)
+static y_filetransfer* new_ft(CYahooProto* ppro, int id, MCONTACT hContact, const char *who, const char *msg,
+ const char *url, const char *ft_token, int y7, YList *fs, int sending)
{
LOG(("[new_ft] id: %d, who: %s, msg: %s, ft_token: %s, y7: %d, sending: %d", id, who, msg, ft_token, y7, sending));
- y_filetransfer* ft = (y_filetransfer*) calloc(1, sizeof(y_filetransfer));
+ y_filetransfer* ft = (y_filetransfer*)calloc(1, sizeof(y_filetransfer));
ft->ppro = ppro;
- ft->id = id;
+ ft->id = id;
ft->who = strdup(who);
ft->hWaitEvent = INVALID_HANDLE_VALUE;
@@ -39,25 +39,25 @@ static y_filetransfer* new_ft(CYahooProto* ppro, int id, MCONTACT hContact, cons ft->cancel = 0;
ft->y7 = y7;
-
+
ft->hWaitEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
ft->pfts.cbSize = sizeof(PROTOFILETRANSFERSTATUS);
ft->pfts.hContact = hContact;
- ft->pfts.flags = PFTS_TCHAR;
+ ft->pfts.flags = PFTS_TCHAR;
ft->pfts.flags |= (sending != 0) ? PFTS_SENDING : PFTS_RECEIVING;
-
+
ft->pfts.tszWorkingDir = NULL;
ft->pfts.currentFileTime = 0;
ft->pfts.totalFiles = y_list_length(fs);
- ft->pfts.ptszFiles = (TCHAR**) mir_calloc(ft->pfts.totalFiles * sizeof(TCHAR *));
+ ft->pfts.ptszFiles = (TCHAR**)mir_calloc(ft->pfts.totalFiles * sizeof(TCHAR *));
ft->pfts.totalBytes = 0;
-
- int i=0;
- for(YList *l=fs; l; l=l->next) {
- yahoo_file_info *fi = ( yahoo_file_info* )l->data;
+
+ int i = 0;
+ for (YList *l = fs; l; l = l->next) {
+ yahoo_file_info *fi = (yahoo_file_info*)l->data;
ft->pfts.ptszFiles[i++] = mir_utf8decodeT(fi->filename);
ft->pfts.totalBytes += fi->filesize;
@@ -65,23 +65,23 @@ static y_filetransfer* new_ft(CYahooProto* ppro, int id, MCONTACT hContact, cons ft->pfts.currentFileNumber = 0;
- yahoo_file_info *fi = ( yahoo_file_info* )fs->data;
+ yahoo_file_info *fi = (yahoo_file_info*)fs->data;
ft->pfts.tszCurrentFile = _tcsdup(ft->pfts.ptszFiles[ft->pfts.currentFileNumber]);
- ft->pfts.currentFileSize = fi->filesize;
+ ft->pfts.currentFileSize = fi->filesize;
file_transfers = y_list_prepend(file_transfers, ft);
LOG(("[/new_ft]"));
-
+
return ft;
}
-y_filetransfer* find_ft(const char *ft_token, const char *who)
+y_filetransfer* find_ft(const char *ft_token, const char *who)
{
LOG(("[find_ft] Searching for: %s", ft_token));
-
- for(YList *l = file_transfers; l; l = y_list_next(l)) {
- y_filetransfer *f = (y_filetransfer* )l->data;
+
+ for (YList *l = file_transfers; l; l = y_list_next(l)) {
+ y_filetransfer *f = (y_filetransfer*)l->data;
if (mir_strcmp(f->ftoken, ft_token) == 0 && mir_strcmp(f->who, who) == 0) {
LOG(("[find_ft] Got it!"));
return f;
@@ -95,8 +95,8 @@ y_filetransfer* find_ft(const char *ft_token, const char *who) static void free_ft(y_filetransfer *ft)
{
LOG(("[free_ft] token: %s", ft->ftoken));
-
- for(YList *l = file_transfers; l; l = y_list_next(l)) {
+
+ for (YList *l = file_transfers; l; l = y_list_next(l)) {
if (l->data == ft) {
LOG(("[free_ft] Ft found and removed from the list"));
file_transfers = y_list_remove_link(file_transfers, l);
@@ -105,42 +105,42 @@ static void free_ft(y_filetransfer *ft) }
}
- if ( ft->hWaitEvent != INVALID_HANDLE_VALUE )
- CloseHandle( ft->hWaitEvent );
-
+ if (ft->hWaitEvent != INVALID_HANDLE_VALUE)
+ CloseHandle(ft->hWaitEvent);
+
FREE(ft->who);
FREE(ft->msg);
FREE(ft->url);
FREE(ft->ftoken);
FREE(ft->relay);
-
+
LOG(("[free_ft] About to free the File List."));
-
- while(ft->files) {
+
+ while (ft->files) {
YList *tmp = ft->files;
- yahoo_file_info * c = ( yahoo_file_info* )ft->files->data;
+ yahoo_file_info * c = (yahoo_file_info*)ft->files->data;
FREE(c->filename);
FREE(c);
ft->files = y_list_remove_link(ft->files, ft->files);
y_list_free_1(tmp);
}
-
+
LOG(("[free_ft] About to free PFTS."));
-
- for (int i=0; i< ft->pfts.totalFiles; i++)
+
+ for (int i = 0; i < ft->pfts.totalFiles; i++)
mir_free(ft->pfts.ptszFiles[i]);
-
+
mir_free(ft->pfts.ptszFiles);
FREE(ft->pfts.tszCurrentFile);
FREE(ft->pfts.tszWorkingDir);
FREE(ft);
-
+
LOG(("[/free_ft]"));
}
-static void upload_file(int id, INT_PTR fd, int error, void *data)
+static void upload_file(int id, INT_PTR fd, int error, void *data)
{
- y_filetransfer *sf = (y_filetransfer*) data;
+ y_filetransfer *sf = (y_filetransfer*)data;
struct yahoo_file_info *fi = (struct yahoo_file_info *)sf->files->data;
char buf[1024];
unsigned long size = 0;
@@ -155,13 +155,13 @@ static void upload_file(int id, INT_PTR fd, int error, void *data) if (!error) {
HANDLE myhFile = CreateFile(sf->pfts.tszCurrentFile,
GENERIC_READ,
- FILE_SHARE_READ|FILE_SHARE_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN,
0);
- if (myhFile !=INVALID_HANDLE_VALUE) {
+ if (myhFile != INVALID_HANDLE_VALUE) {
DWORD lNotify = GetTickCount();
LOG(("proto: %s, hContact: %p", sf->ppro->m_szModuleName, sf->hContact));
@@ -179,7 +179,8 @@ static void upload_file(int id, INT_PTR fd, int error, void *data) LOG(("Upload Failed. Send error? Got: %d", rw));
error = 1;
break;
- } else
+ }
+ else
size += rw;
if (GetTickCount() >= lNotify + 500 || rw < 1024 || size == fi->filesize) {
@@ -187,7 +188,7 @@ static void upload_file(int id, INT_PTR fd, int error, void *data) sf->pfts.totalProgress = size;
sf->pfts.currentFileProgress = size;
- ProtoBroadcastAck(sf->ppro->m_szModuleName, sf->hContact, ACKTYPE_FILE, ACKRESULT_DATA, sf, (LPARAM) & sf->pfts);
+ ProtoBroadcastAck(sf->ppro->m_szModuleName, sf->hContact, ACKTYPE_FILE, ACKRESULT_DATA, sf, (LPARAM)& sf->pfts);
lNotify = GetTickCount();
}
@@ -198,17 +199,17 @@ static void upload_file(int id, INT_PTR fd, int error, void *data) error = 1;
break;
}
- } while ( rw > 0 && dw > 0 && !error);
+ } while (rw > 0 && dw > 0 && !error);
CloseHandle(myhFile);
sf->pfts.totalProgress = size;
sf->pfts.currentFileProgress = size;
- ProtoBroadcastAck(sf->ppro->m_szModuleName, sf->hContact, ACKTYPE_FILE, ACKRESULT_DATA, sf, (LPARAM) & sf->pfts);
+ ProtoBroadcastAck(sf->ppro->m_szModuleName, sf->hContact, ACKTYPE_FILE, ACKRESULT_DATA, sf, (LPARAM)& sf->pfts);
}
- }
+ }
if (fd > 0) {
int tr = 0;
@@ -223,11 +224,11 @@ static void upload_file(int id, INT_PTR fd, int error, void *data) if (rw > 12) {
if (buf[9] != '2' || buf[10] != '0' || buf[11] != '0') {
LOG(("File Transfer Failed: %c%c%c", buf[9], buf[10], buf[11]));
- error=1;
+ error = 1;
}
}
}
- tr +=rw;
+ tr += rw;
} while (rw > 0);
Netlib_CloseHandle((HANDLE)fd);
@@ -235,62 +236,64 @@ static void upload_file(int id, INT_PTR fd, int error, void *data) LOG(("File send complete!"));
- if (! error) {
+ if (!error) {
sf->pfts.currentFileNumber++;
if (sf->pfts.currentFileNumber >= sf->pfts.totalFiles) {
ProtoBroadcastAck(sf->ppro->m_szModuleName, sf->hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, sf, 0);
- } else {
+ }
+ else {
// Do Next file
FREE(sf->pfts.tszCurrentFile);
-
+
YList *l = sf->files;
-
- fi = ( yahoo_file_info* )l->data;
+
+ fi = (yahoo_file_info*)l->data;
FREE(fi->filename);
FREE(fi);
-
+
sf->files = y_list_remove_link(sf->files, l);
y_list_free_1(l);
-
+
// need to move to the next file on the list and fill the file information
- struct yahoo_file_info *fi = ( yahoo_file_info* )sf->files->data;
+ struct yahoo_file_info *fi = (yahoo_file_info*)sf->files->data;
sf->pfts.tszCurrentFile = _tcsdup(sf->pfts.ptszFiles[sf->pfts.currentFileNumber]);
- sf->pfts.currentFileSize = fi->filesize;
+ sf->pfts.currentFileSize = fi->filesize;
sf->pfts.currentFileProgress = 0;
-
+
ProtoBroadcastAck(sf->ppro->m_szModuleName, sf->hContact, ACKTYPE_FILE, ACKRESULT_NEXTFILE, sf, 0);
LOG(("Waiting for next file request packet..."));
}
- } else {
+ }
+ else {
ProtoBroadcastAck(sf->ppro->m_szModuleName, sf->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, sf, 0);
}
}
-static void dl_file(int id, INT_PTR fd, int error, const char *filename, unsigned long size, void *data)
+static void dl_file(int id, INT_PTR fd, int error, const char *filename, unsigned long size, void *data)
{
- y_filetransfer *sf = (y_filetransfer*) data;
+ y_filetransfer *sf = (y_filetransfer*)data;
struct yahoo_file_info *fi = (struct yahoo_file_info *)sf->files->data;
- char buf[1024];
- unsigned long rsize = 0;
+ char buf[1024];
+ unsigned long rsize = 0;
DWORD dw, c;
if (fd < 0) {
LOG(("[get_url] Connect Failed!"));
-
+
if (sf->ftoken != NULL) {
LOG(("[get_url] DC Detected: asking sender to upload to Yahoo FileServers!"));
- yahoo_ftdc_deny(id, sf->who, fi->filename, sf->ftoken, 3);
+ yahoo_ftdc_deny(id, sf->who, fi->filename, sf->ftoken, 3);
}
-
+
error = 1;
}
-
- if (!error) {
+
+ if (!error) {
HANDLE myhFile;
TCHAR filefull[MAX_PATH];
-
+
/*
* We need FULL Path for File Resume to work properly!!!
*
@@ -298,141 +301,145 @@ static void dl_file(int id, INT_PTR fd, int error, const char *filename, unsigne */
mir_sntprintf(filefull, SIZEOF(filefull), _T("%s\\%s"), sf->pfts.tszWorkingDir, sf->pfts.tszCurrentFile);
FREE(sf->pfts.tszCurrentFile);
- sf->pfts.tszCurrentFile = _tcsdup(filefull);
-
+ sf->pfts.tszCurrentFile = _tcsdup(filefull);
+
ResetEvent(sf->hWaitEvent);
-
- if ( sf->ppro->ProtoBroadcastAck( sf->hContact, ACKTYPE_FILE, ACKRESULT_FILERESUME, sf, (LPARAM)&sf->pfts )) {
- WaitForSingleObject( sf->hWaitEvent, INFINITE );
-
- LOG(("[dl_file] Got action: %ld", sf->action));
-
- switch(sf->action) {
- case FILERESUME_RENAME:
- case FILERESUME_OVERWRITE:
- case FILERESUME_RESUME:
- // no action needed at this point, just break out of the switch statement
- break;
- case FILERESUME_CANCEL :
- sf->cancel = 1;
- break;
+ if (sf->ppro->ProtoBroadcastAck(sf->hContact, ACKTYPE_FILE, ACKRESULT_FILERESUME, sf, (LPARAM)&sf->pfts)) {
+ WaitForSingleObject(sf->hWaitEvent, INFINITE);
- case FILERESUME_SKIP :
- default:
- sf->cancel = 2;
- break;
- }
+ LOG(("[dl_file] Got action: %ld", sf->action));
+
+ switch (sf->action) {
+ case FILERESUME_RENAME:
+ case FILERESUME_OVERWRITE:
+ case FILERESUME_RESUME:
+ // no action needed at this point, just break out of the switch statement
+ break;
+
+ case FILERESUME_CANCEL:
+ sf->cancel = 1;
+ break;
+
+ case FILERESUME_SKIP:
+ default:
+ sf->cancel = 2;
+ break;
+ }
}
-
-
- if (! sf->cancel) {
-
- myhFile = CreateFile(sf->pfts.tszCurrentFile,
- GENERIC_WRITE,
- FILE_SHARE_WRITE,
- NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
-
- if (myhFile !=INVALID_HANDLE_VALUE) {
+
+
+ if (!sf->cancel) {
+
+ myhFile = CreateFile(sf->pfts.tszCurrentFile,
+ GENERIC_WRITE,
+ FILE_SHARE_WRITE,
+ NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
+
+ if (myhFile != INVALID_HANDLE_VALUE) {
DWORD lNotify = GetTickCount();
-
+
SetEndOfFile(myhFile);
-
+
LOG(("proto: %s, hContact: %p", sf->ppro->m_szModuleName, sf->hContact));
-
+
ProtoBroadcastAck(sf->ppro->m_szModuleName, sf->hContact, ACKTYPE_FILE, ACKRESULT_CONNECTED, sf, 0);
-
+
do {
dw = Netlib_Recv((HANDLE)fd, buf, 1024, MSG_NODUMP);
-
+
if (dw > 0) {
WriteFile(myhFile, buf, dw, &c, NULL);
rsize += dw;
sf->pfts.totalProgress += dw;
sf->pfts.currentFileProgress += dw;
-
+
if (GetTickCount() >= lNotify + 500 || dw <= 0 || rsize == size) {
-
+
LOG(("DOING UI Notify. Got %lu/%lu", rsize, size));
-
- ProtoBroadcastAck(sf->ppro->m_szModuleName, sf->hContact, ACKTYPE_FILE, ACKRESULT_DATA, sf, (LPARAM) & sf->pfts);
+
+ ProtoBroadcastAck(sf->ppro->m_szModuleName, sf->hContact, ACKTYPE_FILE, ACKRESULT_DATA, sf, (LPARAM)& sf->pfts);
lNotify = GetTickCount();
}
-
- } else {
+
+ }
+ else {
LOG(("Recv Failed! Socket Error?"));
error = 1;
break;
}
-
+
if (sf->cancel) {
LOG(("Recv Cancelled! "));
error = 1;
break;
}
- } while ( dw > 0 && rsize < size);
-
- while (dw > 0 && ! sf->cancel && ! error) {
+ } while (dw > 0 && rsize < size);
+
+ while (dw > 0 && !sf->cancel && !error) {
dw = Netlib_Recv((HANDLE)fd, buf, 1024, MSG_NODUMP);
LOG(("Ack."));
}
-
- ProtoBroadcastAck(sf->ppro->m_szModuleName, sf->hContact, ACKTYPE_FILE, ACKRESULT_DATA, sf, (LPARAM) & sf->pfts);
-
+
+ ProtoBroadcastAck(sf->ppro->m_szModuleName, sf->hContact, ACKTYPE_FILE, ACKRESULT_DATA, sf, (LPARAM)& sf->pfts);
+
LOG(("[Finished DL] Got %lu/%lu", rsize, size));
CloseHandle(myhFile);
-
- } else {
+
+ }
+ else {
LOG(("Can not open file for writing: %s", buf));
error = 1;
}
-
- }
- }
-
+
+ }
+ }
+
if (fd > 0) {
LOG(("Closing connection: %d", fd));
Netlib_CloseHandle((HANDLE)fd);
-
+
if (sf->cancel || error) {
/* abort FT transfer */
yahoo_ft7dc_abort(id, sf->who, sf->ftoken);
}
}
-
- if (! error) {
+
+ if (!error) {
sf->pfts.currentFileNumber++;
-
+
LOG(("File %d/%d download complete!", sf->pfts.currentFileNumber, sf->pfts.totalFiles));
-
+
if (sf->pfts.currentFileNumber >= sf->pfts.totalFiles) {
ProtoBroadcastAck(sf->ppro->m_szModuleName, sf->hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, sf, 0);
- } else {
+ }
+ else {
// Do Next file
yahoo_ft7dc_nextfile(id, sf->who, sf->ftoken);
FREE(sf->pfts.tszCurrentFile);
-
+
YList *l = sf->files;
-
- fi = ( yahoo_file_info* )l->data;
+
+ fi = (yahoo_file_info*)l->data;
FREE(fi->filename);
FREE(fi);
-
+
sf->files = y_list_remove_link(sf->files, l);
y_list_free_1(l);
-
+
// need to move to the next file on the list and fill the file information
- struct yahoo_file_info *fi = ( yahoo_file_info* )sf->files->data;
+ struct yahoo_file_info *fi = (yahoo_file_info*)sf->files->data;
sf->pfts.tszCurrentFile = _tcsdup(sf->pfts.ptszFiles[sf->pfts.currentFileNumber]);
- sf->pfts.currentFileSize = fi->filesize;
+ sf->pfts.currentFileSize = fi->filesize;
sf->pfts.currentFileProgress = 0;
-
+
ProtoBroadcastAck(sf->ppro->m_szModuleName, sf->hContact, ACKTYPE_FILE, ACKRESULT_NEXTFILE, sf, 0);
}
- } else {
+ }
+ else {
LOG(("File download failed!"));
-
+
ProtoBroadcastAck(sf->ppro->m_szModuleName, sf->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, sf, 0);
}
}
@@ -440,18 +447,18 @@ static void dl_file(int id, INT_PTR fd, int error, const char *filename, unsigne //=======================================================
//File Transfer
//=======================================================
-void __cdecl CYahooProto::recv_filethread(void *psf)
+void __cdecl CYahooProto::recv_filethread(void *psf)
{
- y_filetransfer *sf = ( y_filetransfer* )psf;
+ y_filetransfer *sf = (y_filetransfer*)psf;
struct yahoo_file_info *fi = (struct yahoo_file_info *)sf->files->data;
-
+
ProtoBroadcastAck(sf->hContact, ACKTYPE_FILE, ACKRESULT_CONNECTING, sf, 0);
-
+
debugLogA("[yahoo_recv_filethread] who: %s, msg: %s, filename: %s ", sf->who, sf->msg, fi->filename);
-
-
+
+
yahoo_get_url_handle(m_id, sf->url, &dl_file, sf);
-
+
if (sf->pfts.currentFileNumber >= sf->pfts.totalFiles)
free_ft(sf);
else
@@ -463,7 +470,7 @@ void CYahooProto::ext_got_file(const char *me, const char *who, const char *url, LOG(("[ext_yahoo_got_file] ident:%s, who: %s, url: %s, expires: %lu, msg: %s, fname: %s, fsize: %lu ftoken: %s y7: %d", me, who, url, expires, msg, fname, fesize, ft_token == NULL ? "NULL" : ft_token, y7));
MCONTACT hContact = getbuddyH(who);
- if (hContact == NULL)
+ if (hContact == NULL)
hContact = add_buddy(who, who, 0 /* NO FT for other IMs */, PALF_TEMPORARY);
char fn[1024];
@@ -475,25 +482,26 @@ void CYahooProto::ext_got_file(const char *me, const char *who, const char *url, char *start, *end;
/* based on how gaim does this */
- start = ( char* )strrchr(url, '/');
+ start = (char*)strrchr(url, '/');
if (start)
start++;
- end = ( char* )strrchr(url, '?');
+ end = (char*)strrchr(url, '?');
if (start && *start && end) {
- mir_strncpy(fn, start, end-start+1);
- } else
+ mir_strncpy(fn, start, end - start + 1);
+ }
+ else
mir_strcpy(fn, "filename.ext");
}
- yahoo_file_info *fi = y_new(struct yahoo_file_info,1);
+ yahoo_file_info *fi = y_new(struct yahoo_file_info, 1);
fi->filename = strdup(fn);
fi->filesize = fesize;
YList *files = y_list_append(NULL, fi);
- y_filetransfer *ft = new_ft(this, m_id, hContact, who, msg, url, ft_token, y7, files, 0 /* downloading */);
+ y_filetransfer *ft = new_ft(this, m_id, hContact, who, msg, url, ft_token, y7, files, 0 /* downloading */);
if (ft == NULL) {
y_list_free(files);
debugLogA("SF IS NULL!!!");
@@ -502,7 +510,7 @@ void CYahooProto::ext_got_file(const char *me, const char *who, const char *url, TCHAR* ptszFileName = mir_a2t(fn);
- PROTORECVFILET pre = {0};
+ PROTORECVFILET pre = { 0 };
pre.dwFlags = PRFF_TCHAR;
pre.fileCount = 1;
pre.timestamp = time(NULL);
@@ -523,7 +531,7 @@ void CYahooProto::ext_got_files(const char *me, const char *who, const char *ft_ LOG(("[ext_yahoo_got_files] ident:%s, who: %s, ftoken: %s ", me, who, ft_token == NULL ? "NULL" : ft_token));
MCONTACT hContact = getbuddyH(who);
- if (hContact == NULL)
+ if (hContact == NULL)
hContact = add_buddy(who, who, 0 /* NO FT for other IMs */, PALF_TEMPORARY);
y_filetransfer *ft = new_ft(this, m_id, hContact, who, NULL, NULL, ft_token, y7, files, 0 /* downloading */);
@@ -533,7 +541,7 @@ void CYahooProto::ext_got_files(const char *me, const char *who, const char *ft_ }
fn[0] = '\0';
- for (YList *f=files; f; f = y_list_next(f)) {
+ for (YList *f = files; f; f = y_list_next(f)) {
char z[1024];
struct yahoo_file_info *fi = (struct yahoo_file_info *) f->data;
@@ -547,7 +555,7 @@ void CYahooProto::ext_got_files(const char *me, const char *who, const char *ft_ }
- PROTORECVFILET pre = {0};
+ PROTORECVFILET pre = { 0 };
pre.fileCount = 1;
pre.timestamp = time(NULL);
pre.descr.a = "";
@@ -559,55 +567,57 @@ void CYahooProto::ext_got_files(const char *me, const char *who, const char *ft_ void CYahooProto::ext_got_file7info(const char *me, const char *who, const char *url, const char *fname, const char *ft_token)
{
LOG(("[ext_yahoo_got_file7info] ident:%s, who: %s, url: %s, fname: %s, ft_token: %s", me, who, url, fname, ft_token));
-
+
y_filetransfer *ft = find_ft(ft_token, who);
-
+
if (ft == NULL) {
LOG(("ERROR: Can't find the token: %s in my file transfers list...", ft_token));
return;
}
-
- ProtoBroadcastAck(ft->hContact, ACKTYPE_GETINFO, ACKRESULT_SUCCESS, (HANDLE) 1, 0);
-
+
+ ProtoBroadcastAck(ft->hContact, ACKTYPE_GETINFO, ACKRESULT_SUCCESS, (HANDLE)1, 0);
+
FREE(ft->url);
-
+
ft->url = strdup(url);
-
+
ForkThread(&CYahooProto::recv_filethread, ft);
}
void ext_yahoo_send_file7info(int id, const char *me, const char *who, const char *ft_token)
{
LOG(("[ext_yahoo_send_file7info] id: %i, ident:%s, who: %s, ft_token: %s", id, me, who, ft_token));
-
+
y_filetransfer *ft = find_ft(ft_token, who);
-
+
if (ft == NULL) {
LOG(("ERROR: Can't find the token: %s in my file transfers list...", ft_token));
return;
}
-
- yahoo_file_info *fi = (yahoo_file_info *) ft->files->data;
-
+
+ yahoo_file_info *fi = (yahoo_file_info *)ft->files->data;
+
char *c = strrchr(fi->filename, '\\');
if (c != NULL) {
c++;
- } else {
+ }
+ else {
c = fi->filename;
}
-
+
LOG(("Resolving relay.msg.yahoo.com..."));
PHOSTENT he = gethostbyname("relay.msg.yahoo.com");
-
+
if (he) {
- ft->relay = strdup( inet_ntoa(*( PIN_ADDR )he->h_addr_list[0]));
+ ft->relay = strdup(inet_ntoa(*(PIN_ADDR)he->h_addr_list[0]));
LOG(("Got Relay IP: %s", ft->relay));
- } else {
+ }
+ else {
ft->relay = strdup("98.136.112.33");
LOG(("DNS Lookup failed. Using Relay IP: %s", ft->relay));
}
-
- yahoo_send_file7info(id, me, who, ft_token, c, ft->relay );
+
+ yahoo_send_file7info(id, me, who, ft_token, c, ft->relay);
}
struct _sfs{
@@ -619,44 +629,45 @@ struct _sfs{ void CYahooProto::ext_ft7_send_file(const char *me, const char *who, const char *filename, const char *token, const char *ft_token)
{
LOG(("[ext_yahoo_send_file7info] ident:%s, who: %s, ft_token: %s", me, who, ft_token));
-
+
y_filetransfer *sf = find_ft(ft_token, who);
-
+
if (sf == NULL) {
LOG(("ERROR: Can't find the token: %s in my file transfers list...", ft_token));
return;
}
- struct _sfs *s = (struct _sfs *) malloc( sizeof( struct _sfs ));
-
+ struct _sfs *s = (struct _sfs *) malloc(sizeof(struct _sfs));
+
s->me = strdup(me);
s->token = strdup(token);
s->sf = sf;
-
+
ForkThread(&CYahooProto::send_filethread, s);
}
/**************** Send File ********************/
-void __cdecl CYahooProto::send_filethread(void *psf)
+void __cdecl CYahooProto::send_filethread(void *psf)
{
- struct _sfs *s = ( struct _sfs * )psf;
+ struct _sfs *s = (struct _sfs *)psf;
y_filetransfer *sf = s->sf;
struct yahoo_file_info *fi = (struct yahoo_file_info *)sf->files->data;
-
+
ProtoBroadcastAck(sf->hContact, ACKTYPE_FILE, ACKRESULT_CONNECTING, sf, 0);
-
+
LOG(("who %s, msg: %s, filename: %s filesize: %ld", sf->who, sf->msg, fi->filename, fi->filesize));
-
- yahoo_send_file_y7(sf->id, s->me, sf->who, sf->relay, fi->filesize, s->token, &upload_file, sf);
-
+
+ yahoo_send_file_y7(sf->id, s->me, sf->who, sf->relay, fi->filesize, s->token, &upload_file, sf);
+
FREE(s->me);
FREE(s->token);
FREE(s);
-
+
if (sf->pfts.currentFileNumber >= sf->pfts.totalFiles) {
free_ft(sf);
- } else {
+ }
+ else {
debugLogA("[yahoo_send_filethread] More files coming?");
}
}
@@ -668,50 +679,50 @@ void __cdecl CYahooProto::send_filethread(void *psf) HANDLE __cdecl CYahooProto::SendFile(MCONTACT hContact, const TCHAR *szDescription, TCHAR **ppszFiles)
{
LOG(("[YahooSendFile]"));
-
- if ( !m_bLoggedIn )
+
+ if (!m_bLoggedIn)
return 0;
DBVARIANT dbv;
if (!getString(hContact, YAHOO_LOGINID, &dbv)) {
long tFileSize = 0;
struct _stat statbuf;
- YList *fs=NULL;
-
- int i=0;
- for (;ppszFiles[i] != NULL;i++) {
- if ( _tstat( ppszFiles[i], &statbuf ) == 0)
+ YList *fs = NULL;
+
+ int i = 0;
+ for (; ppszFiles[i] != NULL; i++) {
+ if (_tstat(ppszFiles[i], &statbuf) == 0)
tFileSize = statbuf.st_size;
-
- struct yahoo_file_info *fi = y_new(struct yahoo_file_info,1);
-
+
+ struct yahoo_file_info *fi = y_new(struct yahoo_file_info, 1);
+
fi->filename = strdup(T2Utf(ppszFiles[i]));
fi->filesize = tFileSize;
-
+
fs = y_list_append(fs, fi);
}
-
- y_filetransfer *sf = new_ft(this, m_id, hContact, dbv.pszVal, ( char* )szDescription,
- NULL, NULL, 0, fs, 1 /* sending */);
-
+
+ y_filetransfer *sf = new_ft(this, m_id, hContact, dbv.pszVal, (char*)szDescription,
+ NULL, NULL, 0, fs, 1 /* sending */);
+
db_free(&dbv);
-
+
if (sf == NULL) {
debugLogA("SF IS NULL!!!");
return 0;
}
LOG(("who: %s, msg: %s, # files: %d", sf->who, sf->msg, i));
-
- sf->ftoken=yahoo_ft7dc_send(m_id, sf->who, fs);
-
+
+ sf->ftoken = yahoo_ft7dc_send(m_id, sf->who, fs);
+
LOG(("Exiting SendRequest..."));
-
+
return sf;
}
-
+
LOG(("[/YahooSendFile]"));
-
+
return 0;
}
@@ -725,12 +736,12 @@ HANDLE __cdecl CYahooProto::FileAllow(MCONTACT hContact, HANDLE hTransfer, const debugLogA("[YahooFileAllow]");
//LOG(LOG_INFO, "[%s] Requesting file from %s", ft->cookie, ft->user);
- ft->pfts.tszWorkingDir = _tcsdup( szPath );
+ ft->pfts.tszWorkingDir = _tcsdup(szPath);
size_t len = mir_tstrlen(ft->pfts.tszWorkingDir) - 1;
if (ft->pfts.tszWorkingDir[len] == '\\')
ft->pfts.tszWorkingDir[len] = 0;
-
+
if (ft->y7) {
debugLogA("[YahooFileAllow] Trying to relay Y7 transfer.");
//void yahoo_ft7dc_accept(int id, const char *buddy, const char *ft_token);
@@ -751,18 +762,18 @@ int __cdecl CYahooProto::FileCancel(MCONTACT hContact, HANDLE hTransfer) debugLogA("[YahooFileCancel]");
y_filetransfer* ft = (y_filetransfer*)hTransfer;
-
- if (! (ft->pfts.flags & PFTS_SENDING) && ! ft->cancel) {
+
+ if (!(ft->pfts.flags & PFTS_SENDING) && !ft->cancel) {
/* abort FT transfer */
yahoo_ft7dc_abort(ft->id, ft->who, ft->ftoken);
}
-
- if ( ft->hWaitEvent != INVALID_HANDLE_VALUE )
- SetEvent( ft->hWaitEvent );
+
+ if (ft->hWaitEvent != INVALID_HANDLE_VALUE)
+ SetEvent(ft->hWaitEvent);
ft->action = FILERESUME_CANCEL;
ft->cancel = 1;
-
+
return 0;
}
diff --git a/protocols/Yahoo/src/http_gateway.cpp b/protocols/Yahoo/src/http_gateway.cpp index 9fbfdcb57f..5136a26196 100644 --- a/protocols/Yahoo/src/http_gateway.cpp +++ b/protocols/Yahoo/src/http_gateway.cpp @@ -20,11 +20,11 @@ int YAHOO_httpGatewayInit(HANDLE hConn, NETLIBOPENCONNECTION *nloc, NETLIBHTTPRE NETLIBHTTPPROXYINFO nlhpi;
debugLogA("YAHOO_httpGatewayInit!!!");
-
+
memset(&nlhpi, 0, sizeof(nlhpi));
nlhpi.cbSize = sizeof(nlhpi);
nlhpi.szHttpPostUrl = "http://shttp.msg.yahoo.com/notify/";
-
+
return CallService(MS_NETLIB_SETHTTPPROXYINFO, (WPARAM)hConn, (LPARAM)&nlhpi);
}
@@ -36,7 +36,7 @@ int YAHOO_httpGatewayWrapSend(HANDLE hConn, PBYTE buf, int len, int flags, MIRAN int n;
char *z = yahoo_webmessenger_idle_packet(m_id, &n);
int ret = 0;
-
+
if (z != NULL) {
debugLogA("YAHOO_httpGatewayWrapSend!!! Got Len: %d", n);
NETLIBBUFFER tBuf = { ( char* )z, n, flags };
@@ -45,38 +45,38 @@ int YAHOO_httpGatewayWrapSend(HANDLE hConn, PBYTE buf, int len, int flags, MIRAN } else {
debugLogA("YAHOO_httpGatewayWrapSend!!! GOT NULL???");
}
-
+
return ret;
} else {
NETLIBBUFFER tBuf = { ( char* )buf, len, flags };
-
+
return pfnNetlibSend((LPARAM)hConn, (WPARAM) &tBuf );
}
}
PBYTE YAHOO_httpGatewayUnwrapRecv(NETLIBHTTPREQUEST *nlhr, PBYTE buf, int len, int *outBufLen, void *(*NetlibRealloc)(void *, size_t))
{
- debugLogA("YAHOO_httpGatewayUnwrapRecv!!! Len: %d", len);
+ debugLogA("YAHOO_httpGatewayUnwrapRecv!!! Len: %d", len);
- debugLogA("Got headers: %d", nlhr->headersCount);
- /* we need to get the first 4 bytes! */
+ debugLogA("Got headers: %d", nlhr->headersCount);
+ /* we need to get the first 4 bytes! */
if (len < 4)
return NULL;
ylad->rpkts = buf[0] + buf[1] *256;
debugLogA("Got packets: %d", ylad->rpkts);
-
- if (len == 4) {
- *outBufLen = 0;
- return buf;
- } else if ( (buf[4] == 'Y') && (buf[5] == 'M') && (buf[6] == 'S') && (buf[7] == 'G')) {
+
+ if (len == 4) {
+ *outBufLen = 0;
+ return buf;
+ } else if ( (buf[4] == 'Y') && (buf[5] == 'M') && (buf[6] == 'S') && (buf[7] == 'G')) {
memmove( buf, buf + 4, len - 4);
*outBufLen = len-4;// we take off 4 bytes from the beginning
-
+
return buf;
- } else
- return NULL; /* Break connection, something went wrong! */
-
+ } else
+ return NULL; /* Break connection, something went wrong! */
+
}
#endif
diff --git a/protocols/Yahoo/src/icolib.cpp b/protocols/Yahoo/src/icolib.cpp index 69cb3eb97c..0734022277 100644 --- a/protocols/Yahoo/src/icolib.cpp +++ b/protocols/Yahoo/src/icolib.cpp @@ -19,21 +19,21 @@ static IconItem iconList[] =
{
- { LPGEN("Main"), "yahoo", IDI_YAHOO },
- { LPGEN("Mail"), "mail", IDI_INBOX },
- { LPGEN("Profile"), "profile", IDI_PROFILE },
- { LPGEN("Refresh"), "refresh", IDI_REFRESH },
- { LPGEN("Address Book"), "yab", IDI_YAB },
- { LPGEN("Set Status"), "set_status", IDI_SET_STATUS },
- { LPGEN("Calendar"), "calendar", IDI_CALENDAR }
+ { LPGEN("Main"), "yahoo", IDI_YAHOO },
+ { LPGEN("Mail"), "mail", IDI_INBOX },
+ { LPGEN("Profile"), "profile", IDI_PROFILE },
+ { LPGEN("Refresh"), "refresh", IDI_REFRESH },
+ { LPGEN("Address Book"), "yab", IDI_YAB },
+ { LPGEN("Set Status"), "set_status", IDI_SET_STATUS },
+ { LPGEN("Calendar"), "calendar", IDI_CALENDAR }
};
-void CYahooProto::IconsInit( void )
+void CYahooProto::IconsInit(void)
{
Icon_Register(hInstance, "Protocols/YAHOO", iconList, SIZEOF(iconList), "YAHOO");
}
-HICON CYahooProto::LoadIconEx( const char* name, bool big )
+HICON CYahooProto::LoadIconEx(const char* name, bool big)
{
char szSettingName[100];
mir_snprintf(szSettingName, SIZEOF(szSettingName), "YAHOO_%s", name);
@@ -42,7 +42,7 @@ HICON CYahooProto::LoadIconEx( const char* name, bool big ) HANDLE CYahooProto::GetIconHandle(int iconId)
{
- for (unsigned i=0; i < SIZEOF(iconList); i++)
+ for (unsigned i = 0; i < SIZEOF(iconList); i++)
if (iconList[i].defIconID == iconId)
return iconList[i].hIcolib;
diff --git a/protocols/Yahoo/src/ignore.cpp b/protocols/Yahoo/src/ignore.cpp index 1f87658371..24f0d96957 100644 --- a/protocols/Yahoo/src/ignore.cpp +++ b/protocols/Yahoo/src/ignore.cpp @@ -17,7 +17,7 @@ const YList* CYahooProto::GetIgnoreList(void) {
if (m_id < 1)
return NULL;
-
+
return yahoo_get_ignorelist(m_id);
}
@@ -25,7 +25,7 @@ void CYahooProto::IgnoreBuddy(const char *buddy, int ignore) {
if (m_id < 1)
return;
-
+
yahoo_ignore_buddy(m_id, buddy, ignore);
//yahoo_get_list(m_id);
}
@@ -36,7 +36,7 @@ int CYahooProto::BuddyIgnored(const char *who) const YList *l = GetIgnoreList();
while (l != NULL) {
struct yahoo_buddy *b = (struct yahoo_buddy *) l->data;
-
+
if (mir_strcmpi(b->id, who) == 0) {
//LOG(("User '%s' on our Ignore List. Dropping Message.", who));
return 1;
@@ -48,19 +48,19 @@ int CYahooProto::BuddyIgnored(const char *who) }
void CYahooProto::ext_got_ignore(YList * igns)
-{
+{
YList *l = igns;
-
- LOG(("[ext_yahoo_got_ignore] Got Ignore List"));
-
+
+ LOG(("[ext_yahoo_got_ignore] Got Ignore List"));
+
while (l != NULL) {
struct yahoo_buddy *b = (struct yahoo_buddy *) l->data;
- debugLogA("[ext_yahoo_got_ignore] Buddy: %s", b->id );
-
+ debugLogA("[ext_yahoo_got_ignore] Buddy: %s", b->id);
+
l = l->next;
}
-
- debugLogA("[ext_yahoo_got_ignore] End Of Ignore List");
+
+ debugLogA("[ext_yahoo_got_ignore] End Of Ignore List");
}
diff --git a/protocols/Yahoo/src/im.cpp b/protocols/Yahoo/src/im.cpp index 1301007189..5192666321 100644 --- a/protocols/Yahoo/src/im.cpp +++ b/protocols/Yahoo/src/im.cpp @@ -23,13 +23,13 @@ void CYahooProto::send_msg(const char *id, int protocol, const char *msg, int ut {
LOG(("[send_msg] Who: %s: protocol: %d Msg: '%s', utf: %d", id, protocol, msg, utf8));
- int buddy_icon = (getDword("AvatarHash", 0) != 0) ? 2: 0;
+ int buddy_icon = (getDword("AvatarHash", 0) != 0) ? 2 : 0;
yahoo_send_im(m_id, NULL, id, protocol, msg, utf8, buddy_icon);
}
void CYahooProto::ext_got_im(const char *me, const char *who, int protocol, const char *msg,
- long tm, int stat, int utf8, int buddy_icon,
- const char *seqn, int sendn)
+ long tm, int stat, int utf8, int buddy_icon,
+ const char *seqn, int sendn)
{
char *umsg;
const char *c = msg;
@@ -42,7 +42,7 @@ void CYahooProto::ext_got_im(const char *me, const char *who, int protocol, cons mir_snprintf(z, SIZEOF(z), "Error sending message to %s", who);
LOG((z));
- ShowError( TranslateT("Yahoo Error"), _A2T(z));
+ ShowError(TranslateT("Yahoo Error"), _A2T(z));
return;
}
@@ -62,27 +62,29 @@ void CYahooProto::ext_got_im(const char *me, const char *who, int protocol, cons }
}
- if ( BuddyIgnored( who )) {
+ if (BuddyIgnored(who)) {
LOG(("User '%s' on our Ignore List. Dropping Message.", who));
return;
}
// make a bigger buffer for \n -> \r\n conversion (x2)
- umsg = (char *) alloca(mir_strlen(msg) * 2 + 1);
+ umsg = (char *)alloca(mir_strlen(msg) * 2 + 1);
- while ( *c != '\0') {
+ while (*c != '\0') {
// Strip the font tag
- if (!_strnicmp(c,"<font ",6) || !_strnicmp(c,"</font>",6) ||
+ if (!_strnicmp(c, "<font ", 6) || !_strnicmp(c, "</font>", 6) ||
// strip the fade tag
- !_strnicmp(c, "<FADE ",6) || !_strnicmp(c,"</FADE>",7) ||
+ !_strnicmp(c, "<FADE ", 6) || !_strnicmp(c, "</FADE>", 7) ||
// strip the alternate colors tag
- !_strnicmp(c, "<ALT ",5) || !_strnicmp(c, "</ALT>",6)) {
- while ((*c++ != '>') && (*c != '\0'));
- } else
+ !_strnicmp(c, "<ALT ", 5) || !_strnicmp(c, "</ALT>", 6)) {
+ while ((*c++ != '>') && (*c != '\0'));
+ }
+ else
// strip ANSI color combination
- if ((*c == 0x1b) && (*(c+1) == '[')) {
+ if ((*c == 0x1b) && (*(c + 1) == '[')) {
while ((*c++ != 'm') && (*c != '\0'));
- } else
+ }
+ else
if (*c != '\0') {
umsg[oidx++] = *c;
@@ -95,7 +97,7 @@ void CYahooProto::ext_got_im(const char *me, const char *who, int protocol, cons }
}
- umsg[oidx++]= '\0';
+ umsg[oidx++] = '\0';
/* Need to strip off formatting stuff first. Then do all decoding/converting */
LOG(("%s: %s", who, umsg));
@@ -110,7 +112,7 @@ void CYahooProto::ext_got_im(const char *me, const char *who, int protocol, cons if (hEvent) { // contact has events
DWORD dummy;
- DBEVENTINFO dbei = { sizeof (dbei) };
+ DBEVENTINFO dbei = { sizeof(dbei) };
dbei.pBlob = (BYTE*)&dummy;
dbei.cbBlob = 2;
if (!db_event_get(hEvent, &dbei))
diff --git a/protocols/Yahoo/src/links.cpp b/protocols/Yahoo/src/links.cpp index ae7ef3f0aa..a436c3f400 100644 --- a/protocols/Yahoo/src/links.cpp +++ b/protocols/Yahoo/src/links.cpp @@ -33,21 +33,17 @@ static void url_decode(TCHAR* str) {
TCHAR* s = str, *d = str;
- while(*s)
- {
- if (*s == '%')
- {
+ while (*s) {
+ if (*s == '%') {
int digit1 = SingleHexToDecimal(s[1]);
- if (digit1 != -1)
- {
+ if (digit1 != -1) {
int digit2 = SingleHexToDecimal(s[2]);
- if (digit2 != -1)
- {
+ if (digit2 != -1) {
s += 3;
*d++ = (TCHAR)((digit1 << 4) | digit2);
continue;
- }
- }
+ }
+ }
}
*d++ = *s++;
}
@@ -64,18 +60,18 @@ static char* get_buddy(TCHAR ** arg) if (!buf[0]) return NULL;
url_decode(buf);
-
+
*arg = tok ? tok + 1 : NULL;
return mir_t2a(buf);
}
-/*
+/*
add user: ymsgr:addfriend?ID
send message: ymsgr:sendim?ID&m=MESSAGE
add chatroom: ymsgr:chat?ROOM
-*/
+ */
static INT_PTR ServiceParseYmsgrLink(WPARAM wParam, LPARAM lParam)
{
TCHAR *arg = (TCHAR*)lParam;
@@ -84,16 +80,14 @@ static INT_PTR ServiceParseYmsgrLink(WPARAM wParam, LPARAM lParam) /* skip leading prefix */
arg = _tcschr(arg, ':');
if (arg == NULL) return 1; /* parse failed */
-
+
for (++arg; *arg == '/'; ++arg) {}
if (g_instances.getCount() == 0) return 0;
CYahooProto *proto = g_instances[0];
- for (int i = 0; i < g_instances.getCount(); ++i)
- {
- if (g_instances[i]->m_iStatus > ID_STATUS_OFFLINE)
- {
+ for (int i = 0; i < g_instances.getCount(); ++i) {
+ if (g_instances[i]->m_iStatus > ID_STATUS_OFFLINE) {
proto = g_instances[i];
break;
}
@@ -101,22 +95,21 @@ static INT_PTR ServiceParseYmsgrLink(WPARAM wParam, LPARAM lParam) if (!proto) return 1;
/* add a contact to the list */
- if (!_tcsnicmp(arg, _T("addfriend?"), 10))
- {
+ if (!_tcsnicmp(arg, _T("addfriend?"), 10)) {
arg += 10;
char *id = get_buddy(&arg);
if (!id) return 1;
-
+
if (proto->getbuddyH(id) == NULL) /* does not yet check if id is current user */
{
- ADDCONTACTSTRUCT acs = {0};
- PROTOSEARCHRESULT psr = {0};
-
+ ADDCONTACTSTRUCT acs = { 0 };
+ PROTOSEARCHRESULT psr = { 0 };
+
acs.handleType = HANDLE_SEARCHRESULT;
acs.szProto = proto->m_szModuleName;
acs.psr = &psr;
-
+
psr.cbSize = sizeof(PROTOSEARCHRESULT);
psr.id.t = (TCHAR*)id;
CallService(MS_ADDCONTACT_SHOW, 0, (LPARAM)&acs);
@@ -126,8 +119,7 @@ static INT_PTR ServiceParseYmsgrLink(WPARAM wParam, LPARAM lParam) return 0;
}
/* send a message to a contact */
- else if (!_tcsnicmp(arg, _T("sendim?"), 7))
- {
+ else if (!_tcsnicmp(arg, _T("sendim?"), 7)) {
arg += 7;
char *id = get_buddy(&arg);
@@ -135,19 +127,17 @@ static INT_PTR ServiceParseYmsgrLink(WPARAM wParam, LPARAM lParam) TCHAR *msg = NULL;
- while (arg)
- {
- if (!_tcsnicmp(arg, _T("m="), 2))
- {
+ while (arg) {
+ if (!_tcsnicmp(arg, _T("m="), 2)) {
msg = arg + 2;
url_decode(msg);
break;
}
-
+
arg = _tcschr(arg + 1, '&'); /* first token */
if (arg) *arg = 0;
}
-
+
MCONTACT hContact = proto->add_buddy(id, id, 0, PALF_TEMPORARY); /* ensure contact is on list */
if (hContact)
CallService(MS_MSG_SENDMESSAGET, hContact, (LPARAM)msg);
@@ -156,12 +146,11 @@ static INT_PTR ServiceParseYmsgrLink(WPARAM wParam, LPARAM lParam) return 0;
}
/* open a chatroom */
- else if (!_tcsnicmp(arg, _T("chat?"), 5))
- {
+ else if (!_tcsnicmp(arg, _T("chat?"), 5)) {
arg += 5;
-// char *id = get_buddy(&arg);
-// if (!id) return 1;
+ // char *id = get_buddy(&arg);
+ // if (!id) return 1;
/* not yet implemented (rm contains name of chatroom)*/
return 0;
diff --git a/protocols/Yahoo/src/main.cpp b/protocols/Yahoo/src/main.cpp index 9789cf760f..74d61a4fbc 100644 --- a/protocols/Yahoo/src/main.cpp +++ b/protocols/Yahoo/src/main.cpp @@ -27,7 +27,7 @@ HANDLE g_hNetlibUser; CLIST_INTERFACE *pcli;
int hLangpack;
-PLUGININFOEX pluginInfo={
+PLUGININFOEX pluginInfo = {
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
@@ -37,7 +37,7 @@ PLUGININFOEX pluginInfo={ __COPYRIGHT,
__AUTHORWEB,
UNICODE_AWARE, //not transient
- {0xaa7bfea, 0x1fc7, 0x45f0, {0x90, 0x6e, 0x2a, 0x46, 0xb6, 0xe1, 0x19, 0xcf}} // {0AA7BFEA-1FC7-45f0-906E-2A46B6E119CF}
+ { 0xaa7bfea, 0x1fc7, 0x45f0, { 0x90, 0x6e, 0x2a, 0x46, 0xb6, 0xe1, 0x19, 0xcf } } // {0AA7BFEA-1FC7-45f0-906E-2A46B6E119CF}
};
void YmsgrLinksInit(void);
@@ -45,15 +45,15 @@ void YmsgrLinksUninit(void); /*
* WINAPI DllMain - main entry point into a DLL
- * Parameters:
+ * Parameters:
* HINSTANCE hinst,
* DWORD fdwReason,
* LPVOID lpvReserved
- * Returns :
+ * Returns :
* BOOL
- *
+ *
*/
-extern "C" BOOL WINAPI DllMain(HINSTANCE hinst,DWORD /*fdwReason*/,LPVOID /*lpvReserved*/)
+extern "C" BOOL WINAPI DllMain(HINSTANCE hinst, DWORD /*fdwReason*/, LPVOID /*lpvReserved*/)
{
hInstance = hinst;
return TRUE;
@@ -62,7 +62,7 @@ extern "C" BOOL WINAPI DllMain(HINSTANCE hinst,DWORD /*fdwReason*/,LPVOID /*lpvR /*
* Load - loads plugin into memory
*/
-
+
//=====================================================
// Name : Load
// Parameters:
@@ -70,44 +70,44 @@ extern "C" BOOL WINAPI DllMain(HINSTANCE hinst,DWORD /*fdwReason*/,LPVOID /*lpvR // Description : Called when plugin is loaded into Miranda
//=====================================================
-static int CompareProtos( const CYahooProto* p1, const CYahooProto* p2 )
+static int CompareProtos(const CYahooProto* p1, const CYahooProto* p2)
{
return mir_tstrcmp(p1->m_tszUserName, p2->m_tszUserName);
}
-LIST<CYahooProto> g_instances( 1, CompareProtos );
+LIST<CYahooProto> g_instances(1, CompareProtos);
-static CYahooProto* yahooProtoInit( const char* pszProtoName, const TCHAR* tszUserName )
+static CYahooProto* yahooProtoInit(const char* pszProtoName, const TCHAR* tszUserName)
{
CYahooProto* ppro = new CYahooProto(pszProtoName, tszUserName);
-
- g_instances.insert( ppro );
-
+
+ g_instances.insert(ppro);
+
return ppro;
}
-static int yahooProtoUninit( CYahooProto* ppro )
+static int yahooProtoUninit(CYahooProto* ppro)
{
- g_instances.remove( ppro );
+ g_instances.remove(ppro);
delete ppro;
-
+
return 0;
}
extern "C" int __declspec(dllexport)Load(void)
{
- mir_getLP( &pluginInfo );
+ mir_getLP(&pluginInfo);
mir_getCLI();
-
+
PROTOCOLDESCRIPTOR pd = { 0 };
pd.cbSize = sizeof(pd);
pd.szName = "YAHOO";
- pd.type = PROTOTYPE_PROTOCOL;
- pd.fnInit = ( pfnInitProto )yahooProtoInit;
- pd.fnUninit = ( pfnUninitProto )yahooProtoUninit;
+ pd.type = PROTOTYPE_PROTOCOL;
+ pd.fnInit = (pfnInitProto)yahooProtoInit;
+ pd.fnUninit = (pfnUninitProto)yahooProtoUninit;
CallService(MS_PROTO_REGISTERMODULE, 0, (LPARAM)&pd);
- NETLIBUSER nlu = {0};
+ NETLIBUSER nlu = { 0 };
nlu.cbSize = sizeof(nlu);
nlu.flags = NUF_TCHAR | NUF_OUTGOING | NUF_HTTPCONNS;
nlu.szSettingsModule = "YAHOO/libyahoo2";
@@ -119,7 +119,7 @@ extern "C" int __declspec(dllexport)Load(void) * Register LibYahoo2 callback functions
*/
register_callbacks();
-
+
return 0;
}
@@ -131,9 +131,9 @@ extern "C" int __declspec(dllexport)Load(void) extern "C" int __declspec(dllexport) Unload(void)
{
LOG(("Unload"));
-
+
YmsgrLinksUninit();
- Netlib_CloseHandle( g_hNetlibUser );
+ Netlib_CloseHandle(g_hNetlibUser);
return 0;
}
@@ -150,4 +150,4 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD miranda * MirandaInterfaces - Notifies the core of interfaces implemented
* Parameters: none
*/
-extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_PROTOCOL, MIID_LAST};
+extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOCOL, MIID_LAST };
diff --git a/protocols/Yahoo/src/options.cpp b/protocols/Yahoo/src/options.cpp index e157362e95..f8eeab9976 100644 --- a/protocols/Yahoo/src/options.cpp +++ b/protocols/Yahoo/src/options.cpp @@ -27,73 +27,73 @@ static INT_PTR CALLBACK DlgProcYahooOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { DBVARIANT dbv; - CYahooProto* ppro = (CYahooProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA ); + CYahooProto* ppro = (CYahooProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - switch ( msg ) { - case WM_INITDIALOG: + switch (msg) { + case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); ppro = (CYahooProto*)lParam; - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam ); + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); - if ( !ppro->getString( YAHOO_LOGINID, &dbv)) { + if (!ppro->getString(YAHOO_LOGINID, &dbv)) { SetDlgItemTextA(hwndDlg, IDC_HANDLE, dbv.pszVal); db_free(&dbv); } - if ( !ppro->getString("Nick", &dbv)) { + if (!ppro->getString("Nick", &dbv)) { SetDlgItemTextA(hwndDlg, IDC_NICK, dbv.pszVal); db_free(&dbv); } - if ( !ppro->getString( YAHOO_PASSWORD, &dbv)) { + if (!ppro->getString(YAHOO_PASSWORD, &dbv)) { //bit of a security hole here, since it's easy to extract a password from an edit box - SetDlgItemTextA(hwndDlg, IDC_PASSWORD, dbv.pszVal ); + SetDlgItemTextA(hwndDlg, IDC_PASSWORD, dbv.pszVal); db_free(&dbv); } //SetButtonCheck(hwndDlg, IDC_DISABLE_UTF8, ppro->getByte("DisableUTF8", 0)); - SetButtonCheck(hwndDlg, IDC_USE_YAB, ppro->getByte("UseYAB", 1 )); - SetButtonCheck(hwndDlg, IDC_SHOW_AVATARS, ppro->getByte("ShowAvatars", 1 )); - SetButtonCheck(hwndDlg, IDC_MAIL_AUTOLOGIN, ppro->getByte("MailAutoLogin", 1 )); + SetButtonCheck(hwndDlg, IDC_USE_YAB, ppro->getByte("UseYAB", 1)); + SetButtonCheck(hwndDlg, IDC_SHOW_AVATARS, ppro->getByte("ShowAvatars", 1)); + SetButtonCheck(hwndDlg, IDC_MAIL_AUTOLOGIN, ppro->getByte("MailAutoLogin", 1)); SetButtonCheck(hwndDlg, IDC_DISABLEYAHOOMAIL, !ppro->getByte("DisableYahoomail", 0)); - SetButtonCheck(hwndDlg, IDC_SHOW_ERRORS, ppro->getByte("ShowErrors", 1 )); + SetButtonCheck(hwndDlg, IDC_SHOW_ERRORS, ppro->getByte("ShowErrors", 1)); return TRUE; - case WM_COMMAND: + case WM_COMMAND: - switch ( LOWORD( wParam )) { + switch (LOWORD(wParam)) { case IDC_NEWYAHOOACCOUNTLINK: - CallService(MS_UTILS_OPENURL, OUF_NEWWINDOW, + CallService(MS_UTILS_OPENURL, OUF_NEWWINDOW, ppro->getByte("YahooJapan", 0) ? (LPARAM)"http://edit.yahoo.co.jp/config/eval_register" : - (LPARAM)"http://edit.yahoo.com/config/eval_register"); + (LPARAM)"http://edit.yahoo.com/config/eval_register"); return TRUE; //case IDC_DISABLE_UTF8: - case IDC_USE_YAB: + case IDC_USE_YAB: case IDC_SHOW_AVATARS: case IDC_MAIL_AUTOLOGIN: case IDC_SHOW_ERRORS: case IDC_DISABLEYAHOOMAIL: SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; - } + } - if ( HIWORD( wParam ) == EN_CHANGE && ( HWND )lParam == GetFocus()) - switch( LOWORD( wParam )) { - case IDC_HANDLE: - case IDC_PASSWORD: + if (HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus()) + switch (LOWORD(wParam)) { + case IDC_HANDLE: + case IDC_PASSWORD: case IDC_NICK: SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); } break; - case WM_NOTIFY: + case WM_NOTIFY: - if (((LPNMHDR)lParam)->code == (UINT) PSN_APPLY ) { + if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY) { bool reconnectRequired = false; char str[128]; @@ -102,44 +102,45 @@ static INT_PTR CALLBACK DlgProcYahooOpts(HWND hwndDlg, UINT msg, WPARAM wParam, reconnectRequired = true; } else { - if(mir_strcmp(str, dbv.pszVal)) + if (mir_strcmp(str, dbv.pszVal)) reconnectRequired = true; db_free(&dbv); } - ppro->setString( YAHOO_LOGINID, str ); + ppro->setString(YAHOO_LOGINID, str); GetDlgItemTextA(hwndDlg, IDC_PASSWORD, str, SIZEOF(str)); if (ppro->getString(YAHOO_PASSWORD, &dbv)) { reconnectRequired = true; } else { - if(mir_strcmp(str, dbv.pszVal)) + if (mir_strcmp(str, dbv.pszVal)) reconnectRequired = true; db_free(&dbv); } - ppro->setString( YAHOO_PASSWORD, str ); + ppro->setString(YAHOO_PASSWORD, str); GetDlgItemTextA(hwndDlg, IDC_NICK, str, SIZEOF(str)); if (str[0] == '\0') { /* Check for empty Nick, if so delete the key in the DB */ ppro->delSetting("Nick"); - } else { + } + else { /* otherwise save the new Nick */ ppro->setString("Nick", str); } - ppro->setByte("UseYAB", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_USE_YAB)); - ppro->setByte("ShowAvatars", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SHOW_AVATARS)); - ppro->setByte("MailAutoLogin", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_MAIL_AUTOLOGIN)); + ppro->setByte("UseYAB", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_USE_YAB)); + ppro->setByte("ShowAvatars", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SHOW_AVATARS)); + ppro->setByte("MailAutoLogin", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_MAIL_AUTOLOGIN)); ppro->setByte("DisableYahoomail", (BYTE)BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_DISABLEYAHOOMAIL)); - ppro->setByte("ShowErrors", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SHOW_ERRORS)); + ppro->setByte("ShowErrors", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SHOW_ERRORS)); if (reconnectRequired) { ppro->delSetting(YAHOO_PWTOKEN); - if (ppro->m_bLoggedIn ) - MessageBox(hwndDlg, TranslateT("The changes you have made require you to reconnect to the Yahoo network before they take effect"), TranslateT("YAHOO Options"), MB_OK ); + if (ppro->m_bLoggedIn) + MessageBox(hwndDlg, TranslateT("The changes you have made require you to reconnect to the Yahoo network before they take effect"), TranslateT("YAHOO Options"), MB_OK); } @@ -157,86 +158,85 @@ static INT_PTR CALLBACK DlgProcYahooOpts(HWND hwndDlg, UINT msg, WPARAM wParam, static INT_PTR CALLBACK DlgProcYahooOptsConn(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { DBVARIANT dbv; - CYahooProto* ppro = (CYahooProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA ); - - switch ( msg ) { + CYahooProto* ppro = (CYahooProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + + switch (msg) { case WM_INITDIALOG: - TranslateDialogDefault(hwndDlg ); + TranslateDialogDefault(hwndDlg); - ppro = ( CYahooProto* )lParam; - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam ); + ppro = (CYahooProto*)lParam; + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); - if ( !ppro->getString( YAHOO_LOGINSERVER, &dbv)) { - SetDlgItemTextA(hwndDlg, IDC_LOGINSERVER, dbv.pszVal ); + if (!ppro->getString(YAHOO_LOGINSERVER, &dbv)) { + SetDlgItemTextA(hwndDlg, IDC_LOGINSERVER, dbv.pszVal); db_free(&dbv); } - else SetDlgItemTextA(hwndDlg, IDC_LOGINSERVER, - ppro->getByte("YahooJapan", 0) - ? YAHOO_DEFAULT_JAPAN_LOGIN_SERVER - : YAHOO_DEFAULT_LOGIN_SERVER ); + else SetDlgItemTextA(hwndDlg, IDC_LOGINSERVER, + ppro->getByte("YahooJapan", 0) + ? YAHOO_DEFAULT_JAPAN_LOGIN_SERVER + : YAHOO_DEFAULT_LOGIN_SERVER); SetDlgItemInt(hwndDlg, IDC_YAHOOPORT, ppro->getWord(YAHOO_LOGINPORT, YAHOO_DEFAULT_PORT), FALSE); - + SetButtonCheck(hwndDlg, IDC_YAHOO_JAPAN, ppro->getByte("YahooJapan", 0)); return TRUE; case WM_COMMAND: - switch ( LOWORD( wParam )) { - case IDC_RESETSERVER: - SetDlgItemTextA(hwndDlg, IDC_LOGINSERVER, YAHOO_DEFAULT_LOGIN_SERVER ); - SetDlgItemInt( hwndDlg, IDC_YAHOOPORT, YAHOO_DEFAULT_PORT, FALSE ); - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - break; - + switch (LOWORD(wParam)) { + case IDC_RESETSERVER: + SetDlgItemTextA(hwndDlg, IDC_LOGINSERVER, YAHOO_DEFAULT_LOGIN_SERVER); + SetDlgItemInt(hwndDlg, IDC_YAHOOPORT, YAHOO_DEFAULT_PORT, FALSE); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + case IDC_YAHOO_JAPAN: - SetDlgItemTextA(hwndDlg, IDC_LOGINSERVER, - (IsDlgButtonChecked(hwndDlg,IDC_YAHOO_JAPAN)==BST_CHECKED) ? - YAHOO_DEFAULT_JAPAN_LOGIN_SERVER : - YAHOO_DEFAULT_LOGIN_SERVER ); - // fall through and enable apply button + SetDlgItemTextA(hwndDlg, IDC_LOGINSERVER, + (IsDlgButtonChecked(hwndDlg, IDC_YAHOO_JAPAN) == BST_CHECKED) ? +YAHOO_DEFAULT_JAPAN_LOGIN_SERVER : + YAHOO_DEFAULT_LOGIN_SERVER); + // fall through and enable apply button SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; - } + } - if ( HIWORD( wParam ) == EN_CHANGE && ( HWND )lParam == GetFocus()) - switch( LOWORD( wParam )) { + if (HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus()) + switch (LOWORD(wParam)) { case IDC_LOGINSERVER: - case IDC_YAHOOPORT: - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - } + case IDC_YAHOOPORT: + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + } break; case WM_NOTIFY: - if (((LPNMHDR)lParam)->code == PSN_APPLY ) - { + if (((LPNMHDR)lParam)->code == PSN_APPLY) { bool reconnectRequired = false; char str[128]; GetDlgItemTextA(hwndDlg, IDC_LOGINSERVER, str, SIZEOF(str)); - + DBVARIANT dbv; if (ppro->getString(YAHOO_LOGINSERVER, &dbv)) { reconnectRequired = true; } else { - if(mir_strcmp(str, dbv.pszVal)) + if (mir_strcmp(str, dbv.pszVal)) reconnectRequired = true; db_free(&dbv); } ppro->setString(YAHOO_LOGINSERVER, str); - int port = GetDlgItemInt(hwndDlg, IDC_YAHOOPORT, NULL, FALSE ); - if ( ppro->getWord(YAHOO_LOGINPORT, -1) != port) + int port = GetDlgItemInt(hwndDlg, IDC_YAHOOPORT, NULL, FALSE); + if (ppro->getWord(YAHOO_LOGINPORT, -1) != port) reconnectRequired = true; - + ppro->setWord(YAHOO_LOGINPORT, port); - ppro->setByte("YahooJapan", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_YAHOO_JAPAN )); + ppro->setByte("YahooJapan", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_YAHOO_JAPAN)); - if ( reconnectRequired && ppro->m_bLoggedIn ) - MessageBox(hwndDlg, TranslateT("The changes you have made require you to reconnect to the Yahoo network before they take effect"), TranslateT("YAHOO Options"), MB_OK ); + if (reconnectRequired && ppro->m_bLoggedIn) + MessageBox(hwndDlg, TranslateT("The changes you have made require you to reconnect to the Yahoo network before they take effect"), TranslateT("YAHOO Options"), MB_OK); return TRUE; } @@ -251,67 +251,67 @@ static INT_PTR CALLBACK DlgProcYahooOptsConn(HWND hwndDlg, UINT msg, WPARAM wPar static INT_PTR CALLBACK DlgProcYahooOptsIgnore(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { YList *l; - CYahooProto* ppro = (CYahooProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA ); + CYahooProto* ppro = (CYahooProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - switch ( msg ) { + switch (msg) { case WM_INITDIALOG: - TranslateDialogDefault(hwndDlg ); + TranslateDialogDefault(hwndDlg); - ppro = ( CYahooProto* )lParam; - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam ); + ppro = (CYahooProto*)lParam; + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); - if ( ppro->getByte("IgnoreUnknown", 0)) { + if (ppro->getByte("IgnoreUnknown", 0)) { CheckDlgButton(hwndDlg, IDC_OPT_IGN_UNKNOWN, BST_CHECKED); - EnableWindow( GetDlgItem(hwndDlg, IDC_IGN_ADD), 0); - EnableWindow( GetDlgItem(hwndDlg, IDC_IGN_REMOVE), 0); - EnableWindow( GetDlgItem(hwndDlg, IDC_YIGN_EDIT), 0); - EnableWindow( GetDlgItem(hwndDlg, IDC_YIGN_LIST), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_IGN_ADD), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_IGN_REMOVE), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_YIGN_EDIT), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_YIGN_LIST), 0); } else CheckDlgButton(hwndDlg, IDC_OPT_IGN_LIST, BST_CHECKED); /* show our current ignore list */ LOG(("[DlgProcYahooOptsIgnore] Grabbing current ignore list...")) - l = (YList *)ppro->GetIgnoreList(); + l = (YList *)ppro->GetIgnoreList(); while (l != NULL) { struct yahoo_buddy *b = (struct yahoo_buddy *) l->data; - LOG(("[DlgProcYahooOptsIgnore] Buddy: %s", b->id )) - SendDlgItemMessageA(hwndDlg, IDC_YIGN_LIST, LB_ADDSTRING, 0, (LPARAM)b->id); + LOG(("[DlgProcYahooOptsIgnore] Buddy: %s", b->id)) + SendDlgItemMessageA(hwndDlg, IDC_YIGN_LIST, LB_ADDSTRING, 0, (LPARAM)b->id); l = l->next; } LOG(("[DlgProcYahooOptsIgnore] End of Ignore List...")) - - return TRUE; + + return TRUE; case WM_COMMAND: - switch ( LOWORD( wParam )) { + switch (LOWORD(wParam)) { case IDC_OPT_IGN_UNKNOWN: case IDC_OPT_IGN_LIST: - if (( HWND )lParam != GetFocus()) return 0; + if ((HWND)lParam != GetFocus()) return 0; - EnableWindow( GetDlgItem(hwndDlg, IDC_IGN_ADD), LOWORD( wParam ) == IDC_OPT_IGN_LIST); - EnableWindow( GetDlgItem(hwndDlg, IDC_IGN_REMOVE), LOWORD( wParam ) == IDC_OPT_IGN_LIST); - EnableWindow( GetDlgItem(hwndDlg, IDC_YIGN_EDIT), LOWORD( wParam ) == IDC_OPT_IGN_LIST); - EnableWindow( GetDlgItem(hwndDlg, IDC_YIGN_LIST), LOWORD( wParam ) == IDC_OPT_IGN_LIST); + EnableWindow(GetDlgItem(hwndDlg, IDC_IGN_ADD), LOWORD(wParam) == IDC_OPT_IGN_LIST); + EnableWindow(GetDlgItem(hwndDlg, IDC_IGN_REMOVE), LOWORD(wParam) == IDC_OPT_IGN_LIST); + EnableWindow(GetDlgItem(hwndDlg, IDC_YIGN_EDIT), LOWORD(wParam) == IDC_OPT_IGN_LIST); + EnableWindow(GetDlgItem(hwndDlg, IDC_YIGN_LIST), LOWORD(wParam) == IDC_OPT_IGN_LIST); SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; - case IDC_IGN_ADD: + case IDC_IGN_ADD: if (!ppro->m_bLoggedIn) - MessageBox(hwndDlg, TranslateT("You need to be connected to Yahoo to add to Ignore List."), TranslateT("Yahoo Ignore"), MB_OK| MB_ICONINFORMATION); + MessageBox(hwndDlg, TranslateT("You need to be connected to Yahoo to add to Ignore List."), TranslateT("Yahoo Ignore"), MB_OK | MB_ICONINFORMATION); else { char id[128]; int i = GetDlgItemTextA(hwndDlg, IDC_YIGN_EDIT, id, SIZEOF(id)); if (i < 3) { - MessageBox(hwndDlg, TranslateT("Please enter a valid buddy name to ignore."), TranslateT("Yahoo Ignore"), MB_OK| MB_ICONINFORMATION); + MessageBox(hwndDlg, TranslateT("Please enter a valid buddy name to ignore."), TranslateT("Yahoo Ignore"), MB_OK | MB_ICONINFORMATION); break; } - i = SendDlgItemMessageA(hwndDlg, IDC_YIGN_LIST, LB_FINDSTRINGEXACT,(WPARAM) -1, (LPARAM)id); - if (i != LB_ERR ) { + i = SendDlgItemMessageA(hwndDlg, IDC_YIGN_LIST, LB_FINDSTRINGEXACT, (WPARAM)-1, (LPARAM)id); + if (i != LB_ERR) { MessageBox(hwndDlg, TranslateT("The buddy is already on your ignore list."), TranslateT("Yahoo Ignore"), MB_OK | MB_ICONINFORMATION); break; } @@ -327,27 +327,27 @@ static INT_PTR CALLBACK DlgProcYahooOptsIgnore(HWND hwndDlg, UINT msg, WPARAM wP char id[128]; if (!ppro->m_bLoggedIn) { - MessageBox(hwndDlg, TranslateT("You need to be connected to Yahoo to remove from the ignore list."), TranslateT("Yahoo Ignore"), MB_OK| MB_ICONINFORMATION); + MessageBox(hwndDlg, TranslateT("You need to be connected to Yahoo to remove from the ignore list."), TranslateT("Yahoo Ignore"), MB_OK | MB_ICONINFORMATION); break; } - i = SendDlgItemMessage(hwndDlg,IDC_YIGN_LIST, LB_GETCURSEL, 0, 0); + i = SendDlgItemMessage(hwndDlg, IDC_YIGN_LIST, LB_GETCURSEL, 0, 0); if (i == LB_ERR) { - MessageBox(hwndDlg, TranslateT("Please select a buddy on the ignore list to remove."), TranslateT("Yahoo Ignore"), MB_OK| MB_ICONINFORMATION); + MessageBox(hwndDlg, TranslateT("Please select a buddy on the ignore list to remove."), TranslateT("Yahoo Ignore"), MB_OK | MB_ICONINFORMATION); break; } SendDlgItemMessageA(hwndDlg, IDC_YIGN_LIST, LB_GETTEXT, i, (LPARAM)id); ppro->IgnoreBuddy(id, 1); - SendDlgItemMessage(hwndDlg,IDC_YIGN_LIST, LB_DELETESTRING, i, 0); - } + SendDlgItemMessage(hwndDlg, IDC_YIGN_LIST, LB_DELETESTRING, i, 0); + } } break; case WM_NOTIFY: - if (((LPNMHDR)lParam)->code == PSN_APPLY ) { - ppro->setByte("IgnoreUnknown", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_OPT_IGN_UNKNOWN )); + if (((LPNMHDR)lParam)->code == PSN_APPLY) { + ppro->setByte("IgnoreUnknown", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_OPT_IGN_UNKNOWN)); return TRUE; } break; @@ -360,28 +360,28 @@ static INT_PTR CALLBACK DlgProcYahooOptsIgnore(HWND hwndDlg, UINT msg, WPARAM wP * YahooOptInit - initialize/register our Options w/ Miranda. */ -int __cdecl CYahooProto::OnOptionsInit(WPARAM wParam,LPARAM) +int __cdecl CYahooProto::OnOptionsInit(WPARAM wParam, LPARAM) { OPTIONSDIALOGPAGE odp = { 0 }; - odp.position = -790000000; - odp.hInstance = hInstance; + odp.position = -790000000; + odp.hInstance = hInstance; odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_YAHOO); - odp.ptszTitle = m_tszUserName; - odp.flags = ODPF_BOLDGROUPS | ODPF_TCHAR | ODPF_DONTTRANSLATE; - odp.ptszGroup = LPGENT("Network"); - odp.ptszTab = LPGENT("Account"); - odp.pfnDlgProc = DlgProcYahooOpts; + odp.ptszTitle = m_tszUserName; + odp.flags = ODPF_BOLDGROUPS | ODPF_TCHAR | ODPF_DONTTRANSLATE; + odp.ptszGroup = LPGENT("Network"); + odp.ptszTab = LPGENT("Account"); + odp.pfnDlgProc = DlgProcYahooOpts; odp.dwInitParam = LPARAM(this); Options_AddPage(wParam, &odp); - odp.ptszTab = LPGENT("Connection"); + odp.ptszTab = LPGENT("Connection"); odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_YAHOO_CONNECTION); - odp.pfnDlgProc = DlgProcYahooOptsConn; + odp.pfnDlgProc = DlgProcYahooOptsConn; Options_AddPage(wParam, &odp); - - odp.ptszTab = LPGENT("Ignore List"); + + odp.ptszTab = LPGENT("Ignore List"); odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_YAHOO_IGNORE); - odp.pfnDlgProc = DlgProcYahooOptsIgnore; + odp.pfnDlgProc = DlgProcYahooOptsIgnore; Options_AddPage(wParam, &odp); return 0; } diff --git a/protocols/Yahoo/src/proto.cpp b/protocols/Yahoo/src/proto.cpp index 4fbc1389a8..0ebea61427 100644 --- a/protocols/Yahoo/src/proto.cpp +++ b/protocols/Yahoo/src/proto.cpp @@ -24,10 +24,10 @@ #pragma warning(disable:4355)
-CYahooProto::CYahooProto( const char* aProtoName, const TCHAR* aUserName ) :
- PROTO<CYahooProto>(aProtoName, aUserName),
- m_bLoggedIn( FALSE ),
- poll_loop( 0),
+CYahooProto::CYahooProto(const char *aProtoName, const TCHAR *aUserName)
+ : PROTO<CYahooProto>(aProtoName, aUserName),
+ m_bLoggedIn(FALSE),
+ poll_loop(0),
m_chatrooms(3, ChatRoom::compare)
{
m_connections = NULL;
@@ -63,19 +63,19 @@ CYahooProto::~CYahooProto() int CYahooProto::OnModulesLoadedEx(WPARAM, LPARAM)
{
- HookProtoEvent( ME_USERINFO_INITIALISE, &CYahooProto::OnUserInfoInit );
- HookProtoEvent( ME_IDLE_CHANGED, &CYahooProto::OnIdleEvent);
- HookProtoEvent( ME_CLIST_PREBUILDCONTACTMENU, &CYahooProto::OnPrebuildContactMenu );
+ HookProtoEvent(ME_USERINFO_INITIALISE, &CYahooProto::OnUserInfoInit);
+ HookProtoEvent(ME_IDLE_CHANGED, &CYahooProto::OnIdleEvent);
+ HookProtoEvent(ME_CLIST_PREBUILDCONTACTMENU, &CYahooProto::OnPrebuildContactMenu);
- TCHAR tModuleDescr[ 100 ];
+ TCHAR tModuleDescr[100];
mir_sntprintf(tModuleDescr, SIZEOF(tModuleDescr), TranslateT("%s plugin connections"), m_tszUserName);
- NETLIBUSER nlu = {0};
+ NETLIBUSER nlu = { 0 };
nlu.cbSize = sizeof(nlu);
#ifdef HTTP_GATEWAY
nlu.flags = NUF_OUTGOING | NUF_HTTPGATEWAY| NUF_HTTPCONNS | NUF_TCHAR;
#else
- nlu.flags = NUF_OUTGOING | NUF_HTTPCONNS | NUF_TCHAR;
+ nlu.flags = NUF_OUTGOING | NUF_HTTPCONNS | NUF_TCHAR;
#endif
nlu.szSettingsModule = m_szModuleName;
nlu.ptszDescriptiveName = tModuleDescr;
@@ -84,7 +84,7 @@ int CYahooProto::OnModulesLoadedEx(WPARAM, LPARAM) // Here comes the Gateway Code!
nlu.szHttpGatewayHello = NULL;
nlu.szHttpGatewayUserAgent = "User-Agent: " + NETLIB_USER_AGENT;
- nlu.pfnHttpGatewayInit = YAHOO_httpGatewayInit;
+ nlu.pfnHttpGatewayInit = YAHOO_httpGatewayInit;
nlu.pfnHttpGatewayBegin = NULL;
nlu.pfnHttpGatewayWrapSend = YAHOO_httpGatewayWrapSend;
nlu.pfnHttpGatewayUnwrapRecv = YAHOO_httpGatewayUnwrapRecv;
@@ -138,20 +138,20 @@ MCONTACT CYahooProto::AddToList(int flags, PROTOSEARCHRESULT *psr) return hContact;
}
-MCONTACT __cdecl CYahooProto::AddToListByEvent( int flags, int /*iContact*/, MEVENT hDbEvent )
+MCONTACT __cdecl CYahooProto::AddToListByEvent(int flags, int /*iContact*/, MEVENT hDbEvent)
{
debugLogA("[YahooAddToListByEvent]");
if (!m_bLoggedIn)
return 0;
- DBEVENTINFO dbei = { sizeof( dbei ) };
- if ((dbei.cbBlob = db_event_getBlobSize(hDbEvent)) == -1 ) {
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ if ((dbei.cbBlob = db_event_getBlobSize(hDbEvent)) == -1) {
debugLogA("[YahooAddToListByEvent] ERROR: Can't get blob size.");
return 0;
}
debugLogA("[YahooAddToListByEvent] Got blob size: %lu", dbei.cbBlob);
- dbei.pBlob = ( PBYTE )_alloca( dbei.cbBlob );
+ dbei.pBlob = (PBYTE)_alloca(dbei.cbBlob);
if (db_event_get(hDbEvent, &dbei)) {
debugLogA("[YahooAddToListByEvent] ERROR: Can't get event.");
return 0;
@@ -162,7 +162,7 @@ MCONTACT __cdecl CYahooProto::AddToListByEvent( int flags, int /*iContact*/, MEV return 0;
}
- if ( mir_strcmp(dbei.szModule, m_szModuleName)) {
+ if (mir_strcmp(dbei.szModule, m_szModuleName)) {
debugLogA("[YahooAddToListByEvent] ERROR: Not Yahoo protocol.");
return 0;
}
@@ -182,31 +182,31 @@ MCONTACT __cdecl CYahooProto::AddToListByEvent( int flags, int /*iContact*/, MEV int CYahooProto::Authorize(MEVENT hdbe)
{
debugLogA("[YahooAuthAllow]");
- if ( !m_bLoggedIn ) {
+ if (!m_bLoggedIn) {
debugLogA("[YahooAuthAllow] Not Logged In!");
return 1;
}
DBEVENTINFO dbei = { sizeof(dbei) };
- if (( dbei.cbBlob = db_event_getBlobSize(hdbe)) == -1 )
+ if ((dbei.cbBlob = db_event_getBlobSize(hdbe)) == -1)
return 1;
- dbei.pBlob = ( PBYTE )_alloca( dbei.cbBlob );
+ dbei.pBlob = (PBYTE)_alloca(dbei.cbBlob);
if (db_event_get(hdbe, &dbei))
return 1;
if (dbei.eventType != EVENTTYPE_AUTHREQUEST)
return 1;
- if ( mir_strcmp(dbei.szModule, m_szModuleName))
+ if (mir_strcmp(dbei.szModule, m_szModuleName))
return 1;
/* Need to remove the buddy from our Miranda Lists */
MCONTACT hContact = DbGetAuthEventContact(&dbei);
if (hContact != NULL) {
- ptrA who( getStringA(hContact, YAHOO_LOGINID));
+ ptrA who(getStringA(hContact, YAHOO_LOGINID));
if (who) {
- ptrA myid( getStringA(hContact, "MyIdentity"));
+ ptrA myid(getStringA(hContact, "MyIdentity"));
debugLogA("Accepting buddy:%s", who);
accept(myid, who, getWord(hContact, "yprotoid", 0));
}
@@ -221,16 +221,16 @@ int CYahooProto::Authorize(MEVENT hdbe) int CYahooProto::AuthDeny(MEVENT hdbe, const TCHAR *reason)
{
debugLogA("[YahooAuthDeny]");
- if ( !m_bLoggedIn )
+ if (!m_bLoggedIn)
return 1;
- DBEVENTINFO dbei = { sizeof( dbei ) };
- if (( dbei.cbBlob = db_event_getBlobSize(hdbe)) == -1 ) {
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ if ((dbei.cbBlob = db_event_getBlobSize(hdbe)) == -1) {
debugLogA("[YahooAuthDeny] ERROR: Can't get blob size");
return 1;
}
- dbei.pBlob = ( PBYTE )alloca( dbei.cbBlob );
+ dbei.pBlob = (PBYTE)alloca(dbei.cbBlob);
if (db_event_get(hdbe, &dbei)) {
debugLogA("YahooAuthDeny - Can't get db event!");
return 1;
@@ -241,7 +241,7 @@ int CYahooProto::AuthDeny(MEVENT hdbe, const TCHAR *reason) return 1;
}
- if (mir_strcmp( dbei.szModule, m_szModuleName)) {
+ if (mir_strcmp(dbei.szModule, m_szModuleName)) {
debugLogA("YahooAuthDeny - wrong module?");
return 1;
}
@@ -268,7 +268,7 @@ int CYahooProto::AuthDeny(MEVENT hdbe, const TCHAR *reason) int __cdecl CYahooProto::AuthRecv(MCONTACT hContact, PROTORECVEVENT* pre)
{
debugLogA("[YahooRecvAuth] ");
- db_unset(hContact,"CList","Hidden");
+ db_unset(hContact, "CList", "Hidden");
Proto_AuthRecv(m_szModuleName, pre);
return 0;
@@ -277,7 +277,7 @@ int __cdecl CYahooProto::AuthRecv(MCONTACT hContact, PROTORECVEVENT* pre) ////////////////////////////////////////////////////////////////////////////////////////
// PSS_AUTHREQUEST
-int __cdecl CYahooProto::AuthRequest(MCONTACT hContact, const TCHAR* msg )
+int __cdecl CYahooProto::AuthRequest(MCONTACT hContact, const TCHAR* msg)
{
debugLogA("[YahooSendAuthRequest]");
@@ -294,10 +294,10 @@ int __cdecl CYahooProto::AuthRequest(MCONTACT hContact, const TCHAR* msg ) DWORD_PTR __cdecl CYahooProto::GetCaps(int type, MCONTACT hContact)
{
- switch ( type ) {
+ switch (type) {
case PFLAGNUM_1:
- return PF1_IM | PF1_ADDED | PF1_AUTHREQ | PF1_MODEMSGRECV | PF1_MODEMSGSEND | PF1_BASICSEARCH |
- PF1_EXTSEARCH | PF1_FILESEND | PF1_FILERECV| PF1_VISLIST | PF1_SERVERCLIST;
+ return PF1_IM | PF1_ADDED | PF1_AUTHREQ | PF1_MODEMSGRECV | PF1_MODEMSGSEND | PF1_BASICSEARCH |
+ PF1_EXTSEARCH | PF1_FILESEND | PF1_FILERECV | PF1_VISLIST | PF1_SERVERCLIST;
case PFLAGNUM_2:
return PF2_ONLINE | PF2_SHORTAWAY | PF2_LONGAWAY | PF2_ONTHEPHONE |
@@ -305,15 +305,15 @@ DWORD_PTR __cdecl CYahooProto::GetCaps(int type, MCONTACT hContact) case PFLAGNUM_3:
return PF2_ONLINE | PF2_SHORTAWAY | PF2_LONGAWAY | PF2_ONTHEPHONE |
- PF2_OUTTOLUNCH | PF2_LIGHTDND ;
+ PF2_OUTTOLUNCH | PF2_LIGHTDND;
case PFLAGNUM_4:
return PF4_FORCEAUTH | PF4_FORCEADDED | PF4_SUPPORTTYPING | PF4_SUPPORTIDLE
- |PF4_AVATARS | PF4_OFFLINEFILES | PF4_IMSENDOFFLINE /* for Meta plugin*/;
+ | PF4_AVATARS | PF4_OFFLINEFILES | PF4_IMSENDOFFLINE /* for Meta plugin*/;
case PFLAG_UNIQUEIDTEXT:
- return (DWORD_PTR) Translate("ID");
+ return (DWORD_PTR)Translate("ID");
case PFLAG_UNIQUEIDSETTING:
- return (DWORD_PTR) YAHOO_LOGINID;
+ return (DWORD_PTR)YAHOO_LOGINID;
case PFLAG_MAXLENOFMESSAGE:
return 800; /* STUPID YAHOO!!! */
default:
@@ -330,7 +330,7 @@ void __cdecl CYahooProto::get_info_thread(void *hContact) ProtoBroadcastAck((MCONTACT)hContact, ACKTYPE_GETINFO, ACKRESULT_SUCCESS, (HANDLE)1, 0);
}
-int __cdecl CYahooProto::GetInfo(MCONTACT hContact, int /*infoType*/ )
+int __cdecl CYahooProto::GetInfo(MCONTACT hContact, int /*infoType*/)
{
ForkThread(&CYahooProto::get_info_thread, (void*)hContact);
return 0;
@@ -406,7 +406,7 @@ int __cdecl CYahooProto::SetStatus(int iNewStatus) db_free(&dbv);
}
- else {
+ else {
ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_WRONGPASSWORD);
err++;
}
@@ -594,7 +594,7 @@ INT_PTR __cdecl CYahooProto::GetMyAwayMsg(WPARAM wParam, LPARAM lParam) if (!m_bLoggedIn || !m_startMsg)
return 0;
- if (lParam & SGMA_UNICODE) {
+ if (lParam & SGMA_UNICODE) {
return (INT_PTR)mir_utf8decodeW(m_startMsg);
}
else {
@@ -692,8 +692,7 @@ INT_PTR CALLBACK first_run_dialog(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM return TRUE;
}
- if (HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus())
- {
+ if (HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus()) {
switch (LOWORD(wParam)) {
case IDC_HANDLE:
case IDC_PASSWORD:
@@ -709,12 +708,12 @@ INT_PTR CALLBACK first_run_dialog(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM bool reconnectRequired = false;
GetDlgItemTextA(hwndDlg, IDC_HANDLE, str, SIZEOF(str));
-
+
if (ppro->getString(YAHOO_LOGINID, &dbv)) {
reconnectRequired = true;
}
else {
- if(mir_strcmp(str, dbv.pszVal))
+ if (mir_strcmp(str, dbv.pszVal))
reconnectRequired = true;
db_free(&dbv);
}
@@ -726,7 +725,7 @@ INT_PTR CALLBACK first_run_dialog(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM reconnectRequired = true;
}
else {
- if(mir_strcmp(str, dbv.pszVal))
+ if (mir_strcmp(str, dbv.pszVal))
reconnectRequired = true;
db_free(&dbv);
}
diff --git a/protocols/Yahoo/src/search.cpp b/protocols/Yahoo/src/search.cpp index e914dacec4..b0ab4bae82 100644 --- a/protocols/Yahoo/src/search.cpp +++ b/protocols/Yahoo/src/search.cpp @@ -22,10 +22,10 @@ void __cdecl CYahooProto::search_simplethread(void *snsearch)
{
- TCHAR *id = (TCHAR *) snsearch;
+ TCHAR *id = (TCHAR *)snsearch;
if (mir_tstrlen(id) < 4) {
- ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE) 1, 0);
+ ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)1, 0);
MessageBoxA(NULL, "Please enter a valid ID to search for.", "Search", MB_OK);
return;
}
@@ -40,22 +40,22 @@ void __cdecl CYahooProto::search_simplethread(void *snsearch) psr.id.t = (TCHAR*)_tcslwr(id);
psr.protocol = YAHOO_IM_YAHOO;
- ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE) 1, (LPARAM) & psr);
+ ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)1, (LPARAM)& psr);
//yahoo_search(m_id, YAHOO_SEARCH_YID, m, YAHOO_GENDER_NONE, YAHOO_AGERANGE_NONE, 0, 1);
- ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE) 1, 0);
+ ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)1, 0);
}
-HANDLE __cdecl CYahooProto::SearchBasic( const TCHAR* nick )
+HANDLE __cdecl CYahooProto::SearchBasic(const TCHAR* nick)
{
LOG(("[YahooBasicSearch] Searching for: %S", nick));
-
- if ( !m_bLoggedIn )
+
+ if (!m_bLoggedIn)
return 0;
- ForkThread(&CYahooProto::search_simplethread, _tcsdup( nick ));
- return ( HANDLE )1;
+ ForkThread(&CYahooProto::search_simplethread, _tcsdup(nick));
+ return (HANDLE)1;
}
////////////////////////////////////////////////////////////////////////////////////////
@@ -63,61 +63,52 @@ HANDLE __cdecl CYahooProto::SearchBasic( const TCHAR* nick ) void CYahooProto::ext_got_search_result(int found, int start, int total, YList *contacts)
{
- struct yahoo_found_contact *yct=NULL;
- int i=start;
- YList *en=contacts;
+ struct yahoo_found_contact *yct = NULL;
+ int i = start;
+ YList *en = contacts;
LOG(("got search result: "));
-
+
LOG(("Found: %d", found));
LOG(("Start: %d", start));
LOG(("Total: %d", total));
-
+
YAHOO_SEARCH_RESULT psr;
memset(&psr, 0, sizeof(psr));
psr.cbSize = sizeof(psr);
- psr.flags = PSR_TCHAR;
+ psr.flags = PSR_UTF8;
psr.protocol = YAHOO_IM_YAHOO;
-
- while (en) {
- yct = ( yahoo_found_contact* )en->data;
+ while (en) {
+ yct = (yahoo_found_contact*)en->data;
if (yct == NULL) {
- LOG(("[%d] Empty record?",i++));
- } else {
+ LOG(("[%d] Empty record?", i++));
+ }
+ else {
LOG(("[%d] id: '%s', online: %d, age: %d, sex: '%s', location: '%s'", i++, yct->id, yct->online, yct->age, yct->gender, yct->location));
- psr.id.t = mir_utf8decodeT( yct->id );
-
- if (yct->gender[0] != 5)
- psr.firstName.t = mir_utf8decodeT( yct->gender );
- else
- psr.firstName.t = NULL;
-
- TCHAR c[10];
+ psr.id.a = yct->id;
+
+ if (yct->gender[0] != 5) {
+ psr.firstName.a = yct->gender;
+ psr.email.a = yct->location;
+ }
+ else psr.firstName.a = psr.email.a = NULL;
+
+ char c[10];
if (yct->age > 0) {
- _itot(yct->age, c,10);
- psr.lastName.t = ( TCHAR* )c;
+ _itoa(yct->age, c, 10);
+ psr.lastName.a = c;
}
- else
- psr.lastName.t = NULL;
-
- if (yct->location[0] != 5)
- psr.email.t = mir_utf8decodeT( yct->location );
- else
- psr.email.t = NULL;
-
- //void yahoo_search(int id, enum yahoo_search_type t, const char *text, enum yahoo_search_gender g, enum yahoo_search_agerange ar,
- // int photo, int yahoo_only)
+ else psr.lastName.a = NULL;
- ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE) 1, (LPARAM) & psr);
+ // void yahoo_search(int id, enum yahoo_search_type t, const char *text, enum yahoo_search_gender g, enum yahoo_search_agerange ar,
+ // int photo, int yahoo_only)
- mir_free(psr.id.t);
- mir_free(psr.firstName.t);
- mir_free(psr.email.t);
+ ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)1, (LPARAM)& psr);
}
en = y_list_next(en);
}
- ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE) 1, 0);
+ ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)1, 0);
}
/*
@@ -128,25 +119,26 @@ void CYahooProto::ext_got_search_result(int found, int start, int total, YList * static INT_PTR CALLBACK YahooSearchAdvancedDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch ( msg ) {
+ switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
-
+
SendDlgItemMessageA(hwndDlg, IDC_SEARCH_PROTOCOL, CB_ADDSTRING, 0, (LPARAM)"Yahoo! Messenger");
SendDlgItemMessageA(hwndDlg, IDC_SEARCH_PROTOCOL, CB_ADDSTRING, 0, (LPARAM)"Lotus Sametime");
SendDlgItemMessageA(hwndDlg, IDC_SEARCH_PROTOCOL, CB_ADDSTRING, 0, (LPARAM)"LCS");
SendDlgItemMessageA(hwndDlg, IDC_SEARCH_PROTOCOL, CB_ADDSTRING, 0, (LPARAM)"Windows Live (MSN)");
-
+
// select the first one
SendDlgItemMessage(hwndDlg, IDC_SEARCH_PROTOCOL, CB_SETCURSEL, 0, 0);
return TRUE;
+
case WM_COMMAND:
- if(LOWORD(wParam)==IDC_SEARCH_ID && HIWORD(wParam)==EN_CHANGE){
- PostMessage(GetParent(hwndDlg),WM_COMMAND, MAKEWPARAM(0,EN_SETFOCUS), (LPARAM)hwndDlg);
+ if (LOWORD(wParam) == IDC_SEARCH_ID && HIWORD(wParam) == EN_CHANGE) {
+ PostMessage(GetParent(hwndDlg), WM_COMMAND, MAKEWPARAM(0, EN_SETFOCUS), (LPARAM)hwndDlg);
return TRUE;
}
- if(LOWORD(wParam)==IDC_SEARCH_PROTOCOL && HIWORD(wParam)==CBN_SELCHANGE){
- PostMessage(GetParent(hwndDlg),WM_COMMAND, MAKEWPARAM(0,EN_SETFOCUS), (LPARAM)hwndDlg);
+ if (LOWORD(wParam) == IDC_SEARCH_PROTOCOL && HIWORD(wParam) == CBN_SELCHANGE) {
+ PostMessage(GetParent(hwndDlg), WM_COMMAND, MAKEWPARAM(0, EN_SETFOCUS), (LPARAM)hwndDlg);
return TRUE;
}
break;
@@ -154,35 +146,35 @@ static INT_PTR CALLBACK YahooSearchAdvancedDlgProc(HWND hwndDlg, UINT msg, WPARA return FALSE;
}
-HWND __cdecl CYahooProto::CreateExtendedSearchUI( HWND parent )
+HWND __cdecl CYahooProto::CreateExtendedSearchUI(HWND parent)
{
- if ( parent && hInstance )
- return CreateDialogParam( hInstance, MAKEINTRESOURCE(IDD_SEARCHUSER), parent, YahooSearchAdvancedDlgProc, (LPARAM)this );
+ if (parent && hInstance)
+ return CreateDialogParam(hInstance, MAKEINTRESOURCE(IDD_SEARCHUSER), parent, YahooSearchAdvancedDlgProc, (LPARAM)this);
return 0;
}
void __cdecl CYahooProto::searchadv_thread(void *pHWND)
{
- HWND hwndDlg = (HWND) pHWND;
+ HWND hwndDlg = (HWND)pHWND;
TCHAR searchid[128];
GetDlgItemText(hwndDlg, IDC_SEARCH_ID, searchid, SIZEOF(searchid));
if (mir_tstrlen(searchid) == 0) {
- ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE) 1, 0);
+ ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)1, 0);
MessageBoxA(NULL, "Please enter a valid ID to search for.", "Search", MB_OK);
return;
- }
+ }
YAHOO_SEARCH_RESULT psr;
memset(&psr, 0, sizeof(psr));
psr.cbSize = sizeof(psr);
- psr.flags = PSR_TCHAR;
+ psr.flags = PSR_UNICODE;
psr.id.t = _tcslwr(searchid);
switch (SendDlgItemMessage(hwndDlg, IDC_SEARCH_PROTOCOL, CB_GETCURSEL, 0, 0)) {
- case 0: psr.firstName.t = _T("<Yahoo >"); psr.protocol = YAHOO_IM_YAHOO; break;
+ case 0: psr.firstName.t = _T("<Yahoo>"); psr.protocol = YAHOO_IM_YAHOO; break;
case 1: psr.firstName.t = _T("<Lotus Sametime>"); psr.protocol = YAHOO_IM_SAMETIME; break;
case 2: psr.firstName.t = _T("<LCS>"); psr.protocol = YAHOO_IM_LCS; break;
case 3: psr.firstName.t = _T("<Windows Live (MSN)>"); psr.protocol = YAHOO_IM_MSN; break;
@@ -191,12 +183,12 @@ void __cdecl CYahooProto::searchadv_thread(void *pHWND) /*
* Show this in results
*/
- ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE) 1, (LPARAM) & psr);
+ ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)1, (LPARAM)& psr);
/*
* Done searching.
*/
- ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE) 1, 0);
+ ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)1, 0);
}
/*
@@ -205,13 +197,13 @@ void __cdecl CYahooProto::searchadv_thread(void *pHWND) * Returns: 0 on failure or HWND on success
*/
-HWND __cdecl CYahooProto::SearchAdvanced( HWND owner )
+HWND __cdecl CYahooProto::SearchAdvanced(HWND owner)
{
LOG(("[YahooAdvancedSearch]"));
- if ( !m_bLoggedIn )
+ if (!m_bLoggedIn)
return 0;
- ForkThread( &CYahooProto::searchadv_thread, owner );
- return ( HWND )1;
+ ForkThread(&CYahooProto::searchadv_thread, owner);
+ return (HWND)1;
}
diff --git a/protocols/Yahoo/src/server.cpp b/protocols/Yahoo/src/server.cpp index aaaac11341..c9b742fb2a 100644 --- a/protocols/Yahoo/src/server.cpp +++ b/protocols/Yahoo/src/server.cpp @@ -37,7 +37,7 @@ int PASCAL recv(SOCKET s, char FAR *buf, int len, int flags) if (RecvResult == 0) {
LOG(("[recv] Connection closed gracefully."));
return 0;
- }
+ }
if (RecvResult == SOCKET_ERROR) {
LOG(("[recv] Connection abortively closed"));
return -1;
@@ -51,13 +51,13 @@ void __cdecl CYahooProto::server_main(void *empty) enum yahoo_status status = (enum yahoo_status) (int)empty;
time_t lLastPing, lLastKeepAlive, t;
YList *l;
- NETLIBSELECTEX nls = {0};
+ NETLIBSELECTEX nls = { 0 };
int recvResult, ridx = 0, widx = 0, i;
debugLogA("Server Thread Starting status: %d", status);
- do_yahoo_debug=YAHOO_LOG_DEBUG;
- yahoo_set_log_level(( yahoo_log_level )do_yahoo_debug);
+ do_yahoo_debug = YAHOO_LOG_DEBUG;
+ yahoo_set_log_level((yahoo_log_level)do_yahoo_debug);
poll_loop = 1; /* set this so we start looping */
@@ -73,10 +73,10 @@ void __cdecl CYahooProto::server_main(void *empty) FD_ZERO(&nls.hWriteStatus);
FD_ZERO(&nls.hExceptStatus);
nls.hExceptConns[0] = NULL;
- ridx = 0; widx = 0;
+ ridx = 0; widx = 0;
- for(l=m_connections; l; ) {
- struct _conn *c = ( _conn * )l->data;
+ for (l = m_connections; l;) {
+ struct _conn *c = (_conn *)l->data;
//LOG(("Connection tag:%d id:%d fd:%d remove:%d", c->tag, c->id, c->fd, c->remove));
if (c->remove) {
YList *n = y_list_next(l);
@@ -84,8 +84,9 @@ void __cdecl CYahooProto::server_main(void *empty) m_connections = y_list_remove_link(m_connections, l);
y_list_free_1(l);
FREE(c);
- l=n;
- } else {
+ l = n;
+ }
+ else {
if (c->cond & YAHOO_INPUT_READ) {
//LOG(("[YAHOO_INPUT_READ] Waiting on read. Tag: %d fd: %d", c->tag, c->fd ));
nls.hReadConns[ridx++] = (HANDLE)c->fd;
@@ -93,7 +94,7 @@ void __cdecl CYahooProto::server_main(void *empty) if (c->cond & YAHOO_INPUT_WRITE) {
//LOG(("[YAHOO_INPUT_WRITE] Waiting on write. Tag: %d fd: %d", c->tag, c->fd ));
- nls.hWriteConns[widx++] =(HANDLE) c->fd;
+ nls.hWriteConns[widx++] = (HANDLE)c->fd;
}
l = y_list_next(l);
@@ -109,7 +110,7 @@ void __cdecl CYahooProto::server_main(void *empty) debugLogA("Last connection closed.");
break;
}
- recvResult = CallService(MS_NETLIB_SELECTEX, (WPARAM) 0, (LPARAM)&nls);
+ recvResult = CallService(MS_NETLIB_SELECTEX, (WPARAM)0, (LPARAM)&nls);
/* do the timer check */
if (m_id > 0) {
@@ -117,7 +118,7 @@ void __cdecl CYahooProto::server_main(void *empty) //debugLogA("HTTPGateway: %d", iHTTPGateway);
if (!iHTTPGateway) {
#endif
- t = time(NULL);
+ t = time(NULL);
if (m_bLoggedIn && t - lLastKeepAlive >= 60) {
LOG(("[TIMER] Sending a keep alive message"));
@@ -140,8 +141,8 @@ void __cdecl CYahooProto::server_main(void *empty) if ( m_bLoggedIn && ( (ylad->rpkts > 0 && (time(NULL) - lLastSend) >=3) ||
( (time(NULL) - lLastSend) >= 13)) ) {
- LOG(("[TIMER] Sending an idle message..."));
- yahoo_send_idle_packet(m_id);
+ LOG(("[TIMER] Sending an idle message..."));
+ yahoo_send_idle_packet(m_id);
}
//
@@ -153,16 +154,16 @@ void __cdecl CYahooProto::server_main(void *empty) }
/* do the timer check ends */
- for(l = m_connections; l; l = y_list_next(l)) {
- struct _conn *c = ( _conn * )l->data;
+ for (l = m_connections; l; l = y_list_next(l)) {
+ struct _conn *c = (_conn *)l->data;
- if (c->remove)
+ if (c->remove)
continue;
/* are we waiting for a Read request? */
if (c->cond & YAHOO_INPUT_READ) {
-
- for (i = 0; i < ridx; i++) {
+
+ for (i = 0; i < ridx; i++) {
if ((HANDLE)c->fd == nls.hReadConns[i]) {
if (nls.hReadStatus[i]) {
//LOG(("[YAHOO_INPUT_READ] Read Ready. Tag: %d fd: %d", c->tag, c->fd ));
@@ -170,13 +171,13 @@ void __cdecl CYahooProto::server_main(void *empty) }
}//if c->fd=
}//for i = 0
-
+
}
/* are we waiting for a Write request? */
if (c->cond & YAHOO_INPUT_WRITE) {
-
- for (i = 0; i < widx; i++) {
+
+ for (i = 0; i < widx; i++) {
if ((HANDLE)c->fd == nls.hWriteConns[i]) {
if (nls.hWriteStatus[i]) {
//LOG(("[YAHOO_INPUT_WRITE] Write ready. Tag: %d fd: %d", c->tag, c->fd ));
@@ -197,9 +198,9 @@ void __cdecl CYahooProto::server_main(void *empty) debugLogA("Exited loop");
/* cleanup the data stuff and close our connection handles */
- while(m_connections) {
+ while (m_connections) {
YList *tmp = m_connections;
- struct _conn * c = ( _conn * )m_connections->data;
+ struct _conn * c = (_conn *)m_connections->data;
Netlib_CloseHandle((HANDLE)c->fd);
FREE(c);
m_connections = y_list_remove_link(m_connections, m_connections);
@@ -208,14 +209,14 @@ void __cdecl CYahooProto::server_main(void *empty) yahoo_close(m_id);
- m_bLoggedIn = FALSE;
+ m_bLoggedIn = FALSE;
m_status = YAHOO_STATUS_OFFLINE;
m_id = 0;
/* now set ourselves to offline */
BroadcastStatus(ID_STATUS_OFFLINE);
- logoff_buddies();
+ logoff_buddies();
debugLogA("Server thread ending");
}
diff --git a/protocols/Yahoo/src/services.cpp b/protocols/Yahoo/src/services.cpp index b6417f83d6..8877bd076b 100644 --- a/protocols/Yahoo/src/services.cpp +++ b/protocols/Yahoo/src/services.cpp @@ -32,7 +32,7 @@ void CYahooProto::logoff_buddies() {
//set all contacts to 'offline'
for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
- setWord( hContact, "Status", ID_STATUS_OFFLINE );
+ setWord(hContact, "Status", ID_STATUS_OFFLINE);
setDword(hContact, "IdleTS", 0);
setDword(hContact, "PictLastCheck", 0);
setDword(hContact, "PictLoading", 0);
@@ -74,7 +74,7 @@ void CYahooProto::BroadcastStatus(int s) debugLogA("[yahoo_util_broadcaststatus] Old Status: %S (%d), New Status: %S (%d)",
pcli->pfnGetStatusModeDescription(oldStatus, 0), oldStatus,
pcli->pfnGetStatusModeDescription(m_iStatus, 0), m_iStatus);
- ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE) oldStatus, (LPARAM)m_iStatus);
+ ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, (LPARAM)m_iStatus);
}
//=======================================================
@@ -84,7 +84,7 @@ int __cdecl CYahooProto::OnContactDeleted(WPARAM hContact, LPARAM lParam) {
debugLogA("[YahooContactDeleted]");
- if (!m_bLoggedIn) {//should never happen for Yahoo contacts
+ if (!m_bLoggedIn) {//should never happen for Yahoo contacts
debugLogA("[YahooContactDeleted] We are not Logged On!!!");
return 0;
}
@@ -116,78 +116,78 @@ static INT_PTR CALLBACK DlgProcSetCustStat(HWND hwndDlg, UINT msg, WPARAM wParam switch (msg) {
case WM_INITDIALOG:
- TranslateDialogDefault(hwndDlg );
+ TranslateDialogDefault(hwndDlg);
{
CYahooProto* ppro = (CYahooProto*)lParam;
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam );
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
- SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)ppro->LoadIconEx("yahoo", true ));
+ SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)ppro->LoadIconEx("yahoo", true));
SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)ppro->LoadIconEx("yahoo"));
- if ( !ppro->getString(YAHOO_CUSTSTATDB, &dbv)) {
- SetDlgItemTextA(hwndDlg, IDC_CUSTSTAT, dbv. pszVal );
+ if (!ppro->getString(YAHOO_CUSTSTATDB, &dbv)) {
+ SetDlgItemTextA(hwndDlg, IDC_CUSTSTAT, dbv.pszVal);
- EnableWindow( GetDlgItem(hwndDlg, IDOK ), mir_strlen(dbv.pszVal) > 0);
+ EnableWindow(GetDlgItem(hwndDlg, IDOK), mir_strlen(dbv.pszVal) > 0);
db_free(&dbv);
}
else {
SetDlgItemTextA(hwndDlg, IDC_CUSTSTAT, "");
- EnableWindow( GetDlgItem(hwndDlg, IDOK ), FALSE );
+ EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE);
}
- CheckDlgButton(hwndDlg, IDC_CUSTSTATBUSY, ppro->getByte("BusyCustStat", 0) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_CUSTSTATBUSY, ppro->getByte("BusyCustStat", 0) ? BST_CHECKED : BST_UNCHECKED);
}
return TRUE;
case WM_COMMAND:
- switch(wParam) {
+ switch (wParam) {
case IDOK:
{
- char str[ 255 + 1 ];
- CYahooProto* ppro = ( CYahooProto* )GetWindowLongPtr(hwndDlg, GWLP_USERDATA );
+ char str[255 + 1];
+ CYahooProto* ppro = (CYahooProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
/* Get String from dialog */
GetDlgItemTextA(hwndDlg, IDC_CUSTSTAT, str, SIZEOF(str));
/* Save it for later use */
- ppro->setString( YAHOO_CUSTSTATDB, str );
- ppro->setByte("BusyCustStat", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_CUSTSTATBUSY ));
+ ppro->setString(YAHOO_CUSTSTATDB, str);
+ ppro->setByte("BusyCustStat", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_CUSTSTATBUSY));
/* set for Idle/AA */
if (ppro->m_startMsg) mir_free(ppro->m_startMsg);
ppro->m_startMsg = mir_strdup(str);
/* notify Server about status change */
- ppro->set_status(YAHOO_CUSTOM_STATUS, str, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_CUSTSTATBUSY ));
+ ppro->set_status(YAHOO_CUSTOM_STATUS, str, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_CUSTSTATBUSY));
/* change local/miranda status */
- ppro->BroadcastStatus((BYTE)IsDlgButtonChecked(hwndDlg, IDC_CUSTSTATBUSY ) ? ID_STATUS_AWAY : ID_STATUS_ONLINE);
+ ppro->BroadcastStatus((BYTE)IsDlgButtonChecked(hwndDlg, IDC_CUSTSTATBUSY) ? ID_STATUS_AWAY : ID_STATUS_ONLINE);
}
case IDCANCEL:
- DestroyWindow(hwndDlg );
+ DestroyWindow(hwndDlg);
break;
}
- if ( HIWORD( wParam ) == EN_CHANGE && ( HWND )lParam == GetFocus()) {
- if (LOWORD( wParam ) == IDC_CUSTSTAT) {
- char str[ 255 + 1 ];
+ if (HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus()) {
+ if (LOWORD(wParam) == IDC_CUSTSTAT) {
+ char str[255 + 1];
BOOL toSet;
toSet = GetDlgItemTextA(hwndDlg, IDC_CUSTSTAT, str, SIZEOF(str)) != 0;
- EnableWindow( GetDlgItem(hwndDlg, IDOK ), toSet );
+ EnableWindow(GetDlgItem(hwndDlg, IDOK), toSet);
}
}
break; /* case WM_COMMAND */
case WM_CLOSE:
- DestroyWindow(hwndDlg );
+ DestroyWindow(hwndDlg);
break;
case WM_DESTROY:
{
- CYahooProto* ppro = ( CYahooProto* )GetWindowLongPtr(hwndDlg, GWLP_USERDATA );
+ CYahooProto* ppro = (CYahooProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
ppro->ReleaseIconEx("yahoo", true);
ppro->ReleaseIconEx("yahoo");
}
@@ -196,17 +196,17 @@ static INT_PTR CALLBACK DlgProcSetCustStat(HWND hwndDlg, UINT msg, WPARAM wParam return FALSE;
}
-INT_PTR __cdecl CYahooProto::SetCustomStatCommand( WPARAM wParam, LPARAM lParam )
+INT_PTR __cdecl CYahooProto::SetCustomStatCommand(WPARAM wParam, LPARAM lParam)
{
- if ( !m_bLoggedIn ) {
- ShowNotification( TranslateT("Yahoo Error"), TranslateT("You need to be connected to set the custom message"), NIIF_ERROR);
+ if (!m_bLoggedIn) {
+ ShowNotification(TranslateT("Yahoo Error"), TranslateT("You need to be connected to set the custom message"), NIIF_ERROR);
return 0;
}
- HWND hwndSetCustomStatus = CreateDialogParam(hInstance, MAKEINTRESOURCE( IDD_SETCUSTSTAT ), NULL, DlgProcSetCustStat, (LPARAM)this );
- SetForegroundWindow( hwndSetCustomStatus );
- SetFocus( hwndSetCustomStatus );
- ShowWindow( hwndSetCustomStatus, SW_SHOW );
+ HWND hwndSetCustomStatus = CreateDialogParam(hInstance, MAKEINTRESOURCE(IDD_SETCUSTSTAT), NULL, DlgProcSetCustStat, (LPARAM)this);
+ SetForegroundWindow(hwndSetCustomStatus);
+ SetFocus(hwndSetCustomStatus);
+ ShowWindow(hwndSetCustomStatus, SW_SHOW);
return 0;
}
@@ -215,7 +215,7 @@ INT_PTR __cdecl CYahooProto::SetCustomStatCommand( WPARAM wParam, LPARAM lParam //=======================================================
void CYahooProto::OpenURL(const char *url, int autoLogin)
{
- char tUrl[ 4096 ];
+ char tUrl[4096];
debugLogA("[YahooOpenURL] url: %s Auto Login: %d", url, autoLogin);
@@ -226,13 +226,14 @@ void CYahooProto::OpenURL(const char *url, int autoLogin) t = yahoo_urlencode(yahoo_get_cookie(m_id, "t"));
u = yahoo_urlencode(url);
mir_snprintf(tUrl, SIZEOF(tUrl),
- "http://msg.edit.yahoo.com/config/reset_cookies?&.y=Y=%s&.t=T=%s&.ver=2&.done=http%%3a//us.rd.yahoo.com/messenger/client/%%3f%s",
- y, t, u);
+ "http://msg.edit.yahoo.com/config/reset_cookies?&.y=Y=%s&.t=T=%s&.ver=2&.done=http%%3a//us.rd.yahoo.com/messenger/client/%%3f%s",
+ y, t, u);
FREE(y);
FREE(t);
FREE(u);
- } else {
+ }
+ else {
mir_snprintf(tUrl, SIZEOF(tUrl), url);
}
@@ -266,7 +267,7 @@ INT_PTR __cdecl CYahooProto::OnShowProfileCommand(WPARAM wParam, LPARAM lParam) return 0;
}
-INT_PTR __cdecl CYahooProto::OnEditMyProfile( WPARAM wParam, LPARAM lParam )
+INT_PTR __cdecl CYahooProto::OnEditMyProfile(WPARAM wParam, LPARAM lParam)
{
OpenURL("http://edit.yahoo.com/config/eval_profile", 1);
return 0;
@@ -275,16 +276,16 @@ INT_PTR __cdecl CYahooProto::OnEditMyProfile( WPARAM wParam, LPARAM lParam ) //=======================================================
//Show My profile
//=======================================================
-INT_PTR __cdecl CYahooProto::OnShowMyProfileCommand( WPARAM wParam, LPARAM lParam )
+INT_PTR __cdecl CYahooProto::OnShowMyProfileCommand(WPARAM wParam, LPARAM lParam)
{
DBVARIANT dbv;
- if ( getString( YAHOO_LOGINID, &dbv) != 0) {
- ShowError( TranslateT("Yahoo Error"), TranslateT("Please enter your Yahoo ID in Options/Network/Yahoo"));
+ if (getString(YAHOO_LOGINID, &dbv) != 0) {
+ ShowError(TranslateT("Yahoo Error"), TranslateT("Please enter your Yahoo ID in Options/Network/Yahoo"));
return 0;
}
- char tUrl[ 4096 ];
+ char tUrl[4096];
mir_snprintf(tUrl, SIZEOF(tUrl), "http://profiles.yahoo.com/%s", dbv.pszVal);
db_free(&dbv);
@@ -295,7 +296,7 @@ INT_PTR __cdecl CYahooProto::OnShowMyProfileCommand( WPARAM wParam, LPARAM lPara //=======================================================
//Show Goto mailbox
//=======================================================
-INT_PTR __cdecl CYahooProto::OnGotoMailboxCommand( WPARAM wParam, LPARAM lParam )
+INT_PTR __cdecl CYahooProto::OnGotoMailboxCommand(WPARAM wParam, LPARAM lParam)
{
if (getByte("YahooJapan", 0))
OpenURL("http://mail.yahoo.co.jp/", 1);
@@ -305,13 +306,13 @@ INT_PTR __cdecl CYahooProto::OnGotoMailboxCommand( WPARAM wParam, LPARAM lParam return 0;
}
-INT_PTR __cdecl CYahooProto::OnABCommand( WPARAM wParam, LPARAM lParam )
+INT_PTR __cdecl CYahooProto::OnABCommand(WPARAM wParam, LPARAM lParam)
{
OpenURL("http://address.yahoo.com/yab/", 1);
return 0;
}
-INT_PTR __cdecl CYahooProto::OnCalendarCommand( WPARAM wParam, LPARAM lParam )
+INT_PTR __cdecl CYahooProto::OnCalendarCommand(WPARAM wParam, LPARAM lParam)
{
OpenURL("http://calendar.yahoo.com/", 1);
return 0;
@@ -320,9 +321,9 @@ INT_PTR __cdecl CYahooProto::OnCalendarCommand( WPARAM wParam, LPARAM lParam ) //=======================================================
//Refresh Yahoo
//=======================================================
-INT_PTR __cdecl CYahooProto::OnRefreshCommand( WPARAM wParam, LPARAM lParam )
+INT_PTR __cdecl CYahooProto::OnRefreshCommand(WPARAM wParam, LPARAM lParam)
{
- if ( !m_bLoggedIn ) {
+ if (!m_bLoggedIn) {
ShowNotification(TranslateT("Yahoo Error"), TranslateT("You need to be connected to refresh your buddy list"), NIIF_ERROR);
return 0;
}
@@ -335,9 +336,9 @@ int __cdecl CYahooProto::OnIdleEvent(WPARAM wParam, LPARAM lParam) {
BOOL bIdle = (lParam & IDF_ISIDLE);
- debugLogA("[YAHOO_IDLE_EVENT] Idle: %s", bIdle ?"Yes":"No");
+ debugLogA("[YAHOO_IDLE_EVENT] Idle: %s", bIdle ? "Yes" : "No");
- if ( lParam & IDF_PRIVACY )
+ if (lParam & IDF_PRIVACY)
return 0; /* we support Privacy settings */
if (m_bLoggedIn) {
@@ -345,8 +346,9 @@ int __cdecl CYahooProto::OnIdleEvent(WPARAM wParam, LPARAM lParam) if (m_iStatus == ID_STATUS_INVISIBLE)
debugLogA("[YAHOO_IDLE_EVENT] WARNING: INVISIBLE! Don't change my status!");
else
- set_status(m_iStatus,m_startMsg,(bIdle) ? 2 : (m_iStatus == ID_STATUS_ONLINE) ? 0 : 1);
- } else {
+ set_status(m_iStatus, m_startMsg, (bIdle) ? 2 : (m_iStatus == ID_STATUS_ONLINE) ? 0 : 1);
+ }
+ else {
debugLogA("[YAHOO_IDLE_EVENT] WARNING: NOT LOGGED IN???");
}
@@ -355,7 +357,7 @@ int __cdecl CYahooProto::OnIdleEvent(WPARAM wParam, LPARAM lParam) INT_PTR __cdecl CYahooProto::GetUnreadEmailCount(WPARAM wParam, LPARAM lParam)
{
- if ( !m_bLoggedIn )
+ if (!m_bLoggedIn)
return 0;
return m_unreadMessages;
@@ -363,21 +365,21 @@ INT_PTR __cdecl CYahooProto::GetUnreadEmailCount(WPARAM wParam, LPARAM lParam) /////////////////////////////////////////////////////////////////////////////////////////
-void CYahooProto::MenuMainInit( void )
+void CYahooProto::MenuMainInit(void)
{
- char servicefunction[ 100 ];
- mir_strcpy( servicefunction, m_szModuleName);
- char* tDest = servicefunction + mir_strlen( servicefunction );
+ char servicefunction[100];
+ mir_strcpy(servicefunction, m_szModuleName);
+ char* tDest = servicefunction + mir_strlen(servicefunction);
CLISTMENUITEM mi = { sizeof(mi) };
mi.pszService = servicefunction;
- HGENMENU hRoot = MO_GetProtoRootMenu( m_szModuleName);
- if ( hRoot == NULL) {
+ HGENMENU hRoot = MO_GetProtoRootMenu(m_szModuleName);
+ if (hRoot == NULL) {
mi.position = 500015000;
mi.hParentMenu = HGENMENU_ROOT;
mi.flags = CMIF_ROOTPOPUP | CMIF_TCHAR | CMIF_KEEPUNTRANSLATED;
- mi.icolibItem = GetIconHandle( IDI_YAHOO );
+ mi.icolibItem = GetIconHandle(IDI_YAHOO);
mi.ptszName = m_tszUserName;
hRoot = mainMenuRoot = Menu_AddProtoMenuItem(&mi);
}
@@ -391,39 +393,39 @@ void CYahooProto::MenuMainInit( void ) mi.hParentMenu = hRoot;
// Show custom status menu
- mir_strcpy( tDest, YAHOO_SET_CUST_STAT );
+ mir_strcpy(tDest, YAHOO_SET_CUST_STAT);
CreateProtoService(YAHOO_SET_CUST_STAT, &CYahooProto::SetCustomStatCommand);
mi.position = 290000;
- mi.icolibItem = GetIconHandle( IDI_SET_STATUS );
+ mi.icolibItem = GetIconHandle(IDI_SET_STATUS);
mi.pszName = LPGEN("Set &Custom Status");
menuItemsAll[0] = Menu_AddProtoMenuItem(&mi);
// Edit My profile
- mir_strcpy( tDest, YAHOO_EDIT_MY_PROFILE );
+ mir_strcpy(tDest, YAHOO_EDIT_MY_PROFILE);
CreateProtoService(YAHOO_EDIT_MY_PROFILE, &CYahooProto::OnEditMyProfile);
mi.position = 290005;
- mi.icolibItem = GetIconHandle( IDI_PROFILE );
+ mi.icolibItem = GetIconHandle(IDI_PROFILE);
mi.pszName = LPGEN("&Edit My Profile");
menuItemsAll[1] = Menu_AddProtoMenuItem(&mi);
// Show My profile
- mir_strcpy( tDest, YAHOO_SHOW_MY_PROFILE );
+ mir_strcpy(tDest, YAHOO_SHOW_MY_PROFILE);
CreateProtoService(YAHOO_SHOW_MY_PROFILE, &CYahooProto::OnShowMyProfileCommand);
mi.position = 290006;
- mi.icolibItem = GetIconHandle( IDI_PROFILE );
+ mi.icolibItem = GetIconHandle(IDI_PROFILE);
mi.pszName = LPGEN("&My Profile");
menuItemsAll[2] = Menu_AddProtoMenuItem(&mi);
// Show Yahoo mail
- mir_strcpy( tDest, YAHOO_YAHOO_MAIL );
+ mir_strcpy(tDest, YAHOO_YAHOO_MAIL);
CreateProtoService(YAHOO_YAHOO_MAIL, &CYahooProto::OnGotoMailboxCommand);
mi.position = 290010;
- mi.icolibItem = GetIconHandle( IDI_INBOX );
+ mi.icolibItem = GetIconHandle(IDI_INBOX);
mi.pszName = LPGEN("&Yahoo Mail");
menuItemsAll[3] = Menu_AddProtoMenuItem(&mi);
@@ -432,19 +434,19 @@ void CYahooProto::MenuMainInit( void ) CreateProtoService(YAHOO_AB, &CYahooProto::OnABCommand);
mi.position = 290015;
- mi.icolibItem = GetIconHandle( IDI_YAB );
+ mi.icolibItem = GetIconHandle(IDI_YAB);
mi.pszName = LPGEN("&Address Book");
menuItemsAll[4] = Menu_AddProtoMenuItem(&mi);
// Show Calendar
- mir_strcpy( tDest, YAHOO_CALENDAR );
+ mir_strcpy(tDest, YAHOO_CALENDAR);
CreateProtoService(YAHOO_CALENDAR, &CYahooProto::OnCalendarCommand);
mi.position = 290017;
- mi.icolibItem = GetIconHandle( IDI_CALENDAR );
+ mi.icolibItem = GetIconHandle(IDI_CALENDAR);
mi.pszName = LPGEN("&Calendar");
menuItemsAll[5] = Menu_AddProtoMenuItem(&mi);
- mir_strcpy( tDest, "/JoinChatRoom");
+ mir_strcpy(tDest, "/JoinChatRoom");
CreateProtoService("/JoinChatRoom", &CYahooProto::CreateConference);
mi.position = 290018;
@@ -453,28 +455,28 @@ void CYahooProto::MenuMainInit( void ) menuItemsAll[6] = Menu_AddProtoMenuItem(&mi);
}
-void CYahooProto::MenuContactInit( void )
+void CYahooProto::MenuContactInit(void)
{
- char servicefunction[ 100 ];
- mir_strcpy( servicefunction, m_szModuleName);
- char* tDest = servicefunction + mir_strlen( servicefunction );
+ char servicefunction[100];
+ mir_strcpy(servicefunction, m_szModuleName);
+ char* tDest = servicefunction + mir_strlen(servicefunction);
CLISTMENUITEM mi = { sizeof(mi) };
mi.pszService = servicefunction;
mi.pszContactOwner = m_szModuleName;
// Show Profile
- mir_strcpy( tDest, YAHOO_SHOW_PROFILE );
- CreateProtoService(YAHOO_SHOW_PROFILE, &CYahooProto::OnShowProfileCommand );
+ mir_strcpy(tDest, YAHOO_SHOW_PROFILE);
+ CreateProtoService(YAHOO_SHOW_PROFILE, &CYahooProto::OnShowProfileCommand);
mi.position = -2000006000;
- mi.icolibItem = GetIconHandle( IDI_PROFILE );
+ mi.icolibItem = GetIconHandle(IDI_PROFILE);
mi.pszName = LPGEN("&Show Profile");
hShowProfileMenuItem = Menu_AddContactMenuItem(&mi);
}
-void CYahooProto::MenuUninit( void )
+void CYahooProto::MenuUninit(void)
{
if (mainMenuRoot)
CallService(MO_REMOVEMENUITEM, (WPARAM)mainMenuRoot, 0);
@@ -497,7 +499,7 @@ int __cdecl CYahooProto::OnPrebuildContactMenu(WPARAM hContact, LPARAM) //=======================================================================================
// Load the yahoo service/plugin
//=======================================================================================
-void CYahooProto::LoadYahooServices( void )
+void CYahooProto::LoadYahooServices(void)
{
//----| Events hooking |--------------------------------------------------------------
HookProtoEvent(ME_OPT_INITIALISE, &CYahooProto::OnOptionsInit);
@@ -509,12 +511,12 @@ void CYahooProto::LoadYahooServices( void ) CreateProtoService(PS_CREATEACCMGRUI, &CYahooProto::SvcCreateAccMgrUI);
CreateProtoService(PS_GETAVATARINFO, &CYahooProto::GetAvatarInfo);
- CreateProtoService(PS_GETMYAVATAR, &CYahooProto::GetMyAvatar);
- CreateProtoService(PS_SETMYAVATAR, &CYahooProto::SetMyAvatar);
- CreateProtoService(PS_GETAVATARCAPS, &CYahooProto::GetAvatarCaps);
+ CreateProtoService(PS_GETMYAVATAR, &CYahooProto::GetMyAvatar);
+ CreateProtoService(PS_SETMYAVATAR, &CYahooProto::SetMyAvatar);
+ CreateProtoService(PS_GETAVATARCAPS, &CYahooProto::GetAvatarCaps);
- CreateProtoService(PS_GETMYAWAYMSG, &CYahooProto::GetMyAwayMsg);
- CreateProtoService(PS_SEND_NUDGE, &CYahooProto::SendNudge);
+ CreateProtoService(PS_GETMYAWAYMSG, &CYahooProto::GetMyAwayMsg);
+ CreateProtoService(PS_SEND_NUDGE, &CYahooProto::SendNudge);
CreateProtoService(PS_GETUNREADEMAILCOUNT, &CYahooProto::GetUnreadEmailCount);
diff --git a/protocols/Yahoo/src/user_info.cpp b/protocols/Yahoo/src/user_info.cpp index cb5cf88283..f7f4e47c82 100644 --- a/protocols/Yahoo/src/user_info.cpp +++ b/protocols/Yahoo/src/user_info.cpp @@ -21,12 +21,12 @@ #include <commctrl.h>
-static INT_PTR CALLBACK YahooUserInfoDlgProc( HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam )
+static INT_PTR CALLBACK YahooUserInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch ( msg ) {
+ switch (msg) {
case WM_INITDIALOG:
// lParam is hContact
- TranslateDialogDefault(hwndDlg );
+ TranslateDialogDefault(hwndDlg);
//SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadSkinnedIcon(SKINICON_OTHER_USERDETAILS));
@@ -34,10 +34,10 @@ static INT_PTR CALLBACK YahooUserInfoDlgProc( HWND hwndDlg, UINT msg, WPARAM wPa break;
case WM_NOTIFY:
- if (( ( LPNMHDR )lParam )->idFrom == 0) {
- switch (( ( LPNMHDR )lParam )->code ) {
+ if (((LPNMHDR)lParam)->idFrom == 0) {
+ switch (((LPNMHDR)lParam)->code) {
case PSN_PARAMCHANGED:
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (( PSHNOTIFY* )lParam )->lParam );
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, ((PSHNOTIFY*)lParam)->lParam);
break;
case PSN_INFOCHANGED:
{
@@ -51,7 +51,8 @@ static INT_PTR CALLBACK YahooUserInfoDlgProc( HWND hwndDlg, UINT msg, WPARAM wPa if (hContact == NULL) {
szProto = ppro->m_szModuleName;
- } else {
+ }
+ else {
szProto = GetContactProto(hContact);
}
@@ -62,34 +63,38 @@ static INT_PTR CALLBACK YahooUserInfoDlgProc( HWND hwndDlg, UINT msg, WPARAM wPa DBVARIANT dbv;
char z[128];
- if (ppro->getString( hContact, YAHOO_LOGINID, &dbv) == 0) {
+ if (ppro->getString(hContact, YAHOO_LOGINID, &dbv) == 0) {
mir_strcpy(z, dbv.pszVal);
db_free(&dbv);
- } else {
+ }
+ else {
mir_strcpy(z, "???");
}
SetDlgItemTextA(hwndDlg, IDC_SEARCH_ID, z);
- if (ppro->getString( hContact, "Transport", &dbv) == 0) {
+ if (ppro->getString(hContact, "Transport", &dbv) == 0) {
mir_strcpy(z, dbv.pszVal);
db_free(&dbv);
- } else {
+ }
+ else {
mir_strcpy(z, "Yahoo");
}
SetDlgItemTextA(hwndDlg, IDC_SEARCH_PROTOCOL, z);
- if (ppro->getString( hContact, "MirVer", &dbv) == 0) {
+ if (ppro->getString(hContact, "MirVer", &dbv) == 0) {
mir_strcpy(z, dbv.pszVal);
db_free(&dbv);
- } else {
+ }
+ else {
mir_strcpy(z, "???");
}
SetDlgItemTextA(hwndDlg, IDC_NFO_CLIENT, z);
- } else {
+ }
+ else {
}
}
break;
@@ -111,7 +116,7 @@ static INT_PTR CALLBACK YahooUserInfoDlgProc( HWND hwndDlg, UINT msg, WPARAM wPa /////////////////////////////////////////////////////////////////////////////////////////
// OnInfoInit - initializes user info option dialogs
-int __cdecl CYahooProto::OnUserInfoInit( WPARAM wParam, LPARAM lParam )
+int __cdecl CYahooProto::OnUserInfoInit(WPARAM wParam, LPARAM lParam)
{
OPTIONSDIALOGPAGE odp = { 0 };
odp.hInstance = hInstance;
@@ -119,10 +124,10 @@ int __cdecl CYahooProto::OnUserInfoInit( WPARAM wParam, LPARAM lParam ) odp.flags = ODPF_TCHAR | ODPF_DONTTRANSLATE;
MCONTACT hContact = lParam;
- if ( IsMyContact(hContact)) {
+ if (IsMyContact(hContact)) {
odp.pfnDlgProc = YahooUserInfoDlgProc;
odp.position = -1900000000;
- odp.pszTemplate = MAKEINTRESOURCEA( IDD_USER_INFO );
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_USER_INFO);
odp.ptszTitle = m_tszUserName;
UserInfo_AddPage(wParam, &odp);
}
diff --git a/protocols/Yahoo/src/util.cpp b/protocols/Yahoo/src/util.cpp index 569d9bed08..030599d82a 100644 --- a/protocols/Yahoo/src/util.cpp +++ b/protocols/Yahoo/src/util.cpp @@ -24,58 +24,60 @@ extern HANDLE g_hNetlibUser;
-int debugLogA( const char *fmt, ... )
+int debugLogA(const char *fmt, ...)
{
- char str[ 4096 ];
+ char str[4096];
va_list vararg;
- va_start( vararg, fmt );
-
+ va_start(vararg, fmt);
+
int tBytes = mir_vsnprintf(str, sizeof(str), fmt, vararg);
- if ( tBytes > 0)
- str[ tBytes ] = 0;
+ if (tBytes > 0)
+ str[tBytes] = 0;
+
+ va_end(vararg);
- va_end( vararg );
-
return CallService(MS_NETLIB_LOG, (WPARAM)g_hNetlibUser, (LPARAM)str);
}
-DWORD CYahooProto::Set_Protocol(MCONTACT hContact, int protocol )
+DWORD CYahooProto::Set_Protocol(MCONTACT hContact, int protocol)
{
- char *s=NULL;
-
+ char *s = NULL;
+
setWord(hContact, "yprotoid", protocol);
-
+
switch (protocol) {
- case YAHOO_IM_YAHOO: s = "Yahoo"; break; /* Yahoo, nothing special here */
- case YAHOO_IM_MSN: s = "Windows Live (MSN)"; break;
- case YAHOO_IM_LCS: s = "LCS"; break;
- case YAHOO_IM_SAMETIME: s = "Lotus Sametime"; break;
- }
-
+ case YAHOO_IM_YAHOO: s = "Yahoo"; break; /* Yahoo, nothing special here */
+ case YAHOO_IM_MSN: s = "Windows Live (MSN)"; break;
+ case YAHOO_IM_LCS: s = "LCS"; break;
+ case YAHOO_IM_SAMETIME: s = "Lotus Sametime"; break;
+ }
+
if (protocol != YAHOO_IM_YAHOO)
setString(hContact, "MirVer", s);
-
+
setString(hContact, "Transport", s);
return 0;
}
int CYahooProto::GetStringUtf(MCONTACT hContact, const char* name, DBVARIANT* result)
-{ return db_get_utf(hContact, m_szModuleName, name, result);
+{
+ return db_get_utf(hContact, m_szModuleName, name, result);
}
DWORD CYahooProto::SetStringUtf(MCONTACT hContact, const char* valueName, const char* parValue)
-{ return db_set_utf(hContact, m_szModuleName, valueName, parValue);
+{
+ return db_set_utf(hContact, m_szModuleName, valueName, parValue);
}
/////////////////////////////////////////////////////////////////////////////////////////
// Popups
-static LRESULT CALLBACK PopupWindowProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
+static LRESULT CALLBACK PopupWindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
- switch(message) {
+ switch (message) {
case WM_COMMAND:
debugLogA("[PopupWindowProc] WM_COMMAND");
- if ( HIWORD(wParam) == STN_CLICKED) {
+ if (HIWORD(wParam) == STN_CLICKED) {
char *szURL = (char*)PUGetPluginData(hWnd);
if (szURL != NULL)
CallService(MS_UTILS_OPENURL, OUF_NEWWINDOW, (LPARAM)szURL);
@@ -87,14 +89,14 @@ static LRESULT CALLBACK PopupWindowProc( HWND hWnd, UINT message, WPARAM wParam, case WM_CONTEXTMENU:
debugLogA("[PopupWindowProc] WM_CONTEXTMENU");
- PUDeletePopup(hWnd);
+ PUDeletePopup(hWnd);
return TRUE;
case UM_FREEPLUGINDATA:
debugLogA("[PopupWindowProc] UM_FREEPLUGINDATA");
{
char *szURL = (char *)PUGetPluginData(hWnd);
- if (szURL != NULL)
+ if (szURL != NULL)
free(szURL);
}
@@ -106,7 +108,7 @@ static LRESULT CALLBACK PopupWindowProc( HWND hWnd, UINT message, WPARAM wParam, int CYahooProto::ShowPopup(const TCHAR* nickname, const TCHAR* msg, const char *szURL)
{
- if ( !ServiceExists(MS_POPUP_ADDPOPUPT))
+ if (!ServiceExists(MS_POPUP_ADDPOPUPT))
return 0;
POPUPDATAT ppd = { 0 };
@@ -115,13 +117,13 @@ int CYahooProto::ShowPopup(const TCHAR* nickname, const TCHAR* msg, const char * mir_tstrncpy(ppd.lptzText, msg, SIZEOF(ppd.lptzText));
if (szURL != NULL) {
- ppd.lchIcon = LoadIconEx( !mir_strcmpi(szURL, "http://mail.yahoo.com") ? "mail" : "calendar");
+ ppd.lchIcon = LoadIconEx(!mir_strcmpi(szURL, "http://mail.yahoo.com") ? "mail" : "calendar");
ppd.PluginData = (void*)strdup(szURL);
}
else ppd.lchIcon = LoadIconEx("yahoo");
-
+
debugLogA("[MS_POPUP_ADDPOPUP] Generating a popup for [%S] %S", nickname, msg);
-
+
PUAddPopupT(&ppd);
return 1;
}
@@ -136,10 +138,10 @@ int CYahooProto::ShowNotification(const TCHAR *title, const TCHAR *info, DWORD f err.tszInfo = (TCHAR*)info;
err.dwInfoFlags = flags | NIIF_INTERN_UNICODE;
err.uTimeout = 1000 * 3;
- INT_PTR ret = CallService(MS_CLIST_SYSTRAY_NOTIFY, 0, (LPARAM) & err);
+ INT_PTR ret = CallService(MS_CLIST_SYSTRAY_NOTIFY, 0, (LPARAM)& err);
if (ret == 0)
return 1;
- }
+ }
MessageBox(NULL, info, title, MB_OK | MB_ICONINFORMATION);
return 0;
@@ -147,8 +149,8 @@ int CYahooProto::ShowNotification(const TCHAR *title, const TCHAR *info, DWORD f void CYahooProto::ShowError(const TCHAR *title, const TCHAR *buff)
{
- if ( getByte("ShowErrors", 1))
- if ( !ShowPopup(title, buff, NULL))
+ if (getByte("ShowErrors", 1))
+ if (!ShowPopup(title, buff, NULL))
ShowNotification(title, buff, NIIF_ERROR);
}
@@ -158,7 +160,7 @@ int __cdecl CYahooProto::OnSettingChanged(WPARAM hContact, LPARAM lParam) return 0;
DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*)lParam;
- if ( !mir_strcmp(cws->szSetting, "ApparentMode")) {
+ if (!mir_strcmp(cws->szSetting, "ApparentMode")) {
debugLogA("DB Setting changed. YAHOO user's visible setting changed.");
DBVARIANT dbv;
@@ -187,15 +189,15 @@ extern PLUGININFOEX pluginInfo; */
void CYahooProto::YAHOO_utils_logversion()
{
- char str[256];
- mir_snprintf(str, "Yahoo v%d.%d.%d.%d", (pluginInfo.version >> 24) & 0xFF, (pluginInfo.version >> 16) & 0xFF,
- (pluginInfo.version >> 8) & 0xFF, pluginInfo.version & 0xFF);
- debugLogA(str);
+ char str[256];
+ mir_snprintf(str, "Yahoo v%d.%d.%d.%d", (pluginInfo.version >> 24) & 0xFF, (pluginInfo.version >> 16) & 0xFF,
+ (pluginInfo.version >> 8) & 0xFF, pluginInfo.version & 0xFF);
+ debugLogA(str);
}
void SetButtonCheck(HWND hwndDlg, int CtrlID, BOOL bCheck)
{
HWND hwndCtrl = GetDlgItem(hwndDlg, CtrlID);
-
+
Button_SetCheck(hwndCtrl, (bCheck) ? BST_CHECKED : BST_UNCHECKED);
}
diff --git a/protocols/Yahoo/src/webcam.cpp b/protocols/Yahoo/src/webcam.cpp index 62973c5b58..8a5c0b01e9 100644 --- a/protocols/Yahoo/src/webcam.cpp +++ b/protocols/Yahoo/src/webcam.cpp @@ -25,8 +25,8 @@ /* WEBCAM callbacks */
void ext_yahoo_got_webcam_image(int id, const char *who,
- const unsigned char *image, unsigned int image_size, unsigned int real_size,
- unsigned int timestamp)
+ const unsigned char *image, unsigned int image_size, unsigned int real_size,
+ unsigned int timestamp)
{
LOG(("ext_yahoo_got_webcam_image"));
}
@@ -50,7 +50,7 @@ void ext_yahoo_webcam_invite(int id, const char *me, const char *from) {
LOG(("ext_yahoo_webcam_invite"));
- GETPROTOBYID( id )->ext_got_im(me, from, 0, Translate("[miranda] Got webcam invite. (not currently supported)"), 0, 0, 0, -1);
+ GETPROTOBYID(id)->ext_got_im(me, from, 0, Translate("[miranda] Got webcam invite. (not currently supported)"), 0, 0, 0, -1);
}
void ext_yahoo_webcam_invite_reply(int id, const char *me, const char *from, int accept)
diff --git a/protocols/Yahoo/src/yahoo.cpp b/protocols/Yahoo/src/yahoo.cpp index c0e8dee551..394e979589 100644 --- a/protocols/Yahoo/src/yahoo.cpp +++ b/protocols/Yahoo/src/yahoo.cpp @@ -40,22 +40,22 @@ typedef struct { } yahoo_authorize_data;
yahoo_idlabel yahoo_status_codes[] = {
- {YAHOO_STATUS_AVAILABLE, ""},
- {YAHOO_STATUS_BRB, "BRB"},
- {YAHOO_STATUS_BUSY, "Busy"},
- {YAHOO_STATUS_NOTATHOME, "Not At Home"},
- {YAHOO_STATUS_NOTATDESK, "Not At my Desk"},
- {YAHOO_STATUS_NOTINOFFICE, "Not In The Office"},
- {YAHOO_STATUS_ONPHONE, "On The Phone"},
- {YAHOO_STATUS_ONVACATION, "On Vacation"},
- {YAHOO_STATUS_OUTTOLUNCH, "Out To Lunch"},
- {YAHOO_STATUS_STEPPEDOUT, "Stepped Out"},
- {YAHOO_STATUS_INVISIBLE, "Invisible"},
- {YAHOO_STATUS_IDLE, "Idle"},
- {YAHOO_STATUS_OFFLINE, "Offline"},
- {YAHOO_STATUS_CUSTOM, "[Custom]"},
-// {YAHOO_STATUS_NOTIFY, "Notify"},
- {0, NULL}
+ { YAHOO_STATUS_AVAILABLE, "" },
+ { YAHOO_STATUS_BRB, "BRB" },
+ { YAHOO_STATUS_BUSY, "Busy" },
+ { YAHOO_STATUS_NOTATHOME, "Not At Home" },
+ { YAHOO_STATUS_NOTATDESK, "Not At my Desk" },
+ { YAHOO_STATUS_NOTINOFFICE, "Not In The Office" },
+ { YAHOO_STATUS_ONPHONE, "On The Phone" },
+ { YAHOO_STATUS_ONVACATION, "On Vacation" },
+ { YAHOO_STATUS_OUTTOLUNCH, "Out To Lunch" },
+ { YAHOO_STATUS_STEPPEDOUT, "Stepped Out" },
+ { YAHOO_STATUS_INVISIBLE, "Invisible" },
+ { YAHOO_STATUS_IDLE, "Idle" },
+ { YAHOO_STATUS_OFFLINE, "Offline" },
+ { YAHOO_STATUS_CUSTOM, "[Custom]" },
+ // {YAHOO_STATUS_NOTIFY, "Notify"},
+ { 0, NULL }
};
#define MAX_PREF_LEN 255
@@ -68,10 +68,10 @@ extern int poll_loop; char * yahoo_status_code(enum yahoo_status s)
{
- for(int i=0; yahoo_status_codes[i].label; i++)
+ for (int i = 0; yahoo_status_codes[i].label; i++)
if (yahoo_status_codes[i].id == s)
return yahoo_status_codes[i].label;
-
+
return "Unknown";
}
@@ -81,7 +81,7 @@ yahoo_status miranda_to_yahoo(int myyahooStatus) case ID_STATUS_OFFLINE:
return YAHOO_STATUS_OFFLINE;
case ID_STATUS_FREECHAT:
- case ID_STATUS_ONLINE:
+ case ID_STATUS_ONLINE:
return YAHOO_STATUS_AVAILABLE;
case ID_STATUS_AWAY:
return YAHOO_STATUS_STEPPEDOUT;
@@ -105,7 +105,7 @@ yahoo_status miranda_to_yahoo(int myyahooStatus) int yahoo_to_miranda_status(int m_iStatus, int away)
{
switch (m_iStatus) {
- case YAHOO_STATUS_AVAILABLE:
+ case YAHOO_STATUS_AVAILABLE:
return ID_STATUS_ONLINE;
case YAHOO_STATUS_BRB:
return ID_STATUS_NA;
@@ -125,7 +125,7 @@ int yahoo_to_miranda_status(int m_iStatus, int away) case YAHOO_STATUS_IDLE:
return ID_STATUS_AWAY;
case YAHOO_STATUS_CUSTOM:
- return (away ? ID_STATUS_AWAY:ID_STATUS_ONLINE);
+ return (away ? ID_STATUS_AWAY : ID_STATUS_ONLINE);
default:
return ID_STATUS_OFFLINE;
}
@@ -136,12 +136,12 @@ void CYahooProto::set_status(int myyahooStatus, char *msg, int away) LOG(("[set_status] myyahooStatus: %d, msg: %s, away: %d", myyahooStatus, msg, away));
/* Safety check, don't dereference Invalid pointers */
- if (m_id > 0) {
-
+ if (m_id > 0) {
+
if (YAHOO_CUSTOM_STATUS != myyahooStatus)
yahoo_set_away(m_id, miranda_to_yahoo(myyahooStatus), msg, away);
else
- yahoo_set_away(m_id, ( yahoo_status )YAHOO_CUSTOM_STATUS, msg, away);
+ yahoo_set_away(m_id, (yahoo_status)YAHOO_CUSTOM_STATUS, msg, away);
}
}
@@ -202,10 +202,10 @@ void CYahooProto::AddBuddy(MCONTACT hContact, const char *group, const TCHAR *ms {
/* We adding a buddy to our list.
2 Stages.
- 1. We send add buddy packet.
- 2. We get a packet back from the server confirming add.
-
- No refresh needed. */
+ 1. We send add buddy packet.
+ 2. We get a packet back from the server confirming add.
+
+ No refresh needed. */
ptrA who(getStringA(hContact, YAHOO_LOGINID));
if (who == NULL)
@@ -221,7 +221,7 @@ void CYahooProto::AddBuddy(MCONTACT hContact, const char *group, const TCHAR *ms SetStringUtf(hContact, "YGroup", group);
debugLogA("Adding Permanently %s to list. Auth: %s", who, u_msg ? u_msg : "<None>");
- yahoo_add_buddy(m_id, ident, T2Utf(fname), T2Utf(lname), who, protocol, group, u_msg);
+ yahoo_add_buddy(m_id, ident, T2Utf(fname), T2Utf(lname), who, protocol, group, u_msg);
}
MCONTACT CYahooProto::getbuddyH(const char *yahoo_id)
@@ -231,9 +231,9 @@ MCONTACT CYahooProto::getbuddyH(const char *yahoo_id) if (getString(hContact, YAHOO_LOGINID, &dbv))
continue;
- int tCompareResult = mir_strcmpi( dbv.pszVal, yahoo_id );
+ int tCompareResult = mir_strcmpi(dbv.pszVal, yahoo_id);
db_free(&dbv);
- if ( tCompareResult )
+ if (tCompareResult)
continue;
return hContact;
@@ -246,40 +246,40 @@ MCONTACT CYahooProto::add_buddy(const char *yahoo_id, const char *yahoo_name, in {
char *yid = NEWSTR_ALLOCA(yahoo_id);
strlwr(yid);
-
+
MCONTACT hContact = getbuddyH(yid);
if (hContact != NULL) {
LOG(("[add_buddy] Found buddy id: %s, handle: %p", yid, hContact));
- if ( !(flags & PALF_TEMPORARY) && db_get_b(hContact, "CList", "NotOnList", 1)) {
+ if (!(flags & PALF_TEMPORARY) && db_get_b(hContact, "CList", "NotOnList", 1)) {
LOG(("[add_buddy] Making Perm id: %s, flags: %lu", yahoo_id, flags));
- db_unset( hContact, "CList", "NotOnList");
- db_unset( hContact, "CList", "Hidden");
+ db_unset(hContact, "CList", "NotOnList");
+ db_unset(hContact, "CList", "Hidden");
}
-
+
return hContact;
}
//not already there: add
LOG(("[add_buddy] Adding buddy id: %s (Nick: %s), flags: %lu", yid, yahoo_name, flags));
hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
- CallService(MS_PROTO_ADDTOCONTACT, hContact,(LPARAM)m_szModuleName);
- setString( hContact, YAHOO_LOGINID, yid );
- Set_Protocol( hContact, protocol );
+ CallService(MS_PROTO_ADDTOCONTACT, hContact, (LPARAM)m_szModuleName);
+ setString(hContact, YAHOO_LOGINID, yid);
+ Set_Protocol(hContact, protocol);
if (mir_strlen(yahoo_name) > 0)
- SetStringUtf( hContact, "Nick", yahoo_name );
+ SetStringUtf(hContact, "Nick", yahoo_name);
else
- SetStringUtf( hContact, "Nick", yahoo_id );
+ SetStringUtf(hContact, "Nick", yahoo_id);
if (flags & PALF_TEMPORARY) {
- db_set_b( hContact, "CList", "NotOnList", 1 );
- db_set_b( hContact, "CList", "Hidden", 1 );
- }
-
+ db_set_b(hContact, "CList", "NotOnList", 1);
+ db_set_b(hContact, "CList", "Hidden", 1);
+ }
+
return hContact;
}
-const char* CYahooProto::find_buddy( const char *yahoo_id)
+const char* CYahooProto::find_buddy(const char *yahoo_id)
{
static char nick[128];
DBVARIANT dbv;
@@ -289,7 +289,7 @@ const char* CYahooProto::find_buddy( const char *yahoo_id) if (GetStringUtf(hContact, "Nick", &dbv))
return NULL;
- strncpy(nick, dbv.pszVal, sizeof(nick)-1);
+ strncpy(nick, dbv.pszVal, sizeof(nick) - 1);
db_free(&dbv);
return nick;
}
@@ -302,27 +302,27 @@ const char* CYahooProto::find_buddy( const char *yahoo_id) /* Other handlers */
void CYahooProto::ext_status_changed(const char *who, int protocol, int stat, const char *msg, int away, int idle, int mobile, int utf8)
{
- debugLogA("[ext_status_changed] %s (prot: %d) with msg %s utf8: %d, stat: %s (%d), away: %d, idle: %d seconds",
- who,
- protocol,
- msg,
- utf8,
- (stat == 0) ? "Online" : yahoo_status_code( (yahoo_status)stat ),
- stat,
- away,
- idle);
-
+ debugLogA("[ext_status_changed] %s (prot: %d) with msg %s utf8: %d, stat: %s (%d), away: %d, idle: %d seconds",
+ who,
+ protocol,
+ msg,
+ utf8,
+ (stat == 0) ? "Online" : yahoo_status_code((yahoo_status)stat),
+ stat,
+ away,
+ idle);
+
MCONTACT hContact = getbuddyH(who);
if (hContact == NULL) {
debugLogA("Buddy Not Found. Adding...");
hContact = add_buddy(who, who, protocol, 0);
}
-
+
if (!mobile)
- setWord(hContact, "Status", yahoo_to_miranda_status(stat,away));
+ setWord(hContact, "Status", yahoo_to_miranda_status(stat, away));
else
setWord(hContact, "Status", ID_STATUS_ONTHEPHONE);
-
+
setWord(hContact, "YStatus", stat);
setWord(hContact, "YAway", away);
setWord(hContact, "Mobile", mobile);
@@ -331,9 +331,9 @@ void CYahooProto::ext_status_changed(const char *who, int protocol, int stat, co debugLogA("[ext_status_changed] %s custom message '%s'", who, msg);
if (utf8)
- db_set_utf( hContact, "CList", "StatusMsg", msg);
+ db_set_utf(hContact, "CList", "StatusMsg", msg);
else
- db_set_s( hContact, "CList", "StatusMsg", msg);
+ db_set_s(hContact, "CList", "StatusMsg", msg);
}
else db_unset(hContact, "CList", "StatusMsg");
@@ -345,16 +345,16 @@ void CYahooProto::ext_status_changed(const char *who, int protocol, int stat, co }
else {
time_t idlets = 0;
- if ( (away == 2) || (stat == YAHOO_STATUS_IDLE) || (idle > 0)) {
+ if ((away == 2) || (stat == YAHOO_STATUS_IDLE) || (idle > 0)) {
/* TODO: set Idle=-1, because of key 138=1 and don't set idlets then */
if (stat > 0) {
- debugLogA("[ext_status_changed] %s idle for %d:%02d:%02d", who, idle/3600, (idle/60)%60, idle%60);
-
+ debugLogA("[ext_status_changed] %s idle for %d:%02d:%02d", who, idle / 3600, (idle / 60) % 60, idle % 60);
+
time(&idlets);
idlets -= idle;
}
- }
-
+ }
+
setDword(hContact, "IdleTS", idlets);
}
@@ -364,78 +364,78 @@ void CYahooProto::ext_status_changed(const char *who, int protocol, int stat, co void CYahooProto::ext_status_logon(const char *who, int protocol, int stat, const char *msg, int away, int idle, int mobile, int cksum, int buddy_icon, long client_version, int utf8)
{
debugLogA("[ext_status_logon] %s (prot: %d) with msg %s utf8: %d, (stat: %d, away: %d, idle: %d seconds, checksum: %d buddy_icon: %d client_version: %ld)", who, protocol, msg, utf8, stat, away, idle, cksum, buddy_icon, client_version);
-
+
ext_status_changed(who, protocol, stat, msg, away, idle, mobile, utf8);
MCONTACT hContact = getbuddyH(who);
if (hContact == NULL) {
debugLogA("[ext_status_logon] Can't find handle for %s??? PANIC!!!", who);
return;
- }
+ }
/**
* We only do real client detection when using Yahoo client. Other option is to fill in the protocol info
*/
if (protocol == 0) {
char *s = NULL;
-
+
switch (client_version & 0x1FFFFBF) {
case 2:
s = "Yahoo Mobile";
break;
-
+
case 6:
s = "Yahoo PingBox";
break;
-
+
case 3075:
case 0x00880C03:
s = "Yahoo Web Messenger";
break;
-
+
case 35846:
s = "Go!Chat for Android";
break;
-
- case 262651:
- s = "libyahoo2";
+
+ case 262651:
+ s = "libyahoo2";
break;
-
- case 262655:
- s = "< Yahoo 6.x (Yahoo 5.x?)";
+
+ case 262655:
+ s = "< Yahoo 6.x (Yahoo 5.x?)";
break;
-
- case 278527:
- s = "Yahoo 6.x";
+
+ case 278527:
+ s = "Yahoo 6.x";
break;
-
- case 524223:
+
+ case 524223:
//Yahoo 7.4
//Yahoo 7.5
- s = "Yahoo 7.x";
+ s = "Yahoo 7.x";
break;
-
+
case 888327:
s = "Yahoo 9.0 for Vista";
break;
-
+
case 822366: /* Yahoo! Messenger 2.1.37 by RIM */
s = "Yahoo for Blackberry";
break;
-
+
case 822543: /* ? "Yahoo Version 3.0 beta 1 (build 18274) OSX" */
- case 1572799: /* 8.0.x ?? */
+ case 1572799: /* 8.0.x ?? */
case 2097087: /* 8.1.0.195 */
case 0x009FFFBF:
- s = "Yahoo 8.x";
+ s = "Yahoo 8.x";
break;
-
+
case 2088895:
case 4194239:
case 0x00BFFFBF:
s = "Yahoo 9.0";
break;
-
+
case 8388543:
s = "Yahoo 10.0";
break;
@@ -457,57 +457,59 @@ void CYahooProto::ext_status_logon(const char *who, int protocol, int stat, cons break;
}
- if (s != NULL)
- setString( hContact, "MirVer", s);
+ if (s != NULL)
+ setString(hContact, "MirVer", s);
else
delSetting(hContact, "MirVer");
}
else Set_Protocol(hContact, protocol);
-
+
/* Add the client_Version # to the contact DB entry */
- setDword( hContact, "ClientVersion", client_version);
-
+ setDword(hContact, "ClientVersion", client_version);
+
/* Last thing check the checksum and request new one if we need to */
if (buddy_icon == -1) {
debugLogA("[ext_status_logon] No avatar information in this packet? Not touching stuff!");
- } else {
+ }
+ else {
// we got some avatartype info
setByte(hContact, "AvatarType", buddy_icon);
-
+
if (cksum == 0 || cksum == -1) {
// no avatar
setDword(hContact, "PictCK", 0);
- } else if (getDword(hContact, "PictCK", 0) != (unsigned)cksum) {
+ }
+ else if (getDword(hContact, "PictCK", 0) != (unsigned)cksum) {
//char szFile[MAX_PATH];
-
+
// Save new Checksum
setDword(hContact, "PictCK", cksum);
-
+
// Need to delete the Avatar File!!
//GetAvatarFileName(hContact, szFile, sizeof szFile, 0);
//DeleteFile(szFile);
}
-
+
// Cleanup the type? and reset things...
reset_avatar(hContact);
}
-
+
debugLogA("[ext_status_logon] exiting");
}
void CYahooProto::ext_got_audible(const char *me, const char *who, const char *aud, const char *msg, const char *aud_hash)
{
- /* aud = file class name
+ /* aud = file class name
GAIM: the audible, in foo.bar.baz format
-
+
Actually this is the filename.
Full URL:
-
- http://us.dl1.yimg.com/download.yahoo.com/dl/aud/us/aud.swf
-
+
+ http://us.dl1.yimg.com/download.yahoo.com/dl/aud/us/aud.swf
+
where aud in foo.bar.baz format
- */
-
+ */
+
LOG(("ext_got_audible for %s aud: %s msg:'%s' hash: %s", who, aud, msg, aud_hash));
MCONTACT hContact = getbuddyH(who);
@@ -515,18 +517,18 @@ void CYahooProto::ext_got_audible(const char *me, const char *who, const char *a LOG(("Buddy Not Found. Skipping avatar update"));
return;
}
-
+
char z[1028];
- mir_snprintf(z, SIZEOF(z), "[miranda-audible] %s", msg ?msg:"");
+ mir_snprintf(z, SIZEOF(z), "[miranda-audible] %s", msg ? msg : "");
ext_got_im((char*)me, (char*)who, 0, z, 0, 0, 1, -1, NULL, 0);
}
void CYahooProto::ext_got_calendar(const char *url, int type, const char *msg, int svc)
{
LOG(("[ext_got_calendar] URL:%s type: %d msg: %s svc: %d", url, type, msg, svc));
-
+
ptrT tszMsg(mir_utf8decodeT(msg));
- if (!ShowPopup( TranslateT("Calendar Reminder"), tszMsg, url))
+ if (!ShowPopup(TranslateT("Calendar Reminder"), tszMsg, url))
ShowNotification(TranslateT("Calendar Reminder"), tszMsg, NIIF_INFO);
}
@@ -535,17 +537,17 @@ void CYahooProto::ext_got_stealth(char *stealthlist) char **stealth = NULL;
LOG(("[ext_got_stealth] list: %s", stealthlist));
-
+
if (stealthlist)
stealth = y_strsplit(stealthlist, ",", -1);
for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
DBVARIANT dbv;
- if (getString( hContact, YAHOO_LOGINID, &dbv))
+ if (getString(hContact, YAHOO_LOGINID, &dbv))
continue;
bool found = false;
- for(char **s = stealth; s && *s; s++) {
+ for (char **s = stealth; s && *s; s++) {
if (mir_strcmpi(*s, dbv.pszVal) == 0) {
debugLogA("GOT id = %s", dbv.pszVal);
found = true;
@@ -560,7 +562,8 @@ void CYahooProto::ext_got_stealth(char *stealthlist) if (ID_STATUS_OFFLINE != getWord(hContact, "ApparentMode", 0))
getWord(hContact, "ApparentMode", ID_STATUS_OFFLINE);
- } else { /* he is not on the Stealth List */
+ }
+ else { /* he is not on the Stealth List */
//LOG(("Resetting STEALTH for id = %s", dbv.pszVal));
/* need to delete the ApparentMode thingy */
if (getWord(hContact, "ApparentMode", 0))
@@ -584,14 +587,14 @@ void CYahooProto::ext_got_buddies(YList * buds) for (; buds; buds = buds->next) {
MCONTACT hContact;
- yahoo_buddy *bud = ( yahoo_buddy* )buds->data;
+ yahoo_buddy *bud = (yahoo_buddy*)buds->data;
if (bud == NULL) {
LOG(("[ext_got_buddies] EMPTY BUDDY LIST??"));
continue;
}
debugLogA("[ext_got_buddies] id = %s, protocol = %d, group = %s, auth = %d", bud->id, bud->protocol, bud->group, bud->auth);
-
+
hContact = getbuddyH(bud->id);
if (hContact == NULL)
hContact = add_buddy(bud->id, (bud->real_name != NULL) ? bud->real_name : bud->id, bud->protocol, 0);
@@ -606,9 +609,10 @@ void CYahooProto::ext_got_buddies(YList * buds) debugLogA("Setting STEALTH for id = %s", bud->id);
/* need to set the ApparentMode thingy */
if (ID_STATUS_OFFLINE != getWord(hContact, "ApparentMode", 0))
- setWord(hContact, "ApparentMode", (WORD) ID_STATUS_OFFLINE);
+ setWord(hContact, "ApparentMode", (WORD)ID_STATUS_OFFLINE);
- } else { /* he is not on the Stealth List */
+ }
+ else { /* he is not on the Stealth List */
//LOG(("Resetting STEALTH for id = %s", dbv.pszVal));
/* need to delete the ApparentMode thingy */
if (getWord(hContact, "ApparentMode", 0))
@@ -621,34 +625,34 @@ void CYahooProto::ext_got_buddies(YList * buds) if (bud->real_name) {
debugLogA("id = %s name = %s", bud->id, bud->real_name);
- SetStringUtf( hContact, "Nick", bud->real_name);
+ SetStringUtf(hContact, "Nick", bud->real_name);
}
if (bud->yab_entry) {
//LOG(("YAB_ENTRY"));
- if (bud->yab_entry->fname)
- SetStringUtf( hContact, "FirstName", bud->yab_entry->fname);
+ if (bud->yab_entry->fname)
+ SetStringUtf(hContact, "FirstName", bud->yab_entry->fname);
- if (bud->yab_entry->lname)
- SetStringUtf( hContact, "LastName", bud->yab_entry->lname);
+ if (bud->yab_entry->lname)
+ SetStringUtf(hContact, "LastName", bud->yab_entry->lname);
- if (bud->yab_entry->email)
- setString( hContact, "e-mail", bud->yab_entry->email);
+ if (bud->yab_entry->email)
+ setString(hContact, "e-mail", bud->yab_entry->email);
- if (bud->yab_entry->mphone)
- setString( hContact, "Cellular", bud->yab_entry->mphone);
+ if (bud->yab_entry->mphone)
+ setString(hContact, "Cellular", bud->yab_entry->mphone);
- if (bud->yab_entry->hphone)
- setString( hContact, "Phone", bud->yab_entry->hphone);
+ if (bud->yab_entry->hphone)
+ setString(hContact, "Phone", bud->yab_entry->hphone);
- if (bud->yab_entry->wphone)
- setString( hContact, "CompanyPhone", bud->yab_entry->wphone);
+ if (bud->yab_entry->wphone)
+ setString(hContact, "CompanyPhone", bud->yab_entry->wphone);
- setWord( hContact, "YabID", bud->yab_entry->dbid);
+ setWord(hContact, "YabID", bud->yab_entry->dbid);
}
}
-
+
debugLogA(("[ext_got_buddies] buddy list Finished."));
}
@@ -660,40 +664,40 @@ void CYahooProto::ext_rejected(const char *who, const char *msg) if (hContact != NULL) {
/*
* Make sure the contact is temporary so we could delete it w/o extra traffic
- */
- db_set_b( hContact, "CList", "NotOnList", 1 );
- CallService(MS_DB_CONTACT_DELETE, hContact, 0);
+ */
+ db_set_b(hContact, "CList", "NotOnList", 1);
+ CallService(MS_DB_CONTACT_DELETE, hContact, 0);
}
else LOG(("[ext_rejected] Buddy not on our buddy list"));
- ptrT tszWho( mir_utf8decodeT(who));
- ptrT tszMsg( mir_utf8decodeT(msg));
+ ptrT tszWho(mir_utf8decodeT(who));
+ ptrT tszMsg(mir_utf8decodeT(msg));
TCHAR buff[1024];
mir_sntprintf(buff, TranslateT("%s has rejected your request and sent the following message:"), (TCHAR*)tszWho);
- MessageBox(NULL, tszMsg, buff, MB_OK | MB_ICONINFORMATION );
+ MessageBox(NULL, tszMsg, buff, MB_OK | MB_ICONINFORMATION);
}
void CYahooProto::ext_buddy_added(char *myid, char *who, char *group, int status, int auth)
{
- MCONTACT hContact=getbuddyH(who);
-
+ MCONTACT hContact = getbuddyH(who);
+
LOG(("[ext_buddy_added] %s authorized you as %s group: %s status: %d auth: %d", who, myid, group, status, auth));
-
+
switch (status) {
case 0: /* we are ok */
case 2: /* seems that we ok, not sure what this means.. we already on buddy list? */
case 40: /* When adding MSN Live contacts we get this one? */
- db_unset( hContact, "CList", "NotOnList");
- db_unset( hContact, "CList", "Hidden");
+ db_unset(hContact, "CList", "NotOnList");
+ db_unset(hContact, "CList", "Hidden");
break;
case 1: /* invalid ID? */
case 3: /* invalid ID */
if (hContact != NULL) {
- ShowPopup( TranslateT("Invalid Contact"), TranslateT("The ID you tried to add is invalid."), NULL);
+ ShowPopup(TranslateT("Invalid Contact"), TranslateT("The ID you tried to add is invalid."), NULL);
/* Make it TEMP first, we don't want to send any extra packets for FALSE ids */
- db_set_b( hContact, "CList", "NotOnList", 1 );
+ db_set_b(hContact, "CList", "NotOnList", 1);
CallService(MS_DB_CONTACT_DELETE, hContact, 0);
}
break;
@@ -701,9 +705,9 @@ void CYahooProto::ext_buddy_added(char *myid, char *who, char *group, int status default:
/* ??? */
if (hContact != NULL) {
- ShowPopup( TranslateT("Invalid Contact"), TranslateT("Unknown Error."), NULL);
+ ShowPopup(TranslateT("Invalid Contact"), TranslateT("Unknown Error."), NULL);
/* Make it TEMP first, we don't want to send any extra packets for FALSE ids */
- db_set_b( hContact, "CList", "NotOnList", 1 );
+ db_set_b(hContact, "CList", "NotOnList", 1);
CallService(MS_DB_CONTACT_DELETE, hContact, 0);
}
@@ -721,7 +725,7 @@ void CYahooProto::ext_contact_added(const char *myid, const char *who, const cha /* NOTE: Msg is actually in UTF8 unless stated otherwise!! */
LOG(("[ext_contact_added] %s %s (%s:%d) added you as %s w/ msg '%s'", fname, lname, who, protocol, myid, msg));
- if ( BuddyIgnored( who )) {
+ if (BuddyIgnored(who)) {
LOG(("User '%s' on our Ignore List. Dropping Authorization Request.", who));
return;
}
@@ -755,7 +759,7 @@ void CYahooProto::ext_contact_added(const char *myid, const char *who, const cha Set_Protocol(hContact, protocol);
pre.timestamp = time(NULL);
- pre.lParam = sizeof(DWORD)+sizeof(HANDLE)+mir_strlen(who)+mir_strlen(nick)+5;
+ pre.lParam = sizeof(DWORD) + sizeof(HANDLE) + mir_strlen(who) + mir_strlen(nick) + 5;
if (fname != NULL)
pre.lParam += mir_strlen(fname);
@@ -774,25 +778,25 @@ void CYahooProto::ext_contact_added(const char *myid, const char *who, const cha pCurBlob += sizeof(DWORD);
// hContact
- *(PDWORD)pCurBlob = (DWORD)hContact;
+ *(PDWORD)pCurBlob = (DWORD)hContact;
pCurBlob += sizeof(DWORD);
// NICK
- mir_strcpy((char*)pCurBlob, nick);
+ mir_strcpy((char*)pCurBlob, nick);
- pCurBlob+=mir_strlen((char *)pCurBlob)+1;
+ pCurBlob += mir_strlen((char *)pCurBlob) + 1;
// FIRST
- mir_strcpy((char*)pCurBlob, (fname != NULL) ? fname : "");
- pCurBlob+=mir_strlen((char *)pCurBlob)+1;
+ mir_strcpy((char*)pCurBlob, (fname != NULL) ? fname : "");
+ pCurBlob += mir_strlen((char *)pCurBlob) + 1;
// LAST
- mir_strcpy((char*)pCurBlob, (lname != NULL) ? lname : "");
- pCurBlob+=mir_strlen((char *)pCurBlob)+1;
+ mir_strcpy((char*)pCurBlob, (lname != NULL) ? lname : "");
+ pCurBlob += mir_strlen((char *)pCurBlob) + 1;
// E-mail
- mir_strcpy((char*)pCurBlob,who);
- pCurBlob+=mir_strlen((char *)pCurBlob)+1;
+ mir_strcpy((char*)pCurBlob, who);
+ pCurBlob += mir_strlen((char *)pCurBlob) + 1;
// Reason
mir_strcpy((char*)pCurBlob, (msg != NULL) ? msg : "");
@@ -805,37 +809,37 @@ void CYahooProto::ext_typing_notify(const char *me, const char *who, int protoco LOG(("[ext_typing_notify] me: '%s' who: '%s' protocol: %d stat: %d ", me, who, protocol, stat));
MCONTACT hContact = getbuddyH(who);
-
- if (hContact)
- CallService(MS_PROTO_CONTACTISTYPING, hContact, (LPARAM)stat?10:0);
+
+ if (hContact)
+ CallService(MS_PROTO_CONTACTISTYPING, hContact, (LPARAM)stat ? 10 : 0);
}
void CYahooProto::ext_game_notify(const char *me, const char *who, int stat, const char *msg)
{
/* There's also game invite packet:
- [17:36:44 YAHOO] libyahoo2/libyahoo2.c:3093: debug:
-[17:36:44 YAHOO] Yahoo Service: (null) (0xb7) Status: YAHOO_STATUS_BRB (1)
-[17:36:44 YAHOO]
-[17:36:44 YAHOO] libyahoo2/libyahoo2.c:863: debug:
-[17:36:44 YAHOO] [Reading packet] len: 88
-[17:36:44 YAHOO]
-[17:36:44 YAHOO] Key: From (4) Value: 'xxxxx'
-[17:36:44 YAHOO]
-[17:36:44 YAHOO] Key: To (5) Value: 'zxzxxx'
-[17:36:44 YAHOO]
-[17:36:44 YAHOO] Key: (null) (180) Value: 'pl'
-[17:36:44 YAHOO]
-[17:36:44 YAHOO] Key: (null) (183) Value: ''
-[17:36:44 YAHOO]
-[17:36:44 YAHOO] Key: (null) (181) Value: ''
-[17:36:44 YAHOO]
-[17:36:44 YAHOO] Key: session (11) Value: 'o8114ik_lixyxtdfrxbogw--'
-[17:36:44 YAHOO]
-[17:36:44 YAHOO] Key: stat/location (13) Value: '1'
-[17:36:44 YAHOO]
-[17:36:44 YAHOO] libyahoo2/libyahoo2.c:908: debug:
-[17:36:44 YAHOO] [Reading packet done]
-*/
+ [17:36:44 YAHOO] libyahoo2/libyahoo2.c:3093: debug:
+ [17:36:44 YAHOO] Yahoo Service: (null) (0xb7) Status: YAHOO_STATUS_BRB (1)
+ [17:36:44 YAHOO]
+ [17:36:44 YAHOO] libyahoo2/libyahoo2.c:863: debug:
+ [17:36:44 YAHOO] [Reading packet] len: 88
+ [17:36:44 YAHOO]
+ [17:36:44 YAHOO] Key: From (4) Value: 'xxxxx'
+ [17:36:44 YAHOO]
+ [17:36:44 YAHOO] Key: To (5) Value: 'zxzxxx'
+ [17:36:44 YAHOO]
+ [17:36:44 YAHOO] Key: (null) (180) Value: 'pl'
+ [17:36:44 YAHOO]
+ [17:36:44 YAHOO] Key: (null) (183) Value: ''
+ [17:36:44 YAHOO]
+ [17:36:44 YAHOO] Key: (null) (181) Value: ''
+ [17:36:44 YAHOO]
+ [17:36:44 YAHOO] Key: session (11) Value: 'o8114ik_lixyxtdfrxbogw--'
+ [17:36:44 YAHOO]
+ [17:36:44 YAHOO] Key: stat/location (13) Value: '1'
+ [17:36:44 YAHOO]
+ [17:36:44 YAHOO] libyahoo2/libyahoo2.c:908: debug:
+ [17:36:44 YAHOO] [Reading packet done]
+ */
LOG(("[ext_game_notify] me: %s, who: %s, stat: %d, msg: %s", me, who, stat, msg));
/* FIXME - Not Implemented - this informs you someone else is playing on Yahoo! Games */
/* Also Stubbed in Sample Client */
@@ -843,32 +847,32 @@ void CYahooProto::ext_game_notify(const char *me, const char *who, int stat, con if (!hContact)
return;
- if (stat == 2)
+ if (stat == 2)
setString(hContact, "YGMsg", "");
else if (msg) {
const char *l = msg, *u = NULL;
char *z, *c;
int i = 0;
- /* Parse and Set a custom Message
+ /* Parse and Set a custom Message
*
- * Format: 1 [09] ygamesp [09] 1 [09] 0 [09] ante?room=yahoo_1078798506&follow=rrrrrrr
+ * Format: 1 [09] ygamesp [09] 1 [09] 0 [09] ante?room=yahoo_1078798506&follow=rrrrrrr
* [09] Yahoo! Poker\nRoom: Intermediate Lounge 2
*
* Sign-in:
- * [17:13:42 YAHOO] [ext_yahoo_game_notify] id: 1, me: xxxxx, who: rrrrrrr,
- * stat: 1, msg: 1 ygamesa 1 0 ante?room=yahoo_1043183792&follow=lotesdelere
- * Yahoo! Backgammon Room: Social Lounge 12
+ * [17:13:42 YAHOO] [ext_yahoo_game_notify] id: 1, me: xxxxx, who: rrrrrrr,
+ * stat: 1, msg: 1 ygamesa 1 0 ante?room=yahoo_1043183792&follow=lotesdelere
+ * Yahoo! Backgammon Room: Social Lounge 12
*
* Sign-out:
- * [17:18:38 YAHOO] [ext_yahoo_game_notify] id: 1, me: xxxxx, who: rrrrr,
+ * [17:18:38 YAHOO] [ext_yahoo_game_notify] id: 1, me: xxxxx, who: rrrrr,
* stat: 2, msg: 1 ygamesa 2
*/
- z = (char *) _alloca(mir_strlen(l) + 50);
+ z = (char *)_alloca(mir_strlen(l) + 50);
- z[0]='\0';
- do{
- c = ( char* )strchr(l, 0x09);
+ z[0] = '\0';
+ do {
+ c = (char*)strchr(l, 0x09);
i++;
if (c != NULL) {
l = c;
@@ -880,15 +884,16 @@ void CYahooProto::ext_game_notify(const char *me, const char *who, int stat, con if (c != NULL) {
// insert \r before \n
- do{
- c = ( char* )strchr(l, '\n');
+ do {
+ c = (char*)strchr(l, '\n');
if (c != NULL) {
(*c) = '\0';
mir_strcat(z, l);
mir_strcat(z, "\r\n");
l = c + 1;
- } else {
+ }
+ else {
mir_strcat(z, l);
}
} while (c != NULL);
@@ -901,7 +906,8 @@ void CYahooProto::ext_game_notify(const char *me, const char *who, int stat, con SetStringUtf(hContact, "YGMsg", z);
- } else {
+ }
+ else {
/* ? no information / reset custom message */
setString(hContact, "YGMsg", "");
}
@@ -910,13 +916,13 @@ void CYahooProto::ext_game_notify(const char *me, const char *who, int stat, con void CYahooProto::ext_mail_notify(const char *from, const char *subj, int cnt)
{
LOG(("[ext_mail_notify] from: %s subject: %s count: %d", from, subj, cnt));
-
+
if (cnt > 0) {
SkinPlaySound("mail");
-
- if (!getByte("DisableYahoomail", 0)) {
+
+ if (!getByte("DisableYahoomail", 0)) {
TCHAR z[MAX_SECONDLINE], title[MAX_CONTACTNAME];
-
+
if (from == NULL) {
mir_sntprintf(title, SIZEOF(title), _T("%s: %s"), m_tszUserName, TranslateT("New Mail"));
mir_sntprintf(z, SIZEOF(z), TranslateT("You have %i unread messages"), cnt);
@@ -924,76 +930,76 @@ void CYahooProto::ext_mail_notify(const char *from, const char *subj, int cnt) else {
mir_sntprintf(title, SIZEOF(title), TranslateT("New Mail (%i messages)"), cnt);
- ptrT tszFrom( mir_utf8decodeT(from));
- ptrT tszSubj( mir_utf8decodeT(subj));
+ ptrT tszFrom(mir_utf8decodeT(from));
+ ptrT tszSubj(mir_utf8decodeT(subj));
mir_sntprintf(z, SIZEOF(z), TranslateT("From: %s\nSubject: %s"), (TCHAR*)tszFrom, (TCHAR*)tszSubj);
}
-
- if ( !ShowPopup(title, z, "http://mail.yahoo.com"))
+
+ if (!ShowPopup(title, z, "http://mail.yahoo.com"))
ShowNotification(title, z, NIIF_INFO);
}
}
-
+
m_unreadMessages = cnt;
- ProtoBroadcastAck( NULL, ACKTYPE_EMAIL, ACKRESULT_STATUS, NULL, 0);
-}
-
+ ProtoBroadcastAck(NULL, ACKTYPE_EMAIL, ACKRESULT_STATUS, NULL, 0);
+}
+
void CYahooProto::ext_system_message(const char *me, const char *who, const char *msg)
{
LOG(("[ext_system_message] System Message to: %s from: %s msg: %s", me, who, msg));
- ptrT tszWho( mir_utf8decodeT(who));
- ptrT tszMsg( mir_utf8decodeT(msg));
+ ptrT tszWho(mir_utf8decodeT(who));
+ ptrT tszMsg(mir_utf8decodeT(msg));
ShowPopup((who != NULL) ? tszWho : TranslateT("Yahoo System Message"), tszMsg, NULL);
}
void CYahooProto::ext_got_identities(const char *nick, const char *fname, const char *lname, YList * ids)
{
- LOG(("[ext_got_identities] First Name: %s, Last Name: %s", fname, lname));
-
- /* FIXME - Not implemented - Got list of Yahoo! identities */
- /* We currently only use the default identity */
- /* Also Stubbed in Sample Client */
+ LOG(("[ext_got_identities] First Name: %s, Last Name: %s", fname, lname));
+
+ /* FIXME - Not implemented - Got list of Yahoo! identities */
+ /* We currently only use the default identity */
+ /* Also Stubbed in Sample Client */
SetStringUtf(NULL, "FirstName", fname ? fname : "");
SetStringUtf(NULL, "LastName", lname ? lname : "");
}
-void __cdecl yahoo_get_yab_thread(void *psf)
+void __cdecl yahoo_get_yab_thread(void *psf)
{
int id = (int)psf;
-
+
yahoo_get_yab(id);
}
void ext_yahoo_got_cookies(int id)
{
-// char z[1024];
+ // char z[1024];
+
+ LOG(("[ext_got_cookies] id: %d", id));
+ /* LOG(("Y Cookie: '%s'", yahoo_get_cookie(id, "y")));
+ LOG(("T Cookie: '%s'", yahoo_get_cookie(id, "t")));
+ LOG(("C Cookie: '%s'", yahoo_get_cookie(id, "c")));
+ LOG(("Login Cookie: '%s'", yahoo_get_cookie(id, "login")));
- LOG(("[ext_got_cookies] id: %d", id));
-/* LOG(("Y Cookie: '%s'", yahoo_get_cookie(id, "y")));
- LOG(("T Cookie: '%s'", yahoo_get_cookie(id, "t")));
- LOG(("C Cookie: '%s'", yahoo_get_cookie(id, "c")));
- LOG(("Login Cookie: '%s'", yahoo_get_cookie(id, "login")));
-
- //wsprintfA(z, "Cookie: %s; C=%s; Y=%s; T=%s", Bcookie, yahoo_get_cookie(id, "c"), yahoo_get_cookie(id, "y"), yahoo_get_cookie(id, "t"));
- //wsprintfA(z, "Cookie: %s; Y=%s", Bcookie, yahoo_get_cookie(id, "y"), yahoo_get_cookie(id, "t"));
- mir_snprintf(z, SIZEOF(z), "Cookie: Y=%s; T=%s", yahoo_get_cookie(id, "y"), yahoo_get_cookie(id, "t"));
- LOG(("Our Cookie: '%s'", z));
- CallService(MS_NETLIB_SETSTICKYHEADERS, (WPARAM)hnuMain, (LPARAM)z);*/
+ //wsprintfA(z, "Cookie: %s; C=%s; Y=%s; T=%s", Bcookie, yahoo_get_cookie(id, "c"), yahoo_get_cookie(id, "y"), yahoo_get_cookie(id, "t"));
+ //wsprintfA(z, "Cookie: %s; Y=%s", Bcookie, yahoo_get_cookie(id, "y"), yahoo_get_cookie(id, "t"));
+ mir_snprintf(z, SIZEOF(z), "Cookie: Y=%s; T=%s", yahoo_get_cookie(id, "y"), yahoo_get_cookie(id, "t"));
+ LOG(("Our Cookie: '%s'", z));
+ CallService(MS_NETLIB_SETSTICKYHEADERS, (WPARAM)hnuMain, (LPARAM)z);*/
#ifdef HTTP_GATEWAY
if (iHTTPGateway) {
char z[1024];
-
+
// need to add Cookie header to our requests or we get booted w/ "Bad Cookie" message.
mir_snprintf(z, SIZEOF(z), "Cookie: Y=%s; T=%s; C=%s", yahoo_get_cookie(id, "y"),
- yahoo_get_cookie(id, "t"), yahoo_get_cookie(id, "c"));
+ yahoo_get_cookie(id, "t"), yahoo_get_cookie(id, "c"));
LOG(("Our Cookie: '%s'", z));
CallService(MS_NETLIB_SETSTICKYHEADERS, (WPARAM)hNetlibUser, (LPARAM)z);
}
#endif
-
+
}
void CYahooProto::ext_got_ping(const char *errormsg)
@@ -1002,30 +1008,31 @@ void CYahooProto::ext_got_ping(const char *errormsg) if (errormsg) {
LOG(("[ext_got_ping] Error msg: %s", errormsg));
- ptrT tszMsg( mir_utf8decodeT(errormsg));
- ShowError( TranslateT("Yahoo Ping Error"), tszMsg);
+ ptrT tszMsg(mir_utf8decodeT(errormsg));
+ ShowError(TranslateT("Yahoo Ping Error"), tszMsg);
return;
}
if (m_iStatus == ID_STATUS_CONNECTING) {
LOG(("[ext_got_ping] We are connecting. Checking for different status. Start: %d, Current: %d", m_startStatus, m_iStatus));
if (m_startStatus != m_iStatus) {
- LOG(("[COOKIES] Updating Status to %d ", m_startStatus));
+ LOG(("[COOKIES] Updating Status to %d ", m_startStatus));
if (m_startStatus != ID_STATUS_INVISIBLE) {// don't generate a bogus packet for Invisible state
if (m_startMsg != NULL) {
set_status(YAHOO_STATUS_CUSTOM, m_startMsg, (m_startStatus != ID_STATUS_ONLINE) ? 1 : 0);
- } else
+ }
+ else
set_status(m_startStatus, NULL, (m_startStatus != ID_STATUS_ONLINE) ? 1 : 0);
}
BroadcastStatus(m_startStatus);
- m_bLoggedIn=TRUE;
+ m_bLoggedIn = TRUE;
/**
* Now load the YAB.
*/
- if (getByte("UseYAB", 1 )) {
+ if (getByte("UseYAB", 1)) {
LOG(("[ext_got_ping] GET YAB"));
if (m_iStatus != ID_STATUS_OFFLINE)
mir_forkthread(yahoo_get_yab_thread, (void *)m_id);
@@ -1040,21 +1047,21 @@ void CYahooProto::ext_login_response(int succ, const char *url) TCHAR buff[1024];
LOG(("[ext_login_response] succ: %d, url: %s", succ, url));
-
+
if (succ == YAHOO_LOGIN_OK) {
const char *c;
-
+
m_status = yahoo_current_status(m_id);
LOG(("logged in status-> %d", m_status));
-
+
c = yahoo_get_pw_token(m_id);
-
+
setString(YAHOO_PWTOKEN, c);
-
+
LOG(("PW Token-> %s", c));
return;
}
-
+
if (succ == YAHOO_LOGIN_UNAME) {
mir_sntprintf(buff, TranslateT("Could not log into Yahoo service - username not recognized. Please verify that your username is correctly typed."));
ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_BADUSERID);
@@ -1078,21 +1085,21 @@ void CYahooProto::ext_login_response(int succ, const char *url) else if (succ == -1) {
/// Can't Connect or got disconnected.
if (m_iStatus == ID_STATUS_CONNECTING)
- mir_sntprintf(buff, TranslateT("Could not connect to the Yahoo service. Check your server/port and proxy settings."));
+ mir_sntprintf(buff, TranslateT("Could not connect to the Yahoo service. Check your server/port and proxy settings."));
else
return;
- }
+ }
else mir_sntprintf(buff, TranslateT("Could not log in, unknown reason: %d."), succ);
delSetting(YAHOO_PWTOKEN);
-
+
debugLogA("ERROR: %s", buff);
-
+
/*
* Show Error Message
*/
- ShowError( TranslateT("Yahoo Login Error"), buff);
-
+ ShowError(TranslateT("Yahoo Login Error"), buff);
+
/*
* Stop the server thread and let Server cleanup
*/
@@ -1101,12 +1108,12 @@ void CYahooProto::ext_login_response(int succ, const char *url) void CYahooProto::ext_error(const char *err, int fatal, int num)
{
- ptrT tszErr( mir_utf8decodeT(err));
+ ptrT tszErr(mir_utf8decodeT(err));
TCHAR buff[1024];
-
+
LOG(("[ext_error] Error: fatal: %d, num: %d, err: %s", fatal, num, err));
-
- switch(num) {
+
+ switch (num) {
case E_UNKNOWN:
mir_sntprintf(buff, TranslateT("Unknown error %s"), (TCHAR*)tszErr);
break;
@@ -1133,13 +1140,13 @@ void CYahooProto::ext_error(const char *err, int fatal, int num) debugLogA("Error: %S", buff);
return;
}
-
+
debugLogA("Error: %S", buff);
-
+
/*
* Show Error Message
*/
- ShowError( TranslateT("Yahoo Error"), buff);
+ ShowError(TranslateT("Yahoo Error"), buff);
}
extern HANDLE g_hNetlibUser;
@@ -1148,75 +1155,76 @@ INT_PTR CYahooProto::ext_connect(const char *h, int p, int type) {
LOG(("[ext_connect] %s:%d type: %d", h, p, type));
- HANDLE hUser=m_hNetlibUser;
- NETLIBOPENCONNECTION ncon = {0};
- ncon.cbSize = sizeof(ncon);
+ HANDLE hUser = m_hNetlibUser;
+ NETLIBOPENCONNECTION ncon = { 0 };
+ ncon.cbSize = sizeof(ncon);
ncon.flags = NLOCF_V2;
ncon.szHost = h;
ncon.wPort = p;
- ncon.timeout = 5;
+ ncon.timeout = 5;
if (type != YAHOO_CONNECTION_PAGER) {
ncon.flags |= NLOCF_HTTP;
- hUser = g_hNetlibUser;
+ hUser = g_hNetlibUser;
}
- HANDLE con = (HANDLE) CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)hUser, (LPARAM)&ncon);
- if (con == NULL) {
+ HANDLE con = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)hUser, (LPARAM)&ncon);
+ if (con == NULL) {
LOG(("ERROR: Connect Failed!"));
return -1;
}
LOG(("[ext_connect] Got: %d", (int)con));
-
+
return (INT_PTR)con;
}
-void CYahooProto::ext_send_http_request(enum yahoo_connection_type type, const char *method, const char *url,
- const char *cookies, long content_length, yahoo_get_fd_callback callback, void *callback_data)
+void CYahooProto::ext_send_http_request(enum yahoo_connection_type type, const char *method, const char *url,
+ const char *cookies, long content_length, yahoo_get_fd_callback callback, void *callback_data)
{
-/* if (mir_strcmpi(method, "GET") == 0)
- yahoo_http_get(id, url, cookies, callback, callback_data);
- else if (mir_strcmpi(method, "POST") == 0)
- yahoo_http_post(id, url, cookies, content_length, callback, callback_data);
- else
- LOG(("ERROR: Unknown method: %s", method));
-*/
- NETLIBHTTPREQUEST nlhr={0};
+ /* if (mir_strcmpi(method, "GET") == 0)
+ yahoo_http_get(id, url, cookies, callback, callback_data);
+ else if (mir_strcmpi(method, "POST") == 0)
+ yahoo_http_post(id, url, cookies, content_length, callback, callback_data);
+ else
+ LOG(("ERROR: Unknown method: %s", method));
+ */
+ NETLIBHTTPREQUEST nlhr = { 0 };
NETLIBHTTPHEADER httpHeaders[5];
int error = 0;
INT_PTR fd;
char host[255];
- int port = 80, i=0;
+ int port = 80, i = 0;
char path[255];
char z[1024];
-
+
LOG(("[ext_send_http_request] type: %d, method: %s, url: %s, cookies: %s, content length: %ld",
type, method, url, cookies, content_length));
-
+
if (!url_to_host_port_path(url, host, &port, path))
return;
fd = ext_connect(host, port, type);
-
+
if (fd < 0) {
LOG(("[ext_send_http_request] Can't connect?? Exiting..."));
//return;
- } else {
- nlhr.cbSize=sizeof(nlhr);
- nlhr.requestType=(mir_strcmpi(method, "GET") == 0) ? REQUEST_GET : REQUEST_POST;
- nlhr.flags=NLHRF_DUMPASTEXT|NLHRF_HTTP11;
- nlhr.szUrl=(char *)path;
+ }
+ else {
+ nlhr.cbSize = sizeof(nlhr);
+ nlhr.requestType = (mir_strcmpi(method, "GET") == 0) ? REQUEST_GET : REQUEST_POST;
+ nlhr.flags = NLHRF_DUMPASTEXT | NLHRF_HTTP11;
+ nlhr.szUrl = (char *)path;
nlhr.headers = httpHeaders;
nlhr.headersCount = 3;
-
+
if (cookies != NULL && cookies[0] != '\0') {
httpHeaders[i].szName = "Cookie";
httpHeaders[i].szValue = (char *)cookies;
nlhr.headersCount = 4;
i++;
}
-
+
httpHeaders[i].szName = "User-Agent";
httpHeaders[i].szValue = NETLIB_USER_AGENT;
i++;
@@ -1226,20 +1234,20 @@ void CYahooProto::ext_send_http_request(enum yahoo_connection_type type, const c i++;
if (nlhr.requestType == REQUEST_POST) {
- httpHeaders[nlhr.headersCount].szName="Content-Length";
+ httpHeaders[nlhr.headersCount].szName = "Content-Length";
mir_snprintf(z, SIZEOF(z), "%d", content_length);
- httpHeaders[nlhr.headersCount].szValue=z;
-
+ httpHeaders[nlhr.headersCount].szValue = z;
+
nlhr.headersCount++;
}
-
+
httpHeaders[i].szName = "Cache-Control";
httpHeaders[i].szValue = "no-cache";
i++;
-
- error = CallService(MS_NETLIB_SENDHTTPREQUEST,(WPARAM)fd,(LPARAM)&nlhr);
+
+ error = CallService(MS_NETLIB_SENDHTTPREQUEST, (WPARAM)fd, (LPARAM)&nlhr);
}
-
+
callback(m_id, fd, error == SOCKET_ERROR, callback_data);
}
@@ -1249,7 +1257,7 @@ void CYahooProto::ext_send_http_request(enum yahoo_connection_type type, const c unsigned int CYahooProto::ext_add_handler(int fd, yahoo_input_condition cond, void *data)
{
struct _conn *c = y_new0(struct _conn, 1);
-
+
c->tag = ++m_connection_tags;
c->id = m_id;
c->fd = fd;
@@ -1257,7 +1265,7 @@ unsigned int CYahooProto::ext_add_handler(int fd, yahoo_input_condition cond, vo c->data = data;
LOG(("[ext_add_handler] fd:%d, id:%d, cond: %d, tag %d", fd, m_id, cond, c->tag));
-
+
m_connections = y_list_prepend(m_connections, c);
return c->tag;
@@ -1265,12 +1273,10 @@ unsigned int CYahooProto::ext_add_handler(int fd, yahoo_input_condition cond, vo void CYahooProto::ext_remove_handler(unsigned int tag)
{
- YList *l;
-
LOG(("[ext_remove_handler] id:%d tag:%d ", m_id, tag));
-
- for(l = m_connections; l; l = y_list_next(l)) {
- struct _conn *c = ( _conn* )l->data;
+
+ for (YList *l = m_connections; l; l = y_list_next(l)) {
+ struct _conn *c = (_conn*)l->data;
if (c->tag == tag) {
/* don't actually remove it, just mark it for removal */
/* we'll remove when we start the next poll cycle */
@@ -1292,20 +1298,16 @@ void ext_yahoo_remove_handler(int id, unsigned int tag); static void connect_complete(void *data, int source, yahoo_input_condition condition)
{
- struct connect_callback_data *ccd = ( connect_callback_data* )data;
+ struct connect_callback_data *ccd = (connect_callback_data*)data;
int error = 0;//, err_size = sizeof(error);
- NETLIBSELECT tSelect = {0};
+ NETLIBSELECT tSelect = { 0 };
ext_yahoo_remove_handler(ccd->id, ccd->tag);
-
- // We Need to read the Socket error
- //getsockopt(source, SOL_SOCKET, SO_ERROR, &error, (socklen_t *)&err_size);
-
- tSelect.cbSize = sizeof( tSelect );
- //tSelect.dwTimeout = T->mGatewayTimeout * 1000;
+
+ tSelect.cbSize = sizeof(tSelect);
tSelect.dwTimeout = 1;
- tSelect.hReadConns[ 0 ] = ( HANDLE )source;
- error = CallService(MS_NETLIB_SELECT, 0, (LPARAM)&tSelect );
+ tSelect.hReadConns[0] = (HANDLE)source;
+ error = CallService(MS_NETLIB_SELECT, 0, (LPARAM)&tSelect);
if (error) {
//close(source);
@@ -1321,24 +1323,23 @@ static void connect_complete(void *data, int source, yahoo_input_condition condi void yahoo_callback(struct _conn *c, yahoo_input_condition cond)
{
- int ret=1;
+ int ret = 1;
- //LOG(("[yahoo_callback] id: %d, fd: %d tag: %d", c->id, c->fd, c->tag));
- if (c->id < 0) {
+ if (c->id < 0)
connect_complete(c->data, c->fd, cond);
- } else if (c->fd > 0) {
-
+ else if (c->fd > 0) {
if (cond & YAHOO_INPUT_READ)
ret = yahoo_read_ready(c->id, c->fd, c->data);
- if (ret>0 && cond & YAHOO_INPUT_WRITE)
+ if (ret > 0 && cond & YAHOO_INPUT_WRITE)
ret = yahoo_write_ready(c->id, c->fd, c->data);
if (ret == -1) {
LOG(("Yahoo read error (%d): %s", errno, strerror(errno)));
- } else if (ret == 0)
+ }
+ else if (ret == 0)
LOG(("Yahoo read error: Server closed socket"));
}
-
+
//LOG(("[yahoo_callback] id: %d exiting...", c->id));
}
@@ -1346,23 +1347,23 @@ int CYahooProto::ext_connect_async(const char *host, int port, int type, yahoo_c {
int err = 0;
INT_PTR res;
-
- LOG(("[ext_connect_async] %s:%d type: %d", host, port, type));
-
- res = ext_connect(host, port, type);
+
+ LOG(("[ext_connect_async] %s:%d type: %d", host, port, type));
+
+ res = ext_connect(host, port, type);
LOG(("[ext_connect_async] %s:%d type: %d, result: %d", host, port, type, res));
-
+
if (type == YAHOO_CONNECTION_PAGER && res < 1) {
err = 1;
- }
-
+ }
+
/*
* need to call the callback so we could handle the failure condition!!!
* fd = -1 in case of an error
*/
callback(res, err, data);
-
+
/*
* Return proper thing: 0 - ok, -1 - failed, >0 - pending connect
*/
@@ -1373,57 +1374,59 @@ int CYahooProto::ext_connect_async(const char *host, int port, int type, yahoo_c ***********************************/
char * CYahooProto::ext_send_https_request(struct yahoo_data *yd, const char *host, const char *path)
{
- NETLIBHTTPREQUEST nlhr={0},*nlhrReply;
- char z[4096], *result=NULL;
+ NETLIBHTTPREQUEST nlhr = { 0 }, *nlhrReply;
+ char z[4096], *result = NULL;
int i;
-
+
mir_snprintf(z, SIZEOF(z), "https://%s%s", host, path);
- nlhr.cbSize = sizeof(nlhr);
- nlhr.requestType= REQUEST_GET;
- nlhr.flags = NLHRF_HTTP11 | NLHRF_NODUMPSEND | NLHRF_DUMPASTEXT; /* Use HTTP/1.1 and don't dump the requests to the log */
- nlhr.szUrl = z;
+ nlhr.cbSize = sizeof(nlhr);
+ nlhr.requestType = REQUEST_GET;
+ nlhr.flags = NLHRF_HTTP11 | NLHRF_NODUMPSEND | NLHRF_DUMPASTEXT; /* Use HTTP/1.1 and don't dump the requests to the log */
+ nlhr.szUrl = z;
nlhr.headersCount = 3;
- nlhr.headers=(NETLIBHTTPHEADER*)mir_alloc(sizeof(NETLIBHTTPHEADER)*(nlhr.headersCount+5));
- nlhr.headers[0].szName = "User-Agent";
+ nlhr.headers = (NETLIBHTTPHEADER*)mir_alloc(sizeof(NETLIBHTTPHEADER)*(nlhr.headersCount + 5));
+ nlhr.headers[0].szName = "User-Agent";
nlhr.headers[0].szValue = NETLIB_USER_AGENT;
- nlhr.headers[1].szName = "Cache-Control";
+ nlhr.headers[1].szName = "Cache-Control";
nlhr.headers[1].szValue = "no-cache";
- nlhr.headers[2].szName = "Connection";
+ nlhr.headers[2].szName = "Connection";
nlhr.headers[2].szValue = "close"; /*"Keep-Alive";*/
-
- nlhrReply=(NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION,(WPARAM)g_hNetlibUser,(LPARAM)&nlhr);
+
+ nlhrReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)g_hNetlibUser, (LPARAM)&nlhr);
if (nlhrReply) {
-
+
if (nlhrReply->resultCode == 200 && nlhrReply->pData != NULL) {
result = strdup(nlhrReply->pData);
- } else {
- LOG(("[ext_send_https_request] Got result code: %d, content length: %d", nlhrReply->resultCode, nlhrReply->dataLength));
}
-
+ else {
+ LOG(("[ext_send_https_request] Got result code: %d, content length: %d", nlhrReply->resultCode, nlhrReply->dataLength));
+ }
+
LOG(("Got %d headers!", nlhrReply->headersCount));
-
- for (i=0; i < nlhrReply->headersCount; i++) {
+
+ for (i = 0; i < nlhrReply->headersCount; i++) {
//LOG(("%s: %s", nlhrReply->headers[i].szName, nlhrReply->headers[i].szValue));
-
+
if (mir_strcmpi(nlhrReply->headers[i].szName, "Set-Cookie") == 0) {
//LOG(("Found Cookie... Yum yum..."));
-
+
if (nlhrReply->headers[i].szValue[0] == 'B' && nlhrReply->headers[i].szValue[1] == '=') {
-
+
FREE(yd->cookie_b);
yd->cookie_b = getcookie(nlhrReply->headers[i].szValue);
-
+
LOG(("Got B Cookie: %s", yd->cookie_b));
}
}
}
-
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,(LPARAM)nlhrReply);
- } else {
+
+ CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply);
+ }
+ else {
LOG(("No Response???"));
}
-
+
mir_free(nlhr.headers);
return result;
@@ -1432,7 +1435,7 @@ char * CYahooProto::ext_send_https_request(struct yahoo_data *yd, const char *ho void CYahooProto::ext_login(enum yahoo_status login_mode)
{
char host[128], fthost[128], login_host[128];
- int port=0;
+ int port = 0;
DBVARIANT dbv;
#ifdef HTTP_GATEWAY
NETLIBUSERSETTINGS nlus = { 0 };
@@ -1441,63 +1444,65 @@ void CYahooProto::ext_login(enum yahoo_status login_mode) LOG(("[ext_login]"));
host[0] = '\0';
-
+
/**
* Implementing Yahoo 9 2 Stage Login using their VIP server/services
*/
- NETLIBHTTPREQUEST nlhr={0},*nlhrReply;
+ NETLIBHTTPREQUEST nlhr = { 0 }, *nlhrReply;
char z[4096];
- mir_snprintf(z, SIZEOF(z), "http://%s%s", getByte("YahooJapan",0) != 0 ? "cs1.msg.vip.ogk.yahoo.co.jp" : "vcs.msg.yahoo.com", "/capacity");
- nlhr.cbSize = sizeof(nlhr);
- nlhr.requestType= REQUEST_GET;
- nlhr.flags = NLHRF_HTTP11;
- nlhr.szUrl = z;
+ mir_snprintf(z, SIZEOF(z), "http://%s%s", getByte("YahooJapan", 0) != 0 ? "cs1.msg.vip.ogk.yahoo.co.jp" : "vcs.msg.yahoo.com", "/capacity");
+ nlhr.cbSize = sizeof(nlhr);
+ nlhr.requestType = REQUEST_GET;
+ nlhr.flags = NLHRF_HTTP11;
+ nlhr.szUrl = z;
- nlhrReply=(NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION,(WPARAM)g_hNetlibUser,(LPARAM)&nlhr);
+ nlhrReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)g_hNetlibUser, (LPARAM)&nlhr);
if (nlhrReply) {
if (nlhrReply->resultCode == 200 && nlhrReply->pData != NULL) {
- char *c = strstr(nlhrReply->pData,"CS_IP_ADDRESS=");
-
+ char *c = strstr(nlhrReply->pData, "CS_IP_ADDRESS=");
+
if (c != NULL) {
- char *t = c;
-
- while ( (*t) != '=') t++; /* scan until = */
- t++;
-
- while ( (*c) != '\0' && (*c) != '\r' && (*c) != '\n') c++;
-
- memcpy(host, t, c - t);
- host[c - t] = '\0';
-
- LOG(("Got Host: %s", host));
+ char *t = c;
+
+ while ((*t) != '=') t++; /* scan until = */
+ t++;
+
+ while ((*c) != '\0' && (*c) != '\r' && (*c) != '\n') c++;
+
+ memcpy(host, t, c - t);
+ host[c - t] = '\0';
+
+ LOG(("Got Host: %s", host));
}
- } else {
+ }
+ else {
LOG(("Problem retrieving a response from VIP server."));
}
-
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,(LPARAM)nlhrReply);
- }
-
- if (host[0] == '\0') {
+
+ CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply);
+ }
+
+ if (host[0] == '\0') {
if (!getString(YAHOO_LOGINSERVER, &dbv)) {
strncpy_s(host, dbv.pszVal, _TRUNCATE);
db_free(&dbv);
- } else {
- strncpy_s(host, (getByte("YahooJapan",0) ? YAHOO_DEFAULT_JAPAN_LOGIN_SERVER : YAHOO_DEFAULT_LOGIN_SERVER), _TRUNCATE);
+ }
+ else {
+ strncpy_s(host, (getByte("YahooJapan", 0) ? YAHOO_DEFAULT_JAPAN_LOGIN_SERVER : YAHOO_DEFAULT_LOGIN_SERVER), _TRUNCATE);
}
}
-
- mir_strncpy(fthost,getByte("YahooJapan",0)?"filetransfer.msg.yahoo.co.jp":"filetransfer.msg.yahoo.com" , sizeof(fthost));
- mir_strncpy(login_host,getByte("YahooJapan",0)?"login.yahoo.co.jp":"login.yahoo.com" , sizeof(login_host));
+
+ mir_strncpy(fthost, getByte("YahooJapan", 0) ? "filetransfer.msg.yahoo.co.jp" : "filetransfer.msg.yahoo.com", sizeof(fthost));
+ mir_strncpy(login_host, getByte("YahooJapan", 0) ? "login.yahoo.co.jp" : "login.yahoo.com", sizeof(login_host));
port = getWord(NULL, YAHOO_LOGINPORT, YAHOO_DEFAULT_PORT);
-
+
#ifdef HTTP_GATEWAY
nlus.cbSize = sizeof( nlus );
if (CallService(MS_NETLIB_GETUSERSETTINGS, (WPARAM) hNetlibUser, (LPARAM) &nlus) == 0) {
LOG(("ERROR: Problem retrieving miranda network settings!!!"));
}
-
+
iHTTPGateway = (nlus.useProxy && nlus.proxyType == PROXYTYPE_HTTP) ? 1:0;
LOG(("Proxy Type: %d HTTP Gateway: %d", nlus.proxyType, iHTTPGateway));
#endif
@@ -1512,13 +1517,13 @@ void CYahooProto::ext_login(enum yahoo_status login_mode) #endif
"login_host", login_host,
NULL);
-
+
m_status = YAHOO_STATUS_OFFLINE;
yahoo_login(m_id, login_mode);
if (m_id <= 0) {
LOG(("Could not connect to Yahoo server. Please verify that you are connected to the net and the pager host and port are correctly entered."));
- ShowError( TranslateT("Yahoo Login Error"), TranslateT("Could not connect to Yahoo server. Please verify that you are connected to the net and the pager host and port are correctly entered."));
+ ShowError(TranslateT("Yahoo Login Error"), TranslateT("Could not connect to Yahoo server. Please verify that you are connected to the net and the pager host and port are correctly entered."));
return;
}
@@ -1528,203 +1533,203 @@ void CYahooProto::ext_login(enum yahoo_status login_mode) /////////////////////////////////////////////////////////////////////////////////////////
// stubs
-CYahooProto* __fastcall getProtoById( int id )
+CYahooProto* __fastcall getProtoById(int id)
{
- for ( int i=0; i < g_instances.getCount(); i++ )
- if ( g_instances[i]->m_id == id )
+ for (int i = 0; i < g_instances.getCount(); i++)
+ if (g_instances[i]->m_id == id)
return g_instances[i];
return NULL;
}
unsigned int ext_yahoo_add_handler(int id, INT_PTR fd, yahoo_input_condition cond, void *data)
-{
- CYahooProto* ppro = getProtoById( id );
- if ( ppro )
+{
+ CYahooProto* ppro = getProtoById(id);
+ if (ppro)
return ppro->ext_add_handler(fd, cond, data);
-
+
return 0;
}
void ext_yahoo_remove_handler(int id, unsigned int tag)
{
- GETPROTOBYID( id )->ext_remove_handler(tag);
+ GETPROTOBYID(id)->ext_remove_handler(tag);
}
void ext_yahoo_status_changed(int id, const char *who, int protocol, int stat, const char *msg, int away, int idle, int mobile, int utf8)
-{
- GETPROTOBYID( id )->ext_status_changed(who, protocol, stat, msg, away, idle, mobile, utf8);
+{
+ GETPROTOBYID(id)->ext_status_changed(who, protocol, stat, msg, away, idle, mobile, utf8);
}
void ext_yahoo_status_logon(int id, const char *who, int protocol, int stat, const char *msg, int away, int idle, int mobile, int cksum, int buddy_icon, long client_version, int utf8)
-{
- GETPROTOBYID( id )->ext_status_logon(who, protocol, stat, msg, away, idle, mobile, cksum, buddy_icon, client_version, utf8);
+{
+ GETPROTOBYID(id)->ext_status_logon(who, protocol, stat, msg, away, idle, mobile, cksum, buddy_icon, client_version, utf8);
}
void ext_yahoo_got_audible(int id, const char *me, const char *who, const char *aud, const char *msg, const char *aud_hash)
-{
- GETPROTOBYID( id )->ext_got_audible(me, who, aud, msg, aud_hash);
+{
+ GETPROTOBYID(id)->ext_got_audible(me, who, aud, msg, aud_hash);
}
void ext_yahoo_got_calendar(int id, const char *url, int type, const char *msg, int svc)
-{
- GETPROTOBYID( id )->ext_got_calendar(url, type, msg, svc);
+{
+ GETPROTOBYID(id)->ext_got_calendar(url, type, msg, svc);
}
void ext_yahoo_got_stealth(int id, char *stealthlist)
-{
- GETPROTOBYID( id )->ext_got_stealth(stealthlist);
+{
+ GETPROTOBYID(id)->ext_got_stealth(stealthlist);
}
void ext_yahoo_got_buddies(int id, YList * buds)
-{
- GETPROTOBYID( id )->ext_got_buddies(buds);
+{
+ GETPROTOBYID(id)->ext_got_buddies(buds);
}
void ext_yahoo_rejected(int id, const char *who, const char *msg)
-{
- GETPROTOBYID( id )->ext_rejected(who, msg);
+{
+ GETPROTOBYID(id)->ext_rejected(who, msg);
}
void ext_yahoo_buddy_added(int id, char *myid, char *who, char *group, int status, int auth)
-{
- GETPROTOBYID( id )->ext_buddy_added(myid, who, group, status, auth);
+{
+ GETPROTOBYID(id)->ext_buddy_added(myid, who, group, status, auth);
}
void ext_yahoo_buddy_group_changed(int id, char *myid, char *who, char *old_group, char *new_group)
-{
+{
LOG(("[ext_yahoo_buddy_group_changed] %s has been moved from group: %s to: %s", who, old_group, new_group));
}
void ext_yahoo_contact_added(int id, const char *myid, const char *who, const char *fname, const char *lname, const char *msg, int protocol)
-{
- GETPROTOBYID( id )->ext_contact_added(myid, who, fname, lname, msg, protocol);
+{
+ GETPROTOBYID(id)->ext_contact_added(myid, who, fname, lname, msg, protocol);
}
void ext_yahoo_typing_notify(int id, const char *me, const char *who, int protocol, int stat)
-{
- GETPROTOBYID( id )->ext_typing_notify(me, who, protocol, stat);
+{
+ GETPROTOBYID(id)->ext_typing_notify(me, who, protocol, stat);
}
void ext_yahoo_game_notify(int id, const char *me, const char *who, int stat, const char *msg)
-{
- GETPROTOBYID( id )->ext_game_notify(me, who, stat, msg);
+{
+ GETPROTOBYID(id)->ext_game_notify(me, who, stat, msg);
}
void ext_yahoo_mail_notify(int id, const char *from, const char *subj, int cnt)
-{
- GETPROTOBYID( id )->ext_mail_notify(from, subj, cnt);
+{
+ GETPROTOBYID(id)->ext_mail_notify(from, subj, cnt);
}
void ext_yahoo_system_message(int id, const char *me, const char *who, const char *msg)
-{
- GETPROTOBYID( id )->ext_system_message(me, who, msg);
+{
+ GETPROTOBYID(id)->ext_system_message(me, who, msg);
}
void ext_yahoo_got_identities(int id, const char *nick, const char *fname, const char *lname, YList * ids)
-{
- GETPROTOBYID( id )->ext_got_identities(nick, fname, lname, ids);
+{
+ GETPROTOBYID(id)->ext_got_identities(nick, fname, lname, ids);
}
void ext_yahoo_got_ping(int id, const char *errormsg)
-{
- GETPROTOBYID( id )->ext_got_ping(errormsg);
+{
+ GETPROTOBYID(id)->ext_got_ping(errormsg);
}
void ext_yahoo_error(int id, const char *err, int fatal, int num)
-{
- GETPROTOBYID( id )->ext_error(err, fatal, num);
+{
+ GETPROTOBYID(id)->ext_error(err, fatal, num);
}
void ext_yahoo_login_response(int id, int succ, const char *url)
-{
- GETPROTOBYID( id )->ext_login_response(succ, url);
+{
+ GETPROTOBYID(id)->ext_login_response(succ, url);
}
void ext_yahoo_got_im(int id, const char *me, const char *who, int protocol, const char *msg, long tm, int stat, int utf8, int buddy_icon, const char *seqn, int sendn)
-{
- GETPROTOBYID( id )->ext_got_im(me, who, protocol, msg, tm, stat, utf8, buddy_icon, seqn, sendn);
+{
+ GETPROTOBYID(id)->ext_got_im(me, who, protocol, msg, tm, stat, utf8, buddy_icon, seqn, sendn);
}
void ext_yahoo_got_search_result(int id, int found, int start, int total, YList *contacts)
-{
- GETPROTOBYID( id )->ext_got_search_result(found, start, total, contacts);
+{
+ GETPROTOBYID(id)->ext_got_search_result(found, start, total, contacts);
}
void ext_yahoo_got_picture(int id, const char *me, const char *who, const char *pic_url, int cksum, int type)
-{
- GETPROTOBYID( id )->ext_got_picture(me, who, pic_url, cksum, type);
+{
+ GETPROTOBYID(id)->ext_got_picture(me, who, pic_url, cksum, type);
}
void ext_yahoo_got_picture_checksum(int id, const char *me, const char *who, int cksum)
-{
- GETPROTOBYID( id )->ext_got_picture_checksum(me, who, cksum);
+{
+ GETPROTOBYID(id)->ext_got_picture_checksum(me, who, cksum);
}
void ext_yahoo_got_picture_update(int id, const char *me, const char *who, int buddy_icon)
-{
- GETPROTOBYID( id )->ext_got_picture_update(me, who, buddy_icon);
+{
+ GETPROTOBYID(id)->ext_got_picture_update(me, who, buddy_icon);
}
void ext_yahoo_got_picture_status(int id, const char *me, const char *who, int buddy_icon)
-{
- GETPROTOBYID( id )->ext_got_picture_status(me, who, buddy_icon);
+{
+ GETPROTOBYID(id)->ext_got_picture_status(me, who, buddy_icon);
}
-void ext_yahoo_got_picture_upload(int id, const char *me, const char *url,unsigned int ts)
-{
- GETPROTOBYID( id )->ext_got_picture_upload(me, url, ts);
+void ext_yahoo_got_picture_upload(int id, const char *me, const char *url, unsigned int ts)
+{
+ GETPROTOBYID(id)->ext_got_picture_upload(me, url, ts);
}
void ext_yahoo_got_avatar_share(int id, int buddy_icon)
-{
- GETPROTOBYID( id )->ext_got_avatar_share(buddy_icon);
+{
+ GETPROTOBYID(id)->ext_got_avatar_share(buddy_icon);
}
void ext_yahoo_got_file(int id, const char *me, const char *who, const char *url, long expires, const char *msg, const char *fname, unsigned long fesize, const char *ft_token, int y7)
-{
- GETPROTOBYID( id )->ext_got_file(me, who, url, expires, msg, fname, fesize, ft_token, y7);
+{
+ GETPROTOBYID(id)->ext_got_file(me, who, url, expires, msg, fname, fesize, ft_token, y7);
}
void ext_yahoo_got_files(int id, const char *me, const char *who, const char *ft_token, int y7, YList* files)
-{
- GETPROTOBYID( id )->ext_got_files(me, who, ft_token, y7, files);
+{
+ GETPROTOBYID(id)->ext_got_files(me, who, ft_token, y7, files);
}
void ext_yahoo_got_file7info(int id, const char *me, const char *who, const char *url, const char *fname, const char *ft_token)
-{
- GETPROTOBYID( id )->ext_got_file7info(me, who, url, fname, ft_token);
+{
+ GETPROTOBYID(id)->ext_got_file7info(me, who, url, fname, ft_token);
}
void ext_yahoo_ft7_send_file(int id, const char *me, const char *who, const char *filename, const char *token, const char *ft_token)
-{
- GETPROTOBYID( id )->ext_ft7_send_file(me, who, filename, token, ft_token);
+{
+ GETPROTOBYID(id)->ext_ft7_send_file(me, who, filename, token, ft_token);
}
int ext_yahoo_connect_async(int id, const char *host, int port, int type, yahoo_connect_callback callback, void *data)
-{
- CYahooProto* ppro = getProtoById( id );
- if ( ppro )
+{
+ CYahooProto* ppro = getProtoById(id);
+ if (ppro)
return ppro->ext_connect_async(host, port, type, callback, data);
return SOCKET_ERROR;
}
void ext_yahoo_send_http_request(int id, enum yahoo_connection_type type, const char *method, const char *url, const char *cookies, long content_length, yahoo_get_fd_callback callback, void *callback_data)
-{
- GETPROTOBYID( id )->ext_send_http_request(type, method, url, cookies, content_length, callback, callback_data);
+{
+ GETPROTOBYID(id)->ext_send_http_request(type, method, url, cookies, content_length, callback, callback_data);
}
char *ext_yahoo_send_https_request(struct yahoo_data *yd, const char *host, const char *path)
{
- CYahooProto* ppro = getProtoById( yd->client_id );
- if ( ppro )
+ CYahooProto* ppro = getProtoById(yd->client_id);
+ if (ppro)
return ppro->ext_send_https_request(yd, host, path);
return NULL;
}
void ext_yahoo_got_ignore(int id, YList * igns)
-{
- GETPROTOBYID( id )->ext_got_ignore( igns );
+{
+ GETPROTOBYID(id)->ext_got_ignore(igns);
}
void register_callbacks()
@@ -1778,20 +1783,20 @@ void register_callbacks() yc.ext_yahoo_send_http_request = ext_yahoo_send_http_request;
yc.ext_yahoo_got_stealthlist = ext_yahoo_got_stealth;
- yc.ext_yahoo_got_ping = ext_yahoo_got_ping;
- yc.ext_yahoo_got_picture = ext_yahoo_got_picture;
+ yc.ext_yahoo_got_ping = ext_yahoo_got_ping;
+ yc.ext_yahoo_got_picture = ext_yahoo_got_picture;
yc.ext_yahoo_got_picture_checksum = ext_yahoo_got_picture_checksum;
yc.ext_yahoo_got_picture_update = ext_yahoo_got_picture_update;
yc.ext_yahoo_got_avatar_share = ext_yahoo_got_avatar_share;
-
+
yc.ext_yahoo_buddy_added = ext_yahoo_buddy_added;
yc.ext_yahoo_got_picture_upload = ext_yahoo_got_picture_upload;
yc.ext_yahoo_got_picture_status = ext_yahoo_got_picture_status;
yc.ext_yahoo_got_audible = ext_yahoo_got_audible;
yc.ext_yahoo_got_calendar = ext_yahoo_got_calendar;
yc.ext_yahoo_buddy_group_changed = ext_yahoo_buddy_group_changed;
-
+
yc.ext_yahoo_send_https_request = ext_yahoo_send_https_request;
-
+
yahoo_register_callbacks(&yc);
}
|