Commit 1e13a3d2 authored by Lucas Beeler's avatar Lucas Beeler

The Facebook Connector, previously ported to the new publishing API, has now...

The Facebook Connector, previously ported to the new publishing API, has now been packaged in a separate .so file as a dynamically loadable plug-in. This is the result of both code and build system changes.
parent 044eb899
......@@ -20,7 +20,7 @@ all: $(PLUGIN).so
$(PLUGIN).so: $(SRC_FILES) $(MAKE_FILES)
$(VALAC) --save-temps --main=dummy_main --vapidir=../ \
$(foreach pkg,$(PKGS),--pkg=$(pkg)) \
-X -I../.. -X --shared -X -fPIC -X -D_VERSION='"$(PLUGINS_VERSION)"' $(SRC_FILES) -o $@
-X -I../.. -X --shared -X -fPIC -X -D_VERSION='"$(PLUGINS_VERSION)"' -X -DGETTEXT_PACKAGE='"shotwell"' $(SRC_FILES) -o $@
.PHONY: cleantemps
cleantemps:
......
PLUGINS := \
spitter \
shotwell-transitions
shotwell-transitions \
shotwell-publishing
......@@ -4,6 +4,28 @@
* (version 2.1 or later). See the COPYING file in this distribution.
*/
extern Soup.Message soup_form_request_new_from_multipart(string uri, Soup.Multipart multipart);
extern void qsort(void *p, size_t num, size_t size, GLib.CompareFunc func);
public class FacebookService : Object, Spit.Pluggable, Spit.Publishing.PublishingService {
public int get_pluggable_interface(int min_host_interface, int max_host_interface) {
return Spit.negotiate_interfaces(min_host_interface, max_host_interface,
Spit.Publishing.CURRENT_API_VERSION);
}
public string get_service_id() {
return "org.yorba.shotwell.publishing.core_services.facebook";
}
public string get_service_name() {
return "Facebook";
}
public Spit.Publishing.Publisher create_publisher() {
return new Publishing.Facebook.FacebookPublisher();
}
}
namespace Publishing.Facebook {
// global parameters for the Facebook publishing plugin -- don't touch these (unless you really,
// truly, deep-down know what you're doing)
......@@ -1291,6 +1313,8 @@ internal class PublishingOptionsPane : Spit.Publishing.PublishingDialogPane, GLi
public void on_pane_installed() {
wrapped.logout.connect(notify_logout);
wrapped.publish.connect(notify_publish);
wrapped.installed();
}
public void on_pane_uninstalled() {
......@@ -1299,7 +1323,7 @@ internal class PublishingOptionsPane : Spit.Publishing.PublishingDialogPane, GLi
}
}
internal class LegacyPublishingOptionsPane : global::PublishingDialogPane {
internal class LegacyPublishingOptionsPane : Gtk.VBox {
private struct PrivacyDescription {
private string description;
private string privacy_setting;
......@@ -1313,7 +1337,8 @@ internal class LegacyPublishingOptionsPane : global::PublishingDialogPane {
private const string HEADER_LABEL_TEXT = _("You are logged into Facebook as %s.\n\n");
private const string PHOTOS_LABEL_TEXT = _("Where would you like to publish the selected photos?");
private const int CONTENT_GROUP_SPACING = 32;
private const int STANDARD_ACTION_BUTTON_WIDTH = 128;
private Gtk.RadioButton use_existing_radio = null;
private Gtk.RadioButton create_new_radio = null;
private Gtk.ComboBox existing_albums_combo = null;
......@@ -1415,8 +1440,8 @@ internal class LegacyPublishingOptionsPane : global::PublishingDialogPane {
buttons_layouter.add(buttons_central_padding);
buttons_layouter.add(publish_button_aligner);
buttons_layouter.add(buttons_right_padding);
publish_button.set_size_request(PublishingDialog.STANDARD_ACTION_BUTTON_WIDTH, -1);
logout_button.set_size_request(PublishingDialog.STANDARD_ACTION_BUTTON_WIDTH, -1);
publish_button.set_size_request(STANDARD_ACTION_BUTTON_WIDTH, -1);
logout_button.set_size_request(STANDARD_ACTION_BUTTON_WIDTH, -1);
album_mode_layouter.add(use_existing_layouter);
album_mode_layouter.add(create_new_layouter);
......@@ -1495,7 +1520,7 @@ internal class LegacyPublishingOptionsPane : global::PublishingDialogPane {
return result;
}
public override void installed() {
public void installed() {
if (albums.length == 0) {
create_new_radio.set_active(true);
new_album_entry.set_text(DEFAULT_ALBUM_NAME);
......
PLUGIN := shotwell-publishing
PKGS := shotwell-publishing-1.0 \
gtk+-2.0 \
libsoup-2.4 \
libxml-2.0 \
webkit-1.0 \
shotwell-spit-1.0
SRC_FILES := \
shotwell-publishing.vala \
FacebookPublishing.vala
include ../Makefile.plugin.mk
/* Copyright 2011 Yorba Foundation
*
* This software is licensed under the GNU Lesser General Public License
* (version 2.1 or later). See the COPYING file in this distribution.
*/
extern const string _VERSION;
// "core services" are: Facebook, Flickr, Picasa Web Albums, and YouTube
private class ShotwellPublishingCoreServices : Object, Spit.Wad {
private Spit.Pluggable[] pluggables = new Spit.Pluggable[0];
public ShotwellPublishingCoreServices() {
pluggables += new FacebookService();
}
~ShotwellPublishingCoreServices() {
}
public string get_name() {
return "Core Publishing Services";
}
public string get_version() {
return _VERSION;
}
public string get_wad_name() {
return "org.yorba.shotwell.publishing.core_services";
}
public Spit.Pluggable[]? get_pluggables() {
return pluggables;
}
}
private ShotwellPublishingCoreServices? core_services = null;
private Spit.EntryPoint? compiler_entry_point = null;
// This entry point is required for all SPIT modules.
public unowned Spit.Wad? spit_entry_point(int host_min_spit_interface, int host_max_spit_interface,
out int module_spit_interface) {
// this is purely for compilation, to verify that the entry point matches SpitEntryPoint's sig;
// it does nothing functionally
compiler_entry_point = spit_entry_point;
module_spit_interface = Spit.negotiate_interfaces(host_min_spit_interface, host_max_spit_interface,
Spit.CURRENT_INTERFACE);
if (module_spit_interface == Spit.UNSUPPORTED_INTERFACE)
return null;
if (core_services == null)
core_services = new ShotwellPublishingCoreServices();
return core_services;
}
public void g_module_unload() {
if (core_services != null)
debug("%s %s unloaded", core_services.get_name(), core_services.get_version());
else
debug("core_services unloaded prior to spit_entry_point being called");
core_services = null;
}
// valac wants a default entry point, so valac gets a default entry point
private void dummy_main() {
}
......@@ -8,7 +8,7 @@ namespace FacebookConnector {
public class Capabilities : ServiceCapabilities {
public override string get_name() {
return Publishing.Facebook.SERVICE_NAME;
return "Facebook";
}
public override Spit.Publishing.Publisher.MediaType get_supported_media() {
......
......@@ -6,6 +6,8 @@
namespace Spit.Publishing {
public const int CURRENT_API_VERSION = 0;
public errordomain PublishingError {
NO_ANSWER,
COMMUNICATION_FAILED,
......@@ -129,4 +131,13 @@ public interface Publishable : GLib.Object {
public abstract Spit.Publishing.Publisher.MediaType get_media_type();
}
public interface PublishingService : Object, Spit.Pluggable {
public abstract string get_service_id();
public abstract string get_service_name();
public abstract Spit.Publishing.Publisher create_publisher();
}
}
PLUGIN_VAPIS := \
plugins/shotwell-spit-1.0.vapi \
plugins/shotwell-transitions-1.0.vapi
plugins/shotwell-transitions-1.0.vapi \
plugins/shotwell-publishing-1.0.vapi
PLUGIN_HEADERS := $(PLUGIN_VAPIS:.vapi=.h)
PLUGIN_DEPS := $(PLUGIN_VAPIS:.vapi=.deps)
......@@ -23,3 +24,11 @@ plugins/shotwell-transitions-1.0.vapi: src/plugins/TransitionsInterfaces.vala pl
$(call check_valac_version)
$(VALAC) -c $(VALAFLAGS) -X -I. --pkg=gdk-2.0 --pkg=shotwell-spit-1.0 --includedir=plugins --vapi=$@ --header=$(basename $@).h $<
rm $(notdir $<).o
plugins/shotwell-publishing-1.0.deps: plugins/shotwell-publishing-1.0.vapi
@printf "gtk+-2.0\nshotwell-spit-1.0" > $@
plugins/shotwell-publishing-1.0.vapi: src/plugins/PublishingInterfaces.vala plugins/shotwell-spit-1.0.vapi
$(call check_valac_version)
$(VALAC) -c $(VALAFLAGS) -X -I. -X -DGETTEXT_PACKAGE='"shotwell"' --pkg=gtk+-2.0 --pkg=shotwell-spit-1.0 --includedir=plugins --vapi=$@ --header=$(basename $@).h $<
......@@ -330,8 +330,26 @@ public class GlueFactory {
((DialogInteractorWrapper) active_dialog).set_plugin_host(publishing_host);
Spit.Publishing.Publisher real_publisher =
new global::Publishing.Facebook.FacebookPublisher();
// load publishing services from plug-ins
Gee.Collection<Spit.Pluggable> pluggables = Plugins.get_pluggables_for_type(
typeof(Spit.Publishing.PublishingService));
debug("Publising API Glue: discovered %d pluggable publishing services.", pluggables.size);
Spit.Publishing.PublishingService? facebook_service = null;
foreach (Spit.Pluggable pluggable in pluggables) {
Spit.Publishing.PublishingService service =
(Spit.Publishing.PublishingService) pluggable;
debug("Publishing API Glue: discovered pluggable publishing service '%s'.",
service.get_service_name());
if (service.get_service_id() == "org.yorba.shotwell.publishing.core_services.facebook")
facebook_service = service;
}
if (facebook_service == null)
error("Publishing API Glue: required service 'Facebook' wasn't found.'");
Spit.Publishing.Publisher real_publisher = facebook_service.create_publisher();
ServiceInteractor publisher_wrapper = new PublisherWrapperInteractor(real_publisher,
publishing_host, active_dialog);
......
......@@ -12,7 +12,6 @@ UNIT_DIR := publishing
# NOTE: Do *not* include the unit's master file, i.e. UNIT_NAME.vala.
UNIT_FILES := \
PublishingPluginHost.vala \
FacebookPublishing.vala \
APIGlue.vala
# Any unit this unit relies upon (and should be initialized before it's initialized) should
......
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