Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
jami-client-gnome
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
savoirfairelinux
jami-client-gnome
Commits
5455e546
Commit
5455e546
authored
6 years ago
by
Sébastien Blin
Browse files
Options
Downloads
Patches
Plain Diff
registration: add dialogs when an error occurs
Change-Id: I9d5e2177407196dd1d40ed861cbbafb04028a950
parent
84c17e88
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/usernameregistrationbox.cpp
+54
-20
54 additions, 20 deletions
src/usernameregistrationbox.cpp
with
54 additions
and
20 deletions
src/usernameregistrationbox.cpp
+
54
−
20
View file @
5455e546
...
...
@@ -305,6 +305,18 @@ button_register_username_clicked(G_GNUC_UNUSED GtkButton* button, UsernameRegist
return
;
}
auto
show_password
=
true
;
if
(
*
priv
->
accountInfo_
)
{
std
::
string
accountId
=
(
*
priv
->
accountInfo_
)
->
id
;
lrc
::
api
::
account
::
ConfProperties_t
props
;
props
=
(
*
priv
->
accountInfo_
)
->
accountModel
->
getAccountConfig
(
accountId
);
show_password
=
props
.
archiveHasPassword
;
}
std
::
string
password
;
gint
result
=
GTK_RESPONSE_OK
;
if
(
show_password
)
{
GtkWidget
*
password_dialog
=
gtk_message_dialog_new
(
GTK_WINDOW
(
gtk_widget_get_toplevel
(
GTK_WIDGET
(
view
))),
(
GtkDialogFlags
)(
GTK_DIALOG_MODAL
|
GTK_DIALOG_DESTROY_WITH_PARENT
),
...
...
@@ -318,9 +330,10 @@ button_register_username_clicked(G_GNUC_UNUSED GtkButton* button, UsernameRegist
gtk_box_pack_end
(
GTK_BOX
(
gtk_dialog_get_content_area
(
GTK_DIALOG
(
password_dialog
))),
entry_password
,
FALSE
,
FALSE
,
0
);
gtk_widget_show
(
entry_password
);
gint
result
=
gtk_dialog_run
(
GTK_DIALOG
(
password_dialog
));
const
std
::
string
password
=
gtk_entry_get_text
(
GTK_ENTRY
(
entry_password
));
result
=
gtk_dialog_run
(
GTK_DIALOG
(
password_dialog
));
password
=
gtk_entry_get_text
(
GTK_ENTRY
(
entry_password
));
gtk_widget_destroy
(
password_dialog
);
}
switch
(
result
)
{
...
...
@@ -352,6 +365,19 @@ button_register_username_clicked(G_GNUC_UNUSED GtkButton* button, UsernameRegist
}
}
static
void
username_registration_dialog_error
(
const
char
*
msg
)
{
g_warning
(
"%s"
,
msg
);
GtkWidget
*
dialog
=
gtk_message_dialog_new
(
NULL
,
(
GtkDialogFlags
)(
GTK_DIALOG_MODAL
),
GTK_MESSAGE_ERROR
,
GTK_BUTTONS_CLOSE
,
"%s"
,
msg
);
gtk_window_set_title
(
GTK_WINDOW
(
dialog
),
_
(
"Name registration Error"
));
gtk_dialog_run
(
GTK_DIALOG
(
dialog
));
gtk_widget_destroy
(
dialog
);
}
static
void
build_view
(
UsernameRegistrationBox
*
view
,
gboolean
register_button
)
{
...
...
@@ -404,15 +430,23 @@ build_view(UsernameRegistrationBox *view, gboolean register_button)
break
;
}
case
lrc
::
api
::
account
::
RegisterNameStatus
::
INVALID_NAME
:
gtk_widget_set_sensitive
(
priv
->
button_register_username
,
TRUE
);
username_registration_dialog_error
(
_
(
"Unable to register name (Invalid name). Your username should contains between 3 and 32 alphanumerics characters (or underscore)."
));
break
;
case
lrc
::
api
::
account
::
RegisterNameStatus
::
WRONG_PASSWORD
:
gtk_widget_set_sensitive
(
priv
->
button_register_username
,
TRUE
);
username_registration_dialog_error
(
_
(
"Unable to register name (Wrong password)."
));
break
;
case
lrc
::
api
::
account
::
RegisterNameStatus
::
ALREADY_TAKEN
:
gtk_widget_set_sensitive
(
priv
->
button_register_username
,
TRUE
);
username_registration_dialog_error
(
_
(
"Unable to register name (Username already taken)."
));
break
;
case
lrc
::
api
::
account
::
RegisterNameStatus
::
NETWORK_ERROR
:
{
gtk_widget_set_sensitive
(
priv
->
button_register_username
,
TRUE
);
username_registration_dialog_error
(
_
(
"Unable to register name (Network error) - check your connection."
));
break
;
}
}
}
);
}
gtk_widget_show
(
priv
->
frame_username
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment