void FacebookProto::OpenUrl(std::string url) { url = PrepareUrl(url); ptrT data(mir_utf8decodeT(url.c_str())); // Check if there is user defined browser for opening links ptrT browser(getTStringA(FACEBOOK_KEY_OPEN_URL_BROWSER)); if (browser != NULL) // If so, use it to open this link ForkThread(&FacebookProto::OpenUrlThread, new open_url(browser, data)); else // Or use Miranda's service Utils_OpenUrlT(data); }
void WebsocketTransport::Open() { auto thiz = std::static_pointer_cast<WebsocketTransport>(shared_from_this()); auto query = MergeQuery(socket_->options().query.value(), ""); websocket_ = Websocket::Create(PrepareUrl() + query, ""); websocket_->set_on_open([thiz](){ thiz->OnOpen(); thiz->socket()->SetBuffer(false); }); websocket_->set_on_message([thiz](const Websocket::Message & message){ thiz->OnData(ToString(*message.data)); }); websocket_->set_on_close([thiz](){ thiz->OnClose(); thiz->socket()->SetBuffer(true); }); websocket_->set_on_error([thiz](const std::string & error){ thiz->OnError(error); }); }
void FacebookProto::UpdateNotificationsChatRoom(facebook_notification *notification) { if (!getBool(FACEBOOK_KEY_NOTIFICATIONS_CHATROOM, DEFAULT_NOTIFICATIONS_CHATROOM)) return; std::stringstream text; text << notification->text << "\n\n" << PrepareUrl(notification->link); std::string message = text.str(); utils::text::replace_all(&message, "%", "%%"); ptrT idT(mir_tstrdup(_T(FACEBOOK_NOTIFICATIONS_CHATROOM))); ptrT messageT(mir_a2t_cp(message.c_str(), CP_UTF8)); GCDEST gcd = { m_szModuleName, _T(FACEBOOK_NOTIFICATIONS_CHATROOM), GC_EVENT_MESSAGE }; GCEVENT gce = { sizeof(gce), &gcd }; gce.ptszText = messageT; gce.time = notification->time ? notification->time : ::time(NULL); gce.bIsMe = false; gce.dwFlags |= GCEF_ADDTOLOG; gce.ptszNick = TranslateT("Notifications"); gce.ptszUID = idT; CallServiceSync(MS_GC_EVENT, 0, reinterpret_cast<LPARAM>(&gce)); }