Beispiel #1
0
/**
 * update all or only the given status message information from the database
 *
 * @param szKey: char* database key name or 0 to reload all messages
 */
void CContactCache::updateStatusMsg(const char *szKey)
{
	if (!m_Valid)
		return;

	MCONTACT hContact = getActiveContact();

	if (szKey == 0 || (szKey && !mir_strcmp("StatusMsg", szKey))) {
		if (m_szStatusMsg)
			mir_free(m_szStatusMsg);
		m_szStatusMsg = 0;
		ptrT szStatus(db_get_tsa(hContact, "CList", "StatusMsg"));
		if (szStatus != 0)
			m_szStatusMsg = (mir_tstrlen(szStatus) > 0 ? getNormalizedStatusMsg(szStatus) : 0);
	}
	if (szKey == 0 || (szKey && !mir_strcmp("ListeningTo", szKey))) {
		if (m_ListeningInfo)
			mir_free(m_ListeningInfo);
		m_ListeningInfo = 0;
		ptrT szListeningTo(db_get_tsa(hContact, cc->szProto, "ListeningTo"));
		if (szListeningTo != 0 && *szListeningTo)
			m_ListeningInfo = szListeningTo.detach();
	}
	if (szKey == 0 || (szKey && !mir_strcmp("XStatusMsg", szKey))) {
		if (m_xStatusMsg)
			mir_free(m_xStatusMsg);
		m_xStatusMsg = 0;
		ptrT szXStatusMsg(db_get_tsa(hContact, cc->szProto, "XStatusMsg"));
		if (szXStatusMsg != 0 && *szXStatusMsg)
			m_xStatusMsg = szXStatusMsg.detach();
	}
	m_xStatus = db_get_b(hContact, cc->szProto, "XStatusId", 0);
}
Beispiel #2
0
CVkProto::CVkProto(const char *szModuleName, const TCHAR *ptszUserName) :
	PROTO<CVkProto>(szModuleName, ptszUserName),
	m_arRequestsQueue(10, sttCompareAsyncHttpRequest),
	m_sendIds(3, PtrKeySortT),
	m_incIds(3, PtrKeySortT),
	m_cookies(5),
	m_msgId(1),
	m_chats(1, NumericKeySortT)
{
	InitQueue();

	CreateProtoService(PS_CREATEACCMGRUI, &CVkProto::SvcCreateAccMgrUI);
	CreateProtoService(PS_GETAVATARINFO, &CVkProto::SvcGetAvatarInfo);
	CreateProtoService(PS_GETAVATARCAPS, &CVkProto::SvcGetAvatarCaps);
	CreateProtoService(PS_GETMYAVATAR, &CVkProto::SvcGetMyAvatar);
	CreateProtoService(PS_SET_LISTENINGTO, &CVkProto::SvcSetListeningTo);

	HookProtoEvent(ME_OPT_INITIALISE, &CVkProto::OnOptionsInit);

	TCHAR descr[512];
	mir_sntprintf(descr, TranslateT("%s server connection"), m_tszUserName);

	NETLIBUSER nlu = {sizeof(nlu)};
	nlu.flags = NUF_INCOMING | NUF_OUTGOING | NUF_HTTPCONNS | NUF_TCHAR;
	nlu.szSettingsModule = m_szModuleName;
	nlu.ptszDescriptiveName = descr;
	m_hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);

	m_defaultGroup = getTStringA("ProtoGroup");
	if (m_defaultGroup == NULL)
		m_defaultGroup = mir_tstrdup(_T("VKontakte"));
	Clist_CreateGroup(NULL, m_defaultGroup);

	m_bServerDelivery = getBool("ServerDelivery", true);
	m_bHideChats = getBool("HideChats", true);
	m_bMesAsUnread = getBool("MesAsUnread");
	m_bUseLocalTime = getBool("UseLocalTime");
	m_bReportAbuse = getBool("ReportAbuseOnBanUser");
	m_bClearServerHistory = getBool("ClearServerHistoryOnBanUser");
	m_bRemoveFromFrendlist = getBool("RemoveFromFrendlistOnBanUser");
	m_bRemoveFromClist = getBool("RemoveFromClistOnBanUser");
	m_bPopUpSyncHistory = getBool("PopUpSyncHistory");
	m_iMarkMessageReadOn = (MarkMsgReadOn)getByte("MarkMessageReadOn", markOnRead);
	m_bStikersAsSmyles = getBool("StikersAsSmyles");
	m_bUserForceOnlineOnActivity = getBool("UserForceOnlineOnActivity");
	m_iMusicSendMetod = (MusicSendMetod)getByte("MusicSendMetod", sendBroadcastOnly);
	m_iSyncHistoryMetod = (SyncHistoryMetod)getByte("SyncHistoryMetod", syncOff);
	CMStringA szListeningTo(m_szModuleName);
	szListeningTo += "Enabled";
	db_set_b(NULL, "ListeningTo", szListeningTo, m_iMusicSendMetod == 0 ? 0 : 1);
	
	m_bNewsEnabled = getBool("NewsEnabled");
	m_iMaxLoadNewsPhoto = getByte("MaxLoadNewsPhoto", 5);
	m_bNotificationsEnabled = getBool("NotificationsEnabled");
	m_bNotificationsMarkAsViewed = getBool("NotificationsMarkAsViewed", true);
	m_bSpecialContactAlwaysEnabled = getBool("SpecialContactAlwaysEnabled");
	m_iNewsInterval = getDword("NewsInterval", 15);
	m_iNotificationsInterval = getDword("NotificationsInterval", 1);
	m_iIMGBBCSupport = (IMGBBCSypport)getByte("IMGBBCSupport", imgNo);
	m_iBBCForNews = (BBCSupport)getByte("BBCForNews", bbcBasic);
	m_iBBCForAttachments = (BBCSupport)getByte("BBCForAttachments", bbcBasic);
	m_bUseBBCOnAttacmentsAsNews = getBool("UseBBCOnAttacmentsAsNews", true);
	m_bNewsAutoClearHistory = getBool("NewsAutoClearHistory");
	m_iNewsAutoClearHistoryInterval = getDword("NewsAutoClearHistoryInterval", 60*60*24*3);

	m_bNewsFilterPosts = getBool("NewsFilterPosts", true);
	m_bNewsFilterPhotos = getBool("NewsFilterPhotos", true);
	m_bNewsFilterTags = getBool("NewsFilterTags", true);
	m_bNewsFilterWallPhotos = getBool("NewsFilterWallPhotos", true);
	m_bNewsSourceFriends = getBool("NewsSourceFriends", true);
	m_bNewsSourceGroups = getBool("NewsSourceGroups", true);
	m_bNewsSourcePages = getBool("NewsSourcePages", true);
	m_bNewsSourceFollowing = getBool("NewsSourceFollowing", true);
	m_bNewsSourceIncludeBanned = getBool("NewsSourceIncludeBanned");
	m_bNewsSourceNoReposts = getBool("NewsSourceNoReposts");

	m_bNotificationFilterComments = getBool("NotificationFilterComments", true);
	m_bNotificationFilterLikes = getBool("NotificationFilterLikes", true);
	m_bNotificationFilterReposts = getBool("NotificationFilterReposts", true);
	m_bNotificationFilterMentions = getBool("NotificationFilterMentions", true);
	m_bNotificationFilterInvites = getBool("NotificationFilterInvites", true);

	m_bUseNonStandardUrlEncode = getBool("UseNonStandardUrlEncode", true);
	m_iInvisibleInterval = getDword("InvisibleInterval", 10);

	m_bShortenLinksForAudio = getBool("ShortenLinksForAudio", true);

	m_bSplitFormatFwdMsg = getBool("SplitFormatFwdMsg", true);
	
	m_bSetBroadcast = false;
	m_bNeedSendOnline = false;
	delSetting("InviteGroupIds");

	// Set all contacts offline -- in case we crashed
	SetAllContactStatuses(ID_STATUS_OFFLINE);
	{
		mir_cslock lck(csInstances);
		vk_Instances.insert(this);
	}
}