diff options
Diffstat (limited to 'protocols/FacebookRM/src')
23 files changed, 824 insertions, 827 deletions
diff --git a/protocols/FacebookRM/src/avatars.cpp b/protocols/FacebookRM/src/avatars.cpp index ae0f2f40b3..eabb77c8f0 100644 --- a/protocols/FacebookRM/src/avatars.cpp +++ b/protocols/FacebookRM/src/avatars.cpp @@ -60,15 +60,15 @@ void FacebookProto::CheckAvatarChange(HANDLE hContact, std::string image_url) bool big_avatars = db_get_b(NULL, m_szModuleName, FACEBOOK_KEY_BIG_AVATARS, DEFAULT_BIG_AVATARS) != 0;
// We've got url to avatar of default size 32x32px, let's change it to slightly bigger (50x50px) - looks like maximum size for square format
- std::tstring::size_type pos = image_url.rfind( "/s32x32/" );
+ std::tstring::size_type pos = image_url.rfind("/s32x32/");
if (pos != std::wstring::npos)
- image_url = image_url.replace( pos, 8, big_avatars ? "/s200x200/" : "/s50x50/" );
+ image_url = image_url.replace(pos, 8, big_avatars ? "/s200x200/" : "/s50x50/");
if (big_avatars)
{
- pos = image_url.rfind( "_q." );
+ pos = image_url.rfind("_q.");
if (pos != std::wstring::npos)
- image_url = image_url.replace( pos, 3, "_s." );
+ image_url = image_url.replace(pos, 3, "_s.");
}
DBVARIANT dbv;
@@ -135,8 +135,8 @@ void FacebookProto::UpdateAvatarWorker(void *) std::tstring FacebookProto::GetAvatarFolder()
{
TCHAR path[MAX_PATH];
- if ( !hAvatarFolder_ || FoldersGetCustomPathT(hAvatarFolder_, path, SIZEOF(path), _T("")))
- mir_sntprintf(path, SIZEOF(path), _T("%s\\%s"), (TCHAR*)VARST( _T("%miranda_avatarcache%")), m_tszUserName);
+ if (!hAvatarFolder_ || FoldersGetCustomPathT(hAvatarFolder_, path, SIZEOF(path), _T("")))
+ mir_sntprintf(path, SIZEOF(path), _T("%s\\%s"), (TCHAR*)VARST(_T("%miranda_avatarcache%")), m_tszUserName);
return path;
}
@@ -196,7 +196,7 @@ int FacebookProto::GetAvatarInfo(WPARAM wParam, LPARAM lParam) if (needLoad)
{
LOG("***** Starting avatar request thread for %s", AI->filename);
- ScopedLock s( avatar_lock_ );
+ ScopedLock s(avatar_lock_);
if (std::find(avatar_queue.begin(), avatar_queue.end(), AI->hContact) == avatar_queue.end())
{
@@ -221,8 +221,8 @@ int FacebookProto::GetMyAvatar(WPARAM wParam, LPARAM lParam) if (!wParam || !lParam)
return -3;
- TCHAR* buf = ( TCHAR* )wParam;
- int size = ( int )lParam;
+ TCHAR* buf = (TCHAR*)wParam;
+ int size = (int)lParam;
PROTO_AVATAR_INFORMATIONT ai = {sizeof(ai)};
switch (GetAvatarInfo(0, (LPARAM)&ai))
diff --git a/protocols/FacebookRM/src/chat.cpp b/protocols/FacebookRM/src/chat.cpp index 1178b46a85..5bfb562713 100644 --- a/protocols/FacebookRM/src/chat.cpp +++ b/protocols/FacebookRM/src/chat.cpp @@ -48,7 +48,7 @@ void FacebookProto::UpdateChat(const char *chat_id, const char *id, const char * // Close chat window, if set
- ForkThread( &FacebookProto::MessagingWorker, this, new send_messaging(chat_id, FACEBOOK_SEND_MESSAGE ));
+ ForkThread(&FacebookProto::MessagingWorker, this, new send_messaging(chat_id, FACEBOOK_SEND_MESSAGE));
}
int FacebookProto::OnChatOutgoing(WPARAM wParam,LPARAM lParam)
@@ -198,9 +198,9 @@ void FacebookProto::AddChat(const char *id, const char *name) // Create a user statuses
gcd.iType = GC_EVENT_ADDGROUP;
gce.ptszStatus = _T("Admin");
- CallServiceSync( MS_GC_EVENT, NULL, reinterpret_cast<LPARAM>(&gce));
+ CallServiceSync(MS_GC_EVENT, NULL, reinterpret_cast<LPARAM>(&gce));
gce.ptszStatus = _T("Normal");
- CallServiceSync( MS_GC_EVENT, NULL, reinterpret_cast<LPARAM>(&gce));
+ CallServiceSync(MS_GC_EVENT, NULL, reinterpret_cast<LPARAM>(&gce));
// Finish initialization
gcd.iType = GC_EVENT_CONTROL;
@@ -258,10 +258,10 @@ int FacebookProto::OnJoinChat(WPARAM,LPARAM suppress) gcd.iType = GC_EVENT_ADDGROUP;
gce.ptszStatus = _T("Admin");
- CallServiceSync( MS_GC_EVENT, NULL, reinterpret_cast<LPARAM>(&gce));
+ CallServiceSync(MS_GC_EVENT, NULL, reinterpret_cast<LPARAM>(&gce));
gce.ptszStatus = _T("Normal");
- CallServiceSync( MS_GC_EVENT, NULL, reinterpret_cast<LPARAM>(&gce));
+ CallServiceSync(MS_GC_EVENT, NULL, reinterpret_cast<LPARAM>(&gce));
SetTopic("Omegle is a great way of meeting new friends!");
diff --git a/protocols/FacebookRM/src/client.h b/protocols/FacebookRM/src/client.h index 0b9ee55625..62a9a7f2c0 100644 --- a/protocols/FacebookRM/src/client.h +++ b/protocols/FacebookRM/src/client.h @@ -32,7 +32,7 @@ public: // Client definition
- facebook_client( )
+ facebook_client()
{
username_ = password_ = \
chat_sequence_num_ = chat_channel_host_ = chat_channel_partition_ = \
@@ -82,7 +82,7 @@ public: // Client vs protocol communication
- void client_notify( TCHAR* message );
+ void client_notify(TCHAR* message);
////////////////////////////////////////////////////////////
@@ -92,11 +92,11 @@ public: std::map< std::string, std::string > cookies;
- std::string get_newsfeed_type( );
+ std::string get_newsfeed_type();
- char* load_cookies( );
- void store_headers( http::response* resp, NETLIBHTTPHEADER* headers, int headers_count );
- void clear_cookies( );
+ char* load_cookies();
+ void store_headers(http::response* resp, NETLIBHTTPHEADER* headers, int headers_count);
+ void clear_cookies();
////////////////////////////////////////////////////////////
@@ -104,22 +104,22 @@ public: unsigned int error_count_;
- bool validate_response( http::response* );
+ bool validate_response(http::response*);
- bool handle_entry( std::string method );
- bool handle_success( std::string method );
- bool handle_error( std::string method, bool force_disconnect = false );
+ bool handle_entry(std::string method);
+ bool handle_success(std::string method);
+ bool handle_error(std::string method, bool force_disconnect = false);
- void __inline increment_error( ) { this->error_count_++; }
- void __inline decrement_error( ) { if ( error_count_ > 0 ) error_count_--; }
- void __inline reset_error( ) { error_count_ = 0; }
+ void __inline increment_error() { this->error_count_++; }
+ void __inline decrement_error() { if (error_count_ > 0) error_count_--; }
+ void __inline reset_error() { error_count_ = 0; }
////////////////////////////////////////////////////////////
// Login handling
- bool login( const std::string &username, const std::string &password );
- bool logout( );
+ bool login(const std::string &username, const std::string &password);
+ bool logout();
const std::string & get_username() const;
@@ -127,9 +127,9 @@ public: // Session handling
- bool home( );
- bool reconnect( );
- bool chat_state( bool online = true );
+ bool home();
+ bool reconnect();
+ bool chat_state(bool online = true);
////////////////////////////////////////////////////////////
@@ -139,18 +139,18 @@ public: HANDLE buddies_lock_;
HANDLE send_message_lock_;
- bool buddy_list( );
- bool load_friends( );
- bool feeds( );
+ bool buddy_list();
+ bool load_friends();
+ bool feeds();
////////////////////////////////////////////////////////////
// Messages handling
- bool channel( );
- bool send_message( std::string message_recipient, std::string message_text, std::string *error_text, int method );
- void close_chat( std::string message_recipient );
- void chat_mark_read( std::string message_recipient );
+ bool channel();
+ bool send_message(std::string message_recipient, std::string message_text, std::string *error_text, int method);
+ void close_chat(std::string message_recipient);
+ void chat_mark_read(std::string message_recipient);
////////////////////////////////////////////////////////////
@@ -162,17 +162,17 @@ public: // HTTP communication
- http::response flap( const int request_type, std::string* request_data = NULL, std::string* request_get_data = NULL, int method = 0 );
+ http::response flap(const int request_type, std::string* request_data = NULL, std::string* request_get_data = NULL, int method = 0);
bool save_url(const std::string &url,const std::tstring &filename, HANDLE &nlc);
- DWORD choose_security_level( int );
- int choose_method( int );
- std::string choose_proto( int );
- std::string choose_server( int, std::string* data = NULL, std::string* get_data = NULL );
- std::string choose_action( int, std::string* data = NULL, std::string* get_data = NULL );
- std::string choose_request_url( int, std::string* data = NULL, std::string* get_data = NULL );
+ DWORD choose_security_level(int);
+ int choose_method(int);
+ std::string choose_proto(int);
+ std::string choose_server(int, std::string* data = NULL, std::string* get_data = NULL);
+ std::string choose_action(int, std::string* data = NULL, std::string* get_data = NULL);
+ std::string choose_request_url(int, std::string* data = NULL, std::string* get_data = NULL);
- NETLIBHTTPHEADER* get_request_headers( int request_type, int* headers_count );
+ NETLIBHTTPHEADER* get_request_headers(int request_type, int* headers_count);
////////////////////////////////////////////////////////////
diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp index 8e3897e2d6..fe8d53c121 100644 --- a/protocols/FacebookRM/src/communication.cpp +++ b/protocols/FacebookRM/src/communication.cpp @@ -22,19 +22,19 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "common.h"
-void facebook_client::client_notify( TCHAR* message )
+void facebook_client::client_notify(TCHAR* message)
{
- parent->NotifyEvent( parent->m_tszUserName, message, NULL, FACEBOOK_EVENT_CLIENT );
+ parent->NotifyEvent(parent->m_tszUserName, message, NULL, FACEBOOK_EVENT_CLIENT);
}
-http::response facebook_client::flap( const int request_type, std::string* request_data, std::string* request_get_data, int method )
+http::response facebook_client::flap(const int request_type, std::string* request_data, std::string* request_get_data, int method)
{
- NETLIBHTTPREQUEST nlhr = {sizeof( NETLIBHTTPREQUEST )};
- nlhr.requestType = !method ? choose_method( request_type ) : method;
- 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( nlhr.requestType, &nlhr.headersCount );
+ NETLIBHTTPREQUEST nlhr = {sizeof(NETLIBHTTPREQUEST)};
+ nlhr.requestType = !method ? choose_method(request_type) : method;
+ 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(nlhr.requestType, &nlhr.headersCount);
switch (request_type)
{
@@ -44,15 +44,15 @@ http::response facebook_client::flap( const int request_type, std::string* reque nlhr.timeout = 1000 * 15; break;
}
- if ( request_data != NULL )
+ if (request_data != NULL)
{
nlhr.pData = (char*)(*request_data).c_str();
- nlhr.dataLength = (int)request_data->length( );
+ nlhr.dataLength = (int)request_data->length();
}
parent->Log("@@@@@ Sending request to '%s'", nlhr.szUrl);
- switch ( request_type )
+ switch (request_type)
{
case FACEBOOK_REQUEST_LOGIN:
nlhr.nlc = NULL;
@@ -70,14 +70,14 @@ http::response facebook_client::flap( const int request_type, std::string* reque break;
}
- NETLIBHTTPREQUEST* pnlhr = ( NETLIBHTTPREQUEST* )CallService( MS_NETLIB_HTTPTRANSACTION, (WPARAM)handle_, (LPARAM)&nlhr );
+ NETLIBHTTPREQUEST* pnlhr = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)handle_, (LPARAM)&nlhr);
utils::mem::detract(nlhr.headers[3].szValue);
utils::mem::detract(nlhr.headers);
http::response resp;
- switch ( request_type )
+ switch (request_type)
{
case FACEBOOK_REQUEST_LOGIN:
case FACEBOOK_REQUEST_SETUP_MACHINE:
@@ -93,10 +93,10 @@ http::response facebook_client::flap( const int request_type, std::string* reque break;
}
- if ( pnlhr != NULL )
+ if (pnlhr != NULL)
{
parent->Log("@@@@@ Got response with code %d", pnlhr->resultCode);
- store_headers( &resp, pnlhr->headers, pnlhr->headersCount );
+ store_headers(&resp, pnlhr->headers, pnlhr->headersCount);
resp.code = pnlhr->resultCode;
resp.data = pnlhr->pData ? pnlhr->pData : "";
@@ -108,21 +108,21 @@ http::response facebook_client::flap( const int request_type, std::string* reque // is compaired in all communication requests
}
- if (db_get_b( NULL, parent->m_szModuleName, FACEBOOK_KEY_VALIDATE_RESPONSE, 0 ) == 1)
+ if (db_get_b(NULL, parent->m_szModuleName, FACEBOOK_KEY_VALIDATE_RESPONSE, 0) == 1)
validate_response(&resp);
return resp;
}
-bool facebook_client::validate_response( http::response* resp )
+bool facebook_client::validate_response(http::response* resp)
{
- if ( resp->code == HTTP_CODE_FAKE_DISCONNECTED )
+ if (resp->code == HTTP_CODE_FAKE_DISCONNECTED)
{
parent->Log(" ! ! Request has timed out, connection or server error");
return false;
}
- if (db_get_b( NULL, parent->m_szModuleName, FACEBOOK_KEY_VALIDATE_RESPONSE, 0 ) == 2) {
+ if (db_get_b(NULL, parent->m_szModuleName, FACEBOOK_KEY_VALIDATE_RESPONSE, 0) == 2) {
return true;
}
@@ -137,29 +137,29 @@ bool facebook_client::validate_response( http::response* resp ) this->cookies[cookie_name] = cookie_value;
}
*/
- std::string::size_type pos = resp->data.find( "\"error\":" );
- if ( pos != std::string::npos )
+ std::string::size_type pos = resp->data.find("\"error\":");
+ if (pos != std::string::npos)
try
{
pos += 8;
- int error_num = atoi( resp->data.substr( pos, resp->data.find( ",", pos ) - pos ).c_str());
- if ( error_num != 0 )
+ int error_num = atoi(resp->data.substr(pos, resp->data.find(",", pos) - pos).c_str());
+ if (error_num != 0)
{
std::string error = "";
- pos = resp->data.find( "\"errorDescription\":\"", pos );
- if (pos != std::string::npos ) {
+ pos = resp->data.find("\"errorDescription\":\"", pos);
+ if (pos != std::string::npos) {
pos += 20;
- error = resp->data.substr( pos, resp->data.find( "\"", pos ) - pos );
+ error = resp->data.substr(pos, resp->data.find("\"", pos) - pos);
error = utils::text::trim(
- utils::text::special_expressions_decode(
- utils::text::slashu_to_utf8( error )) );
+ utils::text::special_expressions_decode(
+ utils::text::slashu_to_utf8(error)));
}
resp->error_number = error_num;
resp->error_text = error;
parent->Log(" ! ! Received Facebook error: %d -- %s", error_num, error.c_str());
- // client_notify( ... );
+ // client_notify(...);
resp->code = HTTP_CODE_FAKE_ERROR;
return false;
}
@@ -171,33 +171,33 @@ bool facebook_client::validate_response( http::response* resp ) return true;
}
-bool facebook_client::handle_entry( std::string method )
+bool facebook_client::handle_entry(std::string method)
{
parent->Log(" >> Entering %s()", method.c_str());
return true;
}
-bool facebook_client::handle_success( std::string method )
+bool facebook_client::handle_success(std::string method)
{
parent->Log(" << Quitting %s()", method.c_str());
reset_error();
return true;
}
-bool facebook_client::handle_error( std::string method, bool force_disconnect )
+bool facebook_client::handle_error(std::string method, bool force_disconnect)
{
bool result;
increment_error();
parent->Log("!!!!! %s(): Something with Facebook went wrong", method.c_str());
- if ( force_disconnect )
+ if (force_disconnect)
result = false;
- else if ( error_count_ <= (UINT)db_get_b(NULL,parent->m_szModuleName,FACEBOOK_KEY_TIMEOUTS_LIMIT,FACEBOOK_TIMEOUTS_LIMIT))
+ else if (error_count_ <= (UINT)db_get_b(NULL,parent->m_szModuleName,FACEBOOK_KEY_TIMEOUTS_LIMIT,FACEBOOK_TIMEOUTS_LIMIT))
result = true;
else
result = false;
- if ( result == false )
+ if (result == false)
{
reset_error();
parent->SetStatus(ID_STATUS_OFFLINE);
@@ -208,16 +208,16 @@ bool facebook_client::handle_error( std::string method, bool force_disconnect ) //////////////////////////////////////////////////////////////////////////////
-DWORD facebook_client::choose_security_level( int request_type )
+DWORD facebook_client::choose_security_level(int request_type)
{
if (this->https_)
{
- if ( request_type != FACEBOOK_REQUEST_MESSAGES_RECEIVE
- || db_get_b( NULL, parent->m_szModuleName, FACEBOOK_KEY_FORCE_HTTPS_CHANNEL, DEFAULT_FORCE_HTTPS_CHANNEL ))
+ if (request_type != FACEBOOK_REQUEST_MESSAGES_RECEIVE
+ || db_get_b(NULL, parent->m_szModuleName, FACEBOOK_KEY_FORCE_HTTPS_CHANNEL, DEFAULT_FORCE_HTTPS_CHANNEL))
return NLHRF_SSL;
}
- switch ( request_type )
+ switch (request_type)
{
case FACEBOOK_REQUEST_LOGIN:
case FACEBOOK_REQUEST_SETUP_MACHINE:
@@ -247,13 +247,13 @@ DWORD facebook_client::choose_security_level( int request_type ) // case FACEBOOK_REQUEST_ASYNC:
// case FACEBOOK_REQUEST_TYPING_SEND:
default:
- return ( DWORD )0;
+ return (DWORD)0;
}
}
-int facebook_client::choose_method( int request_type )
+int facebook_client::choose_method(int request_type)
{
- switch ( request_type )
+ switch (request_type)
{
case FACEBOOK_REQUEST_LOGIN:
case FACEBOOK_REQUEST_SETUP_MACHINE:
@@ -287,7 +287,7 @@ int facebook_client::choose_method( int request_type ) }
}
-std::string facebook_client::choose_proto( int request_type )
+std::string facebook_client::choose_proto(int request_type)
{
if (choose_security_level(request_type) == NLHRF_SSL)
return HTTP_PROTO_SECURE;
@@ -295,9 +295,9 @@ std::string facebook_client::choose_proto( int request_type ) return HTTP_PROTO_REGULAR;
}
-std::string facebook_client::choose_server( int request_type, std::string* data, std::string* get_data )
+std::string facebook_client::choose_server(int request_type, std::string* data, std::string* get_data)
{
- switch ( request_type )
+ switch (request_type)
{
case FACEBOOK_REQUEST_LOGIN:
return FACEBOOK_SERVER_LOGIN;
@@ -305,8 +305,8 @@ std::string facebook_client::choose_server( int request_type, std::string* data, case FACEBOOK_REQUEST_MESSAGES_RECEIVE:
{
std::string server = FACEBOOK_SERVER_CHAT;
- utils::text::replace_first( &server, "%s", "0" );
- utils::text::replace_first( &server, "%s", this->chat_channel_host_ );
+ utils::text::replace_first(&server, "%s", "0");
+ utils::text::replace_first(&server, "%s", this->chat_channel_host_);
return server;
}
@@ -340,9 +340,9 @@ std::string facebook_client::choose_server( int request_type, std::string* data, }
}
-std::string facebook_client::choose_action( int request_type, std::string* data, std::string* get_data )
+std::string facebook_client::choose_action(int request_type, std::string* data, std::string* get_data)
{
- switch ( request_type )
+ switch (request_type)
{
case FACEBOOK_REQUEST_LOGIN:
return "/login.php?login_attempt=1";
@@ -365,7 +365,7 @@ std::string facebook_client::choose_action( int request_type, std::string* data, case FACEBOOK_REQUEST_LOAD_FRIENDS:
{
std::string action = "/ajax/chat/user_info_all.php?__a=1&viewer=%s&__user=%s";
- utils::text::replace_all( &action, "%s", self_.user_id );
+ utils::text::replace_all(&action, "%s", self_.user_id);
return action;
}
@@ -417,15 +417,15 @@ std::string facebook_client::choose_action( int request_type, std::string* data, action += get_newsfeed_type();
action += "&request_type=4&__a=1&newest=%s&ignore_self=true&load_newer=true&__user=%s";
std::string newest = utils::conversion::to_string((void*)&this->last_feeds_update_, UTILS_CONV_TIME_T);
- utils::text::replace_first( &action, "%s", newest );
- utils::text::replace_first( &action, "%s", self_.user_id );
+ utils::text::replace_first(&action, "%s", newest);
+ utils::text::replace_first(&action, "%s", self_.user_id);
return action;
}
case FACEBOOK_REQUEST_NOTIFICATIONS:
{
std::string action = "/ajax/notifications/get.php?__a=1&user=%s&time=0&version=2&__user=%s";
- utils::text::replace_all( &action, "%s", self_.user_id );
+ utils::text::replace_all(&action, "%s", self_.user_id);
return action;
}
@@ -436,9 +436,9 @@ std::string facebook_client::choose_action( int request_type, std::string* data, if (this->chat_reconnect_reason_.empty())
this->chat_reconnect_reason_ = "6";
- utils::text::replace_first( &action, "%s", this->chat_reconnect_reason_ );
- utils::text::replace_first( &action, "%s", this->dtsg_ );
- utils::text::replace_first( &action, "%s", this->self_.user_id );
+ utils::text::replace_first(&action, "%s", this->chat_reconnect_reason_);
+ utils::text::replace_first(&action, "%s", this->dtsg_);
+ utils::text::replace_first(&action, "%s", this->self_.user_id);
return action;
}
@@ -486,22 +486,22 @@ std::string facebook_client::choose_action( int request_type, std::string* data, }
}
-std::string facebook_client::choose_request_url( int request_type, std::string* data, std::string* get_data )
+std::string facebook_client::choose_request_url(int request_type, std::string* data, std::string* get_data)
{
- std::string url = choose_proto( request_type );
- url.append( choose_server( request_type, data, get_data ));
- url.append( choose_action( request_type, data, get_data ));
+ std::string url = choose_proto(request_type);
+ url.append(choose_server(request_type, data, get_data));
+ url.append(choose_action(request_type, data, get_data));
return url;
}
-NETLIBHTTPHEADER* facebook_client::get_request_headers( int request_type, int* headers_count )
+NETLIBHTTPHEADER* facebook_client::get_request_headers(int request_type, int* headers_count)
{
if (request_type == REQUEST_POST)
*headers_count = 5;
else
*headers_count = 4;
- NETLIBHTTPHEADER* headers = ( NETLIBHTTPHEADER* )utils::mem::allocate( sizeof( NETLIBHTTPHEADER )*( *headers_count ));
+ NETLIBHTTPHEADER* headers = (NETLIBHTTPHEADER*)utils::mem::allocate(sizeof(NETLIBHTTPHEADER)*(*headers_count));
if (request_type == REQUEST_POST)
{
@@ -510,9 +510,9 @@ NETLIBHTTPHEADER* facebook_client::get_request_headers( int request_type, int* h }
headers[3].szName = "Cookie";
- headers[3].szValue = load_cookies( );
+ headers[3].szValue = load_cookies();
headers[2].szName = "User-Agent";
- headers[2].szValue = (char *)g_strUserAgent.c_str( );
+ headers[2].szValue = (char *)g_strUserAgent.c_str();
headers[1].szName = "Accept";
headers[1].szValue = "*/*";
headers[0].szName = "Accept-Language";
@@ -521,7 +521,7 @@ NETLIBHTTPHEADER* facebook_client::get_request_headers( int request_type, int* h return headers;
}
-std::string facebook_client::get_newsfeed_type( )
+std::string facebook_client::get_newsfeed_type()
{
BYTE feed_type = db_get_b(NULL, parent->m_szModuleName, FACEBOOK_KEY_FEED_TYPE, 0);
if (feed_type < 0 || feed_type >= SIZEOF(feed_types))
@@ -529,41 +529,41 @@ std::string facebook_client::get_newsfeed_type( ) return feed_types[feed_type].id;
}
-char* facebook_client::load_cookies( )
+char* facebook_client::load_cookies()
{
- ScopedLock s( cookies_lock_ );
+ ScopedLock s(cookies_lock_);
std::string cookieString = "isfbe=false;";
- if ( !cookies.empty( ))
- for ( std::map< std::string, std::string >::iterator iter = cookies.begin(); iter != cookies.end(); ++iter )
+ if (!cookies.empty())
+ for (std::map< std::string, std::string >::iterator iter = cookies.begin(); iter != cookies.end(); ++iter)
{
- cookieString.append( iter->first );
- cookieString.append( 1, '=' );
- cookieString.append( iter->second );
- cookieString.append( 1, ';' );
+ cookieString.append(iter->first);
+ cookieString.append(1, '=');
+ cookieString.append(iter->second);
+ cookieString.append(1, ';');
}
return mir_strdup(cookieString.c_str());
}
-void facebook_client::store_headers( http::response* resp, NETLIBHTTPHEADER* headers, int headersCount )
+void facebook_client::store_headers(http::response* resp, NETLIBHTTPHEADER* headers, int headersCount)
{
- ScopedLock c( cookies_lock_ );
+ ScopedLock c(cookies_lock_);
- for ( int i = 0; i < headersCount; i++ )
+ for (int i = 0; i < headersCount; i++)
{
std::string header_name = headers[i].szName; // TODO: Casting?
std::string header_value = headers[i].szValue; // TODO: Casting?
- if ( header_name == "Set-Cookie" )
+ if (header_name == "Set-Cookie")
{
- std::string cookie_name = header_value.substr( 0, header_value.find( "=" ));
- std::string cookie_value = header_value.substr( header_value.find( "=" ) + 1, header_value.find( ";" ) - header_value.find( "=" ) - 1 );
- if ( cookie_value == "deleted" )
+ std::string cookie_name = header_value.substr(0, header_value.find("="));
+ std::string cookie_value = header_value.substr(header_value.find("=") + 1, header_value.find(";") - header_value.find("=") - 1);
+ if (cookie_value == "deleted")
{
parent->Log(" Deleted cookie '%s'", cookie_name.c_str());
- cookies.erase( cookie_name );
+ cookies.erase(cookie_name);
} else {
parent->Log(" New cookie '%s'", cookie_name.c_str());
cookies[cookie_name] = cookie_value;
@@ -577,85 +577,85 @@ void facebook_client::store_headers( http::response* resp, NETLIBHTTPHEADER* hea }
}
-void facebook_client::clear_cookies( )
+void facebook_client::clear_cookies()
{
- ScopedLock s( cookies_lock_ );
+ ScopedLock s(cookies_lock_);
- if ( !cookies.empty( ))
- cookies.clear( );
+ if (!cookies.empty())
+ cookies.clear();
}
bool facebook_client::login(const std::string &username,const std::string &password)
{
- handle_entry( "login" );
+ handle_entry("login");
username_ = username;
password_ = password;
// Access homepage to get initial cookies
- flap( FACEBOOK_REQUEST_HOME, NULL );
+ flap(FACEBOOK_REQUEST_HOME, NULL);
// Prepare login data
std::string data = "charset_test=%e2%82%ac%2c%c2%b4%2c%e2%82%ac%2c%c2%b4%2c%e6%b0%b4%2c%d0%94%2c%d0%84&locale=en&pass_placeHolder=Password&login=Login&persistent=1";
- data += "&email=" + utils::url::encode( username );
- data += "&pass=" + utils::url::encode( password );
+ data += "&email=" + utils::url::encode(username);
+ data += "&pass=" + utils::url::encode(password);
// Send validation
- http::response resp = flap( FACEBOOK_REQUEST_LOGIN, &data );
+ http::response resp = flap(FACEBOOK_REQUEST_LOGIN, &data);
// Process result data
validate_response(&resp);
- if ( resp.code == HTTP_CODE_FOUND && resp.headers.find("Location") != resp.headers.end())
+ if (resp.code == HTTP_CODE_FOUND && resp.headers.find("Location") != resp.headers.end())
{
// Check whether some Facebook things are required
- if ( resp.headers["Location"].find("help.php") != std::string::npos )
+ if (resp.headers["Location"].find("help.php") != std::string::npos)
{
- client_notify( TranslateT("Login error: Some Facebook things are required."));
+ client_notify(TranslateT("Login error: Some Facebook things are required."));
parent->Log(" ! ! Login error: Some Facebook things are required.");
- // return handle_error( "login", FORCE_DISCONNECT );
+ // return handle_error("login", FORCE_DISCONNECT);
}
// Check whether setting Machine name is required
- if ( resp.headers["Location"].find("/checkpoint/") != std::string::npos )
+ if (resp.headers["Location"].find("/checkpoint/") != std::string::npos)
{
- resp = flap( FACEBOOK_REQUEST_SETUP_MACHINE, NULL, NULL, REQUEST_GET );
+ resp = flap(FACEBOOK_REQUEST_SETUP_MACHINE, NULL, NULL, REQUEST_GET);
std::string inner_data;
if (resp.data.find("name=\"submit[Continue]\"") != std::string::npos) {
// Multi step with approving last unrecognized device
// 1) Continue
inner_data = "submit[Continue]=Continue";
- inner_data += "&nh=" + utils::text::source_get_value(&resp.data, 3, "name=\"nh\"", "value=\"", "\"" );
- inner_data += "&fb_dtsg=" + utils::text::source_get_value(&resp.data, 3, "name=\"fb_dtsg\"", "value=\"", "\"" );
- resp = flap( FACEBOOK_REQUEST_SETUP_MACHINE, &inner_data );
+ inner_data += "&nh=" + utils::text::source_get_value(&resp.data, 3, "name=\"nh\"", "value=\"", "\"");
+ inner_data += "&fb_dtsg=" + utils::text::source_get_value(&resp.data, 3, "name=\"fb_dtsg\"", "value=\"", "\"");
+ resp = flap(FACEBOOK_REQUEST_SETUP_MACHINE, &inner_data);
// 2) Approve last unknown login
// inner_data = "submit[I%20don't%20recognize]=I%20don't%20recognize"; // Don't recognize - this will force to change account password
inner_data = "submit[This%20is%20Okay]=This%20is%20Okay"; // Recognize
- inner_data += "&nh=" + utils::text::source_get_value(&resp.data, 3, "name=\"nh\"", "value=\"", "\"" );
- inner_data += "&fb_dtsg=" + utils::text::source_get_value(&resp.data, 3, "name=\"fb_dtsg\"", "value=\"", "\"" );
- resp = flap( FACEBOOK_REQUEST_SETUP_MACHINE, &inner_data );
+ inner_data += "&nh=" + utils::text::source_get_value(&resp.data, 3, "name=\"nh\"", "value=\"", "\"");
+ inner_data += "&fb_dtsg=" + utils::text::source_get_value(&resp.data, 3, "name=\"fb_dtsg\"", "value=\"", "\"");
+ resp = flap(FACEBOOK_REQUEST_SETUP_MACHINE, &inner_data);
}
// Save actual machine name
// inner_data = "machine_name=Miranda%20NG&submit[Don't%20Save]=Don't%20Save"; // Don't save
inner_data = "machine_name=Miranda%20NG&submit[Save%20Device]=Save%20Device"; // Save
- inner_data += "&lsd=" + utils::text::source_get_value(&resp.data, 3, "name=\"lsd\"", "value=\"", "\"" );
- inner_data += "&nh=" + utils::text::source_get_value(&resp.data, 3, "name=\"nh\"", "value=\"", "\"" );
- inner_data += "&fb_dtsg=" + utils::text::source_get_value(&resp.data, 3, "name=\"fb_dtsg\"", "value=\"", "\"" );
+ inner_data += "&lsd=" + utils::text::source_get_value(&resp.data, 3, "name=\"lsd\"", "value=\"", "\"");
+ inner_data += "&nh=" + utils::text::source_get_value(&resp.data, 3, "name=\"nh\"", "value=\"", "\"");
+ inner_data += "&fb_dtsg=" + utils::text::source_get_value(&resp.data, 3, "name=\"fb_dtsg\"", "value=\"", "\"");
- resp = flap( FACEBOOK_REQUEST_SETUP_MACHINE, &inner_data );
+ resp = flap(FACEBOOK_REQUEST_SETUP_MACHINE, &inner_data);
validate_response(&resp);
}
}
- if ( resp.code == HTTP_CODE_FOUND && resp.headers.find("Location") != resp.headers.end())
+ if (resp.code == HTTP_CODE_FOUND && resp.headers.find("Location") != resp.headers.end())
{
// Check whether HTTPS connection is required and we don't have enabled it
if (!this->https_)
{
- if ( resp.headers["Location"].find("https://") != std::string::npos )
+ if (resp.headers["Location"].find("https://") != std::string::npos)
{
client_notify(TranslateT("Your account requires HTTPS connection. Activating."));
db_set_b(NULL, parent->m_szModuleName, FACEBOOK_KEY_FORCE_HTTPS, 1);
@@ -666,15 +666,15 @@ bool facebook_client::login(const std::string &username,const std::string &passw }
// Check for Device ID
- if ( cookies["datr"].length())
- db_set_s( NULL, parent->m_szModuleName, FACEBOOK_KEY_DEVICE_ID, cookies["datr"].c_str());
+ if (cookies["datr"].length())
+ db_set_s(NULL, parent->m_szModuleName, FACEBOOK_KEY_DEVICE_ID, cookies["datr"].c_str());
- switch ( resp.code )
+ switch (resp.code)
{
case HTTP_CODE_FAKE_DISCONNECTED:
{
// When is error only because timeout, try login once more
- if ( handle_error( "login" ))
+ if (handle_error("login"))
return login(username, password);
else
return false;
@@ -683,60 +683,60 @@ bool facebook_client::login(const std::string &username,const std::string &passw case HTTP_CODE_OK: // OK page returned, but that is regular login page we don't want in fact
{
// Check whether captcha code is required
- if ( resp.data.find("id=\"captcha\"") != std::string::npos )
+ if (resp.data.find("id=\"captcha\"") != std::string::npos)
{
- client_notify( TranslateT("Login error: Captcha code is required. Bad login credentials?"));
+ client_notify(TranslateT("Login error: Captcha code is required. Bad login credentials?"));
parent->Log(" ! ! Login error: Captcha code is required.");
- return handle_error( "login", FORCE_DISCONNECT );
+ return handle_error("login", FORCE_DISCONNECT);
}
// Get error message
std::string error_str = utils::text::trim(
utils::text::special_expressions_decode(
- utils::text::remove_html(
+ utils::text::remove_html(
utils::text::edit_html(
utils::text::source_get_value(&resp.data, 3, "login_error_box", "<p>", "</p>")))));
- if ( !error_str.length())
+ if (!error_str.length())
error_str = Translate("Unknown login error");
parent->Log(" ! ! Login error: %s", error_str.c_str());
std::string message = Translate("Login error: ") + error_str;
TCHAR* tmessage = mir_a2t(message.c_str());
- client_notify( tmessage );
- mir_free( tmessage );
+ client_notify(tmessage);
+ mir_free(tmessage);
}
case HTTP_CODE_FORBIDDEN: // Forbidden
case HTTP_CODE_NOT_FOUND: // Not Found
default:
- return handle_error( "login", FORCE_DISCONNECT );
+ return handle_error("login", FORCE_DISCONNECT);
case HTTP_CODE_FOUND: // Found and redirected to Home, Logged in, everything is OK
- if ( cookies.find("c_user") != cookies.end())
+ if (cookies.find("c_user") != cookies.end())
{
this->self_.user_id = cookies.find("c_user")->second;
db_set_s(NULL,parent->m_szModuleName,FACEBOOK_KEY_ID,this->self_.user_id.c_str());
parent->Log(" Got self user id: %s", this->self_.user_id.c_str());
- return handle_success( "login" );
+ return handle_success("login");
} else {
client_notify(TranslateT("Login error, probably bad login credentials."));
parent->Log(" ! ! Login error, probably bad login credentials.");
- return handle_error( "login", FORCE_DISCONNECT );
+ return handle_error("login", FORCE_DISCONNECT);
}
}
}
-bool facebook_client::logout( )
+bool facebook_client::logout()
{
- if ( db_get_b(NULL, parent->m_szModuleName, FACEBOOK_KEY_DISABLE_LOGOUT, 0))
+ if (db_get_b(NULL, parent->m_szModuleName, FACEBOOK_KEY_DISABLE_LOGOUT, 0))
return true;
- handle_entry( "logout" );
+ handle_entry("logout");
std::string data = "fb_dtsg=" + (this->dtsg_.length() ? this->dtsg_ : "0");
data += "&ref=mb&h=" + this->logout_hash_;
- http::response resp = flap( FACEBOOK_REQUEST_LOGOUT, &data );
+ http::response resp = flap(FACEBOOK_REQUEST_LOGOUT, &data);
if (hFcbCon)
Netlib_CloseHandle(hFcbCon);
@@ -745,62 +745,62 @@ bool facebook_client::logout( ) // Process result
username_ = password_ = self_.user_id = "";
- switch ( resp.code )
+ switch (resp.code)
{
case HTTP_CODE_OK:
case HTTP_CODE_FOUND:
- return handle_success( "logout" );
+ return handle_success("logout");
default:
return false; // Logout not finished properly, but..okay, who cares :P
}
}
-bool facebook_client::home( )
+bool facebook_client::home()
{
- handle_entry( "home" );
+ handle_entry("home");
// get fb_dtsg
- http::response resp = flap( FACEBOOK_REQUEST_DTSG );
+ http::response resp = flap(FACEBOOK_REQUEST_DTSG);
- this->dtsg_ = utils::text::source_get_value( &resp.data, 3, "name=\"fb_dtsg\"", "value=\"", "\"" );
+ this->dtsg_ = utils::text::source_get_value(&resp.data, 3, "name=\"fb_dtsg\"", "value=\"", "\"");
parent->Log(" Got self dtsg: %s", this->dtsg_.c_str());
if (this->dtsg_.empty())
return false;
- resp = flap( FACEBOOK_REQUEST_HOME );
+ resp = flap(FACEBOOK_REQUEST_HOME);
// Process result data
validate_response(&resp);
- switch ( resp.code )
+ switch (resp.code)
{
case HTTP_CODE_OK:
{
// Get real_name
- this->self_.real_name = utils::text::source_get_value( &resp.data, 2, "<strong class=\"profileName\">", "</strong>" );
+ this->self_.real_name = utils::text::source_get_value(&resp.data, 2, "<strong class=\"profileName\">", "</strong>");
if (!this->self_.real_name.empty()) {
db_set_utf(NULL, parent->m_szModuleName, FACEBOOK_KEY_NAME, this->self_.real_name.c_str());
db_set_utf(NULL, parent->m_szModuleName, FACEBOOK_KEY_NICK, this->self_.real_name.c_str());
parent->Log(" Got self real name: %s", this->self_.real_name.c_str());
} else {
client_notify(TranslateT("Something happened to Facebook. Maybe there was some major update so you should wait for an update."));
- return handle_error( "home", FORCE_DISCONNECT );
+ return handle_error("home", FORCE_DISCONNECT);
}
// Get avatar
- this->self_.image_url = utils::text::source_get_value( &resp.data, 4, "<i class=", "profpic", "<img src=\"", "\"" );
+ this->self_.image_url = utils::text::source_get_value(&resp.data, 4, "<i class=", "profpic", "<img src=\"", "\"");
parent->Log(" Got self avatar: %s", this->self_.image_url.c_str());
parent->CheckAvatarChange(NULL, this->self_.image_url);
// Get logout hash
- this->logout_hash_ = utils::text::source_get_value2( &resp.data, "/logout.php?h=", "&\"" );
+ this->logout_hash_ = utils::text::source_get_value2(&resp.data, "/logout.php?h=", "&\"");
parent->Log(" Got self logout hash: %s", this->logout_hash_.c_str());
- return handle_success( "home" );
+ return handle_success("home");
}
case HTTP_CODE_FOUND:
@@ -809,60 +809,60 @@ bool facebook_client::home( ) return this->home();
default:
- return handle_error( "home", FORCE_DISCONNECT );
+ return handle_error("home", FORCE_DISCONNECT);
}
}
-bool facebook_client::chat_state( bool online )
+bool facebook_client::chat_state(bool online)
{
- handle_entry( "chat_state" );
+ handle_entry("chat_state");
std::string data = (online ? "visibility=1" : "visibility=0");
data += "&window_id=0";
data += "&fb_dtsg=" + this->dtsg_;
data += "&lsd=&phstamp=0&__user=" + self_.user_id;
- http::response resp = flap( FACEBOOK_REQUEST_VISIBILITY, &data );
+ http::response resp = flap(FACEBOOK_REQUEST_VISIBILITY, &data);
- return handle_success( "chat_state" );
+ return handle_success("chat_state");
}
-bool facebook_client::reconnect( )
+bool facebook_client::reconnect()
{
- handle_entry( "reconnect" );
+ handle_entry("reconnect");
// Request reconnect
- http::response resp = flap( FACEBOOK_REQUEST_RECONNECT );
+ http::response resp = flap(FACEBOOK_REQUEST_RECONNECT);
// Process result data
validate_response(&resp);
- switch ( resp.code )
+ switch (resp.code)
{
case HTTP_CODE_OK:
{
- this->chat_channel_ = utils::text::source_get_value( &resp.data, 2, "\"user_channel\":\"", "\"" );
+ this->chat_channel_ = utils::text::source_get_value(&resp.data, 2, "\"user_channel\":\"", "\"");
parent->Log(" Got self channel: %s", this->chat_channel_.c_str());
- this->chat_channel_partition_ = utils::text::source_get_value2( &resp.data, "\"partition\":", ",}" );
+ this->chat_channel_partition_ = utils::text::source_get_value2(&resp.data, "\"partition\":", ",}");
parent->Log(" Got self channel partition: %s", this->chat_channel_partition_.c_str());
- this->chat_channel_host_ = utils::text::source_get_value( &resp.data, 2, "\"host\":\"", "\"" );
+ this->chat_channel_host_ = utils::text::source_get_value(&resp.data, 2, "\"host\":\"", "\"");
parent->Log(" Got self channel host: %s", this->chat_channel_host_.c_str());
- this->chat_sequence_num_ = utils::text::source_get_value2( &resp.data, "\"seq\":", ",}" );
+ this->chat_sequence_num_ = utils::text::source_get_value2(&resp.data, "\"seq\":", ",}");
parent->Log(" Got self sequence number: %s", this->chat_sequence_num_.c_str());
- return handle_success( "reconnect" );
+ return handle_success("reconnect");
}
default:
- return handle_error( "reconnect", FORCE_DISCONNECT );
+ return handle_error("reconnect", FORCE_DISCONNECT);
}
}
-bool facebook_client::buddy_list( )
+bool facebook_client::buddy_list()
{
- handle_entry( "buddy_list" );
+ handle_entry("buddy_list");
// Prepare update data
std::string data = "user=" + this->self_.user_id + "&fetch_mobile=true&fb_dtsg=" + this->dtsg_ + "&lsd=&__user=" + this->self_.user_id;
@@ -871,7 +871,7 @@ bool facebook_client::buddy_list( ) ScopedLock s(buddies_lock_);
int counter = 0;
- for (List::Item< facebook_user >* i = buddies.begin(); i != NULL; i = i->next, counter++ )
+ for (List::Item< facebook_user >* i = buddies.begin(); i != NULL; i = i->next, counter++)
{
data += "&available_user_info_ids[";
data += utils::conversion::to_string(&counter, UTILS_CONV_UNSIGNED_NUMBER);
@@ -881,146 +881,146 @@ bool facebook_client::buddy_list( ) }
// Get buddy list
- http::response resp = flap( FACEBOOK_REQUEST_BUDDY_LIST, &data );
+ http::response resp = flap(FACEBOOK_REQUEST_BUDDY_LIST, &data);
// Process result data
validate_response(&resp);
- switch ( resp.code )
+ switch (resp.code)
{
case HTTP_CODE_OK:
{
- std::string* response_data = new std::string( resp.data );
- ForkThread( &FacebookProto::ProcessBuddyList, this->parent, ( void* )response_data );
- return handle_success( "buddy_list" );
+ std::string* response_data = new std::string(resp.data);
+ ForkThread(&FacebookProto::ProcessBuddyList, this->parent, (void*)response_data);
+ return handle_success("buddy_list");
}
case HTTP_CODE_FAKE_ERROR:
case HTTP_CODE_FAKE_DISCONNECTED:
default:
- return handle_error( "buddy_list" );
+ return handle_error("buddy_list");
}
}
-bool facebook_client::load_friends( )
+bool facebook_client::load_friends()
{
- handle_entry( "load_friends" );
+ handle_entry("load_friends");
// Get buddy list
- http::response resp = flap( FACEBOOK_REQUEST_LOAD_FRIENDS );
+ http::response resp = flap(FACEBOOK_REQUEST_LOAD_FRIENDS);
// Process result data
validate_response(&resp);
- switch ( resp.code )
+ switch (resp.code)
{
case HTTP_CODE_OK:
{
- std::string* response_data = new std::string( resp.data );
- ForkThread( &FacebookProto::ProcessFriendList, this->parent, ( void* )response_data );
- return handle_success( "load_friends" );
+ std::string* response_data = new std::string(resp.data);
+ ForkThread(&FacebookProto::ProcessFriendList, this->parent, (void*)response_data);
+ return handle_success("load_friends");
}
case HTTP_CODE_FAKE_ERROR:
case HTTP_CODE_FAKE_DISCONNECTED:
default:
- return handle_error( "load_friends" );
+ return handle_error("load_friends");
}
}
-bool facebook_client::feeds( )
+bool facebook_client::feeds()
{
- handle_entry( "feeds" );
+ handle_entry("feeds");
// Get feeds
- http::response resp = flap( FACEBOOK_REQUEST_FEEDS );
+ http::response resp = flap(FACEBOOK_REQUEST_FEEDS);
// Process result data
validate_response(&resp);
- switch ( resp.code )
+ switch (resp.code)
{
case HTTP_CODE_OK:
if (resp.data.find("\"num_stories\":0") == std::string::npos) {
- std::string* response_data = new std::string( resp.data );
- ForkThread( &FacebookProto::ProcessFeeds, this->parent, ( void* )response_data );
+ std::string* response_data = new std::string(resp.data);
+ ForkThread(&FacebookProto::ProcessFeeds, this->parent, (void*)response_data);
}
- return handle_success( "feeds" );
+ return handle_success("feeds");
case HTTP_CODE_FAKE_ERROR:
case HTTP_CODE_FAKE_DISCONNECTED:
default:
- return handle_error( "feeds" );
+ return handle_error("feeds");
}
}
-bool facebook_client::channel( )
+bool facebook_client::channel()
{
- handle_entry( "channel" );
+ handle_entry("channel");
// Get update
- http::response resp = flap( FACEBOOK_REQUEST_MESSAGES_RECEIVE );
+ http::response resp = flap(FACEBOOK_REQUEST_MESSAGES_RECEIVE);
// Process result data
validate_response(&resp);
- if ( resp.code != HTTP_CODE_OK )
+ if (resp.code != HTTP_CODE_OK)
{
// Something went wrong
}
- else if ( resp.data.find( "\"t\":\"continue\"" ) != std::string::npos )
+ else if (resp.data.find("\"t\":\"continue\"") != std::string::npos)
{
// Everything is OK, no new message received
}
- else if ( resp.data.find( "\"t\":\"fullReload\"" ) != std::string::npos )
+ else if (resp.data.find("\"t\":\"fullReload\"") != std::string::npos)
{
// Something went wrong (server flooding?)
parent->Log("! ! ! Requested full reload");
- this->chat_sequence_num_ = utils::text::source_get_value2( &resp.data, "\"seq\":", ",}" );
+ this->chat_sequence_num_ = utils::text::source_get_value2(&resp.data, "\"seq\":", ",}");
parent->Log(" Got self sequence number: %s", this->chat_sequence_num_.c_str());
- this->chat_reconnect_reason_ = utils::text::source_get_value2( &resp.data, "\"reason\":", ",}" );
+ this->chat_reconnect_reason_ = utils::text::source_get_value2(&resp.data, "\"reason\":", ",}");
parent->Log(" Reconnect reason: %s", this->chat_reconnect_reason_.c_str());
}
- else if ( resp.data.find( "\"t\":\"refresh\"" ) != std::string::npos )
+ else if (resp.data.find("\"t\":\"refresh\"") != std::string::npos)
{
// Something went wrong (server flooding?)
parent->Log("! ! ! Requested channel refresh");
- this->chat_reconnect_reason_ = utils::text::source_get_value2( &resp.data, "\"reason\":", ",}" );
+ this->chat_reconnect_reason_ = utils::text::source_get_value2(&resp.data, "\"reason\":", ",}");
parent->Log(" Reconnect reason: %s", this->chat_reconnect_reason_.c_str());
- this->chat_sequence_num_ = utils::text::source_get_value2( &resp.data, "\"seq\":", ",}" );
+ this->chat_sequence_num_ = utils::text::source_get_value2(&resp.data, "\"seq\":", ",}");
parent->Log(" Got self sequence number: %s", this->chat_sequence_num_.c_str());
- return this->reconnect( );
+ return this->reconnect();
} else {
// Something has been received, throw to new thread to process
- std::string* response_data = new std::string( resp.data );
- ForkThread( &FacebookProto::ProcessMessages, this->parent, ( void* )response_data );
+ std::string* response_data = new std::string(resp.data);
+ ForkThread(&FacebookProto::ProcessMessages, this->parent, (void*)response_data);
// Increment sequence number
- this->chat_sequence_num_ = utils::text::source_get_value2( &resp.data, "\"seq\":", ",}" );
+ this->chat_sequence_num_ = utils::text::source_get_value2(&resp.data, "\"seq\":", ",}");
parent->Log(" Got self sequence number: %s", this->chat_sequence_num_.c_str());
}
// Return
- switch ( resp.code )
+ switch (resp.code)
{
case HTTP_CODE_OK:
- return handle_success( "channel" );
+ return handle_success("channel");
case HTTP_CODE_FAKE_DISCONNECTED:
case HTTP_CODE_FAKE_ERROR:
default:
- return handle_error( "channel" );
+ return handle_error("channel");
}
}
-bool facebook_client::send_message( std::string message_recipient, std::string message_text, std::string *error_text, int method )
+bool facebook_client::send_message(std::string message_recipient, std::string message_text, std::string *error_text, int method)
{
- handle_entry( "send_message" );
+ handle_entry("send_message");
http::response resp;
@@ -1029,14 +1029,14 @@ bool facebook_client::send_message( std::string message_recipient, std::string m {
parent->Log(" > Sending message through INBOX");
std::string data = "action=send";
- data += "&body=" + utils::url::encode( message_text );
+ data += "&body=" + utils::url::encode(message_text);
data += "&recipients[0]=" + message_recipient;
data += "&__user=" + this->self_.user_id;
data += "&__a=1";
data += "&fb_dtsg=" + (dtsg_.length() ? dtsg_ : "0");
data += "&phstamp=0";
- resp = flap( FACEBOOK_REQUEST_MESSAGE_SEND2, &data );
+ resp = flap(FACEBOOK_REQUEST_MESSAGE_SEND2, &data);
break;
}
case MESSAGE_MERCURY:
@@ -1070,7 +1070,7 @@ bool facebook_client::send_message( std::string message_recipient, std::string m data += "&__a=1";
data += "&phstamp=0";
- resp = flap( FACEBOOK_REQUEST_MESSAGE_SEND, &data );
+ resp = flap(FACEBOOK_REQUEST_MESSAGE_SEND, &data);
break;
}
case MESSAGE_TID:
@@ -1094,19 +1094,19 @@ bool facebook_client::send_message( std::string message_recipient, std::string m data += "&__user=" + this->self_.user_id;
data += "&phstamp=0";
- resp = flap( FACEBOOK_REQUEST_MESSAGE_SEND, &data );
+ resp = flap(FACEBOOK_REQUEST_MESSAGE_SEND, &data);
break;
}
case MESSAGE_ASYNC:
{
parent->Log(" > Sending message through ASYNC");
std::string data = "action=send";
- data += "&body=" + utils::url::encode( message_text );
+ data += "&body=" + utils::url::encode(message_text);
data += "&recipients[0]=" + message_recipient;
data += "&lsd=";
data += "&fb_dtsg=" + (dtsg_.length() ? dtsg_ : "0");
- resp = flap( FACEBOOK_REQUEST_ASYNC, &data );
+ resp = flap(FACEBOOK_REQUEST_ASYNC, &data);
break;
}
}
@@ -1114,7 +1114,7 @@ bool facebook_client::send_message( std::string message_recipient, std::string m validate_response(&resp);
*error_text = resp.error_text;
- switch ( resp.error_number )
+ switch (resp.error_number)
{
case 0: // Everything is OK
break;
@@ -1123,7 +1123,7 @@ bool facebook_client::send_message( std::string message_recipient, std::string m case 1356003: // Contact is offline
{
- HANDLE hContact = parent->ContactIDToHContact( message_recipient );
+ HANDLE hContact = parent->ContactIDToHContact(message_recipient);
if (hContact != NULL)
db_set_w(hContact,parent->m_szModuleName,"Status",ID_STATUS_OFFLINE);
return false;
@@ -1140,26 +1140,26 @@ bool facebook_client::send_message( std::string message_recipient, std::string m return false;
}
- switch ( resp.code )
+ switch (resp.code)
{
case HTTP_CODE_OK:
- return handle_success( "send_message" );
+ return handle_success("send_message");
case HTTP_CODE_FAKE_ERROR:
case HTTP_CODE_FAKE_DISCONNECTED:
default:
*error_text = Translate("Timeout when sending message.");
- handle_error( "send_message" );
+ handle_error("send_message");
return false;
}
}
-void facebook_client::close_chat( std::string message_recipient )
+void facebook_client::close_chat(std::string message_recipient)
{
// TODO RM: better optimalization for close_chat
// add items to list and then checking every x seconds
-/* if ( (::time(NULL) - parent->facy.last_close_chat_time_) < 8 )
+/* if ((::time(NULL) - parent->facy.last_close_chat_time_) < 8)
return;*/
// parent->facy.last_close_chat_time_ = ::time(NULL);
@@ -1172,10 +1172,10 @@ void facebook_client::close_chat( std::string message_recipient ) data += "&fb_dtsg=" + (this->dtsg_.length() ? this->dtsg_ : "0");
data += "&__user=" + self_.user_id;
- http::response resp = flap( FACEBOOK_REQUEST_TABS, &data );
+ http::response resp = flap(FACEBOOK_REQUEST_TABS, &data);
}
-void facebook_client::chat_mark_read( std::string message_recipient )
+void facebook_client::chat_mark_read(std::string message_recipient)
{
// TODO RM: optimalization?
@@ -1184,15 +1184,15 @@ void facebook_client::chat_mark_read( std::string message_recipient ) data += "&fb_dtsg=" + (this->dtsg_.length() ? this->dtsg_ : "0");
data += "&lsd=&__user=" + self_.user_id;
- http::response resp = flap( FACEBOOK_REQUEST_ASYNC, &data );
+ http::response resp = flap(FACEBOOK_REQUEST_ASYNC, &data);
}
bool facebook_client::set_status(const std::string &status_text)
{
- handle_entry( "set_status" );
+ handle_entry("set_status");
if (status_text.empty())
- return handle_success( "set_status" );
+ return handle_success("set_status");
// TODO: use also privacy options
std::string data = "&fb_dtsg=" + (this->dtsg_.length() ? this->dtsg_ : "0");
@@ -1201,19 +1201,19 @@ bool facebook_client::set_status(const std::string &status_text) data += "nctr[_mod]=pagelet_composer&__a=1&__req=b&phstamp=&composertags_place_name=Miranda+NG";
data += "&xhpc_message=" + utils::url::encode(status_text);
- http::response resp = flap( FACEBOOK_REQUEST_STATUS_SET, &data );
+ http::response resp = flap(FACEBOOK_REQUEST_STATUS_SET, &data);
validate_response(&resp);
- switch ( resp.code )
+ switch (resp.code)
{
case HTTP_CODE_OK:
- return handle_success( "set_status" );
+ return handle_success("set_status");
case HTTP_CODE_FAKE_ERROR:
case HTTP_CODE_FAKE_DISCONNECTED:
default:
- return handle_error( "set_status" );
+ return handle_error("set_status");
}
}
@@ -1228,17 +1228,17 @@ bool facebook_client::save_url(const std::string &url,const std::tstring &filena req.flags = NLHRF_HTTP11 | NLHRF_REDIRECT | NLHRF_PERSISTENT | NLHRF_NODUMP;
req.nlc = nlc;
- resp = reinterpret_cast<NETLIBHTTPREQUEST*>(CallService( MS_NETLIB_HTTPTRANSACTION,
+ resp = reinterpret_cast<NETLIBHTTPREQUEST*>(CallService(MS_NETLIB_HTTPTRANSACTION,
reinterpret_cast<WPARAM>(this->parent->m_hNetlibUser), reinterpret_cast<LPARAM>(&req)));
- if ( resp )
+ if (resp)
{
nlc = resp->nlc;
- parent->Log( "@@@@@ Saving avatar URL %s to path %s", url.c_str(), filename.c_str());
+ parent->Log("@@@@@ Saving avatar URL %s to path %s", url.c_str(), filename.c_str());
// Create folder if necessary
std::tstring dir = filename.substr(0,filename.rfind('\\'));
- if( _taccess(dir.c_str(),0))
+ if(_taccess(dir.c_str(),0))
CreateDirectoryTreeT(dir.c_str());
// Write to file
diff --git a/protocols/FacebookRM/src/connection.cpp b/protocols/FacebookRM/src/connection.cpp index 799a66f50e..54a68876ce 100644 --- a/protocols/FacebookRM/src/connection.cpp +++ b/protocols/FacebookRM/src/connection.cpp @@ -30,7 +30,7 @@ void FacebookProto::ChangeStatus(void*) int new_status = m_iDesiredStatus;
int old_status = m_iStatus;
- if ( new_status == ID_STATUS_OFFLINE )
+ if (new_status == ID_STATUS_OFFLINE)
{ // Logout
LOG("##### Beginning SignOff process");
@@ -38,21 +38,21 @@ void FacebookProto::ChangeStatus(void*) SetEvent(update_loop_lock_);
Netlib_Shutdown(facy.hMsgCon);
- if ( getByte(FACEBOOK_KEY_DISCONNECT_CHAT, DEFAULT_DISCONNECT_CHAT))
- facy.chat_state( false );
+ if (getByte(FACEBOOK_KEY_DISCONNECT_CHAT, DEFAULT_DISCONNECT_CHAT))
+ facy.chat_state(false);
- facy.logout( );
+ facy.logout();
- deleteSetting( "LogonTS" );
+ deleteSetting("LogonTS");
- facy.clear_cookies( );
- facy.buddies.clear( );
+ facy.clear_cookies();
+ facy.buddies.clear();
ProtoBroadcastAck(m_szModuleName, 0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, m_iStatus);
OnLeaveChat(NULL, NULL);
- SetAllContactStatuses( ID_STATUS_OFFLINE, true );
+ SetAllContactStatuses(ID_STATUS_OFFLINE, true);
ToggleStatusMenuItems(false);
@@ -64,10 +64,10 @@ void FacebookProto::ChangeStatus(void*) return;
}
- else if ( old_status == ID_STATUS_OFFLINE )
+ else if (old_status == ID_STATUS_OFFLINE)
{ // Login
SYSTEMTIME t;
- GetLocalTime( &t );
+ GetLocalTime(&t);
Log("[%d.%d.%d] Using Facebook Protocol RM %s", t.wDay, t.wMonth, t.wYear, __VERSION_STRING);
LOG("***** Beginning SignOn process");
@@ -83,17 +83,17 @@ void FacebookProto::ChangeStatus(void*) facy.load_friends();
// Process Friends requests
- ForkThread( &FacebookProto::ProcessFriendRequests, this, NULL );
+ ForkThread(&FacebookProto::ProcessFriendRequests, this, NULL);
// Get unread messages
- ForkThread( &FacebookProto::ProcessUnreadMessages, this );
+ ForkThread(&FacebookProto::ProcessUnreadMessages, this);
// Get notifications
- ForkThread( &FacebookProto::ProcessNotifications, this );
+ ForkThread(&FacebookProto::ProcessNotifications, this);
- setDword( "LogonTS", (DWORD)time(NULL));
- ForkThread( &FacebookProto::UpdateLoop, this );
- ForkThread( &FacebookProto::MessageLoop, this );
+ setDword("LogonTS", (DWORD)time(NULL));
+ ForkThread(&FacebookProto::UpdateLoop, this);
+ ForkThread(&FacebookProto::MessageLoop, this);
if (getByte(FACEBOOK_KEY_SET_MIRANDA_STATUS, DEFAULT_SET_MIRANDA_STATUS))
{
@@ -115,14 +115,14 @@ void FacebookProto::ChangeStatus(void*) ToggleStatusMenuItems(true);
LOG("***** SignOn complete");
}
- else if ( new_status == ID_STATUS_INVISIBLE )
+ else if (new_status == ID_STATUS_INVISIBLE)
{
- facy.buddies.clear( );
- this->SetAllContactStatuses( ID_STATUS_OFFLINE, true );
+ facy.buddies.clear();
+ this->SetAllContactStatuses(ID_STATUS_OFFLINE, true);
}
- facy.chat_state( m_iDesiredStatus != ID_STATUS_INVISIBLE );
- facy.buddy_list( );
+ facy.chat_state(m_iDesiredStatus != ID_STATUS_INVISIBLE);
+ facy.buddy_list();
m_iStatus = facy.self_.status_id = m_iDesiredStatus;
ProtoBroadcastAck(m_szModuleName, 0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, m_iStatus);
@@ -131,7 +131,7 @@ void FacebookProto::ChangeStatus(void*) }
/** Return true on success, false on error. */
-bool FacebookProto::NegotiateConnection( )
+bool FacebookProto::NegotiateConnection()
{
LOG("***** Negotiating connection with Facebook");
@@ -140,7 +140,7 @@ bool FacebookProto::NegotiateConnection( ) DBVARIANT dbv = {0};
error = true;
- if ( !db_get_s(NULL,m_szModuleName,FACEBOOK_KEY_LOGIN,&dbv))
+ if (!db_get_s(NULL,m_szModuleName,FACEBOOK_KEY_LOGIN,&dbv))
{
user = dbv.pszVal;
db_free(&dbv);
@@ -153,7 +153,7 @@ bool FacebookProto::NegotiateConnection( ) }
error = true;
- if ( !db_get_s(NULL,m_szModuleName,FACEBOOK_KEY_PASS,&dbv))
+ if (!db_get_s(NULL,m_szModuleName,FACEBOOK_KEY_PASS,&dbv))
{
CallService(MS_DB_CRYPT_DECODESTRING,strlen(dbv.pszVal)+1,
reinterpret_cast<LPARAM>(dbv.pszVal));
@@ -168,7 +168,7 @@ bool FacebookProto::NegotiateConnection( ) }
// Load machine name
- if ( !db_get_s(NULL,m_szModuleName,FACEBOOK_KEY_DEVICE_ID,&dbv))
+ if (!db_get_s(NULL,m_szModuleName,FACEBOOK_KEY_DEVICE_ID,&dbv))
{
facy.cookies["datr"] = dbv.pszVal;
db_free(&dbv);
@@ -178,7 +178,7 @@ bool FacebookProto::NegotiateConnection( ) facy.last_feeds_update_ = ::time(NULL);
// Get info about secured connection
- facy.https_ = db_get_b(NULL, m_szModuleName, FACEBOOK_KEY_FORCE_HTTPS, DEFAULT_FORCE_HTTPS ) != 0;
+ facy.https_ = db_get_b(NULL, m_szModuleName, FACEBOOK_KEY_FORCE_HTTPS, DEFAULT_FORCE_HTTPS) != 0;
// Create default group for new contacts
if (!db_get_ts(NULL, m_szModuleName, FACEBOOK_KEY_DEF_GROUP, &dbv) && lstrlen(dbv.ptszVal) > 0)
@@ -186,59 +186,59 @@ bool FacebookProto::NegotiateConnection( ) CallService(MS_CLIST_GROUPCREATE, 0, (LPARAM)dbv.ptszVal);
}
- return facy.login( user, pass );
+ return facy.login(user, pass);
}
void FacebookProto::UpdateLoop(void *)
{
time_t tim = ::time(NULL);
- LOG( ">>>>> Entering Facebook::UpdateLoop[%d]", tim );
+ LOG(">>>>> Entering Facebook::UpdateLoop[%d]", tim);
- for ( int i = -1; !isOffline(); i = ++i % 50 )
+ for (int i = -1; !isOffline(); i = ++i % 50)
{
- if ( i != -1 ) {
- if ( !facy.invisible_ )
- if ( !facy.buddy_list( ))
+ if (i != -1) {
+ if (!facy.invisible_)
+ if (!facy.buddy_list())
break;
}
- if ( i == 2 && getByte( FACEBOOK_KEY_EVENT_FEEDS_ENABLE, DEFAULT_EVENT_FEEDS_ENABLE ))
- if ( !facy.feeds( ))
+ if (i == 2 && getByte(FACEBOOK_KEY_EVENT_FEEDS_ENABLE, DEFAULT_EVENT_FEEDS_ENABLE))
+ if (!facy.feeds())
break;
- if ( i == 49 )
- ForkThread( &FacebookProto::ProcessFriendRequests, this, NULL );
+ if (i == 49)
+ ForkThread(&FacebookProto::ProcessFriendRequests, this, NULL);
- LOG( "***** FacebookProto::UpdateLoop[%d] going to sleep...", tim );
- if ( WaitForSingleObjectEx( update_loop_lock_, GetPollRate( ) * 1000, true ) != WAIT_TIMEOUT )
+ LOG("***** FacebookProto::UpdateLoop[%d] going to sleep...", tim);
+ if (WaitForSingleObjectEx(update_loop_lock_, GetPollRate() * 1000, true) != WAIT_TIMEOUT)
break;
- LOG( "***** FacebookProto::UpdateLoop[%d] waking up...", tim );
+ LOG("***** FacebookProto::UpdateLoop[%d] waking up...", tim);
}
ResetEvent(update_loop_lock_);
- LOG( "<<<<< Exiting FacebookProto::UpdateLoop[%d]", tim );
+ LOG("<<<<< Exiting FacebookProto::UpdateLoop[%d]", tim);
}
void FacebookProto::MessageLoop(void *)
{
time_t tim = ::time(NULL);
- LOG( ">>>>> Entering Facebook::MessageLoop[%d]", tim );
+ LOG(">>>>> Entering Facebook::MessageLoop[%d]", tim);
- while ( facy.channel( ))
+ while (facy.channel())
{
- if ( isOffline())
+ if (isOffline())
break;
- LOG( "***** FacebookProto::MessageLoop[%d] refreshing...", tim );
+ LOG("***** FacebookProto::MessageLoop[%d] refreshing...", tim);
}
- LOG( "<<<<< Exiting FacebookProto::MessageLoop[%d]", tim );
+ LOG("<<<<< Exiting FacebookProto::MessageLoop[%d]", tim);
}
-BYTE FacebookProto::GetPollRate( )
+BYTE FacebookProto::GetPollRate()
{
- BYTE poll_rate = getByte( FACEBOOK_KEY_POLL_RATE, FACEBOOK_DEFAULT_POLL_RATE );
+ BYTE poll_rate = getByte(FACEBOOK_KEY_POLL_RATE, FACEBOOK_DEFAULT_POLL_RATE);
return (
- ( poll_rate >= FACEBOOK_MINIMAL_POLL_RATE &&
- poll_rate <= FACEBOOK_MAXIMAL_POLL_RATE )
- ? poll_rate : FACEBOOK_DEFAULT_POLL_RATE );
+ (poll_rate >= FACEBOOK_MINIMAL_POLL_RATE &&
+ poll_rate <= FACEBOOK_MAXIMAL_POLL_RATE)
+ ? poll_rate : FACEBOOK_DEFAULT_POLL_RATE);
}
diff --git a/protocols/FacebookRM/src/contacts.cpp b/protocols/FacebookRM/src/contacts.cpp index 0d3ba50bfe..0fd4a2b1e9 100644 --- a/protocols/FacebookRM/src/contacts.cpp +++ b/protocols/FacebookRM/src/contacts.cpp @@ -25,9 +25,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. bool FacebookProto::IsMyContact(HANDLE hContact, bool include_chat)
{
const char *proto = GetContactProto(hContact);
- if( proto && strcmp(m_szModuleName,proto) == 0 )
+ if(proto && strcmp(m_szModuleName, proto) == 0)
{
- if( include_chat )
+ if(include_chat)
return true;
else
return db_get_b(hContact,m_szModuleName,"ChatRoom",0) == 0;
@@ -43,15 +43,12 @@ HANDLE FacebookProto::ChatIDToHContact(std::string chat_id) continue;
DBVARIANT dbv;
- if( !db_get_s(hContact,m_szModuleName,"ChatRoomID",&dbv))
+ if(!db_get_s(hContact,m_szModuleName,"ChatRoomID",&dbv))
{
- if( strcmp(chat_id.c_str(),dbv.pszVal) == 0 )
- {
- db_free(&dbv);
+ bool found = strcmp(chat_id.c_str(), dbv.pszVal) == 0;
+ db_free(&dbv);
+ if (found)
return hContact;
- } else {
- db_free(&dbv);
- }
}
}
@@ -65,9 +62,9 @@ HANDLE FacebookProto::ContactIDToHContact(std::string user_id) continue;
DBVARIANT dbv;
- if( !db_get_s(hContact,m_szModuleName,FACEBOOK_KEY_ID,&dbv))
+ if(!db_get_s(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)
{
db_free(&dbv);
return hContact;
@@ -87,15 +84,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)
{
db_set_s(hContact,m_szModuleName,FACEBOOK_KEY_ID,fbu->user_id.c_str());
@@ -106,7 +103,7 @@ HANDLE FacebookProto::AddToContactList(facebook_user* fbu, BYTE type, bool dont_ db_unset(hContact, "CList", "MyHandle");
DBVARIANT dbv;
- if( !db_get_ts(NULL,m_szModuleName,FACEBOOK_KEY_DEF_GROUP,&dbv))
+ if(!db_get_ts(NULL,m_szModuleName,FACEBOOK_KEY_DEF_GROUP,&dbv))
{
db_set_ts(hContact,"CList","Group",dbv.ptszVal);
db_free(&dbv);
@@ -135,7 +132,7 @@ HANDLE FacebookProto::AddToContactList(facebook_user* fbu, BYTE type, bool dont_ void FacebookProto::SetAllContactStatuses(int status, bool reset_client)
{
for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- if ( db_get_b(hContact,m_szModuleName,"ChatRoom",0))
+ if (db_get_b(hContact,m_szModuleName,"ChatRoom",0))
continue;
if (reset_client) {
@@ -168,9 +165,9 @@ void FacebookProto::SetAllContactStatuses(int status, bool reset_client) void FacebookProto::DeleteContactFromServer(void *data)
{
- facy.handle_entry( "DeleteContactFromServer" );
+ facy.handle_entry("DeleteContactFromServer");
- if ( data == NULL )
+ if (data == NULL)
return;
std::string id = (*(std::string*)data);
@@ -184,14 +181,14 @@ void FacebookProto::DeleteContactFromServer(void *data) std::string get_query = "norefresh=true&unref=button_dropdown&uid=" + id;
// Get unread inbox threads
- http::response resp = facy.flap( FACEBOOK_REQUEST_DELETE_FRIEND, &query, &get_query );
+ http::response resp = facy.flap(FACEBOOK_REQUEST_DELETE_FRIEND, &query, &get_query);
// Process result data
facy.validate_response(&resp);
if (resp.data.find("\"payload\":null", 0) != std::string::npos)
{
- facebook_user* fbu = facy.buddies.find( id );
+ facebook_user* fbu = facy.buddies.find(id);
if (fbu != NULL)
fbu->deleted = true;
@@ -207,18 +204,18 @@ void FacebookProto::DeleteContactFromServer(void *data) 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."));
+ facy.client_notify(TranslateT("Error occured when removing contact from server."));
}
if (resp.code != HTTP_CODE_OK)
- facy.handle_error( "DeleteContactFromServer" );
+ facy.handle_error("DeleteContactFromServer");
}
void FacebookProto::AddContactToServer(void *data)
{
- facy.handle_entry( "AddContactToServer" );
+ facy.handle_entry("AddContactToServer");
- if ( data == NULL )
+ if (data == NULL)
return;
std::string id = (*(std::string*)data);
@@ -230,7 +227,7 @@ void FacebookProto::AddContactToServer(void *data) query += "&__user=" + facy.self_.user_id;
// Get unread inbox threads
- http::response resp = facy.flap( FACEBOOK_REQUEST_REQUEST_FRIEND, &query );
+ http::response resp = facy.flap(FACEBOOK_REQUEST_REQUEST_FRIEND, &query);
// Process result data
facy.validate_response(&resp);
@@ -247,19 +244,19 @@ void FacebookProto::AddContactToServer(void *data) NotifyEvent(m_tszUserName, TranslateT("Request for friendship was sent."), NULL, FACEBOOK_EVENT_OTHER, NULL);
} else {
- facy.client_notify( TranslateT("Error occured when requesting friendship."));
+ facy.client_notify(TranslateT("Error occured when requesting friendship."));
}
if (resp.code != HTTP_CODE_OK)
- facy.handle_error( "AddContactToServer" );
+ facy.handle_error("AddContactToServer");
}
void FacebookProto::ApproveContactToServer(void *data)
{
- facy.handle_entry( "ApproveContactToServer" );
+ facy.handle_entry("ApproveContactToServer");
- if ( data == NULL )
+ if (data == NULL)
return;
HANDLE hContact = (*(HANDLE*)data);
@@ -277,7 +274,7 @@ void FacebookProto::ApproveContactToServer(void *data) db_free(&dbv);
}
- http::response resp = facy.flap( FACEBOOK_REQUEST_APPROVE_FRIEND, &post_data, &get_data );
+ http::response resp = facy.flap(FACEBOOK_REQUEST_APPROVE_FRIEND, &post_data, &get_data);
// Process result data
facy.validate_response(&resp);
@@ -287,9 +284,9 @@ void FacebookProto::ApproveContactToServer(void *data) void FacebookProto::CancelFriendsRequest(void *data)
{
- facy.handle_entry( "CancelFriendsRequest" );
+ facy.handle_entry("CancelFriendsRequest");
- if ( data == NULL )
+ if (data == NULL)
return;
HANDLE hContact = (*(HANDLE*)data);
@@ -307,7 +304,7 @@ void FacebookProto::CancelFriendsRequest(void *data) }
// Get unread inbox threads
- http::response resp = facy.flap( FACEBOOK_REQUEST_CANCEL_REQUEST, &query );
+ http::response resp = facy.flap(FACEBOOK_REQUEST_CANCEL_REQUEST, &query);
// Process result data
facy.validate_response(&resp);
@@ -317,11 +314,11 @@ void FacebookProto::CancelFriendsRequest(void *data) db_set_b(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."));
+ facy.client_notify(TranslateT("Error occured when canceling friendship request."));
}
if (resp.code != HTTP_CODE_OK)
- facy.handle_error( "CancelFriendsRequest" );
+ facy.handle_error("CancelFriendsRequest");
}
diff --git a/protocols/FacebookRM/src/db.h b/protocols/FacebookRM/src/db.h index 1d309b1160..373bf8163a 100644 --- a/protocols/FacebookRM/src/db.h +++ b/protocols/FacebookRM/src/db.h @@ -23,19 +23,19 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #pragma once
// DB macros
-#define getByte( setting, error ) db_get_b( NULL, m_szModuleName, setting, error )
-#define setByte( setting, value ) db_set_b( NULL, m_szModuleName, setting, value )
-#define getWord( setting, error ) db_get_w( NULL, m_szModuleName, setting, error )
-#define setWord( setting, value ) db_set_w( NULL, m_szModuleName, setting, value )
-#define getDword( setting, error ) db_get_dw( NULL, m_szModuleName, setting, error )
-#define setDword( setting, value ) db_set_dw( NULL, m_szModuleName, setting, value )
-#define getString( setting, dest ) db_get_s( NULL, m_szModuleName, setting, dest )
-#define setString( setting, value ) db_set_s( NULL, m_szModuleName, setting, value )
-#define getTString( setting, dest ) db_get_ts( NULL, m_szModuleName, setting, dest )
-#define setTString( setting, value ) db_set_ts( NULL, m_szModuleName, setting, value )
-#define getU8String( setting, dest ) db_get_utf( NULL, m_szModuleName, setting, dest )
-#define setU8String( setting, value ) db_set_utf( NULL, m_szModuleName, setting, value )
-#define deleteSetting( setting ) db_unset( NULL, m_szModuleName, setting )
+#define getByte(setting, error) db_get_b(NULL, m_szModuleName, setting, error)
+#define setByte(setting, value) db_set_b(NULL, m_szModuleName, setting, value)
+#define getWord(setting, error) db_get_w(NULL, m_szModuleName, setting, error)
+#define setWord(setting, value) db_set_w(NULL, m_szModuleName, setting, value)
+#define getDword(setting, error) db_get_dw(NULL, m_szModuleName, setting, error)
+#define setDword(setting, value) db_set_dw(NULL, m_szModuleName, setting, value)
+#define getString(setting, dest) db_get_s(NULL, m_szModuleName, setting, dest)
+#define setString(setting, value) db_set_s(NULL, m_szModuleName, setting, value)
+#define getTString(setting, dest) db_get_ts(NULL, m_szModuleName, setting, dest)
+#define setTString(setting, value) db_set_ts(NULL, m_szModuleName, setting, value)
+#define getU8String(setting, dest) db_get_utf(NULL, m_szModuleName, setting, dest)
+#define setU8String(setting, value) db_set_utf(NULL, m_szModuleName, setting, value)
+#define deleteSetting(setting) db_unset(NULL, m_szModuleName, setting)
// DB keys
#define FACEBOOK_KEY_LOGIN "Email"
diff --git a/protocols/FacebookRM/src/definitions.h b/protocols/FacebookRM/src/definitions.h index 8e33793d68..3de244779f 100644 --- a/protocols/FacebookRM/src/definitions.h +++ b/protocols/FacebookRM/src/definitions.h @@ -25,11 +25,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #define CODE_BLOCK_BEGIN {
#define CODE_BLOCK_TRY try {
#define CODE_BLOCK_CATCH } catch(const std::exception &e) {
-#define CODE_BLOCK_INFINITE while( true ) {
+#define CODE_BLOCK_INFINITE while(true) {
#define CODE_BLOCK_END }
-#define FLAG_CONTAINS(x,y) ( ( x & y ) == y )
-#define REMOVE_FLAG(x,y) ( x = ( x & ~y ))
+#define FLAG_CONTAINS(x,y) ((x & y) == y)
+#define REMOVE_FLAG(x,y) (x = (x & ~y))
#define LOG Log
diff --git a/protocols/FacebookRM/src/dialogs.cpp b/protocols/FacebookRM/src/dialogs.cpp index e5bbf76d8f..f27adefe2e 100644 --- a/protocols/FacebookRM/src/dialogs.cpp +++ b/protocols/FacebookRM/src/dialogs.cpp @@ -36,11 +36,11 @@ static BOOL StoreDBCheckState(FacebookProto* ppro, HWND hwnd, int idCtrl, const return state;
}
-INT_PTR CALLBACK FBAccountProc( HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam )
+INT_PTR CALLBACK FBAccountProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
FacebookProto *proto;
- switch ( message )
+ switch (message)
{
case WM_INITDIALOG:
@@ -50,13 +50,13 @@ INT_PTR CALLBACK FBAccountProc( HWND hwnd, UINT message, WPARAM wparam, LPARAM l SetWindowLongPtr(hwnd,GWLP_USERDATA,lparam);
DBVARIANT dbv;
- if ( !db_get_s(0,proto->ModuleName(),FACEBOOK_KEY_LOGIN,&dbv))
+ if (!db_get_s(0,proto->ModuleName(),FACEBOOK_KEY_LOGIN,&dbv))
{
SetDlgItemTextA(hwnd,IDC_UN,dbv.pszVal);
db_free(&dbv);
}
- if ( !db_get_s(0,proto->ModuleName(),FACEBOOK_KEY_PASS,&dbv))
+ if (!db_get_s(0,proto->ModuleName(),FACEBOOK_KEY_PASS,&dbv))
{
CallService(MS_DB_CRYPT_DECODESTRING,strlen(dbv.pszVal)+1,
reinterpret_cast<LPARAM>(dbv.pszVal));
@@ -71,14 +71,14 @@ INT_PTR CALLBACK FBAccountProc( HWND hwnd, UINT message, WPARAM wparam, LPARAM l return TRUE;
case WM_COMMAND:
- if ( LOWORD( wparam ) == IDC_NEWACCOUNTLINK )
+ if (LOWORD(wparam) == IDC_NEWACCOUNTLINK)
{
CallService(MS_UTILS_OPENURL,1,reinterpret_cast<LPARAM>
- ( FACEBOOK_URL_HOMEPAGE ));
+ (FACEBOOK_URL_HOMEPAGE));
return TRUE;
}
- if ( HIWORD( wparam ) == EN_CHANGE && reinterpret_cast<HWND>(lparam) == GetFocus())
+ if (HIWORD(wparam) == EN_CHANGE && reinterpret_cast<HWND>(lparam) == GetFocus())
{
switch(LOWORD(wparam))
{
@@ -90,7 +90,7 @@ INT_PTR CALLBACK FBAccountProc( HWND hwnd, UINT message, WPARAM wparam, LPARAM l break;
case WM_NOTIFY:
- if ( reinterpret_cast<NMHDR*>(lparam)->code == PSN_APPLY )
+ if (reinterpret_cast<NMHDR*>(lparam)->code == PSN_APPLY)
{
proto = reinterpret_cast<FacebookProto*>(GetWindowLongPtr(hwnd,GWLP_USERDATA));
char str[128];
@@ -111,7 +111,7 @@ INT_PTR CALLBACK FBAccountProc( HWND hwnd, UINT message, WPARAM wparam, LPARAM l return FALSE;
}
-INT_PTR CALLBACK FBMindProc( HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam )
+INT_PTR CALLBACK FBMindProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
FacebookProto *proto;
@@ -130,27 +130,27 @@ INT_PTR CALLBACK FBMindProc( HWND hwnd, UINT message, WPARAM wparam, LPARAM lpar if (!db_get_ts(NULL,proto->m_szModuleName,FACEBOOK_KEY_NAME,&dbv))
{
- SetWindowText( hwnd, dbv.ptszVal );
- db_free( &dbv );
+ SetWindowText(hwnd, dbv.ptszVal);
+ db_free(&dbv);
}
}
- EnableWindow(GetDlgItem( hwnd, IDOK ), FALSE);
+ EnableWindow(GetDlgItem(hwnd, IDOK), FALSE);
return TRUE;
case WM_COMMAND:
- if ( LOWORD( wparam ) == IDC_MINDMSG && HIWORD( wparam ) == EN_CHANGE )
+ if (LOWORD(wparam) == IDC_MINDMSG && HIWORD(wparam) == EN_CHANGE)
{
size_t len = SendDlgItemMessage(hwnd,IDC_MINDMSG,WM_GETTEXTLENGTH,0,0);
TCHAR str[4];
- _sntprintf( str, 4, TEXT( "%d" ), FACEBOOK_MIND_LIMIT-len );
+ _sntprintf(str, 4, TEXT("%d"), FACEBOOK_MIND_LIMIT-len);
SetDlgItemText(hwnd,IDC_CHARACTERS,str);
- EnableWindow(GetDlgItem( hwnd, IDOK ), len > 0);
+ EnableWindow(GetDlgItem(hwnd, IDOK), len > 0);
return TRUE;
}
- else if ( LOWORD( wparam ) == IDOK )
+ else if (LOWORD(wparam) == IDOK)
{
TCHAR mindMessage[FACEBOOK_MIND_LIMIT+1];
proto = reinterpret_cast<FacebookProto*>(GetWindowLongPtr(hwnd,GWLP_USERDATA));
@@ -169,7 +169,7 @@ INT_PTR CALLBACK FBMindProc( HWND hwnd, UINT message, WPARAM wparam, LPARAM lpar EndDialog(hwnd, wparam);
return TRUE;
}
- else if ( LOWORD( wparam ) == IDCANCEL )
+ else if (LOWORD(wparam) == IDCANCEL)
{
EndDialog(hwnd, wparam);
return TRUE;
@@ -181,11 +181,11 @@ INT_PTR CALLBACK FBMindProc( HWND hwnd, UINT message, WPARAM wparam, LPARAM lpar return FALSE;
}
-INT_PTR CALLBACK FBOptionsProc( HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam )
+INT_PTR CALLBACK FBOptionsProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
FacebookProto *proto = reinterpret_cast<FacebookProto*>(GetWindowLongPtr(hwnd,GWLP_USERDATA));
- switch ( message )
+ switch (message)
{
case WM_INITDIALOG:
@@ -196,13 +196,13 @@ INT_PTR CALLBACK FBOptionsProc( HWND hwnd, UINT message, WPARAM wparam, LPARAM l SetWindowLongPtr(hwnd,GWLP_USERDATA,lparam);
DBVARIANT dbv;
- if ( !db_get_s(0,proto->ModuleName(),FACEBOOK_KEY_LOGIN,&dbv))
+ if (!db_get_s(0,proto->ModuleName(),FACEBOOK_KEY_LOGIN,&dbv))
{
SetDlgItemTextA(hwnd,IDC_UN,dbv.pszVal);
db_free(&dbv);
}
- if ( !db_get_s(0,proto->ModuleName(),FACEBOOK_KEY_PASS,&dbv))
+ if (!db_get_s(0,proto->ModuleName(),FACEBOOK_KEY_PASS,&dbv))
{
CallService(MS_DB_CRYPT_DECODESTRING,strlen(dbv.pszVal)+1,reinterpret_cast<LPARAM>(dbv.pszVal));
SetDlgItemTextA(hwnd,IDC_PW,dbv.pszVal);
@@ -217,7 +217,7 @@ INT_PTR CALLBACK FBOptionsProc( HWND hwnd, UINT message, WPARAM wparam, LPARAM l SendDlgItemMessage(hwnd, IDC_GROUP, EM_LIMITTEXT, FACEBOOK_GROUP_NAME_LIMIT, 0);
- if ( !db_get_ts(0,proto->ModuleName(),FACEBOOK_KEY_DEF_GROUP,&dbv))
+ if (!db_get_ts(0,proto->ModuleName(),FACEBOOK_KEY_DEF_GROUP,&dbv))
{
SetDlgItemText(hwnd,IDC_GROUP,dbv.ptszVal);
db_free(&dbv);
@@ -230,14 +230,14 @@ INT_PTR CALLBACK FBOptionsProc( HWND hwnd, UINT message, WPARAM wparam, LPARAM l } return TRUE;
case WM_COMMAND: {
- if ( LOWORD( wparam ) == IDC_NEWACCOUNTLINK )
+ if (LOWORD(wparam) == IDC_NEWACCOUNTLINK)
{
CallService(MS_UTILS_OPENURL,1,reinterpret_cast<LPARAM>
- ( FACEBOOK_URL_HOMEPAGE ));
+ (FACEBOOK_URL_HOMEPAGE));
return TRUE;
}
- if ( LOWORD( wparam ) == IDC_SECURE ) {
+ if (LOWORD(wparam) == IDC_SECURE) {
EnableWindow(GetDlgItem(hwnd, IDC_SECURE_CHANNEL), IsDlgButtonChecked(hwnd, IDC_SECURE));
}
@@ -250,7 +250,7 @@ INT_PTR CALLBACK FBOptionsProc( HWND hwnd, UINT message, WPARAM wparam, LPARAM l } break;
case WM_NOTIFY:
- if ( reinterpret_cast<NMHDR*>(lparam)->code == PSN_APPLY )
+ if (reinterpret_cast<NMHDR*>(lparam)->code == PSN_APPLY)
{
char str[128]; TCHAR tstr[128];
@@ -262,10 +262,10 @@ INT_PTR CALLBACK FBOptionsProc( HWND hwnd, UINT message, WPARAM wparam, LPARAM l db_set_s(NULL,proto->m_szModuleName,FACEBOOK_KEY_PASS,str);
GetDlgItemText(hwnd,IDC_GROUP,tstr,sizeof(tstr));
- if ( lstrlen( tstr ) > 0 )
+ if (lstrlen(tstr) > 0)
{
db_set_ts(NULL,proto->m_szModuleName,FACEBOOK_KEY_DEF_GROUP,tstr);
- CallService( MS_CLIST_GROUPCREATE, 0, (LPARAM)tstr );
+ CallService(MS_CLIST_GROUPCREATE, 0, (LPARAM)tstr);
}
else
db_unset(NULL,proto->m_szModuleName,FACEBOOK_KEY_DEF_GROUP);
@@ -283,11 +283,11 @@ INT_PTR CALLBACK FBOptionsProc( HWND hwnd, UINT message, WPARAM wparam, LPARAM l return FALSE;
}
-INT_PTR CALLBACK FBOptionsAdvancedProc( HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam )
+INT_PTR CALLBACK FBOptionsAdvancedProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
FacebookProto *proto = reinterpret_cast<FacebookProto*>(GetWindowLongPtr(hwnd,GWLP_USERDATA));
- switch ( message )
+ switch (message)
{
case WM_INITDIALOG:
@@ -311,12 +311,12 @@ INT_PTR CALLBACK FBOptionsAdvancedProc( HWND hwnd, UINT message, WPARAM wparam, }
case WM_COMMAND: {
- if ( LOWORD( wparam ) == IDC_SECURE ) {
+ if (LOWORD(wparam) == IDC_SECURE) {
EnableWindow(GetDlgItem(hwnd, IDC_SECURE_CHANNEL), IsDlgButtonChecked(hwnd, IDC_SECURE));
}
if (LOWORD(wparam) == IDC_SECURE_CHANNEL && IsDlgButtonChecked(hwnd, IDC_SECURE_CHANNEL))
- MessageBox( hwnd, TranslateT("Note: Make sure you have disabled 'Validate SSL certificates' option in Network options to work properly."), proto->m_tszUserName, MB_OK );
+ MessageBox(hwnd, TranslateT("Note: Make sure you have disabled 'Validate SSL certificates' option in Network options to work properly."), proto->m_tszUserName, MB_OK);
SendMessage(GetParent(hwnd),PSM_CHANGED,0,0);
@@ -324,7 +324,7 @@ INT_PTR CALLBACK FBOptionsAdvancedProc( HWND hwnd, UINT message, WPARAM wparam, }
case WM_NOTIFY:
- if ( reinterpret_cast<NMHDR*>(lparam)->code == PSN_APPLY )
+ if (reinterpret_cast<NMHDR*>(lparam)->code == PSN_APPLY)
{
StoreDBCheckState(proto, hwnd, IDC_SECURE, FACEBOOK_KEY_FORCE_HTTPS);
StoreDBCheckState(proto, hwnd, IDC_LOGGING, FACEBOOK_KEY_LOGGING_ENABLE);
@@ -354,7 +354,7 @@ INT_PTR CALLBACK FBOptionsAdvancedProc( HWND hwnd, UINT message, WPARAM wparam, }
-INT_PTR CALLBACK FBEventsProc( HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam )
+INT_PTR CALLBACK FBEventsProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
FacebookProto *proto = reinterpret_cast<FacebookProto*>(GetWindowLongPtr(hwnd,GWLP_USERDATA));
@@ -411,16 +411,16 @@ INT_PTR CALLBACK FBEventsProc( HWND hwnd, UINT message, WPARAM wparam, LPARAM lp } return TRUE;
case WM_COMMAND: {
- switch ( LOWORD( wparam ))
+ switch (LOWORD(wparam))
{
case IDC_PREVIEW:
{
TCHAR protoName[255];
- lstrcpy( protoName, proto->m_tszUserName );
- proto->NotifyEvent( protoName, TranslateT("Sample event"), NULL, FACEBOOK_EVENT_CLIENT );
- proto->NotifyEvent( protoName, TranslateT("Sample request"), NULL, FACEBOOK_EVENT_OTHER );
- proto->NotifyEvent( protoName, TranslateT("Sample newsfeed"), NULL, FACEBOOK_EVENT_NEWSFEED );
- proto->NotifyEvent( protoName, TranslateT("Sample notification"), NULL, FACEBOOK_EVENT_NOTIFICATION );
+ lstrcpy(protoName, proto->m_tszUserName);
+ proto->NotifyEvent(protoName, TranslateT("Sample event"), NULL, FACEBOOK_EVENT_CLIENT);
+ proto->NotifyEvent(protoName, TranslateT("Sample request"), NULL, FACEBOOK_EVENT_OTHER);
+ proto->NotifyEvent(protoName, TranslateT("Sample newsfeed"), NULL, FACEBOOK_EVENT_NEWSFEED);
+ proto->NotifyEvent(protoName, TranslateT("Sample notification"), NULL, FACEBOOK_EVENT_NOTIFICATION);
} break;
case IDC_COLTEXT:
@@ -444,7 +444,7 @@ INT_PTR CALLBACK FBEventsProc( HWND hwnd, UINT message, WPARAM wparam, LPARAM lp case WM_NOTIFY:
{
- if ( reinterpret_cast<NMHDR*>(lparam)->code == PSN_APPLY )
+ if (reinterpret_cast<NMHDR*>(lparam)->code == PSN_APPLY)
{
db_set_b(NULL, proto->m_szModuleName, FACEBOOK_KEY_FEED_TYPE, SendDlgItemMessage(hwnd, IDC_FEED_TYPE, CB_GETCURSEL, 0, 0));
diff --git a/protocols/FacebookRM/src/dialogs.h b/protocols/FacebookRM/src/dialogs.h index e02c30cf98..facc969acd 100644 --- a/protocols/FacebookRM/src/dialogs.h +++ b/protocols/FacebookRM/src/dialogs.h @@ -22,8 +22,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #pragma once
-INT_PTR CALLBACK FBAccountProc( HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam );
-INT_PTR CALLBACK FBMindProc( HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam );
-INT_PTR CALLBACK FBOptionsProc( HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam );
-INT_PTR CALLBACK FBOptionsAdvancedProc( HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam );
-INT_PTR CALLBACK FBEventsProc( HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam );
+INT_PTR CALLBACK FBAccountProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
+INT_PTR CALLBACK FBMindProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
+INT_PTR CALLBACK FBOptionsProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
+INT_PTR CALLBACK FBOptionsAdvancedProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
+INT_PTR CALLBACK FBEventsProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
diff --git a/protocols/FacebookRM/src/entities.h b/protocols/FacebookRM/src/entities.h index 32404ca723..0f9058c42d 100644 --- a/protocols/FacebookRM/src/entities.h +++ b/protocols/FacebookRM/src/entities.h @@ -36,7 +36,7 @@ struct facebook_user bool deleted;
- facebook_user( )
+ facebook_user()
{
this->handle = NULL;
this->user_id = this->real_name = this->image_url = "";
@@ -45,7 +45,7 @@ struct facebook_user this->deleted = false;
}
- facebook_user( facebook_user* fu )
+ facebook_user(facebook_user* fu)
{
this->handle = fu->handle;
this->image_url = fu->image_url;
@@ -64,13 +64,13 @@ struct facebook_message std::string sender_name;
DWORD time;
- facebook_message( )
+ facebook_message()
{
this->user_id = this->message_text = this->sender_name = "";
this->time = 0;
}
- facebook_message( const facebook_message& msg )
+ facebook_message(const facebook_message& msg)
{
this->user_id = msg.user_id;
this->message_text = msg.message_text;
@@ -85,7 +85,7 @@ struct facebook_notification std::string text;
std::string link;
- facebook_notification( )
+ facebook_notification()
{
this->user_id = this->text = this->link = "";
}
@@ -98,7 +98,7 @@ struct facebook_newsfeed std::string text;
std::string link;
- facebook_newsfeed( )
+ facebook_newsfeed()
{
this->user_id = this->title = this->text = this->link = "";
}
diff --git a/protocols/FacebookRM/src/events.cpp b/protocols/FacebookRM/src/events.cpp index ee99787029..fa116bf1e6 100644 --- a/protocols/FacebookRM/src/events.cpp +++ b/protocols/FacebookRM/src/events.cpp @@ -53,7 +53,7 @@ LRESULT CALLBACK PopupDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa if (data != NULL)
{
std::string url = mir_t2a_cp(data,CP_UTF8);
- if ( url.substr(0,4) != "http" )
+ if (url.substr(0,4) != "http")
url = FACEBOOK_URL_HOMEPAGE + url; // make absolute url
CallService(MS_UTILS_OPENURL, (WPARAM) 1, (LPARAM) url.c_str());
@@ -86,61 +86,61 @@ void FacebookProto::NotifyEvent(TCHAR* title, TCHAR* info, HANDLE contact, DWORD {
int ret; int timeout; COLORREF colorBack = 0; COLORREF colorText = 0;
- switch ( flags )
+ switch (flags)
{
case FACEBOOK_EVENT_CLIENT:
- if ( !getByte( FACEBOOK_KEY_EVENT_CLIENT_ENABLE, DEFAULT_EVENT_CLIENT_ENABLE ))
+ if (!getByte(FACEBOOK_KEY_EVENT_CLIENT_ENABLE, DEFAULT_EVENT_CLIENT_ENABLE))
goto exit;
- if ( !getByte( FACEBOOK_KEY_EVENT_CLIENT_DEFAULT, 0 ))
+ if (!getByte(FACEBOOK_KEY_EVENT_CLIENT_DEFAULT, 0))
{
- colorBack = getDword( FACEBOOK_KEY_EVENT_CLIENT_COLBACK, DEFAULT_EVENT_COLBACK );
- colorText = getDword( FACEBOOK_KEY_EVENT_CLIENT_COLTEXT, DEFAULT_EVENT_COLTEXT );
+ colorBack = getDword(FACEBOOK_KEY_EVENT_CLIENT_COLBACK, DEFAULT_EVENT_COLBACK);
+ colorText = getDword(FACEBOOK_KEY_EVENT_CLIENT_COLTEXT, DEFAULT_EVENT_COLTEXT);
}
- timeout = getDword( FACEBOOK_KEY_EVENT_CLIENT_TIMEOUT, 0 );
+ timeout = getDword(FACEBOOK_KEY_EVENT_CLIENT_TIMEOUT, 0);
flags |= NIIF_WARNING;
break;
case FACEBOOK_EVENT_NEWSFEED:
- if ( !getByte( FACEBOOK_KEY_EVENT_FEEDS_ENABLE, DEFAULT_EVENT_FEEDS_ENABLE ))
+ if (!getByte(FACEBOOK_KEY_EVENT_FEEDS_ENABLE, DEFAULT_EVENT_FEEDS_ENABLE))
goto exit;
- if ( !getByte( FACEBOOK_KEY_EVENT_FEEDS_DEFAULT, 0 ))
+ if (!getByte(FACEBOOK_KEY_EVENT_FEEDS_DEFAULT, 0))
{
- colorBack = getDword( FACEBOOK_KEY_EVENT_FEEDS_COLBACK, DEFAULT_EVENT_COLBACK );
- colorText = getDword( FACEBOOK_KEY_EVENT_FEEDS_COLTEXT, DEFAULT_EVENT_COLTEXT );
+ colorBack = getDword(FACEBOOK_KEY_EVENT_FEEDS_COLBACK, DEFAULT_EVENT_COLBACK);
+ colorText = getDword(FACEBOOK_KEY_EVENT_FEEDS_COLTEXT, DEFAULT_EVENT_COLTEXT);
}
- timeout = getDword( FACEBOOK_KEY_EVENT_FEEDS_TIMEOUT, 0 );
- SkinPlaySound( "NewsFeed" );
+ timeout = getDword(FACEBOOK_KEY_EVENT_FEEDS_TIMEOUT, 0);
+ SkinPlaySound("NewsFeed");
flags |= NIIF_INFO;
break;
case FACEBOOK_EVENT_NOTIFICATION:
- if ( !getByte( FACEBOOK_KEY_EVENT_NOTIFICATIONS_ENABLE, DEFAULT_EVENT_NOTIFICATIONS_ENABLE ))
+ if (!getByte(FACEBOOK_KEY_EVENT_NOTIFICATIONS_ENABLE, DEFAULT_EVENT_NOTIFICATIONS_ENABLE))
goto exit;
- if ( !getByte( FACEBOOK_KEY_EVENT_NOTIFICATIONS_DEFAULT, 0 ))
+ if (!getByte(FACEBOOK_KEY_EVENT_NOTIFICATIONS_DEFAULT, 0))
{
- colorBack = getDword( FACEBOOK_KEY_EVENT_NOTIFICATIONS_COLBACK, DEFAULT_EVENT_COLBACK );
- colorText = getDword( FACEBOOK_KEY_EVENT_NOTIFICATIONS_COLTEXT, DEFAULT_EVENT_COLTEXT );
+ colorBack = getDword(FACEBOOK_KEY_EVENT_NOTIFICATIONS_COLBACK, DEFAULT_EVENT_COLBACK);
+ colorText = getDword(FACEBOOK_KEY_EVENT_NOTIFICATIONS_COLTEXT, DEFAULT_EVENT_COLTEXT);
}
- timeout = getDword( FACEBOOK_KEY_EVENT_NOTIFICATIONS_TIMEOUT, 0 );
- SkinPlaySound( "Notification" );
+ timeout = getDword(FACEBOOK_KEY_EVENT_NOTIFICATIONS_TIMEOUT, 0);
+ SkinPlaySound("Notification");
flags |= NIIF_INFO;
break;
case FACEBOOK_EVENT_OTHER:
- if ( !getByte( FACEBOOK_KEY_EVENT_OTHER_ENABLE, DEFAULT_EVENT_OTHER_ENABLE ))
+ if (!getByte(FACEBOOK_KEY_EVENT_OTHER_ENABLE, DEFAULT_EVENT_OTHER_ENABLE))
goto exit;
- if ( !getByte( FACEBOOK_KEY_EVENT_OTHER_DEFAULT, 0 ))
+ if (!getByte(FACEBOOK_KEY_EVENT_OTHER_DEFAULT, 0))
{
- colorBack = getDword( FACEBOOK_KEY_EVENT_OTHER_COLBACK, DEFAULT_EVENT_COLBACK );
- colorText = getDword( FACEBOOK_KEY_EVENT_OTHER_COLTEXT, DEFAULT_EVENT_COLTEXT );
+ colorBack = getDword(FACEBOOK_KEY_EVENT_OTHER_COLBACK, DEFAULT_EVENT_COLBACK);
+ colorText = getDword(FACEBOOK_KEY_EVENT_OTHER_COLTEXT, DEFAULT_EVENT_COLTEXT);
}
- timeout = getDword( FACEBOOK_KEY_EVENT_OTHER_TIMEOUT, 0 );
- SkinPlaySound( "OtherEvent" );
+ timeout = getDword(FACEBOOK_KEY_EVENT_OTHER_TIMEOUT, 0);
+ SkinPlaySound("OtherEvent");
flags |= NIIF_INFO;
break;
}
- if ( !getByte(FACEBOOK_KEY_SYSTRAY_NOTIFY,DEFAULT_SYSTRAY_NOTIFY))
+ if (!getByte(FACEBOOK_KEY_SYSTRAY_NOTIFY,DEFAULT_SYSTRAY_NOTIFY))
{
if (ServiceExists(MS_POPUP_ADDPOPUP))
{
@@ -164,10 +164,10 @@ void FacebookProto::NotifyEvent(TCHAR* title, TCHAR* info, HANDLE contact, DWORD {
MIRANDASYSTRAYNOTIFY err;
int niif_flags = flags;
- REMOVE_FLAG( niif_flags, FACEBOOK_EVENT_CLIENT |
+ REMOVE_FLAG(niif_flags, FACEBOOK_EVENT_CLIENT |
FACEBOOK_EVENT_NEWSFEED |
FACEBOOK_EVENT_NOTIFICATION |
- FACEBOOK_EVENT_OTHER );
+ FACEBOOK_EVENT_OTHER);
err.szProto = m_szModuleName;
err.cbSize = sizeof(err);
err.dwInfoFlags = NIIF_INTERN_TCHAR | niif_flags;
diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp index 89e2359dfa..5ca3496c43 100644 --- a/protocols/FacebookRM/src/json.cpp +++ b/protocols/FacebookRM/src/json.cpp @@ -25,52 +25,52 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "JSON_CAJUN/writer.h"
#include "JSON_CAJUN/elements.h"
-int facebook_json_parser::parse_buddy_list( void* data, List::List< facebook_user >* buddy_list )
+int facebook_json_parser::parse_buddy_list(void* data, List::List< facebook_user >* buddy_list)
{
using namespace json;
try
{
facebook_user* current = NULL;
- std::string buddyData = static_cast< std::string* >( data )->substr( 9 );
- std::istringstream sDocument( buddyData );
+ std::string buddyData = static_cast< std::string* >(data)->substr(9);
+ std::istringstream sDocument(buddyData);
Object objDocument;
Reader::Read(objDocument, sDocument);
const Object& objRoot = objDocument;
/* const Array& wasAvailableIDs = objRoot["payload"]["buddy_list"]["wasAvailableIDs"];
- for ( Array::const_iterator itWasAvailable( wasAvailableIDs.Begin());
+ for (Array::const_iterator itWasAvailable(wasAvailableIDs.Begin());
itWasAvailable != wasAvailableIDs.End(); ++itWasAvailable)
{
const Number& member = *itWasAvailable;
char was_id[32];
- lltoa( member.Value(), was_id, 10 );
+ lltoa(member.Value(), was_id, 10);
- current = buddy_list->find( std::string( was_id ));
- if ( current != NULL )
+ current = buddy_list->find(std::string(was_id));
+ if (current != NULL)
current->status_id = ID_STATUS_OFFLINE;
}*/ // Facebook removed support for "wasAvailableIDs"
// Set all contacts in map to offline
- for ( List::Item< facebook_user >* i = buddy_list->begin( ); i != NULL; i = i->next ) {
+ for (List::Item< facebook_user >* i = buddy_list->begin(); i != NULL; i = i->next) {
i->data->status_id = ID_STATUS_OFFLINE;
}
const Array& mobileFriends = objRoot["payload"]["buddy_list"]["mobile_friends"];
// Find mobile friends
- for ( Array::const_iterator buddy( mobileFriends.Begin()); buddy != mobileFriends.End(); ++buddy) {
+ for (Array::const_iterator buddy(mobileFriends.Begin()); buddy != mobileFriends.End(); ++buddy) {
const Number& member = *buddy;
char was_id[32];
- lltoa( member.Value(), was_id, 10 );
+ lltoa(member.Value(), was_id, 10);
std::string id = was_id;
if (!id.empty()) {
- current = buddy_list->find( id );
+ current = buddy_list->find(id);
- if ( current == NULL) {
- buddy_list->insert( std::make_pair( id, new facebook_user( )) );
- current = buddy_list->find( id );
+ if (current == NULL) {
+ buddy_list->insert(std::make_pair(id, new facebook_user()));
+ current = buddy_list->find(id);
current->user_id = id;
}
@@ -87,12 +87,12 @@ int facebook_json_parser::parse_buddy_list( void* data, List::List< facebook_use const Object& objMember = member.element;
const Boolean idle = objMember["i"]; // In new version of Facebook "i" means "offline"
- current = buddy_list->find( member.name );
- if ( current == NULL) {
+ current = buddy_list->find(member.name);
+ if (current == NULL) {
if (idle) continue; // Just little optimalization
- buddy_list->insert( std::make_pair( member.name, new facebook_user( )) );
- current = buddy_list->find( member.name );
+ buddy_list->insert(std::make_pair(member.name, new facebook_user()));
+ current = buddy_list->find(member.name);
current->user_id = current->real_name = member.name;
}
@@ -106,8 +106,8 @@ int facebook_json_parser::parse_buddy_list( void* data, List::List< facebook_use {
const Object::Member& member = *itUserInfo;
- current = buddy_list->find( member.name );
- if ( current == NULL )
+ current = buddy_list->find(member.name);
+ if (current == NULL)
continue;
const Object& objMember = member.element;
@@ -115,43 +115,43 @@ int facebook_json_parser::parse_buddy_list( void* data, List::List< facebook_use const String& imageUrl = objMember["thumbSrc"];
current->real_name = utils::text::slashu_to_utf8(
- utils::text::special_expressions_decode( realName.Value( )) );
+ utils::text::special_expressions_decode(realName.Value()));
current->image_url = utils::text::slashu_to_utf8(
- utils::text::special_expressions_decode( imageUrl.Value( )) );
+ utils::text::special_expressions_decode(imageUrl.Value()));
}
}
catch (Reader::ParseException& e)
{
- proto->Log( "!!!!! Caught json::ParseException: %s", e.what());
- proto->Log( " Line/offset: %d/%d", e.m_locTokenBegin.m_nLine + 1, e.m_locTokenBegin.m_nLineOffset + 1 );
+ proto->Log("!!!!! Caught json::ParseException: %s", e.what());
+ proto->Log(" Line/offset: %d/%d", e.m_locTokenBegin.m_nLine + 1, e.m_locTokenBegin.m_nLineOffset + 1);
}
catch (const Exception& e)
{
- proto->Log( "!!!!! Caught json::Exception: %s", e.what());
+ proto->Log("!!!!! Caught json::Exception: %s", e.what());
}
catch (const std::exception& e)
{
- proto->Log( "!!!!! Caught std::exception: %s", e.what());
+ proto->Log("!!!!! Caught std::exception: %s", e.what());
}
return EXIT_SUCCESS;
}
-int facebook_json_parser::parse_friends( void* data, std::map< std::string, facebook_user* >* friends )
+int facebook_json_parser::parse_friends(void* data, std::map< std::string, facebook_user* >* friends)
{
using namespace json;
try
{
- std::string buddyData = static_cast< std::string* >( data )->substr( 9 );
- std::istringstream sDocument( buddyData );
+ std::string buddyData = static_cast< std::string* >(data)->substr(9);
+ std::istringstream sDocument(buddyData);
Object objDocument;
Reader::Read(objDocument, sDocument);
const Object& objRoot = objDocument;
const Object& payload = objRoot["payload"];
- for ( Object::const_iterator payload_item( payload.Begin()); payload_item != payload.End(); ++payload_item)
+ for (Object::const_iterator payload_item(payload.Begin()); payload_item != payload.End(); ++payload_item)
{
const Object::Member& member = *payload_item;
@@ -166,9 +166,9 @@ int facebook_json_parser::parse_friends( void* data, std::map< std::string, face fbu->user_id = member.name;
fbu->real_name = utils::text::slashu_to_utf8(
- utils::text::special_expressions_decode( realName.Value()) );
+ utils::text::special_expressions_decode(realName.Value()));
fbu->image_url = utils::text::slashu_to_utf8(
- utils::text::special_expressions_decode( imageUrl.Value()) );
+ utils::text::special_expressions_decode(imageUrl.Value()));
if (gender.Value() == 1) {
fbu->gender = 70; // female
@@ -176,42 +176,42 @@ int facebook_json_parser::parse_friends( void* data, std::map< std::string, face fbu->gender = 77; // male
}
- friends->insert( std::make_pair( member.name, fbu ));
+ friends->insert(std::make_pair(member.name, fbu));
}
}
catch (Reader::ParseException& e)
{
- proto->Log( "!!!!! Caught json::ParseException: %s", e.what());
- proto->Log( " Line/offset: %d/%d", e.m_locTokenBegin.m_nLine + 1, e.m_locTokenBegin.m_nLineOffset + 1 );
+ proto->Log("!!!!! Caught json::ParseException: %s", e.what());
+ proto->Log(" Line/offset: %d/%d", e.m_locTokenBegin.m_nLine + 1, e.m_locTokenBegin.m_nLineOffset + 1);
}
catch (const Exception& e)
{
- proto->Log( "!!!!! Caught json::Exception: %s", e.what());
+ proto->Log("!!!!! Caught json::Exception: %s", e.what());
}
catch (const std::exception& e)
{
- proto->Log( "!!!!! Caught std::exception: %s", e.what());
+ proto->Log("!!!!! Caught std::exception: %s", e.what());
}
return EXIT_SUCCESS;
}
-int facebook_json_parser::parse_notifications( void *data, std::vector< facebook_notification* > *notifications )
+int facebook_json_parser::parse_notifications(void *data, std::vector< facebook_notification* > *notifications)
{
using namespace json;
try
{
- std::string notificationsData = static_cast< std::string* >( data )->substr( 9 );
- std::istringstream sDocument( notificationsData );
+ std::string notificationsData = static_cast< std::string* >(data)->substr(9);
+ std::istringstream sDocument(notificationsData);
Object objDocument;
Reader::Read(objDocument, sDocument);
const Object& objRoot = objDocument;
const Object& payload = objRoot["payload"]["notifications"];
- for ( Object::const_iterator payload_item( payload.Begin()); payload_item != payload.End(); ++payload_item)
+ for (Object::const_iterator payload_item(payload.Begin()); payload_item != payload.End(); ++payload_item)
{
const Object::Member& member = *payload_item;
@@ -224,42 +224,42 @@ int facebook_json_parser::parse_notifications( void *data, std::vector< facebook continue;
std::string text = utils::text::slashu_to_utf8(
- utils::text::special_expressions_decode( content.Value()) );
+ utils::text::special_expressions_decode(content.Value()));
- facebook_notification* notification = new facebook_notification( );
+ facebook_notification* notification = new facebook_notification();
- notification->text = utils::text::remove_html( utils::text::source_get_value(&text, 1, "<abbr"));
+ notification->text = utils::text::remove_html(utils::text::source_get_value(&text, 1, "<abbr"));
notification->link = utils::text::source_get_value(&text, 3, "<a ", "href=\"", "\"");
- notifications->push_back( notification );
+ notifications->push_back(notification);
}
}
catch (Reader::ParseException& e)
{
- proto->Log( "!!!!! Caught json::ParseException: %s", e.what());
- proto->Log( " Line/offset: %d/%d", e.m_locTokenBegin.m_nLine + 1, e.m_locTokenBegin.m_nLineOffset + 1 );
+ proto->Log("!!!!! Caught json::ParseException: %s", e.what());
+ proto->Log(" Line/offset: %d/%d", e.m_locTokenBegin.m_nLine + 1, e.m_locTokenBegin.m_nLineOffset + 1);
}
catch (const Exception& e)
{
- proto->Log( "!!!!! Caught json::Exception: %s", e.what());
+ proto->Log("!!!!! Caught json::Exception: %s", e.what());
}
catch (const std::exception& e)
{
- proto->Log( "!!!!! Caught std::exception: %s", e.what());
+ proto->Log("!!!!! Caught std::exception: %s", e.what());
}
return EXIT_SUCCESS;
}
-int facebook_json_parser::parse_messages( void* data, std::vector< facebook_message* >* messages, std::vector< facebook_notification* >* notifications )
+int facebook_json_parser::parse_messages(void* data, std::vector< facebook_message* >* messages, std::vector< facebook_notification* >* notifications)
{
using namespace json;
try
{
- std::string messageData = static_cast< std::string* >( data )->substr( 9 );
- std::istringstream sDocument( messageData );
+ std::string messageData = static_cast< std::string* >(data)->substr(9);
+ std::istringstream sDocument(messageData);
Object objDocument;
Reader::Read(objDocument, sDocument);
@@ -274,11 +274,11 @@ int facebook_json_parser::parse_messages( void* data, std::vector< facebook_mess const String& type = objMember["type"];
- if ( type.Value( ) == "msg" || type.Value() == "offline_msg" ) // direct message
+ if (type.Value() == "msg" || type.Value() == "offline_msg") // direct message
{
const Number& from = objMember["from"];
char was_id[32];
- lltoa( from.Value(), was_id, 10 );
+ lltoa(from.Value(), was_id, 10);
const Object& messageContent = objMember["msg"];
const String& text = messageContent["text"];
@@ -295,20 +295,20 @@ int facebook_json_parser::parse_messages( void* data, std::vector< facebook_mess proto->Log(msg.c_str());
} else if (last_msg != text.Value()) {
last_msg = text.Value();
- facebook_message* message = new facebook_message( );
+ facebook_message* message = new facebook_message();
message->message_text = utils::text::special_expressions_decode(
- utils::text::slashu_to_utf8( text.Value( )) );
- message->time = utils::time::fix_timestamp( time_sent.Value());
+ utils::text::slashu_to_utf8(text.Value()));
+ message->time = utils::time::fix_timestamp(time_sent.Value());
message->user_id = was_id;
- messages->push_back( message );
+ messages->push_back(message);
} else {
std::string msg = "????? Got duplicit message?\n";
msg += utils::text::special_expressions_decode(utils::text::slashu_to_utf8(text.Value()));
proto->Log(msg.c_str());
}
}
- else if ( type.Value( ) == "messaging" ) // inbox message (multiuser or direct)
+ else if (type.Value() == "messaging") // inbox message (multiuser or direct)
{
const String& type = objMember["event"];
@@ -317,7 +317,7 @@ int facebook_json_parser::parse_messages( void* data, std::vector< facebook_mess const Number& from = messageContent["sender_fbid"];
char was_id[32];
- lltoa( from.Value(), was_id, 10 );
+ lltoa(from.Value(), was_id, 10);
// Ignore if message is from self user
@@ -338,21 +338,21 @@ int facebook_json_parser::parse_messages( void* data, std::vector< facebook_mess if (last_msg != text.Value()) {
last_msg = text.Value();
- facebook_message* message = new facebook_message( );
+ facebook_message* message = new facebook_message();
message->message_text = utils::text::special_expressions_decode(
- utils::text::slashu_to_utf8( text.Value( )) );
+ utils::text::slashu_to_utf8(text.Value()));
message->sender_name = utils::text::special_expressions_decode(
- utils::text::slashu_to_utf8( sender_name.Value( )) );
+ utils::text::slashu_to_utf8(sender_name.Value()));
- message->time = utils::time::fix_timestamp( time_sent.Value());
+ message->time = utils::time::fix_timestamp(time_sent.Value());
message->user_id = was_id; // TODO: Check if we have contact with this ID in friendlist and then do something different?
if (row.find("uiSplitPic",0) != std::string::npos) {
// This is multiuser message
std::string authors = utils::text::special_expressions_decode(
- utils::text::slashu_to_utf8( row ));
+ utils::text::slashu_to_utf8(row));
authors = utils::text::source_get_value(&authors, 2, "<strong class=\"authors\">", "<");
const String& to_id = messageContent["tid"];
@@ -378,7 +378,7 @@ int facebook_json_parser::parse_messages( void* data, std::vector< facebook_mess mir_free(szText);
} else {
- messages->push_back( message );
+ messages->push_back(message);
}
} else {
std::string msg = "????? Got duplicit inbox message?\n";
@@ -387,7 +387,7 @@ int facebook_json_parser::parse_messages( void* data, std::vector< facebook_mess }
}
}
- else if ( type.Value( ) == "thread_msg" ) // multiuser message
+ else if (type.Value() == "thread_msg") // multiuser message
{
const String& from_name = objMember["from_name"];
const String& to_name = objMember["to_name"]["__html"];
@@ -395,7 +395,7 @@ int facebook_json_parser::parse_messages( void* data, std::vector< facebook_mess const Number& from = objMember["from"];
char was_id[32];
- lltoa( from.Value(), was_id, 10 );
+ lltoa(from.Value(), was_id, 10);
// Ignore if message is from self user
if (was_id == proto->facy.self_.user_id)
@@ -409,15 +409,15 @@ int facebook_json_parser::parse_messages( void* data, std::vector< facebook_mess std::string popup_text = utils::text::special_expressions_decode(
- utils::text::slashu_to_utf8( from_name.Value( )) );
+ utils::text::slashu_to_utf8(from_name.Value()));
popup_text += ": ";
popup_text += utils::text::special_expressions_decode(
- utils::text::slashu_to_utf8( text.Value( )) );
+ utils::text::slashu_to_utf8(text.Value()));
std::string title = Translate("Multichat");
title += ": ";
title += utils::text::special_expressions_decode(
- utils::text::slashu_to_utf8( to_name.Value( )) );
+ utils::text::slashu_to_utf8(to_name.Value()));
std::string url = "/?action=read&sk=inbox&page&query&tid=";
url += to_id.Value();
@@ -431,7 +431,7 @@ int facebook_json_parser::parse_messages( void* data, std::vector< facebook_mess mir_free(szTitle);
mir_free(szText);
}
- else if ( type.Value() == "notification_json" ) // event notification
+ else if (type.Value() == "notification_json") // event notification
{
if (!db_get_b(NULL, proto->m_szModuleName, FACEBOOK_KEY_EVENT_NOTIFICATIONS_ENABLE, DEFAULT_EVENT_NOTIFICATIONS_ENABLE))
continue;
@@ -459,18 +459,18 @@ int facebook_json_parser::parse_messages( void* data, std::vector< facebook_mess }
}
}
- else if ( type.Value( ) == "typ" ) // chat typing notification
+ else if (type.Value() == "typ") // chat typing notification
{
const Number& from = objMember["from"];
char user_id[32];
- lltoa( from.Value(), user_id, 10 );
+ lltoa(from.Value(), user_id, 10);
facebook_user fbu;
fbu.user_id = user_id;
HANDLE hContact = proto->AddToContactList(&fbu, FACEBOOK_CONTACT_FRIEND);
- if ( db_get_w(hContact,proto->m_szModuleName,"Status", 0) == ID_STATUS_OFFLINE )
+ if (db_get_w(hContact,proto->m_szModuleName,"Status", 0) == ID_STATUS_OFFLINE)
db_set_w(hContact,proto->m_szModuleName,"Status",ID_STATUS_ONLINE);
const Number& state = objMember["st"];
@@ -479,16 +479,16 @@ int facebook_json_parser::parse_messages( void* data, std::vector< facebook_mess else
CallService(MS_PROTO_CONTACTISTYPING, (WPARAM)hContact, (LPARAM)PROTOTYPE_CONTACTTYPING_OFF);
}
- else if ( type.Value( ) == "privacy_changed")
+ else if (type.Value() == "privacy_changed")
{
const String& event_type = objMember["event"];
const Object& event_data = objMember["data"];
- if ( event_type.Value( ) == "visibility_update" )
+ if (event_type.Value() == "visibility_update")
{ // change of chat status
const Boolean visibility = event_data["visibility"];
proto->Log(" Requested chat switch to %s", visibility ? "Online" : "Offline");
- proto->SetStatus( visibility ? ID_STATUS_ONLINE : ID_STATUS_INVISIBLE );
+ proto->SetStatus(visibility ? ID_STATUS_ONLINE : ID_STATUS_INVISIBLE);
}
}
else
@@ -497,12 +497,12 @@ int facebook_json_parser::parse_messages( void* data, std::vector< facebook_mess }
catch (Reader::ParseException& e)
{
- proto->Log( "!!!!! Caught json::ParseException: %s", e.what());
- proto->Log( " Line/offset: %d/%d", e.m_locTokenBegin.m_nLine + 1, e.m_locTokenBegin.m_nLineOffset + 1 );
+ proto->Log("!!!!! Caught json::ParseException: %s", e.what());
+ proto->Log(" Line/offset: %d/%d", e.m_locTokenBegin.m_nLine + 1, e.m_locTokenBegin.m_nLineOffset + 1);
}
catch (const Exception& e)
{
- proto->Log ( "!!!!! Caught json::Exception: %s", e.what());
+ proto->Log ("!!!!! Caught json::Exception: %s", e.what());
}
return EXIT_SUCCESS;
diff --git a/protocols/FacebookRM/src/json.h b/protocols/FacebookRM/src/json.h index 00029da099..de16fe76db 100644 --- a/protocols/FacebookRM/src/json.h +++ b/protocols/FacebookRM/src/json.h @@ -30,12 +30,12 @@ class facebook_json_parser {
public:
FacebookProto* proto;
- int parse_buddy_list( void*, List::List< facebook_user >* );
- int parse_friends( void*, std::map< std::string, facebook_user* >* );
- int parse_notifications( void*, std::vector< facebook_notification* >* );
- int parse_messages( void*, std::vector< facebook_message* >*, std::vector< facebook_notification* >* );
+ int parse_buddy_list(void*, List::List< facebook_user >*);
+ int parse_friends(void*, std::map< std::string, facebook_user* >*);
+ int parse_notifications(void*, std::vector< facebook_notification* >*);
+ int parse_messages(void*, std::vector< facebook_message* >*, std::vector< facebook_notification* >*);
- facebook_json_parser( FacebookProto* proto )
+ facebook_json_parser(FacebookProto* proto)
{
this->proto = proto;
}
diff --git a/protocols/FacebookRM/src/main.cpp b/protocols/FacebookRM/src/main.cpp index 709d91cbd6..564bc195ae 100644 --- a/protocols/FacebookRM/src/main.cpp +++ b/protocols/FacebookRM/src/main.cpp @@ -75,7 +75,7 @@ extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_PROTOCO /////////////////////////////////////////////////////////////////////////////////////////
// Load
-static PROTO_INTERFACE* protoInit(const char *proto_name,const TCHAR *username )
+static PROTO_INTERFACE* protoInit(const char *proto_name,const TCHAR *username)
{
FacebookProto *proto = new FacebookProto(proto_name,username);
g_Instances.insert(proto);
@@ -84,7 +84,7 @@ static PROTO_INTERFACE* protoInit(const char *proto_name,const TCHAR *username ) static int protoUninit(PROTO_INTERFACE* proto)
{
- g_Instances.remove(( FacebookProto* )proto);
+ g_Instances.remove((FacebookProto*)proto);
return EXIT_SUCCESS;
}
@@ -109,22 +109,22 @@ extern "C" int __declspec(dllexport) Load(void) // Init native User-Agent
{
std::stringstream agent;
-// DWORD mir_ver = ( DWORD )CallService( MS_SYSTEM_GETVERSION, NULL, NULL );
+// DWORD mir_ver = (DWORD)CallService(MS_SYSTEM_GETVERSION, NULL, NULL);
agent << "MirandaNG/";
- agent << (( g_mirandaVersion >> 24) & 0xFF);
+ agent << ((g_mirandaVersion >> 24) & 0xFF);
agent << ".";
- agent << (( g_mirandaVersion >> 16) & 0xFF);
+ agent << ((g_mirandaVersion >> 16) & 0xFF);
agent << ".";
- agent << (( g_mirandaVersion >> 8) & 0xFF);
+ agent << ((g_mirandaVersion >> 8) & 0xFF);
agent << ".";
- agent << (( g_mirandaVersion ) & 0xFF);
+ agent << ((g_mirandaVersion ) & 0xFF);
#ifdef _WIN64
agent << " Facebook Protocol RM x64/";
#else
agent << " Facebook Protocol RM/";
#endif
agent << __VERSION_STRING;
- g_strUserAgent = agent.str( );
+ g_strUserAgent = agent.str();
}
return 0;
diff --git a/protocols/FacebookRM/src/messages.cpp b/protocols/FacebookRM/src/messages.cpp index 52faf83b0d..369d392733 100644 --- a/protocols/FacebookRM/src/messages.cpp +++ b/protocols/FacebookRM/src/messages.cpp @@ -26,9 +26,9 @@ int FacebookProto::RecvMsg(HANDLE hContact, PROTORECVEVENT *pre) {
DBVARIANT dbv;
- if ( !db_get_s(hContact,m_szModuleName,FACEBOOK_KEY_ID,&dbv))
+ if (!db_get_s(hContact,m_szModuleName,FACEBOOK_KEY_ID,&dbv))
{
- ForkThread( &FacebookProto::MessagingWorker, this, new send_messaging(dbv.pszVal, FACEBOOK_RECV_MESSAGE ));
+ ForkThread(&FacebookProto::MessagingWorker, this, new send_messaging(dbv.pszVal, FACEBOOK_RECV_MESSAGE));
db_free(&dbv);
}
@@ -42,17 +42,17 @@ void FacebookProto::SendMsgWorker(void *p) if(p == NULL)
return;
-// ScopedLock s( facy.send_message_lock_, 500 );
+// ScopedLock s(facy.send_message_lock_, 500);
send_direct *data = static_cast<send_direct*>(p);
DBVARIANT dbv;
- if ( !isOnline( ))
+ if (!isOnline())
{
ProtoBroadcastAck(m_szModuleName, data->hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, data->msgid, (LPARAM)Translate("You cannot send messages when you are offline."));
}
- else if ( !db_get_s(data->hContact,m_szModuleName,FACEBOOK_KEY_ID,&dbv))
+ else if (!db_get_s(data->hContact,m_szModuleName,FACEBOOK_KEY_ID,&dbv))
{
//parseSmileys(data->msg, data->hContact);
@@ -65,7 +65,7 @@ void FacebookProto::SendMsgWorker(void *p) }
if (result) {
ProtoBroadcastAck(m_szModuleName,data->hContact,ACKTYPE_MESSAGE,ACKRESULT_SUCCESS, data->msgid,0);
- MessagingWorker( new send_messaging(dbv.pszVal, FACEBOOK_SEND_MESSAGE ));
+ MessagingWorker(new send_messaging(dbv.pszVal, FACEBOOK_SEND_MESSAGE));
} else {
char *err = mir_utf8decodeA(error_text.c_str());
ProtoBroadcastAck(m_szModuleName,data->hContact,ACKTYPE_MESSAGE,ACKRESULT_FAILED, data->msgid,(LPARAM)err);
@@ -97,7 +97,7 @@ void FacebookProto::SendChatMsgWorker(void *p) post_data += "&__user=" + facy.self_.user_id;
post_data += "&phstamp=0";
- http::response resp = facy.flap( FACEBOOK_REQUEST_THREAD_INFO, &post_data );
+ http::response resp = facy.flap(FACEBOOK_REQUEST_THREAD_INFO, &post_data);
facy.validate_response(&resp);
tid = utils::text::source_get_value(&resp.data, 2, "\"thread_id\":\"", "\"");
@@ -115,11 +115,11 @@ void FacebookProto::SendChatMsgWorker(void *p) int FacebookProto::SendMsg(HANDLE hContact, int flags, const char *msg)
{
// TODO: msg comes as Unicode (retyped wchar_t*), why should we convert it as ANSI to UTF-8? o_O
- if ( flags & PREF_UNICODE )
+ if (flags & PREF_UNICODE)
msg = mir_utf8encode(msg);
facy.msgid_ = (facy.msgid_ % 1024)+1;
- ForkThread( &FacebookProto::SendMsgWorker, this, new send_direct(hContact, msg, (HANDLE)facy.msgid_));
+ ForkThread(&FacebookProto::SendMsgWorker, this, new send_direct(hContact, msg, (HANDLE)facy.msgid_));
return facy.msgid_;
}
@@ -139,22 +139,22 @@ void FacebookProto::SendTypingWorker(void *p) send_typing *typing = static_cast<send_typing*>(p);
// Dont send typing notifications to contacts, that are offline or not friends
- if ( db_get_w(typing->hContact,m_szModuleName,"Status", 0) == ID_STATUS_OFFLINE
+ if (db_get_w(typing->hContact,m_szModuleName,"Status", 0) == ID_STATUS_OFFLINE
|| db_get_b(typing->hContact, m_szModuleName, FACEBOOK_KEY_CONTACT_TYPE, 0) != FACEBOOK_CONTACT_FRIEND)
return;
// TODO RM: maybe better send typing optimalization
facy.is_typing_ = (typing->status == PROTOTYPE_SELFTYPING_ON);
- SleepEx( 2000, true );
+ SleepEx(2000, true);
- if ( !facy.is_typing_ == (typing->status == PROTOTYPE_SELFTYPING_ON))
+ if (!facy.is_typing_ == (typing->status == PROTOTYPE_SELFTYPING_ON))
{
delete typing;
return;
}
DBVARIANT dbv;
- if ( !db_get_s(typing->hContact,m_szModuleName,FACEBOOK_KEY_ID,&dbv))
+ if (!db_get_s(typing->hContact,m_szModuleName,FACEBOOK_KEY_ID,&dbv))
{
std::string data = "&source=mercury-chat";
data += (typing->status == PROTOTYPE_SELFTYPING_ON ? "&typ=1" : "&typ=0"); // PROTOTYPE_SELFTYPING_OFF
@@ -162,7 +162,7 @@ void FacebookProto::SendTypingWorker(void *p) data += "&fb_dtsg=" + facy.dtsg_;
data += "&lsd=&phstamp=0&__user=" + facy.self_.user_id;
- http::response resp = facy.flap( FACEBOOK_REQUEST_TYPING_SEND, &data );
+ http::response resp = facy.flap(FACEBOOK_REQUEST_TYPING_SEND, &data);
db_free(&dbv);
}
@@ -178,7 +178,7 @@ void FacebookProto::MessagingWorker(void *p) send_messaging *data = static_cast<send_messaging*>(p);
if (data->type == FACEBOOK_RECV_MESSAGE)
- facy.chat_mark_read( data->user_id );
+ facy.chat_mark_read(data->user_id);
delete data;
}
diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp index ae0911e3f0..e0608e3555 100644 --- a/protocols/FacebookRM/src/process.cpp +++ b/protocols/FacebookRM/src/process.cpp @@ -22,29 +22,29 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "common.h"
-void FacebookProto::ProcessBuddyList( void* data )
+void FacebookProto::ProcessBuddyList(void* data)
{
- if ( data == NULL )
+ if (data == NULL)
return;
- ScopedLock s( facy.buddies_lock_ );
+ ScopedLock s(facy.buddies_lock_);
std::string* resp = (std::string*)data;
- if ( isOffline())
+ if (isOffline())
goto exit;
LOG("***** Starting processing buddy list");
CODE_BLOCK_TRY
- facebook_json_parser* p = new facebook_json_parser( this );
- p->parse_buddy_list( data, &facy.buddies );
+ facebook_json_parser* p = new facebook_json_parser(this);
+ p->parse_buddy_list(data, &facy.buddies);
delete p;
bool use_mobile_status = db_get_b(NULL,m_szModuleName,FACEBOOK_KEY_LOAD_MOBILE, DEFAULT_LOAD_MOBILE) != 0;
- for ( List::Item< facebook_user >* i = facy.buddies.begin( ); i != NULL; )
+ for (List::Item< facebook_user >* i = facy.buddies.begin(); i != NULL;)
{
facebook_user* fbu = i->data;
bool on_mobile = false;
@@ -87,9 +87,9 @@ void FacebookProto::ProcessBuddyList( void* data ) if (fbu->handle)
db_set_w(fbu->handle, m_szModuleName, "Status", ID_STATUS_OFFLINE);
- std::string to_delete( i->key );
+ std::string to_delete(i->key);
i = i->next;
- facy.buddies.erase( to_delete );
+ facy.buddies.erase(to_delete);
} else {
i = i->next;
@@ -102,8 +102,8 @@ void FacebookProto::ProcessBuddyList( void* data ) }
}
- if (db_get_w(fbu->handle,m_szModuleName,"Status", 0) != fbu->status_id ) {
- db_set_w(fbu->handle,m_szModuleName,"Status", fbu->status_id );
+ if (db_get_w(fbu->handle,m_szModuleName,"Status", 0) != fbu->status_id) {
+ db_set_w(fbu->handle,m_szModuleName,"Status", fbu->status_id);
}
if (db_get_b(fbu->handle, m_szModuleName, FACEBOOK_KEY_CONTACT_TYPE, 0) != FACEBOOK_CONTACT_FRIEND) {
@@ -112,7 +112,7 @@ void FacebookProto::ProcessBuddyList( void* data ) }
// Wasn't contact removed from "server-list" someday?
- if ( db_get_dw(fbu->handle, m_szModuleName, FACEBOOK_KEY_DELETED, 0)) {
+ if (db_get_dw(fbu->handle, m_szModuleName, FACEBOOK_KEY_DELETED, 0)) {
db_unset(fbu->handle, m_szModuleName, FACEBOOK_KEY_DELETED);
std::string url = FACEBOOK_URL_PROFILE + fbu->user_id;
@@ -120,8 +120,8 @@ void FacebookProto::ProcessBuddyList( void* data ) TCHAR* szTitle = mir_a2t_cp(fbu->real_name.c_str(), CP_UTF8);
TCHAR* szUrl = mir_a2t_cp(url.c_str(), CP_UTF8);
NotifyEvent(szTitle, TranslateT("Contact is back on server-list."), fbu->handle, FACEBOOK_EVENT_OTHER, szUrl);
- mir_free( szTitle );
- // mir_free( szUrl ); // url is free'd in popup procedure
+ mir_free(szTitle);
+ // mir_free(szUrl); // url is free'd in popup procedure
}
// Check avatar change
@@ -141,9 +141,9 @@ exit: delete resp;
}
-void FacebookProto::ProcessFriendList( void* data )
+void FacebookProto::ProcessFriendList(void* data)
{
- if ( data == NULL )
+ if (data == NULL)
return;
std::string* resp = (std::string*)data;
@@ -154,19 +154,19 @@ void FacebookProto::ProcessFriendList( void* data ) std::map<std::string, facebook_user*> friends;
- facebook_json_parser* p = new facebook_json_parser( this );
- p->parse_friends( data, &friends );
+ facebook_json_parser* p = new facebook_json_parser(this);
+ p->parse_friends(data, &friends);
delete p;
// Check and update old contacts
for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
- if ( db_get_b(hContact,m_szModuleName,"ChatRoom",0))
+ if (db_get_b(hContact,m_szModuleName,"ChatRoom",0))
continue;
DBVARIANT dbv;
facebook_user *fbu;
- if ( !db_get_s(hContact,m_szModuleName,FACEBOOK_KEY_ID,&dbv)) {
+ if (!db_get_s(hContact,m_szModuleName,FACEBOOK_KEY_ID,&dbv)) {
std::string id = dbv.pszVal;
db_free(&dbv);
@@ -182,16 +182,16 @@ void FacebookProto::ProcessFriendList( void* data ) // TODO RM: remove, because contacts cant change it, so its only for "first run"
// - but what with contacts, that was added after logon?
// Update gender
- if ( db_get_b(hContact, m_szModuleName, "Gender", 0) != fbu->gender )
+ if (db_get_b(hContact, m_szModuleName, "Gender", 0) != fbu->gender)
db_set_b(hContact, m_szModuleName, "Gender", fbu->gender);
// Update real name
- if ( !db_get_utf(hContact, m_szModuleName, FACEBOOK_KEY_NAME, &dbv))
+ if (!db_get_utf(hContact, m_szModuleName, FACEBOOK_KEY_NAME, &dbv))
{
- update_required = strcmp( dbv.pszVal, fbu->real_name.c_str()) != 0;
+ update_required = strcmp(dbv.pszVal, fbu->real_name.c_str()) != 0;
db_free(&dbv);
}
- if ( update_required )
+ if (update_required)
{
db_set_utf(hContact, m_szModuleName, FACEBOOK_KEY_NAME, fbu->real_name.c_str());
db_set_utf(hContact, m_szModuleName, FACEBOOK_KEY_NICK, fbu->real_name.c_str());
@@ -203,7 +203,7 @@ void FacebookProto::ProcessFriendList( void* data ) }
// Wasn't contact removed from "server-list" someday?
- if ( db_get_dw(hContact, m_szModuleName, FACEBOOK_KEY_DELETED, 0)) {
+ if (db_get_dw(hContact, m_szModuleName, FACEBOOK_KEY_DELETED, 0)) {
db_unset(hContact, m_szModuleName, FACEBOOK_KEY_DELETED);
std::string url = FACEBOOK_URL_PROFILE + fbu->user_id;
@@ -211,8 +211,8 @@ void FacebookProto::ProcessFriendList( void* data ) TCHAR* szTitle = mir_a2t_cp(fbu->real_name.c_str(), CP_UTF8);
TCHAR* szUrl = mir_a2t_cp(url.c_str(), CP_UTF8);
NotifyEvent(szTitle, TranslateT("Contact is back on server-list."), hContact, FACEBOOK_EVENT_OTHER, szUrl);
- mir_free( szTitle );
- // mir_free( szUrl ); // url is free'd in popup procedure
+ mir_free(szTitle);
+ // mir_free(szUrl); // url is free'd in popup procedure
}
// Check avatar change
@@ -232,7 +232,7 @@ void FacebookProto::ProcessFriendList( void* data ) db_set_b(hContact, m_szModuleName, FACEBOOK_KEY_CONTACT_TYPE, FACEBOOK_CONTACT_NONE);
std::string contactname = id;
- if ( !db_get_utf(hContact, m_szModuleName, FACEBOOK_KEY_NAME, &dbv)) {
+ if (!db_get_utf(hContact, m_szModuleName, FACEBOOK_KEY_NAME, &dbv)) {
contactname = dbv.pszVal;
db_free(&dbv);
}
@@ -242,25 +242,25 @@ void FacebookProto::ProcessFriendList( void* data ) TCHAR* szTitle = mir_a2t_cp(contactname.c_str(), CP_UTF8);
TCHAR* szUrl = mir_a2t_cp(url.c_str(), CP_UTF8);
NotifyEvent(szTitle, TranslateT("Contact is no longer on server-list."), hContact, FACEBOOK_EVENT_OTHER, szUrl);
- mir_free( szTitle );
- // mir_free( szUrl ); // url is free'd in popup procedure
+ mir_free(szTitle);
+ // mir_free(szUrl); // url is free'd in popup procedure
}
}
}
}
// Check remain contacts in map and add it to contact list
- for ( std::map< std::string, facebook_user* >::iterator iter = friends.begin(); iter != friends.end(); ++iter )
+ for (std::map< std::string, facebook_user* >::iterator iter = friends.begin(); iter != friends.end(); ++iter)
{
facebook_user *fbu = iter->second;
HANDLE hContact = AddToContactList(fbu, FACEBOOK_CONTACT_FRIEND, true); // This contact is surely new
- db_set_b(hContact, m_szModuleName, "Gender", fbu->gender );
+ db_set_b(hContact, m_szModuleName, "Gender", fbu->gender);
db_set_utf(hContact, m_szModuleName, FACEBOOK_KEY_NAME, fbu->real_name.c_str());
db_set_utf(hContact, m_szModuleName, FACEBOOK_KEY_NICK, fbu->real_name.c_str());
db_set_s(hContact, m_szModuleName, FACEBOOK_KEY_AV_URL, fbu->image_url.c_str());
-// db_set_w(hContact, m_szModuleName, "Status", ID_STATUS_OFFLINE );
+// db_set_w(hContact, m_szModuleName, "Status", ID_STATUS_OFFLINE);
}
LOG("***** Friend list processed");
@@ -274,9 +274,9 @@ void FacebookProto::ProcessFriendList( void* data ) delete resp;
}
-void FacebookProto::ProcessUnreadMessages( void* )
+void FacebookProto::ProcessUnreadMessages(void*)
{
- facy.handle_entry( "messages" );
+ facy.handle_entry("messages");
std::string get_data = "sk=inbox&query=is%3Aunread";
@@ -285,7 +285,7 @@ void FacebookProto::ProcessUnreadMessages( void* ) data += "&__user=" + facy.self_.user_id;
// Get unread inbox threads
- http::response resp = facy.flap( FACEBOOK_REQUEST_ASYNC, &data, &get_data );
+ http::response resp = facy.flap(FACEBOOK_REQUEST_ASYNC, &data, &get_data);
// sk=inbox, sk=other
@@ -293,7 +293,7 @@ void FacebookProto::ProcessUnreadMessages( void* ) facy.validate_response(&resp);
if (resp.code != HTTP_CODE_OK) {
- facy.handle_error( "messages" );
+ facy.handle_error("messages");
return;
}
@@ -301,18 +301,18 @@ void FacebookProto::ProcessUnreadMessages( void* ) std::string::size_type pos = 0;
- while ( ( pos = threadlist.find( "<li class=\\\"threadRow noDraft unread", pos )) != std::string::npos )
+ while ((pos = threadlist.find("<li class=\\\"threadRow noDraft unread", pos)) != std::string::npos)
{
- std::string::size_type pos2 = threadlist.find( "/li>", pos );
- std::string thread_content = threadlist.substr( pos, pos2 - pos );
+ std::string::size_type pos2 = threadlist.find("/li>", pos);
+ std::string thread_content = threadlist.substr(pos, pos2 - pos);
pos = pos2;
get_data = "sk=inbox&query=is%3Aunread&thread_query=is%3Aunread&action=read&tid=";
- get_data += utils::text::source_get_value( &thread_content, 2, "id=\\\"", "\\\"" );
+ get_data += utils::text::source_get_value(&thread_content, 2, "id=\\\"", "\\\"");
utils::text::replace_all(&get_data, "+", "%2B");
- resp = facy.flap( FACEBOOK_REQUEST_ASYNC, &data, &get_data );
+ resp = facy.flap(FACEBOOK_REQUEST_ASYNC, &data, &get_data);
// TODO: move this to new thread...
facy.validate_response(&resp);
@@ -324,7 +324,7 @@ void FacebookProto::ProcessUnreadMessages( void* ) std::string messageslist = utils::text::slashu_to_utf8(resp.data);
- std::string user_id = utils::text::source_get_value( &messageslist, 2, "single_thread_id\":", "," );
+ std::string user_id = utils::text::source_get_value(&messageslist, 2, "single_thread_id\":", ",");
if (user_id.empty()) {
LOG(" !! !! Thread id is empty - this is groupchat message."); // TODO: remove as this is not such 'error'
continue;
@@ -338,41 +338,41 @@ void FacebookProto::ProcessUnreadMessages( void* ) // TODO: maybe create new "receiveMsg" function and use it for offline and channel messages?
pos2 = 0;
- while ( ( pos2 = messageslist.find( "class=\\\"MessagingMessage ", pos2 )) != std::string::npos ) {
+ while ((pos2 = messageslist.find("class=\\\"MessagingMessage ", pos2)) != std::string::npos) {
pos2 += 8;
std::string strclass = messageslist.substr(pos2, messageslist.find("\\\"", pos2) - pos2);
if (strclass.find("MessagingMessageUnread") == std::string::npos)
continue; // ignoring old messages
- //std::string::size_type pos3 = messageslist.find( "/li>", pos2 ); // TODO: ne proti tomuhle li, protože i pÅ™Ãlohy majà li...
- std::string::size_type pos3 = messageslist.find( "class=\\\"MessagingMessage ", pos2 );
- std::string messagesgroup = messageslist.substr( pos2, pos3 - pos2 );
+ //std::string::size_type pos3 = messageslist.find("/li>", pos2); // TODO: ne proti tomuhle li, protože i pÅ™Ãlohy majà li...
+ std::string::size_type pos3 = messageslist.find("class=\\\"MessagingMessage ", pos2);
+ std::string messagesgroup = messageslist.substr(pos2, pos3 - pos2);
- DWORD timestamp = utils::conversion::to_timestamp(
- utils::text::source_get_value( &messagesgroup, 2, "data-utime=\\\"", "\\\"" ));
+ DWORD timestamp = utils::conversion::to_timestamp(
+ utils::text::source_get_value(&messagesgroup, 2, "data-utime=\\\"", "\\\""));
pos3 = 0;
- while ( ( pos3 = messagesgroup.find( "class=\\\"content noh", pos3 )) != std::string::npos )
+ while ((pos3 = messagesgroup.find("class=\\\"content noh", pos3)) != std::string::npos)
{
std::string message_attachments = "";
std::string::size_type pos4 = 0;
- if ((pos4 = messagesgroup.find( "class=\\\"attachments\\\"", pos4)) != std::string::npos) {
- std::string attachments = messagesgroup.substr( pos4, messagesgroup.find("<\\/ul", pos4) - pos4 );
+ if ((pos4 = messagesgroup.find("class=\\\"attachments\\\"", pos4)) != std::string::npos) {
+ std::string attachments = messagesgroup.substr(pos4, messagesgroup.find("<\\/ul", pos4) - pos4);
pos4 = 0;
- while ( ( pos4 = attachments.find("<li", pos4)) != std::string::npos ) {
- std::string attachment = attachments.substr( pos4, attachments.find("<\\/li>", pos4) - pos4 );
- std::string link = utils::text::source_get_value( &attachment, 4, "<a class=", "attachment", "href=\\\"", "\\\"" );
+ while ((pos4 = attachments.find("<li", pos4)) != std::string::npos) {
+ std::string attachment = attachments.substr(pos4, attachments.find("<\\/li>", pos4) - pos4);
+ std::string link = utils::text::source_get_value(&attachment, 4, "<a class=", "attachment", "href=\\\"", "\\\"");
link = utils::text::trim(
- utils::text::special_expressions_decode( link ));
+ utils::text::special_expressions_decode(link));
- // or first: std::string name = utils::text::source_get_value( &attachment, 4, "<a class=", "attachment", ">", "<\\/a>" );
+ // or first: std::string name = utils::text::source_get_value(&attachment, 4, "<a class=", "attachment", ">", "<\\/a>");
std::string name = utils::text::trim(
utils::text::special_expressions_decode(
- utils::text::remove_html( attachment )) );
+ utils::text::remove_html(attachment)));
if (link.find("/ajax/messaging/attachments/photo/dialog.php?uri=") != std::string::npos) {
link = link.substr(49);
@@ -387,12 +387,12 @@ void FacebookProto::ProcessUnreadMessages( void* ) }
- std::string message_text = messagesgroup.substr(pos3, messagesgroup.find( "<\\/div", pos3 ) + 6 - pos3);
+ std::string message_text = messagesgroup.substr(pos3, messagesgroup.find("<\\/div", pos3) + 6 - pos3);
LOG("Got unread message: \"%s\"", message_text.c_str());
- message_text = utils::text::source_get_value( &message_text, 2, "\\\">", "<\\/div" );
+ message_text = utils::text::source_get_value(&message_text, 2, "\\\">", "<\\/div");
message_text = utils::text::trim(
utils::text::special_expressions_decode(
- utils::text::remove_html( message_text )) );
+ utils::text::remove_html(message_text)));
parseSmileys(message_text, hContact);
@@ -419,14 +419,14 @@ void FacebookProto::ProcessUnreadMessages( void* ) }
-void FacebookProto::ProcessMessages( void* data )
+void FacebookProto::ProcessMessages(void* data)
{
- if ( data == NULL )
+ if (data == NULL)
return;
std::string* resp = (std::string*)data;
- if ( isOffline())
+ if (isOffline())
goto exit;
LOG("***** Starting processing messages");
@@ -436,15 +436,15 @@ void FacebookProto::ProcessMessages( void* data ) std::vector< facebook_message* > messages;
std::vector< facebook_notification* > notifications;
- facebook_json_parser* p = new facebook_json_parser( this );
- p->parse_messages( data, &messages, ¬ifications );
+ facebook_json_parser* p = new facebook_json_parser(this);
+ p->parse_messages(data, &messages, ¬ifications);
delete p;
bool local_timestamp = getByte(FACEBOOK_KEY_LOCAL_TIMESTAMP, 0) != 0;
- for(std::vector<facebook_message*>::size_type i=0; i<messages.size( ); i++)
+ for(std::vector<facebook_message*>::size_type i=0; i<messages.size(); i++)
{
- if ( messages[i]->user_id != facy.self_.user_id )
+ if (messages[i]->user_id != facy.self_.user_id)
{
LOG(" Got message: %s", messages[i]->message_text.c_str());
facebook_user fbu;
@@ -467,16 +467,16 @@ void FacebookProto::ProcessMessages( void* data ) }
messages.clear();
- for(std::vector<facebook_notification*>::size_type i=0; i<notifications.size( ); i++)
+ for(std::vector<facebook_notification*>::size_type i=0; i<notifications.size(); i++)
{
LOG(" Got notification: %s", notifications[i]->text.c_str());
TCHAR* szTitle = mir_a2t_cp(this->m_szModuleName, CP_UTF8);
TCHAR* szText = mir_a2t_cp(notifications[i]->text.c_str(), CP_UTF8);
TCHAR* szUrl = mir_a2t_cp(notifications[i]->link.c_str(), CP_UTF8);
- NotifyEvent( szTitle, szText, ContactIDToHContact(notifications[i]->user_id), FACEBOOK_EVENT_NOTIFICATION, szUrl );
- mir_free( szTitle );
- mir_free( szText );
-// mir_free( szUrl ); // URL is free'd in popup procedure
+ NotifyEvent(szTitle, szText, ContactIDToHContact(notifications[i]->user_id), FACEBOOK_EVENT_NOTIFICATION, szUrl);
+ mir_free(szTitle);
+ mir_free(szText);
+// mir_free(szUrl); // URL is free'd in popup procedure
delete notifications[i];
}
@@ -494,24 +494,24 @@ exit: delete resp;
}
-void FacebookProto::ProcessNotifications( void* )
+void FacebookProto::ProcessNotifications(void*)
{
- if ( isOffline())
+ if (isOffline())
return;
- if (!getByte( FACEBOOK_KEY_EVENT_NOTIFICATIONS_ENABLE, DEFAULT_EVENT_NOTIFICATIONS_ENABLE ))
+ if (!getByte(FACEBOOK_KEY_EVENT_NOTIFICATIONS_ENABLE, DEFAULT_EVENT_NOTIFICATIONS_ENABLE))
return;
- facy.handle_entry( "notifications" );
+ facy.handle_entry("notifications");
// Get notifications
- http::response resp = facy.flap( FACEBOOK_REQUEST_NOTIFICATIONS );
+ http::response resp = facy.flap(FACEBOOK_REQUEST_NOTIFICATIONS);
// Process result data
facy.validate_response(&resp);
if (resp.code != HTTP_CODE_OK) {
- facy.handle_error( "notifications" );
+ facy.handle_error("notifications");
return;
}
@@ -523,20 +523,20 @@ void FacebookProto::ProcessNotifications( void* ) std::vector< facebook_notification* > notifications;
- facebook_json_parser* p = new facebook_json_parser( this );
- p->parse_notifications( &(resp.data), ¬ifications );
+ facebook_json_parser* p = new facebook_json_parser(this);
+ p->parse_notifications(&(resp.data), ¬ifications);
delete p;
- for(std::vector<facebook_notification*>::size_type i=0; i<notifications.size( ); i++)
+ for(std::vector<facebook_notification*>::size_type i=0; i<notifications.size(); i++)
{
LOG(" Got notification: %s", notifications[i]->text.c_str());
TCHAR* szTitle = mir_a2t_cp(this->m_szModuleName, CP_UTF8);
TCHAR* szText = mir_a2t_cp(notifications[i]->text.c_str(), CP_UTF8);
TCHAR* szUrl = mir_a2t_cp(notifications[i]->link.c_str(), CP_UTF8);
- NotifyEvent( szTitle, szText, ContactIDToHContact(notifications[i]->user_id), FACEBOOK_EVENT_NOTIFICATION, szUrl );
- mir_free( szTitle );
- mir_free( szText );
-// mir_free( szUrl ); // URL is free'd in popup procedure
+ NotifyEvent(szTitle, szText, ContactIDToHContact(notifications[i]->user_id), FACEBOOK_EVENT_NOTIFICATION, szUrl);
+ mir_free(szTitle);
+ mir_free(szText);
+// mir_free(szUrl); // URL is free'd in popup procedure
delete notifications[i];
}
@@ -551,18 +551,18 @@ void FacebookProto::ProcessNotifications( void* ) CODE_BLOCK_END
}
-void FacebookProto::ProcessFriendRequests( void* )
+void FacebookProto::ProcessFriendRequests(void*)
{
- facy.handle_entry( "friendRequests" );
+ facy.handle_entry("friendRequests");
// Get notifications
- http::response resp = facy.flap( FACEBOOK_REQUEST_LOAD_REQUESTS );
+ http::response resp = facy.flap(FACEBOOK_REQUEST_LOAD_REQUESTS);
// Process result data
facy.validate_response(&resp);
if (resp.code != HTTP_CODE_OK) {
- facy.handle_error( "friendRequests" );
+ facy.handle_error("friendRequests");
return;
}
@@ -607,17 +607,17 @@ void FacebookProto::ProcessFriendRequests( void* ) // This is new request
db_set_s(hContact, m_szModuleName, "RequestTime", time.c_str());
- //blob is: uin( DWORD ), hContact( HANDLE ), nick( ASCIIZ ), first( ASCIIZ ), last( ASCIIZ ), email( ASCIIZ ), reason( ASCIIZ )
- //blob is: 0( DWORD ), hContact( HANDLE ), nick( ASCIIZ ), ""( ASCIIZ ), ""( ASCIIZ ), ""( ASCIIZ ), ""( ASCIIZ )
+ //blob is: uin(DWORD), hContact(HANDLE), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ), reason(ASCIIZ)
+ //blob is: 0(DWORD), hContact(HANDLE), nick(ASCIIZ), ""(ASCIIZ), ""(ASCIIZ), ""(ASCIIZ), ""(ASCIIZ)
DBEVENTINFO dbei = {0};
- dbei.cbSize = sizeof( DBEVENTINFO );
+ dbei.cbSize = sizeof(DBEVENTINFO);
dbei.szModule = m_szModuleName;
- dbei.timestamp = ::time( NULL );
+ dbei.timestamp = ::time(NULL);
dbei.flags = DBEF_UTF;
dbei.eventType = EVENTTYPE_AUTHREQUEST;
- dbei.cbBlob = (DWORD)(sizeof( DWORD )*2 + fbu->real_name.length() + 5);
+ dbei.cbBlob = (DWORD)(sizeof(DWORD)*2 + fbu->real_name.length() + 5);
- PBYTE pCurBlob = dbei.pBlob = ( PBYTE ) mir_alloc( dbei.cbBlob );
+ PBYTE pCurBlob = dbei.pBlob = (PBYTE) mir_alloc(dbei.cbBlob);
*(PDWORD)pCurBlob = 0; pCurBlob += sizeof(DWORD); // UID
*(PDWORD)pCurBlob = (DWORD)hContact; pCurBlob += sizeof(DWORD); // Contact Handle
strcpy((char*)pCurBlob, fbu->real_name.data()); pCurBlob += fbu->real_name.length()+1; // Nickname
@@ -638,12 +638,12 @@ void FacebookProto::ProcessFriendRequests( void* ) }
}
- facy.handle_success( "friendRequests" );
+ facy.handle_success("friendRequests");
}
-void FacebookProto::ProcessFeeds( void* data )
+void FacebookProto::ProcessFeeds(void* data)
{
- if ( data == NULL )
+ if (data == NULL)
return;
std::string* resp = (std::string*)data;
@@ -663,13 +663,13 @@ void FacebookProto::ProcessFeeds( void* data ) *resp = utils::text::slashu_to_utf8(*resp);
*resp = utils::text::source_get_value(resp, 2, "\"html\":\"", ">\"");
- while ( ( pos = resp->find( "<div class=\\\"mainWrapper\\\"", pos )) != std::string::npos && limit <= 25 )
+ while ((pos = resp->find("<div class=\\\"mainWrapper\\\"", pos)) != std::string::npos && limit <= 25)
{
- std::string::size_type pos2 = resp->find( "<div class=\\\"mainWrapper\\\"", pos+5 );
+ std::string::size_type pos2 = resp->find("<div class=\\\"mainWrapper\\\"", pos+5);
if (pos2 == std::string::npos)
pos2 = resp->length();
- std::string post = resp->substr( pos, pos2 - pos );
+ std::string post = resp->substr(pos, pos2 - pos);
pos += 5;
std::string post_header = utils::text::source_get_value(&post, 4, "<h5 class=", "uiStreamHeadline", ">", "<\\/h5>");
@@ -683,25 +683,25 @@ void FacebookProto::ProcessFeeds( void* data ) post_header = post_header.substr(0, pos2);
// append attachement to message (if any)
- post_message += utils::text::trim( post_attach );
+ post_message += utils::text::trim(post_attach);
facebook_newsfeed* nf = new facebook_newsfeed;
nf->title = utils::text::trim(
utils::text::special_expressions_decode(
- utils::text::remove_html( post_header )) );
+ utils::text::remove_html(post_header)));
- nf->user_id = utils::text::source_get_value( &post_header, 2, "user.php?id=", "\\\"" );
+ nf->user_id = utils::text::source_get_value(&post_header, 2, "user.php?id=", "\\\"");
nf->link = utils::text::special_expressions_decode(
- utils::text::source_get_value( &post_link, 2, "href=\\\"", "\\\">" ));
+ utils::text::source_get_value(&post_link, 2, "href=\\\"", "\\\">"));
nf->text = utils::text::trim(
utils::text::special_expressions_decode(
utils::text::remove_html(
- utils::text::edit_html( post_message )) ));
+ utils::text::edit_html(post_message))));
- if ( !nf->title.length() || !nf->text.length())
+ if (!nf->title.length() || !nf->text.length())
{
delete nf;
continue;
@@ -713,12 +713,12 @@ void FacebookProto::ProcessFeeds( void* data ) nf->text += "...";
}
- news.push_back( nf );
+ news.push_back(nf);
pos++;
limit++;
}
- for(std::vector<facebook_newsfeed*>::size_type i=0; i<news.size( ); i++)
+ for(std::vector<facebook_newsfeed*>::size_type i=0; i<news.size(); i++)
{
LOG(" Got newsfeed: %s %s", news[i]->title.c_str(), news[i]->text.c_str());
TCHAR* szTitle = mir_a2t_cp(news[i]->title.c_str(), CP_UTF8);
@@ -748,12 +748,12 @@ exit: void FacebookProto::SearchAckThread(void *targ)
{
- facy.handle_entry( "searchAckThread" );
+ facy.handle_entry("searchAckThread");
int count = 0;
char *arg = mir_utf8encodeT((TCHAR*)targ);
- std::string search = utils::url::encode( arg );
+ std::string search = utils::url::encode(arg);
std::string ssid;
while (count < 50 && !isOffline())
@@ -762,7 +762,7 @@ void FacebookProto::SearchAckThread(void *targ) if (!ssid.empty())
get_data += "&ssid=" + ssid;
- http::response resp = facy.flap( FACEBOOK_REQUEST_SEARCH, NULL, &get_data );
+ http::response resp = facy.flap(FACEBOOK_REQUEST_SEARCH, NULL, &get_data);
// Process result data
facy.validate_response(&resp);
@@ -833,7 +833,7 @@ void FacebookProto::SearchAckThread(void *targ) ProtoBroadcastAck(m_szModuleName, NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, targ, 0);
- facy.handle_success( "searchAckThread" );
+ facy.handle_success("searchAckThread");
mir_free(targ);
mir_free(arg);
diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp index 3dbaebea54..1d3e8383bd 100644 --- a/protocols/FacebookRM/src/proto.cpp +++ b/protocols/FacebookRM/src/proto.cpp @@ -28,13 +28,13 @@ FacebookProto::FacebookProto(const char* proto_name,const TCHAR* username) facy.parent = this;
- signon_lock_ = CreateMutex( NULL, FALSE, NULL );
- avatar_lock_ = CreateMutex( NULL, FALSE, NULL );
- log_lock_ = CreateMutex( NULL, FALSE, NULL );
- update_loop_lock_ = CreateEvent( NULL, FALSE, FALSE, NULL);
- facy.buddies_lock_ = CreateMutex( NULL, FALSE, NULL );
- facy.send_message_lock_ = CreateMutex( NULL, FALSE, NULL );
- facy.fcb_conn_lock_ = CreateMutex( NULL, FALSE, NULL );
+ signon_lock_ = CreateMutex(NULL, FALSE, NULL);
+ avatar_lock_ = CreateMutex(NULL, FALSE, NULL);
+ log_lock_ = CreateMutex(NULL, FALSE, NULL);
+ update_loop_lock_ = CreateEvent(NULL, FALSE, FALSE, NULL);
+ facy.buddies_lock_ = CreateMutex(NULL, FALSE, NULL);
+ facy.send_message_lock_ = CreateMutex(NULL, FALSE, NULL);
+ facy.fcb_conn_lock_ = CreateMutex(NULL, FALSE, NULL);
CreateProtoService(m_szModuleName, PS_CREATEACCMGRUI, &FacebookProto::SvcCreateAccMgrUI, this);
CreateProtoService(m_szModuleName, PS_GETMYAWAYMSG, &FacebookProto::GetMyAwayMsg, this);
@@ -66,41 +66,41 @@ FacebookProto::FacebookProto(const char* proto_name,const TCHAR* username) facy.set_handle(m_hNetlibUser);
- SkinAddNewSoundExT( "Notification", m_tszUserName, LPGENT( "Notification" ));
- SkinAddNewSoundExT( "NewsFeed", m_tszUserName, LPGENT( "News Feed" ));
- SkinAddNewSoundExT( "OtherEvent", m_tszUserName, LPGENT( "Other Event" ));
+ SkinAddNewSoundExT("Notification", m_tszUserName, LPGENT("Notification"));
+ SkinAddNewSoundExT("NewsFeed", m_tszUserName, LPGENT("News Feed"));
+ SkinAddNewSoundExT("OtherEvent", m_tszUserName, LPGENT("Other Event"));
mir_sntprintf(descr, SIZEOF(descr), _T("%%miranda_avatarcache%%\\%s"), m_tszUserName);
hAvatarFolder_ = FoldersRegisterCustomPathT(LPGEN("Avatars"), m_szModuleName, descr, m_tszUserName);
// Set all contacts offline -- in case we crashed
- SetAllContactStatuses( ID_STATUS_OFFLINE, true );
+ SetAllContactStatuses(ID_STATUS_OFFLINE, true);
}
-FacebookProto::~FacebookProto( )
+FacebookProto::~FacebookProto()
{
- Netlib_CloseHandle( m_hNetlibUser );
-
- WaitForSingleObject( signon_lock_, IGNORE );
- WaitForSingleObject( avatar_lock_, IGNORE );
- WaitForSingleObject( log_lock_, IGNORE );
- WaitForSingleObject( facy.buddies_lock_, IGNORE );
- WaitForSingleObject( facy.send_message_lock_, IGNORE );
-
- CloseHandle( signon_lock_ );
- CloseHandle( avatar_lock_ );
- CloseHandle( log_lock_ );
- CloseHandle( update_loop_lock_ );
- CloseHandle( facy.buddies_lock_ );
- CloseHandle( facy.send_message_lock_ );
- CloseHandle( facy.fcb_conn_lock_ );
+ Netlib_CloseHandle(m_hNetlibUser);
+
+ WaitForSingleObject(signon_lock_, IGNORE);
+ WaitForSingleObject(avatar_lock_, IGNORE);
+ WaitForSingleObject(log_lock_, IGNORE);
+ WaitForSingleObject(facy.buddies_lock_, IGNORE);
+ WaitForSingleObject(facy.send_message_lock_, IGNORE);
+
+ CloseHandle(signon_lock_);
+ CloseHandle(avatar_lock_);
+ CloseHandle(log_lock_);
+ CloseHandle(update_loop_lock_);
+ CloseHandle(facy.buddies_lock_);
+ CloseHandle(facy.send_message_lock_);
+ CloseHandle(facy.fcb_conn_lock_);
ProtoDestructor(this);
}
//////////////////////////////////////////////////////////////////////////////
-DWORD_PTR FacebookProto::GetCaps( int type, HANDLE hContact )
+DWORD_PTR FacebookProto::GetCaps(int type, HANDLE hContact)
{
switch(type)
{
@@ -108,7 +108,7 @@ DWORD_PTR FacebookProto::GetCaps( int type, HANDLE hContact ) {
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;
- if ( getByte( FACEBOOK_KEY_SET_MIRANDA_STATUS, 0 ))
+ if (getByte(FACEBOOK_KEY_SET_MIRANDA_STATUS, 0))
return flags |= PF1_MODEMSG;
else
return flags |= PF1_MODEMSGRECV;
@@ -116,7 +116,7 @@ DWORD_PTR FacebookProto::GetCaps( int type, HANDLE hContact ) case PFLAGNUM_2:
return PF2_ONLINE | PF2_INVISIBLE | PF2_ONTHEPHONE | PF2_IDLE; // | PF2_SHORTAWAY;
case PFLAGNUM_3:
- if ( getByte( FACEBOOK_KEY_SET_MIRANDA_STATUS, 0 ))
+ if (getByte(FACEBOOK_KEY_SET_MIRANDA_STATUS, 0))
return PF2_ONLINE; // | PF2_SHORTAWAY;
else
return 0;
@@ -136,12 +136,12 @@ DWORD_PTR FacebookProto::GetCaps( int type, HANDLE hContact ) //////////////////////////////////////////////////////////////////////////////
-int FacebookProto::SetStatus( int new_status )
+int FacebookProto::SetStatus(int new_status)
{
LOG("===== Beginning SetStatus process");
// Routing statuses not supported by Facebook
- switch ( new_status )
+ switch (new_status)
{
case ID_STATUS_INVISIBLE:
case ID_STATUS_OFFLINE:
@@ -164,26 +164,26 @@ int FacebookProto::SetStatus( int new_status ) break;
}
- if ( m_iStatus == ID_STATUS_CONNECTING )
+ if (m_iStatus == ID_STATUS_CONNECTING)
{
LOG("===== Status is connecting, no change");
return 0;
}
- if ( m_iStatus == m_iDesiredStatus)
+ if (m_iStatus == m_iDesiredStatus)
{
LOG("===== Statuses are same, no change");
return 0;
}
- facy.invisible_ = ( new_status == ID_STATUS_INVISIBLE );
+ facy.invisible_ = (new_status == ID_STATUS_INVISIBLE);
- ForkThread( &FacebookProto::ChangeStatus, this );
+ ForkThread(&FacebookProto::ChangeStatus, this);
return 0;
}
-int FacebookProto::SetAwayMsg( int status, const PROTOCHAR *msg )
+int FacebookProto::SetAwayMsg(int status, const PROTOCHAR *msg)
{
if (!msg)
{
@@ -204,11 +204,11 @@ int FacebookProto::SetAwayMsg( int status, const PROTOCHAR *msg ) void FacebookProto::SetAwayMsgWorker(void *)
{
- if ( !last_status_msg_.empty())
- facy.set_status( last_status_msg_ );
+ if (!last_status_msg_.empty())
+ facy.set_status(last_status_msg_);
}
-HANDLE FacebookProto::SearchBasic( const PROTOCHAR* id )
+HANDLE FacebookProto::SearchBasic(const PROTOCHAR* id)
{
if (isOffline())
return 0;
@@ -219,12 +219,12 @@ HANDLE FacebookProto::SearchBasic( const PROTOCHAR* id ) return email;
}
-HANDLE FacebookProto::SearchByEmail( const PROTOCHAR* email )
+HANDLE FacebookProto::SearchByEmail(const PROTOCHAR* email)
{
return SearchBasic(email);
}
-HANDLE FacebookProto::SearchByName( const PROTOCHAR* nick, const PROTOCHAR* firstName, const PROTOCHAR* lastName )
+HANDLE FacebookProto::SearchByName(const PROTOCHAR* nick, const PROTOCHAR* firstName, const PROTOCHAR* lastName)
{
TCHAR arg[200];
_sntprintf (arg, SIZEOF(arg), _T("%s %s %s"), nick, firstName, lastName);
@@ -273,7 +273,7 @@ int FacebookProto::Authorize(HANDLE hDbEvent) {
if (!isOffline() && hDbEvent)
{
- HANDLE hContact = HContactFromAuthEvent( hDbEvent );
+ HANDLE hContact = HContactFromAuthEvent(hDbEvent);
if (hContact == INVALID_HANDLE_VALUE)
return 1;
@@ -306,20 +306,20 @@ int FacebookProto::AuthDeny(HANDLE hDbEvent, const PROTOCHAR *reason) //////////////////////////////////////////////////////////////////////////////
// SERVICES
-int FacebookProto::GetMyAwayMsg( WPARAM wParam, LPARAM lParam )
+int FacebookProto::GetMyAwayMsg(WPARAM wParam, LPARAM lParam)
{
DBVARIANT dbv = { DBVT_TCHAR };
- if ( !getTString( "StatusMsg", &dbv ) && lstrlen( dbv.ptszVal ) != 0 )
+ if (!getTString("StatusMsg", &dbv) && lstrlen(dbv.ptszVal) != 0)
{
int res = (lParam & SGMA_UNICODE) ? (INT_PTR)mir_t2u(dbv.ptszVal) : (INT_PTR)mir_t2a(dbv.ptszVal);
- db_free( &dbv );
+ db_free(&dbv);
return res;
} else {
return 0;
}
}
-int FacebookProto::OnIdleChanged( WPARAM wParam, LPARAM lParam )
+int FacebookProto::OnIdleChanged(WPARAM wParam, LPARAM lParam)
{
if (m_iStatus == ID_STATUS_INVISIBLE || m_iStatus <= ID_STATUS_OFFLINE)
return 0;
@@ -369,7 +369,7 @@ int FacebookProto::OnEvent(PROTOEVENTTYPE event,WPARAM wParam,LPARAM lParam) int FacebookProto::SvcCreateAccMgrUI(WPARAM wParam,LPARAM lParam)
{
return (int)CreateDialogParam(g_hInstance,MAKEINTRESOURCE(IDD_FACEBOOKACCOUNT),
- (HWND)lParam, FBAccountProc, (LPARAM)this );
+ (HWND)lParam, FBAccountProc, (LPARAM)this);
}
int FacebookProto::OnModulesLoaded(WPARAM wParam,LPARAM lParam)
@@ -389,7 +389,7 @@ int FacebookProto::OnModulesLoaded(WPARAM wParam,LPARAM lParam) int FacebookProto::OnPreShutdown(WPARAM wParam,LPARAM lParam)
{
- SetStatus( ID_STATUS_OFFLINE );
+ SetStatus(ID_STATUS_OFFLINE);
return 0;
}
@@ -427,16 +427,16 @@ int FacebookProto::OnOptionsInit(WPARAM wParam,LPARAM lParam) int FacebookProto::OnMind(WPARAM,LPARAM)
{
- HWND hDlg = CreateDialogParam( g_hInstance, MAKEINTRESOURCE( IDD_MIND ),
- ( HWND )0, FBMindProc, reinterpret_cast<LPARAM>( this ));
- ShowWindow( hDlg, SW_SHOW );
+ HWND hDlg = CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_MIND),
+ (HWND)0, FBMindProc, reinterpret_cast<LPARAM>(this));
+ ShowWindow(hDlg, SW_SHOW);
return FALSE;
}
int FacebookProto::CheckNewsfeeds(WPARAM, LPARAM)
{
if (!isOffline()) {
- facy.client_notify( TranslateT("Loading newsfeeds..."));
+ facy.client_notify(TranslateT("Loading newsfeeds..."));
facy.feeds();
}
return 0;
@@ -445,7 +445,7 @@ int FacebookProto::CheckNewsfeeds(WPARAM, LPARAM) int FacebookProto::CheckFriendRequests(WPARAM, LPARAM)
{
if (!isOffline()) {
- facy.client_notify( TranslateT("Checking friend requests..."));
+ facy.client_notify(TranslateT("Checking friend requests..."));
ProcessFriendRequests(NULL);
}
return 0;
@@ -454,7 +454,7 @@ int FacebookProto::CheckFriendRequests(WPARAM, LPARAM) int FacebookProto::RefreshBuddyList(WPARAM, LPARAM)
{
if (!isOffline()) {
- facy.client_notify( TranslateT("Refreshing buddy list..."));
+ facy.client_notify(TranslateT("Refreshing buddy list..."));
facy.buddy_list();
}
return 0;
@@ -504,28 +504,28 @@ int FacebookProto::CancelFriendship(WPARAM wParam,LPARAM lParam) DBVARIANT dbv;
TCHAR tstr[256];
- if ( !db_get_ts(hContact, m_szModuleName, FACEBOOK_KEY_NAME, &dbv)) {
+ if (!db_get_ts(hContact, m_szModuleName, FACEBOOK_KEY_NAME, &dbv)) {
mir_sntprintf(tstr,SIZEOF(tstr),TranslateT("Do you want to cancel your friendship with '%s'?"), dbv.ptszVal);
db_free(&dbv);
- } else if ( !db_get_ts(hContact,m_szModuleName,FACEBOOK_KEY_ID,&dbv)) {
+ } else if (!db_get_ts(hContact,m_szModuleName,FACEBOOK_KEY_ID,&dbv)) {
mir_sntprintf(tstr,SIZEOF(tstr),TranslateT("Do you want to cancel your friendship with '%s'?"), dbv.ptszVal);
db_free(&dbv);
}
- if (MessageBox( 0, tstr, m_tszUserName, MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2 ) == IDYES) {
+ if (MessageBox(0, tstr, m_tszUserName, MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2) == IDYES) {
- if ( !db_get_s(hContact,m_szModuleName,FACEBOOK_KEY_ID,&dbv))
+ if (!db_get_s(hContact,m_szModuleName,FACEBOOK_KEY_ID,&dbv))
{
std::string* id = new std::string(dbv.pszVal);
if (deleting) {
- facebook_user* fbu = facy.buddies.find( (*id));
+ facebook_user* fbu = facy.buddies.find((*id));
if (fbu != NULL) {
fbu->handle = NULL;
}
}
- ForkThread( &FacebookProto::DeleteContactFromServer, this, ( void* )id );
+ ForkThread(&FacebookProto::DeleteContactFromServer, this, (void*)id);
db_free(&dbv);
}
@@ -542,10 +542,10 @@ int FacebookProto::RequestFriendship(WPARAM wParam,LPARAM lParam) HANDLE hContact = reinterpret_cast<HANDLE>(wParam);
DBVARIANT dbv;
- if ( !db_get_s(hContact,m_szModuleName,FACEBOOK_KEY_ID,&dbv))
+ if (!db_get_s(hContact,m_szModuleName,FACEBOOK_KEY_ID,&dbv))
{
std::string* id = new std::string(dbv.pszVal);
- ForkThread( &FacebookProto::AddContactToServer, this, ( void* )id );
+ ForkThread(&FacebookProto::AddContactToServer, this, (void*)id);
db_free(&dbv);
}
@@ -558,7 +558,7 @@ int FacebookProto::ApproveFriendship(WPARAM wParam,LPARAM lParam) return 0;
HANDLE *hContact = new HANDLE(reinterpret_cast<HANDLE>(wParam));
- ForkThread( &FacebookProto::ApproveContactToServer, this, ( void* )hContact );
+ ForkThread(&FacebookProto::ApproveContactToServer, this, (void*)hContact);
return 0;
}
@@ -569,7 +569,7 @@ int FacebookProto::OnCancelFriendshipRequest(WPARAM wParam,LPARAM lParam) return 0;
HANDLE *hContact = new HANDLE(reinterpret_cast<HANDLE>(wParam));
- ForkThread( &FacebookProto::CancelFriendsRequest, this, ( void* )hContact );
+ ForkThread(&FacebookProto::CancelFriendsRequest, this, (void*)hContact);
return 0;
}
diff --git a/protocols/FacebookRM/src/proto.h b/protocols/FacebookRM/src/proto.h index 0637b90f5e..ae74b7f51c 100644 --- a/protocols/FacebookRM/src/proto.h +++ b/protocols/FacebookRM/src/proto.h @@ -25,94 +25,94 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. class FacebookProto : public PROTO_INTERFACE
{
public:
- FacebookProto( const char *proto_name, const TCHAR *username );
- ~FacebookProto( );
+ FacebookProto(const char *proto_name, const TCHAR *username);
+ ~FacebookProto();
- inline const char* ModuleName( ) const
+ inline const char* ModuleName() const
{
return m_szModuleName;
}
- inline bool isOnline( )
+ inline bool isOnline()
{
- return ( m_iStatus != ID_STATUS_OFFLINE && m_iStatus != ID_STATUS_CONNECTING );
+ return (m_iStatus != ID_STATUS_OFFLINE && m_iStatus != ID_STATUS_CONNECTING);
}
- inline bool isOffline( )
+ inline bool isOffline()
{
- return ( m_iStatus == ID_STATUS_OFFLINE );
+ return (m_iStatus == ID_STATUS_OFFLINE);
}
- inline bool isInvisible( )
+ inline bool isInvisible()
{
- return ( m_iStatus == ID_STATUS_INVISIBLE );
+ return (m_iStatus == ID_STATUS_INVISIBLE);
}
//PROTO_INTERFACE
- virtual HANDLE __cdecl AddToList( int flags, PROTOSEARCHRESULT* psr );
- virtual HANDLE __cdecl AddToListByEvent( int flags, int iContact, HANDLE hDbEvent );
+ virtual HANDLE __cdecl AddToList(int flags, PROTOSEARCHRESULT* psr);
+ virtual HANDLE __cdecl AddToListByEvent(int flags, int iContact, HANDLE hDbEvent);
- virtual int __cdecl Authorize( HANDLE hDbEvent );
- virtual int __cdecl AuthDeny( HANDLE hDbEvent, const PROTOCHAR* szReason );
- virtual int __cdecl AuthRecv( HANDLE hContact, PROTORECVEVENT* );
- virtual int __cdecl AuthRequest( HANDLE hContact, const PROTOCHAR* szMessage );
+ virtual int __cdecl Authorize(HANDLE hDbEvent);
+ virtual int __cdecl AuthDeny(HANDLE hDbEvent, const PROTOCHAR* szReason);
+ virtual int __cdecl AuthRecv(HANDLE hContact, PROTORECVEVENT*);
+ virtual int __cdecl AuthRequest(HANDLE hContact, const PROTOCHAR* szMessage);
- virtual HANDLE __cdecl ChangeInfo( int iInfoType, void* pInfoData );
+ virtual HANDLE __cdecl ChangeInfo(int iInfoType, void* pInfoData);
- virtual HANDLE __cdecl FileAllow( HANDLE hContact, HANDLE hTransfer, const PROTOCHAR* szPath );
- virtual int __cdecl FileCancel( HANDLE hContact, HANDLE hTransfer );
- virtual int __cdecl FileDeny( HANDLE hContact, HANDLE hTransfer, const PROTOCHAR* szReason );
- virtual int __cdecl FileResume( HANDLE hTransfer, int* action, const PROTOCHAR** szFilename );
+ virtual HANDLE __cdecl FileAllow(HANDLE hContact, HANDLE hTransfer, const PROTOCHAR* szPath);
+ virtual int __cdecl FileCancel(HANDLE hContact, HANDLE hTransfer);
+ virtual int __cdecl FileDeny(HANDLE hContact, HANDLE hTransfer, const PROTOCHAR* szReason);
+ virtual int __cdecl FileResume(HANDLE hTransfer, int* action, const PROTOCHAR** szFilename);
- virtual DWORD_PTR __cdecl GetCaps( int type, HANDLE hContact = NULL );
- virtual int __cdecl GetInfo( HANDLE hContact, int infoType );
+ virtual DWORD_PTR __cdecl GetCaps(int type, HANDLE hContact = NULL);
+ virtual int __cdecl GetInfo(HANDLE hContact, int infoType);
- virtual HANDLE __cdecl SearchBasic( const PROTOCHAR* id );
- virtual HANDLE __cdecl SearchByEmail( const PROTOCHAR* email );
- virtual HANDLE __cdecl SearchByName( const PROTOCHAR* nick, const PROTOCHAR* firstName, const PROTOCHAR* lastName );
- virtual HWND __cdecl SearchAdvanced( HWND owner );
- virtual HWND __cdecl CreateExtendedSearchUI( HWND owner );
+ virtual HANDLE __cdecl SearchBasic(const PROTOCHAR* id);
+ virtual HANDLE __cdecl SearchByEmail(const PROTOCHAR* email);
+ virtual HANDLE __cdecl SearchByName(const PROTOCHAR* nick, const PROTOCHAR* firstName, const PROTOCHAR* lastName);
+ virtual HWND __cdecl SearchAdvanced(HWND owner);
+ virtual HWND __cdecl CreateExtendedSearchUI(HWND owner);
- virtual int __cdecl RecvContacts( HANDLE hContact, PROTORECVEVENT* );
- virtual int __cdecl RecvFile( HANDLE hContact, PROTOFILEEVENT* );
- virtual int __cdecl RecvMsg( HANDLE hContact, PROTORECVEVENT* );
- virtual int __cdecl RecvUrl( HANDLE hContact, PROTORECVEVENT* );
+ virtual int __cdecl RecvContacts(HANDLE hContact, PROTORECVEVENT*);
+ virtual int __cdecl RecvFile(HANDLE hContact, PROTOFILEEVENT*);
+ virtual int __cdecl RecvMsg(HANDLE hContact, PROTORECVEVENT*);
+ virtual int __cdecl RecvUrl(HANDLE hContact, PROTORECVEVENT*);
- virtual int __cdecl SendContacts( HANDLE hContact, int flags, int nContacts, HANDLE* hContactsList );
- virtual HANDLE __cdecl SendFile( HANDLE hContact, const PROTOCHAR* szDescription, PROTOCHAR** ppszFiles );
- virtual int __cdecl SendMsg( HANDLE hContact, int flags, const char* msg );
- virtual int __cdecl SendUrl( HANDLE hContact, int flags, const char* url );
+ virtual int __cdecl SendContacts(HANDLE hContact, int flags, int nContacts, HANDLE* hContactsList);
+ virtual HANDLE __cdecl SendFile(HANDLE hContact, const PROTOCHAR* szDescription, PROTOCHAR** ppszFiles);
+ virtual int __cdecl SendMsg(HANDLE hContact, int flags, const char* msg);
+ virtual int __cdecl SendUrl(HANDLE hContact, int flags, const char* url);
- virtual int __cdecl SetApparentMode( HANDLE hContact, int mode );
- virtual int __cdecl SetStatus( int iNewStatus );
+ virtual int __cdecl SetApparentMode(HANDLE hContact, int mode);
+ virtual int __cdecl SetStatus(int iNewStatus);
- virtual HANDLE __cdecl GetAwayMsg( HANDLE hContact );
- virtual int __cdecl RecvAwayMsg( HANDLE hContact, int mode, PROTORECVEVENT* evt );
- virtual int __cdecl SendAwayMsg( HANDLE hContact, HANDLE hProcess, const char* msg );
- virtual int __cdecl SetAwayMsg( int iStatus, const PROTOCHAR* msg );
+ virtual HANDLE __cdecl GetAwayMsg(HANDLE hContact);
+ virtual int __cdecl RecvAwayMsg(HANDLE hContact, int mode, PROTORECVEVENT* evt);
+ virtual int __cdecl SendAwayMsg(HANDLE hContact, HANDLE hProcess, const char* msg);
+ virtual int __cdecl SetAwayMsg(int iStatus, const PROTOCHAR* msg);
- virtual int __cdecl UserIsTyping( HANDLE hContact, int type );
+ virtual int __cdecl UserIsTyping(HANDLE hContact, int type);
- virtual int __cdecl OnEvent( PROTOEVENTTYPE iEventType, WPARAM wParam, LPARAM lParam );
+ virtual int __cdecl OnEvent(PROTOEVENTTYPE iEventType, WPARAM wParam, LPARAM lParam);
////////////////////////
// Services
- int __cdecl GetMyAwayMsg( WPARAM, LPARAM );
- int __cdecl SetMyAwayMsg( WPARAM, LPARAM );
- int __cdecl SvcCreateAccMgrUI( WPARAM, LPARAM );
- int __cdecl GetMyAvatar(WPARAM, LPARAM );
- int __cdecl GetAvatarInfo(WPARAM, LPARAM );
- int __cdecl GetAvatarCaps(WPARAM, LPARAM );
- int __cdecl VisitProfile(WPARAM, LPARAM );
- int __cdecl CancelFriendship(WPARAM, LPARAM );
- int __cdecl RequestFriendship(WPARAM, LPARAM );
- int __cdecl ApproveFriendship(WPARAM, LPARAM );
- int __cdecl OnCancelFriendshipRequest(WPARAM, LPARAM );
- int __cdecl CheckNewsfeeds(WPARAM, LPARAM );
- int __cdecl CheckFriendRequests(WPARAM, LPARAM );
- int __cdecl RefreshBuddyList(WPARAM, LPARAM );
+ int __cdecl GetMyAwayMsg(WPARAM, LPARAM);
+ int __cdecl SetMyAwayMsg(WPARAM, LPARAM);
+ int __cdecl SvcCreateAccMgrUI(WPARAM, LPARAM);
+ int __cdecl GetMyAvatar(WPARAM, LPARAM);
+ int __cdecl GetAvatarInfo(WPARAM, LPARAM);
+ int __cdecl GetAvatarCaps(WPARAM, LPARAM);
+ int __cdecl VisitProfile(WPARAM, LPARAM);
+ int __cdecl CancelFriendship(WPARAM, LPARAM);
+ int __cdecl RequestFriendship(WPARAM, LPARAM);
+ int __cdecl ApproveFriendship(WPARAM, LPARAM);
+ int __cdecl OnCancelFriendshipRequest(WPARAM, LPARAM);
+ int __cdecl CheckNewsfeeds(WPARAM, LPARAM);
+ int __cdecl CheckFriendRequests(WPARAM, LPARAM);
+ int __cdecl RefreshBuddyList(WPARAM, LPARAM);
// Events
int __cdecl OnModulesLoaded(WPARAM, LPARAM);
@@ -182,7 +182,7 @@ public: std::tstring GetAvatarFolder();
bool GetDbAvatarInfo(PROTO_AVATAR_INFORMATIONT &ai, std::string *url);
void CheckAvatarChange(HANDLE hContact, std::string image_url);
- void ToggleStatusMenuItems( BOOL bEnable );
+ void ToggleStatusMenuItems(BOOL bEnable);
void parseSmileys(std::string message, HANDLE hContact);
// Handles, Locks
diff --git a/protocols/FacebookRM/src/stubs.cpp b/protocols/FacebookRM/src/stubs.cpp index d8698e7536..f7b0353b45 100644 --- a/protocols/FacebookRM/src/stubs.cpp +++ b/protocols/FacebookRM/src/stubs.cpp @@ -58,7 +58,7 @@ int FacebookProto::FileResume(HANDLE hTransfer,int *action,const PROTOCHAR **fil return 1;
}
-int FacebookProto::GetInfo( HANDLE hContact, int infoType )
+int FacebookProto::GetInfo(HANDLE hContact, int infoType)
{
// TODO: Most probably some ProtoAck should be here instead
return 1;
diff --git a/protocols/FacebookRM/src/theme.cpp b/protocols/FacebookRM/src/theme.cpp index c43cc7666e..a1a539a196 100644 --- a/protocols/FacebookRM/src/theme.cpp +++ b/protocols/FacebookRM/src/theme.cpp @@ -69,7 +69,7 @@ HGENMENU g_hContactMenuItems[CMITEMS_COUNT]; static FacebookProto * GetInstanceByHContact(HANDLE hContact)
{
char *proto = GetContactProto(hContact);
- if( !proto )
+ if(!proto)
return 0;
for(int i=0; i<g_Instances.getCount(); i++)
@@ -176,17 +176,17 @@ int FacebookProto::OnBuildStatusMenu(WPARAM wParam,LPARAM lParam) if (hRoot == NULL) {
mi.popupPosition = 500085000;
mi.hParentMenu = HGENMENU_ROOT;
- mi.flags = CMIF_ROOTPOPUP | CMIF_TCHAR | CMIF_KEEPUNTRANSLATED | ( this->isOnline() ? 0 : CMIF_GRAYED );
- mi.icolibItem = GetIconHandle( "facebook" );
+ mi.flags = CMIF_ROOTPOPUP | CMIF_TCHAR | CMIF_KEEPUNTRANSLATED | (this->isOnline() ? 0 : CMIF_GRAYED);
+ mi.icolibItem = GetIconHandle("facebook");
mi.ptszName = m_tszUserName;
hRoot = m_hMenuRoot = Menu_AddProtoMenuItem(&mi);
} else {
- if ( m_hMenuRoot )
+ if (m_hMenuRoot)
CallService(MS_CLIST_REMOVEMAINMENUITEM, (WPARAM)m_hMenuRoot, 0);
m_hMenuRoot = NULL;
}
- mi.flags = CMIF_CHILDPOPUP | ( this->isOnline() ? 0 : CMIF_GRAYED );
+ mi.flags = CMIF_CHILDPOPUP | (this->isOnline() ? 0 : CMIF_GRAYED);
mi.position = 201001;
CreateProtoService(m_szModuleName,"/Mind",&FacebookProto::OnMind,this);
@@ -206,8 +206,8 @@ int FacebookProto::OnBuildStatusMenu(WPARAM wParam,LPARAM lParam) // Services...
mi.pszName = LPGEN("Services...");
- strcpy( tDest, "/Services" );
- mi.flags = CMIF_CHILDPOPUP | ( this->isOnline() ? 0 : CMIF_GRAYED );
+ strcpy(tDest, "/Services");
+ mi.flags = CMIF_CHILDPOPUP | (this->isOnline() ? 0 : CMIF_GRAYED);
mi.icolibItem = NULL;
m_hMenuServicesRoot = Menu_AddProtoMenuItem(&mi);
@@ -240,12 +240,12 @@ int FacebookProto::OnBuildStatusMenu(WPARAM wParam,LPARAM lParam) return 0;
}
-void FacebookProto::ToggleStatusMenuItems( BOOL bEnable )
+void FacebookProto::ToggleStatusMenuItems(BOOL bEnable)
{
CLISTMENUITEM clmi = {sizeof(clmi)};
- clmi.flags = CMIM_FLAGS | (( bEnable ) ? 0 : CMIF_GRAYED);
+ clmi.flags = CMIM_FLAGS | ((bEnable) ? 0 : CMIF_GRAYED);
- Menu_ModifyItem(m_hMenuRoot, &clmi );
- Menu_ModifyItem(m_hStatusMind, &clmi );
- Menu_ModifyItem(m_hMenuServicesRoot, &clmi );
+ Menu_ModifyItem(m_hMenuRoot, &clmi);
+ Menu_ModifyItem(m_hStatusMind, &clmi);
+ Menu_ModifyItem(m_hMenuServicesRoot, &clmi);
}
diff --git a/protocols/FacebookRM/src/utils.cpp b/protocols/FacebookRM/src/utils.cpp index ea1518f841..a7d22d441d 100644 --- a/protocols/FacebookRM/src/utils.cpp +++ b/protocols/FacebookRM/src/utils.cpp @@ -24,7 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. std::string utils::url::encode(const std::string &s)
{
- return (char*)mir_ptr<char>( mir_urlEncode( s.c_str()));
+ return (char*)mir_ptr<char>(mir_urlEncode(s.c_str()));
}
std::string utils::url::decode(std::string data)
diff --git a/protocols/FacebookRM/src/utils.h b/protocols/FacebookRM/src/utils.h index 3c00ba904a..9918eb917f 100644 --- a/protocols/FacebookRM/src/utils.h +++ b/protocols/FacebookRM/src/utils.h @@ -38,7 +38,7 @@ void CreateProtoService(const char *module,const char *service, char temp[MAX_PATH*2];
mir_snprintf(temp,sizeof(temp),"%s%s",module,service);
- CreateServiceFunctionObj(temp,( MIRANDASERVICEOBJ )*(void**)&serviceProc, self );
+ CreateServiceFunctionObj(temp,(MIRANDASERVICEOBJ)*(void**)&serviceProc, self);
}
template<typename T>
@@ -50,7 +50,7 @@ void HookProtoEvent(const char* evt, int (__cdecl T::*eventProc)(WPARAM,LPARAM), template<typename T>
HANDLE ForkThreadEx(void (__cdecl T::*thread)(void*),T *self,void *data = 0)
{
- return reinterpret_cast<HANDLE>( mir_forkthreadowner(
+ return reinterpret_cast<HANDLE>(mir_forkthreadowner(
(pThreadFuncOwner)*(void**)&thread,self,data,0));
}
@@ -70,14 +70,14 @@ namespace utils namespace time
{
- std::string unix_timestamp( );
- std::string mili_timestamp( );
- DWORD fix_timestamp( double );
+ std::string unix_timestamp();
+ std::string mili_timestamp();
+ DWORD fix_timestamp(double);
};
namespace number
{
- int random( );
+ int random();
};
namespace text
@@ -85,7 +85,7 @@ namespace utils void replace_first(std::string* data, std::string from, std::string to);
void replace_all(std::string* data, std::string from, std::string to);
unsigned int count_all(std::string* data, std::string term);
- std::string special_expressions_decode( std::string data);
+ std::string special_expressions_decode(std::string data);
std::string edit_html(std::string data);
std::string remove_html(std::string data);
std::string slashu_to_utf8(std::string data);
@@ -98,8 +98,8 @@ namespace utils namespace conversion
{
- DWORD to_timestamp( std::string data );
- std::string to_string( void*, WORD type );
+ DWORD to_timestamp(std::string data);
+ std::string to_string(void*, WORD type);
template <class T>
bool from_string(T& t, const std::string& s, std::ios_base& (*f)(std::ios_base&)) {
@@ -115,7 +115,7 @@ namespace utils namespace mem
{
- void __fastcall detract(char** str );
+ void __fastcall detract(char** str);
void __fastcall detract(void** p);
void __fastcall detract(void* p);
void* __fastcall allocate(size_t size);
@@ -146,5 +146,5 @@ private: int ext_to_format(const std::string &ext);
-void MB( const char* m );
-void MBI( int a );
+void MB(const char* m);
+void MBI(int a);
|