summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/Scriver/resource.h12
-rw-r--r--plugins/Scriver/utils.h8
-rw-r--r--protocols/Yahoo/avatar.cpp16
-rw-r--r--protocols/Yahoo/file_transfer.cpp6
-rw-r--r--protocols/Yahoo/im.cpp4
-rw-r--r--protocols/Yahoo/proto.cpp82
-rw-r--r--protocols/Yahoo/proto.h7
-rw-r--r--protocols/Yahoo/services.cpp4
-rw-r--r--protocols/Yahoo/util.cpp29
-rw-r--r--protocols/Yahoo/yahoo.cpp134
10 files changed, 168 insertions, 134 deletions
diff --git a/plugins/Scriver/resource.h b/plugins/Scriver/resource.h
index 6d4b18402b..07ea9a6546 100644
--- a/plugins/Scriver/resource.h
+++ b/plugins/Scriver/resource.h
@@ -24,12 +24,12 @@
#define IDI_CLOSEX 135
#define IDI_GOOGLE 140
-#define IDI_BING 141
-#define IDI_WIKIPEDIA 142
-#define IDI_GOOGLE_MAPS 143
-#define IDI_GOOGLE_TRANSLATE 144
+#define IDI_BING 141
+#define IDI_WIKIPEDIA 142
+#define IDI_GOOGLE_MAPS 143
+#define IDI_GOOGLE_TRANSLATE 144
#define IDI_YAHOO 145
-#define IDI_FOODNETWORK 146
+#define IDI_FOODNETWORK 146
#define IDR_CONTEXT 180
@@ -193,7 +193,7 @@
#define IDM_SEARCH_WIKIPEDIA 40082
#define IDM_SEARCH_GOOGLE_MAPS 40083
#define IDM_SEARCH_GOOGLE_TRANSLATE 40084
-#define IDM_SEARCH_YAHOO 40085
+#define IDM_SEARCH_YAHOO 40085
#define IDM_SEARCH_FOODNETWORK 40086
/* chat.dll resources */
diff --git a/plugins/Scriver/utils.h b/plugins/Scriver/utils.h
index a0da80f6ff..f92375f161 100644
--- a/plugins/Scriver/utils.h
+++ b/plugins/Scriver/utils.h
@@ -26,10 +26,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
enum SEARCHENGINES {
SEARCHENGINE_GOOGLE = 1,
SEARCHENGINE_BING = 2,
- SEARCHENGINE_YAHOO = 3,
- SEARCHENGINE_WIKIPEDIA = 4,
- SEARCHENGINE_GOOGLE_MAPS = 5,
- SEARCHENGINE_GOOGLE_TRANSLATE = 6,
+ SEARCHENGINE_WIKIPEDIA = 3,
+ SEARCHENGINE_GOOGLE_MAPS = 4,
+ SEARCHENGINE_GOOGLE_TRANSLATE = 5,
+ SEARCHENGINE_YAHOO = 6,
SEARCHENGINE_FOODNETWORK=7
};
diff --git a/protocols/Yahoo/avatar.cpp b/protocols/Yahoo/avatar.cpp
index 9b093ccb3d..3c8a9471e7 100644
--- a/protocols/Yahoo/avatar.cpp
+++ b/protocols/Yahoo/avatar.cpp
@@ -178,7 +178,7 @@ void __cdecl CYahooProto::recv_avatarthread(void *pavt)
hContact = getbuddyH(avt->who);
- if (!hContact){
+ if (!hContact) {
LOG(("ERROR: Can't find buddy: %s", avt->who));
error = 1;
} else if (!error) {
@@ -295,7 +295,7 @@ void CYahooProto::ext_got_picture(const char *me, const char *who, const char *p
/* need to read CheckSum */
cksum = GetDword("AvatarHash", 0);
if (cksum) {
- if (!DBGetContactSettingString(NULL, m_szModuleName, "AvatarURL", &dbv)) {
+ if (!GetString("AvatarURL", &dbv)) {
LOG(("[ext_yahoo_got_picture] Sending url: %s checksum: %d to '%s'!", dbv.pszVal, cksum, who));
//void yahoo_send_picture_info(int id, const char *me, const char *who, const char *pic_url, int cksum)
yahoo_send_picture_info(m_id, who, 2, dbv.pszVal, cksum);
@@ -307,7 +307,7 @@ void CYahooProto::ext_got_picture(const char *me, const char *who, const char *p
/*
* Try to re-upload the avatar
*/
- if (GetByte("AvatarUL", 0) != 1){
+ if (GetByte("AvatarUL", 0) != 1) {
// NO avatar URL??
if (!DBGetContactSettingTString(NULL, m_szModuleName, "AvatarFile", &dbv)) {
struct _stat statbuf;
@@ -406,7 +406,7 @@ void CYahooProto::ext_got_picture(const char *me, const char *who, const char *p
LOG(("[ext_yahoo_got_picture] My Checksum: %d", mcksum));
- if (!DBGetContactSettingString(NULL, m_szModuleName, "AvatarURL", &dbv)) {
+ if (!GetString("AvatarURL", &dbv)) {
if (lstrcmpiA(pic_url, dbv.pszVal) == 0) {
DBVARIANT dbv2;
/*time_t ts;
@@ -562,7 +562,7 @@ void CYahooProto::ext_got_picture_upload(const char *me, const char *url,unsigne
SetString(NULL, "AvatarURL", url);
//YAHOO_SetDword("AvatarExpires", ts);
- if (!DBGetContactSettingString(NULL, m_szModuleName, "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));
@@ -676,7 +676,7 @@ INT_PTR __cdecl CYahooProto::GetAvatarInfo(WPARAM wParam,LPARAM lParam)
DBVARIANT dbv;
int avtType;
- if (!DBGetContactSettingString(AI->hContact, m_szModuleName, YAHOO_LOGINID, &dbv)) {
+ if (!GetString(AI->hContact, YAHOO_LOGINID, &dbv)) {
DebugLog("[YAHOO_GETAVATARINFO] For: %s", dbv.pszVal);
DBFreeVariant(&dbv);
}else {
@@ -718,7 +718,7 @@ INT_PTR __cdecl CYahooProto::GetAvatarInfo(WPARAM wParam,LPARAM lParam)
} else if ( m_bLoggedIn ) {
DBVARIANT dbv;
- if (!DBGetContactSettingString(AI->hContact, m_szModuleName, YAHOO_LOGINID, &dbv)) {
+ if (!GetString(AI->hContact, YAHOO_LOGINID, &dbv)) {
DebugLog("[YAHOO_GETAVATARINFO] Requesting avatar!");
request_avatar(dbv.pszVal);
@@ -811,7 +811,7 @@ INT_PTR __cdecl CYahooProto::GetMyAvatar(WPARAM wParam, LPARAM lParam)
if (GetDword("AvatarHash", 0)) {
if (!DBGetContactSettingTString(NULL, m_szModuleName, "AvatarFile", &dbv)) {
- if (_taccess(dbv.ptszVal, 0) == 0){
+ if (_taccess(dbv.ptszVal, 0) == 0) {
lstrcpyn(buffer, dbv.ptszVal, size-1);
buffer[size-1] = '\0';
diff --git a/protocols/Yahoo/file_transfer.cpp b/protocols/Yahoo/file_transfer.cpp
index 58958c3c4a..038ba3ea05 100644
--- a/protocols/Yahoo/file_transfer.cpp
+++ b/protocols/Yahoo/file_transfer.cpp
@@ -107,7 +107,7 @@ static void free_ft(y_filetransfer* ft)
LOG(("[free_ft] token: %s", ft->ftoken));
for(l = file_transfers; l; l = y_list_next(l)) {
- if (l->data == ft){
+ if (l->data == ft) {
LOG(("[free_ft] Ft found and removed from the list"));
file_transfers = y_list_remove_link(file_transfers, l);
y_list_free_1(l);
@@ -324,7 +324,7 @@ static void dl_file(int id, int fd, int error, const char *filename, unsigned lo
LOG(("[dl_file] Got action: %ld", sf->action));
- switch(sf->action){
+ switch(sf->action) {
case FILERESUME_RENAME:
case FILERESUME_OVERWRITE:
case FILERESUME_RESUME:
@@ -742,7 +742,7 @@ HANDLE __cdecl CYahooProto::SendFile( HANDLE hContact, const PROTOCHAR* szDescri
DebugLog("Getting Yahoo ID");
*/
- if (!DBGetContactSettingString(hContact, m_szModuleName, YAHOO_LOGINID, &dbv)) {
+ if (!GetString(hContact, YAHOO_LOGINID, &dbv)) {
long tFileSize = 0;
struct _stat statbuf;
struct yahoo_file_info *fi;
diff --git a/protocols/Yahoo/im.cpp b/protocols/Yahoo/im.cpp
index 03360e2374..7478b1090b 100644
--- a/protocols/Yahoo/im.cpp
+++ b/protocols/Yahoo/im.cpp
@@ -213,7 +213,7 @@ int __cdecl CYahooProto::SendMsg( HANDLE hContact, int flags, const char* pszSrc
return 1;
}
- if (!DBGetContactSettingString( hContact, m_szModuleName, YAHOO_LOGINID, &dbv)) {
+ if (!GetString( hContact, YAHOO_LOGINID, &dbv)) {
send_msg(dbv.pszVal, GetWord( hContact, "yprotoid", 0), msg, (!bANSI) ? 1 : 0);
if (!bANSI)
@@ -262,7 +262,7 @@ INT_PTR __cdecl CYahooProto::SendNudge(WPARAM wParam, LPARAM lParam)
}
DBVARIANT dbv;
- if (!DBGetContactSettingString(hContact, m_szModuleName, YAHOO_LOGINID, &dbv)) {
+ if (!GetString(hContact, YAHOO_LOGINID, &dbv)) {
send_msg(dbv.pszVal, GetWord(hContact, "yprotoid", 0), "<ding>", 0);
DBFreeVariant(&dbv);
diff --git a/protocols/Yahoo/proto.cpp b/protocols/Yahoo/proto.cpp
index e5de41ae29..37a3af24d1 100644
--- a/protocols/Yahoo/proto.cpp
+++ b/protocols/Yahoo/proto.cpp
@@ -115,7 +115,7 @@ HANDLE CYahooProto::AddToList( int flags, PROTOSEARCHRESULT* psr )
{
DebugLog("[YahooAddToList] Flags: %d", flags);
- if (!m_bLoggedIn){
+ if (!m_bLoggedIn) {
DebugLog("[YahooAddToList] WARNING: WE ARE OFFLINE!");
return 0;
}
@@ -149,14 +149,13 @@ HANDLE CYahooProto::AddToList( int flags, PROTOSEARCHRESULT* psr )
HANDLE __cdecl CYahooProto::AddToListByEvent( int flags, int /*iContact*/, HANDLE hDbEvent )
{
- DBEVENTINFO dbei;
+ DBEVENTINFO dbei = {0};
HANDLE hContact;
DebugLog("[YahooAddToListByEvent]");
if ( !m_bLoggedIn )
return 0;
- memset( &dbei, 0, sizeof( dbei ));
dbei.cbSize = sizeof( dbei );
if (( dbei.cbBlob = YAHOO_CallService( MS_DB_EVENT_GETBLOBSIZE, ( LPARAM )hDbEvent, 0 )) == -1 ) {
@@ -240,11 +239,18 @@ int CYahooProto::Authorize( HANDLE hdbe )
memcpy(&hContact,( char* )( dbei.pBlob + sizeof( DWORD ) ), sizeof(HANDLE));
/* Need to remove the buddy from our Miranda Lists */
- DBVARIANT dbv;
- if (hContact != NULL && !DBGetContactSettingString( hContact, m_szModuleName, YAHOO_LOGINID, &dbv )) {
- DebugLog("Accepting buddy:%s", dbv.pszVal);
- accept(dbv.pszVal, GetWord(hContact, "yprotoid", 0));
- DBFreeVariant(&dbv);
+
+ if (hContact != NULL) {
+ char *who = DBGetString(hContact, m_szModuleName, YAHOO_LOGINID);
+ if (!who) return 0;
+
+ char *myid = DBGetString(hContact, m_szModuleName, "MyIdentity");
+
+ DebugLog("Accepting buddy:%s", who);
+ accept(myid, who, GetWord(hContact, "yprotoid", 0));
+
+ mir_free(myid);
+ mir_free(who);
}
return 0;
@@ -285,21 +291,24 @@ int CYahooProto::AuthDeny( HANDLE hdbe, const TCHAR* reason )
}
HANDLE hContact;
- memcpy(&hContact,( char* )( dbei.pBlob + sizeof( DWORD ) ), sizeof(HANDLE));
+ memcpy(&hContact, dbei.pBlob + sizeof(DWORD), sizeof(HANDLE));
/* Need to remove the buddy from our Miranda Lists */
- DBVARIANT dbv;
- if (hContact != NULL && !DBGetContactSettingString( hContact, m_szModuleName, YAHOO_LOGINID, &dbv )) {
- char *u_reason;
-
- u_reason = mir_utf8encodeT(reason);
+ if (hContact != NULL)
+ {
+ char *who = DBGetString(hContact, m_szModuleName, YAHOO_LOGINID);
+ if (!who) return 0;
+
+ char *myid = DBGetString(hContact, m_szModuleName, "MyIdentity");
+ char *u_reason = mir_utf8encodeT(reason);
- DebugLog("Rejecting buddy:%s msg: %s", dbv.pszVal, u_reason);
- reject(dbv.pszVal, GetWord(hContact, "yprotoid", 0), u_reason);
- DBFreeVariant(&dbv);
- YAHOO_CallService( MS_DB_CONTACT_DELETE, (WPARAM) hContact, 0);
+ DebugLog("Rejecting buddy:%s msg: %s", who, u_reason);
+ reject(myid, who, GetWord(hContact, "yprotoid", 0), u_reason);
+ YAHOO_CallService(MS_DB_CONTACT_DELETE, (WPARAM) hContact, 0);
mir_free(u_reason);
+ mir_free(myid);
+ mir_free(who);
}
return 0;
}
@@ -337,21 +346,8 @@ int __cdecl CYahooProto::AuthRequest( HANDLE hContact, const TCHAR* msg )
DebugLog("[YahooSendAuthRequest]");
if (hContact && m_bLoggedIn) {
- if (hContact) {
- DBVARIANT dbv;
- if (!DBGetContactSettingString(hContact, m_szModuleName, YAHOO_LOGINID, &dbv )) {
- char *u_msg;
-
- u_msg = mir_utf8encodeT(msg);
- DebugLog("Adding buddy:%s Auth:%s", dbv.pszVal, u_msg);
- AddBuddy( dbv.pszVal, GetWord(hContact, "yprotoid", 0), "miranda", u_msg );
- SetString(hContact, "YGroup", "miranda");
- DBFreeVariant( &dbv );
-
- mir_free(u_msg);
- return 0; // Success
- }
- }
+ AddBuddy(hContact, "miranda", msg);
+ return 0; // Success
}
return 1; // Failure
@@ -509,9 +505,9 @@ int __cdecl CYahooProto::SetApparentMode( HANDLE hContact, int mode )
if (mode && mode != ID_STATUS_OFFLINE)
return 1;
- int oldMode = DBGetContactSettingWord(hContact, m_szModuleName, "ApparentMode", 0);
+ int oldMode = GetWord(hContact, "ApparentMode", 0);
if (mode != oldMode)
- DBWriteContactSettingWord(hContact, m_szModuleName, "ApparentMode", (WORD)mode);
+ SetWord(hContact, "ApparentMode", mode);
return 1;
}
@@ -570,7 +566,7 @@ int __cdecl CYahooProto::SetStatus( int iNewStatus )
lstrcpynA(errmsg, Translate("Please enter your yahoo password in Options/Network/Yahoo"), 80);
}
- if (err != 0){
+ if (err != 0) {
BroadcastStatus(ID_STATUS_OFFLINE);
ShowError(Translate("Yahoo Login Error"), errmsg);
@@ -601,7 +597,7 @@ int __cdecl CYahooProto::SetStatus( int iNewStatus )
iNewStatus = (iNewStatus == ID_STATUS_INVISIBLE) ? YAHOO_STATUS_INVISIBLE: YAHOO_STATUS_AVAILABLE;
YForkThread(&CYahooProto::server_main, (void *)iNewStatus);
}
- else if (iNewStatus == ID_STATUS_INVISIBLE){ /* other normal away statuses are set via setaway */
+ else if (iNewStatus == ID_STATUS_INVISIBLE) { /* other normal away statuses are set via setaway */
BroadcastStatus(iNewStatus);
set_status(m_iStatus,NULL,(m_iStatus != ID_STATUS_ONLINE) ? 1 : 0);
}
@@ -628,7 +624,7 @@ void __cdecl CYahooProto::get_status_thread(HANDLE hContact)
Sleep( 150 );
/* Check Yahoo Games Message */
- if (! DBGetContactSettingString(( HANDLE )hContact, m_szModuleName, "YGMsg", &dbv )) {
+ if (!GetString(hContact, "YGMsg", &dbv)) {
gm = strdup(dbv.pszVal);
DBFreeVariant( &dbv );
@@ -640,7 +636,7 @@ void __cdecl CYahooProto::get_status_thread(HANDLE hContact)
DBFreeVariant( &dbv );
} else {
- WORD status = DBGetContactSettingWord(hContact, m_szModuleName, "YStatus", YAHOO_STATUS_OFFLINE);
+ WORD status = GetWord(hContact, "YStatus", YAHOO_STATUS_OFFLINE);
sm = yahoo_status_code( yahoo_status( status ));
if (sm) sm = strdup(sm); /* we need this to go global FREE later */
}
@@ -685,7 +681,7 @@ HANDLE __cdecl CYahooProto::GetAwayMsg( HANDLE hContact )
DebugLog("[YahooGetAwayMessage] ");
if (hContact && m_bLoggedIn) {
- if (DBGetContactSettingWord(hContact, m_szModuleName, "Status", ID_STATUS_OFFLINE) == ID_STATUS_OFFLINE)
+ if (GetWord(hContact, "Status", ID_STATUS_OFFLINE) == ID_STATUS_OFFLINE)
return 0; /* user offline, what Status message? */
YForkThread(&CYahooProto::get_status_thread, hContact);
@@ -720,7 +716,7 @@ int __cdecl CYahooProto::SetAwayMsg( int status, const PROTOCHAR* msg )
DebugLog("[YahooSetAwayMessage] Status: %s, Msg: %s",(char *) CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, status, 0), (char*) c);
- if (!m_bLoggedIn){
+ if (!m_bLoggedIn) {
if (m_iStatus == ID_STATUS_OFFLINE) {
DebugLog("[YahooSetAwayMessage] WARNING: WE ARE OFFLINE!");
mir_free(c);
@@ -745,7 +741,7 @@ int __cdecl CYahooProto::SetAwayMsg( int status, const PROTOCHAR* msg )
m_startMsg = strdup(c);
if(status == ID_STATUS_ONLINE) {
set_status(YAHOO_CUSTOM_STATUS, c, 0);
- } else if(status != ID_STATUS_INVISIBLE){
+ } else if(status != ID_STATUS_INVISIBLE) {
set_status(YAHOO_CUSTOM_STATUS, c, 1);
}
} else {
@@ -785,7 +781,7 @@ int __cdecl CYahooProto::UserIsTyping( HANDLE hContact, int type )
return 0;
DBVARIANT dbv;
- if (!DBGetContactSettingString(hContact, m_szModuleName, YAHOO_LOGINID, &dbv)) {
+ if (!GetString(hContact, YAHOO_LOGINID, &dbv)) {
if (type == PROTOTYPE_SELFTYPING_OFF || type == PROTOTYPE_SELFTYPING_ON) {
sendtyping(dbv.pszVal, GetWord(hContact, "yprotoid", 0), type == PROTOTYPE_SELFTYPING_ON?1:0);
}
diff --git a/protocols/Yahoo/proto.h b/protocols/Yahoo/proto.h
index bdcbf51a36..539bd2a6b3 100644
--- a/protocols/Yahoo/proto.h
+++ b/protocols/Yahoo/proto.h
@@ -225,6 +225,7 @@ struct CYahooProto : public PROTO_INTERFACE
int GetString( const char* name, DBVARIANT* );
int GetString( HANDLE hContact, const char* name, DBVARIANT* );
+ int GetStringUtf( HANDLE hContact, const char* name, DBVARIANT* );
void SetString( const char* name, const char* value );
void SetString( HANDLE hContact, const char* name, const char* value );
@@ -261,8 +262,8 @@ struct CYahooProto : public PROTO_INTERFACE
void logout();
- void accept(const char *who, int protocol);
- void reject(const char *who, int protocol, const char *msg);
+ void accept(const char *myid, const char *who, int protocol);
+ void reject(const char *myid, const char *who, int protocol, const char *msg);
void sendtyping(const char *who, int protocol, int stat);
void set_status(int myyahooStatus, char *msg, int away);
void stealth(const char *buddy, int add);
@@ -292,7 +293,7 @@ struct CYahooProto : public PROTO_INTERFACE
void ext_login_response(int succ, const char *url);
void ext_login(enum yahoo_status login_mode);
- void AddBuddy( const char *who, int protocol, const char *group, const char *msg);
+ void AddBuddy(HANDLE hContact, const char *group, const TCHAR *msg);
void YAHOO_utils_logversion();
diff --git a/protocols/Yahoo/services.cpp b/protocols/Yahoo/services.cpp
index 77e99626ed..8bf397ce95 100644
--- a/protocols/Yahoo/services.cpp
+++ b/protocols/Yahoo/services.cpp
@@ -105,7 +105,7 @@ INT_PTR __cdecl CYahooProto::OnContactDeleted( WPARAM wParam, LPARAM lParam )
return 0;
}
- if ( !DBGetContactSettingString(hContact, m_szModuleName, YAHOO_LOGINID, &dbv )) {
+ if (!GetString(hContact, YAHOO_LOGINID, &dbv)) {
DebugLog("[YahooContactDeleted] Removing %s", dbv.pszVal);
remove_buddy(dbv.pszVal, GetWord(hContact, "yprotoid", 0));
@@ -265,7 +265,7 @@ INT_PTR __cdecl CYahooProto::OnShowProfileCommand( WPARAM wParam, LPARAM lParam
return 0;
}
- if ( DBGetContactSettingString(( HANDLE )wParam, m_szModuleName, YAHOO_LOGINID, &dbv ))
+ if (GetString((HANDLE)wParam, YAHOO_LOGINID, &dbv))
return 0;
_snprintf( tUrl, sizeof( tUrl ), "http://profiles.yahoo.com/%s", dbv.pszVal );
diff --git a/protocols/Yahoo/util.cpp b/protocols/Yahoo/util.cpp
index f259b12d33..197bc37497 100644
--- a/protocols/Yahoo/util.cpp
+++ b/protocols/Yahoo/util.cpp
@@ -182,6 +182,10 @@ int CYahooProto::GetString( HANDLE hContact, const char* name, DBVARIANT* result
{ return DBGetContactSettingString( hContact, m_szModuleName, name, result );
}
+int CYahooProto::GetStringUtf( HANDLE hContact, const char* name, DBVARIANT* result )
+{ return DBGetContactSettingStringUtf(hContact, m_szModuleName, name, result);
+}
+
void CYahooProto::SetString( const char* name, const char* value )
{ DBWriteContactSettingString(NULL, m_szModuleName, name, value );
}
@@ -301,33 +305,16 @@ INT_PTR __cdecl CYahooProto::OnSettingChanged(WPARAM wParam, LPARAM lParam)
{
DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *) lParam;
- if ((HANDLE) wParam == NULL)
- return 0;
- if (!m_bLoggedIn)
+ if (!wParam || !m_bLoggedIn)
return 0;
- if (!strcmp(cws->szModule, "CList")) {
- // A temporary contact has been added permanently
- if (!strcmp(cws->szSetting, "NotOnList")) {
- if (DBGetContactSettingByte((HANDLE) wParam, "CList", "Hidden", 0))
- return 0;
- if (cws->value.type == DBVT_DELETED || (cws->value.type == DBVT_BYTE && cws->value.bVal == 0)) {
- DBVARIANT dbv;
-
- if ( !DBGetContactSettingString( (HANDLE) wParam, m_szModuleName, YAHOO_LOGINID, &dbv )) {
- DebugLog("Adding Permanently %s to list.", dbv.pszVal);
- AddBuddy(dbv.pszVal,GetWord((HANDLE) wParam, "yprotoid", 0), "miranda", NULL);
- DBFreeVariant(&dbv);
- }
- }
- }
- }else if (!strcmp(cws->szModule, m_szModuleName) && !strcmp(cws->szSetting, "ApparentMode")) {
+ if (!strcmp(cws->szSetting, "ApparentMode")) {
DBVARIANT dbv;
DebugLog("DB Setting changed. YAHOO user's visible setting changed.");
- if ( !DBGetContactSettingString( (HANDLE) wParam, m_szModuleName, YAHOO_LOGINID, &dbv )) {
- int iAdd = (ID_STATUS_OFFLINE == DBGetContactSettingWord((HANDLE) wParam, m_szModuleName, "ApparentMode", 0));
+ if (!GetString((HANDLE)wParam, YAHOO_LOGINID, &dbv)) {
+ int iAdd = (ID_STATUS_OFFLINE == GetWord((HANDLE) wParam, "ApparentMode", 0));
stealth(dbv.pszVal, iAdd);
DBFreeVariant(&dbv);
}
diff --git a/protocols/Yahoo/yahoo.cpp b/protocols/Yahoo/yahoo.cpp
index f14a311d0a..b39e243d8f 100644
--- a/protocols/Yahoo/yahoo.cpp
+++ b/protocols/Yahoo/yahoo.cpp
@@ -189,7 +189,7 @@ void CYahooProto::remove_buddy(const char *who, int protocol)
LOG(("[remove_buddy] Buddy: '%s' protocol: %d", who, protocol));
DBVARIANT dbv;
- if ( DBGetContactSettingString( getbuddyH(who), m_szModuleName, "YGroup", &dbv )) {
+ if (GetStringUtf(getbuddyH(who), "YGroup", &dbv)) {
LOG(("WARNING NO DATABASE GROUP using 'miranda'!"));
yahoo_remove_buddy(m_id, who, protocol, "miranda");
return;
@@ -205,14 +205,14 @@ void CYahooProto::sendtyping(const char *who, int protocol, int stat)
yahoo_send_typing(m_id, NULL, who, protocol, stat);
}
-void CYahooProto::accept(const char *who, int protocol)
+void CYahooProto::accept(const char *myid, const char *who, int protocol)
{
- yahoo_accept_buddy(m_id, who, protocol);
+ yahoo_accept_buddy(m_id, myid, who, protocol);
}
-void CYahooProto::reject(const char *who, int protocol, const char *msg)
+void CYahooProto::reject(const char *myid, const char *who, int protocol, const char *msg)
{
- yahoo_reject_buddy(m_id, who, protocol, msg);
+ yahoo_reject_buddy(m_id, myid, who, protocol, msg);
}
void CYahooProto::logout()
@@ -226,10 +226,11 @@ void CYahooProto::logout()
poll_loop = 0;
}
-void CYahooProto::AddBuddy( const char *who, int protocol, const char *group, const char *msg)
+void CYahooProto::AddBuddy(HANDLE hContact, const char *group, const TCHAR *msg)
{
DBVARIANT dbv;
- char *fname=NULL, *lname=NULL;
+ char *fname=NULL, *lname=NULL, *ident=NULL, *who, *u_msg;
+ int protocol;
/* We adding a buddy to our list.
2 Stages.
@@ -238,20 +239,45 @@ void CYahooProto::AddBuddy( const char *who, int protocol, const char *group, co
No refresh needed. */
- if ( !DBGetContactSettingString( NULL, m_szModuleName, "First Name", &dbv )) {
+ if (!GetString(hContact, YAHOO_LOGINID, &dbv))
+ {
+ who = strdup(dbv.pszVal);
+ DBFreeVariant(&dbv);
+ }
+ else
+ return;
+
+ protocol = GetWord(hContact, "yprotoid", 0);
+ u_msg = mir_utf8encodeT(msg);
+
+ if (!GetString(hContact, "MyIdentity", &dbv))
+ {
+ ident = strdup(dbv.pszVal);
+ DBFreeVariant(&dbv);
+ }
+
+ if (!GetStringUtf(NULL, "FirstName", &dbv))
+ {
fname = strdup(dbv.pszVal);
DBFreeVariant(&dbv);
}
- if ( !DBGetContactSettingString( NULL, m_szModuleName, "Last Name", &dbv )) {
+ if (!GetStringUtf(NULL, "LastName", &dbv))
+ {
lname = strdup(dbv.pszVal);
DBFreeVariant(&dbv);
}
- yahoo_add_buddy(m_id, fname, lname, who, protocol, group, msg);
+ SetStringUtf(hContact, "YGroup", group);
+
+ DebugLog("Adding Permanently %s to list. Auth: %s", who, u_msg ? u_msg : "<None>");
+ yahoo_add_buddy(m_id, ident, fname, lname, who, protocol, group, u_msg);
- FREE(fname);
- FREE(lname);
+ free(fname);
+ free(lname);
+ free(ident);
+ free(who);
+ mir_free(u_msg);
}
HANDLE CYahooProto::getbuddyH(const char *yahoo_id)
@@ -267,7 +293,7 @@ HANDLE CYahooProto::getbuddyH(const char *yahoo_id)
if ( szProto != NULL && !lstrcmpA( szProto, m_szModuleName ))
{
DBVARIANT dbv;
- if ( DBGetContactSettingString( hContact, m_szModuleName, YAHOO_LOGINID, &dbv ))
+ if (GetString(hContact, YAHOO_LOGINID, &dbv))
continue;
{
@@ -335,7 +361,7 @@ const char* CYahooProto::find_buddy( const char *yahoo_id)
hContact = getbuddyH(yahoo_id);
if (hContact != NULL) {
- if ( DBGetContactSettingString( hContact, m_szModuleName, "Nick", &dbv ))
+ if (GetStringUtf(hContact, "Nick", &dbv))
return NULL;
strncpy(nick, dbv.pszVal, 128);
@@ -431,7 +457,7 @@ void CYahooProto::ext_status_logon(const char *who, int protocol, int stat, cons
if (protocol == 0) {
char *s = NULL;
- switch (client_version & 0x7FFFBF) {
+ switch (client_version & 0x1FFFFBF) {
case 2:
s = "Yahoo Mobile";
break;
@@ -441,11 +467,12 @@ void CYahooProto::ext_status_logon(const char *who, int protocol, int stat, cons
break;
case 3075:
+ case 0x00880C03:
s = "Yahoo Web Messenger";
break;
case 35846:
- s = "iPhone Y! Messenger"; // iPhone Y! Messenger 1.5
+ s = "Go!Chat for Android";
break;
case 262651:
@@ -476,18 +503,36 @@ void CYahooProto::ext_status_logon(const char *who, int protocol, int stat, cons
case 822543: /* ? "Yahoo Version 3.0 beta 1 (build 18274) OSX" */
case 1572799: /* 8.0.x ?? */
- case 2097087: /* 8.1.0.195 */
+ case 2097087: /* 8.1.0.195 */
+ case 0x009FFFBF:
s = "Yahoo 8.x";
break;
case 2088895:
case 4194239:
+ case 0x00BFFFBF:
s = "Yahoo 9.0";
break;
case 8388543:
s = "Yahoo 10.0";
break;
+
+ case 0x01FFFFBF:
+ s = "Yahoo 11.0";
+ break;
+
+ case 0x01498C06:
+ s = "Yahoo for iPhone";
+ break;
+
+ case 0x01498C07:
+ s = "Yahoo for Android";
+ break;
+
+ case 0x00AD9F1F:
+ s = "Yahoo for Mac v3";
+ break;
}
if (s != NULL)
@@ -509,7 +554,7 @@ void CYahooProto::ext_status_logon(const char *who, int protocol, int stat, cons
// we got some avatartype info
DBWriteContactSettingByte(hContact, m_szModuleName, "AvatarType", buddy_icon);
- if (cksum == 0 || cksum == -1){
+ if (cksum == 0 || cksum == -1) {
// no avatar
DBWriteContactSettingDword(hContact, m_szModuleName, "PictCK", 0);
} else if (DBGetContactSettingDword(hContact, m_szModuleName,"PictCK", 0) != cksum) {
@@ -584,7 +629,7 @@ void CYahooProto::ext_got_stealth(char *stealthlist)
szProto = ( char* )YAHOO_CallService( MS_PROTO_GETCONTACTBASEPROTO, ( WPARAM )hContact, 0 );
if ( szProto != NULL && !lstrcmpA( szProto, m_szModuleName )) {
DBVARIANT dbv;
- if ( DBGetContactSettingString( hContact, m_szModuleName, YAHOO_LOGINID, &dbv ))
+ if (GetString( hContact, YAHOO_LOGINID, &dbv))
continue;
found = 0;
@@ -602,13 +647,13 @@ void CYahooProto::ext_got_stealth(char *stealthlist)
if (found) { /* we have him on our Stealth List */
YAHOO_DEBUGLOG("Setting STEALTH for id = %s", dbv.pszVal);
/* need to set the ApparentMode thingy */
- if (ID_STATUS_OFFLINE != DBGetContactSettingWord(hContact, m_szModuleName, "ApparentMode", 0))
- DBWriteContactSettingWord(hContact, m_szModuleName, "ApparentMode", (WORD) ID_STATUS_OFFLINE);
+ if (ID_STATUS_OFFLINE != GetWord(hContact, "ApparentMode", 0))
+ GetWord(hContact, "ApparentMode", ID_STATUS_OFFLINE);
} else { /* he is not on the Stealth List */
//LOG(("Resetting STEALTH for id = %s", dbv.pszVal));
/* need to delete the ApparentMode thingy */
- if (DBGetContactSettingWord(hContact, m_szModuleName, "ApparentMode", 0))
+ if (GetWord(hContact, "ApparentMode", 0))
DBDeleteContactSetting(hContact, m_szModuleName, "ApparentMode");
}
@@ -646,18 +691,18 @@ void CYahooProto::ext_got_buddies(YList * buds)
Set_Protocol(hContact, bud->protocol);
if (bud->group)
- SetString( hContact, "YGroup", bud->group);
+ SetStringUtf(hContact, "YGroup", bud->group);
if (bud->stealth) { /* we have him on our Stealth List */
YAHOO_DEBUGLOG("Setting STEALTH for id = %s", bud->id);
/* need to set the ApparentMode thingy */
- if (ID_STATUS_OFFLINE != DBGetContactSettingWord(hContact, m_szModuleName, "ApparentMode", 0))
- DBWriteContactSettingWord(hContact, m_szModuleName, "ApparentMode", (WORD) ID_STATUS_OFFLINE);
+ if (ID_STATUS_OFFLINE != GetWord(hContact, "ApparentMode", 0))
+ SetWord(hContact, "ApparentMode", (WORD) ID_STATUS_OFFLINE);
} else { /* he is not on the Stealth List */
//LOG(("Resetting STEALTH for id = %s", dbv.pszVal));
/* need to delete the ApparentMode thingy */
- if (DBGetContactSettingWord(hContact, m_szModuleName, "ApparentMode", 0))
+ if (GetWord(hContact, "ApparentMode", 0))
DBDeleteContactSetting(hContact, m_szModuleName, "ApparentMode");
}
@@ -772,24 +817,29 @@ void CYahooProto::ext_contact_added(const char *myid, const char *who, const cha
nick[0] = '\0';
- if (lname != NULL) {
- if (fname != NULL) {
- mir_snprintf(nick, sizeof(nick), "%s %s", fname, lname);
- } else {
- mir_snprintf(nick, sizeof(nick), "%s", lname);
- }
- } else if (fname != NULL) {
+ if (lname && fname)
+ mir_snprintf(nick, sizeof(nick), "%s %s", fname, lname);
+ else if (lname)
+ mir_snprintf(nick, sizeof(nick), "%s", lname);
+ else if (fname)
mir_snprintf(nick, sizeof(nick), "%s", fname);
- }
if (nick[0] == '\0')
mir_snprintf(nick, sizeof(nick), "%s", who);
+ if (fname) SetStringUtf(hContact, "FirstName", fname);
+ if (lname) SetStringUtf(hContact, "LastName", lname);
+
hContact = add_buddy(who, nick, protocol, PALF_TEMPORARY);
- if (lstrcmpA(nick, who) != 0)
- SetStringUtf( hContact, "Nick", nick);
-
+ if (strcmp(nick, who) != 0)
+ SetStringUtf(hContact, "Nick", nick);
+
+ if (strcmp(myid, m_yahoo_id))
+ SetString(hContact, "MyIdentity", myid);
+ else
+ DBDeleteContactSetting(hContact, m_szModuleName, "MyIdentity");
+
//SetWord(hContact, "yprotoid", protocol);
Set_Protocol(hContact, protocol);
@@ -953,7 +1003,7 @@ void CYahooProto::ext_game_notify(const char *me, const char *who, int stat, con
(*c) = '\0';
}
- SetString(hContact, "YGMsg", z);
+ SetStringUtf(hContact, "YGMsg", z);
} else {
/* ? no information / reset custom message */
@@ -979,7 +1029,7 @@ void CYahooProto::ext_mail_notify(const char *from, const char *subj, int cnt)
snprintf(z, sizeof(z), Translate("From: %s\nSubject: %s"), from, subj);
}
- if (!ShowPopup( title, z, "http://mail.yahoo.com" ))
+ if(!ShowPopup( title, z, "http://mail.yahoo.com" ))
ShowNotification(title, z, NIIF_INFO);
}
}
@@ -1002,8 +1052,8 @@ void CYahooProto::ext_got_identities(const char *nick, const char *fname, const
/* FIXME - Not implemented - Got list of Yahoo! identities */
/* We currently only use the default identity */
/* Also Stubbed in Sample Client */
- SetString(NULL, "First Name", fname ? fname : "");
- SetString(NULL, "Last Name", lname ? lname : "");
+ SetStringUtf(NULL, "FirstName", fname ? fname : "");
+ SetStringUtf(NULL, "LastName", lname ? lname : "");
}
void __cdecl yahoo_get_yab_thread(void *psf)
@@ -1538,7 +1588,7 @@ void CYahooProto::ext_login(enum yahoo_status login_mode)
lstrcpynA(fthost,GetByte("YahooJapan",0)?"filetransfer.msg.yahoo.co.jp":"filetransfer.msg.yahoo.com" , sizeof(fthost));
lstrcpynA(login_host,GetByte("YahooJapan",0)?"login.yahoo.co.jp":"login.yahoo.com" , sizeof(login_host));
- port = DBGetContactSettingWord(NULL, m_szModuleName, YAHOO_LOGINPORT, YAHOO_DEFAULT_PORT);
+ port = GetWord(NULL, YAHOO_LOGINPORT, YAHOO_DEFAULT_PORT);
#ifdef HTTP_GATEWAY
nlus.cbSize = sizeof( nlus );