aboutsummaryrefslogtreecommitdiffstats
path: root/win32/PropLog.cpp
blob: 27957b07a1e4c38cc2477fc7f6acba8075649ebd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// PropLog.cpp : implementation file
//

#define BITLBEE_CORE
#include "bitlbeewin.h"
#include "PropLog.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CPropLog dialog


CPropLog::CPropLog()
	: CPropertyPage(CPropLog::IDD)
{
	//{{AFX_DATA_INIT(CPropLog)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CPropLog::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPropLog)
	DDX_Control(pDX, IDC_LOG, m_log);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CPropLog, CPropertyPage)
	//{{AFX_MSG_MAP(CPropLog)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPropLog message handlers

static GList *log = NULL;

extern "C" {
void glib_logger (const gchar *log_domain, GLogLevelFlags log_level, const gchar *msg, gpointer user_data)
{
	log = g_list_append(log, g_strdup_printf("%s: %s", log_domain, msg));
}
}

void log_message(int level, char *message, ... ) { 
#define LOG_MAXLEN 300
	va_list ap;
	va_start(ap, message);
	char *msg = (char *)g_malloc(LOG_MAXLEN);
	g_vsnprintf(msg, LOG_MAXLEN, message, ap);
	va_end(ap);
	log = g_list_append(log, msg);
	if(level == LOGLVL_ERROR) ::MessageBox(NULL, msg, "Bitlbee", MB_OK | MB_ICONINFORMATION);
	TRACE("%d: %s\n", level, msg);
}


BOOL CPropLog::OnInitDialog() 
{
	CPropertyPage::OnInitDialog();
	
	m_log.ResetContent();
	GList *gl = log;
	while(gl) {
		char *d = (char *)gl->data;
		m_log.AddString(d);
		gl = gl->next;
	}
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}