Commit ece66b8b authored by Paolo Bacchilega's avatar Paolo Bacchilega
Browse files

picasaweb: removed album creation

no longer supported by the google API
parent 2d618954
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.0 -->
<!-- Generated with glade 3.20.1 -->
<interface>
<requires lib="gtk+" version="3.0"/>
<object class="GtkListStore" id="account_liststore">
......@@ -301,38 +301,6 @@
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="vbox5">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkButton" id="add_album_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<child>
<object class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">list-add-symbolic</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
......
......@@ -295,92 +295,6 @@ update_album_list (DialogData *data)
}
static void
create_album_ready_cb (GObject *source_object,
GAsyncResult *result,
gpointer user_data)
{
DialogData *data = user_data;
PicasaWebService *picasaweb = PICASA_WEB_SERVICE (source_object);
PicasaWebAlbum *album;
GError *error = NULL;
album = picasa_web_service_create_album_finish (picasaweb, result, &error);
if (error != NULL) {
gth_task_dialog (GTH_TASK (data->service), TRUE, NULL);
_gtk_error_dialog_from_gerror_show (GTK_WINDOW (data->browser), _("Could not create the album"), error);
g_clear_error (&error);
return;
}
data->albums = g_list_append (data->albums, album);
update_album_list (data);
}
static void
new_album_dialog_response_cb (GtkDialog *dialog,
int response_id,
gpointer user_data)
{
DialogData *data = user_data;
switch (response_id) {
case GTK_RESPONSE_DELETE_EVENT:
case GTK_RESPONSE_CANCEL:
gtk_widget_destroy (GTK_WIDGET (dialog));
break;
case GTK_RESPONSE_OK:
{
PicasaWebAlbum *album;
album = picasa_web_album_new ();
picasa_web_album_set_title (album, picasa_album_properties_dialog_get_name (PICASA_ALBUM_PROPERTIES_DIALOG (dialog)));
album->access = picasa_album_properties_dialog_get_access (PICASA_ALBUM_PROPERTIES_DIALOG (dialog));
picasa_web_service_create_album (data->service,
album,
data->cancellable,
create_album_ready_cb,
data);
g_object_unref (album);
}
gtk_widget_destroy (GTK_WIDGET (dialog));
break;
default:
break;
}
}
static void
add_album_button_clicked_cb (GtkButton *button,
gpointer user_data)
{
DialogData *data = user_data;
GtkWidget *dialog;
dialog = picasa_album_properties_dialog_new (g_file_info_get_edit_name (data->location->info),
NULL,
PICASA_WEB_ACCESS_PUBLIC);
g_signal_connect (dialog,
"delete-event",
G_CALLBACK (gtk_true),
NULL);
g_signal_connect (dialog,
"response",
G_CALLBACK (new_album_dialog_response_cb),
data);
gtk_window_set_title (GTK_WINDOW (dialog), _("New Album"));
gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (data->dialog));
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
gtk_window_present (GTK_WINDOW (dialog));
}
static void
edit_accounts_button_clicked_cb (GtkButton *button,
gpointer user_data)
......@@ -655,10 +569,6 @@ dlg_export_to_picasaweb (GthBrowser *browser,
"response",
G_CALLBACK (export_dialog_response_cb),
data);
g_signal_connect (GET_WIDGET ("add_album_button"),
"clicked",
G_CALLBACK (add_album_button_clicked_cb),
data);
g_signal_connect (GET_WIDGET ("edit_accounts_button"),
"clicked",
G_CALLBACK (edit_accounts_button_clicked_cb),
......
......@@ -738,107 +738,6 @@ picasa_web_service_list_albums_finish (PicasaWebService *service,
}
/* -- picasa_web_service_create_album -- */
static void
create_album_ready_cb (SoupSession *session,
SoupMessage *msg,
gpointer user_data)
{
PicasaWebService *self = user_data;
GSimpleAsyncResult *result;
SoupBuffer *body;
DomDocument *doc;
GError *error = NULL;
result = _web_service_get_result (WEB_SERVICE (self));
if (msg->status_code != 201) {
g_simple_async_result_set_error (result,
SOUP_HTTP_ERROR,
msg->status_code,
"%s",
soup_status_get_phrase (msg->status_code));
g_simple_async_result_complete_in_idle (result);
return;
}
body = soup_message_body_flatten (msg->response_body);
doc = dom_document_new ();
if (dom_document_load (doc, body->data, body->length, &error)) {
PicasaWebAlbum *album;
album = picasa_web_album_new ();
dom_domizable_load_from_element (DOM_DOMIZABLE (album), DOM_ELEMENT (doc)->first_child);
g_simple_async_result_set_op_res_gpointer (result, album, (GDestroyNotify) g_object_unref);
}
else {
g_simple_async_result_set_from_error (result, error);
g_error_free (error);
}
g_simple_async_result_complete_in_idle (result);
g_object_unref (doc);
soup_buffer_free (body);
}
void
picasa_web_service_create_album (PicasaWebService *self,
PicasaWebAlbum *album,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
OAuthAccount *account;
DomDocument *doc;
DomElement *entry;
char *buffer;
gsize len;
char *url;
SoupMessage *msg;
account = web_service_get_current_account (WEB_SERVICE (self));
g_return_if_fail (account != NULL);
gth_task_progress (GTH_TASK (self), _("Creating the new album"), NULL, TRUE, 0.0);
doc = dom_document_new ();
entry = dom_domizable_create_element (DOM_DOMIZABLE (album), doc);
dom_element_append_child (DOM_ELEMENT (doc), entry);
buffer = dom_document_dump (doc, &len);
url = g_strconcat ("https://picasaweb.google.com/data/feed/api/user/", account->id, NULL);
msg = soup_message_new ("POST", url);
soup_message_set_request (msg, ATOM_ENTRY_MIME_TYPE, SOUP_MEMORY_TAKE, buffer, len);
_picasa_web_service_add_headers (self, msg);
_web_service_send_message (WEB_SERVICE (self),
msg,
cancellable,
callback,
user_data,
picasa_web_service_create_album,
create_album_ready_cb,
self);
g_free (url);
g_object_unref (doc);
}
PicasaWebAlbum *
picasa_web_service_create_album_finish (PicasaWebService *service,
GAsyncResult *result,
GError **error)
{
if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result), error))
return NULL;
else
return g_object_ref (g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (result)));
}
/* -- picasa_web_service_post_photos -- */
......
......@@ -62,14 +62,6 @@ void picasa_web_service_list_albums (PicasaWebService
GList * picasa_web_service_list_albums_finish (PicasaWebService *self,
GAsyncResult *result,
GError **error);
void picasa_web_service_create_album (PicasaWebService *self,
PicasaWebAlbum *album,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
PicasaWebAlbum * picasa_web_service_create_album_finish (PicasaWebService *self,
GAsyncResult *result,
GError **error);
void picasa_web_service_post_photos (PicasaWebService *self,
PicasaWebAlbum *album,
GList *file_list, /* GFile list */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment