Beispiel #1
0
bool SkinOptionList_Update(OPTTREE_OPTION* &options, int *OptionsCount, HWND hwndDlg) {
	if (options) {
		int index = -1;
		OptTree_ProcessMessage(hwndDlg, WM_DESTROY, 0, 0, &index, IDC_SKIN_LIST_OPT, options, *OptionsCount);
		for (int i = 0; i < *OptionsCount; ++i) {
			mir_free(options[i].pszOptionName);
			mir_free(options[i].pszSettingName);
		}
		mir_free(options);
		options = NULL;
		*OptionsCount = 0;
	}
	// add "Global options"
	DWORD dwGlobalOptions = 0;
	int pos = SkinOptionList_AddMain(options, OptionsCount, 0, &dwGlobalOptions);
	// add "Skin options"
	DWORD dwSkinOptions = 0;
	pos = SkinOptionList_AddSkin(options, OptionsCount, pos, &dwSkinOptions);
	// generate treeview
	int index = -1;
	OptTree_ProcessMessage(hwndDlg, WM_INITDIALOG, 0, 0, &index, IDC_SKIN_LIST_OPT, options, *OptionsCount);

	// check "Skin options" state 
	char prefix[128];
	mir_snprintf(prefix, "skin.%S", PopupOptions.SkinPack);
	OptTree_SetOptions(hwndDlg, IDC_SKIN_LIST_OPT, options, *OptionsCount,
		db_get_dw(NULL, MODULNAME, prefix, dwSkinOptions), _T("Skin options"));

	// check "Global Settings"
	OptTree_SetOptions(hwndDlg, IDC_SKIN_LIST_OPT, options, *OptionsCount,
		dwGlobalOptions, _T("Global settings"));

	return true;
}
Beispiel #2
0
DWORD CMraProto::MraAvatarsQueueInitialize(HANDLE *phAvatarsQueueHandle)
{
	mir_snprintf(szAvtSectName, SIZEOF(szAvtSectName), "%s Avatars", m_szModuleName);

	if (phAvatarsQueueHandle == NULL)
		return ERROR_INVALID_HANDLE;

	MRA_AVATARS_QUEUE *pmraaqAvatarsQueue = new MRA_AVATARS_QUEUE();

	char szBuffer[MAX_PATH];
	mir_snprintf(szBuffer, SIZEOF(szBuffer), "%s %s", m_szModuleName, Translate("Avatars' plugin connections"));

	NETLIBUSER nlu = { sizeof(nlu) };
	nlu.flags = NUF_OUTGOING | NUF_HTTPCONNS;
	nlu.szSettingsModule = MRA_AVT_SECT_NAME;
	nlu.szDescriptiveName = szBuffer;
	pmraaqAvatarsQueue->hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
	if (pmraaqAvatarsQueue->hNetlibUser) {
		InterlockedExchange((volatile LONG*)&pmraaqAvatarsQueue->bIsRunning, TRUE);
		pmraaqAvatarsQueue->hThreadEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
		pmraaqAvatarsQueue->iThreadsCount = db_get_dw(NULL, MRA_AVT_SECT_NAME, "WorkThreadsCount", MRA_AVT_DEFAULT_WRK_THREAD_COUNTS);
		if (pmraaqAvatarsQueue->iThreadsCount == 0)
			pmraaqAvatarsQueue->iThreadsCount = 1;
		if (pmraaqAvatarsQueue->iThreadsCount > MAXIMUM_WAIT_OBJECTS)
			pmraaqAvatarsQueue->iThreadsCount = MAXIMUM_WAIT_OBJECTS;
		for (int i = 0; i < pmraaqAvatarsQueue->iThreadsCount; i++)
			pmraaqAvatarsQueue->hThread[i] = ForkThreadEx(&CMraProto::MraAvatarsThreadProc, pmraaqAvatarsQueue, 0);

		*phAvatarsQueueHandle = (HANDLE)pmraaqAvatarsQueue;
	}

	return NO_ERROR;
}
Beispiel #3
0
VOID CALLBACK TimerProc(HWND, UINT, UINT_PTR, DWORD)
{
	time_t t = time(NULL);
	time_t diff = t - (time_t)db_get_dw(0, "AutoBackups", "LastBackupTimestamp", 0);
	if (diff > (time_t)(options.period * (options.period_type == PT_MINUTES ? 60 : (options.period_type == PT_HOURS ? (60 * 60) : (60 * 60 * 24)))))
		BackupStart(NULL);
}
Beispiel #4
0
void fnGetFontSetting(int i, LOGFONT* lf, COLORREF* colour)
{
	DBVARIANT dbv;
	char idstr[20];
	BYTE style;

	cli.pfnGetDefaultFontSetting(i, lf, colour);
	mir_snprintf(idstr, SIZEOF(idstr), "Font%dName", i);
	if (!db_get_ts(NULL, "CLC", idstr, &dbv)) {
		lstrcpy(lf->lfFaceName, dbv.ptszVal);
		mir_free(dbv.pszVal);
	}
	mir_snprintf(idstr, SIZEOF(idstr), "Font%dCol", i);
	*colour = db_get_dw(NULL, "CLC", idstr, *colour);
	mir_snprintf(idstr, SIZEOF(idstr), "Font%dSize", i);
	lf->lfHeight = (char) db_get_b(NULL, "CLC", idstr, lf->lfHeight);
	mir_snprintf(idstr, SIZEOF(idstr), "Font%dSty", i);
	style = (BYTE) db_get_b(NULL, "CLC", idstr, (lf->lfWeight == FW_NORMAL ? 0 : DBFONTF_BOLD) | (lf->lfItalic ? DBFONTF_ITALIC : 0) | (lf->lfUnderline ? DBFONTF_UNDERLINE : 0));
	lf->lfWidth = lf->lfEscapement = lf->lfOrientation = 0;
	lf->lfWeight = style & DBFONTF_BOLD ? FW_BOLD : FW_NORMAL;
	lf->lfItalic = (style & DBFONTF_ITALIC) != 0;
	lf->lfUnderline = (style & DBFONTF_UNDERLINE) != 0;
	lf->lfStrikeOut = 0;
	mir_snprintf(idstr, SIZEOF(idstr), "Font%dSet", i);
	lf->lfCharSet = db_get_b(NULL, "CLC", idstr, lf->lfCharSet);
	lf->lfOutPrecision = OUT_DEFAULT_PRECIS;
	lf->lfClipPrecision = CLIP_DEFAULT_PRECIS;
	lf->lfQuality = DEFAULT_QUALITY;
	lf->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
}
Beispiel #5
0
//gets the handle for the default contact
//wParam=(HANDLE)hMetaContact
//lParam=0
//returns a handle to the default contact, or null on failure
INT_PTR MetaAPI_GetDefault(WPARAM wParam, LPARAM lParam) {
	DWORD default_contact_number = db_get_dw((HANDLE)wParam, META_PROTO, "Default", -1);
	if (default_contact_number != -1) {
		return (INT_PTR)Meta_GetContactHandle((HANDLE)wParam, default_contact_number);
	}
	return 0;
}
Beispiel #6
0
void ReportSendQueueTimeouts(HWND hwndSender)
{
	MessageSendQueueItem *item, *item2;
	int timeout = db_get_dw(NULL, SRMMMOD, SRMSGSET_MSGTIMEOUT, SRMSGDEFSET_MSGTIMEOUT);

	mir_cslock lock(queueMutex);

	for (item = global_sendQueue; item != NULL; item = item2) {
		item2 = item->next;
		if (item->timeout < timeout) {
			item->timeout += 1000;
			if (item->timeout >= timeout) {
				if (item->hwndSender == hwndSender && item->hwndErrorDlg == NULL) {
					if (hwndSender != NULL) {
						ErrorWindowData *ewd = (ErrorWindowData *) mir_alloc(sizeof(ErrorWindowData));
						ewd->szName = GetNickname(item->hContact, item->proto);
						ewd->szDescription = mir_tstrdup(TranslateT("The message send timed out."));
						ewd->szText = GetSendBufferMsg(item);
						ewd->hwndParent = hwndSender;
						ewd->queueItem = item;
						PostMessage(hwndSender, DM_SHOWERRORMESSAGE, 0, (LPARAM)ewd);
					} else {
						/* TODO: Handle errors outside messaging window in a better way */
						RemoveSendQueueItem(item);
					}
				}
			}
		}
	}
}
Beispiel #7
0
void TlenGetAvatarFileName(TlenProtocol *proto, TLEN_LIST_ITEM *item, TCHAR* ptszDest, int cbLen)
{
	
	int tPathLen = mir_sntprintf(ptszDest, cbLen, TEXT("%s\\%S"), VARST( TEXT("%miranda_avatarcache%")), proto->m_szModuleName);
	if (_taccess(ptszDest, 0)) {
		int ret = CreateDirectoryTreeT(ptszDest);
		if (ret == 0)
			proto->debugLog(_T("getAvatarFilename(): Created new directory for avatar cache: %s."), ptszDest);
		else {
			proto->debugLog(_T("getAvatarFilename(): Can not create directory for avatar cache: %s. errno=%d: %s"), ptszDest, errno, strerror(errno));
			TCHAR buffer[512];
			mir_sntprintf(buffer, _countof(buffer), TranslateT("Cannot create avatars cache directory. ERROR: %d: %s\n%s"), errno, _tcserror(errno), ptszDest);
			PUShowMessageT(buffer, SM_WARNING);
		}
	}

	int format = PA_FORMAT_PNG;

	ptszDest[ tPathLen++ ] = '\\';
	if (item != NULL)
		format = item->avatarFormat;
	else if (proto->threadData != NULL)
		format = proto->threadData->avatarFormat;
	else
		format = db_get_dw(NULL, proto->m_szModuleName, "AvatarFormat", PA_FORMAT_UNKNOWN);

	const TCHAR *tszFileType = ProtoGetAvatarExtension(format);
	if ( item != NULL )
		mir_sntprintf(ptszDest + tPathLen, MAX_PATH - tPathLen, TEXT("%S%s"), ptrA( TlenSha1(item->jid)), tszFileType);
	else
		mir_sntprintf(ptszDest + tPathLen, MAX_PATH - tPathLen, TEXT("%S_avatar%s"), proto->m_szModuleName, tszFileType);
}
Beispiel #8
0
static void CreateBackgroundBrush()
{
	bkColor = db_get_dw(NULL, MODULE, "BkColor", FLT_DEFAULT_BKGNDCOLOR);

	if (NULL != hLTEdgesPen) {
		DeleteObject(hLTEdgesPen);
		hLTEdgesPen = NULL;
	}

	if (NULL != hRBEdgesPen) {
		DeleteObject(hRBEdgesPen);
		hRBEdgesPen = NULL;
	}

	if (NULL != hBmpBackground) {
		DeleteObject(hBmpBackground);
		hBmpBackground = NULL;
	}

	if (NULL != hBkBrush) {
		SetClassLong((HWND)WND_CLASS, GCLP_HBRBACKGROUND, (LONG)NULL);
		DeleteObject( hBkBrush );
		hBkBrush = NULL;
	}

	if ( db_get_b(NULL, MODULE, "DrawBorder", FLT_DEFAULT_DRAWBORDER)) {
		COLORREF cr = (COLORREF)db_get_dw(NULL, MODULE, "LTEdgesColor", FLT_DEFAULT_LTEDGESCOLOR);
		hLTEdgesPen = CreatePen(PS_SOLID, 1, cr);
		cr = (COLORREF)db_get_dw(NULL, MODULE, "RBEdgesColor", FLT_DEFAULT_RBEDGESCOLOR);
		hRBEdgesPen = CreatePen(PS_SOLID, 1, cr);
	}
	
	if (db_get_b(NULL, MODULE, "BkUseBitmap", FLT_DEFAULT_BKGNDUSEBITMAP)) {
		DBVARIANT dbv;
		if ( !db_get_ts(NULL, MODULE, "BkBitmap", &dbv)) {
			hBmpBackground = (HBITMAP)CallService(MS_UTILS_LOADBITMAPT, 0, (LPARAM)dbv.ptszVal);
			db_free(&dbv);
		}
	}
	nBackgroundBmpUse = (WORD)db_get_w(NULL, MODULE, "BkBitmapOpt", FLT_DEFAULT_BKGNDBITMAPOPT);

	// Create brush
	hBkBrush	 = CreateSolidBrush(bkColor);

	// Attach brush to the window
	SetClassLong((HWND)WND_CLASS, GCLP_HBRBACKGROUND, (LONG)hBkBrush);
}
Beispiel #9
0
int ThreadData::sendMessage(int msgType, const char* email, int netId, const char* parMsg, int parFlags)
{
	char buf[2048];
	int off;

	off = mir_snprintf(buf, sizeof(buf), "MIME-Version: 1.0\r\n");

	if ((parFlags & MSG_DISABLE_HDR) == 0) {
		char  tFontName[100], tFontStyle[3];
		DWORD tFontColor;

		strcpy(tFontName, "Arial");

		if (proto->getByte("SendFontInfo", 1)) {
			char* p;

			DBVARIANT dbv;
			if (!db_get_s(NULL, "SRMsg", "Font0", &dbv)) {
				for (p = dbv.pszVal; *p; p++)
					if (BYTE(*p) >= 128 || *p < 32)
						break;

				if (*p == 0) {
					strncpy_s(tFontName, sizeof(tFontName), ptrA(mir_urlEncode(dbv.pszVal)), _TRUNCATE);
					db_free(&dbv);
				}
			}

			int  tStyle = db_get_b(NULL, "SRMsg", "Font0Sty", 0);
			p = tFontStyle;
			if (tStyle & 1) *p++ = 'B';
			if (tStyle & 2) *p++ = 'I';
			*p = 0;

			tFontColor = db_get_dw(NULL, "SRMsg", "Font0Col", 0);
		}
		else {
			tFontColor = 0;
			tFontStyle[0] = 0;
		}

		if (parFlags & MSG_OFFLINE)
			off += mir_snprintf(buf + off, sizeof(buf) - off, "Dest-Agent: client\r\n");

		off += mir_snprintf(buf + off, sizeof(buf) - off, "Content-Type: text/plain; charset=UTF-8\r\n");
		off += mir_snprintf(buf + off, sizeof(buf) - off, "X-MMS-IM-Format: FN=%s; EF=%s; CO=%x; CS=0; PF=31%s\r\n\r\n",
			tFontName, tFontStyle, tFontColor, (parFlags & MSG_RTL) ? ";RL=1" : "");
	}

	int seq;
	if (netId == NETID_YAHOO || netId == NETID_MOB || (parFlags & MSG_OFFLINE))
		seq = sendPacket("UUM", "%s %d %c %d\r\n%s%s", email, netId, msgType,
		strlen(parMsg)+off, buf, parMsg);
	else
		seq = sendPacket("MSG", "%c %d\r\n%s%s", msgType,
		strlen(parMsg)+off, buf, parMsg);

	return seq;
}
Beispiel #10
0
static void OnLoadSettings()
{
	if (g_Settings.MessageAreaFont)
		DeleteObject(g_Settings.MessageAreaFont);

	LOGFONT lf;
	LoadMessageFont(&lf, &g_Settings.MessageAreaColor);
	g_Settings.MessageAreaFont = CreateFontIndirect(&lf);

	g_Settings.iX = db_get_dw(NULL, CHAT_MODULE, "roomx", -1);
	g_Settings.iY = db_get_dw(NULL, CHAT_MODULE, "roomy", -1);

	g_Settings.bTabsEnable = db_get_b(NULL, CHAT_MODULE, "Tabs", 1) != 0;
	g_Settings.TabRestore = db_get_b(NULL, CHAT_MODULE, "TabRestore", 0) != 0;
	g_Settings.TabsAtBottom = db_get_b(NULL, CHAT_MODULE, "TabBottom", 0) != 0;
	g_Settings.TabCloseOnDblClick = db_get_b(NULL, CHAT_MODULE, "TabCloseOnDblClick", 0) != 0;
}
DWORD CSkinnedProfile::SpiGetSkinDword( HANDLE hContact, const char * szSection, const char * szKey, const DWORD defValue )
{
	if ( hContact ) 
		return db_get_dw( hContact, szSection, szKey, defValue ); //per-contact settings are not skinnablr at all

	CAutoCriticalSection Lock( SkinProfile()->_Lock, true );

	ValueVariant* value = SkinProfile()->_GetValue( szSection, szKey );

	if ( value == NULL ) // not skinned => return DB
		return db_get_dw( hContact, szSection, szKey, defValue );
	
	else if ( !value->IsEmpty() ) 
		return value->GetDword();	
	
	return defValue; // skinned but empty => return default value
}
Beispiel #12
0
static void CreateBackgroundBrush()
{
	bkColor = db_get_dw(NULL, MODULE, "BkColor", FLT_DEFAULT_BKGNDCOLOR);

	if (NULL != hLTEdgesPen) {
		DeleteObject(hLTEdgesPen);
		hLTEdgesPen = NULL;
	}

	if (NULL != hRBEdgesPen) {
		DeleteObject(hRBEdgesPen);
		hRBEdgesPen = NULL;
	}

	if (NULL != hBmpBackground) {
		DeleteObject(hBmpBackground);
		hBmpBackground = NULL;
	}

	if (NULL != hBkBrush) {
		SetClassLong((HWND)WND_CLASS, GCLP_HBRBACKGROUND, (LONG)NULL);
		DeleteObject(hBkBrush);
		hBkBrush = NULL;
	}

	if (db_get_b(NULL, MODULE, "DrawBorder", FLT_DEFAULT_DRAWBORDER)) {
		COLORREF cr = (COLORREF)db_get_dw(NULL, MODULE, "LTEdgesColor", FLT_DEFAULT_LTEDGESCOLOR);
		hLTEdgesPen = CreatePen(PS_SOLID, 1, cr);
		cr = (COLORREF)db_get_dw(NULL, MODULE, "RBEdgesColor", FLT_DEFAULT_RBEDGESCOLOR);
		hRBEdgesPen = CreatePen(PS_SOLID, 1, cr);
	}

	if (db_get_b(NULL, MODULE, "BkUseBitmap", FLT_DEFAULT_BKGNDUSEBITMAP)) {
		ptrT tszBitmapName(db_get_tsa(NULL, MODULE, "BkBitmap"));
		if (tszBitmapName != NULL)
			hBmpBackground = Bitmap_Load(tszBitmapName);
	}
	nBackgroundBmpUse = (WORD)db_get_w(NULL, MODULE, "BkBitmapOpt", FLT_DEFAULT_BKGNDBITMAPOPT);

	// Create brush
	hBkBrush = CreateSolidBrush(bkColor);

	// Attach brush to the window
	SetClassLongPtr((HWND)WND_CLASS, GCLP_HBRBACKGROUND, (LONG_PTR)hBkBrush);
}
Beispiel #13
0
int UpdateTimers()
{
	KillTimers();
	int interval;
	interval = db_get_dw(NULL, ModuleName, "Interval", DEFAULT_INTERVAL);
	interval *= 1000; //go from miliseconds to seconds
	hCheckTimer = SetTimer(NULL, 0, interval, (TIMERPROC) OnCheckTimer);
	
	int bReconnect = db_get_b(NULL, ModuleName, "Reconnect", 0);
	if (bReconnect) //user wants to forcefully reconnect every x minutes
		{
			interval = db_get_dw(NULL, ModuleName, "ReconnectInterval", DEFAULT_RECONNECT_INTERVAL);
			interval *= 1000 * 60; //go from miliseconds to seconds to minutes
			hReconnectTimer = SetTimer(NULL, 0, interval, (TIMERPROC) OnReconnectTimer);
		}
	
	return 0;
}
Beispiel #14
0
// main auto-update timer
VOID CALLBACK timerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
{
	// only run if it is not current updating and the auto update option is enabled
	if (!ThreadRunning && !Miranda_Terminated()) {
		BOOL HaveUpdates = FALSE;
		for (MCONTACT hContact = db_find_first(MODULE); hContact; hContact = db_find_next(hContact, MODULE)) {
			if (db_get_dw(hContact, MODULE, "UpdateTime", DEFAULT_UPDATE_TIME)) {
				double diff = difftime(time(NULL), db_get_dw(hContact, MODULE, "LastCheck", 0));
				if (db_get_b(NULL, MODULE, "AutoUpdate", 1) != 0 && diff >= db_get_dw(hContact, MODULE, "UpdateTime", DEFAULT_UPDATE_TIME) * 60) {
					UpdateListAdd(hContact);
					HaveUpdates = TRUE;
				}
			}
		}
		if (!ThreadRunning && HaveUpdates)
			mir_forkthread(UpdateThreadProc, (LPVOID)FALSE);
	}
}
Beispiel #15
0
int CheckDate(MCONTACT hContact)
{
	time_t curtime = time (NULL);
	if(!db_get_b(hContact,modname,"GiveUpDays",0))
		return 1;
	if(db_get_b(hContact,modname,"GiveUpDays",0) && ( abs((time_t)db_get_dw(hContact,modname,"GiveUpDate",0)) > curtime))
		return 1;
	return 0;
}
Beispiel #16
0
ClcContact* AddContactToGroup(struct ClcData *dat, ClcGroup *group, MCONTACT hContact)
{
	ClcContact *p = coreCli.pfnAddContactToGroup(dat, group, hContact);

	p->wStatus = db_get_w(hContact, p->proto, "Status", ID_STATUS_OFFLINE);
	p->xStatus = db_get_b(hContact, p->proto, "XStatusId", 0);

	if (p->proto)
		p->bIsMeta = !mir_strcmp(p->proto, META_PROTO);
	else
		p->bIsMeta = FALSE;
	if (p->bIsMeta && !(cfg::dat.dwFlags & CLUI_USEMETAICONS)) {
		p->hSubContact = db_mc_getMostOnline(hContact);
		p->metaProto = GetContactProto(p->hSubContact);
		p->iImage = pcli->pfnGetContactIcon(p->hSubContact);
	}
	else {
		p->iImage = pcli->pfnGetContactIcon(hContact);
		p->metaProto = NULL;
	}

	p->codePage = db_get_dw(hContact, "Tab_SRMsg", "ANSIcodepage", db_get_dw(hContact, "UserInfo", "ANSIcodepage", CP_ACP));
	p->bSecondLine = db_get_b(hContact, "CList", "CLN_2ndline", cfg::dat.dualRowMode);

	if (dat->bisEmbedded)
		p->pExtra = 0;
	else {
		p->pExtra = cfg::getCache(p->hContact, p->proto);
		GetExtendedInfo(p, dat);
		if (p->pExtra)
			p->pExtra->proto_status_item = GetProtocolStatusItem(p->bIsMeta ? p->metaProto : p->proto);

		LoadAvatarForContact(p);
		// notify other plugins to re-supply their extra images (icq for xstatus, mBirthday etc...)
		pcli->pfnSetAllExtraIcons(hContact);
	}

	RTL_DetectAndSet(p, p->hContact);

	p->avatarLeft = p->extraIconRightBegin = -1;
	p->flags |= db_get_b(p->hContact, "CList", "Priority", 0) ? CONTACTF_PRIORITY : 0;

	return p;
}
Beispiel #17
0
int LoadStatusBarData()
{
	g_StatusBarData.perProtoConfig = db_get_b(NULL, "CLUI", "SBarPerProto", SETTING_SBARPERPROTO_DEFAULT);
	g_StatusBarData.bShowProtoIcon = (db_get_b(NULL, "CLUI", "SBarShow", SETTING_SBARSHOW_DEFAULT) & 1) != 0;
	g_StatusBarData.bShowProtoName = (db_get_b(NULL, "CLUI", "SBarShow", SETTING_SBARSHOW_DEFAULT) & 2) != 0;
	g_StatusBarData.bShowStatusName = (db_get_b(NULL, "CLUI", "SBarShow", SETTING_SBARSHOW_DEFAULT) & 4) != 0;
	g_StatusBarData.xStatusMode = db_get_b(NULL, "CLUI", "ShowXStatus", SETTING_SHOWXSTATUS_DEFAULT);
	g_StatusBarData.bConnectingIcon = db_get_b(NULL, "CLUI", "UseConnectingIcon", SETTING_USECONNECTINGICON_DEFAULT) != 0;
	g_StatusBarData.bShowProtoEmails = db_get_b(NULL, "CLUI", "ShowUnreadEmails", SETTING_SHOWUNREADEMAILS_DEFAULT) != 0;
	g_StatusBarData.SBarRightClk = db_get_b(NULL, "CLUI", "SBarRightClk", SETTING_SBARRIGHTCLK_DEFAULT);

	g_StatusBarData.nProtosPerLine = db_get_b(NULL, "CLUI", "StatusBarProtosPerLine", SETTING_PROTOSPERLINE_DEFAULT);
	g_StatusBarData.Align = db_get_b(NULL, "CLUI", "Align", SETTING_ALIGN_DEFAULT);
	g_StatusBarData.VAlign = db_get_b(NULL, "CLUI", "VAlign", SETTING_VALIGN_DEFAULT);
	g_StatusBarData.sameWidth = db_get_b(NULL, "CLUI", "EqualSections", SETTING_EQUALSECTIONS_DEFAULT);
	g_StatusBarData.rectBorders.left = db_get_dw(NULL, "CLUI", "LeftOffset", SETTING_LEFTOFFSET_DEFAULT);
	g_StatusBarData.rectBorders.right = db_get_dw(NULL, "CLUI", "RightOffset", SETTING_RIGHTOFFSET_DEFAULT);
	g_StatusBarData.rectBorders.top = db_get_dw(NULL, "CLUI", "TopOffset", SETTING_TOPOFFSET_DEFAULT);
	g_StatusBarData.rectBorders.bottom = db_get_dw(NULL, "CLUI", "BottomOffset", SETTING_BOTTOMOFFSET_DEFAULT);
	g_StatusBarData.extraspace = (BYTE)db_get_dw(NULL, "CLUI", "SpaceBetween", SETTING_SPACEBETWEEN_DEFAULT);

	if (g_StatusBarData.BarFont) {
		DeleteObject(g_StatusBarData.BarFont);
		g_StatusBarData.BarFont = NULL;
	}

	int vis = db_get_b(NULL, "CLUI", "ShowSBar", SETTING_SHOWSBAR_DEFAULT);
	int frameID = Sync(FindFrameID, hModernStatusBar);
	int frameopt = CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_FLAGS, frameID), 0);
	frameopt = frameopt & (~F_VISIBLE);
	if (vis) {
		ShowWindow(hModernStatusBar, SW_SHOW);
		frameopt |= F_VISIBLE;
	}
	else ShowWindow(hModernStatusBar, SW_HIDE);
	CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS, MAKEWPARAM(FO_FLAGS, frameID), frameopt);

	g_StatusBarData.TextEffectID = db_get_b(NULL, "StatusBar", "TextEffectID", SETTING_TEXTEFFECTID_DEFAULT);
	g_StatusBarData.TextEffectColor1 = db_get_dw(NULL, "StatusBar", "TextEffectColor1", SETTING_TEXTEFFECTCOLOR1_DEFAULT);
	g_StatusBarData.TextEffectColor2 = db_get_dw(NULL, "StatusBar", "TextEffectColor2", SETTING_TEXTEFFECTCOLOR2_DEFAULT);

	if (g_StatusBarData.hBmpBackground) { DeleteObject(g_StatusBarData.hBmpBackground); g_StatusBarData.hBmpBackground = NULL; }

	if (g_CluiData.fDisableSkinEngine) {
		DBVARIANT dbv;
		g_StatusBarData.bkColour = sttGetColor("StatusBar", "BkColour", CLCDEFAULT_BKCOLOUR);
		if (db_get_b(NULL, "StatusBar", "UseBitmap", CLCDEFAULT_USEBITMAP)) {
			if (!db_get_s(NULL, "StatusBar", "BkBitmap", &dbv)) {
				g_StatusBarData.hBmpBackground = (HBITMAP)CallService(MS_UTILS_LOADBITMAP, 0, (LPARAM)dbv.pszVal);
				db_free(&dbv);
			}
		}
		g_StatusBarData.bkUseWinColors = db_get_b(NULL, "StatusBar", "UseWinColours", CLCDEFAULT_USEWINDOWSCOLOURS);
		g_StatusBarData.backgroundBmpUse = db_get_w(NULL, "StatusBar", "BkBmpUse", CLCDEFAULT_BKBMPUSE);
	}
	
	SendMessage(pcli->hwndContactList, WM_SIZE, 0, 0);
	return 1;
}
Beispiel #18
0
void popupWatchedVar(MCONTACT hContact,const char* module,const char* setting)
{
	HICON hIcon = LoadIcon(hInst, MAKEINTRESOURCE(ICO_REGEDIT));
	char lpzContactName[MAX_CONTACTNAME];
	char lpzText[MAX_SECONDLINE];
	COLORREF colorBack = db_get_dw(NULL,modname,"PopupColour",RGB(255,0,0));
	COLORREF colorText = RGB(0,0,0);
	int timeout = db_get_b(NULL,modname,"PopupDelay",3);

	if (hContact) {
		// contacts nick
		char szProto[256];
		if (GetValue(hContact,"Protocol","p",szProto,SIZEOF(szProto)))
			mir_snprintf(lpzContactName, MAX_SECONDLINE, "%s (%s)", (char*)GetContactName(hContact, szProto, 0), szProto);
		else
			mir_snprintf(lpzContactName, MAX_SECONDLINE, nick_unknown);
	}
	else strcpy(lpzContactName,Translate("Settings"));

	// 2nd line
	DBVARIANT dbv;
	if ( GetSetting(hContact, module, setting, &dbv))
		return;

	switch (dbv.type) {
	case DBVT_BYTE:
		mir_snprintf(lpzText, SIZEOF(lpzText), Translate("Database Setting Changed: \nModule: \"%s\" , Setting: \"%s\"\nNew Value: (BYTE) %d"), module, setting, dbv.bVal);
		break;
	case DBVT_WORD:
		mir_snprintf(lpzText, SIZEOF(lpzText), Translate("Database Setting Changed: \nModule: \"%s\" , Setting: \"%s\"\nNew Value: (WORD) %d"), module, setting, dbv.wVal);
		break;
	case DBVT_DWORD:
		mir_snprintf(lpzText, SIZEOF(lpzText), Translate("Database Setting Changed: \nModule: \"%s\" , Setting: \"%s\"\nNew Value: (DWORD) 0x%X"), module, setting, dbv.dVal);
		break;
	case DBVT_ASCIIZ:
		mir_snprintf(lpzText, SIZEOF(lpzText), Translate("Database Setting Changed: \nModule: \"%s\" , Setting: \"%s\"\nNew Value: \"%s\""), module, setting, dbv.pszVal);
		break;
	case DBVT_UTF8:
		mir_snprintf(lpzText, SIZEOF(lpzText), Translate("Database Setting Changed: \nModule: \"%s\" , Setting: \"%s\"\nNew Value (UTF8): \"%s\""), module, setting, dbv.pszVal);
		break;
	default:
		return;
	}

	db_free(&dbv);

	POPUPDATA ppd = { 0 };
	ppd.lchContact = (MCONTACT)hContact;
	ppd.lchIcon = hIcon;
	lstrcpyn(ppd.lpzContactName, lpzContactName,MAX_CONTACTNAME);
	lstrcpyn(ppd.lpzText, lpzText,MAX_SECONDLINE);
	ppd.colorBack = colorBack;
	ppd.colorText = colorText;
	ppd.iSeconds = timeout ? timeout : -1;
	PUAddPopup(&ppd);
}
Beispiel #19
0
static INT_PTR sttGetColourWorker(ColourIDW* colour_id)
{
	for (int i=0; i < colour_id_list.getCount(); i++) {
		ColourInternal& C = colour_id_list[i];
		if (!_tcscmp(C.group, colour_id->group) && !_tcscmp(C.name, colour_id->name))
			return db_get_dw(NULL, C.dbSettingsGroup, C.setting, GetColorFromDefault(C.defcolour));
	}

	return -1;
}
Beispiel #20
0
BOOL contactCheckProtocol(char *szProto, MCONTACT hContact, WORD eventType)
{
	if (bMetaProtoEnabled && hContact) {
		MCONTACT hMetaContact = (MCONTACT)db_get_dw(hContact, META_PROTO, "Handle", 0);
		if (hMetaContact && db_mc_getMeta(hContact) == hMetaContact)
			return FALSE;
	}

	return (metaCheckProtocol(szProto, hContact, eventType));
}
Beispiel #21
0
void StartUpdate(void *dummy)
{
	StartUpDelay = 1;
	Sleep(((db_get_dw(NULL, MODULENAME, START_DELAY_KEY, 0)) * SECOND));

	for (MCONTACT hContact = db_find_first(MODULENAME); hContact != NULL; hContact = db_find_next(hContact, MODULENAME))
		GetData((void*)hContact);

	StartUpDelay = 0;
}
Beispiel #22
0
bool HasUnread(MCONTACT hContact)
{
	const char *szProto = GetContactProto(hContact);
	if (CheckProtoSupport(szProto))
	{
		return ((GetLastSentMessageTime(hContact) > db_get_dw(hContact, MODULENAME, DBKEY_MESSAGE_READ_TIME, 0)) && db_get_dw(hContact, MODULENAME, DBKEY_MESSAGE_READ_TIME, 0) != 0);
	}

	return false;
}
Beispiel #23
0
int UpdateTimers()
{
	UINT interval = db_get_dw(NULL, ModuleName, "Interval", CHECK_INTERVAL);
	interval *= (1000 * 60 * 60); //go from miliseconds to hours
	hCheckTimer = SetTimer(NULL, 0, interval, OnCheckTimer);
	if (!hDateChangeTimer)
		hDateChangeTimer = SetTimer(NULL, 0, (1000 * DATE_CHANGE_CHECK_INTERVAL), OnDateChangeTimer);

	return 0;
}
Beispiel #24
0
void LoadConfig()
{
	char szNameFG[4];
	char szNameBG[4];
	char szNameTO[4];
	int indx;

	for(indx = 0; indx < 4; indx++)
	{
		mir_snprintf(szNameFG, SIZEOF(szNameFG), "FG%d", indx);
		mir_snprintf(szNameBG, SIZEOF(szNameBG), "BG%d", indx);
		mir_snprintf(szNameTO, SIZEOF(szNameTO), "TO%d", indx);
		options.FG[indx] = db_get_dw(NULL, SERVICENAME, szNameFG, optionsDefault.FG[indx]);
		options.BG[indx] = db_get_dw(NULL, SERVICENAME, szNameBG, optionsDefault.BG[indx]);
		options.Timeout[indx] = db_get_dw(NULL, SERVICENAME, szNameTO, (DWORD)optionsDefault.Timeout[indx]);
	}
	options.Sound = db_get_b(NULL, SERVICENAME, "Sound", (DWORD)optionsDefault.Sound);

}
Beispiel #25
0
static INT_PTR CALLBACK icqUserInfoDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    LPNMHDR hdr;

    switch (msg)
    {
    case WM_INITDIALOG:
        TranslateDialogDefault(hWnd);
        return TRUE;

    case WM_NOTIFY:
        hdr = (LPNMHDR)lParam;
        if (hdr->idFrom == 0 && hdr->code == PSN_INFOCHANGED)
        {
            char buffer[64];
            unsigned long ip, port;
			MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam;

            _itoa(db_get_dw(hContact, protoName, "UIN", 0), buffer, 10);
            setTextValue(hWnd, IDC_INFO_UIN, buffer);

            ip = db_get_dw(hContact, protoName, "IP", 0);
            setTextValue(hWnd, IDC_INFO_IP, ip ? iptoa(ip) : NULL);

            ip = db_get_dw(hContact, protoName, "RealIP", 0);
            setTextValue(hWnd, IDC_INFO_REALIP, ip ? iptoa(ip) : NULL);

            port = db_get_w(hContact, protoName, "Port", 0);
            _itoa(port, buffer, 10);
            setTextValue(hWnd, IDC_INFO_PORT, port ? buffer : NULL);

            setTextValue(hWnd, IDC_INFO_VERSION, NULL);
            setTextValue(hWnd, IDC_INFO_MIRVER, NULL);
            setTextValue(hWnd, IDC_INFO_PING, NULL);
        }
        break;

    case WM_COMMAND:
        if (LOWORD(wParam) == IDCANCEL) SendMessage(GetParent(hWnd), msg, wParam, lParam);
        break;
    }
    return FALSE;
}
Beispiel #26
0
void TwitterProto::MessageLoop(void*)
{
	debugLogA( _T("***** Entering Twitter::MessageLoop"));

	since_id_    = db_pod_get<twitter_id>(0,m_szModuleName,TWITTER_KEY_SINCEID,0);
	dm_since_id_ = db_pod_get<twitter_id>(0,m_szModuleName,TWITTER_KEY_DMSINCEID,0);

	bool new_account = db_get_b(0,m_szModuleName,TWITTER_KEY_NEW,1) != 0;
	bool popups = db_get_b(0,m_szModuleName,TWITTER_KEY_POPUP_SIGNON,1) != 0;

	// if this isn't set, it will automatically not turn a tweet into a msg. probably should make the default that it does turn a tweet into a message
	bool tweetToMsg  = db_get_b(0,m_szModuleName,TWITTER_KEY_TWEET_TO_MSG,0) != 0;

	int poll_rate = db_get_dw(0,m_szModuleName,TWITTER_KEY_POLLRATE,80);

	for(unsigned int i=0;;i++)
	{

		if(m_iStatus != ID_STATUS_ONLINE)
			break;
//		if(i%10 == 0)
//			UpdateFriends();

		if(m_iStatus != ID_STATUS_ONLINE)
			break;
		UpdateStatuses(new_account,popups, tweetToMsg);

		if(m_iStatus != ID_STATUS_ONLINE)
			break;
		
		if(i%10 == 0)
			UpdateMessages(new_account);

		if(new_account) // Not anymore!
		{
			new_account = false;
			db_set_b(0,m_szModuleName,TWITTER_KEY_NEW,0);
		}

		if(m_iStatus != ID_STATUS_ONLINE)
			break;
		debugLogA( _T("***** TwitterProto::MessageLoop going to sleep..."));
		if(SleepEx(poll_rate*1000,true) == WAIT_IO_COMPLETION)
			break;
		debugLogA( _T("***** TwitterProto::MessageLoop waking up..."));

		popups = true;
	}

	{
		ScopedLock s(twitter_lock_);
		twit_.set_credentials("",L"",L"",L"",L"",L"", false);
	}
	debugLogA( _T("***** Exiting TwitterProto::MessageLoop"));
}
//called to load settings from database
void LoadSettings()
{
	settingInterval=(INT)db_get_dw(NULL, PLUGINNAME, "Interval", 500);
	settingInterval1=(INT)db_get_dw (NULL, PLUGINNAME, "PopupInterval", 0);
	settingResolveIp=db_get_b  (NULL, PLUGINNAME, "ResolveIp",TRUE);
	settingDefaultAction=db_get_b  (NULL, PLUGINNAME, "FilterDefaultAction",TRUE);
	
	settingSetColours=db_get_b  (NULL, PLUGINNAME, "PopupSetColours",0);
	settingBgColor = (COLORREF)db_get_dw(NULL, PLUGINNAME, "PopupBgColor", (DWORD)0xFFFFFF);
	settingFgColor = (COLORREF)db_get_dw(NULL, PLUGINNAME, "PopupFgColor", (DWORD)0x000000);
	settingFiltersCount=(INT)db_get_dw (NULL, PLUGINNAME, "FiltersCount", 0);
	settingStatusMask=(WORD)db_get_w(NULL, PLUGINNAME, "StatusMask", 16);
	for(int i = 0; i < STATUS_COUNT; i++) 
	{
		char buff[128];
		mir_snprintf(buff,sizeof(buff), "Status%d", i);
		settingStatus[i] = (db_get_b(0, PLUGINNAME, buff, 0) == 1);
	}
	//lookupLotusDefaultSettings();
}
Beispiel #28
0
//forces the metacontact to send using a specific subcontact, using the subcontact's handle
//wParam=(HANDLE)hMetaContact
//lParam=(HANDLE)hSubcontact
//returns 0 on success (will fail if 'force default' is in effect)
INT_PTR MetaAPI_ForceSendContact(WPARAM wParam, LPARAM lParam) {
	HANDLE hContact = (HANDLE)lParam;
	HANDLE hMeta = (HANDLE)db_get_dw(hContact, META_PROTO, "Handle", 0);
	if ( !hContact || !hMeta || hMeta != (HANDLE)wParam || db_get_b(hMeta, META_PROTO, "ForceDefault", 0)) 
		return 1;

	db_set_dw(hMeta, META_PROTO, "ForceSend", (DWORD)hContact);

	NotifyEventHooks(hEventForceSend, wParam, lParam);
	return 0;
}
Beispiel #29
0
BOOL AllowUpdateOnStartup()
{
	if (OnlyOnceADay) {
		time_t now = time(NULL);
		time_t was = db_get_dw(NULL, MODNAME, "LastUpdate", 0);

		if ((now - was) < 86400)
			return FALSE;
	}
	return TRUE;
}
Beispiel #30
0
//sets the default contact, using the subcontact's handle
//wParam=(HANDLE)hMetaContact
//lParam=(HANDLE)hSubcontact
//returns 0 on success
INT_PTR MetaAPI_SetDefaultContact(WPARAM wParam, LPARAM lParam) {
	HANDLE hMeta = (HANDLE)db_get_dw((HANDLE)lParam, META_PROTO, "Handle", 0);
	DWORD contact_number = Meta_GetContactNumber((HANDLE)lParam);
	if (contact_number == -1 || !hMeta || hMeta != (HANDLE)wParam) 
		return 1;
	if (db_set_dw(hMeta, META_PROTO, "Default", contact_number))
		return 1;
	
	NotifyEventHooks(hEventDefaultChanged, wParam, lParam);
	return 0;
}