summaryrefslogtreecommitdiff
path: root/protocols/Yahoo/proto.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-06-04 16:05:04 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-06-04 16:05:04 +0000
commita4a275e150788c7b3da197a26899a2afad393768 (patch)
tree3ea7388e3ba2a1fffe20de14a4b70c40c1e3a291 /protocols/Yahoo/proto.cpp
parentab2438d317799cc265c6f392f877947c61ecd585 (diff)
sync
git-svn-id: http://svn.miranda-ng.org/main/trunk@298 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Yahoo/proto.cpp')
-rw-r--r--protocols/Yahoo/proto.cpp82
1 files changed, 39 insertions, 43 deletions
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);
}