Пример #1
0
//************************************************************************
// update's the screens title labels
//************************************************************************
void CChatScreen::UpdateLabels()
{
	tstring strNickname = CAppletManager::GetContactDisplayname(m_hContact);
	char *szProto = GetContactProto(m_hContact);
	m_iStatus = ID_STATUS_OFFLINE;

	tstring strProto = _T("");
	tstring strStatus = _T("");
	if(szProto != NULL)
	{
		strProto = _T("(") + toTstring(szProto) + _T(")");
		m_iStatus = db_get_w(m_hContact,szProto,"Status",ID_STATUS_OFFLINE);
	}
	
	TCHAR *szStatus = pcli->pfnGetStatusModeDescription(m_iStatus, 0);
	if(szStatus != NULL)
		strStatus = toTstring(szStatus);

	m_UserName.SetText(strNickname.c_str());
	m_UserStatus.SetText(strStatus.c_str());

	if(m_bContactTyping && CConfig::GetBoolSetting(SESSION_SHOWTYPING))
		m_UserProto.SetText(CAppletManager::TranslateString(_T("typing..")));
	else
		m_UserProto.SetText(strProto.c_str());
}
Пример #2
0
//************************************************************************
// Called when an LCD-button is pressed
//************************************************************************
void CEventScreen::OnLCDButtonDown(int iButton)
{
	if(iButton == LGLCDBUTTON_CANCEL) {
		CAppletManager::GetInstance()->ActivatePreviousScreen();
	} else if(iButton == LGLCDBUTTON_BUTTON1 || iButton == LGLCDBUTTON_DOWN) {
		m_EventLog.ScrollDown();
		UpdateChatButton();
	} else if(iButton == LGLCDBUTTON_BUTTON0 || iButton == LGLCDBUTTON_UP) {
		m_EventLog.ScrollUp();
		UpdateChatButton();
	} else if(iButton == LGLCDBUTTON_BUTTON2 || iButton == LGLCDBUTTON_MENU) {
		CAppletManager::GetInstance()->ActivateCListScreen();
	} else if(iButton == LGLCDBUTTON_BUTTON3 || iButton == LGLCDBUTTON_OK)
	{
		CListEntry<CEventLogEntry*> *pItem = m_EventLog.GetSelectedEntry();
		if(!pItem || pItem->GetType() != ITEM)
				return;
		CEventLogEntry *pEntry = ((CListItem<CEventLogEntry*>*)pItem)->GetItemData();

		if(!pEntry->hContact)
			return;
		
		// if the contact is an irc chatroom, check if it is hidden (user left the channel)
		char *szProto = GetContactProto(pEntry->hContact);
		CIRCConnection *pIRCCon = CAppletManager::GetInstance()->GetIRCConnection(toTstring(szProto));

		if(pIRCCon && db_get_b(pEntry->hContact, szProto, "ChatRoom", 0) != 0 &&
			db_get_b(pEntry->hContact,"CList","Hidden",0))
			return;

		CAppletManager::GetInstance()->ActivateChatScreen(pEntry->hContact);
	}
}
Пример #3
0
//************************************************************************
// Init
//
// Called after Miranda has finished loading all modules
// This is where the main plugin initialization happens and the
// connection to the LCD is established,
//************************************************************************
int Init(WPARAM, LPARAM)
{
	g_AppletManager = new CAppletManager();
	// Memoryleak Detection
	#ifdef _DEBUG
		_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
		
	#endif
	
	 // set up the LCD context as non-autostart, non-persist, callbacked
	CConfig::Initialize();

	// Initialize the output object
	if(!g_AppletManager->Initialize(toTstring(APP_SHORTNAME)))
	{
		if(CConfig::GetBoolSetting(SKIP_DRIVER_ERROR)) {
			tstring text = L"Failed to initialize the LCD connection\n Make sure you have the newest Logitech drivers installed (>=1.03).\n";
			tstring title = _A2W(APP_SHORTNAME);
			MessageBox(nullptr, text.c_str(), title.c_str(), MB_OK | MB_ICONEXCLAMATION);
		}

		TRACE(L"Initialization failed!.\n");
		return 0;
	}
	
	g_bInitialized = true;
	TRACE(L"Initialization completed successfully.\n-------------------------------------------\n");
	return 0;
}
Пример #4
0
//************************************************************************
// Called to draw the specified group
//************************************************************************
void CContactList::DrawGroup(CLCDGfx *pGfx,CContactListGroup *pGroup,bool bOpen,bool bSelected)
{
	if(pGroup == NULL || ( pGroup->hMetaContact && pGroup->pContactListEntry == NULL)) {
		return;
	}

	char num[10],num2[10];
	itoa(pGroup->iMembers,num,10);
	itoa(pGroup->iOnline,num2,10);

	int iEvents = pGroup->iEvents;
	tstring strText = pGroup->strName;

	if(!pGroup->hMetaContact)
	{
		if(CConfig::GetBoolSetting(CLIST_COUNTERS))
			strText = strText + _T(" (") + toTstring(num2).c_str()+ _T("/") + toTstring(num).c_str() + _T(")");
	}
	else
	{
		pGfx->DrawBitmap(8,ceil((pGfx->GetClipHeight()-5)/2.0f),5,5,CAppletManager::GetInstance()->GetStatusBitmap(pGroup->pContactListEntry->iStatus));
		iEvents += pGroup->pContactListEntry->iMessages;
	}

	if(iEvents != 0)
	{
		itoa(iEvents,num,10);
		strText = _T("[") + toTstring(num) + _T("]") + strText;
	}

	int iOffset = !pGroup->hMetaContact?m_iFontHeight*0.8:m_iFontHeight*0.8+8;
	pGfx->DrawText(iOffset,0,pGfx->GetClipWidth()-iOffset,strText.c_str());

	if(bOpen)
		pGfx->DrawText(1,0,_T("-"));
	else
		pGfx->DrawText(1,0,_T("+"));
	
	if(bSelected && (GetTickCount() - m_dwLastScroll < 1000|| !CConfig::GetBoolSetting(CLIST_SELECTION)))
	{
		RECT invert2 = { 0,0,GetWidth(),m_iFontHeight};
		InvertRect(pGfx->GetHDC(),&invert2);
	}
}
Пример #5
0
//************************************************************************
// updates the message count for the specified contact
//************************************************************************
void CContactList::UpdateMessageCounter(CListEntry<CContactListEntry*,CContactListGroup*> *pContactEntry)
{
	CContactListEntry *pEntry = GetContactData(pContactEntry);
	if(!pEntry) {
		return;
	}
	int iOldMessages = pEntry->iMessages;

	bool bSort = false;
	HANDLE hEvent= NULL;

	hEvent = db_event_firstUnread(pEntry->hHandle);
	if(CAppletManager::IsMessageWindowOpen(pEntry->hHandle) || (hEvent == NULL && pEntry->iMessages > 0))
	{
		pEntry->iMessages = 0;
		bSort = true;
	}
	else
	{
		pEntry->iMessages = 0;
		HANDLE hLastEvent = db_event_last(pEntry->hHandle);
		while(hLastEvent != NULL && hEvent != NULL)
		{
			pEntry->iMessages++;
			if(hLastEvent == hEvent)
				break;
			hLastEvent = db_event_prev(hLastEvent);
		}
	}
	if(pEntry->iMessages >= 100)
		pEntry->strMessages = _T(">99");
	else
	{
		char buffer[8];
		buffer[0] = 0;
		itoa(pEntry->iMessages,buffer,10);
		pEntry->strMessages = toTstring(buffer);
	}

	CListContainer<CContactListEntry*,CContactListGroup*>* pContainer = ((CListContainer<CContactListEntry*,CContactListGroup*>*)pContactEntry->GetParent());
	// Update the contacts group if it has one
	if(pContainer->GetType() != ROOT)
	{
		// Update the groups event count
		if(iOldMessages != 0 && pEntry->iMessages == 0)
			ChangeGroupObjectCounters(pContainer->GetGroupData()->strPath,0,0,-1);
		else if(iOldMessages == 0 && pEntry->iMessages != 0)
			ChangeGroupObjectCounters(pContainer->GetGroupData()->strPath,0,0,1);
		else
			return;
		
		// sort the groups parent
		((CListContainer<CContactListEntry*,CContactListGroup*>*)pContainer->GetParent())->sort(CContactList::CompareEntries);
	}
}
Пример #6
0
//************************************************************************
// called when a contacts status has changed
//************************************************************************
void CContactList::OnStatusChange(MCONTACT hContact,int iStatus)
{
	// find the entry in the list
	CListEntry<CContactListEntry *,CContactListGroup*> *pContactEntry = FindContact(hContact);
	if(!pContactEntry)
	{
		AddContact(hContact);
		return;
	}
	
	
	CContactListEntry *pItemData = GetContactData(pContactEntry);
	if(!pItemData) {
		return;
	}
	// get the old status
	int iOldStatus = pItemData->iStatus;
		
	// Update the list entry
	TCHAR *szStatus = pcli->pfnGetStatusModeDescription(iStatus, 0);
	if(szStatus != NULL)
		pItemData->strStatus =toTstring(szStatus);
	
	pItemData->iStatus = iStatus;
	
	// update the contacts group
	CListContainer<CContactListEntry*,CContactListGroup*>* pGroup = ((CListContainer<CContactListEntry*,CContactListGroup*>*)pContactEntry->GetParent());
	if(pGroup->GetType() != ROOT)
	{
		if(!db_mc_isSub(hContact) && iStatus == ID_STATUS_OFFLINE && iOldStatus != ID_STATUS_OFFLINE)
			ChangeGroupObjectCounters(pGroup->GetGroupData()->strPath,0,-1);

		else if(!db_mc_isSub(hContact) && iStatus != ID_STATUS_OFFLINE && iOldStatus == ID_STATUS_OFFLINE)
			ChangeGroupObjectCounters(pGroup->GetGroupData()->strPath,0,1);
	}
	
	// check if the entry is still visible
	if(!IsVisible(pItemData))
	{
		RemoveContact(hContact);
		return;
	}

	// sort the list
	pGroup->sort(CContactList::CompareEntries);

}
Пример #7
0
//************************************************************************
// called when a contacts status has changed
//************************************************************************
void CContactList::OnStatusChange(HANDLE hContact,int iStatus)
{
	// find the entry in the list
	CListEntry<CContactListEntry *,CContactListGroup*> *pContactEntry = FindContact(hContact);
	if(!pContactEntry)
	{
		AddContact(hContact);
		return;
	}
	
	
	CContactListEntry *pItemData = GetContactData(pContactEntry);
	if(!pItemData) {
		return;
	}
	// get the old status
	int iOldStatus = pItemData->iStatus;
		
	// Update the list entry
	char *szStatus = (char *) CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, iStatus, 0);
	if(szStatus != NULL)
		pItemData->strStatus =toTstring(szStatus);
	
	pItemData->iStatus = iStatus;
	
	// update the contacts group
	CListContainer<CContactListEntry*,CContactListGroup*>* pGroup = ((CListContainer<CContactListEntry*,CContactListGroup*>*)pContactEntry->GetParent());
	if(pGroup->GetType() != ROOT)
	{
		if(!CAppletManager::IsSubContact(hContact) && iStatus == ID_STATUS_OFFLINE && iOldStatus != ID_STATUS_OFFLINE)
			ChangeGroupObjectCounters(pGroup->GetGroupData()->strPath,0,-1);

		else if(!CAppletManager::IsSubContact(hContact) && iStatus != ID_STATUS_OFFLINE && iOldStatus == ID_STATUS_OFFLINE)
			ChangeGroupObjectCounters(pGroup->GetGroupData()->strPath,0,1);
	}
	
	// check if the entry is still visible
	if(!IsVisible(pItemData))
	{
		RemoveContact(hContact);
		return;
	}

	// sort the list
	pGroup->sort(CContactList::CompareEntries);

}
Пример #8
0
//************************************************************************
// sets the screen's chat contact
//************************************************************************
bool CChatScreen::SetContact(MCONTACT hContact)
{
	if(hContact == NULL)
	{
		m_hContact = NULL;
		return true;
	}
	
	// Check if the contact is valid
	char *szProto = GetContactProto(hContact);
	m_strProto = toTstring(szProto);

	CIRCConnection *pIRCCon = CAppletManager::GetInstance()->GetIRCConnection(m_strProto);
	if(pIRCCon)
		m_bIRCProtocol = true;
	else
		m_bIRCProtocol = false;
			
			
	if(!szProto)
		return false;

	if(m_eReplyState != REPLY_STATE_NONE)
		DeactivateMessageMode();
	else if(IsMaximized())
		Minimize();

	m_bContactTyping = false;
	m_hContact = hContact;
	m_TextLog.ClearLog();
	UpdateLabels();

	LoadHistory();

	return true;
}
Пример #9
0
//************************************************************************
// adds a contact to the list
//************************************************************************
void CContactList::AddContact(MCONTACT hContact)
{
	CListContainer<CContactListEntry*,CContactListGroup*> *pGroup = NULL;

	tstring strName = CAppletManager::GetContactDisplayname(hContact);
	char *szProto = GetContactProto(hContact);
	
	tstring strGroup = GetContactGroupPath(hContact);
	// ignore contacts without a valid protocoll
	if(szProto == NULL)
		return;

	int iStatus = db_get_w(hContact,szProto,"Status",ID_STATUS_OFFLINE);
	TCHAR *szStatus = pcli->pfnGetStatusModeDescription(iStatus, 0);

	CContactListEntry *psContact = new CContactListEntry();

	psContact->strName = strName;
	psContact->iMessages = 0;
	psContact->hHandle = hContact;
	
	psContact->iStatus = iStatus;
	
	if(szStatus != NULL)
		psContact->strStatus =toTstring(szStatus);
	psContact->strProto = toTstring(szProto);

	// check wether the contact should be listed
	if(!IsVisible(psContact)) {
		delete psContact;
		return;
	}

	// Don't add metacontacts as contacts
	if(!mir_strcmpi(szProto,"MetaContacts"))
	{
		if(!CConfig::GetBoolSetting(CLIST_USEGROUPS))
			strGroup = _T("");
		strGroup += (strGroup.empty()?_T(""):_T("\\"))+psContact->strName;
		pGroup = GetGroupByString(strGroup);
		if(pGroup == NULL)
			pGroup = AddGroupByString(strGroup);
		pGroup->GetGroupData()->hMetaContact = hContact;
		pGroup->GetGroupData()->pContactListEntry = psContact;

		pGroup = (CListContainer<CContactListEntry*,CContactListGroup*>*)pGroup->GetParent();
		if(pGroup->GetType() != ROOT && iStatus != ID_STATUS_OFFLINE)
			ChangeGroupObjectCounters(pGroup->GetGroupData()->strPath,0,1);

		pGroup->sort(CContactList::CompareEntries);

		// check that all subcontacts exist
		int numContacts = db_mc_getSubCount(hContact);
		MCONTACT hSubContact = NULL;
		for(int i=0;i<numContacts;i++) {
			hSubContact = db_mc_getSub(hContact, i);
			RemoveContact(hSubContact);
			AddContact(hSubContact);
		}
		return;
	}
	else if(db_mc_isSub(hContact)) {
		MCONTACT hMetaContact = db_mc_getMeta(hContact);
		// check that the metacontact exists
		if(!FindContact(hMetaContact))
			AddContact(hMetaContact);
	}

	CListItem<CContactListEntry*,CContactListGroup*> *pItem = NULL;
	if((!db_mc_isSub(hContact) && !CConfig::GetBoolSetting(CLIST_USEGROUPS)) || strGroup.empty())
	{
		pItem = AddItem(psContact);
		((CListContainer<CContactListEntry*,CContactListGroup*>*)this)->sort(CContactList::CompareEntries);
	}
	else
	{
		pGroup = GetGroupByString(strGroup);
		if(pGroup == NULL) {
			pGroup = AddGroupByString(strGroup);
		}
		pItem = pGroup->AddItem(psContact);
	
		if(!db_mc_isSub(hContact) && iStatus != ID_STATUS_OFFLINE)
			ChangeGroupObjectCounters(pGroup->GetGroupData()->strPath,0,1);

		pGroup->sort(CContactList::CompareEntries);
	}

	UpdateMessageCounter((CListEntry<CContactListEntry*,CContactListGroup*>*)pItem);
}
Пример #10
0
void CConfig::LoadSettings()
{
	m_abBoolSettings[SKIP_DRIVER_ERROR] =				DBGetContactSettingDword(NULL, "MirandaG15", "SkipDriverError",0);

	m_abBoolSettings[SCREENSAVER_LOCK] =				DBGetContactSettingDword(NULL, "MirandaG15", "ScreensaverLock",1);
	m_abBoolSettings[NOTIFY_SHOWPROTO] =				DBGetContactSettingDword(NULL, "MirandaG15", "NotifyShowProto",0);
	m_abBoolSettings[NOTIFY_NICKCUTOFF] =				DBGetContactSettingDword(NULL, "MirandaG15", "NotifyNickCutoff",0);
	m_abBoolSettings[NOTIFY_CHANNELCUTOFF] =				DBGetContactSettingDword(NULL, "MirandaG15", "NotifyChannelCutoff",0);

	m_abBoolSettings[TRANSITIONS] =				DBGetContactSettingDword(NULL, "MirandaG15", "Transitions",0);
	m_abBoolSettings[TIMESTAMP_SECONDS] =		DBGetContactSettingDword(NULL, "MirandaG15", "TimestampSeconds",0);
	m_abBoolSettings[SESSION_TIMESTAMPS] =		DBGetContactSettingDword(NULL, "MirandaG15", "SessionTimestamps",0);
	m_abBoolSettings[NOTIFY_TIMESTAMPS] =		DBGetContactSettingDword(NULL, "MirandaG15", "NotifyTimestamps",0);

	m_abBoolSettings[CONTROL_BACKLIGHTS] =		DBGetContactSettingDword(NULL, "MirandaG15", "ControlBacklights",0);
	m_abBoolSettings[HOOK_VOLUMEWHEEL] =		DBGetContactSettingDword(NULL, "MirandaG15", "HookVolumeWheel",0);

	m_abBoolSettings[CLIST_SELECTION] =		DBGetContactSettingDword(NULL, "MirandaG15", "CListSelection",1);
	m_abBoolSettings[CLIST_COLUMNS] =		DBGetContactSettingDword(NULL, "MirandaG15", "CListColumns",0);
	m_abBoolSettings[CLIST_HIDEOFFLINE] =	DBGetContactSettingDword(NULL, "MirandaG15", "CListHideOffline",1);
	m_abBoolSettings[CLIST_USEIGNORE] =		DBGetContactSettingDword(NULL, "MirandaG15", "CListUseIgnore",1);
	m_abBoolSettings[CLIST_USEGROUPS] =		DBGetContactSettingDword(NULL, "MirandaG15", "CListUseGroups",1);
	m_abBoolSettings[CLIST_SHOWPROTO] =		DBGetContactSettingDword(NULL, "MirandaG15", "CListShowProto",1);
	m_abBoolSettings[CLIST_DRAWLINES] =		DBGetContactSettingDword(NULL, "MirandaG15", "CListDrawLines",1);
	m_abBoolSettings[CLIST_COUNTERS] =		DBGetContactSettingDword(NULL, "MirandaG15", "CListCounters",1);
	m_abBoolSettings[CLIST_POSITION] =		DBGetContactSettingDword(NULL, "MirandaG15", "CListPosition",0);

	m_abBoolSettings[NOTIFY_IRC_MESSAGES] =		DBGetContactSettingDword(NULL, "MirandaG15", "NotifyIRCMessages",	1);
	m_abBoolSettings[NOTIFY_IRC_USERS] =		DBGetContactSettingDword(NULL, "MirandaG15", "NotifyIRCUsers",		0);
	m_abBoolSettings[NOTIFY_IRC_EMOTES] =		DBGetContactSettingDword(NULL, "MirandaG15", "NotifyIRCEmotes",		0);
	m_abBoolSettings[NOTIFY_IRC_NOTICES] =		DBGetContactSettingDword(NULL, "MirandaG15", "NotifyIRCNotices",	1);
	m_abBoolSettings[NOTIFY_IRC_CHANNEL] =		DBGetContactSettingDword(NULL, "MirandaG15", "NotifyIRCChannel",	0);
	m_abBoolSettings[NOTIFY_IRC_STATUS] =		DBGetContactSettingDword(NULL, "MirandaG15", "NotifyIRCStatus",		0);

	m_abBoolSettings[NOTIFY_PROTO_STATUS] =	DBGetContactSettingDword(NULL, "MirandaG15", "NotifyProtoStatus",	0);
	m_abBoolSettings[NOTIFY_PROTO_SIGNON] =	DBGetContactSettingDword(NULL, "MirandaG15", "NotifyProtoSignOn",	1);
	m_abBoolSettings[NOTIFY_PROTO_SIGNOFF] =DBGetContactSettingDword(NULL, "MirandaG15", "NotifyProtoSignOff",	1);
	m_abBoolSettings[NOTIFY_MESSAGES] =		DBGetContactSettingDword(NULL, "MirandaG15", "NotifyMessages",		1);
	m_abBoolSettings[NOTIFY_SIGNON] =		DBGetContactSettingDword(NULL, "MirandaG15", "NotifySignOn",		1);
	m_abBoolSettings[NOTIFY_SIGNOFF] =		DBGetContactSettingDword(NULL, "MirandaG15", "NotifySignOff",		1);
	m_abBoolSettings[NOTIFY_STATUS] =		DBGetContactSettingDword(NULL, "MirandaG15", "NotifyStatus",		0);
	m_abBoolSettings[NOTIFY_SKIP_MESSAGES] =DBGetContactSettingDword(NULL, "MirandaG15", "NotifySkipMessages",	1);
	m_abBoolSettings[NOTIFY_SKIP_SIGNON] =	DBGetContactSettingDword(NULL, "MirandaG15", "NotifySkipSignOn",	0);
	m_abBoolSettings[NOTIFY_SKIP_SIGNOFF] =	DBGetContactSettingDword(NULL, "MirandaG15", "NotifySkipSignOff",	0);
	m_abBoolSettings[NOTIFY_SKIP_STATUS] =	DBGetContactSettingDword(NULL, "MirandaG15", "NotifySkipStatus",	1);
	m_abBoolSettings[NOTIFY_NO_SKIP_REPLY] =	DBGetContactSettingDword(NULL, "MirandaG15", "NotifyNoSkipReply",1);
	m_abBoolSettings[NOTIFY_URL] =			DBGetContactSettingDword(NULL, "MirandaG15", "NotifyURL",			1);
	m_abBoolSettings[NOTIFY_FILE] =			DBGetContactSettingDword(NULL, "MirandaG15", "NotifyFile",			1);
	m_abBoolSettings[NOTIFY_CONTACTS] =		DBGetContactSettingDword(NULL, "MirandaG15", "NotifyContacts",		1);
	
	m_abBoolSettings[SESSION_SCROLL_MAXIMIZED] = DBGetContactSettingDword(NULL, "MirandaG15", "SessionScrollMaximized",	1);
	m_abBoolSettings[SESSION_REPLY_MAXIMIZED] = DBGetContactSettingDword(NULL, "MirandaG15", "SessionReplyMaximized",	1);
	m_abBoolSettings[SESSION_LOADDB] =		DBGetContactSettingDword(NULL, "MirandaG15", "SessionLoadDB",		0);
	m_abBoolSettings[SESSION_MARKREAD] =	DBGetContactSettingDword(NULL, "MirandaG15", "SessionMarkRead",	1);
	m_abBoolSettings[SESSION_SENDRETURN] =	DBGetContactSettingDword(NULL, "MirandaG15", "SessionSendReturn",0);
	m_abBoolSettings[SESSION_SHOWTYPING] =	DBGetContactSettingDword(NULL, "MirandaG15", "SessionShowTyping",1);
	m_abBoolSettings[SESSION_SENDTYPING] =	DBGetContactSettingDword(NULL, "MirandaG15", "SessionSendTyping",1);
	m_abBoolSettings[SESSION_SYMBOLS] =	DBGetContactSettingDword(NULL, "MirandaG15", "SessionSymbols",0);
	m_abBoolSettings[SESSION_CLOSE] =	DBGetContactSettingDword(NULL, "MirandaG15", "SessionClose",1);
	
	m_abBoolSettings[SHOW_LABELS] = DBGetContactSettingDword(NULL, "MirandaG15", "ShowLabels",				1);
	m_abBoolSettings[MAXIMIZED_TITLE] = DBGetContactSettingDword(NULL, "MirandaG15", "MaximizedTitle",		0);
	m_abBoolSettings[MAXIMIZED_LABELS] = DBGetContactSettingDword(NULL, "MirandaG15", "MaximizedLabels",	1);

	m_aiIntSettings[NOTIFY_CHANNELCUTOFF_OFFSET] = DBGetContactSettingDword(NULL, "MirandaG15", "NotifyChannelCutoffOffset", 10);
	m_aiIntSettings[NOTIFY_NICKCUTOFF_OFFSET] = DBGetContactSettingDword(NULL, "MirandaG15", "NotifyNickCutoffOffset", 10);
	m_aiIntSettings[NOTIFY_DURATION] = DBGetContactSettingDword(NULL, "MirandaG15", "NotifyDuration",		4);
	m_aiIntSettings[NOTIFY_LOGSIZE] = DBGetContactSettingDword(NULL, "MirandaG15", "NotifyLogSize",			10);
	m_aiIntSettings[SESSION_LOGSIZE] = DBGetContactSettingDword(NULL, "MirandaG15", "SessionLogSize",		10);
	m_aiIntSettings[SESSION_AUTOSCROLL] = DBGetContactSettingDword(NULL, "MirandaG15", "SessionAutoScroll",	SESSION_AUTOSCROLL_FIRST);
	m_aiIntSettings[SESSION_CLOSETIMER] = DBGetContactSettingDword(NULL, "MirandaG15", "SessionCloseTimer",	15);
	m_aiIntSettings[NOTIFY_TITLE] = DBGetContactSettingDword(NULL, "MirandaG15", "NotifyTitle",			NOTIFY_TITLE_NAME);
	m_aiIntSettings[CLIST_GA] =	DBGetContactSettingDword(NULL, "MirandaG15", "CListGA",CLIST_GA_NONE);
	m_aiIntSettings[DEVICE] =	DBGetContactSettingDword(NULL, "MirandaG15", "Device",0);
	
	for(int i=0;i<FONT_SETTINGS;i++)
		LoadFontSettings(i);

	// Load protocol specific settings
	int iCount;
	int iProtoCount = 0;
	PROTOCOLDESCRIPTOR **ppProtocolDescriptor;
	CProtoFilter *pProtoFilter;
	tstring strSetting;

	CallService(MS_PROTO_ENUMPROTOCOLS,(WPARAM)&iCount,(LPARAM)&ppProtocolDescriptor);
	for(int i=0;i<iCount;i++)
	{
		if(ppProtocolDescriptor[i]->type != PROTOTYPE_PROTOCOL)
			continue;

		iProtoCount++;
		pProtoFilter = new CProtoFilter();
		pProtoFilter->strName = toTstring(ppProtocolDescriptor[i]->szName);
		
		strSetting = _T("ProtoFilter_") + pProtoFilter->strName;
		pProtoFilter->bNotificationFilter = DBGetContactSettingDword(NULL,"MirandaG15",toNarrowString(strSetting).c_str(),1);
		strSetting = _T("ProtoCListFilter_") + pProtoFilter->strName;
		pProtoFilter->bContactlistFilter = DBGetContactSettingDword(NULL,"MirandaG15",toNarrowString(strSetting).c_str(),1);
		m_ProtoList.push_back(pProtoFilter);
	}
}
Пример #11
0
//************************************************************************
// adds a contact to the list
//************************************************************************
void CContactList::AddContact(HANDLE hContact)
{
	CListContainer<CContactListEntry*,CContactListGroup*> *pGroup = NULL;

	tstring strName = CAppletManager::GetContactDisplayname(hContact);
	char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(UINT)hContact,0);
	
	tstring strGroup = GetContactGroupPath(hContact);
	// ignore contacts without a valid protocoll
	if(szProto == NULL)
		return;

	int iStatus = db_get_w(hContact,szProto,"Status",ID_STATUS_OFFLINE);
	char *szStatus = (char *) CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, iStatus, 0);

	CContactListEntry *psContact = new CContactListEntry();

	psContact->strName = strName;
	psContact->iMessages = 0;
	psContact->hHandle = hContact;
	
	psContact->iStatus = iStatus;
	
	if(szStatus != NULL)
		psContact->strStatus =toTstring(szStatus);
	psContact->strProto = toTstring(szProto);

	// check wether the contact should be listed
	if(!IsVisible(psContact)) {
		delete psContact;
		return;
	}

	// Don't add metacontacts as contacts
	if(!stricmp(szProto,"MetaContacts"))
	{
		if(!CConfig::GetBoolSetting(CLIST_USEGROUPS))
			strGroup = _T("");
		strGroup += (strGroup.empty()?_T(""):_T("\\"))+psContact->strName;
		pGroup = GetGroupByString(strGroup);
		if(pGroup == NULL)
			pGroup = AddGroupByString(strGroup);
		pGroup->GetGroupData()->hMetaContact = hContact;
		pGroup->GetGroupData()->pContactListEntry = psContact;

		pGroup = (CListContainer<CContactListEntry*,CContactListGroup*>*)pGroup->GetParent();
		if(pGroup->GetType() != ROOT && iStatus != ID_STATUS_OFFLINE)
			ChangeGroupObjectCounters(pGroup->GetGroupData()->strPath,0,1);

		pGroup->sort(CContactList::CompareEntries);

		// check that all subcontacts exist
		int numContacts = CallService(MS_MC_GETNUMCONTACTS,(WPARAM)hContact,0);
		HANDLE hSubContact = NULL;
		for(int i=0;i<numContacts;i++) {
			hSubContact = (HANDLE *) CallService(MS_MC_GETSUBCONTACT, (WPARAM)hContact, (LPARAM)i);
			RemoveContact(hSubContact);
			AddContact(hSubContact);
		}
		return;
	} else if(CAppletManager::IsSubContact(hContact)) {
		HANDLE hMetaContact = (HANDLE *) CallService(MS_MC_GETMETACONTACT, (WPARAM)hContact, 0);
		// check that the metacontact exists
		if(!FindContact(hMetaContact)) {
			AddContact(hMetaContact);
		}
	}

	CListItem<CContactListEntry*,CContactListGroup*> *pItem = NULL;
	if((!CAppletManager::IsSubContact(hContact) && !CConfig::GetBoolSetting(CLIST_USEGROUPS)) || strGroup.empty())
	{
		pItem = AddItem(psContact);
		((CListContainer<CContactListEntry*,CContactListGroup*>*)this)->sort(CContactList::CompareEntries);
	}
	else
	{
		pGroup = GetGroupByString(strGroup);
		if(pGroup == NULL) {
			pGroup = AddGroupByString(strGroup);
		}
		pItem = pGroup->AddItem(psContact);
	
		if(!CAppletManager::IsSubContact(hContact) && iStatus != ID_STATUS_OFFLINE)
			ChangeGroupObjectCounters(pGroup->GetGroupData()->strPath,0,1);

		pGroup->sort(CContactList::CompareEntries);
	}

	UpdateMessageCounter((CListEntry<CContactListEntry*,CContactListGroup*>*)pItem);
}