diff options
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/FacebookRM/avatars.cpp | 17 | ||||
-rw-r--r-- | protocols/FacebookRM/communication.cpp | 115 | ||||
-rw-r--r-- | protocols/FacebookRM/constants.h | 13 | ||||
-rw-r--r-- | protocols/FacebookRM/contacts.cpp | 62 | ||||
-rw-r--r-- | protocols/FacebookRM/proto.cpp | 19 | ||||
-rw-r--r-- | protocols/FacebookRM/proto.h | 2 | ||||
-rw-r--r-- | protocols/FacebookRM/theme.cpp | 18 | ||||
-rw-r--r-- | protocols/FacebookRM/theme.h | 3 |
8 files changed, 122 insertions, 127 deletions
diff --git a/protocols/FacebookRM/avatars.cpp b/protocols/FacebookRM/avatars.cpp index a316d9fe68..6b7e735c29 100644 --- a/protocols/FacebookRM/avatars.cpp +++ b/protocols/FacebookRM/avatars.cpp @@ -180,11 +180,19 @@ int FacebookProto::GetAvatarInfo(WPARAM wParam, LPARAM lParam) if (!lParam)
return GAIR_NOAVATAR;
- PROTO_AVATAR_INFORMATION* AI = ( PROTO_AVATAR_INFORMATION* )lParam;
+ PROTO_AVATAR_INFORMATION* AI = (PROTO_AVATAR_INFORMATION*)lParam;
if (GetDbAvatarInfo(*AI, NULL))
{
- if (_access(AI->filename, 0) || (wParam & GAIF_FORCE))
+ bool fileExist = _access(AI->filename, 0) == 0;
+
+ bool needLoad;
+ if (AI->hContact)
+ needLoad = (wParam & GAIF_FORCE) && (!fileExist || DBGetContactSettingByte(AI->hContact, "ContactPhoto", "NeedUpdate", 0));
+ else
+ needLoad = (wParam & GAIF_FORCE) || !fileExist;
+
+ if (needLoad)
{
LOG("***** Starting avatar request thread for %s", AI->filename);
ScopedLock s( avatar_lock_ );
@@ -196,12 +204,11 @@ int FacebookProto::GetAvatarInfo(WPARAM wParam, LPARAM lParam) if (is_empty)
ForkThread(&FacebookProto::UpdateAvatarWorker, this, NULL);
}
-
return GAIR_WAITFOR;
}
+ else if (fileExist)
+ return GAIR_SUCCESS;
- LOG("***** Giving AvatarInfo: %s", AI->filename);
- return GAIR_SUCCESS;
}
return GAIR_NOAVATAR;
}
diff --git a/protocols/FacebookRM/communication.cpp b/protocols/FacebookRM/communication.cpp index 2e4dfc81f0..d9d93632e7 100644 --- a/protocols/FacebookRM/communication.cpp +++ b/protocols/FacebookRM/communication.cpp @@ -34,7 +34,7 @@ http::response facebook_client::flap( const int request_type, std::string* reque std::string url = choose_request_url( request_type, request_data, request_get_data );
nlhr.szUrl = (char*)url.c_str( );
nlhr.flags = NLHRF_HTTP11 | NLHRF_NODUMP | choose_security_level( request_type );
- nlhr.headers = get_request_headers( request_type, &nlhr.headersCount );
+ nlhr.headers = get_request_headers( nlhr.requestType, &nlhr.headersCount );
switch (request_type)
{
@@ -234,6 +234,7 @@ DWORD facebook_client::choose_security_level( int request_type ) // case FACEBOOK_REQUEST_DELETE_FRIEND:
// case FACEBOOK_REQUEST_REQUEST_FRIEND:
// case FACEBOOK_REQUEST_APPROVE_FRIEND:
+// case FACEBOOK_REQUEST_CANCEL_REQUEST:
// case FACEBOOK_REQUEST_FEEDS:
// case FACEBOOK_REQUEST_NOTIFICATIONS:
// case FACEBOOK_REQUEST_RECONNECT:
@@ -266,6 +267,7 @@ int facebook_client::choose_method( int request_type ) case FACEBOOK_REQUEST_DELETE_FRIEND:
case FACEBOOK_REQUEST_REQUEST_FRIEND:
case FACEBOOK_REQUEST_APPROVE_FRIEND:
+ case FACEBOOK_REQUEST_CANCEL_REQUEST:
return REQUEST_POST;
// case FACEBOOK_REQUEST_HOME:
@@ -283,40 +285,10 @@ int facebook_client::choose_method( int request_type ) std::string facebook_client::choose_proto( int request_type )
{
- if (this->https_) {
- if ( request_type != FACEBOOK_REQUEST_MESSAGES_RECEIVE
- || DBGetContactSettingByte( NULL, parent->m_szModuleName, FACEBOOK_KEY_FORCE_HTTPS_CHANNEL, DEFAULT_FORCE_HTTPS_CHANNEL ) )
- return HTTP_PROTO_SECURE;
- }
-
- switch ( request_type )
- {
-// case FACEBOOK_REQUEST_LOGOUT:
-// case FACEBOOK_REQUEST_HOME:
-// case FACEBOOK_REQUEST_FEEDS:
-// case FACEBOOK_REQUEST_NOTIFICATIONS:
-// case FACEBOOK_REQUEST_RECONNECT:
-// case FACEBOOK_REQUEST_BUDDY_LIST:
-// case FACEBOOK_REQUEST_LOAD_FRIENDS:
-// case FACEBOOK_REQUEST_LOAD_REQUESTS:
-// case FACEBOOK_REQUEST_SEARCH:
-// case FACEBOOK_REQUEST_STATUS_SET:
-// case FACEBOOK_REQUEST_MESSAGE_SEND:
-// case FACEBOOK_REQUEST_MESSAGES_RECEIVE:
-// case FACEBOOK_REQUEST_VISIBILITY:
-// case FACEBOOK_REQUEST_TABS:
-// case FACEBOOK_REQUEST_ASYNC:
-// case FACEBOOK_REQUEST_TYPING_SEND:
-// case FACEBOOK_REQUEST_DELETE_FRIEND:
-// case FACEBOOK_REQUEST_REQUEST_FRIEND:
-// case FACEBOOK_REQUEST_APPROVE_FRIEND:
- default:
- return HTTP_PROTO_REGULAR;
-
- case FACEBOOK_REQUEST_LOGIN:
- case FACEBOOK_REQUEST_SETUP_MACHINE:
+ if (choose_security_level(request_type) == NLHRF_SSL)
return HTTP_PROTO_SECURE;
- }
+ else
+ return HTTP_PROTO_REGULAR;
}
std::string facebook_client::choose_server( int request_type, std::string* data, std::string* get_data )
@@ -358,6 +330,7 @@ std::string facebook_client::choose_server( int request_type, std::string* data, // case FACEBOOK_REQUEST_SETUP_MACHINE:
// case FACEBOOK_REQUEST_DELETE_FRIEND:
// case FACEBOOK_REQUEST_REQUEST_FRIEND:
+// case FACEBOOK_REQUEST_CANCEL_REQUEST:
default:
return FACEBOOK_SERVER_REGULAR;
}
@@ -422,6 +395,11 @@ std::string facebook_client::choose_action( int request_type, std::string* data, return action;
}
+ case FACEBOOK_REQUEST_CANCEL_REQUEST:
+ {
+ return "/ajax/friends/requests/cancel.php?__a=1";
+ }
+
case FACEBOOK_REQUEST_FEEDS:
{
std::string action = "/ajax/intent.php?filter=";
@@ -508,73 +486,28 @@ std::string facebook_client::choose_request_url( int request_type, std::string* NETLIBHTTPHEADER* facebook_client::get_request_headers( int request_type, int* headers_count )
{
- switch ( request_type )
- {
- case FACEBOOK_REQUEST_LOGIN:
- case FACEBOOK_REQUEST_SETUP_MACHINE:
- case FACEBOOK_REQUEST_BUDDY_LIST:
- case FACEBOOK_REQUEST_LOAD_FRIENDS:
- case FACEBOOK_REQUEST_LOAD_REQUESTS:
- case FACEBOOK_REQUEST_SEARCH:
- case FACEBOOK_REQUEST_STATUS_SET:
- case FACEBOOK_REQUEST_MESSAGE_SEND:
- case FACEBOOK_REQUEST_VISIBILITY:
- case FACEBOOK_REQUEST_TABS:
- case FACEBOOK_REQUEST_ASYNC:
- case FACEBOOK_REQUEST_TYPING_SEND:
- case FACEBOOK_REQUEST_DELETE_FRIEND:
- case FACEBOOK_REQUEST_REQUEST_FRIEND:
- case FACEBOOK_REQUEST_APPROVE_FRIEND:
+ if (request_type == REQUEST_POST)
*headers_count = 5;
- break;
-
- case FACEBOOK_REQUEST_HOME:
- case FACEBOOK_REQUEST_FEEDS:
- case FACEBOOK_REQUEST_NOTIFICATIONS:
- case FACEBOOK_REQUEST_RECONNECT:
- case FACEBOOK_REQUEST_MESSAGES_RECEIVE:
- default:
+ else
*headers_count = 4;
- break;
- }
NETLIBHTTPHEADER* headers = ( NETLIBHTTPHEADER* )utils::mem::allocate( sizeof( NETLIBHTTPHEADER )*( *headers_count ) );
- switch ( request_type )
+ if (request_type == REQUEST_POST)
{
- case FACEBOOK_REQUEST_LOGIN:
- case FACEBOOK_REQUEST_SETUP_MACHINE:
- case FACEBOOK_REQUEST_BUDDY_LIST:
- case FACEBOOK_REQUEST_LOAD_FRIENDS:
- case FACEBOOK_REQUEST_LOAD_REQUESTS:
- case FACEBOOK_REQUEST_SEARCH:
- case FACEBOOK_REQUEST_STATUS_SET:
- case FACEBOOK_REQUEST_MESSAGE_SEND:
- case FACEBOOK_REQUEST_VISIBILITY:
- case FACEBOOK_REQUEST_TABS:
- case FACEBOOK_REQUEST_ASYNC:
- case FACEBOOK_REQUEST_TYPING_SEND:
- case FACEBOOK_REQUEST_DELETE_FRIEND:
- case FACEBOOK_REQUEST_REQUEST_FRIEND:
- case FACEBOOK_REQUEST_APPROVE_FRIEND:
headers[4].szName = "Content-Type";
headers[4].szValue = "application/x-www-form-urlencoded; charset=utf-8";
-
- case FACEBOOK_REQUEST_HOME:
- case FACEBOOK_REQUEST_RECONNECT:
- case FACEBOOK_REQUEST_MESSAGES_RECEIVE:
- default:
- headers[3].szName = "Cookie";
- headers[3].szValue = load_cookies( );
- headers[2].szName = "User-Agent";
- headers[2].szValue = (char *)g_strUserAgent.c_str( );
- headers[1].szName = "Accept";
- headers[1].szValue = "*/*";
- headers[0].szName = "Accept-Language";
- headers[0].szValue = "en,en-US;q=0.9";
- break;
}
+ headers[3].szName = "Cookie";
+ headers[3].szValue = load_cookies( );
+ headers[2].szName = "User-Agent";
+ headers[2].szValue = (char *)g_strUserAgent.c_str( );
+ headers[1].szName = "Accept";
+ headers[1].szValue = "*/*";
+ headers[0].szName = "Accept-Language";
+ headers[0].szValue = "en,en-US;q=0.9";
+
return headers;
}
diff --git a/protocols/FacebookRM/constants.h b/protocols/FacebookRM/constants.h index e647cabf62..8662c7c145 100644 --- a/protocols/FacebookRM/constants.h +++ b/protocols/FacebookRM/constants.h @@ -93,12 +93,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #define FACEBOOK_REQUEST_SEARCH 111 // searching
#define FACEBOOK_REQUEST_BUDDY_LIST 120 // getting regular updates (friends online, ...)
#define FACEBOOK_REQUEST_LOAD_FRIENDS 121 // getting list of all friends
-#define FACEBOOK_REQUEST_DELETE_FRIEND 122 // deleting friends
-#define FACEBOOK_REQUEST_REQUEST_FRIEND 123 // requesting friends
-#define FACEBOOK_REQUEST_APPROVE_FRIEND 124 // approving friends
-#define FACEBOOK_REQUEST_FEEDS 125 // getting feeds
-#define FACEBOOK_REQUEST_NOTIFICATIONS 126 // getting notifications
-#define FACEBOOK_REQUEST_LOAD_REQUESTS 127 // getting friend requests
+#define FACEBOOK_REQUEST_FEEDS 122 // getting feeds
+#define FACEBOOK_REQUEST_NOTIFICATIONS 123 // getting notifications
+#define FACEBOOK_REQUEST_LOAD_REQUESTS 125 // getting friend requests
+#define FACEBOOK_REQUEST_REQUEST_FRIEND 126 // requesting friends
+#define FACEBOOK_REQUEST_APPROVE_FRIEND 127 // approving friends
+#define FACEBOOK_REQUEST_DELETE_FRIEND 128 // deleting friends
+#define FACEBOOK_REQUEST_CANCEL_REQUEST 129 // cancel friends request
#define FACEBOOK_REQUEST_RECONNECT 130 // getting __sequence_num__ and __channel_id__
#define FACEBOOK_REQUEST_STATUS_SET 251 // setting my "What's on my mind?"
#define FACEBOOK_REQUEST_MESSAGE_SEND 300 // sending message
diff --git a/protocols/FacebookRM/contacts.cpp b/protocols/FacebookRM/contacts.cpp index d9acefa076..66c1c3cacd 100644 --- a/protocols/FacebookRM/contacts.cpp +++ b/protocols/FacebookRM/contacts.cpp @@ -27,9 +27,9 @@ bool FacebookProto::IsMyContact(HANDLE hContact, bool include_chat) const char *proto = reinterpret_cast<char*>( CallService(MS_PROTO_GETCONTACTBASEPROTO,
reinterpret_cast<WPARAM>(hContact),0) );
- if ( proto && strcmp(m_szModuleName,proto) == 0 )
+ if( proto && strcmp(m_szModuleName,proto) == 0 )
{
- if ( include_chat )
+ if( include_chat )
return true;
else
return DBGetContactSettingByte(hContact,m_szModuleName,"ChatRoom",0) == 0;
@@ -44,13 +44,13 @@ HANDLE FacebookProto::ContactIDToHContact(std::string user_id) hContact;
hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact,0) )
{
- if (!IsMyContact(hContact))
+ if(!IsMyContact(hContact))
continue;
DBVARIANT dbv;
- if ( !DBGetContactSettingString(hContact,m_szModuleName,FACEBOOK_KEY_ID,&dbv) )
+ if( !DBGetContactSettingString(hContact,m_szModuleName,FACEBOOK_KEY_ID,&dbv) )
{
- if ( strcmp(user_id.c_str(),dbv.pszVal) == 0 )
+ if( strcmp(user_id.c_str(),dbv.pszVal) == 0 )
{
DBFreeVariant(&dbv);
return hContact;
@@ -70,15 +70,15 @@ HANDLE FacebookProto::AddToContactList(facebook_user* fbu, BYTE type, bool dont_ if (!dont_check) {
// First, check if this contact exists
hContact = ContactIDToHContact(fbu->user_id);
- if ( hContact )
+ if( hContact )
return hContact;
}
// If not, make a new contact!
hContact = (HANDLE)CallService(MS_DB_CONTACT_ADD, 0, 0);
- if ( hContact )
+ if( hContact )
{
- if ( CallService(MS_PROTO_ADDTOCONTACT,(WPARAM)hContact,(LPARAM)m_szModuleName) == 0 )
+ if( CallService(MS_PROTO_ADDTOCONTACT,(WPARAM)hContact,(LPARAM)m_szModuleName) == 0 )
{
DBWriteContactSettingString(hContact,m_szModuleName,FACEBOOK_KEY_ID,fbu->user_id.c_str());
@@ -90,7 +90,7 @@ HANDLE FacebookProto::AddToContactList(facebook_user* fbu, BYTE type, bool dont_ DBDeleteContactSetting(hContact, "CList", "MyHandle");
DBVARIANT dbv;
- if ( !DBGetContactSettingTString(NULL,m_szModuleName,FACEBOOK_KEY_DEF_GROUP,&dbv) )
+ if( !DBGetContactSettingTString(NULL,m_szModuleName,FACEBOOK_KEY_DEF_GROUP,&dbv) )
{
DBWriteContactSettingTString(hContact,"CList","Group",dbv.ptszVal);
DBFreeVariant(&dbv);
@@ -173,7 +173,7 @@ void FacebookProto::DeleteContactFromServer(void *data) DBWriteContactSettingDword(hContact, m_szModuleName, FACEBOOK_KEY_DELETED, ::time(NULL));
}
- NotifyEvent(TranslateT("Deleting contact"), TranslateT("Contact was sucessfully removed from your server list."), NULL, FACEBOOK_EVENT_OTHER, NULL);
+ NotifyEvent(m_tszUserName, TranslateT("Contact was removed from your server list."), NULL, FACEBOOK_EVENT_OTHER, NULL);
} else {
facy.client_notify( TranslateT("Error occured when removing contact from server.") );
}
@@ -217,7 +217,7 @@ void FacebookProto::AddContactToServer(void *data) DBWriteContactSettingByte(hContact, m_szModuleName, FACEBOOK_KEY_CONTACT_TYPE, FACEBOOK_CONTACT_REQUEST);
}
- NotifyEvent(TranslateT("Adding contact"), TranslateT("Request for friendship was sent successfully."), NULL, FACEBOOK_EVENT_OTHER, NULL);
+ NotifyEvent(m_tszUserName, TranslateT("Request for friendship was sent."), NULL, FACEBOOK_EVENT_OTHER, NULL);
} else {
facy.client_notify( TranslateT("Error occured when requesting friendship.") );
}
@@ -257,6 +257,46 @@ void FacebookProto::ApproveContactToServer(void *data) DBWriteContactSettingByte(hContact, m_szModuleName, FACEBOOK_KEY_CONTACT_TYPE, FACEBOOK_CONTACT_FRIEND);
}
+void FacebookProto::CancelFriendsRequest(void *data)
+{
+ facy.handle_entry( "CancelFriendsRequest" );
+
+ if ( data == NULL )
+ return;
+
+ HANDLE hContact = (*(HANDLE*)data);
+ delete data;
+
+ std::string query = "phstamp=0&confirmed=1";
+ query += "&fb_dtsg=" + facy.dtsg_;
+ query += "&__user=" + facy.self_.user_id;
+
+ DBVARIANT dbv;
+ if (!DBGetContactSettingString(hContact, m_szModuleName, FACEBOOK_KEY_ID, &dbv))
+ {
+ query += "&friend=" + std::string(dbv.pszVal);
+ DBFreeVariant(&dbv);
+ }
+
+ // Get unread inbox threads
+ http::response resp = facy.flap( FACEBOOK_REQUEST_CANCEL_REQUEST, &query );
+
+ // Process result data
+ facy.validate_response(&resp);
+
+ if (resp.data.find("\"payload\":null", 0) != std::string::npos)
+ {
+ DBWriteContactSettingByte(hContact, m_szModuleName, FACEBOOK_KEY_CONTACT_TYPE, FACEBOOK_CONTACT_NONE);
+ NotifyEvent(m_tszUserName, TranslateT("Request for friendship was canceled."), NULL, FACEBOOK_EVENT_OTHER, NULL);
+ } else {
+ facy.client_notify( TranslateT("Error occured when canceling friendship request.") );
+ }
+
+ if (resp.code != HTTP_CODE_OK)
+ facy.handle_error( "CancelFriendsRequest" );
+}
+
+
HANDLE FacebookProto::GetAwayMsg(HANDLE hContact)
{
return 0; // Status messages are disabled
diff --git a/protocols/FacebookRM/proto.cpp b/protocols/FacebookRM/proto.cpp index 992977b372..72222c1403 100644 --- a/protocols/FacebookRM/proto.cpp +++ b/protocols/FacebookRM/proto.cpp @@ -64,7 +64,7 @@ FacebookProto::FacebookProto(const char* proto_name,const TCHAR* username) mir_sntprintf(descr,SIZEOF(descr),TranslateT("%s server connection"),m_tszUserName);
nlu.ptszDescriptiveName = descr;
m_hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER,0,(LPARAM)&nlu);
- if(m_hNetlibUser == NULL)
+ if (m_hNetlibUser == NULL)
MessageBox(NULL,TranslateT("Unable to get Netlib connection for Facebook"),m_tszUserName,MB_OK);
facy.set_handle(m_hNetlibUser);
@@ -111,7 +111,7 @@ DWORD_PTR FacebookProto::GetCaps( int type, HANDLE hContact ) {
switch(type)
{
- case PFLAGNUM_1: // TODO: Other caps available: PF1_BASICSEARCH, PF1_SEARCHBYEMAIL
+ case PFLAGNUM_1:
{
DWORD_PTR flags = PF1_IM | PF1_CHAT | PF1_SERVERCLIST | PF1_AUTHREQ | /*PF1_ADDED |*/ PF1_BASICSEARCH | PF1_USERIDISEMAIL | PF1_SEARCHBYEMAIL | PF1_SEARCHBYNAME | PF1_ADDSEARCHRES; // | PF1_VISLIST | PF1_INVISLIST;
@@ -143,7 +143,7 @@ DWORD_PTR FacebookProto::GetCaps( int type, HANDLE hContact ) HICON FacebookProto::GetIcon(int index)
{
- if(LOWORD(index) == PLI_PROTOCOL)
+ if (LOWORD(index) == PLI_PROTOCOL)
{
HICON ico = (HICON)CallService(MS_SKIN2_GETICON,0,(LPARAM)"Facebook_facebook");
return CopyIcon(ico);
@@ -433,7 +433,7 @@ int FacebookProto::OnOptionsInit(WPARAM wParam,LPARAM lParam) CallService(MS_OPT_ADDPAGE,wParam,(LPARAM)&odp);
odp.position = 271830;
- if(ServiceExists(MS_POPUP_ADDPOPUPT))
+ if (ServiceExists(MS_POPUP_ADDPOPUPT))
odp.ptszGroup = LPGENT("Popups");
odp.ptszTab = LPGENT("Events");
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS_EVENTS);
@@ -555,6 +555,17 @@ int FacebookProto::ApproveFriendship(WPARAM wParam,LPARAM lParam) return 0;
}
+int FacebookProto::OnCancelFriendshipRequest(WPARAM wParam,LPARAM lParam)
+{
+ if (wParam == NULL || isOffline())
+ return 0;
+
+ HANDLE *hContact = new HANDLE(reinterpret_cast<HANDLE>(wParam));
+ ForkThread( &FacebookProto::CancelFriendsRequest, this, ( void* )hContact );
+
+ return 0;
+}
+
HANDLE FacebookProto::HContactFromAuthEvent(HANDLE hEvent)
{
DBEVENTINFO dbei;
diff --git a/protocols/FacebookRM/proto.h b/protocols/FacebookRM/proto.h index 8a10c5629a..6d956b0db9 100644 --- a/protocols/FacebookRM/proto.h +++ b/protocols/FacebookRM/proto.h @@ -119,6 +119,7 @@ public: int __cdecl CancelFriendship(WPARAM, LPARAM );
int __cdecl RequestFriendship(WPARAM, LPARAM );
int __cdecl ApproveFriendship(WPARAM, LPARAM );
+ int __cdecl OnCancelFriendshipRequest(WPARAM, LPARAM );
// Events
int __cdecl OnModulesLoaded(WPARAM, LPARAM);
@@ -162,6 +163,7 @@ public: void __cdecl DeleteContactFromServer(void*);
void __cdecl AddContactToServer(void*);
void __cdecl ApproveContactToServer(void*);
+ void __cdecl CancelFriendsRequest(void*);
// Contacts handling
bool IsMyContact(HANDLE, bool include_chat = false);
diff --git a/protocols/FacebookRM/theme.cpp b/protocols/FacebookRM/theme.cpp index 88e0ab5498..c6712c37ee 100644 --- a/protocols/FacebookRM/theme.cpp +++ b/protocols/FacebookRM/theme.cpp @@ -37,7 +37,7 @@ static const icons[] = { "mind", LPGEN("Mind"), IDI_MIND },
{ "authRevoke", LPGEN("Cancel friendship"), IDI_AUTH_REVOKE },
- //{ "authRevokeReq", LPGEN("Cancel friendship request"), IDI_AUTH_REVOKE },
+ { "authRevokeReq", LPGEN("Cancel friendship request"), IDI_AUTH_REVOKE },
{ "authAsk", LPGEN("Request friendship"), IDI_AUTH_ASK },
{ "authGrant", LPGEN("Approve friendship"), IDI_AUTH_GRANT },
@@ -118,11 +118,11 @@ static FacebookProto * GetInstanceByHContact(HANDLE hContact) {
char *proto = reinterpret_cast<char*>( CallService(MS_PROTO_GETCONTACTBASEPROTO,
reinterpret_cast<WPARAM>(hContact),0) );
- if (!proto)
+ if(!proto)
return 0;
for(int i=0; i<g_Instances.getCount(); i++)
- if (!strcmp(proto,g_Instances[i].m_szModuleName))
+ if(!strcmp(proto,g_Instances[i].m_szModuleName))
return &g_Instances[i];
return 0;
@@ -169,13 +169,13 @@ void InitContactMenus() g_hContactMenuItems[CMI_AUTH_REVOKE] = reinterpret_cast<HANDLE>(
CallService(MS_CLIST_ADDCONTACTMENUITEM,0,(LPARAM)&mi) );
- /* mi.position=-2000006001;
+ mi.position=-2000006001;
mi.icolibItem = GetIconHandle("authRevokeReq");
mi.pszName = GetIconDescription("authRevokeReq");
mi.pszService = "FacebookProto/CancelFriendshipRequest";
- g_hContactMenuSvc[CMI_AUTH_REVOKE_REQ] = CreateServiceFunction(mi.pszService,GlobalService<&FacebookProto::CancelFriendshipRequest>);
- g_hContactMenuItems[CMI_AUTH_REVOKE_REQ] = reinterpret_cast<HANDLE>(
- CallService(MS_CLIST_ADDCONTACTMENUITEM,0,(LPARAM)&mi) ); */
+ g_hContactMenuSvc[CMI_AUTH_CANCEL] = CreateServiceFunction(mi.pszService,GlobalService<&FacebookProto::OnCancelFriendshipRequest>);
+ g_hContactMenuItems[CMI_AUTH_CANCEL] = reinterpret_cast<HANDLE>(
+ CallService(MS_CLIST_ADDCONTACTMENUITEM,0,(LPARAM)&mi) );
mi.position=-2000006002;
mi.icolibItem = GetIconHandle("authAsk");
@@ -226,12 +226,12 @@ int FacebookProto::OnPrebuildContactMenu(WPARAM wParam,LPARAM lParam) {
bool ctrlPressed = (GetKeyState(VK_CONTROL) & 0x8000) != 0;
- BYTE type = DBGetContactSettingDword(hContact, m_szModuleName, FACEBOOK_KEY_CONTACT_TYPE, 0);
+ BYTE type = DBGetContactSettingByte(hContact, m_szModuleName, FACEBOOK_KEY_CONTACT_TYPE, 0);
EnableMenuItem(g_hContactMenuItems[CMI_AUTH_ASK], ctrlPressed || type == FACEBOOK_CONTACT_NONE || !type);
EnableMenuItem(g_hContactMenuItems[CMI_AUTH_GRANT], ctrlPressed || type == FACEBOOK_CONTACT_APPROVE);
EnableMenuItem(g_hContactMenuItems[CMI_AUTH_REVOKE], ctrlPressed || type == FACEBOOK_CONTACT_FRIEND);
- //EnableMenuItem(g_hContactMenuItems[CMI_AUTH_CANCEL], ctrlPressed || type == FACEBOOK_CONTACT_REQUEST);
+ EnableMenuItem(g_hContactMenuItems[CMI_AUTH_CANCEL], ctrlPressed || type == FACEBOOK_CONTACT_REQUEST);
}
return 0;
diff --git a/protocols/FacebookRM/theme.h b/protocols/FacebookRM/theme.h index e6bf689676..4071fc0669 100644 --- a/protocols/FacebookRM/theme.h +++ b/protocols/FacebookRM/theme.h @@ -34,5 +34,6 @@ void EnableMenuItem(HANDLE hMenuItem, bool enable); #define CMI_AUTH_REVOKE 1
#define CMI_AUTH_ASK 2
#define CMI_AUTH_GRANT 3
+#define CMI_AUTH_CANCEL 4
-#define CMITEMS_COUNT 4
\ No newline at end of file +#define CMITEMS_COUNT 5
\ No newline at end of file |