summaryrefslogtreecommitdiff
path: root/plugins/!NotAdopted/WinterSpeak/speak/announce/dialog_announce.cpp
blob: 5a21859ba5d2f4688d9af00d9b6ff3e6128dba55 (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
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
//==============================================================================
//  Miranda Speak Plugin, © 2002 Ryan Winter
//==============================================================================

#pragma warning(disable:4786)

#include "announce/dialog_announce.h"

#include "resource.h"
#include "speak.h"

#include <general/debug/debug.h>

#include <windows.h>

//------------------------------------------------------------------------------
AnnounceDialog *AnnounceDialog::m_instance = 0;

//------------------------------------------------------------------------------
// public:
//------------------------------------------------------------------------------
AnnounceDialog::AnnounceDialog(AnnounceDatabase &db)
	:
	m_db(db)
{
	CLASSCERR("AnnounceDialog::AnnounceDialog");

    m_instance = this;
}

//------------------------------------------------------------------------------
AnnounceDialog::~AnnounceDialog()
{
	CLASSCERR("AnnounceDialog::~AnnounceDialog");

    m_instance = 0;
}

//------------------------------------------------------------------------------
// private:
//------------------------------------------------------------------------------
int CALLBACK 
AnnounceDialog::process(HWND window, UINT message, WPARAM wparam, LPARAM lparam)
{
    if (!m_instance)
    {
        return 1;
    }

	switch (message)
	{
      case WM_INITDIALOG:
        m_instance->load(window);
        break;

	  case WM_COMMAND:
		m_instance->command(window, wparam);
        break;

	  case WM_NOTIFY:
    	if (PSN_APPLY == LPNMHDR(lparam)->code)
    	{	
		    m_instance->save(window);
	    }
        break;
	}

    return 0;
}

//------------------------------------------------------------------------------
void
AnnounceDialog::command(HWND window, int control)
{
	switch (LOWORD(control))
	{
      case IDC_STATUS_OFFLINE:
      case IDC_STATUS_ONLINE:
      case IDC_STATUS_AWAY:
      case IDC_STATUS_DND:
      case IDC_STATUS_NA:
      case IDC_STATUS_OCCUPIED:
      case IDC_STATUS_FREEFORCHAT:
      case IDC_STATUS_INVISIBLE:
      case IDC_SPEAK_STATUS_MSG:
      case IDC_SUPPRESS_CONNECT:
      case IDC_EVENT_MESSAGE:
      case IDC_EVENT_URL:
      case IDC_EVENT_FILE:
      case IDC_EVENT_AUTHREQUEST:
      case IDC_EVENT_ADDED:
      case IDC_READ_MSG_LENGTH:
      case IDC_DIALOG_OPEN:
      case IDC_DIALOG_FOCUSED:

		changed(window);
		break;

      case IDC_MAX_MSG:
        if (EN_CHANGE == HIWORD(control))
        {
            changed(window);
        }
        break;
	}
}

//------------------------------------------------------------------------------
void
AnnounceDialog::load(HWND window)
{
	CLASSCERR("AnnounceDialog::load");

	TranslateDialogDefault(window);

	// initialise the checkboxes
    CheckDlgButton(window, IDC_STATUS_OFFLINE, 
        m_db.getStatusFlag(AnnounceDatabase::StatusFlag_Offline));
    CheckDlgButton(window, IDC_STATUS_ONLINE, 
        m_db.getStatusFlag(AnnounceDatabase::StatusFlag_Online));
    CheckDlgButton(window, IDC_STATUS_AWAY, 
        m_db.getStatusFlag(AnnounceDatabase::StatusFlag_Away));
    CheckDlgButton(window, IDC_STATUS_DND, 
        m_db.getStatusFlag(AnnounceDatabase::StatusFlag_Dnd));
    CheckDlgButton(window, IDC_STATUS_NA, 
        m_db.getStatusFlag(AnnounceDatabase::StatusFlag_Na));
    CheckDlgButton(window, IDC_STATUS_OCCUPIED, 
        m_db.getStatusFlag(AnnounceDatabase::StatusFlag_Occupied));
    CheckDlgButton(window, IDC_STATUS_FREEFORCHAT, 
        m_db.getStatusFlag(AnnounceDatabase::StatusFlag_FreeForChat));
    CheckDlgButton(window, IDC_STATUS_INVISIBLE, 
        m_db.getStatusFlag(AnnounceDatabase::StatusFlag_Invisible));
    CheckDlgButton(window, IDC_SPEAK_STATUS_MSG, 
        m_db.getStatusFlag(AnnounceDatabase::StatusFlag_SpeakStatusMsg));
    CheckDlgButton(window, IDC_SUPPRESS_CONNECT, 
        m_db.getStatusFlag(AnnounceDatabase::StatusFlag_SuppressConnect));

    CheckDlgButton(window, IDC_EVENT_MESSAGE, 
        m_db.getEventFlag(AnnounceDatabase::EventFlag_Message));
    CheckDlgButton(window, IDC_EVENT_URL, 
        m_db.getEventFlag(AnnounceDatabase::EventFlag_Url));
    CheckDlgButton(window, IDC_EVENT_FILE, 
        m_db.getEventFlag(AnnounceDatabase::EventFlag_File));
    CheckDlgButton(window, IDC_EVENT_AUTHREQUEST, 
        m_db.getEventFlag(AnnounceDatabase::EventFlag_AuthRequest));
    CheckDlgButton(window, IDC_EVENT_ADDED, 
        m_db.getEventFlag(AnnounceDatabase::EventFlag_Added));
    CheckDlgButton(window, IDC_READ_MSG_LENGTH, 
        m_db.getEventFlag(AnnounceDatabase::EventFlag_ReadMsgLength));
    CheckDlgButton(window, IDC_DIALOG_OPEN, 
        m_db.getEventFlag(AnnounceDatabase::EventFlag_DialogOpen));
    CheckDlgButton(window, IDC_DIALOG_FOCUSED, 
        m_db.getEventFlag(AnnounceDatabase::EventFlag_DialogFocused));

	// initialise the welcome message box
	SetDlgItemInt(window, IDC_MAX_MSG, m_db.getMaxMsgSize(), 0);
}

//------------------------------------------------------------------------------
void
AnnounceDialog::save(HWND window)
{
	CLASSCERR("AnnounceDialog::save");

	// store the checkboxes
	m_db.setStatusFlag(AnnounceDatabase::StatusFlag_Offline, 
		(IsDlgButtonChecked(window, IDC_STATUS_OFFLINE) != 0));
	m_db.setStatusFlag(AnnounceDatabase::StatusFlag_Online, 
		(IsDlgButtonChecked(window, IDC_STATUS_ONLINE) != 0));
	m_db.setStatusFlag(AnnounceDatabase::StatusFlag_Away, 
		(IsDlgButtonChecked(window, IDC_STATUS_AWAY) != 0));
	m_db.setStatusFlag(AnnounceDatabase::StatusFlag_Dnd,
		(IsDlgButtonChecked(window, IDC_STATUS_DND) != 0));
	m_db.setStatusFlag(AnnounceDatabase::StatusFlag_Na,
		(IsDlgButtonChecked(window, IDC_STATUS_NA) != 0));
	m_db.setStatusFlag(AnnounceDatabase::StatusFlag_Occupied,
		(IsDlgButtonChecked(window, IDC_STATUS_OCCUPIED) != 0));
	m_db.setStatusFlag(AnnounceDatabase::StatusFlag_FreeForChat,
		(IsDlgButtonChecked(window, IDC_STATUS_FREEFORCHAT) != 0));
	m_db.setStatusFlag(AnnounceDatabase::StatusFlag_Invisible,
		(IsDlgButtonChecked(window, IDC_STATUS_INVISIBLE) != 0));
	m_db.setStatusFlag(AnnounceDatabase::StatusFlag_SpeakStatusMsg,
		(IsDlgButtonChecked(window, IDC_SPEAK_STATUS_MSG) != 0));
	m_db.setStatusFlag(AnnounceDatabase::StatusFlag_SuppressConnect,
		(IsDlgButtonChecked(window, IDC_SUPPRESS_CONNECT) != 0));

	m_db.setEventFlag(AnnounceDatabase::EventFlag_Message,
		(IsDlgButtonChecked(window, IDC_EVENT_MESSAGE) != 0));
	m_db.setEventFlag(AnnounceDatabase::EventFlag_Url,
		(IsDlgButtonChecked(window, IDC_EVENT_URL) != 0));
	m_db.setEventFlag(AnnounceDatabase::EventFlag_File,
		(IsDlgButtonChecked(window, IDC_EVENT_FILE) != 0));
	m_db.setEventFlag(AnnounceDatabase::EventFlag_AuthRequest,
		(IsDlgButtonChecked(window, IDC_EVENT_AUTHREQUEST) != 0));
	m_db.setEventFlag(AnnounceDatabase::EventFlag_Added,
		(IsDlgButtonChecked(window, IDC_EVENT_ADDED) != 0));
	m_db.setEventFlag(AnnounceDatabase::EventFlag_ReadMsgLength,
		(IsDlgButtonChecked(window, IDC_READ_MSG_LENGTH) != 0));
	m_db.setEventFlag(AnnounceDatabase::EventFlag_DialogOpen,
		(IsDlgButtonChecked(window, IDC_DIALOG_OPEN) != 0));
	m_db.setEventFlag(AnnounceDatabase::EventFlag_DialogFocused,
		(IsDlgButtonChecked(window, IDC_DIALOG_FOCUSED) != 0));

    m_db.setMaxMsgSize(GetDlgItemInt(window, IDC_MAX_MSG, NULL, 0));

    m_instance->m_db.save();
}

//==============================================================================