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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
|
// ChannelListDlg.cpp : implementation file
//
#include "stdafx.h"
#include "chatty.h"
#include "ChannelListDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CChannelListDlg dialog
CChannelListDlg::CChannelListDlg(CWnd* pParent /*=NULL*/)
: CDialog(CChannelListDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CChannelListDlg)
m_filter = _T("");
//}}AFX_DATA_INIT
}
void CChannelListDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CChannelListDlg)
DDX_Control(pDX, IDC_NUM, m_num);
DDX_Control(pDX, IDC_LIST, m_list);
DDX_Text(pDX, IDC_FILTER, m_filter);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CChannelListDlg, CDialog)
//{{AFX_MSG_MAP(CChannelListDlg)
ON_BN_CLICKED(ID_CHANNELS, OnChannels)
ON_BN_CLICKED(ID_USERS, OnUsers)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CChannelListDlg message handlers
void EnumChannelsCallbackEach(CHAT chat, CHATBool success, int index, const char * channel, const char * topic, int numUsers, void * param)
{
if(success)
{
CChannelListDlg * dlg = (CChannelListDlg *)param;
CListBox * list = &dlg->m_list;
CString str;
str = channel;
str += " (";
char buffer[16];
itoa(numUsers, buffer, 10);
str += buffer;
str += "): ";
str += topic;
list->AddString(str);
char buf[16];
itoa(index + 1, buf, 10);
dlg->m_num.SetWindowText(buf);
}
GSI_UNUSED(chat);
}
void EnumJoinedChannelsCallback(CHAT chat,
int index,
const char * channel,
void * param)
{
CChannelListDlg * dlg = (CChannelListDlg *)param;
CListBox * list = &dlg->m_list;
CString str;
str = "IN: ";
str += channel;
str += " (";
char buffer[16];
itoa(index, buffer, 10);
str += buffer;
str += "): ";
list->AddString(str);
GSI_UNUSED(chat);
}
void EnumChannelsCallbackAll(CHAT chat, CHATBool success, int numChannels, const char ** channels, const char ** topics, int * numUsers, void * param)
{
if(success)
{
CChannelListDlg * dlg = (CChannelListDlg *)param;
dlg->MessageBox("Search Complete");
}
GSI_UNUSED(numUsers);
GSI_UNUSED(topics);
GSI_UNUSED(channels);
GSI_UNUSED(numChannels);
GSI_UNUSED(chat);
}
void ListUsers(CHAT chat, CHATBool success, const char * channel, int numUsers, const char ** users, int * modes, void * param)
{
if(success)
{
CChannelListDlg * dlg = (CChannelListDlg *)param;
CListBox * list = &dlg->m_list;
CString str;
for(int i = 0 ; i < numUsers ; i++)
{
str = users[i];
if(modes[i] & CHAT_OP)
str.Insert(0, '@');
else if(modes[i] & CHAT_VOICE)
str.Insert(0, '?');
list->AddString(str);
}
char buf[16];
itoa(numUsers, buf, 10);
dlg->m_num.SetWindowText(buf);
}
GSI_UNUSED(channel);
GSI_UNUSED(chat);
}
void CChannelListDlg::OnChannels()
{
// Clear the list.
//////////////////
m_list.ResetContent();
// Get the list.
////////////////
UpdateData();
chatEnumJoinedChannels(theApp.m_chat, EnumJoinedChannelsCallback, this);
chatEnumChannels(theApp.m_chat, m_filter, EnumChannelsCallbackEach, EnumChannelsCallbackAll, this, CHATFalse);
}
void CChannelListDlg::OnUsers()
{
// Clear the list.
//////////////////
m_list.ResetContent();
// Get the list.
////////////////
UpdateData();
chatEnumUsers(theApp.m_chat, m_filter, ListUsers, this, CHATFalse);
}
|