source: win32/PropLog.cpp @ d1d6776

Last change on this file since d1d6776 was d1d6776, checked in by Jelmer Vernooij <jelmer@…>, at 2005-11-07T16:20:37Z

Import win32 branch

  • Property mode set to 100644
File size: 1.8 KB
Line 
1// PropLog.cpp : implementation file
2//
3
4#define BITLBEE_CORE
5#include "bitlbeewin.h"
6#include "PropLog.h"
7
8#ifdef _DEBUG
9#define new DEBUG_NEW
10#undef THIS_FILE
11static char THIS_FILE[] = __FILE__;
12#endif
13
14/////////////////////////////////////////////////////////////////////////////
15// CPropLog dialog
16
17
18CPropLog::CPropLog()
19        : CPropertyPage(CPropLog::IDD)
20{
21        //{{AFX_DATA_INIT(CPropLog)
22                // NOTE: the ClassWizard will add member initialization here
23        //}}AFX_DATA_INIT
24}
25
26
27void CPropLog::DoDataExchange(CDataExchange* pDX)
28{
29        CPropertyPage::DoDataExchange(pDX);
30        //{{AFX_DATA_MAP(CPropLog)
31        DDX_Control(pDX, IDC_LOG, m_log);
32        //}}AFX_DATA_MAP
33}
34
35
36BEGIN_MESSAGE_MAP(CPropLog, CPropertyPage)
37        //{{AFX_MSG_MAP(CPropLog)
38        //}}AFX_MSG_MAP
39END_MESSAGE_MAP()
40
41/////////////////////////////////////////////////////////////////////////////
42// CPropLog message handlers
43
44static GList *log = NULL;
45
46extern "C" {
47void glib_logger (const gchar *log_domain, GLogLevelFlags log_level, const gchar *msg, gpointer user_data)
48{
49        log = g_list_append(log, g_strdup_printf("%s: %s", log_domain, msg));
50}
51}
52
53void log_message(int level, char *message, ... ) { 
54#define LOG_MAXLEN 300
55        va_list ap;
56        va_start(ap, message);
57        char *msg = (char *)g_malloc(LOG_MAXLEN);
58        g_vsnprintf(msg, LOG_MAXLEN, message, ap);
59        va_end(ap);
60        log = g_list_append(log, msg);
61        if(level == LOGLVL_ERROR) ::MessageBox(NULL, msg, "Bitlbee", MB_OK | MB_ICONINFORMATION);
62        TRACE("%d: %s\n", level, msg);
63}
64
65
66BOOL CPropLog::OnInitDialog() 
67{
68        CPropertyPage::OnInitDialog();
69       
70        m_log.ResetContent();
71        GList *gl = log;
72        while(gl) {
73                char *d = (char *)gl->data;
74                m_log.AddString(d);
75                gl = gl->next;
76        }
77       
78        return TRUE;  // return TRUE unless you set the focus to a control
79                      // EXCEPTION: OCX Property Pages should return FALSE
80}
Note: See TracBrowser for help on using the repository browser.