/***************************************************************************
* newownerwindow.cpp
*
* Fri Jul 15 02:16:30 2005
* Copyright 2005 User
* Email
****************************************************************************/
#include "newownerwindow.h"
#include "imownerdaemon.h"
newOwnerWindow::newOwnerWindow(gchar* _titleString)
{
lastDaemon = NULL;
wType = UE_REGISTEROWNER;
titleString = g_strdup_printf("%s", _titleString);
}
newOwnerWindow::~newOwnerWindow()
{
g_free(titleString);
}
GtkWidget* newOwnerWindow::createWindowContent()
{
GtkWidget *frame,
*icon,
*hbox1,
*label,
*vbox1,
*vbox2;
// create the wizard title
icon = gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_DIALOG);
label = gtk_label_new(titleString);
gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f);
gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
hbox1 = gtk_hbox_new(FALSE, 5);
gtk_box_pack_start(GTK_BOX(hbox1), icon, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox1), label, FALSE, TRUE, 0);
frame = gtk_frame_new(NULL);
gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_OUT);
gtk_container_add(GTK_CONTAINER(frame), hbox1);
oneAlertMessage = g_string_new("");
// create the notebook
notebook = gtk_notebook_new();
gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook), FALSE);
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), createTitlePage(), NULL);
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), createDataPage(), NULL);
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), createVerifyPage(), NULL);
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), createSuccessPage(), NULL);
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), createFailedPage(), NULL);
if (strlen(oneAlertMessage->str)>0)
gtk_label_set_label(GTK_LABEL(oneAccountAlertLabel), oneAlertMessage->str);
g_string_free(oneAlertMessage, TRUE);
// create the main vbox
vbox1 = gtk_vbox_new(FALSE, 5);
gtk_container_set_border_width(GTK_CONTAINER(vbox1), 5);
gtk_box_pack_start(GTK_BOX(vbox1), notebook, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(vbox1), gtk_hseparator_new(), FALSE, TRUE, 2);
gtk_box_pack_start(GTK_BOX(vbox1), createButtonbar(), FALSE, TRUE, 0);
vbox2 = gtk_vbox_new(FALSE, 5);
gtk_box_pack_start(GTK_BOX(vbox2), frame, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox2), vbox1, TRUE, TRUE, 0);
currentPage = 0;
return vbox2;
}
GtkWidget* newOwnerWindow::createTitlePage()
{
GtkWidget *vbox,
*label;
label = gtk_label_new(tr("In the following pages you can add a new account to Licq by creating a new one or adding an existing account.\n\n"
"You will first be asked about basic information on that new account. If a new one has to be created it will then be registered by the server."
"Afterwards you can add your personal information.\n\n"
"In the future there will be an option to import users. Stay patient :)"));
gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.0f);
gtk_widget_set_size_request(label, 300, -1);
oneAccountAlertLabel = gtk_label_new(NULL);
gtk_label_set_use_markup(GTK_LABEL(oneAccountAlertLabel), TRUE);
gtk_label_set_line_wrap(GTK_LABEL(oneAccountAlertLabel), TRUE);
gtk_misc_set_alignment(GTK_MISC(oneAccountAlertLabel), 0.0f, 0.0f);
gtk_widget_set_size_request(oneAccountAlertLabel, 300, -1);
vbox = gtk_vbox_new(FALSE, 0);
gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(vbox), oneAccountAlertLabel, TRUE, TRUE, 5);
return vbox;
}
GtkWidget* newOwnerWindow::createDataPage()
{
GtkWidget *label1,
*label2,
*vbox1,
*alignment,
*alignment2,
*vbox2,
*mainVBox,
*table;
GtkListStore *protoStore;
GList *protocols;
GtkTreeIter iter;
GtkCellRenderer *renderer;
GtkSizeGroup *sizes;
IMPluginDaemon *protoDaemon;
gboolean createOneAlertMessage;
gchar *fstr;
mainVBox = gtk_vbox_new(FALSE, 20);
gtk_container_set_border_width(GTK_CONTAINER(mainVBox), 5);
fstr = g_strdup_printf("%s", tr("What would you like to do?"));
label1 = gtk_label_new(fstr);
g_free(fstr);
gtk_misc_set_alignment(GTK_MISC(label1), 0.0f, 0.0f);
gtk_label_set_use_markup(GTK_LABEL(label1), TRUE);
registerUserButton = gtk_radio_button_new_with_mnemonic(NULL, tr("_Register a new account"));
g_signal_connect_swapped(registerUserButton, "clicked", G_CALLBACK(this->cb_userActionButtonClicked), this);
useExistingUserButton = gtk_radio_button_new_with_mnemonic(gtk_radio_button_get_group(GTK_RADIO_BUTTON(registerUserButton)), tr("_Add a registered account"));
g_signal_connect_swapped(useExistingUserButton, "clicked", G_CALLBACK(this->cb_userActionButtonClicked), this);
vbox1 = gtk_vbox_new(FALSE, 2);
gtk_box_pack_start(GTK_BOX(vbox1), registerUserButton, FALSE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(vbox1), useExistingUserButton, FALSE, TRUE, 0);
alignment = gtk_alignment_new(0.0f, 0.0f, 1.0f, 1.0f);
gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), 0, 0, 20, 0);
gtk_container_add(GTK_CONTAINER(alignment), vbox1);
vbox2 = gtk_vbox_new(FALSE, 5);
gtk_box_pack_start(GTK_BOX(vbox2), label1, FALSE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(vbox2), alignment, FALSE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(mainVBox), vbox2, FALSE, TRUE, 0);
fstr = g_strdup_printf("%s", tr("What is the user ID / Password?"));
label1 = gtk_label_new(fstr);
g_free(fstr);
gtk_misc_set_alignment(GTK_MISC(label1), 0.0f, 0.0f);
gtk_label_set_use_markup(GTK_LABEL(label1), TRUE);
table = gtk_table_new(4, 2, FALSE);
sizes = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
label2 = gtk_label_new(tr("User ID:"));
gtk_misc_set_alignment(GTK_MISC(label2), 0.0f, 0.0f);
gtk_misc_set_padding(GTK_MISC(label2), 5, 0);
gtk_size_group_add_widget(sizes, label2);
userIDEntry = gtk_entry_new();
gtk_table_attach(GTK_TABLE(table), label2, 0, 1, 0, 1, (GtkAttachOptions)0, (GtkAttachOptions)0, 0, 0);
gtk_table_attach_defaults(GTK_TABLE(table), userIDEntry, 1, 2, 0, 1);
label2 = gtk_label_new(tr("Password:"));
gtk_misc_set_alignment(GTK_MISC(label2), 0.0f, 0.0f);
gtk_misc_set_padding(GTK_MISC(label2), 5, 5);
gtk_size_group_add_widget(sizes, label2);
userPasswordEntry = gtk_entry_new();
gtk_entry_set_invisible_char(GTK_ENTRY(userPasswordEntry), '*');
gtk_entry_set_visibility(GTK_ENTRY(userPasswordEntry), FALSE);
alignment2 = gtk_alignment_new(0.0f, 0.0f, 1.0f, 1.0f);
gtk_alignment_set_padding(GTK_ALIGNMENT(alignment2), 5, 0, 0, 0);
gtk_container_add(GTK_CONTAINER(alignment2), userPasswordEntry);
gtk_table_attach(GTK_TABLE(table), label2, 0, 1, 1, 2, (GtkAttachOptions)0, (GtkAttachOptions)0, 0, 0);
gtk_table_attach_defaults(GTK_TABLE(table), alignment2, 1, 2, 1, 2);
label2 = gtk_label_new(tr("Cornfirm:"));
gtk_misc_set_alignment(GTK_MISC(label2), 0.0f, 0.0f);
gtk_misc_set_padding(GTK_MISC(label2), 5, 0);
gtk_size_group_add_widget(sizes, label2);
pwdConfirmEntry = gtk_entry_new();
gtk_entry_set_invisible_char(GTK_ENTRY(pwdConfirmEntry), '*');
gtk_entry_set_visibility(GTK_ENTRY(pwdConfirmEntry), FALSE);
alignment2 = gtk_alignment_new(0.0f, 0.0f, 1.0f, 1.0f);
gtk_alignment_set_padding(GTK_ALIGNMENT(alignment2), 0, 5, 0, 0);
gtk_container_add(GTK_CONTAINER(alignment2), pwdConfirmEntry);
gtk_table_attach(GTK_TABLE(table), label2, 0, 1, 2, 3, (GtkAttachOptions)0, (GtkAttachOptions)0, 0, 0);
gtk_table_attach_defaults(GTK_TABLE(table), alignment2, 1, 2, 2, 3);
label2 = gtk_label_new(tr("Protocol:"));
gtk_misc_set_alignment(GTK_MISC(label2), 0.0f, 0.0f);
gtk_misc_set_padding(GTK_MISC(label2), 5, 0);
gtk_size_group_add_widget(sizes, label2);
protoStore = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_POINTER);
protocolsList = gtk_combo_box_new_with_model(GTK_TREE_MODEL(protoStore));
g_object_unref(protoStore);
renderer = gtk_cell_renderer_text_new();
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(protocolsList), renderer, TRUE);
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(protocolsList), renderer, "text", 0, NULL);
protocols = IO_getPluginsList();
if (g_list_length(protocols)<=1)
gtk_widget_set_sensitive(protocolsList, FALSE);
createOneAlertMessage = FALSE;
while(protocols)
{
protoDaemon = (IMPluginDaemon*)protocols->data;
if (protoDaemon->isLoaded && protoDaemon->isProtoPlugin)
{
if (!protoDaemon->owners)
{
gtk_list_store_append(protoStore, &iter);
gtk_list_store_set(protoStore, &iter,
0, protoDaemon->name,
1, protoDaemon,
-1);
if (createOneAlertMessage)
{
if (!strlen(oneAlertMessage->str))
oneAlertMessage = g_string_append(oneAlertMessage, protoDaemon->name);
else
g_string_append_printf(oneAlertMessage, ", %s", protoDaemon->name);
}
} else
createOneAlertMessage = TRUE;
}
protocols = protocols->next;
}
if (createOneAlertMessage)
{
if (!strlen(oneAlertMessage->str))
g_string_printf(oneAlertMessage, "%s", "All protocols have one owner. You cannot create another account!");
else
{
oneAlertMessage = g_string_prepend(oneAlertMessage, tr("Currently only one account can be attached to an owner. You can still attach owners to the following protocols: "));
oneAlertMessage = g_string_prepend(oneAlertMessage, "");
oneAlertMessage = g_string_append(oneAlertMessage, "");
}
}
gtk_combo_box_set_active(GTK_COMBO_BOX(protocolsList), 0);
g_signal_connect_swapped(protocolsList, "changed", G_CALLBACK(this->cb_userActionButtonClicked), this);
fstr = g_strdup_printf("%s", tr("Currently only registering of ICQ-users is possible."));
regHintLabel = gtk_label_new(fstr);
g_free(fstr);
gtk_label_set_use_markup(GTK_LABEL(regHintLabel), TRUE);
gtk_label_set_line_wrap(GTK_LABEL(regHintLabel), TRUE);
gtk_widget_set_no_show_all(regHintLabel, TRUE);
vbox2 = gtk_vbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox2), protocolsList, FALSE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(vbox2), regHintLabel, FALSE, FALSE, 0);
gtk_table_attach(GTK_TABLE(table), label2, 0, 1, 3, 4, (GtkAttachOptions)0, (GtkAttachOptions)0, 0, 0);
gtk_table_attach_defaults(GTK_TABLE(table), vbox2, 1, 2, 3, 4);
alignment = gtk_alignment_new(0.0f, 0.0f, 1.0f, 1.0f);
gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), 0, 0, 20, 0);
gtk_container_add(GTK_CONTAINER(alignment), table);
vbox2 = gtk_vbox_new(FALSE, 5);
gtk_box_pack_start(GTK_BOX(vbox2), label1, FALSE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(vbox2), alignment, FALSE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(mainVBox), vbox2, FALSE, TRUE, 0);
return mainVBox;
}
GtkWidget* newOwnerWindow::createVerifyPage()
{
GtkWidget *frame,
*label,
*vbox,
*alignment;
gchar *fstr;
fstr = g_strdup_printf("%s", tr("Please type the letters that you see in the image below in the text field. This is neccessary to prevent bots from creating accounts. Do not type whitespaces and do use capitals."));
label = gtk_label_new(fstr);
g_free(fstr);
gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
verifyImage = gtk_image_new();
frame = gtk_frame_new(NULL);
gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
gtk_container_add(GTK_CONTAINER(frame), verifyImage);
alignment = gtk_alignment_new(0.5f, 0.0f, 0.0f, 0.0f);
gtk_container_add(GTK_CONTAINER(alignment), frame);
verifyEntry = gtk_entry_new();
vbox = gtk_vbox_new(FALSE, 10);
gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(vbox), alignment, FALSE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(vbox), verifyEntry, FALSE, TRUE, 0);
return vbox;
}
GtkWidget* newOwnerWindow::createSuccessPage()
{
GtkWidget *vbox,
*label1,
*label2,
*alignment1,
*alignment2,
*alignment3,
*hbox,
*editInformationButton,
*editGroupsButton;
GtkSizeGroup *sizeGroup;
gchar *fstr;
fstr = g_strdup_printf("%s", tr("The new user was successfully added."));
label1 = gtk_label_new(fstr);
g_free(fstr);
gtk_label_set_use_markup(GTK_LABEL(label1), TRUE);
gtk_label_set_line_wrap(GTK_LABEL(label1), TRUE);
gtk_misc_set_alignment(GTK_MISC(label1), 0.0f, 0.0f);
label2 = gtk_label_new(tr("Your User ID is: "));
gtk_misc_set_alignment(GTK_MISC(label2), 0.0f, 0.0f);
alignment1 = gtk_alignment_new(0.0f, 0.0f, 1.0f, 1.0f);
gtk_alignment_set_padding(GTK_ALIGNMENT(alignment1), 0, 0, 20, 0);
gtk_container_add(GTK_CONTAINER(alignment1), label2);
newIDLabel = gtk_label_new("");
gtk_label_set_use_markup(GTK_LABEL(newIDLabel), TRUE);
gtk_misc_set_alignment(GTK_MISC(newIDLabel), 0.0f, 0.0f);
hbox = gtk_hbox_new(FALSE, 2);
gtk_box_pack_start(GTK_BOX(hbox), alignment1, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), newIDLabel, FALSE, FALSE, 0);
// create the action buttons
sizeGroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
editInformationButton = u_createTextStockImageButton(tr("Edit personal information"), ICON_INFO);
g_signal_connect_swapped(editInformationButton, "clicked", G_CALLBACK(this->cb_editInfoButtonClicked), this);
gtk_size_group_add_widget(sizeGroup, editInformationButton);
alignment2 = gtk_alignment_new(0.5f, 0.0f, 0.0f, 0.0f);
gtk_alignment_set_padding(GTK_ALIGNMENT(alignment2), 20, 0, 0, 0);
gtk_container_add(GTK_CONTAINER(alignment2), editInformationButton);
editGroupsButton = u_createTextStockImageButton(tr("Create and Edit User Groups"), ICON_INFO);
g_signal_connect_swapped(editGroupsButton, "clicked", G_CALLBACK(this->cb_editGroupsButtonClicked), this);
gtk_size_group_add_widget(sizeGroup, editGroupsButton);
alignment3 = gtk_alignment_new(0.5f, 0.0f, 0.0f, 0.0f);
gtk_container_add(GTK_CONTAINER(alignment3), editGroupsButton);
vbox = gtk_vbox_new(FALSE, 5);
gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
gtk_box_pack_start(GTK_BOX(vbox), label1, FALSE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(vbox), alignment2, FALSE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(vbox), alignment3, FALSE, TRUE, 0);
return vbox;
}
GtkWidget* newOwnerWindow::createFailedPage()
{
GtkWidget *vbox,
*label,
*alignment;
gchar *fstr;
fstr = g_strdup_printf("%s", tr("The login has failed!"));
label = gtk_label_new(fstr);
g_free(fstr);
gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.0f);
failedLabel = gtk_label_new("");
gtk_label_set_use_markup(GTK_LABEL(failedLabel), TRUE);
gtk_label_set_line_wrap(GTK_LABEL(failedLabel), TRUE);
gtk_misc_set_alignment(GTK_MISC(failedLabel), 0.0f, 0.0f);
pwdErrorEntry = gtk_entry_new();
gtk_entry_set_invisible_char(GTK_ENTRY(pwdErrorEntry), '*');
gtk_entry_set_visibility(GTK_ENTRY(pwdErrorEntry), FALSE);
alignment = gtk_alignment_new(0.5f, 0.0f, 0.0f, 0.0f);
gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), 10, 0, 0, 0);
gtk_container_add(GTK_CONTAINER(alignment), pwdErrorEntry);
vbox = gtk_vbox_new(FALSE, 5);
gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(vbox), failedLabel, FALSE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(vbox), alignment, FALSE, TRUE, 0);
return vbox;
}
GtkWidget* newOwnerWindow::createButtonbar()
{
GtkWidget *hbox,
*hbox2;
forwardButton = gtk_button_new_from_stock(GTK_STOCK_GO_FORWARD);
g_signal_connect_swapped(forwardButton, "clicked", G_CALLBACK(this->cb_forwardButtonClicked), this);
backButton = gtk_button_new_from_stock(GTK_STOCK_GO_BACK);
gtk_widget_set_sensitive(backButton, FALSE);
g_signal_connect_swapped(backButton, "clicked", G_CALLBACK(this->cb_backButtonClicked), this);
cancelButton = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
g_signal_connect_swapped(cancelButton, "clicked", G_CALLBACK(this->cb_closeButtonClicked), this);
hbox2 = gtk_hbutton_box_new();
gtk_box_set_spacing(GTK_BOX(hbox2), 2);
gtk_button_box_set_layout(GTK_BUTTON_BOX(hbox2), GTK_BUTTONBOX_START);
gtk_box_pack_start(GTK_BOX(hbox2), backButton, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox2), forwardButton, FALSE, FALSE, 0);
waitAni = new processingAni();
waitAni->setupAnimation(i_getIcons()->images.searchingAni, 22, 22);
hbox = gtk_hbox_new(FALSE, 2);
gtk_box_pack_start(GTK_BOX(hbox), waitAni->widget, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), hbox2, TRUE, TRUE, 0);
gtk_box_pack_end(GTK_BOX(hbox), cancelButton, FALSE, FALSE, 0);
return hbox;
}
void newOwnerWindow::destroyWindowContent()
{
delete waitAni;
IO_getGeneralSource()->removeCallback((IMEventCallback)this->cb_eventCallback);
}
void newOwnerWindow::startProcessing()
{
gtk_widget_set_sensitive(notebook, FALSE);
gtk_widget_set_sensitive(forwardButton, FALSE);
gtk_widget_set_sensitive(backButton, FALSE);
gtk_button_set_label(GTK_BUTTON(cancelButton), GTK_STOCK_CANCEL);
gtk_button_set_use_stock(GTK_BUTTON(cancelButton), TRUE);
waitAni->play();
}
void newOwnerWindow::stopProcessing()
{
gtk_widget_set_sensitive(notebook, TRUE);
gtk_widget_set_sensitive(forwardButton, TRUE);
gtk_widget_set_sensitive(backButton, TRUE);
gtk_button_set_label(GTK_BUTTON(cancelButton), GTK_STOCK_CLOSE);
gtk_button_set_use_stock(GTK_BUTTON(cancelButton), TRUE);
waitAni->stop();
}
gboolean newOwnerWindow::cb_eventCallback(userEventType type, gint command, gint lastResult, gpointer info, newOwnerWindow* self)
{
gchar *newID;
// check whether something is processing. if not the request was cancelled
if (GTK_WIDGET_IS_SENSITIVE(self->notebook))
return TRUE;
switch(command)
{
case PC_VERIFY:
// update the verifying image and set the appropriate page
self->stopProcessing();
fprintf(stderr, "newOwnerWindow::cb_eventCallback(): displaying verifying image: %s\n", (gchar*)info);
gtk_image_set_from_file(GTK_IMAGE(self->verifyImage), (gchar*)info);
gtk_notebook_set_current_page(GTK_NOTEBOOK(self->notebook), 2);
self->currentPage = 2;
break;
case PC_NEWOWNER:
self->stopProcessing();
self->newOwner = (IMOwnerDaemon*)info;
newID = g_strdup_printf("%s", self->newOwner->info->licqID);
gtk_label_set_label(GTK_LABEL(self->newIDLabel), newID);
g_free(newID);
gtk_notebook_set_current_page(GTK_NOTEBOOK(self->notebook), 3);
self->currentPage = 3;
gtk_widget_set_sensitive(self->backButton, FALSE);
gtk_widget_set_sensitive(self->forwardButton, FALSE);
break;
case OC_LOGON_PASSWORD_ERROR:
self->stopProcessing();
gtk_label_set_label(GTK_LABEL(self->failedLabel), tr("You entered the wrong password for this user name or the user name itself doesn't exist.\n\nPlease correct your password below or go back and enter a new user name."));
gtk_widget_show(self->pwdErrorEntry);
self->currentPage = 4;
gtk_notebook_set_current_page(GTK_NOTEBOOK(self->notebook), 4);
break;
case OC_LOGON_RATE_ERROR:
self->stopProcessing();
gtk_label_set_label(GTK_LABEL(self->failedLabel), tr("The server is currently full and cannot logon more users.\n\nPlease try again later."));
gtk_widget_hide(self->pwdErrorEntry);
gtk_widget_set_sensitive(self->forwardButton, FALSE);
self->currentPage = 4;
gtk_notebook_set_current_page(GTK_NOTEBOOK(self->notebook), 4);
break;
}
return TRUE;
}
void newOwnerWindow::cb_forwardButtonClicked(newOwnerWindow* self)
{
gchar *pwd1,
*pwd2;
GtkTreeIter iter;
switch(self->currentPage)
{
case 0:
gtk_notebook_set_current_page(GTK_NOTEBOOK(self->notebook), 1);
gtk_widget_set_sensitive(self->backButton, TRUE);
//gtk_button_set_label(GTK_BUTTON(self->forwardButton), GTK_STOCK_OK);
gtk_button_set_use_stock(GTK_BUTTON(self->forwardButton), TRUE);
self->currentPage++;
self->cb_userActionButtonClicked(self);
break;
case 1:
pwd1 = (gchar*)gtk_entry_get_text(GTK_ENTRY(self->userPasswordEntry));
pwd2 = (gchar*)gtk_entry_get_text(GTK_ENTRY(self->pwdConfirmEntry));
if (!*pwd1 || strlen(pwd1)>8)
{
u_showAlertMessage("Wrong password", "Your password must contain between 1 and 8 characters. Please select another one.", GTK_STOCK_DIALOG_WARNING);
return;
}
if (strcmp(pwd1, pwd2))
{
u_showAlertMessage("Password mismatch", "The passwords don't match. Please type the same password you entered in the \"Password\" field in the \"Confirm\" field.", GTK_STOCK_DIALOG_WARNING);
return;
}
IO_getGeneralSource()->removeCallback((IMEventCallback)self->cb_eventCallback);
gtk_combo_box_get_active_iter(GTK_COMBO_BOX(self->protocolsList), &iter);
gtk_tree_model_get(gtk_combo_box_get_model(GTK_COMBO_BOX(self->protocolsList)), &iter, 1, &self->lastDaemon, -1);
IO_getGeneralSource()->addCallback((IMEventCallback)self->cb_eventCallback, self);
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(self->registerUserButton)))
self->lastDaemon->registerUser((gchar*)gtk_entry_get_text(GTK_ENTRY(self->userIDEntry)), pwd1);
else
self->lastDaemon->addExistingUser((gchar*)gtk_entry_get_text(GTK_ENTRY(self->userIDEntry)), pwd1);
self->startProcessing();
break;
case 2:
pwd1 = (gchar*)gtk_entry_get_text(GTK_ENTRY(self->verifyEntry));
IO_getGeneralSource()->removeCallback((IMEventCallback)self->cb_eventCallback);
gtk_combo_box_get_active_iter(GTK_COMBO_BOX(self->protocolsList), &iter);
gtk_tree_model_get(gtk_combo_box_get_model(GTK_COMBO_BOX(self->protocolsList)), &iter, 1, &self->lastDaemon, -1);
self->lastDaemon->verifyRegistration(pwd1);
self->startProcessing();
break;
case 4:
pwd1 = (gchar*)gtk_entry_get_text(GTK_ENTRY(self->pwdErrorEntry));
IO_getGeneralSource()->removeCallback((IMEventCallback)self->cb_eventCallback);
gtk_combo_box_get_active_iter(GTK_COMBO_BOX(self->protocolsList), &iter);
gtk_tree_model_get(gtk_combo_box_get_model(GTK_COMBO_BOX(self->protocolsList)), &iter, 1, &self->lastDaemon, -1);
IO_getGeneralSource()->addCallback((IMEventCallback)self->cb_eventCallback, self);
self->lastDaemon->addExistingUser((gchar*)gtk_entry_get_text(GTK_ENTRY(self->userIDEntry)), pwd1);
self->startProcessing();
break;
}
}
void newOwnerWindow::cb_backButtonClicked(newOwnerWindow* self)
{
switch(self->currentPage)
{
case 1:
gtk_notebook_set_current_page(GTK_NOTEBOOK(self->notebook), 0);
gtk_widget_set_sensitive(self->backButton, FALSE);
//gtk_button_set_label(GTK_BUTTON(self->forwardButton), GTK_STOCK_GO_FORWARD);
gtk_button_set_use_stock(GTK_BUTTON(self->forwardButton), TRUE);
self->currentPage = 0;
break;
case 4:
case 2:
gtk_notebook_set_current_page(GTK_NOTEBOOK(self->notebook), 1);
self->currentPage = 1;
gtk_widget_set_sensitive(self->forwardButton, TRUE);
self->cb_userActionButtonClicked(self);
break;
}
}
void newOwnerWindow::cb_userActionButtonClicked(newOwnerWindow* self)
{
GtkTreeIter iter;
IMPluginDaemon *daemon;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(self->registerUserButton)))
{
gtk_widget_set_sensitive(self->userIDEntry, FALSE);
if (gtk_combo_box_get_active_iter(GTK_COMBO_BOX(self->protocolsList), &iter))
{
gtk_tree_model_get(gtk_combo_box_get_model(GTK_COMBO_BOX(self->protocolsList)), &iter, 1, &daemon, -1);
if (daemon->pluginID != LICQ_PPID)
{
gtk_widget_show(self->regHintLabel);
gtk_widget_set_sensitive(self->forwardButton, FALSE);
return;
}
} else
{
gtk_widget_set_sensitive(self->forwardButton, FALSE);
return;
}
} else
gtk_widget_set_sensitive(self->userIDEntry, TRUE);
gtk_widget_hide(self->regHintLabel);
gtk_widget_set_sensitive(self->forwardButton, TRUE);
}
void newOwnerWindow::cb_closeButtonClicked(newOwnerWindow* self)
{
if (GTK_WIDGET_IS_SENSITIVE(self->notebook))
{
self->destroyWindow();
delete self;
}
else
{
self->stopProcessing();
if (self->currentPage == 2)
cb_backButtonClicked(self);
}
}
void newOwnerWindow::cb_editInfoButtonClicked(newOwnerWindow* self)
{
self->newOwner->startCallback(EC_FROMMANAGER, UE_USERINFO, NULL);
}
void newOwnerWindow::cb_editGroupsButtonClicked(newOwnerWindow* self)
{
self->newOwner->startCallback(EC_FROMMANAGER, UE_EDITGROUPS, NULL);
}