summaryrefslogtreecommitdiffstats
path: root/src/modules/reguser
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/reguser')
-rw-r--r--src/modules/reguser/Makefile.am25
-rw-r--r--src/modules/reguser/dialog.cpp903
-rw-r--r--src/modules/reguser/dialog.h148
-rw-r--r--src/modules/reguser/edituser.cpp781
-rw-r--r--src/modules/reguser/edituser.h152
-rw-r--r--src/modules/reguser/libkvireguser.cpp1239
-rw-r--r--src/modules/reguser/wizard.cpp464
-rw-r--r--src/modules/reguser/wizard.h89
8 files changed, 3801 insertions, 0 deletions
diff --git a/src/modules/reguser/Makefile.am b/src/modules/reguser/Makefile.am
new file mode 100644
index 00000000..93aea872
--- /dev/null
+++ b/src/modules/reguser/Makefile.am
@@ -0,0 +1,25 @@
+###############################################################################
+# KVirc IRC client Makefile - 10.03.2000 Szymon Stefanek <stefanek@tin.it>
+###############################################################################
+
+AM_CPPFLAGS = -I$(SS_TOPSRCDIR)/src/kvilib/include/ -I$(SS_TOPSRCDIR)/src/kvirc/include/ \
+$(SS_INCDIRS) $(SS_CPPFLAGS) -DGLOBAL_KVIRC_DIR=\"$(globalkvircdir)\"
+
+pluglib_LTLIBRARIES = libkvireguser.la
+
+libkvireguser_la_LDFLAGS = -module -avoid-version $(SS_LDFLAGS) $(SS_LIBDIRS)
+
+libkvireguser_la_SOURCES = libkvireguser.cpp edituser.cpp wizard.cpp dialog.cpp
+libkvireguser_la_LIBADD = $(SS_LIBLINK) ../../kvilib/build/libkvilib.la
+
+noinst_HEADERS= edituser.h wizard.h dialog.h
+nodist_libkvireguser_la_SOURCES = moc_dialog.cpp
+
+%.moc: %.h
+ $(SS_QT_MOC) $< -o $@
+
+moc_dialog.cpp: dialog.h
+ $(SS_QT_MOC) $< -o $@
+
+edituser.cpp: edituser.moc
+wizard.cpp: wizard.moc
diff --git a/src/modules/reguser/dialog.cpp b/src/modules/reguser/dialog.cpp
new file mode 100644
index 00000000..b8d02fe2
--- /dev/null
+++ b/src/modules/reguser/dialog.cpp
@@ -0,0 +1,903 @@
+//=============================================================================
+//
+// File : edituser.cpp
+// Creation date : Tue Dec 26 2000 12:24:12 CEST by Szymon Stefanek
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 2000-2004 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+//=============================================================================
+#define _WANT_OPTION_FLAGS_
+
+#include "edituser.h"
+#include "kvi_regusersdb.h"
+
+#include "kvi_locale.h"
+#include "kvi_ircmask.h"
+#include "kvi_debug.h"
+#include "kvi_iconmanager.h"
+#include "kvi_app.h"
+#include "kvi_options.h"
+#include "kvi_file.h"
+#include "kvi_filedialog.h"
+#include "kvi_msgbox.h"
+#include "kvi_fileutils.h"
+#include "kvi_settings.h"
+#include "kvi_stringconversion.h"
+#include "kvi_options.h"
+
+#include <qlayout.h>
+#include <qlabel.h>
+#ifdef COMPILE_USE_QT4
+#include <q3header.h>
+#include <qevent.h>
+#include <QImageWriter>
+#include <QImageReader>
+
+#else
+#include <qheader.h>
+#endif
+#include "kvi_pointerhashtable.h"
+#include <qimage.h>
+#include <qstring.h>
+#include <qcombobox.h>
+
+
+#include <qstyle.h>
+#include <qpainter.h>
+#include "kvi_tal_hbox.h"
+#include "kvi_tal_vbox.h"
+#include <qinputdialog.h>
+
+#include "wizard.h"
+#include "dialog.h"
+
+
+#ifdef COMPILE_INFO_TIPS
+ #include <qtooltip.h>
+#endif // COMPILE_INFO_TIPS
+
+
+#define LVI_ICON_SIZE 32
+#define LVI_BORDER 4
+#define LVI_SPACING 8
+#define LVI_MINIMUM_TEXT_WIDTH 300
+#define LVI_MINIMUM_CELL_WIDTH (LVI_MINIMUM_TEXT_WIDTH + LVI_BORDER + LVI_ICON_SIZE + LVI_SPACING + LVI_BORDER)
+
+
+extern KviRegisteredUsersDialog * g_pRegisteredUsersDialog;
+
+KviRegisteredUsersDialogItem::KviRegisteredUsersDialogItem(KviTalListViewItem * par,KviRegisteredUser * u)
+: KviRegisteredUsersDialogItemBase(User,par), m_pUser(u)
+{
+ QString szTmp;
+ QString t = "<nobr><b>";
+ t += u->name();
+ t += "</b> [";
+ szTmp = m_pUser->getProperty("notify");
+ if(szTmp.isEmpty())
+ {
+ t += __tr2qs("Notify disabled");
+ } else {
+ t += __tr2qs("Notify as: ");
+ t += szTmp;
+
+ }
+ t += "]</nobr>";
+ t += "<br><nobr><font size=\"-1\">";
+ szTmp = m_pUser->getProperty("comment");
+ if(szTmp.isEmpty())
+ {
+ t += __tr2qs("No comment set");
+ } else {
+ t += __tr2qs("Comment: ");
+ t += m_pUser->getProperty("comment");
+ }
+ t += "</font></nobr>";
+ m_pText = new QSimpleRichText(t,listView()->font());
+
+ //setText(0,u->name());
+}
+
+KviRegisteredUsersDialogItem::~KviRegisteredUsersDialogItem()
+{
+ delete m_pText;
+}
+
+QString KviRegisteredUsersDialogItem::key(int,bool) const
+{
+ return m_pUser->name();
+}
+
+void KviRegisteredUsersDialogItem::paintCell(QPainter * p,const QColorGroup &cg,int column,int width,int align)
+{
+ KviTalListViewItem::paintCell(p,cg,column,width,align);
+ if(column==0)
+ {
+ p->drawPixmap(LVI_BORDER,LVI_BORDER, *(g_pIconManager->getBigIcon(QString(KVI_BIGICON_REGUSERS))) );
+ int afterIcon = LVI_BORDER + LVI_ICON_SIZE + LVI_SPACING;
+ int www = listView()->visibleWidth() - (afterIcon + LVI_BORDER);
+ m_pText->setWidth(www);
+ if(isSelected())
+ {
+ QColorGroup cg2(cg);
+ cg2.setColor(QColorGroup::HighlightedText,cg.text());
+ m_pText->draw(p,afterIcon,LVI_BORDER,QRect(afterIcon,LVI_BORDER,www,height() - (LVI_BORDER * 2)),cg2);
+ } else {
+ m_pText->draw(p,afterIcon,LVI_BORDER,QRect(afterIcon,LVI_BORDER,www,height() - (LVI_BORDER * 2)),cg);
+ }
+ } else {
+ if(m_pUser)
+ {
+ if(!m_pUser->getProperty("notify").isEmpty())
+ p->drawPixmap(LVI_BORDER,LVI_BORDER,*(g_pIconManager->getSmallIcon(KVI_SMALLICON_NOTIFYONLINE)));
+ if(m_pUser->ignoreEnagled())
+ p->drawPixmap(LVI_BORDER,2*LVI_BORDER+16,*(g_pIconManager->getSmallIcon(KVI_SMALLICON_IGNORE)));
+ }
+ }
+}
+
+void KviRegisteredUsersDialogItem::setup()
+{
+ KviTalListViewItem::setup();
+ int iWidth = listView()->visibleWidth();
+ if(iWidth < LVI_MINIMUM_CELL_WIDTH)iWidth = LVI_MINIMUM_CELL_WIDTH;
+ iWidth -= LVI_BORDER + LVI_ICON_SIZE + LVI_SPACING + LVI_BORDER;
+ m_pText->setWidth(iWidth);
+ int iHeight = m_pText->height() + (2 * LVI_BORDER);
+ if(iHeight < (LVI_ICON_SIZE + (2 * LVI_BORDER)))iHeight = LVI_ICON_SIZE + (2 * LVI_BORDER);
+ setHeight(iHeight);
+}
+
+
+KviRegisteredUsersDialog::KviRegisteredUsersDialog(QWidget * par)
+: QWidget(par)
+{
+ g_pRegisteredUsersDialog = this;
+
+ g_pLocalRegisteredUserDataBase = new KviRegisteredUserDataBase();
+ g_pLocalRegisteredUserDataBase->copyFrom(g_pRegisteredUserDataBase);
+
+ setIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_REGUSERS)));
+ setCaption(__tr2qs("Registered Users - KVIrc"));
+
+ QGridLayout * g = new QGridLayout(this,4,3,4,4);
+
+
+ m_pListView = new KviTalListView(this);
+
+ m_pListView->addColumn(__tr2qs("Name"),200);
+ m_pListView->addColumn(__tr2qs("Flags"),20);
+
+ m_pListView->setAllColumnsShowFocus(true);
+
+ m_pListView->setSelectionMode(KviTalListView::Extended);
+ m_pListView->setRootIsDecorated(TRUE);
+
+#ifdef COMPILE_INFO_TIPS
+ QToolTip::add(m_pListView,__tr2qs("<center>This is the list of registered users. " \
+ "KVIrc can automatically recognize and associate properties to them.<br>" \
+ "Use the buttons on the right to add, edit and remove entries. " \
+ "The \"notify\" column allows you to quickly add users to the notify list. " \
+ "Notify list fine-tuning can be performed by editing the entry properties.</center>"));
+#endif // COMPILE_INFO_TIPS
+
+ connect(m_pListView,SIGNAL(pressed(KviTalListViewItem *,const QPoint &,int)),this,SLOT(itemPressed(KviTalListViewItem *,const QPoint &,int)));
+ connect(m_pListView,SIGNAL(doubleClicked(KviTalListViewItem *)),this,SLOT(itemDoubleClicked(KviTalListViewItem *)));
+
+ g->addMultiCellWidget(m_pListView,0,1,0,1);
+
+ KviTalVBox * vbox = new KviTalVBox(this);
+ vbox->setSpacing(4);
+ g->addWidget(vbox,0,2);
+
+ m_pWizardAddButton = new QPushButton(__tr2qs("Add (Wizard)..."),vbox);
+ connect(m_pWizardAddButton,SIGNAL(clicked()),this,SLOT(addWizardClicked()));
+#ifdef COMPILE_INFO_TIPS
+ QToolTip::add(m_pWizardAddButton,__tr2qs("Add a registered user by means of a user-friendly wizard."));
+#endif // COMPILE_INFO_TIPS
+ m_pWizardAddButton->setIconSet(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_NEWITEMBYWIZARD)));
+
+
+ m_pAddButton = new QPushButton(__tr2qs("&Add..."),vbox);
+ connect(m_pAddButton,SIGNAL(clicked()),this,SLOT(addClicked()));
+#ifdef COMPILE_INFO_TIPS
+ QToolTip::add(m_pAddButton,__tr2qs("Open the edit dialog to create a new user entry."));
+#endif // COMPILE_INFO_TIPS
+ m_pAddButton->setIconSet(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_NEWITEM)));
+
+ m_pAddGroupButton = new QPushButton(__tr2qs("&Add Group..."),vbox);
+ connect(m_pAddGroupButton,SIGNAL(clicked()),this,SLOT(addGroupClicked()));
+#ifdef COMPILE_INFO_TIPS
+ QToolTip::add(m_pAddGroupButton,__tr2qs("Adds a new group"));
+#endif // COMPILE_INFO_TIPS
+ m_pAddGroupButton->setIconSet(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_NEWITEM)));
+
+ m_pRemoveButton = new QPushButton(__tr2qs("Re&move"),vbox);
+ connect(m_pRemoveButton,SIGNAL(clicked()),this,SLOT(removeClicked()));
+ m_pRemoveButton->setEnabled(false);
+#ifdef COMPILE_INFO_TIPS
+ QToolTip::add(m_pRemoveButton,__tr2qs("Remove the currently selected entries."));
+#endif // COMPILE_INFO_TIPS
+ m_pRemoveButton->setIconSet(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_DELETEITEM)));
+
+
+ m_pEditButton = new QPushButton(__tr2qs("&Edit..."),vbox);
+ connect(m_pEditButton,SIGNAL(clicked()),this,SLOT(editClicked()));
+ m_pEditButton->setEnabled(false);
+#ifdef COMPILE_INFO_TIPS
+ QToolTip::add(m_pEditButton,__tr2qs("Edit the first selected entry."));
+#endif // COMPILE_INFO_TIPS
+ m_pEditButton->setIconSet(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_EDITITEM)));
+
+ QFrame * f = new QFrame(vbox);
+ f->setFrameStyle(QFrame::HLine | QFrame::Sunken);
+
+ m_pExportButton = new QPushButton(__tr("Export To..."),vbox);
+ m_pExportButton->setEnabled(false);
+ connect(m_pExportButton,SIGNAL(clicked()),this,SLOT(exportClicked()));
+#ifdef COMPILE_INFO_TIPS
+ QToolTip::add(m_pExportButton,__tr2qs("Export the selected entries to a file.<br>All the data associated with the selected registered users will be exported.<br>You (or anyone else) can later import the entries by using the \"Import\" button."));
+#endif // COMPILE_INFO_TIPS
+ m_pExportButton->setIconSet(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_FLOPPY)));
+
+
+ m_pImportButton = new QPushButton(__tr("Import From..."),vbox);
+ connect(m_pImportButton,SIGNAL(clicked()),this,SLOT(importClicked()));
+#ifdef COMPILE_INFO_TIPS
+ QToolTip::add(m_pImportButton,__tr2qs("Import entries from a file exported earlier by the \"export\" function of this dialog."));
+#endif // COMPILE_INFO_TIPS
+ m_pImportButton->setIconSet(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_FOLDER)));
+
+
+ KviTalHBox * hbox = new KviTalHBox(this);
+ hbox->setSpacing(4);
+ g->addMultiCellWidget(hbox,3,3,1,2);
+
+ QPushButton * b;
+
+
+ b = new QPushButton(__tr2qs("&OK"),hbox);
+ connect(b,SIGNAL(clicked()),this,SLOT(okClicked()));
+ b->setIconSet(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_ACCEPT)));
+ //b->setMinimumWidth(120);
+
+ b = new QPushButton(__tr2qs("Cancel"),hbox);
+ connect(b,SIGNAL(clicked()),this,SLOT(cancelClicked()));
+ b->setIconSet(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_DISCARD)));
+ //b->setMinimumWidth(120);
+
+
+ g->addRowSpacing(2,15);
+
+ g->setColStretch(0,1);
+ g->setRowStretch(1,1);
+
+ connect(m_pListView,SIGNAL(selectionChanged()),this,SLOT(selectionChanged()));
+ connect(m_pListView,SIGNAL(rightButtonClicked ( KviTalListViewItem *, const QPoint &, int ) ),this,SLOT(listViewRightButtonClicked ( KviTalListViewItem *, const QPoint &, int )));
+
+ fillList();
+
+ if(!parent())
+ {
+ if(KVI_OPTION_RECT(KviOption_rectRegisteredUsersDialogGeometry).y() < 5)
+ {
+ KVI_OPTION_RECT(KviOption_rectRegisteredUsersDialogGeometry).setY(5);
+ }
+ //setGeometry(KVI_OPTION_RECT(KviOption_rectRegisteredUsersDialogGeometry));
+ resize(KVI_OPTION_RECT(KviOption_rectRegisteredUsersDialogGeometry).width(),
+ KVI_OPTION_RECT(KviOption_rectRegisteredUsersDialogGeometry).height());
+ move(KVI_OPTION_RECT(KviOption_rectRegisteredUsersDialogGeometry).x(),
+ KVI_OPTION_RECT(KviOption_rectRegisteredUsersDialogGeometry).y());
+ }
+}
+
+KviRegisteredUsersDialog::~KviRegisteredUsersDialog()
+{
+#ifndef Q_OS_MACX
+ if(!parent())KVI_OPTION_RECT(KviOption_rectRegisteredUsersDialogGeometry) = QRect(pos().x(),pos().y(),
+ size().width(),size().height());
+#else
+ if(!parent())KVI_OPTION_RECT(KviOption_rectRegisteredUsersDialogGeometry) = geometry();
+#endif
+
+ g_pRegisteredUsersDialog = 0;
+
+ delete g_pLocalRegisteredUserDataBase;
+ g_pLocalRegisteredUserDataBase = 0;
+}
+
+void KviRegisteredUsersDialog::itemPressed(KviTalListViewItem *it,const QPoint &pnt,int c)
+{
+ if(!it)return;
+ KviRegisteredUsersDialogItemBase* b=(KviRegisteredUsersDialogItemBase*)it;
+ if(b->type()==KviRegisteredUsersDialogItemBase::User)
+ {
+ KviRegisteredUsersDialogItem *i = (KviRegisteredUsersDialogItem *)it;
+
+ QRect r = m_pListView->itemRect(i);
+ int daw = m_pListView->columnWidth(0);
+
+ QPoint ppp = m_pListView->mapFromGlobal(pnt);
+
+ if((c == 1) && (ppp.x() < (r.height() + 5 + daw)))
+ {
+ // notify list toggle
+ if(i->user()->getProperty("notify").isEmpty())
+ {
+ i->user()->setProperty("notify",""); // kill that
+ } else {
+ // try to find the nicknames to be notified
+ QString szMask;
+
+ for(KviIrcMask * m = i->user()->maskList()->first();m;m = i->user()->maskList()->next())
+ {
+ QString tmp = m->nick();
+ if((tmp.find('*') == -1) && (tmp.find('?') == -1) && (!tmp.isEmpty()))
+ {
+ if(!szMask.isEmpty())szMask.append(' ');
+ szMask.append(tmp);
+ }
+ }
+ // if the nickname list is still empty , build a dummy nick to notify
+ szMask = i->user()->name();
+ szMask.replace(" ","");
+ szMask.replace("'","");
+ szMask.replace("&","");
+ szMask.replace(",","");
+
+ i->user()->setProperty("notify",szMask);
+ }
+ m_pListView->update();
+ }
+ }
+}
+
+void KviRegisteredUsersDialog::itemDoubleClicked(KviTalListViewItem *it)
+{
+ if(!it)return;
+ KviRegisteredUsersDialogItemBase* b=(KviRegisteredUsersDialogItemBase*)it;
+ if(b->type()==KviRegisteredUsersDialogItemBase::User)
+ {
+ editItem((KviRegisteredUsersDialogItem *)it);
+ } else {
+ KviRegisteredUsersGroupItem *i = (KviRegisteredUsersGroupItem *)b;
+ editGroup(i->group());
+ }
+}
+
+void KviRegisteredUsersDialog::addGroupClicked()
+{
+ bool ok;
+ QString text = QInputDialog::getText(
+ "KVIrc", __tr("Group name:"), QLineEdit::Normal,
+ QString::null, &ok, this );
+ if ( ok && !text.isEmpty() ) {
+ g_pLocalRegisteredUserDataBase->addGroup(text);
+ fillList();
+ }
+}
+void KviRegisteredUsersDialog::editGroup(KviRegisteredUserGroup* group)
+{
+ bool ok;
+
+ QString text = QInputDialog::getText(
+ "KVIrc", __tr("Group name:"), QLineEdit::Normal,
+ group->name(), &ok, this );
+ if ( ok && !text.isEmpty() ) {
+ QString szOldGroup=group->name();
+ g_pLocalRegisteredUserDataBase->groupDict()->setAutoDelete(0);
+ g_pLocalRegisteredUserDataBase->groupDict()->remove(szOldGroup);
+ g_pLocalRegisteredUserDataBase->groupDict()->setAutoDelete(1);
+ group->setName(text);
+ g_pLocalRegisteredUserDataBase->groupDict()->insert(text,group);
+
+ KviPointerHashTable<QString,KviRegisteredUser> * d = g_pLocalRegisteredUserDataBase->userDict();
+
+ for(KviRegisteredUser * u = d->first();u;u = d->next())
+ {
+ if(u->group()==szOldGroup)
+ u->setGroup(text);
+ }
+
+
+ fillList();
+ }
+}
+
+void KviRegisteredUsersDialog::listViewRightButtonClicked ( KviTalListViewItem * pItem, const QPoint & point, int )
+{
+ if(pItem)
+ {
+ KviRegisteredUsersDialogItemBase* b=(KviRegisteredUsersDialogItemBase*)pItem;
+ if(b->type()==KviRegisteredUsersDialogItemBase::User)
+ {
+ KviTalPopupMenu *groups = new KviTalPopupMenu;
+
+ KviPointerHashTable<QString,KviRegisteredUserGroup> * pGroups = g_pLocalRegisteredUserDataBase->groupDict();
+ m_TmpDict.clear();
+ for(KviPointerHashTableEntry<QString,KviRegisteredUserGroup> * g = pGroups->firstEntry();g;g = pGroups->nextEntry())
+ {
+ int id=groups->insertItem(g->key());
+ m_TmpDict.replace(id,g->data());
+ }
+
+ connect(groups,SIGNAL(activated ( int )),this,SLOT(moveToGroupMenuClicked(int)));
+
+ KviTalPopupMenu *mainPopup = new KviTalPopupMenu;
+ mainPopup->insertItem(__tr("Move to group"),groups);
+ mainPopup->exec(point);
+ }
+ }
+}
+
+void KviRegisteredUsersDialog::moveToGroupMenuClicked(int id)
+{
+ QString szGroup=m_TmpDict.find(id)->name();
+ KviTalListViewItemIterator it( m_pListView, KviTalListViewItemIterator::Selected );
+ while ( it.current() ) {
+ KviRegisteredUsersDialogItemBase* b=(KviRegisteredUsersDialogItemBase*)(it.current());
+ if(b->type()==KviRegisteredUsersDialogItemBase::User)
+ {
+ ((KviRegisteredUsersDialogItem *)(it.current()))->user()->setGroup(szGroup);
+ }
+ ++it;
+ }
+ fillList();
+}
+
+void KviRegisteredUsersDialog::fillList()
+{
+ m_pListView->clear();
+ KviPointerHashTable<QString,KviRegisteredUsersGroupItem> groupItems(5,false);
+ groupItems.setAutoDelete(false);
+
+ KviPointerHashTable<QString,KviRegisteredUserGroup> * pGroups = g_pLocalRegisteredUserDataBase->groupDict();
+ for(KviRegisteredUserGroup * g = pGroups->first();g;g = pGroups->next())
+ {
+ KviRegisteredUsersGroupItem* pCur = new KviRegisteredUsersGroupItem(m_pListView,g);
+ groupItems.insert(g->name(),pCur);
+ pCur->setOpen(TRUE);
+ }
+
+ KviPointerHashTable<QString,KviRegisteredUser> * d = g_pLocalRegisteredUserDataBase->userDict();
+ KviRegisteredUsersDialogItem * item;
+
+ for(KviRegisteredUser * u = d->first();u;u = d->next())
+ {
+ if(u->group().isEmpty())
+ u->setGroup(__tr("Default"));
+ if(groupItems.find(u->group()))
+ item = new KviRegisteredUsersDialogItem(groupItems.find(u->group()),u);
+ else if(groupItems.find(__tr("Default")))
+ item = new KviRegisteredUsersDialogItem(groupItems.find(__tr("Default")),u);
+ else { //should never be called
+ KviRegisteredUserGroup* pGroup = g_pLocalRegisteredUserDataBase->addGroup(__tr("Default"));
+ KviRegisteredUsersGroupItem* pCur = new KviRegisteredUsersGroupItem(m_pListView,pGroup);
+ groupItems.insert(__tr("Default"),pCur);
+ item = new KviRegisteredUsersDialogItem(pCur,u);
+ }
+ }
+ if(m_pListView->firstChild())
+ {
+ m_pListView->setSelected(m_pListView->firstChild(),true);
+ m_pListView->setCurrentItem(m_pListView->firstChild());
+ }
+}
+
+void KviRegisteredUsersDialog::closeEvent(QCloseEvent *e)
+{
+ m_pListView->clear();
+ e->accept();
+ okClicked();
+ //delete this;
+}
+
+void KviRegisteredUsersDialog::okClicked()
+{
+ m_pListView->clear();
+ g_pRegisteredUserDataBase->copyFrom(g_pLocalRegisteredUserDataBase);
+ g_pApp->restartNotifyLists();
+ delete this;
+}
+
+void KviRegisteredUsersDialog::cancelClicked()
+{
+ m_pListView->clear();
+ delete this;
+}
+
+void KviRegisteredUsersDialog::addClicked()
+{
+ KviRegisteredUserEntryDialog * dlg = new KviRegisteredUserEntryDialog(this,0);
+ int ret = dlg->exec();
+ delete dlg;
+
+ if(!g_pRegisteredUsersDialog)return; // we have been deleted!
+
+ if(ret == QDialog::Accepted)
+ {
+ fillList();
+ }
+}
+
+void KviRegisteredUsersDialog::addWizardClicked()
+{
+ KviRegistrationWizard * w = new KviRegistrationWizard("",g_pLocalRegisteredUserDataBase,this,true);
+ int ret = w->exec();
+ delete w;
+ if(!g_pRegisteredUsersDialog)return; // we have been deleted!
+ if(ret == QDialog::Accepted)
+ {
+ fillList();
+ }
+}
+
+void KviRegisteredUsersDialog::removeClicked()
+{
+ KviTalListViewItemIterator it( m_pListView, KviTalListViewItemIterator::Selected );
+ while ( it.current() ) {
+ KviRegisteredUsersDialogItemBase* b=(KviRegisteredUsersDialogItemBase*)(it.current());
+ if(b->type()==KviRegisteredUsersDialogItemBase::User)
+ {
+ g_pLocalRegisteredUserDataBase->removeUser(((KviRegisteredUsersDialogItem *)(it.current()))->user()->name());
+ } else {
+ g_pLocalRegisteredUserDataBase->removeGroup(((KviRegisteredUsersGroupItem *)(it.current()))->group()->name());
+ }
+ ++it;
+ }
+ fillList();
+// KviRegisteredUsersDialogItem *it = (KviRegisteredUsersDialogItem *)m_pListView->firstChild();
+// KviRegisteredUsersDialogItemBase* b=(KviRegisteredUsersDialogItemBase*)it;
+// if(b->type()==KviRegisteredUsersDialogItemBase::User)
+// {
+// KviPointerList<KviRegisteredUsersDialogItem> l;
+// l.setAutoDelete(false);
+// while(it)
+// {
+// if(it->isSelected())l.append(it);
+// it = (KviRegisteredUsersDialogItem *)it->nextSibling();
+// }
+//
+// for(KviRegisteredUsersDialogItem * i = l.first();i;i = l.next())
+// {
+// //g_pLocalRegisteredUserDataBase->removeUser(i->user()->name());
+// delete i;
+// }
+// } else {
+//
+// }
+}
+
+void KviRegisteredUsersDialog::editClicked()
+{
+ KviRegisteredUsersDialogItemBase* b=(KviRegisteredUsersDialogItemBase*)(m_pListView->currentItem());
+ if(!b)return;
+ if(b->type()==KviRegisteredUsersDialogItemBase::User)
+ {
+ KviRegisteredUsersDialogItem *i = (KviRegisteredUsersDialogItem *)b;
+ editItem(i);
+ } else {
+ KviRegisteredUsersGroupItem *i = (KviRegisteredUsersGroupItem *)b;
+ editGroup(i->group());
+ }
+}
+
+void KviRegisteredUsersDialog::editItem(KviRegisteredUsersDialogItem * i)
+{
+ KviRegisteredUser * u = i->user();
+
+ i->setUser(0);
+
+ QString szName = u->name();
+
+ KviRegisteredUserEntryDialog * dlg = new KviRegisteredUserEntryDialog(this,u);
+ int res = dlg->exec();
+ delete dlg;
+
+ if(!g_pRegisteredUsersDialog)return; // we have been deleted!
+
+ if(res == QDialog::Accepted)
+ {
+ fillList();
+
+ // select the last edited item
+ KviTalListViewItem * i = m_pListView->firstChild();
+ while(i)
+ {
+ QString szTmp = i->text(0);
+ if(KviQString::equalCI(szTmp,szName))
+ {
+ m_pListView->setSelected(i,true);
+ m_pListView->setCurrentItem(i);
+ break;
+ }
+ i = i->nextSibling();
+ }
+
+ return;
+ }
+
+ i->setUser(u);
+ m_pListView->update();
+}
+
+
+void KviRegisteredUsersDialog::selectionChanged()
+{
+ bool bHaveSelected = !m_pListView->selectedItem();
+
+ m_pEditButton->setEnabled(bHaveSelected);
+ m_pRemoveButton->setEnabled(bHaveSelected);
+ m_pExportButton->setEnabled(bHaveSelected);
+}
+
+
+#define KVI_REGUSER_DB_FILE_MAGIC 0x5334DBDB
+#define KVI_REGUSER_DB_FILE_VERSION 1
+
+typedef struct _KviReguserDbFileHeader
+{
+ unsigned int magic;
+ unsigned int version;
+ unsigned int nentries;
+} KviReguserDbFileHeader;
+
+void KviRegisteredUsersDialog::exportClicked()
+{
+ unsigned int nEntries = 0;
+
+ KviTalListViewItemIterator it( m_pListView, KviTalListViewItemIterator::Selected );
+ KviTalListViewItemIterator cit( m_pListView, KviTalListViewItemIterator::Selected );
+ while ( cit.current() ) {
+ if(((KviRegisteredUsersDialogItemBase *)(cit.current()))->type() == KviRegisteredUsersDialogItemBase::User)
+ nEntries++;
+ ++cit;
+ }
+
+ if(nEntries < 1)
+ {
+ KviMessageBox::warning(__tr("No entries selected."));
+ return;
+ }
+
+ QString buffer;
+
+ if(!KviFileDialog::askForSaveFileName(buffer,__tr("Choose a Filename - KVIrc"),0,0,true,true))return;
+
+ if(!g_pRegisteredUsersDialog)return; // we have been deleted!
+
+ KviFile f(buffer);
+ if(!f.open(IO_WriteOnly | IO_Truncate))
+ {
+ KviMessageBox::warning(__tr("Can't open file %Q for writing."),&buffer);
+ return;
+ }
+
+ KviReguserDbFileHeader hf;
+ hf.magic = KVI_REGUSER_DB_FILE_MAGIC;
+ hf.version = KVI_REGUSER_DB_FILE_VERSION;
+ hf.nentries = nEntries;
+
+ if(f.writeBlock((const char *)&hf,sizeof(KviReguserDbFileHeader)) != sizeof(KviReguserDbFileHeader))goto write_error;
+
+ while ( it.current() ) {
+ KviRegisteredUsersDialogItemBase *pBase = (KviRegisteredUsersDialogItemBase *)(it.current());
+ if(pBase->type()!=KviRegisteredUsersDialogItemBase::User) continue;
+ QString szName = it.current()->text(0);
+ KviRegisteredUser * u = ((KviRegisteredUsersDialogItem *)(it.current()))->user();
+ if(u)
+ {
+ if(!f.save(szName))goto write_error;
+ KviPointerHashTable<QString,QString> * pd = u->propertyDict();
+ if(pd)
+ {
+ if(!f.save(pd->count()))goto write_error;
+ for(KviPointerHashTableEntry<QString,QString> * pCur = pd->firstEntry();pCur;pCur = pd->nextEntry())
+ {
+ QString key = pCur->key();
+ if(!f.save(key))goto write_error;
+ if(!f.save(*(pCur->data())))goto write_error;
+ }
+ } else {
+ if(!f.save(0))goto write_error;
+ }
+
+ KviPointerList<KviIrcMask> * ml = u->maskList();
+ if(ml)
+ {
+ if(!f.save(ml->count()))goto write_error;
+ for(KviIrcMask * m = ml->first();m;m = ml->next())
+ {
+ QString fullMask;
+ m->mask(fullMask,KviIrcMask::NickUserHost);
+ if(!f.save(fullMask))goto write_error;
+ }
+ } else {
+ if(!f.save(0))goto write_error;
+ }
+
+ QString avatar;
+ if(u->getProperty("avatar",avatar))
+ {
+ KviAvatar * av = g_pIconManager->getAvatar(QString::null,avatar);
+ if(av)
+ {
+ if(!av->pixmap()->isNull())
+ {
+ if(!f.save(1))goto write_error;
+#ifdef COMPILE_USE_QT4
+ QImageWriter io;
+ io.setDevice(&f);
+ io.setFormat("PNG");
+ if(!io.write(av->pixmap()->convertToImage()))goto write_error;
+#else
+ QImageIO io;
+ io.setImage(av->pixmap()->convertToImage());
+ io.setIODevice(&f);
+ io.setFormat("PNG");
+ if(!io.write())goto write_error;
+#endif
+ } else {
+ if(!f.save(0))goto write_error;
+ }
+ } else {
+ if(!f.save(0))goto write_error;
+ }
+ } else {
+ if(!f.save(0))goto write_error;
+ }
+ }
+ ++it;
+ }
+
+ goto succesfull_export;
+
+
+write_error:
+ KviMessageBox::warning(__tr("Can't export the registered users database: Write error."));
+ f.close();
+ return;
+
+succesfull_export:
+
+ f.close();
+}
+
+void KviRegisteredUsersDialog::importClicked()
+{
+ //KviStr buffer;
+ QString buffer;
+
+ if(!KviFileDialog::askForOpenFileName(buffer,__tr("Choose a Filename - KVIrc")))return;
+
+ if(!g_pRegisteredUsersDialog)return; // we have been deleted!
+
+ KviFile f(buffer);
+ if(!f.open(IO_ReadOnly))
+ {
+ KviMessageBox::warning(__tr2qs("Can't open file %s for reading."),&buffer);
+ return;
+ }
+
+ KviReguserDbFileHeader hf;
+ unsigned int idx;
+
+ if(f.readBlock((char *)&hf,sizeof(KviReguserDbFileHeader)) != sizeof(KviReguserDbFileHeader))goto read_error;
+
+ if(hf.magic != KVI_REGUSER_DB_FILE_MAGIC)
+ {
+ KviMessageBox::warning(__tr2qs("The file %s doesn't appear to be a valid registered users database."),&buffer);
+ f.close();
+ return;
+ }
+
+ if(hf.version != KVI_REGUSER_DB_FILE_VERSION)
+ {
+ KviMessageBox::warning(__tr2qs("The file %s contains an invalid registered users database version."),&buffer);
+ f.close();
+ return;
+ }
+
+
+
+ for(idx = 0;idx < hf.nentries;idx++)
+ {
+ QString szName;
+ if(!f.load(szName))goto read_error;
+ KviRegisteredUser * u = g_pLocalRegisteredUserDataBase->getUser(szName);
+ unsigned int count = 0;
+ if(!f.load(count))goto read_error;
+ for(unsigned int up = 0;up < count;up++)
+ {
+ QString szKey,szValue;
+ if(!f.load(szKey))goto read_error;
+ if(!f.load(szValue))goto read_error;
+ u->setProperty(szKey,szValue);
+ }
+ if(!f.load(count))goto read_error;
+ for(unsigned int um = 0;um < count;um++)
+ {
+ QString szMask;
+ if(!f.load(szMask))goto read_error;
+ if(!szMask.isEmpty())
+ {
+ KviIrcMask * m = new KviIrcMask(szMask);
+ g_pLocalRegisteredUserDataBase->addMask(u,m);
+ }
+ }
+ if(!f.load(count))goto read_error;
+ if(count)
+ {
+ // there is an avatar
+ QImage img;
+#ifdef COMPILE_USE_QT4
+ QImageReader io;
+ io.setDevice(&f);
+ io.setFormat("PNG");
+ img=io.read();
+// if(io.read())goto read_error;
+
+#else
+ QImageIO io;
+ io.setImage(img);
+ io.setIODevice(&f);
+ io.setFormat("PNG");
+
+ if(!io.read())goto read_error;
+
+ img = io.image();
+#endif
+ if(img.isNull())debug("Ops.. readed a null image ?");
+
+ KviStr fName = u->name();
+ kvi_encodeFileName(fName);
+
+ KviStr fPath;
+ int rnm = 0 ;
+ do
+ {
+ g_pApp->getLocalKvircDirectory(fPath,KviApp::Avatars,fName.ptr());
+ fPath.append(KviStr::Format,"%d.png",rnm);
+ rnm++;
+ } while(KviFileUtils::fileExists(fPath.ptr()));
+
+ if(!img.save(fPath.ptr(),"PNG"))
+ {
+ debug("Can't save image %s",fPath.ptr());
+ } else {
+ u->setProperty("avatar",fPath.ptr());
+ }
+ }
+ }
+
+ goto succesfull_import;
+
+
+read_error:
+ KviMessageBox::warning(__tr("Can't import the registered users database: Read error."));
+ f.close();
+ return;
+
+succesfull_import:
+
+ f.close();
+ fillList();
+}
+#if defined(COMPILE_USE_QT4) && defined(COMPILE_ON_WINDOWS)
+#include "dialog.moc"
+#endif
diff --git a/src/modules/reguser/dialog.h b/src/modules/reguser/dialog.h
new file mode 100644
index 00000000..c292adc4
--- /dev/null
+++ b/src/modules/reguser/dialog.h
@@ -0,0 +1,148 @@
+#ifndef _DIALOG_H_
+#define _DIALOG_H_
+//=============================================================================
+//
+// File : edituser.h
+// Creation date : Sun Dec 24 2000 15:16:17 CEST by Szymon Stefanek
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 2000-2004 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+//=============================================================================
+#include "kvi_string.h"
+#include "kvi_regusersdb.h"
+#include "kvi_selectors.h"
+
+#include <qwidget.h>
+#include <qlineedit.h>
+#include <qpushbutton.h>
+#include "kvi_tal_listview.h"
+#include "kvi_tal_listbox.h"
+#include "kvi_pointerhashtable.h"
+#include "kvi_tal_popupmenu.h"
+#ifdef COMPILE_USE_QT4
+ #include <q3intdict.h>
+ #include <q3simplerichtext.h>
+ #define QSimpleRichText Q3SimpleRichText
+#else
+ #include <qsimplerichtext.h>
+ #include <qintdict.h>
+
+
+#endif
+
+class KviRegisteredUsersDialogItemBase : public KviTalListViewItem
+{
+public:
+ enum Types { User,Group };
+protected:
+ KviRegisteredUsersDialogItemBase(Types type,KviTalListView * par)
+ :KviTalListViewItem(par),m_iType(type)
+ {
+ };
+ KviRegisteredUsersDialogItemBase(Types type,KviTalListViewItem * par)
+ :KviTalListViewItem(par),m_iType(type)
+ {
+ };
+ ~KviRegisteredUsersDialogItemBase()
+ {
+ };
+
+private:
+ KviRegisteredUsersDialogItemBase::Types m_iType;
+public:
+ KviRegisteredUsersDialogItemBase::Types type() { return m_iType; };
+};
+
+class KviRegisteredUsersGroupItem : public KviRegisteredUsersDialogItemBase
+{
+protected:
+ KviRegisteredUserGroup * m_pGroup;
+public:
+ KviRegisteredUsersGroupItem(KviTalListView * par,KviRegisteredUserGroup * g)
+ :KviRegisteredUsersDialogItemBase(Group,par), m_pGroup(g)
+ {
+ setText(0,m_pGroup->name());
+ }
+ ~KviRegisteredUsersGroupItem()
+ {
+ }
+ KviRegisteredUserGroup * group() { return m_pGroup; };
+};
+
+class KviRegisteredUsersDialogItem : public KviRegisteredUsersDialogItemBase
+{
+protected:
+ KviRegisteredUser * m_pUser;
+ QSimpleRichText * m_pText;
+public:
+ KviRegisteredUsersDialogItem(KviTalListViewItem * par,KviRegisteredUser * u);
+ ~KviRegisteredUsersDialogItem();
+public:
+ KviRegisteredUser * user(){ return m_pUser; };
+ void setUser(KviRegisteredUser * u){ m_pUser = u; };
+ virtual void paintCell(QPainter * p,const QColorGroup &cg,int column,int width,int align);
+ virtual void setup();
+ virtual QString key(int,bool) const;
+};
+
+class KviRegisteredUsersDialog : public QWidget
+{
+ Q_OBJECT
+public:
+ KviRegisteredUsersDialog(QWidget * par = 0);
+ ~KviRegisteredUsersDialog();
+public:
+ KviTalListView * m_pListView;
+ QPushButton * m_pAddButton;
+ QPushButton * m_pWizardAddButton;
+ QPushButton * m_pRemoveButton;
+ QPushButton * m_pEditButton;
+ QPushButton * m_pImportButton;
+ QPushButton * m_pExportButton;
+ QPushButton * m_pAddGroupButton;
+#ifdef COMPILE_USE_QT4
+ Q3IntDict<KviRegisteredUserGroup> m_TmpDict;
+#else
+ QIntDict<KviRegisteredUserGroup> m_TmpDict;
+#endif
+
+ protected slots:
+ void itemPressed(KviTalListViewItem *it,const QPoint &pnt,int c);
+ void itemDoubleClicked(KviTalListViewItem *it);
+protected:
+ void fillList();
+protected:
+ virtual void closeEvent(QCloseEvent *);
+ void editItem(KviRegisteredUsersDialogItem * i);
+ void editGroup(KviRegisteredUserGroup* group);
+protected slots:
+ void cancelClicked();
+ void okClicked();
+ void addClicked();
+ void removeClicked();
+ void editClicked();
+ void selectionChanged();
+ void importClicked();
+ void exportClicked();
+ void addWizardClicked();
+ void addGroupClicked();
+ void listViewRightButtonClicked ( KviTalListViewItem *, const QPoint &, int );
+ void moveToGroupMenuClicked(int);
+};
+
+#endif
diff --git a/src/modules/reguser/edituser.cpp b/src/modules/reguser/edituser.cpp
new file mode 100644
index 00000000..f0d6d6b9
--- /dev/null
+++ b/src/modules/reguser/edituser.cpp
@@ -0,0 +1,781 @@
+//=============================================================================
+//
+// File : edituser.cpp
+// Creation date : Tue Dec 26 2000 12:24:12 CEST by Szymon Stefanek
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 2000-2004 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+//=============================================================================
+#define _WANT_OPTION_FLAGS_
+#define _EDITUSER_CPP_
+
+#include "edituser.h"
+#include "kvi_regusersdb.h"
+
+#include "kvi_locale.h"
+#include "kvi_ircmask.h"
+#include "kvi_debug.h"
+#include "kvi_iconmanager.h"
+#include "kvi_app.h"
+#include "kvi_options.h"
+#include "kvi_file.h"
+#include "kvi_filedialog.h"
+#include "kvi_msgbox.h"
+#include "kvi_fileutils.h"
+#include "kvi_settings.h"
+#include "kvi_stringconversion.h"
+#include "kvi_options.h"
+
+#include <qlayout.h>
+#include <qlabel.h>
+#include <qgroupbox.h>
+#ifdef COMPILE_USE_QT4
+#include <qevent.h>
+#include <q3header.h>
+#include <q3vbox.h>
+#else
+#include <qheader.h>
+#endif
+#include "kvi_pointerhashtable.h"
+#include <qimage.h>
+#include <qstring.h>
+#include <qcombobox.h>
+
+
+#include <qstyle.h>
+#include <qpainter.h>
+#include "kvi_tal_hbox.h"
+#include "kvi_tal_vbox.h"
+#include <qinputdialog.h>
+
+#include "wizard.h"
+#include "dialog.h"
+
+
+#ifdef COMPILE_INFO_TIPS
+ #include <qtooltip.h>
+#endif // COMPILE_INFO_TIPS
+
+// kvi_app.cpp
+extern KviRegisteredUsersDialog * g_pRegisteredUsersDialog;
+
+KviRegisteredUserDataBase * g_pLocalRegisteredUserDataBase; // local copy!
+
+
+
+KviReguserPropertiesDialog::KviReguserPropertiesDialog(QWidget * p,KviPointerHashTable<QString,QString> * dict)
+: QDialog(p,"property_editor",true)
+{
+ m_pPropertyDict = dict;
+
+ setCaption(__tr2qs("Property Editor"));
+ setIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_LINUX)));
+
+ QGridLayout * g = new QGridLayout(this,3,3,4,4);
+
+#ifdef COMPILE_USE_QT4
+ m_pTable = new Q3Table(this);
+#else
+ m_pTable = new QTable(this);
+#endif
+ g->addMultiCellWidget(m_pTable,0,1,0,1);
+
+ m_pTable->setNumCols(2);
+ m_pTable->setSelectionMode(Kvi_Tal_Table::NoSelection);
+
+ m_pTable->horizontalHeader()->setLabel(0,__tr2qs("Property"));
+ m_pTable->horizontalHeader()->setLabel(1,__tr2qs("Value"));
+
+ m_pTable->setMinimumSize(250,250);
+ //connect(m_pTable,SIGNAL(valueChanged(int,int)),this,SLOT(propertyValueChanged(int,int)));
+
+ KviTalVBox * vb = new KviTalVBox(this);
+ vb->setSpacing(4);
+ g->addWidget(vb,0,2);
+
+ m_pAddButton = new QPushButton(__tr2qs("&New"),vb);
+ connect(m_pAddButton,SIGNAL(clicked()),this,SLOT(addClicked()));
+ m_pAddButton->setIconSet(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_NEWITEM)));
+
+ m_pDelButton = new QPushButton(__tr2qs("&Remove"),vb);
+ connect(m_pDelButton,SIGNAL(clicked()),this,SLOT(delClicked()));
+ m_pDelButton->setIconSet(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_DELETEITEM)));
+
+ KviTalHBox * b = new KviTalHBox(this);
+ b->setSpacing(4);
+ g->addMultiCellWidget(b,2,2,1,2);
+
+ QPushButton * pb = new QPushButton(__tr2qs("&OK"),b);
+ connect(pb,SIGNAL(clicked()),this,SLOT(okClicked()));
+ pb->setIconSet(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_ACCEPT)));
+
+
+ pb = new QPushButton(__tr2qs("Cancel"),b);
+ connect(pb,SIGNAL(clicked()),this,SLOT(reject()));
+ pb->setIconSet(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_DISCARD)));
+
+ g->setRowStretch(1,1);
+ g->setColStretch(0,1);
+
+ fillData();
+}
+
+KviReguserPropertiesDialog::~KviReguserPropertiesDialog()
+{
+}
+
+void KviReguserPropertiesDialog::closeEvent(QCloseEvent *e)
+{
+ e->accept();
+ //delete this;
+}
+
+void KviReguserPropertiesDialog::fillData()
+{
+ m_pTable->setNumRows(m_pPropertyDict->count());
+ KviPointerHashTableIterator<QString,QString> it(*m_pPropertyDict);
+ int row = 0;
+ while(it.current())
+ {
+ m_pTable->setItem(row,0,new Kvi_Tal_TableItem(m_pTable,Kvi_Tal_TableItem::OnTyping,it.currentKey()));
+ m_pTable->setItem(row,1,new Kvi_Tal_TableItem(m_pTable,Kvi_Tal_TableItem::OnTyping,*(it.current())));
+ ++row;
+ ++it;
+ }
+ if(m_pTable->numRows() == 0)m_pDelButton->setEnabled(false);
+}
+
+void KviReguserPropertiesDialog::okClicked()
+{
+ m_pPropertyDict->clear();
+
+ int n = m_pTable->numRows();
+ for(int i=0;i<n;i++)
+ {
+ QString szName = m_pTable->text(i,0);
+ QString szValue = m_pTable->text(i,1);
+ if((!szName.isEmpty()) && (!szValue.isEmpty()))
+ {
+ m_pPropertyDict->replace(szName,new QString(szValue));
+ }
+ }
+
+ accept();
+}
+
+
+void KviReguserPropertiesDialog::addClicked()
+{
+ m_pTable->setNumRows(m_pTable->numRows() + 1);
+ m_pTable->setItem(m_pTable->numRows() - 1,0,new Kvi_Tal_TableItem(m_pTable,Kvi_Tal_TableItem::OnTyping,""));
+ m_pTable->setItem(m_pTable->numRows() - 1,1,new Kvi_Tal_TableItem(m_pTable,Kvi_Tal_TableItem::OnTyping,""));
+ m_pDelButton->setEnabled(true);
+}
+
+void KviReguserPropertiesDialog::delClicked()
+{
+ int i = m_pTable->currentRow();
+
+ if((i > -1) && (i < m_pTable->numRows()))
+ {
+ // remove row i
+ m_pTable->clearCell(i,0);
+ m_pTable->clearCell(i,1);
+
+ for(;i < (m_pTable->numRows() - 1);i++)
+ {
+ m_pTable->swapRows(i,i+1);
+ }
+ m_pTable->setNumRows(m_pTable->numRows() - 1);
+ if(m_pTable->numRows() == 0)m_pDelButton->setEnabled(false);
+ }
+}
+
+
+KviReguserMaskDialog::KviReguserMaskDialog(QWidget * p,KviIrcMask * m)
+: QDialog(p,"reguser_mask_editor",true)
+{
+ m_pMask = m;
+
+ setCaption(__tr2qs("Mask Editor"));
+
+ QGridLayout * g = new QGridLayout(this,3,2,4,4);
+
+ QLabel * l = new QLabel(__tr2qs("Insert a mask for this user.<br>It can contain the wildcard characters '*' and '?'."),this);
+ //l->setAlignment(Qt::AlignCenter);
+ g->addMultiCellWidget(l,0,0,0,1);
+
+ KviTalHBox * b = new KviTalHBox(this);
+ g->addMultiCellWidget(b,1,1,0,1);
+
+ m_pNickEdit = new QLineEdit(b);
+ //m_pNickEdit->setMinimumWidth(120);
+ m_pNickEdit->setAlignment(Qt::AlignRight);
+#ifdef COMPILE_INFO_TIPS
+ QToolTip::add(m_pNickEdit,__tr2qs("<center>This the <b>nickname</b> that will match this user, default value is the registered name.</center>"));
+#endif
+
+ l = new QLabel("<center><b>!</b></center>",b);
+ l->setAlignment(Qt::AlignCenter);
+ //l->setMinimumWidth(40);
+
+ m_pUserEdit = new QLineEdit(b);
+ //m_pUserEdit->setMinimumWidth(120);
+ m_pUserEdit->setAlignment(Qt::AlignCenter);
+#ifdef COMPILE_INFO_TIPS
+ QToolTip::add(m_pUserEdit,__tr2qs("<center>This the <b>username</b> that will match this user. <b>*</b> will match any username.</center>"));
+#endif
+
+ l = new QLabel("<center><b>@</b></center>",b);
+ l->setAlignment(Qt::AlignCenter);
+ //l->setMinimumWidth(40);
+
+ m_pHostEdit = new QLineEdit(b);
+ //m_pHostEdit->setMinimumWidth(120);
+ m_pHostEdit->setAlignment(Qt::AlignLeft);
+#ifdef COMPILE_INFO_TIPS
+ QToolTip::add(m_pHostEdit,__tr2qs("<center>This the <b>hostname</b> that will match this user. <b>*</b> will match any hostname.</center>"));
+#endif
+
+ // just a spacer
+// l = new QLabel("<nobr>&nbsp;<nobr>",this);
+// g->addMultiCellWidget(l,2,2,0,1);
+
+// QFrame * f = new QFrame(this);
+// f->setFrameStyle(QFrame::HLine | QFrame::Sunken);
+// g->addMultiCellWidget(f,3,3,0,1);
+
+ b = new KviTalHBox(this);
+ b->setSpacing(4);
+ g->addWidget(b,2,1);
+
+ QPushButton * pb = new QPushButton(__tr2qs("&OK"),b);
+ connect(pb,SIGNAL(clicked()),this,SLOT(okClicked()));
+ //pb->setMinimumWidth(120);
+
+ pb = new QPushButton(__tr2qs("Cancel"),b);
+ connect(pb,SIGNAL(clicked()),this,SLOT(reject()));
+ //pb->setMinimumWidth(120);
+
+
+
+ g->setColStretch(0,1);
+ g->setRowStretch(0,1);
+
+ m_pNickEdit->setText(m->nick());
+ m_pUserEdit->setText(m->user());
+ m_pHostEdit->setText(m->host());
+}
+
+KviReguserMaskDialog::~KviReguserMaskDialog()
+{
+}
+
+void KviReguserMaskDialog::closeEvent(QCloseEvent *e)
+{
+ e->accept();
+ //delete this;
+}
+
+void KviReguserMaskDialog::okClicked()
+{
+ KviStr szTmp = m_pNickEdit->text();
+ if(szTmp.isEmpty())szTmp = "*";
+ m_pMask->setNick(szTmp.ptr());
+
+ szTmp = m_pUserEdit->text();
+ if(szTmp.isEmpty())szTmp = "*";
+ m_pMask->setUsername(szTmp.ptr());
+
+ szTmp = m_pHostEdit->text();
+ if(szTmp.isEmpty())szTmp = "*";
+ m_pMask->setHost(szTmp.ptr());
+
+ accept();
+}
+
+
+
+
+KviRegisteredUserEntryDialog::KviRegisteredUserEntryDialog(QWidget *p,KviRegisteredUser * r,bool bModal)
+: KviTalTabDialog(p,"reguser_entry_editor",bModal)
+{
+ m_pUser = r;
+ m_pCustomColor = new QColor();
+
+ if(r)
+ {
+ QString col=r->getProperty("customColor");
+ KviStringConversion::fromString(col,(*m_pCustomColor));
+ }
+
+ m_pPropertyDict = new KviPointerHashTable<QString,QString>(17,false);
+ m_pPropertyDict->setAutoDelete(true);
+
+ //setMinimumSize(400,450);
+
+ setIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_LINUX)));
+ setCaption(__tr2qs("Registered User Entry"));
+
+ QWidget * p1 = new QWidget(this);
+
+ QGridLayout * g = new QGridLayout(p1,6,2,4,4);
+
+ QLabel * l = new QLabel(__tr2qs("Name:"),p1);
+ g->addWidget(l,0,0);
+
+ m_pNameEdit = new QLineEdit(p1);
+ g->addWidget(m_pNameEdit,0,1);
+
+ l = new QLabel(__tr2qs("Comment:"),p1);
+ g->addWidget(l,1,0);
+
+ m_pCommentEdit = new QLineEdit(p1);
+ g->addWidget(m_pCommentEdit,1,1);
+
+ QFrame * f = new QFrame(p1);
+ g->addMultiCellWidget(f,2,2,0,1);
+ f->setFrameStyle(QFrame::HLine | QFrame::Sunken);
+
+ l = new QLabel(__tr2qs("Masks:"),p1);
+ g->addMultiCellWidget(l,3,3,0,1);
+
+ m_pMaskListBox = new KviTalListBox(p1);
+ connect(m_pMaskListBox,SIGNAL(currentChanged(KviTalListBoxItem *)),this,SLOT(maskCurrentChanged(KviTalListBoxItem *)));
+ m_pMaskListBox->setMinimumSize(300,200);
+
+ g->addMultiCellWidget(m_pMaskListBox,4,4,0,1);
+
+ KviTalHBox * b = new KviTalHBox(p1);
+ g->addMultiCellWidget(b,5,5,0,1);
+ b->setSpacing(4);
+
+ m_pAddMaskButton = new QPushButton(__tr2qs("&Add..."),b);
+ connect(m_pAddMaskButton,SIGNAL(clicked()),this,SLOT(addMaskClicked()));
+ m_pAddMaskButton->setIconSet(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_NEWITEM)));
+
+ m_pDelMaskButton = new QPushButton(__tr2qs("Re&move"),b);
+ m_pDelMaskButton->setEnabled(false);
+ connect(m_pDelMaskButton,SIGNAL(clicked()),this,SLOT(delMaskClicked()));
+ m_pDelMaskButton->setIconSet(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_DELETEITEM)));
+
+ m_pEditMaskButton = new QPushButton(__tr2qs("&Edit"),b);
+ m_pEditMaskButton->setEnabled(false);
+ connect(m_pEditMaskButton,SIGNAL(clicked()),this,SLOT(editMaskClicked()));
+ m_pEditMaskButton->setIconSet(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_EDITITEM)));
+
+ g->setRowStretch(4,1);
+ g->setColStretch(1,1);
+
+ addTab(p1,__tr2qs("Identity"));
+
+
+
+ QWidget * p2 = new QWidget(this);
+
+ g = new QGridLayout(p2,6,3,5,2);
+
+ m_pNotifyCheck = new KviStyledCheckBox(__tr2qs("Notify when user is online"),p2);
+ g->addMultiCellWidget(m_pNotifyCheck,0,0,0,2);
+
+ l = new QLabel(__tr2qs("Notify nicknames:"),p2);
+ l->setEnabled(m_pNotifyCheck->isChecked());
+ g->addWidget(l,1,0);
+ connect(m_pNotifyCheck,SIGNAL(toggled(bool)),l,SLOT(setEnabled(bool)));
+#ifdef COMPILE_INFO_TIPS
+ QToolTip::add(m_pNotifyCheck,__tr2qs("<center>You can enter a space separated list of nicknames.</center>"));
+#endif
+
+
+ m_pNotifyNick = new QLineEdit(p2);
+ m_pNotifyNick->setEnabled(false);
+ g->addMultiCellWidget(m_pNotifyNick,1,1,1,2);
+ connect(m_pNotifyCheck,SIGNAL(toggled(bool)),m_pNotifyNick,SLOT(setEnabled(bool)));
+
+
+ f = new QFrame(p2);
+ f->setFrameStyle(QFrame::HLine | QFrame::Sunken);
+ g->addMultiCellWidget(f,2,2,0,2);
+
+ m_pAvatar = 0;
+ if(r)
+ {
+ const char * av = r->getProperty("avatar");
+ if(av)
+ {
+ m_pAvatar = new KviPixmap(av);
+ }
+ }
+ if(!m_pAvatar)m_pAvatar = new KviPixmap();
+
+ m_pAvatarSelector = new KviPixmapSelector(p2,__tr2qs("Avatar"),m_pAvatar,true);
+ g->addMultiCellWidget(m_pAvatarSelector,3,3,0,2);
+
+ f = new QFrame(p2);
+ f->setFrameStyle(QFrame::HLine | QFrame::Sunken);
+ g->addMultiCellWidget(f,4,4,0,2);
+
+ m_pCustomColorCheck = new KviStyledCheckBox(__tr2qs("Use custom color in userlist"),p2);
+ if(r)
+ m_pCustomColorCheck->setChecked(r->getBoolProperty("useCustomColor"));
+ g->addMultiCellWidget(m_pCustomColorCheck,5,5,0,1);
+
+ m_pCustomColorSelector = new KviColorSelector(p2,QString::null,m_pCustomColor,1);
+ g->addWidget(m_pCustomColorSelector,5,2);
+
+ QPushButton * pb = new QPushButton(__tr2qs("All Properties..."),p2);
+ connect(pb,SIGNAL(clicked()),this,SLOT(editAllPropertiesClicked()));
+ g->addWidget(pb,6,2);
+
+ g->setColStretch(1,1);
+ g->setRowStretch(3,1);
+
+ addTab(p2,__tr2qs("Properties"));
+
+ // Ignore TAB
+#ifdef COMPILE_USE_QT4
+ Q3VBox * vb = new Q3VBox(this);
+#else
+ QVBox * vb = new QVBox(this);
+#endif
+ vb->setMargin(10);
+
+ m_pIgnoreEnabled = new KviStyledCheckBox(__tr2qs("Enable ignore for this user"),vb);
+
+ QGroupBox * gb = new QGroupBox(__tr2qs("Ignore features"),vb);
+ connect(m_pIgnoreEnabled,SIGNAL(toggled(bool)),gb,SLOT(setEnabled(bool)));
+
+ QVBoxLayout * layout = new QVBoxLayout(gb,20,3);
+
+ m_pIgnoreQuery = new KviStyledCheckBox(__tr2qs("Ignore query-messages"),gb);
+ layout->addWidget(m_pIgnoreQuery);
+
+ m_pIgnoreChannel = new KviStyledCheckBox(__tr2qs("Ignore channel-messages"),gb);
+ layout->addWidget(m_pIgnoreChannel);
+
+ m_pIgnoreNotice = new KviStyledCheckBox(__tr2qs("Ignore notice-messages"),gb);
+ layout->addWidget(m_pIgnoreNotice);
+
+ m_pIgnoreCtcp = new KviStyledCheckBox(__tr2qs("Ignore ctcp-messages"),gb);
+ layout->addWidget(m_pIgnoreCtcp);
+
+ m_pIgnoreInvite = new KviStyledCheckBox(__tr2qs("Ignore invites"),gb);
+ layout->addWidget(m_pIgnoreInvite);
+
+ m_pIgnoreDcc = new KviStyledCheckBox(__tr2qs("Ignore DCCs"),gb);
+ layout->addWidget(m_pIgnoreDcc);
+
+ QWidget *w = new QWidget(vb);
+ w->setSizePolicy(QSizePolicy::Ignored,QSizePolicy::Ignored);
+
+ addTab(vb,__tr2qs("Ignore"));
+
+ setCancelButton(__tr2qs("Cancel"));
+ setOkButton(__tr2qs("&OK"));
+ connect(this,SIGNAL(applyButtonPressed()),this,SLOT(okClicked()));
+ connect(this,SIGNAL(cancelButtonPressed()),this,SLOT(reject()));
+
+ if(r)
+ {
+ m_pNameEdit->setText(r->name());
+ m_pCommentEdit->setText(r->getProperty("comment"));
+ for(KviIrcMask * m = r->maskList()->first();m;m = r->maskList()->next())
+ {
+ QString mk = m->nick();
+ mk += QChar('!');
+ mk += m->user();
+ mk += QChar('@');
+ mk += m->host();
+ m_pMaskListBox->insertItem(mk);
+ }
+
+ QString szNotifyNicks = r->getProperty("notify");
+ if(!szNotifyNicks.isEmpty())
+ {
+ m_pNotifyCheck->setChecked(true);
+ m_pNotifyNick->setText(szNotifyNicks);
+ m_pNotifyNick->setEnabled(true);
+ }
+
+ if(r->propertyDict())
+ {
+ KviPointerHashTableIterator<QString,QString> it(*(r->propertyDict()));
+ while(QString *s = it.current())
+ {
+ m_pPropertyDict->insert(it.currentKey(),new QString(*s));
+ ++it;
+ }
+ }
+
+ m_pIgnoreEnabled->setChecked(r->ignoreEnagled());
+
+ gb->setEnabled(r->ignoreEnagled());
+
+ m_pIgnoreQuery->setChecked(r->ignoreFlags() & KviRegisteredUser::Query);
+ m_pIgnoreChannel->setChecked(r->ignoreFlags() & KviRegisteredUser::Channel);
+ m_pIgnoreNotice->setChecked(r->ignoreFlags() & KviRegisteredUser::Notice);
+ m_pIgnoreCtcp->setChecked(r->ignoreFlags() & KviRegisteredUser::Ctcp);
+ m_pIgnoreInvite->setChecked(r->ignoreFlags() & KviRegisteredUser::Invite);
+ m_pIgnoreDcc->setChecked(r->ignoreFlags() & KviRegisteredUser::Dcc);
+ } else {
+ // default values
+ if(!m_pIgnoreEnabled->isChecked())
+ {
+ gb->setEnabled(false);
+ }
+ }
+}
+
+void KviRegisteredUserEntryDialog::closeEvent(QCloseEvent *e)
+{
+ e->accept();
+ okClicked();
+ //delete this;
+}
+
+KviRegisteredUserEntryDialog::~KviRegisteredUserEntryDialog()
+{
+ delete m_pAvatar;
+ delete m_pPropertyDict;
+ delete m_pCustomColor;
+}
+
+void KviRegisteredUserEntryDialog::maskCurrentChanged(KviTalListBoxItem *it)
+{
+ m_pDelMaskButton->setEnabled(it);
+ m_pEditMaskButton->setEnabled(it);
+}
+
+void KviRegisteredUserEntryDialog::okClicked()
+{
+ QString szGroup;
+ if(m_pUser)
+ {
+ szGroup=m_pUser->group();
+ g_pLocalRegisteredUserDataBase->removeUser(m_pUser->name());
+ }
+
+ QString name = m_pNameEdit->text();
+
+ if(name.isEmpty())name = "user";
+
+ KviRegisteredUser * u;
+
+ QString szNameOk = name;
+
+ int idx = 1;
+
+ do {
+ u = g_pLocalRegisteredUserDataBase->findUserByName(szNameOk);
+ if(u)
+ {
+ KviQString::sprintf(szNameOk,"%Q%d",&name,idx);
+ idx++;
+ }
+ } while(u);
+
+
+ u = g_pLocalRegisteredUserDataBase->addUser(szNameOk);
+ u->setGroup(szGroup);
+
+ if(!u)
+ {
+ // ops... no way
+ // FIXME: spit an error message ?
+ debug("Ops.. something wrong with the regusers db");
+ accept();
+ return;
+ }
+
+ int cnt = m_pMaskListBox->count();
+ idx = 0;
+ while(cnt > 0)
+ {
+ QString mask = m_pMaskListBox->text(idx);
+ KviIrcMask * mk = new KviIrcMask(mask);
+ g_pLocalRegisteredUserDataBase->removeMask(*mk);
+ g_pLocalRegisteredUserDataBase->addMask(u,mk);
+ cnt--;
+ idx++;
+ }
+ u->setProperty("comment",m_pCommentEdit->text());
+
+ m_pAvatarSelector->commit();
+
+ if(!m_pAvatar->isNull())
+ {
+ QString szPath = m_pAvatar->path();
+ u->setProperty("avatar",szPath);
+ }
+
+ if(m_pNotifyCheck->isChecked())
+ {
+ QString szNicks = m_pNotifyNick->text();
+
+ if(!szNicks.isEmpty())
+ {
+ u->setProperty("notify",szNicks);
+ }
+ }
+
+ m_pPropertyDict->remove("notify");
+ m_pPropertyDict->remove("avatar");
+
+ KviPointerHashTableIterator<QString,QString> it(*m_pPropertyDict);
+ while(QString *s = it.current())
+ {
+ u->setProperty(it.currentKey(),*s);
+ ++it;
+ }
+
+ u->setProperty("useCustomColor",m_pCustomColorCheck->isChecked());
+
+ QString col;
+ KviStringConversion::toString(m_pCustomColorSelector->getColor(),col);
+ u->setProperty("customColor",col);
+
+
+ int iIgnoreFlags=0;
+ u->setIgnoreEnabled(m_pIgnoreEnabled->isChecked());
+ if(m_pIgnoreQuery->isChecked())
+ iIgnoreFlags |= KviRegisteredUser::Query;
+ if(m_pIgnoreChannel->isChecked())
+ iIgnoreFlags |= KviRegisteredUser::Channel;
+ if(m_pIgnoreNotice->isChecked())
+ iIgnoreFlags |= KviRegisteredUser::Notice;
+ if(m_pIgnoreCtcp->isChecked())
+ iIgnoreFlags |= KviRegisteredUser::Ctcp;
+ if(m_pIgnoreInvite->isChecked())
+ iIgnoreFlags |= KviRegisteredUser::Invite;
+ if(m_pIgnoreDcc->isChecked())
+ iIgnoreFlags |= KviRegisteredUser::Dcc;
+
+ u->setIgnoreFlags(iIgnoreFlags);
+ accept();
+ g_pApp->optionResetUpdate(KviOption_resetUpdateGui);
+}
+
+
+void KviRegisteredUserEntryDialog::addMaskClicked()
+{
+ KviIrcMask mk;
+ KviReguserMaskDialog * dlg = new KviReguserMaskDialog(this,&mk);
+ if(dlg->exec() == QDialog::Accepted)
+ {
+ QString m = mk.nick();
+ m += QChar('!');
+ m += mk.user();
+ m += QChar('@');
+ m += mk.host();
+ m_pMaskListBox->insertItem(m);
+ }
+ delete dlg;
+}
+
+void KviRegisteredUserEntryDialog::delMaskClicked()
+{
+ int idx = m_pMaskListBox->currentItem();
+ if(idx == -1)return;
+ m_pMaskListBox->removeItem(idx);
+}
+
+void KviRegisteredUserEntryDialog::editMaskClicked()
+{
+ int idx = m_pMaskListBox->currentItem();
+ if(idx == -1)return;
+ KviStr szM = m_pMaskListBox->text(idx);
+ if(szM.isEmpty())return;
+
+ KviIrcMask mk(szM.ptr());
+ KviReguserMaskDialog * dlg = new KviReguserMaskDialog(this,&mk);
+ if(dlg->exec() == QDialog::Accepted)
+ {
+ QString m = mk.nick();
+ m += QChar('!');
+ m += mk.user();
+ m += QChar('@');
+ m += mk.host();
+ m_pMaskListBox->changeItem(m,idx);
+ }
+ delete dlg;
+}
+
+void KviRegisteredUserEntryDialog::editAllPropertiesClicked()
+{
+ m_pAvatarSelector->commit();
+
+ if(m_pAvatar->isNull())
+ {
+ m_pPropertyDict->remove("avatar");
+ } else {
+ KviStr szPath = m_pAvatar->path();
+ if(szPath.isEmpty())m_pPropertyDict->remove("avatar");
+ else m_pPropertyDict->replace("avatar",new QString(szPath));
+ }
+
+ if(m_pNotifyCheck->isChecked())
+ {
+ QString szNicks = m_pNotifyNick->text();
+
+ if(!szNicks.isEmpty())
+ {
+ m_pPropertyDict->replace("notify",new QString(szNicks));
+ } else {
+ m_pPropertyDict->remove("notify");
+ }
+ } else {
+ m_pPropertyDict->remove("notify");
+ }
+
+
+ KviReguserPropertiesDialog * dlg = new KviReguserPropertiesDialog(this,m_pPropertyDict);
+ if(dlg->exec() != QDialog::Accepted)
+ {
+ delete dlg;
+ return;
+ }
+ delete dlg;
+
+ QString * notify = m_pPropertyDict->find("notify");
+ bool bGotIt = false;
+ if(notify)
+ {
+ if(!notify->isEmpty())
+ {
+ bGotIt = true;
+ m_pNotifyNick->setText(*notify);
+ }
+ }
+ m_pNotifyCheck->setChecked(bGotIt);
+ m_pNotifyNick->setEnabled(bGotIt);
+ if(!bGotIt)m_pNotifyNick->setText("");
+
+ QString * avatar = m_pPropertyDict->find("avatar");
+ bGotIt = false;
+ if(avatar)
+ {
+ if(!avatar->isEmpty())
+ m_pAvatarSelector->setImagePath(*avatar);
+ }
+
+}
+
+
+
+
+#include "edituser.moc"
diff --git a/src/modules/reguser/edituser.h b/src/modules/reguser/edituser.h
new file mode 100644
index 00000000..fecbbf09
--- /dev/null
+++ b/src/modules/reguser/edituser.h
@@ -0,0 +1,152 @@
+#ifndef _EDITUSER_H_
+#define _EDITUSER_H_
+//=============================================================================
+//
+// File : edituser.h
+// Creation date : Sun Dec 24 2000 15:16:17 CEST by Szymon Stefanek
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 2000-2004 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+//=============================================================================
+
+#include "kvi_string.h"
+#include "kvi_regusersdb.h"
+#include "kvi_selectors.h"
+
+#include <qwidget.h>
+#include <qlineedit.h>
+#include <qpushbutton.h>
+#include "kvi_tal_listview.h"
+#include "kvi_tal_listbox.h"
+#include "kvi_pointerhashtable.h"
+#include <kvi_tal_tabdialog.h>
+#ifdef COMPILE_USE_QT4
+#include <q3table.h>
+#define Kvi_Tal_Table Q3Table
+#define Kvi_Tal_TableItem Q3TableItem
+
+#else
+#include <qtable.h>
+#define Kvi_Tal_Table QTable
+#define Kvi_Tal_TableItem QTableItem
+
+#endif
+#include "kvi_tal_popupmenu.h"
+
+#ifndef _EDITUSER_CPP_
+ extern KviRegisteredUserDataBase * g_pLocalRegisteredUserDataBase;
+#endif
+
+class KviRegisteredUser;
+
+class KviReguserPropertiesDialog : public QDialog
+{
+ Q_OBJECT
+public:
+ KviReguserPropertiesDialog(QWidget *p,KviPointerHashTable<QString,QString> * dict);
+ ~KviReguserPropertiesDialog();
+protected:
+#ifdef COMPILE_USE_QT4
+ Q3Table *m_pTable;
+#else
+ QTable * m_pTable;
+#endif
+ KviPointerHashTable<QString,QString> * m_pPropertyDict;
+ QPushButton * m_pDelButton;
+ QPushButton * m_pAddButton;
+protected:
+ void fillData();
+ virtual void closeEvent(QCloseEvent *);
+protected slots:
+ void okClicked();
+ void addClicked();
+ void delClicked();
+};
+
+
+class KviReguserMaskDialog : public QDialog
+{
+ Q_OBJECT
+public:
+ KviReguserMaskDialog(QWidget * p,KviIrcMask * m);
+ ~KviReguserMaskDialog();
+protected:
+ KviIrcMask * m_pMask;
+
+ QLineEdit * m_pNickEdit;
+ QLineEdit * m_pUserEdit;
+ QLineEdit * m_pHostEdit;
+
+ virtual void closeEvent(QCloseEvent *);
+protected slots:
+ void okClicked();
+};
+
+
+class KviRegisteredUserEntryDialog : public KviTalTabDialog
+{
+ Q_OBJECT
+public:
+ KviRegisteredUserEntryDialog(QWidget * p,KviRegisteredUser * r,bool bModal = true);
+ virtual ~KviRegisteredUserEntryDialog();
+protected:
+ KviRegisteredUser * m_pUser;
+
+ QLineEdit * m_pNameEdit;
+ QLineEdit * m_pCommentEdit;
+
+ KviTalListBox * m_pMaskListBox;
+
+ QPushButton * m_pDelMaskButton;
+ QPushButton * m_pEditMaskButton;
+ QPushButton * m_pAddMaskButton;
+
+ QCheckBox * m_pNotifyCheck;
+ QLineEdit * m_pNotifyNick;
+
+ KviPixmap * m_pAvatar;
+ KviPixmapSelector * m_pAvatarSelector;
+
+ KviPointerHashTable<QString,QString> * m_pPropertyDict;
+
+ QCheckBox * m_pCustomColorCheck;
+ QColor * m_pCustomColor;
+ KviColorSelector * m_pCustomColorSelector;
+
+ //Ignore TAB
+ QCheckBox * m_pIgnoreEnabled;
+ QCheckBox * m_pIgnoreQuery;
+ QCheckBox * m_pIgnoreChannel;
+ QCheckBox * m_pIgnoreNotice;
+ QCheckBox * m_pIgnoreCtcp;
+ QCheckBox * m_pIgnoreInvite;
+ QCheckBox * m_pIgnoreDcc;
+
+ virtual void closeEvent(QCloseEvent *);
+protected slots:
+ void okClicked();
+ void addMaskClicked();
+ void delMaskClicked();
+ void editMaskClicked();
+ void editAllPropertiesClicked();
+ void maskCurrentChanged(KviTalListBoxItem *it);
+};
+
+
+
+#endif //_EDITUSER_H_
diff --git a/src/modules/reguser/libkvireguser.cpp b/src/modules/reguser/libkvireguser.cpp
new file mode 100644
index 00000000..49e4a204
--- /dev/null
+++ b/src/modules/reguser/libkvireguser.cpp
@@ -0,0 +1,1239 @@
+//=============================================================================
+//
+// File : libkvireguser.cpp
+// Creation date : Fri Dec 01 2000 14:53:10 CEST by Szymon Stefanek
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 2000-2004 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+//=============================================================================
+
+#include "kvi_module.h"
+
+#include "kvi_regusersdb.h"
+#include "kvi_ircuserdb.h"
+#include "kvi_out.h"
+#include "kvi_mirccntrl.h"
+#include "kvi_window.h"
+#include "kvi_locale.h"
+#include "kvi_app.h"
+#include "kvi_window.h"
+#include "kvi_frame.h"
+
+#include "edituser.h"
+#include "wizard.h"
+#include "kvi_ircconnection.h"
+#include "dialog.h"
+
+#include "kvi_pointerlist.h"
+#include <qsplitter.h> // FIXME: REmove this!
+
+//#warning "$reguser.matches..."
+//#warning "$reguser.clear"
+
+//#warning "THIS MODULE HAS TO BE REVISED (notify list consistency!!!)"
+
+// kvi_app.cpp
+
+
+extern KVIRC_API KviRegisteredUserDataBase * g_pRegisteredUserDataBase;
+
+KviPointerList<KviRegistrationWizard> * g_pRegistrationWizardList = 0;
+
+KviRegisteredUsersDialog * g_pRegisteredUsersDialog = 0;
+
+/*
+ @doc: reguser
+ @type:
+ module
+ @short:
+ Interface to the registered users database
+ @title:
+ The reguser module
+ @body:
+ The reguser module is the scripting interface to the [doc:registered_users]registered users database[/doc].[br]
+ It provides the following set of commands:[br]
+ [cmd]reguser.add[/cmd]: adds an user entry to the database[br]
+ [cmd]reguser.addmask[/cmd]: adds an user's mask to the database[br]
+ [cmd]reguser.remove[/cmd]: removes an user entry from the database[br]
+ [fnc]$reguser.list[/fnc]: lists the entries[br]
+ [cmd]reguser.setproperty[/cmd]: sets a property associated to an entry[br]
+ [cmd]reguser.edit[/cmd]: shows an editor for an user entry
+ [fnc]$reguser.match[/fnc](): finds an entry by matching masks[br]
+ [fnc]$reguser.exactMatch[/fnc](): finds an entry by comparing masks[br]
+ [fnc]$reguser.property[/fnc](): finds a property associated to an entry[br]
+ [fnc]$reguser.matchProperty[/fnc](): shortcut for [fnc]$reguser.property[/fnc]([fnc]$reguser.match[/fnc]())[br]
+ [fnc]$reguser.mask[/fnc](): returns the registration masks for an entry
+*/
+
+/*
+ @doc: reguser.edit
+ @type:
+ command
+ @title:
+ reguser.edit
+ @keyterms:
+ registering users
+ @short:
+ Opens the registeredusers dialog
+ @syntax:
+ reguser.edit [-t]
+ @switches:
+ !sw: -t | --toplevel
+ the editor is created as a toplevel window (dialog)
+ @description:
+ Shows the registered user database editor.[br]
+ If the [-t] switch is passed, the editor is created as a toplevel window (dialog), otherwise
+ it is created as part of the current main window.[br]
+ @examples:
+ @seealso:
+ [module:reguser]Registered users database interface[/module],
+ [doc:registered_users]Registered users database[/doc],
+ [cmd]reguser.add[/cmd],
+ [cmd]reguser.remove[/cmd],
+ [cmd]reguser.addmask[/cmd],
+ [fnc]$reguser.list[/fnc]
+*/
+
+static bool reguser_kvs_cmd_edit(KviKvsModuleCommandCall * c)
+{
+ if(g_pRegisteredUsersDialog)
+ {
+ if(c->hasSwitch('t',"toplevel"))
+ {
+ if(g_pRegisteredUsersDialog->parent())
+ {
+ g_pRegisteredUsersDialog->reparent(0,QPoint(0,0),true);
+ }
+ } else {
+ if(g_pRegisteredUsersDialog->parent() != c->window()->frame()->splitter())
+ {
+ g_pRegisteredUsersDialog->reparent(c->window()->frame()->splitter(),QPoint(0,0),true);
+ }
+ }
+ } else {
+ if(c->hasSwitch('t',"toplevel"))
+ {
+ g_pRegisteredUsersDialog = new KviRegisteredUsersDialog(0);
+ } else {
+ g_pRegisteredUsersDialog = new KviRegisteredUsersDialog(c->window()->frame()->splitter());
+ }
+ }
+ g_pRegisteredUsersDialog->show();
+ g_pRegisteredUsersDialog->raise();
+ g_pRegisteredUsersDialog->setFocus();
+ return true;
+}
+
+/*
+ @doc: reguser.add
+ @type:
+ command
+ @title:
+ reguser.add
+ @keyterms:
+ registering users
+ @short:
+ Registers an user
+ @syntax:
+ reguser.add [-r] [-f] [-q] [-g=group] <name> [mask]
+ @description:
+ Adds a new entry with the specified <name> to the database.[br]
+ If the database contains an entry with the same <name>, this command just prints
+ a warning and returns.[br]
+ If no [mask] is given the new entry has no registration masks: so it can't be "matched" yet. You have to add
+ at least one mask with [cmd]reguser.addmask[/cmd].
+ If [mask] is given, then it is added to the entry mask list.[br]
+ The <name> parameter may contain any character: even spaces are allowed (obviously you have to
+ use quotes in that case).[br]
+ If the '-r' switch is given , the new entry replaces any previous one with the same <name> (the old entry is removed).[br]
+ If the '-f' switch is given , and there is an existing entry with the same name , no warning is printed
+ and the old entry is treated just like it has been just added (thus the [mask] is eventually added to its mask list).[br]
+ The '-q' switch causes the command to run in "quiet" mode and print no warning.[br]
+ @examples:
+ [example]
+ reguser.add Pragma
+ [/example]
+ @seealso:
+ [module:reguser]Registered users database interface[/module],
+ [doc:registered_users]Registered users database[/doc],
+ [cmd]reguser.remove[/cmd],
+ [cmd]reguser.addmask[/cmd],
+ [fnc]$reguser.list[/fnc]
+*/
+
+static bool reguser_kvs_cmd_add(KviKvsModuleCommandCall * c)
+{
+ QString szName;
+ QString szMask;
+ KVSM_PARAMETERS_BEGIN(c)
+ KVSM_PARAMETER("name",KVS_PT_STRING,0,szName)
+ KVSM_PARAMETER("mask",KVS_PT_STRING,0,szMask)
+ KVSM_PARAMETERS_END(c)
+ if(szName.isEmpty())
+ {
+ if(!c->hasSwitch('q',"quiet"))c->warning(__tr2qs("No name specified"));
+ return true;
+ }
+
+ if(c->hasSwitch('r',"replace"))g_pRegisteredUserDataBase->removeUser(szName);
+
+
+ KviRegisteredUser * u = g_pRegisteredUserDataBase->addUser(szName);
+ QString group;
+ if(c->hasSwitch('g',"group"))
+ {
+ c->switches()->getAsStringIfExisting('g',"group",group);
+ u->setGroup(group);
+ }
+ if(u == 0)
+ {
+ if(c->hasSwitch('f',"force"))
+ {
+ u = g_pRegisteredUserDataBase->findUserByName(szName);
+ } else {
+ if(!c->hasSwitch('q',"quiet"))c->warning(__tr2qs("User already registered: found exact name match"));
+ }
+ }
+
+
+ if(u)
+ {
+ if(!szMask.isEmpty())
+ {
+ KviIrcMask * m = new KviIrcMask(szMask);
+ u = g_pRegisteredUserDataBase->addMask(u,m);
+ if(u != 0)
+ {
+ if(!c->hasSwitch('q',"quiet"))c->warning(__tr2qs("Mask %Q is already used to identify user %s"),&szMask,u->name().utf8().data());
+ }
+ }
+ }
+ return true;
+}
+
+/*
+ @doc: reguser.remove
+ @type:
+ command
+ @title:
+ reguser.remove
+ @keyterms:
+ unregistering users
+ @short:
+ Removes an entry from the regusers database
+ @syntax:
+ reguser.remove [-q] [-n] <name>
+ @description:
+ Removes the regusers database entry with the specified <name>.[br]
+ If the -n switch is given, and there is a removed entry,
+ this command will restart all the running "notify lists".
+ If the -q switch is used , no warning is printed if the <name>
+ does not identify an existing entry.
+ @examples:
+ [example]
+ [cmd]reguser.add[/cmd] Pragma
+ reguser.remove Pragma
+ [example]
+ @seealso:
+ [module:reguser]Registered users database interface[/module],
+ [doc:registered_users]Registered users database[/doc],
+ [cmd]reguser.add[/cmd],
+ [cmd]reguser.addmask[/cmd],
+ [fnc]$reguser.list[/fnc]
+*/
+
+static bool reguser_kvs_cmd_remove(KviKvsModuleCommandCall * c)
+{
+ QString szName;
+ KVSM_PARAMETERS_BEGIN(c)
+ KVSM_PARAMETER("name",KVS_PT_STRING,0,szName)
+ KVSM_PARAMETERS_END(c)
+
+ if(szName.isEmpty())
+ {
+ if(!c->hasSwitch('q',"quiet"))c->warning(__tr2qs("No name specified"));
+ return true;
+ }
+
+ if(!(g_pRegisteredUserDataBase->removeUser(szName)))
+ {
+ c->warning(__tr2qs("User not found (%Q)"),&szName);
+ } else {
+ if(c->hasSwitch('n',"restartnotifylists"))g_pApp->restartNotifyLists();
+ }
+ return true;
+}
+
+/*
+ @doc: reguser.addmask
+ @type:
+ command
+ @title:
+ reguser.addmask
+ @keyterms:
+ registering users
+ @short:
+ Adds a mask to a registered user
+ @syntax:
+ reguser.addmask [-f] <name> <mask>
+ @description:
+ Adds a registration mask to the database entry with name <name>.[br]
+ The <mask> has the common [doc:irc_masks]irc mask[/doc] format.[br]
+ The only restriction on the <mask> is that it must be unique inside the
+ regusers database: you can't match two users with the same mask (it would
+ have rather undefined results).[br]
+ If -f is used , KVIrc ensures that the mask is unique in the database
+ and associates is to THIS registered user (breaking the previous associations).<br>
+ Once at least one mask has been added, the user can be "matched"
+ by using the [fnc]$reguser.match[/fnc]() function.[br]
+ Each database entry can have an unlimited number of masks.[br]
+ @examples:
+ [example]
+ [cmd]reguser.add[/cmd] "Szymon Stefanek"
+ reguser.addmask "Szymon Stefanek" Pragma!*@*.it
+ [/example]
+ @seealso:
+ [module:reguser]Registered users database interface[/module],
+ [doc:registered_users]Registered users database[/doc],
+ [cmd]reguser.add[cmd],
+ [cmd]reguser.remove[/cmd],
+ [cmd]reguser.delmask[/cmd],
+ [fnc]$reguser.list[/fnc],
+ [fnc]$reguser.match[/fnc],
+ [fnc]$reguser.exactMatch[/fnc]
+*/
+
+static bool reguser_kvs_cmd_addmask(KviKvsModuleCommandCall * c)
+{
+ QString szName;
+ QString szMask;
+ KVSM_PARAMETERS_BEGIN(c)
+ KVSM_PARAMETER("name",KVS_PT_STRING,0,szName)
+ KVSM_PARAMETER("mask",KVS_PT_STRING,0,szMask)
+ KVSM_PARAMETERS_END(c)
+
+ if(szName.isEmpty())
+ {
+ c->warning(__tr2qs("No name specified"));
+ return true;
+ }
+
+ if(szMask.isEmpty())
+ {
+ c->warning(__tr2qs("No mask specified"));
+ return true;
+ }
+
+ KviRegisteredUser * u = g_pRegisteredUserDataBase->findUserByName(szName);
+ if(!u)
+ {
+ c->warning(__tr2qs("User %Q not found"),&szName);
+ return true;
+ }
+
+ KviIrcMask * mk = new KviIrcMask(szMask);
+
+ if(c->hasSwitch('f',"force"))g_pRegisteredUserDataBase->removeMask(*mk);
+
+ u = g_pRegisteredUserDataBase->addMask(u,mk);
+
+ if(u != 0)c->warning(__tr2qs("Mask %Q already used to identify user %Q"),&szMask,&(u->name()));
+ return true;
+}
+
+/*
+ @doc: reguser.delmask
+ @type:
+ command
+ @title:
+ reguser.delmask
+ @keyterms:
+ registering users
+ @short:
+ Removes a mask from the regusers database
+ @syntax:
+ reguser.delmask <mask>
+ @description:
+ Removes a mask from the regusers database.[br]
+ Since masks are unique in the database , you don't need to pass
+ an <user> parameter: if an <user> entry has the <mask>, removing that <mask>
+ will surely remove it from that <user> entry. (contorsions ?)[br]
+ @examples:
+ [example]
+ [cmd]reguser.add[/cmd] "Szymon Stefanek"
+ [cmd]reguser.addmask[/cmd] "Szymon Stefanek" Pragma!*@*.it
+ reguser.delmask Pragma!*@*.it
+ [fnc]$reguser.list[/fnc]
+ [/example]
+ @seealso:
+ [module:reguser]Registered users database interface[/module],
+ [doc:registered_users]Registered users database[/doc],
+ [cmd]reguser.add[/cmd],
+ [cmd]reguser.remove[/cmd],
+ [cmd]reguser.addmask[/cmd],
+ [fnc]$reguser.list[/fnc],
+ [fnc]$reguser.match[/fnc],
+ [fnc]$reguser.exactMatch[/fnc]
+*/
+
+static bool reguser_kvs_cmd_delmask(KviKvsModuleCommandCall * c)
+{
+ QString szMask;
+ KVSM_PARAMETERS_BEGIN(c)
+ KVSM_PARAMETER("mask",KVS_PT_STRING,0,szMask)
+ KVSM_PARAMETERS_END(c)
+
+ if(szMask.isEmpty())
+ {
+ c->warning(__tr2qs("No mask specified"));
+ return true;
+ }
+
+ KviIrcMask mk(szMask);
+ if(!g_pRegisteredUserDataBase->removeMask(mk))
+ {
+ c->warning(__tr2qs("Mask %Q not found"),&szMask);
+ }
+
+ return true;
+}
+
+/*
+ @doc: reguser.setIgnoreEnabled
+ @type:
+ command
+ @title:
+ reguser.setIgnoreEnabled
+ @keyterms:
+ enable/disable ignoring of this user
+ @short:
+ Enable/disable ignoring of this user
+ @syntax:
+ reguser.setIgnoreEnabled [-q] <name:string> <isEnabled:bool>
+ @description:
+
+ @examples:
+ [example]
+ reguser.setproperty "Alexey" $true
+ [/example]
+ @seealso:
+ [module:reguser]Registered users database interface[/module],
+ [doc:registered_users]Registered users database[/doc],
+ [fnc]$reguser.matchProperty[/fnc],
+ [fnc]$reguser.property[/fnc]
+*/
+
+static bool reguser_kvs_cmd_setIgnoreEnabled(KviKvsModuleCommandCall * c)
+{
+ QString szName;
+ bool bEnabled;
+ KVSM_PARAMETERS_BEGIN(c)
+ KVSM_PARAMETER("name",KVS_PT_STRING,0,szName)
+ KVSM_PARAMETER("isEnabled",KVS_PT_BOOL,0,bEnabled)
+ KVSM_PARAMETERS_END(c)
+
+ if(szName.isEmpty())
+ {
+ if(!c->hasSwitch('q',"quiet"))c->warning(__tr2qs("No name specified"));
+ return true;
+ }
+
+ KviRegisteredUser * u = g_pRegisteredUserDataBase->findUserByName(szName);
+ if(!u)
+ {
+ if(!c->hasSwitch('q',"quiet"))c->warning(__tr2qs("User %Q not found"),&szName);
+ } else {
+ u->setIgnoreEnabled(bEnabled);
+ }
+ return true;
+}
+
+
+/*
+ @doc: reguser.setIgnoreFlags
+ @type:
+ command
+ @title:
+ reguser.setIgnoreFlags
+ @keyterms:
+ Sets ignore flags for registered user
+ @short:
+ Sets ignore flags for registered user
+ @syntax:
+ reguser.setIgnoreFlags [-p|--query] [-c|--channel] [-n|--notice] [-t|--ctcp] [-i|--invite] [-d|--dcc] [-q] <name:string>
+ @switches:
+ !sw: -q | --quiet
+ Don't warn if the specified user doesn't exist. Just continue silently.
+ !sw: -p | --query
+ Sets ignore for query messages and actions
+ !sw: -c | --channel
+ Sets ignore for channel messages and actions
+ !sw: -n | --notice
+ Sets ignore for notices
+ !sw: -t | --ctcp
+ Sets ignore for CTCP's
+ !sw: -i | --invite
+ Sets ignore for invites
+ !sw: -d | --dcc
+ Sets ignore for DCC's
+
+ @description:
+ Sets ignore flags for registered user
+ @examples:
+ [example]
+ reguser.setproperty "Alexey" $true
+ [/example]
+ @seealso:
+ [module:reguser]Registered users database interface[/module],
+ [doc:registered_users]Registered users database[/doc],
+ [fnc]$reguser.matchProperty[/fnc],
+ [fnc]$reguser.property[/fnc]
+*/
+
+static bool reguser_kvs_cmd_setIgnoreFlags(KviKvsModuleCommandCall * c)
+{
+ QString szName;
+ KVSM_PARAMETERS_BEGIN(c)
+ KVSM_PARAMETER("name",KVS_PT_STRING,0,szName)
+ KVSM_PARAMETERS_END(c)
+
+ if(szName.isEmpty())
+ {
+ if(!c->hasSwitch('q',"quiet"))c->warning(__tr2qs("No name specified"));
+ return true;
+ }
+
+ KviRegisteredUser * u = g_pRegisteredUserDataBase->findUserByName(szName);
+ if(!u)
+ {
+ if(!c->hasSwitch('q',"quiet"))c->warning(__tr2qs("User %Q not found"),&szName);
+ } else {
+ int iIgnoreFlags=0;
+ if(c->hasSwitch('p',"query"))
+ iIgnoreFlags |= KviRegisteredUser::Query;
+ if(c->hasSwitch('c',"channel"))
+ iIgnoreFlags |= KviRegisteredUser::Channel;
+ if(c->hasSwitch('n',"notice"))
+ iIgnoreFlags |= KviRegisteredUser::Notice;
+ if(c->hasSwitch('t',"ctcp"))
+ iIgnoreFlags |= KviRegisteredUser::Ctcp;
+ if(c->hasSwitch('i',"invite"))
+ iIgnoreFlags |= KviRegisteredUser::Invite;
+ if(c->hasSwitch('d',"dcc"))
+ iIgnoreFlags |= KviRegisteredUser::Dcc;
+ u->setIgnoreFlags(iIgnoreFlags);
+ }
+ return true;
+}
+
+/*
+ @doc: reguser.getIgnoreFlags
+ @type:
+ function
+ @title:
+ $reguser.getIgnoreFlags
+ @short:
+ Returns ignore flags for registered user
+ @syntax:
+ $reguser.getIgnoreFlags(<name:string>)
+ @description:
+ Returns the ignore flags for registered user. Flags are string of letters:[br]
+ p - query ignore[br]
+ c - channel ignore[br]
+ t - ctcp ignore[br]
+ n - notice ignore[br]
+ d - dcc ignore[br]
+ i - invite ignore[br]
+ @seealso:
+ [module:reguser]Registered users database interface[/module],
+ [doc:registered_users]Registered users database[/doc],
+ [cmd]reguser.add[/cmd],
+ [cmd]reguser.remove[/cmd],
+ [cmd]reguser.addmask[/cmd],
+ [cmd]reguser.delmask[/cmd],
+ [fnc]$reguser.list[/fnc],
+ [fnc]$reguser.match[/fnc],
+ [fnc]$reguser.matchProperty[/fnc]
+*/
+
+static bool reguser_kvs_fnc_getIgnoreFlags(KviKvsModuleFunctionCall * c)
+{
+ QString szName;
+ QString szFlags;
+ KVSM_PARAMETERS_BEGIN(c)
+ KVSM_PARAMETER("name",KVS_PT_STRING,0,szName)
+ KVSM_PARAMETERS_END(c)
+
+ KviKvsArray* pArray = new KviKvsArray();
+ int aid=0;
+ KviRegisteredUser * u = g_pRegisteredUserDataBase->findUserByName(szName);
+ if(u)
+ {
+ if(u->ignoreFlags() & KviRegisteredUser::Query)
+ szFlags+='q';
+ if(u->ignoreFlags() & KviRegisteredUser::Channel)
+ szFlags+='c';
+ if(u->ignoreFlags() & KviRegisteredUser::Notice)
+ szFlags+='n';
+ if(u->ignoreFlags() & KviRegisteredUser::Ctcp)
+ szFlags+='t';
+ if(u->ignoreFlags() & KviRegisteredUser::Invite)
+ szFlags+='i';
+ if(u->ignoreFlags() & KviRegisteredUser::Dcc)
+ szFlags+='d';
+ c->returnValue()->setString(szFlags);
+
+ }
+ return true;
+}
+
+/*
+ @doc: reguser.isIgnoreEnabled
+ @type:
+ function
+ @title:
+ $reguser.isIgnoreEnabled
+ @short:
+ Returns if ignore enabled registered user
+ @syntax:
+ $reguser.isIgnoreEnabled(<name:string>)
+ @description:
+ Returns if ignore enabled registered user
+ @seealso:
+ [module:reguser]Registered users database interface[/module],
+ [doc:registered_users]Registered users database[/doc],
+ [cmd]reguser.add[/cmd],
+ [cmd]reguser.remove[/cmd],
+ [cmd]reguser.addmask[/cmd],
+ [cmd]reguser.delmask[/cmd],
+ [fnc]$reguser.list[/fnc],
+ [fnc]$reguser.match[/fnc],
+ [fnc]$reguser.matchProperty[/fnc]
+*/
+
+static bool reguser_kvs_fnc_isIgnoreEnabled(KviKvsModuleFunctionCall * c)
+{
+ QString szName;
+ KVSM_PARAMETERS_BEGIN(c)
+ KVSM_PARAMETER("name",KVS_PT_STRING,0,szName)
+ KVSM_PARAMETERS_END(c)
+
+ KviKvsArray* pArray = new KviKvsArray();
+ int aid=0;
+ KviRegisteredUser * u = g_pRegisteredUserDataBase->findUserByName(szName);
+ if(u)
+ {
+ c->returnValue()->setBoolean(u->ignoreEnagled());
+
+ }
+ return true;
+}
+
+/*
+ @doc: reguser.setproperty
+ @type:
+ command
+ @title:
+ reguser.setproperty
+ @keyterms:
+ setting user properties
+ @short:
+ Sets a property of a registered user
+ @syntax:
+ reguser.setproperty [-n] [-a] [-q] <name> <property> [value]
+ @description:
+ Adds a property to the registered users database entry with name <name>.[br]
+ The property <property> is set to the specified <value> or is unset if <value>
+ is not given (or is an empty string).[br]
+ If the '-n' switch is used , and the user entry has been found in the database,
+ all the [doc:notify_list]notify lists[/doc] are restarted.[br]
+ If the '-a' switch is used , and there are users on IRC currently matched
+ by this reguser entry then their avatar is reset.
+ This is useful when you're changing someone's notify property.[br]
+ If the -q switch is used , the command runs in "quiet" mode and prints no warnings.[br]
+ @examples:
+ [example]
+ [cmd]reguser.add[/cmd] "Szymon Stefanek"
+ reguser.setproperty -n "Szymon Stefanek" notify Pragma
+ [fnc]$reguser.list[/fnc]
+ [/example]
+ @seealso:
+ [module:reguser]Registered users database interface[/module],
+ [doc:registered_users]Registered users database[/doc],
+ [fnc]$reguser.matchProperty[/fnc],
+ [fnc]$reguser.property[/fnc]
+*/
+
+static bool reguser_kvs_cmd_setproperty(KviKvsModuleCommandCall * c)
+{
+ QString szName;
+ QString szProperty;
+ QString szValue;
+ KVSM_PARAMETERS_BEGIN(c)
+ KVSM_PARAMETER("mask",KVS_PT_STRING,0,szName)
+ KVSM_PARAMETER("property",KVS_PT_STRING,0,szProperty)
+ KVSM_PARAMETER("value",KVS_PT_STRING,KVS_PF_OPTIONAL,szValue)
+ KVSM_PARAMETERS_END(c)
+
+ if(szName.isEmpty())
+ {
+ if(!c->hasSwitch('q',"quiet"))c->warning(__tr2qs("No name specified"));
+ return true;
+ }
+
+ if(szProperty.isEmpty())
+ {
+ if(!c->hasSwitch('q',"quiet"))c->warning(__tr2qs("No property specified"));
+ return true;
+ }
+
+ KviRegisteredUser * u = g_pRegisteredUserDataBase->findUserByName(szName);
+ if(!u)
+ {
+ if(!c->hasSwitch('q',"quiet"))c->warning(__tr2qs("User %Q not found"),&szName);
+ } else {
+ u->setProperty(szProperty,szValue);
+ if(c->hasSwitch('n',"restartnotifylists"))g_pApp->restartNotifyLists();
+ if(c->hasSwitch('a',"resetavatar"))g_pApp->resetAvatarForMatchingUsers(u);
+ }
+ return true;
+}
+/*
+ @doc: reguser.list
+ @type:
+ function
+ @title:
+ $reguser.list
+ @short:
+ Get a list of registered user masks
+ @syntax:
+ $reguser.list([mask])
+ @description:
+ Returns an array of the entries in the registered users database.[br]
+ If <mask> is specified, only entries matching the <mask>
+ and the entries with no registration masks are listed.[br]
+ Please note that <mask> is a wildcard string that will match
+ wildcard strings... don't get messed with that :D[br]
+ @seealso:
+ [module:reguser]Registered users database interface[/module],
+ [doc:registered_users]Registered users database[/doc],
+ [cmd]reguser.add[/cmd],
+ [cmd]reguser.remove[/cmd],
+ [cmd]reguser.addmask[/cmd],
+ [fnc]$reguser.list[/fnc],
+ [fnc]$reguser.exactMatch[/fnc]
+*/
+
+static bool reguser_kvs_fnc_list(KviKvsModuleFunctionCall * c)
+{
+ QString szMask;
+
+ KVSM_PARAMETERS_BEGIN(c)
+ KVSM_PARAMETER("user_mask",KVS_PT_STRING,KVS_PF_OPTIONAL,szMask)
+ KVSM_PARAMETERS_END(c)
+
+ KviIrcMask mask(szMask);
+ KviKvsArray* pArray = new KviKvsArray();
+ int aid=0;
+
+ int cnt = 0;
+
+ KviPointerHashTable<QString,KviRegisteredUser> * d = g_pRegisteredUserDataBase->userDict();
+ KviPointerHashTableIterator<QString,KviRegisteredUser> it(*d);
+
+ while(KviRegisteredUser * u = it.current())
+ {
+ KviPointerList<KviIrcMask> * ml = u->maskList();
+ if(u->matches(mask) || (ml->count() == 0))
+ {
+ pArray->set(aid,new KviKvsVariant(u->name()));
+ aid++;
+ }
+ ++it;
+ }
+ c->returnValue()->setArray(pArray);
+ return true;
+}
+
+/*
+ @doc: reguser.showlist
+ @type:
+ command
+ @title:
+ reguser.showlist
+ @keyterms:
+ registered users
+ @short:
+ Lists the registered users
+ @syntax:
+ reguser.showlist [mask]
+ @description:
+ Lists the entries in the registered users database.[br]
+ If <mask> is specified, only entries matching the <mask>
+ and the entries with no registration masks are listed.[br]
+ Please note that <mask> is a wildcard string that will match
+ wildcard strings... don't get messed with that :D[br]
+ @seealso:
+ [module:reguser]Registered users database interface[/module],
+ [doc:registered_users]Registered users database[/doc],
+ [cmd]reguser.add[/cmd],
+ [cmd]reguser.remove[/cmd],
+ [fnc]$reguser.match[/fnc],
+ [fnc]$reguser.exactMatch[/fnc]
+*/
+
+static bool reguser_kvs_cmd_showlist(KviKvsModuleCommandCall * c)
+{
+ QString szMask;
+ KVSM_PARAMETERS_BEGIN(c)
+ KVSM_PARAMETER("mask",KVS_PT_STRING,KVS_PF_OPTIONAL,szMask)
+ KVSM_PARAMETERS_END(c)
+
+ KviIrcMask mask(szMask);
+ c->window()->outputNoFmt(KVI_OUT_SYSTEMMESSAGE,__tr2qs("Registered users database dump:"));
+
+ int count = 0;
+
+ KviPointerHashTable<QString,KviRegisteredUser> * d = g_pRegisteredUserDataBase->userDict();
+ KviPointerHashTableIterator<QString,KviRegisteredUser> it(*d);
+ while(KviRegisteredUser * u = it.current())
+ {
+ KviPointerList<KviIrcMask> * ml = u->maskList();
+ if(u->matches(mask) || (ml->count() == 0))
+ {
+ c->window()->output(KVI_OUT_SYSTEMMESSAGE,__tr2qs(" User: %c%Q"),KVI_TEXT_BOLD,&(u->name()));
+
+ if(ml->count() == 0)
+ {
+ c->window()->output(KVI_OUT_SYSTEMWARNING,__tr2qs(" Warning: this user has no registration masks"));
+ } else {
+ for(KviIrcMask * m = ml->first();m;m = ml->next())
+ {
+ c->window()->output(KVI_OUT_SYSTEMMESSAGE,__tr2qs(" Mask: %Q!%Q@%Q"),&(m->nick()),&(m->user()),&(m->host()));
+ }
+ }
+
+ KviPointerHashTable<QString,QString> * pd = u->propertyDict();
+ if(pd)
+ {
+ KviPointerHashTableIterator<QString,QString> pdit(*pd);
+ while(pdit.current())
+ {
+ QString key = pdit.currentKey();
+ c->window()->output(KVI_OUT_SYSTEMMESSAGE,__tr2qs(" Property: %Q=%Q"),&(key),pdit.current());
+ ++pdit;
+ }
+ } else c->window()->outputNoFmt(KVI_OUT_SYSTEMMESSAGE,__tr2qs(" No properties"));
+ count++;
+ }
+ ++it;
+ }
+
+ c->window()->output(KVI_OUT_SYSTEMMESSAGE,__tr2qs("Total: %d matching users (of %d in the database)"),count,d->count());
+ return true;
+}
+
+
+
+/*
+ @doc: reguser.match
+ @type:
+ function
+ @title:
+ $reguser.match
+ @short:
+ Returns an entry in the registered user database
+ @syntax:
+ $reguser.match(<user_mask>)
+ @description:
+ Returns the name of the first entry matching <user_mask> in the registered user database.[br]
+ The <user_mask> has the common [doc:irc_masks]irc mask[/doc] format but can't contain wildcards.[br]
+ @seealso:
+ [module:reguser]Registered users database interface[/module],
+ [doc:registered_users]Registered users database[/doc],
+ [cmd]reguser.add[/cmd],
+ [cmd]reguser.remove[/cmd],
+ [cmd]reguser.addmask[/cmd],
+ [fnc]$reguser.list[/fnc],
+ [fnc]$reguser.exactMatch[/fnc]
+*/
+
+static bool reguser_kvs_fnc_match(KviKvsModuleFunctionCall * c)
+{
+ QString szMask;
+
+ KVSM_PARAMETERS_BEGIN(c)
+ KVSM_PARAMETER("user_mask",KVS_PT_STRING,0,szMask)
+ KVSM_PARAMETERS_END(c)
+ KviIrcMask mask(szMask);
+//FIXME: it crashes kvirc KviRegisteredUser * u = c->context()->connection()->userDataBase()->registeredUser(mask.nick(),mask.user(),mask.host());
+ KviRegisteredUser * u = g_pRegisteredUserDataBase->findMatchingUser(mask.nick(),mask.user(),mask.host());
+ if(u) c->returnValue()->setString(u->name());
+ return true;
+}
+
+/*
+ @doc: reguser.exactmatch
+ @type:
+ function
+ @title:
+ $reguser.exactMatch
+ @short:
+ Returns an entry in the registered user database
+ @syntax:
+ $reguser.exactMatch(<user_mask>)
+ @description:
+ Returns the name of the registered user database entry that has <user_mask> in its registration mask list.[br]
+ The <user_mask> has the common [doc:irc_masks]wild irc mask[/doc] format and can contain wildcards.[br]
+ @seealso:
+ [module:reguser]Registered users database interface[/module],
+ [doc:registered_users]Registered users database[/doc],
+ [cmd]reguser.add[/cmd],
+ [cmd]reguser.remove[/cmd],
+ [cmd]reguser.addmask[/cmd],
+ [fnc]$reguser.list[/fnc],
+ [fnc]$reguser.match[/fnc]
+*/
+
+static bool reguser_kvs_fnc_exactMatch(KviKvsModuleFunctionCall * c)
+{
+ QString szMask;
+
+ KVSM_PARAMETERS_BEGIN(c)
+ KVSM_PARAMETER("user_mask",KVS_PT_STRING,0,szMask)
+ KVSM_PARAMETERS_END(c)
+ KviIrcMask mask(szMask);
+ KviRegisteredUser * u = g_pRegisteredUserDataBase->findUserWithMask(mask);
+ if(u) c->returnValue()->setString(u->name());
+ return true;
+}
+
+///*
+// @doc: reguser.matches
+// @type:
+// function
+// @title:
+// $reguser.matches
+// @short:
+// Returns entries in the registered user database
+// @syntax:
+// $reguser.matches(<user_mask>)
+// @description:
+// Returns a comma separated list of registered user masks that match <user_mask>.[br]
+// User mask must be in the format <nick>!<user>@<host> , where <user> and
+// <host> may contain '*' wildcards.[br]
+// If no registered mask matches the <user_mask> an empty string is returned.[br]
+// @seealso:
+// [module:reguser]reguser module documentation[/module]
+//*/
+
+//static void search_reguser_list(KviRegisteredUserList * l,KviWindow * w,const char * mask,KviStr & buffer)
+//{
+// for(KviRegisteredUser * u = l->first();u;u = l->next())
+// {
+// if(u->matches(mask))
+// {
+// if(buffer.hasData())buffer.append(',');
+// buffer.append(u->mask());
+// }
+// }
+//}
+
+//static bool reguser_module_fnc_matches(KviModule *m,KviCommand *c,KviParameterList * parms,KviStr &buffer)
+//{
+// ENTER_STACK_FRAME(c,"reguser.matches");
+//
+// KviStr list;
+//
+// const KviPointerHashTable<const char *,KviRegisteredUserList> * d = g_pRegisteredUserDataBase->nickDict();
+// KviPointerHashTableIterator<const char *,KviRegisteredUserList> it(*d);
+// while(KviRegisteredUserList * l = it.current())
+// {
+// search_reguser_list(l,c->window(),parms->safeFirstParam(),list);
+// ++it;
+// }
+//
+// search_reguser_list(g_pRegisteredUserDataBase->wildList(),c->window(),parms->safeFirstParam(),list);
+//
+// buffer.append(list);
+//
+// return c->leaveStackFrame();
+//}
+
+
+/*
+ @doc: reguser.mask
+ @type:
+ function
+ @title:
+ $reguser.mask
+ @short:
+ Returns the registration masks for a db entry
+ @syntax:
+ $reguser.mask(<name>[,<N>])
+ @description:
+ Returns the <N>th registration mask for the registered user database record identified
+ by <name>. If <N> is not given , returns an array of registration masks for that entry.[br]
+ If <name> does not identify a valid entry an empty string is returned;
+ if <N> is out of range (or there are no masks at all) , an empty string is returned.[br]
+ <N> is a ZERO BASED index.[br]
+ @examples:
+ [example]
+ [cmd]reguser.add[/cmd] Pragma
+ [cmd]reguser.addmask[/cmd] Pragma Pragma!*@*.it
+ [cmd]echo[/cmd] $reguser.mask(Pragma,0)
+ [/example]
+ @seealso:
+ [module:reguser]Registered users database interface[/module],
+ [doc:registered_users]Registered users database[/doc],
+ [cmd]reguser.add[/cmd],
+ [cmd]reguser.remove[/cmd],
+ [cmd]reguser.addmask[/cmd],
+ [cmd]reguser.delmask[/cmd],
+ [fnc]$reguser.list[/fnc],
+ [fnc]$reguser.match[/fnc],
+ [fnc]$reguser.matchProperty[/fnc]
+*/
+
+static bool reguser_kvs_fnc_mask(KviKvsModuleFunctionCall * c)
+{
+ QString szName;
+ QString szN;
+ KVSM_PARAMETERS_BEGIN(c)
+ KVSM_PARAMETER("name",KVS_PT_STRING,0,szName)
+ KVSM_PARAMETER("N",KVS_PT_STRING,KVS_PF_OPTIONAL,szN)
+ KVSM_PARAMETERS_END(c)
+
+ KviKvsArray* pArray = new KviKvsArray();
+ int aid=0;
+ KviRegisteredUser * u = g_pRegisteredUserDataBase->findUserByName(szName);
+ if(u)
+ {
+ KviStr n = szName;
+ if(n.hasData() && n.isUnsignedNum())
+ {
+ KviIrcMask * m = u->maskList()->at(n.toInt());
+ if(m) c->returnValue()->setString(m->nick()+"!"+m->user()+"@"+m->host());
+ } else {
+ int id=0;
+ for(KviIrcMask * m = u->maskList()->first();m;m = u->maskList()->next())
+ {
+ pArray->set(aid,new KviKvsVariant(QString(m->nick()+"!"+m->user()+"@"+m->host())));
+ aid++;
+ }
+ c->returnValue()->setArray(pArray);
+ }
+ }
+ return true;
+}
+/*
+ @doc: reguser.property
+ @type:
+ function
+ @title:
+ $reguser.property
+ @short:
+ Returns a property of an entry in the registered user database
+ @syntax:
+ $reguser.property(<user_name>,<property_name>)
+ @description:
+ Returns the value of the property identified by <property_name> and
+ bound to the entry identified by <user_name>.[br]
+ If the property is not set or if there is no entry with <user_name> an empty string is returned.[br]
+ @examples:
+ [example]
+ [cmd]reguser.add[/cmd] Pragma
+ [cmd]reguser.addmask[/cmd] Pragma Pragma!*@*.it
+ [cmd]reguser.setproperty[/cmd] Pragma isDev 1
+ [cmd]echo[/cmd] $reguser.property(Pragma,isDev)
+ [/example]
+ @seealso:
+ [module:reguser]Registered users database interface[/module],
+ [doc:registered_users]Registered users database[/doc],
+ [cmd]reguser.add[/cmd],
+ [cmd]reguser.remove[/cmd],
+ [cmd]reguser.addmask[/cmd],
+ [fnc]$reguser.list[/fnc],
+ [fnc]$reguser.match[/fnc],
+ [fnc]$reguser.matchProperty[/fnc]
+*/
+
+static bool reguser_kvs_fnc_property(KviKvsModuleFunctionCall * c)
+{
+ QString szName;
+ QString szProperty;
+ KVSM_PARAMETERS_BEGIN(c)
+ KVSM_PARAMETER("user_name",KVS_PT_STRING,0,szName)
+ KVSM_PARAMETER("property_name",KVS_PT_STRING,KVS_PF_OPTIONAL,szProperty)
+ KVSM_PARAMETERS_END(c)
+
+ KviRegisteredUser * u = g_pRegisteredUserDataBase->findUserByName(szName);
+ if(u)
+ {
+ QString tmp;
+ u->getProperty(szProperty,tmp);
+ c->returnValue()->setString(tmp);
+ }
+ return true;
+}
+/*
+ @doc: reguser.matchproperty
+ @type:
+ function
+ @title:
+ $reguser.matchProperty
+ @short:
+ Returns a property of an entry in the registered user database
+ @syntax:
+ $reguser.matchProperty(<user_mask>,<property_name>)
+ @description:
+ Returns the value of the property identified by <property_name> and
+ bound to the first entry matched by by <user_mask>.[br]
+ If the property is not set, an empty string is returned.[br]
+ If no entry matches <user_mask> this function returns an empty string
+ and does not print any error.[br]
+ [example]
+ %property = $reguser.matchProperty(<user_mask>,<property_name>)
+ [/example]
+ Is actually a shortcut for:[br]
+ [example]
+ %tmp = [fnc]$reguser.match[/fnc](<user_mask>)
+ if("%tmp" != "")%property = $reguser.property(%tmp,<property_name>)
+ [/example]
+ @seealso:
+ [module:reguser]Registered users database interface[/module],
+ [doc:registered_users]Registered users database[/doc],
+ [cmd]reguser.add[/cmd],
+ [cmd]reguser.remove[/cmd],
+ [cmd]reguser.addmask[/cmd],
+ [fnc]$reguser.list[/fnc],
+ [fnc]$reguser.match[/fnc],
+ [fnc]$reguser.property[/fnc]
+*/
+
+static bool reguser_kvs_fnc_matchProperty(KviKvsModuleFunctionCall * c)
+{
+ QString szMask;
+ QString szProperty;
+ KVSM_PARAMETERS_BEGIN(c)
+ KVSM_PARAMETER("user_mask",KVS_PT_STRING,0,szMask)
+ KVSM_PARAMETER("property_name",KVS_PT_STRING,KVS_PF_OPTIONAL,szProperty)
+ KVSM_PARAMETERS_END(c)
+
+ KviIrcMask mask(szMask);
+//FIXME: it crashes kvirc KviRegisteredUser * u = c->context()->connection()->userDataBase()->registeredUser(mask.nick(),mask.user(),mask.host());
+ KviRegisteredUser * u = g_pRegisteredUserDataBase->findMatchingUser(mask.nick(),mask.user(),mask.host());
+ if(u)
+ {
+ QString tmp;
+ u->getProperty(szProperty,tmp);
+ c->returnValue()->setString(tmp);
+ }
+ return true;
+}
+
+/*
+ @doc: reguser.wizard
+ @type:
+ command
+ @title:
+ reguser.wizard
+ @keyterms:
+ registering users, registration wizard
+ @short:
+ Shows a registration wizard dialog
+ @syntax:
+ reguser.wizard [mask]
+ @description:
+ Allows registering an user with an intuitive and easy to use interface.
+ If [mask] is specified , it is used as inital mask in the dialog.
+ @seealso:
+ [module:reguser]Registered users database interface[/module],
+ [doc:registered_users]Registered users database[/doc],
+ [cmd]reguser.add[/cmd],
+*/
+
+static bool reguser_kvs_cmd_wizard(KviKvsModuleCommandCall * c)
+{
+ QString szMask;
+ KVSM_PARAMETERS_BEGIN(c)
+ KVSM_PARAMETER("mask",KVS_PT_STRING,KVS_PF_OPTIONAL,szMask)
+ KVSM_PARAMETERS_END(c)
+
+ KviRegistrationWizard * w = new KviRegistrationWizard(szMask);
+ w->show();
+ return true;
+}
+
+static bool reguser_module_init(KviModule * m)
+{
+ g_pLocalRegisteredUserDataBase = 0;
+ g_pRegistrationWizardList = new KviPointerList<KviRegistrationWizard>;
+ g_pRegistrationWizardList->setAutoDelete(true);
+
+ KVSM_REGISTER_SIMPLE_COMMAND(m,"add",reguser_kvs_cmd_add);
+ KVSM_REGISTER_SIMPLE_COMMAND(m,"remove",reguser_kvs_cmd_remove);
+ KVSM_REGISTER_SIMPLE_COMMAND(m,"addmask",reguser_kvs_cmd_addmask);
+ KVSM_REGISTER_SIMPLE_COMMAND(m,"delmask",reguser_kvs_cmd_delmask);
+ KVSM_REGISTER_SIMPLE_COMMAND(m,"edit",reguser_kvs_cmd_edit);
+ KVSM_REGISTER_SIMPLE_COMMAND(m,"showlist",reguser_kvs_cmd_showlist);
+ KVSM_REGISTER_SIMPLE_COMMAND(m,"setproperty",reguser_kvs_cmd_setproperty);
+ KVSM_REGISTER_SIMPLE_COMMAND(m,"wizard",reguser_kvs_cmd_wizard);
+ KVSM_REGISTER_SIMPLE_COMMAND(m,"setIgnoreEnabled",reguser_kvs_cmd_setIgnoreEnabled);
+ KVSM_REGISTER_SIMPLE_COMMAND(m,"setIgnoreFlags",reguser_kvs_cmd_setIgnoreFlags);
+
+ KVSM_REGISTER_FUNCTION(m,"match",reguser_kvs_fnc_match);
+ KVSM_REGISTER_FUNCTION(m,"list",reguser_kvs_fnc_list);
+ KVSM_REGISTER_FUNCTION(m,"exactMatch",reguser_kvs_fnc_exactMatch);
+ KVSM_REGISTER_FUNCTION(m,"mask",reguser_kvs_fnc_mask);
+ KVSM_REGISTER_FUNCTION(m,"property",reguser_kvs_fnc_property);
+ KVSM_REGISTER_FUNCTION(m,"matchProperty",reguser_kvs_fnc_matchProperty);
+ KVSM_REGISTER_FUNCTION(m,"getIgnoreFlags",reguser_kvs_fnc_getIgnoreFlags);
+ KVSM_REGISTER_FUNCTION(m,"isIgnoreEnabled",reguser_kvs_fnc_isIgnoreEnabled);
+
+ return true;
+}
+
+static bool reguser_module_cleanup(KviModule *m)
+{
+ if(g_pRegisteredUsersDialog)delete g_pRegisteredUsersDialog;
+ g_pRegisteredUsersDialog = 0;
+
+ while(KviRegistrationWizard * w = g_pRegistrationWizardList->first())delete w;
+ delete g_pRegistrationWizardList;
+ g_pRegistrationWizardList = 0;
+
+ // FIXME: UNREGISTER THE METAOBJECTS
+ return true;
+}
+
+static bool reguser_module_can_unload(KviModule *)
+{
+ return ((g_pRegistrationWizardList->isEmpty()) && (g_pRegisteredUsersDialog == 0));
+}
+
+KVIRC_MODULE(
+ "Reguser", // module name
+ "1.0.0", // module version
+ "Copyright (C) 2002 Szymon Stefanek (pragma at kvirc dot net)", // author & (C)
+ "Script interface to the registered users database",
+ reguser_module_init,
+ reguser_module_can_unload,
+ 0,
+ reguser_module_cleanup
+)
diff --git a/src/modules/reguser/wizard.cpp b/src/modules/reguser/wizard.cpp
new file mode 100644
index 00000000..1777621d
--- /dev/null
+++ b/src/modules/reguser/wizard.cpp
@@ -0,0 +1,464 @@
+//
+// File : wizard.cpp
+// Creation date : Fri Jun 26 2002 21:21:21 CEST by Szymon Stefanek
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 2002 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+
+#include "wizard.h"
+
+#include "kvi_locale.h"
+#include "kvi_pointerlist.h"
+#include "kvi_app.h"
+#include "kvi_ircmask.h"
+#include "kvi_selectors.h"
+#include "kvi_pixmap.h"
+#include "kvi_regusersdb.h"
+#include "kvi_iconmanager.h"
+#ifdef COMPILE_USE_QT4
+#include <QDesktopWidget>
+#endif
+
+#include <qcheckbox.h>
+#include <qlabel.h>
+#include <qlineedit.h>
+#include <qpushbutton.h>
+#include <qwidget.h>
+#include <qlayout.h>
+#include <qvariant.h>
+#include <qframe.h>
+
+
+extern KVIRC_API KviRegisteredUserDataBase * g_pRegisteredUserDataBase;
+extern KviPointerList<KviRegistrationWizard> * g_pRegistrationWizardList;
+
+KviRegistrationWizard::KviRegistrationWizard(const char * startMask,KviRegisteredUserDataBase * db,QWidget * par,bool bModal)
+: KviTalWizard(par)
+{
+ m_pDb = db;
+
+ setModal(bModal);
+
+ m_bModal = bModal;
+
+ KviIrcMask mask(startMask ? startMask : "*!*@*");
+
+ g_pRegistrationWizardList->append(this);
+
+ QGridLayout* m_pPage1Layout;
+ QGridLayout* m_pPage2Layout;
+ QGridLayout* m_pPage3Layout;
+ QGridLayout* m_pPage4Layout;
+ QGridLayout* m_pPage5Layout;
+
+ QLabel* TextLabel10_2;
+ QLabel* TextLabel10;
+ QLabel* TextLabel10_3;
+ QLabel* TextLabel10_3_2;
+
+ QFrame * f;
+
+// resize( 490, 456 );
+ setCaption(__tr2qs("User Registration Wizard - KVIrc"));
+ setIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_LINUX)));
+
+ setSizeGripEnabled( TRUE );
+
+ m_pPage1 = new QWidget(this);
+ m_pPage1Layout = new QGridLayout(m_pPage1);
+ m_pPage1Layout->setSpacing(4);
+ m_pPage1Layout->setMargin(8);
+
+ m_pLabel1 = new QLabel(m_pPage1);
+ m_pLabel1->setText(__tr2qs("<p>Welcome to the user registration wizard.<br>This process allows you to add an IRC user to the database and set properties for that user. KVIrc will be (hopefully) able to recognize the user, add him to the notify list, and display the associated avatar.<br><br>First of all, you must insert an <b>entry name or real name</b> for the user you're going to register. The name will be used to identify the database entry and has no specific requirements, it can be a given name, nickname, or just some text to remind you of the real person.<br>Examples: \"George W Bush\", \"Dubya\".\n</p>" ));
+
+ m_pPage1Layout->addWidget(m_pLabel1, 0, 0);
+
+ m_pEditRealName = new QLineEdit(m_pPage1);
+ //m_pEditRealName->setAlignment(int(QLineEdit::AlignHCenter));
+
+ m_pPage1Layout->addWidget(m_pEditRealName,1,0);
+ addPage( m_pPage1,__tr2qs("Step 1: Entry Name"));
+
+ if(mask.nick() != "*")m_pEditRealName->setText(mask.nick());
+
+ connect(m_pEditRealName,SIGNAL(textChanged(const QString &)),this,SLOT(realNameChanged(const QString &)));
+
+ // PAGE 2
+
+
+ m_pPage2 = new QWidget(this);
+ m_pPage2Layout = new QGridLayout( m_pPage2 );
+ m_pPage2Layout->setSpacing( 4 );
+ m_pPage2Layout->setMargin( 8 );
+
+ m_pLabel2 = new QLabel( m_pPage2);
+ m_pLabel2->setText(__tr2qs("<p>A registered user is identified by one or more <b>IRC masks</b>.<br>A mask must be in the following form:<br><b>nickname!username@hostname</b><br>and can contain wildcard characters '*' and '?'. Be careful in choosing the masks, as they are the only way to verify the identity of a registered user.<br><br>You can enter at most two masks here, if you wish to add more masks, use the \"<b>Edit</b>\" button in the Registered Users dialog. You must enter at least one mask.</p>"));
+
+ m_pPage2Layout->addMultiCellWidget(m_pLabel2,0,0,0,4);
+
+ //KviStr szMask;
+
+ //mask.mask(szMask,11);
+
+ //KviIrcMask masktempl(szMask.ptr());
+
+ m_pNicknameEdit1 = new QLineEdit(m_pPage2);
+ m_pNicknameEdit1->setAlignment(Qt::AlignRight);
+ if(mask.nick() != "*")m_pNicknameEdit1->setText(mask.nick());
+ connect(m_pNicknameEdit1,SIGNAL(textChanged(const QString &)),this,SLOT(maskChanged(const QString &)));
+ m_pPage2Layout->addWidget( m_pNicknameEdit1, 1, 0 );
+
+ m_pUsernameEdit1 = new QLineEdit(m_pPage2);
+ m_pUsernameEdit1->setAlignment(Qt::AlignHCenter);
+ if(mask.hasUser())m_pUsernameEdit1->setText(mask.user());
+ connect(m_pUsernameEdit1,SIGNAL(textChanged(const QString &)),this,SLOT(maskChanged(const QString &)));
+ m_pPage2Layout->addWidget(m_pUsernameEdit1,1,2);
+
+ m_pHostEdit1 = new QLineEdit(m_pPage2);
+ if(mask.hasHost())m_pHostEdit1->setText(mask.host());
+ connect(m_pHostEdit1,SIGNAL(textChanged(const QString &)),this,SLOT(maskChanged(const QString &)));
+ m_pPage2Layout->addWidget(m_pHostEdit1,1,4);
+
+ m_pNicknameEdit2 = new QLineEdit(m_pPage2);
+ m_pNicknameEdit2->setAlignment(Qt::AlignRight);
+ m_pPage2Layout->addWidget(m_pNicknameEdit2,2,0);
+
+ m_pUsernameEdit2 = new QLineEdit(m_pPage2);
+ m_pUsernameEdit2->setAlignment(Qt::AlignHCenter);
+ m_pPage2Layout->addWidget(m_pUsernameEdit2,2,2);
+
+ m_pHostEdit2 = new QLineEdit(m_pPage2);
+ m_pPage2Layout->addWidget(m_pHostEdit2,2,4);
+
+ TextLabel10_2 = new QLabel(m_pPage2);
+ TextLabel10_2->setText("<center><b>!</b></center>");
+ TextLabel10_2->setAlignment(int(Qt::AlignCenter));
+ m_pPage2Layout->addWidget(TextLabel10_2,2,1);
+
+ TextLabel10 = new QLabel(m_pPage2);
+ TextLabel10->setText("<center><b>!</b></center>");
+ TextLabel10->setAlignment(int(Qt::AlignCenter));
+ m_pPage2Layout->addWidget(TextLabel10,1,1);
+
+ TextLabel10_3 = new QLabel(m_pPage2);
+ TextLabel10_3->setText("<center><b>@</b></center>");
+ TextLabel10_3->setAlignment(int(Qt::AlignCenter));
+ m_pPage2Layout->addWidget(TextLabel10_3,1,3);
+
+ TextLabel10_3_2 = new QLabel(m_pPage2);
+ TextLabel10_3_2->setText("<center><b>@</b></center>");
+ TextLabel10_3_2->setAlignment(int(Qt::AlignCenter));
+ m_pPage2Layout->addWidget(TextLabel10_3_2,2,3);
+
+ addPage(m_pPage2,__tr2qs("Step 2: Mask Selection"));
+
+
+
+
+
+ m_pPage3 = new QWidget(this);
+ m_pPage3Layout = new QGridLayout(m_pPage3);
+ m_pPage3Layout->setSpacing(4);
+ m_pPage3Layout->setMargin(8);
+
+ m_pLabel3 = new QLabel(m_pPage3);
+ m_pLabel3->setText(__tr2qs("<p>If you want to store an avatar image for this user, you can set it here. KVIrc will show the avatar in the userlist next to the user's nickname.<br>An avatar can be in any supported image format (PNG is recommended). Keep in mind that KVIrc stores avatars in memory and has to resize them to fit in the userlist, thus it's better to use small, low-resolution images.</p>"));
+ m_pPage3Layout->addWidget(m_pLabel3,0,0);
+
+ f = new QFrame(m_pPage3);
+ f->setFrameStyle(QFrame::HLine | QFrame::Sunken);
+ m_pPage3Layout->addWidget(f,1,0);
+
+ m_pAvatar = new KviPixmap();
+ m_pAvatarSelector = new KviPixmapSelector(m_pPage3,__tr2qs("Store an avatar for this user"),m_pAvatar,true);
+ m_pPage3Layout->addWidget(m_pAvatarSelector,2,0);
+
+ m_pPage3Layout->setRowStretch(0,1);
+
+ addPage(m_pPage3,__tr2qs( "Step 3: Avatar Selection"));
+
+
+
+
+ m_pPage4 = new QWidget(this);
+ m_pPage4Layout = new QGridLayout(m_pPage4);
+ m_pPage4Layout->setSpacing(4);
+ m_pPage4Layout->setMargin(8);
+
+ m_pLabel4 = new QLabel(m_pPage4);
+ m_pLabel4->setText(__tr2qs("<p>If you want to be notified when this user is online or goes offline, you must specify the list of nicknames that KVIrc will look for.<br><br>You can enter at most two nicknames here, if you wish to add more nicknames, use the \"<b>Edit</b>\" button in the Registered Users dialog.</p>"));
+ m_pPage4Layout->addMultiCellWidget(m_pLabel4,0,0,0,1);
+
+
+ f = new QFrame(m_pPage4);
+ f->setFrameStyle(QFrame::HLine | QFrame::Sunken);
+ m_pPage4Layout->addMultiCellWidget(f,1,1,0,1);
+
+ m_pNotifyCheck = new QCheckBox(m_pPage4);
+ m_pNotifyCheck->setText(__tr2qs("Add this user to the notify list"));
+ m_pNotifyCheck->setChecked(false);
+ connect(m_pNotifyCheck,SIGNAL(toggled(bool)),this,SLOT(notifyCheckToggled(bool)));
+ m_pPage4Layout->addMultiCellWidget(m_pNotifyCheck,2,2,0,1);
+
+ m_pNotifyNickLabel1 = new QLabel(m_pPage4);
+ m_pNotifyNickLabel1->setText(__tr2qs("Nickname:"));
+ m_pPage4Layout->addWidget(m_pNotifyNickLabel1,3,0);
+
+ m_pNotifyNickLabel2 = new QLabel(m_pPage4);
+ m_pNotifyNickLabel2->setText(__tr2qs("Nickname 2:"));
+ m_pPage4Layout->addWidget(m_pNotifyNickLabel2,4,0);
+
+ m_pNotifyNickEdit1 = new QLineEdit(m_pPage4);
+ if(mask.nick() != "*")m_pNotifyNickEdit1->setText(mask.nick());
+ connect(m_pNotifyNickEdit1,SIGNAL(textChanged(const QString &)),this,SLOT(notifyNickChanged(const QString &)));
+ m_pPage4Layout->addWidget(m_pNotifyNickEdit1,3,1);
+
+ m_pNotifyNickEdit2 = new QLineEdit(m_pPage4);
+ connect(m_pNotifyNickEdit2,SIGNAL(textChanged(const QString &)),this,SLOT(notifyNickChanged(const QString &)));
+ m_pPage4Layout->addWidget(m_pNotifyNickEdit2,4,1);
+
+ m_pPage4Layout->setRowStretch(0,1);
+
+ addPage(m_pPage4,__tr2qs("Step 4: Notify List"));
+
+
+
+
+
+ m_pPage5 = new QWidget(this);
+ m_pPage5Layout = new QGridLayout(m_pPage5);
+ m_pPage5Layout->setSpacing(4);
+ m_pPage5Layout->setMargin(8);
+
+ m_pTextLabel5 = new QLabel(m_pPage5);
+ m_pTextLabel5->setText(__tr2qs("<p>That's it. The user registration has been completed.<br><br>Click \"<b>Finish</b>\" to close this dialog.</p>"));
+ m_pPage5Layout->addWidget(m_pTextLabel5,0,0);
+
+ addPage(m_pPage5,__tr2qs("Registration Complete"));
+
+ setFinishEnabled(m_pPage5,true);
+ QString dummy;
+ maskChanged(dummy);
+ realNameChanged(dummy);
+ notifyCheckToggled(false);
+
+ setMinimumSize(QSize(350,420));
+
+ // signals and slots connections
+}
+
+KviRegistrationWizard::~KviRegistrationWizard()
+{
+ delete m_pAvatar;
+ g_pRegistrationWizardList->setAutoDelete(false);
+ g_pRegistrationWizardList->removeRef(this);
+ g_pRegistrationWizardList->setAutoDelete(true);
+}
+
+void KviRegistrationWizard::reject()
+{
+ KviTalWizard::reject();
+ if(!m_bModal)delete this;
+// hide();
+// g_pApp->collectGarbage(this);
+}
+
+void KviRegistrationWizard::accept()
+{
+ bool bLocalDb = true;
+ if(!m_pDb)
+ {
+ bLocalDb = false;
+ m_pDb = g_pRegisteredUserDataBase;
+ }
+
+ QString szName = m_pEditRealName->text();
+ KviRegisteredUser * u;
+
+
+ if(bLocalDb)
+ {
+ if(szName.isEmpty()) szName = "user";
+
+ QString szNameOk = szName;
+
+ int idx = 1;
+
+ do {
+ u = m_pDb->findUserByName(szNameOk);
+ if(u)
+ {
+ KviQString::sprintf(szNameOk,"%Q%d",&szNameOk,idx);
+ idx++;
+ }
+ } while(u);
+
+ u = m_pDb->addUser(szNameOk);
+
+ } else {
+ u = m_pDb->findUserByName(szName);
+ if(!u)u = m_pDb->addUser(szName);
+ }
+
+ if(!u)
+ {
+ // ops... no way
+ // FIXME: spit an error message ?
+ debug("Ops.. something wrong with the regusers db");
+ //delete this;
+ return;
+ }
+
+ QString m1 = m_pNicknameEdit1->text();
+ QString m2 = m_pUsernameEdit1->text();
+ QString m3 = m_pHostEdit1->text();
+ KviIrcMask * mk = new KviIrcMask(m1,m2,m3);
+ m_pDb->removeMask(*mk);
+ m_pDb->addMask(u,mk);
+
+
+ m1 = m_pNicknameEdit2->text();
+ m2 = m_pUsernameEdit2->text();
+ if(m2.isEmpty())m2 = "*";
+ if(m3.isEmpty())m3 = "*";
+ m3 = m_pHostEdit2->text();
+ mk = new KviIrcMask(m1,m2,m3);
+
+ m_pDb->removeMask(*mk);
+ m_pDb->addMask(u,mk);
+
+ m_pAvatarSelector->commit();
+
+ bool bSetAvatar = false;
+
+ if(!m_pAvatar->isNull())
+ {
+ QString szPath = m_pAvatar->path();
+ u->setProperty("avatar",szPath);
+ bSetAvatar = true;
+ }
+
+ if(m_pNotifyCheck->isChecked())
+ {
+ m1 = m_pNotifyNickEdit1->text();
+ m2 = m_pNotifyNickEdit2->text();
+ if(!m2.isEmpty())
+ {
+ if(!m1.isEmpty())
+ m1.append(' ');
+ m1.append(m2);
+ }
+
+ if(!m1.isEmpty())
+ {
+ u->setProperty("notify",m1);
+ if(!bLocalDb)g_pApp->restartNotifyLists();
+ }
+ }
+
+ if(bSetAvatar && !bLocalDb)
+ g_pApp->resetAvatarForMatchingUsers(u);
+
+ KviTalWizard::accept();
+
+// if(!m_bModal)delete this;
+// hide();
+// g_pApp->collectGarbage(this);
+}
+
+
+void KviRegistrationWizard::showEvent(QShowEvent *e)
+{
+ if(height() < 420)resize(width(),420);
+ move((g_pApp->desktop()->width() - width())/2,(g_pApp->desktop()->height() - height())/2);
+ KviTalWizard::showEvent(e);
+}
+
+void KviRegistrationWizard::maskChanged(const QString &)
+{
+ KviStr tmp1 = m_pNicknameEdit1->text();
+ KviStr tmp2 = m_pUsernameEdit1->text();
+ KviStr tmp3 = m_pHostEdit1->text();
+
+ if(tmp1.isEmpty())
+ {
+ setNextEnabled(m_pPage2,false);
+ return;
+ }
+
+ if(tmp2.isEmpty())
+ {
+ setNextEnabled(m_pPage2,false);
+ return;
+ }
+
+ if(tmp3.isEmpty())
+ {
+ setNextEnabled(m_pPage2,false);
+ return;
+ }
+
+ KviStr mask(KviStr::Format,"%s!%s@%s",tmp1.ptr(),tmp2.ptr(),tmp3.ptr());
+
+ //KviIrcMask m(mask.ptr());
+
+ setNextEnabled(m_pPage2,mask!="*!*@*");
+}
+
+void KviRegistrationWizard::realNameChanged(const QString &)
+{
+ QString tmp = m_pEditRealName->text();
+ setNextEnabled(m_pPage1,!(tmp.isEmpty() || tmp.isNull()));
+}
+
+void KviRegistrationWizard::notifyNickChanged(const QString &)
+{
+ bool bYes = !m_pNotifyCheck->isChecked();
+
+ if(!bYes)
+ {
+ // we need at least one nickname then :)
+ KviStr tmp = m_pNotifyNickEdit1->text();
+ if(tmp.hasData())
+ {
+ bYes = true;
+ } else {
+ tmp = m_pNotifyNickEdit2->text();
+ if(tmp.hasData())bYes = true;
+ }
+ }
+
+ setNextEnabled(m_pPage4,bYes);
+}
+
+void KviRegistrationWizard::notifyCheckToggled(bool)
+{
+ bool bYes = m_pNotifyCheck->isChecked();
+
+ m_pNotifyNickEdit1->setEnabled(bYes);
+ m_pNotifyNickEdit2->setEnabled(bYes);
+ m_pNotifyNickLabel1->setEnabled(bYes);
+ m_pNotifyNickLabel2->setEnabled(bYes);
+
+ QString dummy;
+ notifyNickChanged(dummy);
+}
+
+#include "wizard.moc"
diff --git a/src/modules/reguser/wizard.h b/src/modules/reguser/wizard.h
new file mode 100644
index 00000000..f1446ec6
--- /dev/null
+++ b/src/modules/reguser/wizard.h
@@ -0,0 +1,89 @@
+#ifndef _WIZARD_H_
+#define _WIZARD_H_
+//
+// File : wizard.h
+// Creation date : Fri Jun 26 2002 21:21:21 CEST by Szymon Stefanek
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 2002 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+
+#include "kvi_string.h"
+
+#include <kvi_tal_wizard.h>
+
+class KviPixmap;
+class KviPixmapSelector;
+class KviTalVBoxLayout;
+class KviTalHBoxLayout;
+class QGridLayout;
+class QCheckBox;
+class QLabel;
+class QLineEdit;
+class QWidget;
+class KviRegisteredUserDataBase;
+
+class KviRegistrationWizard : public KviTalWizard
+{
+ Q_OBJECT
+public:
+ KviRegistrationWizard(const char * startMask,KviRegisteredUserDataBase * db = 0,QWidget * par = 0,bool bModal = false);
+ ~KviRegistrationWizard();
+
+ KviRegisteredUserDataBase * m_pDb;
+
+ KviStr m_szStartMask;
+
+ bool m_bModal;
+
+ QWidget* m_pPage1;
+ QLabel* m_pLabel1;
+ QLineEdit* m_pEditRealName;
+ QWidget* m_pPage2;
+ QLabel* m_pLabel2;
+ QLineEdit* m_pNicknameEdit1;
+ QLineEdit* m_pNicknameEdit2;
+ QLineEdit* m_pHostEdit1;
+ QLineEdit* m_pHostEdit2;
+ QLineEdit* m_pUsernameEdit1;
+ QLineEdit* m_pUsernameEdit2;
+ QWidget* m_pPage3;
+ QLabel* m_pLabel3;
+ KviPixmapSelector * m_pAvatarSelector;
+ QWidget* m_pPage4;
+ QCheckBox* m_pNotifyCheck;
+ QLabel* m_pNotifyNickLabel1;
+ QLabel* m_pNotifyNickLabel2;
+ QLabel* m_pLabel4;
+ QLineEdit* m_pNotifyNickEdit1;
+ QLineEdit* m_pNotifyNickEdit2;
+ QWidget* m_pPage5;
+ QLabel* m_pTextLabel5;
+
+ KviPixmap * m_pAvatar;
+protected:
+ virtual void showEvent(QShowEvent *e);
+ virtual void accept();
+ virtual void reject();
+protected slots:
+ void realNameChanged(const QString &str);
+ void maskChanged(const QString &str);
+ void notifyNickChanged(const QString &);
+ void notifyCheckToggled(bool);
+};
+
+#endif // _WIZARD_H_