diff options
author | watcherhd <watcherhd@e753b5eb-9565-29b2-b5c5-2cc6f99dfbcb> | 2012-01-19 12:21:27 +0000 |
---|---|---|
committer | watcherhd <watcherhd@e753b5eb-9565-29b2-b5c5-2cc6f99dfbcb> | 2012-01-19 12:21:27 +0000 |
commit | e94c705bb01c662d934c0096480bc9a732d0e1ec (patch) | |
tree | a07c6aa2174cf87d62ecfccdde8dbfa56185d78f /FacebookRM/proto.cpp | |
parent | 9b2d93c613db59b7d47327899a0850d370d6ea5e (diff) |
FacebookRM: Version bump
Version 0.0.7.0
+ Support for group chats (EXPERIMENTAL!) - enable it in options
! Fixed loading contact list
! Fixed potential freeze.
Total downloads: (None or statistics not available yet)
Version 0.0.6.1a
Reuploaded.
Total downloads: (None or statistics not available yet)
Version 0.0.6.1
+ Returned option to close chat windows (on website)
+ New option to map non-standard statuses to Invisible (insetad of Online)
+ New option to load contacts, which have "On the Phone" status
! Fixed changing chat visibility
! Very long messages are no longer received duplicitely
! Changes and fixes related to multiuser messages and messages from people, which are not in server-list
Total downloads: (None or statistics not available yet)
git-svn-id: http://miranda-plugins.googlecode.com/svn/trunk@261 e753b5eb-9565-29b2-b5c5-2cc6f99dfbcb
Diffstat (limited to 'FacebookRM/proto.cpp')
-rw-r--r-- | FacebookRM/proto.cpp | 117 |
1 files changed, 89 insertions, 28 deletions
diff --git a/FacebookRM/proto.cpp b/FacebookRM/proto.cpp index 5a88c40..f54ceee 100644 --- a/FacebookRM/proto.cpp +++ b/FacebookRM/proto.cpp @@ -51,14 +51,16 @@ FacebookProto::FacebookProto(const char* proto_name,const TCHAR* username) CreateProtoService(m_szModuleName, PS_GETAVATARCAPS, &FacebookProto::GetAvatarCaps, this);
// TODO RM: group chats
-/* CreateProtoService(m_szModuleName,PS_JOINCHAT, &FacebookProto::OnJoinChat, this);
- CreateProtoService(m_szModuleName,PS_LEAVECHAT,&FacebookProto::OnLeaveChat,this);*/
+ CreateProtoService(m_szModuleName, PS_JOINCHAT, &FacebookProto::OnJoinChat, this);
+ CreateProtoService(m_szModuleName, PS_LEAVECHAT, &FacebookProto::OnLeaveChat, this);
+
if(g_mirandaVersion < PLUGIN_MAKE_VERSION(0, 10, 0, 2))
{
HookProtoEvent(ME_DB_CONTACT_DELETED, &FacebookProto::OnContactDeleted, this);
}
- HookProtoEvent(ME_CLIST_PREBUILDSTATUSMENU, &FacebookProto::OnBuildStatusMenu, this);
- HookProtoEvent(ME_OPT_INITIALISE, &FacebookProto::OnOptionsInit, this);
+ HookProtoEvent(ME_CLIST_PREBUILDSTATUSMENU, &FacebookProto::OnBuildStatusMenu, this);
+ HookProtoEvent(ME_OPT_INITIALISE, &FacebookProto::OnOptionsInit, this);
+ HookProtoEvent(ME_GC_EVENT, &FacebookProto::OnChatOutgoing, this);
// Create standard network connection
TCHAR descr[512];
@@ -127,7 +129,7 @@ DWORD_PTR FacebookProto::GetCaps( int type, HANDLE hContact ) else
return PF1_IM | PF1_MODEMSGRECV;
case PFLAGNUM_2:
- return PF2_ONLINE | PF2_INVISIBLE; // | PF2_IDLE | PF2_SHORTAWAY;
+ return PF2_ONLINE | PF2_INVISIBLE | PF2_ONTHEPHONE; // | PF2_IDLE | PF2_SHORTAWAY;
case PFLAGNUM_3:
if ( getByte( FACEBOOK_KEY_SET_MIRANDA_STATUS, 0 ) )
return PF2_ONLINE; // | PF2_SHORTAWAY;
@@ -135,6 +137,8 @@ DWORD_PTR FacebookProto::GetCaps( int type, HANDLE hContact ) return 0;
case PFLAGNUM_4:
return PF4_FORCEAUTH | PF4_NOCUSTOMAUTH /*| PF4_SUPPORTIDLE*/ | PF4_IMSENDUTF | PF4_AVATARS | PF4_SUPPORTTYPING | PF4_NOAUTHDENYREASON | PF4_IMSENDOFFLINE;
+ case PFLAGNUM_5:
+ return PF2_ONTHEPHONE;
case PFLAG_MAXLENOFMESSAGE:
return FACEBOOK_MESSAGE_LIMIT;
case PFLAG_UNIQUEIDTEXT:
@@ -166,7 +170,7 @@ int FacebookProto::SetStatus( int new_status ) switch ( new_status )
{
case ID_STATUS_INVISIBLE:
- case ID_STATUS_OFFLINE:
+ case ID_STATUS_OFFLINE:
m_iDesiredStatus = new_status;
break;
@@ -176,6 +180,11 @@ int FacebookProto::SetStatus( int new_status ) break;
default:
+ m_iDesiredStatus = ID_STATUS_INVISIBLE;
+ if (DBGetContactSettingByte(NULL,m_szModuleName,FACEBOOK_KEY_MAP_STATUSES, DEFAULT_MAP_STATUSES))
+ break;
+ case ID_STATUS_ONLINE:
+ case ID_STATUS_FREECHAT:
m_iDesiredStatus = ID_STATUS_ONLINE;
break;
}
@@ -289,16 +298,14 @@ int FacebookProto::SvcCreateAccMgrUI(WPARAM wParam,LPARAM lParam) int FacebookProto::OnModulesLoaded(WPARAM wParam,LPARAM lParam)
{
-/*
- // RM TODO: group chats
// Register group chat
GCREGISTER gcr = {sizeof(gcr)};
- gcr.dwFlags = GC_ACKMSG;
+ //gcr.dwFlags = GC_ACKMSG;
gcr.pszModule = m_szModuleName;
gcr.pszModuleDispName = m_szModuleName;
gcr.iMaxText = FACEBOOK_MESSAGE_LIMIT;
CallService(MS_GC_REGISTER,0,reinterpret_cast<LPARAM>(&gcr));
-*/
+
return 0;
}
@@ -311,8 +318,11 @@ int FacebookProto::OnPreShutdown(WPARAM wParam,LPARAM lParam) int FacebookProto::OnPrebuildContactMenu(WPARAM wParam,LPARAM lParam)
{
HANDLE hContact = reinterpret_cast<HANDLE>(wParam);
- if(IsMyContact(hContact, true))
- ShowContactMenus(true);
+ if(IsMyContact(hContact/*, true*/)) {
+ bool hide = (DBGetContactSettingDword(hContact, m_szModuleName, FACEBOOK_KEY_DELETED, 0)
+ || DBGetContactSettingDword(hContact, m_szModuleName, FACEBOOK_KEY_CONTACT_TYPE, 0) );
+ ShowContactMenus(true, hide);
+ }
return 0;
}
@@ -385,7 +395,7 @@ int FacebookProto::OnBuildStatusMenu(WPARAM wParam,LPARAM lParam) mi.flags = CMIF_ICONFROMICOLIB | CMIF_CHILDPOPUP;
mi.pszName = LPGEN("Visit Profile");
mi.icolibItem = GetIconHandle("homepage");
- // TODO RM: remember and properly free in destructor
+ // TODO RM: remember and properly free in destructor?
/*m_hStatusMind = */reinterpret_cast<HGENMENU>( CallService(
MS_CLIST_ADDPROTOMENUITEM,0,reinterpret_cast<LPARAM>(&mi)) );
@@ -415,27 +425,78 @@ int FacebookProto::VisitProfile(WPARAM wParam,LPARAM lParam) {
CallService(MS_UTILS_OPENURL,1,reinterpret_cast<LPARAM>(dbv.pszVal));
DBFreeVariant(&dbv);
- }/* else {
- // TODO RM: remove this
- std::string key, url;
- if (DBGetContactSettingByte(hContact,m_szModuleName,"ChatRoom",0) == 0)
- { // usual contact
- key = FACEBOOK_KEY_ID;
- url = FACEBOOK_URL_PROFILE;
+ }
+
+ return 0;
+}
+
+int FacebookProto::RemoveFriend(WPARAM wParam,LPARAM lParam)
+{
+ if (wParam == NULL)
+ { // self contact
+ // CallService(MS_UTILS_OPENURL,1,reinterpret_cast<LPARAM>(FACEBOOK_URL_PROFILE));
+ return 0;
+ }
+
+ if (isOffline())
+ return 0;
+
+ if (MessageBox( 0, TranslateT("Are you sure?"), TranslateT("Delete contact from server list"), MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2 ) != IDYES)
+ return 0;
+
+ HANDLE hContact = reinterpret_cast<HANDLE>(wParam);
+
+ DBVARIANT dbv;
+ if( !DBGetContactSettingString(hContact,m_szModuleName,FACEBOOK_KEY_ID,&dbv) )
+ {
+ if (!isOffline()) {
+ std::string* id = new std::string(dbv.pszVal);
+ ForkThread( &FacebookProto::DeleteContactFromServer, this, ( void* )id );
+ DBFreeVariant(&dbv);
+
+ if ( !DBGetContactSettingDword(hContact, m_szModuleName, FACEBOOK_KEY_DELETED, 0) )
+ DBWriteContactSettingDword(hContact, m_szModuleName, FACEBOOK_KEY_DELETED, ::time(NULL));
} else {
- key = "ChatRoomID";
- url = FACEBOOK_URL_GROUP;
+/* facebook_user fbu;
+ fbu.user_id = dbv.pszVal;
+ hContact = AddToContactList(&fbu);
+
+ DBWriteContactSettingByte(hContact,m_szModuleName,FACEBOOK_KEY_DELETE_NEXT,1);
+ facy.client_notify(TranslateT("Contact will be deleted at next login."));*/
+ NotifyEvent(TranslateT("Deleting contact"), TranslateT("Contact wasn't deleted, because you are not connected."), NULL, FACEBOOK_EVENT_OTHER, NULL);
}
+ }
- if ( !DBGetContactSettingString(hContact,m_szModuleName,key.c_str(),&dbv) )
- {
- url += dbv.pszVal;
- DBWriteContactSettingString(hContact,m_szModuleName,"Homepage",url.c_str());
+ return 0;
+}
- CallService(MS_UTILS_OPENURL,1,reinterpret_cast<LPARAM>(url.c_str()));
+int FacebookProto::AddFriend(WPARAM wParam,LPARAM lParam)
+{
+ if (wParam == NULL)
+ { // self contact
+// CallService(MS_UTILS_OPENURL,1,reinterpret_cast<LPARAM>(FACEBOOK_URL_PROFILE));
+ return 0;
+ }
+
+ HANDLE hContact = reinterpret_cast<HANDLE>(wParam);
+
+ DBVARIANT dbv;
+ if( !DBGetContactSettingString(hContact,m_szModuleName,FACEBOOK_KEY_ID,&dbv) )
+ {
+ if (!isOffline()) {
+ std::string* id = new std::string(dbv.pszVal);
+ ForkThread( &FacebookProto::AddContactToServer, this, ( void* )id );
DBFreeVariant(&dbv);
+ } else {
+/* facebook_user fbu;
+ fbu.user_id = dbv.pszVal;
+ hContact = AddToContactList(&fbu);
+
+ DBWriteContactSettingByte(hContact,m_szModuleName,FACEBOOK_KEY_DELETE_NEXT,1);
+ facy.client_notify(TranslateT("Contact will be deleted at next login."));*/
+ NotifyEvent(TranslateT("Adding contact"), TranslateT("Contact wasn't added, because you are not connected."), NULL, FACEBOOK_EVENT_OTHER, NULL);
}
- }*/
+ }
return 0;
}
|