source: win32/PropUsers.cpp @ 99318ad

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

Import win32 branch

  • Property mode set to 100644
File size: 2.9 KB
Line 
1// PropUsers.cpp : implementation file
2//
3
4#define BITLBEE_CORE
5#include "bitlbeewin.h"
6#include "PropUsers.h"
7
8#ifdef _DEBUG
9#define new DEBUG_NEW
10#undef THIS_FILE
11static char THIS_FILE[] = __FILE__;
12#endif
13
14/////////////////////////////////////////////////////////////////////////////
15// CPropUsers dialog
16
17
18CPropUsers::CPropUsers()
19        : CPropertyPage(CPropUsers::IDD)
20{
21        //{{AFX_DATA_INIT(CPropUsers)
22                // NOTE: the ClassWizard will add member initialization here
23        //}}AFX_DATA_INIT
24}
25
26
27void CPropUsers::DoDataExchange(CDataExchange* pDX)
28{
29        CDialog::DoDataExchange(pDX);
30        //{{AFX_DATA_MAP(CPropUsers)
31        DDX_Control(pDX, IDC_KNOWN_USERS, m_known_users);
32        DDX_Control(pDX, IDC_KICK, m_kick);
33        DDX_Control(pDX, IDC_DEL_KNOWN_USERS, m_del_known_users);
34        DDX_Control(pDX, IDC_CURRENT_USERS, m_current_users);
35        //}}AFX_DATA_MAP
36}
37
38
39BEGIN_MESSAGE_MAP(CPropUsers, CPropertyPage)
40        //{{AFX_MSG_MAP(CPropUsers)
41        ON_BN_CLICKED(IDC_KICK, OnKick)
42        ON_BN_CLICKED(IDC_DEL_KNOWN_USERS, OnDelKnownUser)
43        ON_LBN_SELCHANGE(IDC_CURRENT_USERS, OnSelchangeCurrentUsers)
44        ON_LBN_SELCHANGE(IDC_KNOWN_USERS, OnSelchangeKnownUsers)
45        ON_BN_CLICKED(IDC_REFRESH_KNOWN_USERS, OnRefreshKnownUsers)
46        ON_BN_CLICKED(IDC_REFRESH_CURRENT_USERS, OnRefreshCurrentUsers)
47        //}}AFX_MSG_MAP
48END_MESSAGE_MAP()
49
50/////////////////////////////////////////////////////////////////////////////
51// CPropUsers message handlers
52
53void CPropUsers::OnKick() 
54{
55        int idx = m_current_users.GetCurSel();
56        if(idx == LB_ERR) return;
57        irc_t *irc = (irc_t *)m_current_users.GetItemData(idx);
58        irc_free(irc);
59        m_kick.EnableWindow(FALSE);
60        OnRefreshCurrentUsers();
61}
62
63void CPropUsers::OnDelKnownUser() 
64{
65        CString nick;
66        m_known_users.GetText(m_known_users.GetCurSel(), nick);
67        CString accounts; accounts.Format("%s\\%s.accounts", global.conf->configdir, nick);
68        CString nicks; nicks.Format("%s\\%s.nicks", global.conf->configdir, nick);
69        CFile::Remove(accounts);
70        CFile::Remove(nicks);
71        m_del_known_users.EnableWindow(FALSE);
72        OnRefreshKnownUsers();
73}
74
75void CPropUsers::OnSelchangeCurrentUsers() 
76{
77        m_kick.EnableWindow(m_current_users.GetCurSel() != LB_ERR);
78       
79}
80
81void CPropUsers::OnSelchangeKnownUsers() 
82{
83        m_del_known_users.EnableWindow(m_known_users.GetCurSel() != LB_ERR);
84       
85}
86
87void CPropUsers::OnRefreshKnownUsers() 
88{
89        m_known_users.ResetContent();
90        GError *error = NULL;
91        const char *r;
92        GDir *d = g_dir_open(global.conf->configdir, 0, &error);
93        if(!d) return;
94        while(r = g_dir_read_name(d)) {
95                if(strstr(r, ".accounts")) {
96                        CString tmp(r, strlen(r) - strlen(".accounts"));
97                        m_known_users.AddString(tmp);
98                }
99        }
100        g_dir_close(d);
101}
102
103extern "C" {
104        extern GSList *irc_connection_list;
105}
106
107void CPropUsers::OnRefreshCurrentUsers() 
108{
109        m_current_users.ResetContent();
110        GSList *gl = irc_connection_list;
111        while(gl) {
112                irc_t *irc = (irc_t *)gl->data;
113                CString tmp;
114                tmp.Format("%s@%s \"%s\"", irc->nick, irc->myhost, irc->realname);
115                int idx = m_current_users.AddString(tmp);
116                m_current_users.SetItemData(idx, (unsigned long)irc);
117                gl = gl->next;
118        }
119}
120
Note: See TracBrowser for help on using the repository browser.