3
* TOra - An Oracle Toolkit for DBA's and developers
4
* Copyright (C) 2003-2005 Quest Software, Inc
5
* Portions Copyright (C) 2005 Other Contributors
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License
9
* as published by the Free Software Foundation; only version 2 of
10
* the License is valid for this program.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, write to the Free Software
19
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21
* As a special exception, you have permission to link this program
22
* with the Oracle Client libraries and distribute executables, as long
23
* as you follow the requirements of the GNU GPL in regard to all of the
24
* software in the executable aside from Oracle client libraries.
26
* Specifically you are not permitted to link this program with the
27
* Qt/UNIX, Qt/Windows or Qt Non Commercial products of TrollTech.
28
* And you are not permitted to distribute binaries compiled against
29
* these libraries without written consent from Quest Software, Inc.
30
* Observe that this does not disallow linking to the Qt Free Edition.
32
* You may link this product with any GPL'd Qt library such as Qt/Free
34
* All trademarks belong to their respective owners.
2
/* BEGIN_COMMON_COPYRIGHT_HEADER
4
* TOra - An Oracle Toolkit for DBA's and developers
6
* Shared/mixed copyright is held throughout files in this product
8
* Portions Copyright (C) 2000-2001 Underscore AB
9
* Portions Copyright (C) 2003-2005 Quest Software, Inc.
10
* Portions Copyright (C) 2004-2008 Numerous Other Contributors
12
* This program is free software; you can redistribute it and/or
13
* modify it under the terms of the GNU General Public License
14
* as published by the Free Software Foundation; only version 2 of
15
* the License is valid for this program.
17
* This program is distributed in the hope that it will be useful,
18
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
* GNU General Public License for more details.
22
* You should have received a copy of the GNU General Public License
23
* along with this program; if not, write to the Free Software
24
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26
* As a special exception, you have permission to link this program
27
* with the Oracle Client libraries and distribute executables, as long
28
* as you follow the requirements of the GNU GPL in regard to all of the
29
* software in the executable aside from Oracle client libraries.
31
* Specifically you are not permitted to link this program with the
32
* Qt/UNIX, Qt/Windows or Qt Non Commercial products of TrollTech.
33
* And you are not permitted to distribute binaries compiled against
36
* You may link this product with any GPL'd Qt library.
38
* All trademarks belong to their respective owners.
40
* END_COMMON_COPYRIGHT_HEADER */
38
42
#include "toalert.h"
121
124
"Get hostname of current connection");
123
126
toAlert::toAlert(QWidget *main, toConnection &connection)
124
: toToolWidget(AlertTool, "alert.html", main, connection), Connection(connection)
127
: toToolWidget(AlertTool, "alert.html", main, connection, "toAlert")
128
, Connection(connection)
126
130
QToolBar *toolbar = toAllocBar(this, tr("Alert Messenger"));
131
layout()->addWidget(toolbar);
134
139
def += QString::fromLatin1(":");
138
143
def += connection.user();
140
new QLabel(tr("Registered") + " ", toolbar, TO_TOOLBAR_WIDGET_NAME);
141
Registered = new QComboBox(toolbar, TO_TOOLBAR_WIDGET_NAME);
142
Registered->insertItem(def);
146
new QLabel(tr("Registered") + " ", toolbar));
148
Registered = new QComboBox(toolbar);
149
Registered->addItem(def);
143
150
Registered->setEditable(true);
144
151
Registered->setDuplicatesEnabled(false);
145
Registered->setCurrentItem(0);
146
connect(Registered, SIGNAL(activated(int)), this, SLOT(add
152
Registered->setCurrentIndex(0);
153
connect(Registered, SIGNAL(activated(int)), this, SLOT(add()));
154
toolbar->addWidget(Registered);
149
156
AddNames.insert(AddNames.end(), def);
151
new QToolButton(QPixmap(const_cast<const char**>(commit_xpm)),
152
tr("Register current"),
153
tr("Register current"),
159
toolbar->addAction(QIcon(QPixmap(const_cast<const char**>(commit_xpm))),
160
tr("Register current"),
163
addAct->setShortcut(Qt::ALT + Qt::Key_R);
158
new QToolButton(QPixmap(const_cast<const char**>(trash_xpm)),
159
tr("Remove registered"),
160
tr("Remove registered"),
166
toolbar->addAction(QIcon(QPixmap(const_cast<const char**>(trash_xpm))),
167
tr("Remove registered"),
170
removeAct->setShortcut(Qt::CTRL + Qt::Key_Backspace);
165
172
toolbar->addSeparator();
167
new QLabel(tr("Name") + " ", toolbar, TO_TOOLBAR_WIDGET_NAME);
168
Name = new QLineEdit(toolbar, TO_TOOLBAR_WIDGET_NAME);
175
new QLabel(tr("Name") + " ", toolbar));
178
Name = new QLineEdit(toolbar));
169
179
Name->setText(def);
170
180
connect(Name, SIGNAL(returnPressed()), this, SLOT(send()));
171
new QLabel(tr("Message") + " ", toolbar, TO_TOOLBAR_WIDGET_NAME);
172
Message = new QLineEdit(toolbar, TO_TOOLBAR_WIDGET_NAME);
183
new QLabel(tr("Message") + " ", toolbar));
185
Message = new QLineEdit(toolbar);
173
186
connect(Message, SIGNAL(returnPressed()), this, SLOT(send()));
174
new QToolButton(QPixmap(const_cast<const char**>(toworksheet_xpm)),
175
tr("Edit message in memo"),
176
tr("Edit message in memo"),
179
toolbar->setStretchableWidget(Message);
180
new QToolButton(QPixmap(const_cast<const char**>(return_xpm)),
187
Message->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,
188
QSizePolicy::Minimum));
190
toolbar->addWidget(Message);
193
toolbar->addAction(QIcon(QPixmap(const_cast<const char**>(toworksheet_xpm))),
194
tr("Edit message in memo"),
197
memoEditAct->setShortcut(Qt::CTRL + Qt::Key_M);
200
toolbar->addAction(QIcon(QPixmap(const_cast<const char**>(return_xpm))),
204
sendAct->setShortcut(Qt::CTRL + Qt::Key_Return);
186
206
connect(&Timer, SIGNAL(timeout()), this, SLOT(poll()));
187
207
Timer.start(TIMEOUT*1000);
190
210
Alerts->addColumn(tr("Time"));
191
211
Alerts->addColumn(tr("Name"));
192
212
Alerts->addColumn(tr("Message"));
213
layout()->addWidget(Alerts);
195
connect(toMainWidget()->workspace(), SIGNAL(windowActivated(QWidget *)),
196
this, SLOT(windowActivated(QWidget *)));
216
connect(toMainWidget()->workspace(), SIGNAL(subWindowActivated(QMdiSubWindow *)),
217
this, SLOT(windowActivated(QMdiSubWindow *)));
206
toStatusMessage(tr("Failed to start polling thread, try closing some other tools and restart Alert Messenger"));
227
toStatusMessage(tr("Failed to start polling thread, try closing "
228
"some other tools and restart Alert Messenger"));
209
231
setFocusProxy(Message);
212
void toAlert::windowActivated(QWidget *widget)
234
void toAlert::windowActivated(QMdiSubWindow *widget)
238
if (widget->widget() == this)
218
ToolMenu = new QPopupMenu(this);
219
ToolMenu->insertItem(tr("&Add name"), Registered, SLOT(setFocus()), toKeySequence(tr("Alt+R", "Alert|Add Name")));
220
ToolMenu->insertItem(QPixmap(const_cast<const char**>(trash_xpm)), tr("&Remove name"),
222
(void)), toKeySequence(tr("Ctrl+Backspace", "Alert|Remove name")));
223
ToolMenu->insertSeparator();
224
ToolMenu->insertItem(tr("Edit &name"), Name, SLOT(setFocus()), toKeySequence(tr("Alt+N", "Alert|Edit name")));
225
ToolMenu->insertItem(tr("Edit &message"), Message, SLOT(setFocus()), toKeySequence(tr("Alt+M", "Alert|Message")));
226
ToolMenu->insertItem(QPixmap(const_cast<const char**>(toworksheet_xpm)), tr("&Message in memo..."),
227
this, SLOT(memo(void)), toKeySequence(tr("Ctrl+M", "Alert|Message in memo")));
228
ToolMenu->insertItem(QPixmap(const_cast<const char**>(return_xpm)), tr("&Send alert"),
229
this, SLOT(send(void)), toKeySequence(tr("Ctrl+Return", "Alert|Send alert")));
231
toMainWidget()->menuBar()->insertItem(tr("&Alert"), ToolMenu, -1, toToolMenuIndex());
242
ToolMenu = new QMenu(tr("&Alert"), this);
244
ToolMenu->addAction(addAct);
245
ToolMenu->addAction(removeAct);
247
ToolMenu->addSeparator();
249
ToolMenu->addAction(memoEditAct);
250
ToolMenu->addAction(sendAct);
252
toMainWidget()->addCustomMenu(ToolMenu);
268
293
static toSQL SQLPoll("toAlert:PollAlert",
270
295
" SYS.DBMS_ALERT.WAITANY(:name<char[4000],out>,:msg<char[4000],out>,\n"
271
" :stat<in,out>,:tim<char[10],in>);\n"
296
" :stat<int,out>,:tim<char[10],in>);\n"
273
298
"Poll for alert, must have same binds");
274
299
static toSQL SQLSignal("toAlert:Signal",
353
378
Parent.Lock.unlock();
359
383
Sleep(TIMEOUT*1000);
364
387
catch (const QString &str)
366
389
Parent.Lock.lock();
367
Parent.Error.sprintf("Exception in alert polling:\n%s", (const char *)str.latin1());
368
fprintf(stderr, "%s\n", (const char *)Parent.Error);
390
Parent.Error.sprintf("Exception in alert polling:\n%s", (const char *)str.toLatin1());
391
fprintf(stderr, "%s\n", Parent.Error.toAscii().constData());
369
392
Parent.Lock.unlock();
373
396
Parent.Lock.lock();
374
397
Parent.Error.sprintf("Unexpected exception in alert in polling.");
375
fprintf(stderr, "%s\n", (const char *)Parent.Error);
398
fprintf(stderr, "%s\n", Parent.Error.toAscii().constData());
376
399
Parent.Lock.unlock();