summaryrefslogtreecommitdiffstats
path: root/webservice.c
diff options
context:
space:
mode:
Diffstat (limited to 'webservice.c')
-rw-r--r--webservice.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/webservice.c b/webservice.c
index 6dbe32a38..f4f8baeb4 100644
--- a/webservice.c
+++ b/webservice.c
@@ -338,7 +338,7 @@ static gboolean divelogde_dialog(const char **user, const char **pass)
gtk_container_add(GTK_CONTAINER(frame_user), uid);
gtk_entry_set_max_length(GTK_ENTRY(uid), 40);
gtk_entry_set_text(GTK_ENTRY(uid), *user ?: "");
-
+ gtk_entry_set_activates_default(GTK_ENTRY(uid), TRUE);
frame_pass = gtk_frame_new(_("Password"));
gtk_box_pack_start(GTK_BOX(vbox), frame_pass, FALSE, TRUE, 6);
@@ -346,6 +346,9 @@ static gboolean divelogde_dialog(const char **user, const char **pass)
gtk_container_add(GTK_CONTAINER(frame_pass), pwd);
gtk_entry_set_max_length(GTK_ENTRY(pwd), 40);
gtk_entry_set_text(GTK_ENTRY(pwd), *pass ?: "");
+ gtk_entry_set_visibility(GTK_ENTRY(pwd), FALSE);
+ gtk_entry_set_activates_default(GTK_ENTRY(pwd), TRUE);
+ gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT);
gtk_widget_show_all(dialog);
if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
@@ -361,14 +364,21 @@ static gboolean divelogde_dialog(const char **user, const char **pass)
return ret;
}
-int divelogde_upload(char *fn)
+int divelogde_upload(char *fn, char **error)
{
SoupMessage *msg;
SoupMultipart *multipart;
SoupSession *session;
SoupBuffer *sbuf;
gboolean ret = FALSE;
+#ifdef __MINGW32__
+ /* for odd reasons I can't seem to get https connections to work
+ * with mingw32 when cross-building the Windows binaries... so fall
+ * back to http for now */
char url[256] = "http://divelogs.de/DivelogsDirectImport.php";
+#else
+ char url[256] = "https://divelogs.de/DivelogsDirectImport.php";
+#endif
const char *pass = NULL;
const char *user = NULL;
struct memblock mem;
@@ -376,7 +386,7 @@ int divelogde_upload(char *fn)
if (readfile(fn, &mem) < 0)
return ret;
if (!divelogde_dialog(&user, &pass))
- return ret;
+ return TRUE;
sbuf = soup_buffer_new(SOUP_MEMORY_STATIC, mem.buffer, mem.size);
session = soup_session_async_new();
multipart = soup_multipart_new(SOUP_FORM_MIME_TYPE_MULTIPART);
@@ -388,11 +398,10 @@ int divelogde_upload(char *fn)
soup_message_headers_append(msg->request_headers, "Accept", "text/xml");
soup_session_send_message(session, msg);
if (SOUP_STATUS_IS_SUCCESSFUL(msg->status_code)) {
- /* we should really check if the XML returned indicates that
- * the profiles were successfully uploaded...
- */
- fprintf(stderr, "%s\n", (gchar *)msg->response_body->data);
+ *error = strdup(msg->response_body->data);
ret = TRUE;
+ } else {
+ *error = strdup(msg->reason_phrase);
}
soup_session_abort(session);
g_object_unref(G_OBJECT(msg));