oaf async activation



hi all, 


I am currently working on bugzilla.eazel.com #2131
(http://bugzilla.eazel.com/show_bug.cgi?id=2131)

Basically, the fact that activation is synchronous makes the UI
completely dead pretty often which is a major pb. I am pretty sure 
Evolution people might feel concerned about this so, here is my 
proposal to add a few methods to OAF IDL and some new API.

Flames wellcome. If no one raises his hand to bitch about how
bad this design is, I will begin working to add this functionality 
to OAF winthin 2 days...

Of course, I will update the documentation...


Mathieu

---------------------------------------------------------------------------
                                IDL
---------------------------------------------------------------------------
#include "oaf-factory.idl"

module OAF {
        exception GeneralError {
                string description;
        };

        typedef string ImplementationID;
        typedef string ActivationID;
        interface ActivationContext;

        typedef long ActivationFlags;
        const ActivationFlags FLAG_NO_LOCAL = 1<<0; // No shared libraries
        const ActivationFlags FLAG_PRIVATE = 1<<1; // start a new server and don't register it
        const ActivationFlags FLAG_EXISTING_ONLY = 1<<2; // don't start the server if not started

        /* ActivationResult */
        enum ActivationResultType {
                RESULT_OBJECT,
                RESULT_SHLIB,
                RESULT_NONE
        };

        union ActivationResultData switch (ActivationResultType) {
        case RESULT_OBJECT:
                Object res_object;
        case RESULT_SHLIB:
                GNOME::stringlist res_shlib;
        };

        struct ActivationResult {
                string aid;
                ActivationResultData res;
        };

        /* Property */
        enum PropertyType {
                       P_STRING,
                       P_NUMBER,
                       P_BOOLEAN,
                       P_STRINGV
               };

               union PropertyValue switch (PropertyType) {
               case P_STRING:
                       string value_string;
               case P_NUMBER:
                       double value_number;
               case P_BOOLEAN:
                       boolean value_boolean;
               case P_STRINGV:
                       GNOME::stringlist value_stringv;
               };

               struct Property {
                       string name;
                       PropertyValue v;
               };

        /* Server */
        struct ServerInfo {
                ImplementationID iid;

                string server_type;
                string location_info;
                string username, hostname, domain;

                sequence<Property> props;
        };

        typedef sequence<ServerInfo> ServerInfoList;

        typedef long long CacheTime;

        union ServerInfoListCache switch (boolean) {
        case TRUE:
                ServerInfoList server_list;
        };

        union ServerStateCache switch (boolean) {
        case TRUE:
                sequence<ImplementationID> active_servers;
        };

        enum RegistrationResult {
                REG_SUCCESS,
                REG_NOT_LISTED,
                REG_ALREADY_ACTIVE,
                REG_ERROR
        };

        interface ActivationCallback {
                oneway void report_activation_failed (in string reason);
                oneway void report_activation_comlete (in ActivationResult result);
        };

        /* Interfaces */
        interface ObjectDirectory {
                enum UnregisterType {
                        UNREGISTER_NORMAL,
                        UNREGISTER_NOTIFY_UNUSED /* For factories to use */
                };
                ServerInfoListCache get_servers (in CacheTime only_if_newer);
                ServerStateCache get_active_servers (in CacheTime only_if_newer);

                readonly attribute string username, hostname, domain;

                Object activate (in ImplementationID iid, in ActivationContext ac, in ActivationFlags flags)
                        context ("username", "hostname", "domain", "display");

                /* Ensures consistency for activations of publicly advertised objects */
                void lock();
                oneway void unlock();

                RegistrationResult register_new (in ImplementationID iid, in Object obj);
                void unregister (in ImplementationID iid, in Object obj, in UnregisterType notify);
        };

        typedef sequence<ObjectDirectory> ObjectDirectoryList;

        interface ActivationContext {
                exception NotListed {};
                exception AlreadyListed {};
                exception IncompleteContext {};
                exception ParseFailed {
                        string description;
                };

                readonly attribute ObjectDirectoryList directories;
                void add_directory (in ObjectDirectory dir) raises (AlreadyListed);
                void remove_directory (in ObjectDirectory dir) raises (NotListed);

                ActivationResult activate (in string requirements,
                                           in GNOME::stringlist selection_order,
                                           in ActivationFlags flags)
                        raises (ParseFailed, IncompleteContext, GeneralError)
                        context ("username", "hostname", "domain", "display");

                oneway void activate_async (in string requirements,
                                            in GNOME::stringlist selection_order,
                                            in ActivationFlags flags,
                                            in ActivationCallback callback_object)
                        context ("username", "hostname", "domain", "display");



                readonly attribute ServerInfoList servers;
                ServerInfoList query (in string requirements,
                                      in GNOME::stringlist selection_order)
                        raises (ParseFailed, IncompleteContext)
                        context ("username", "hostname", "domain");

                ActivationResult activate_from_id (in ActivationID aid, in ActivationFlags flags)
                        raises (ParseFailed, IncompleteContext, GeneralError)
                        context ("username", "hostname", "domain", "display");

                oneway void activate_from_id_async (in ActivationID aid,
                                                    in ActivationFlags flags,
                                                    in ActivationCallback callback_object)
                        context ("username", "hostname", "domain", "display");

        };
};





---------------------------------------------------------------------------
                                C Header
---------------------------------------------------------------------------
#include <liboaf/liboaf-version.h>
#include <liboaf/oaf.h>


typedef void (*OAFCallback) (CORBA_Object activated_object, const char *error_reason, gpointer user_data);


/* 'callback' is called whenever the activation finished.
   Either it succeeded or failed in which case it receives a
   CORBA_OBJECT_NIL */

void oaf_activate_async (const char *requirements,
                         char *const *selection_order,
                         OAF_ActivationFlags flags,
                         OAFCallback callback,
                         gpointer user_data,
                         CORBA_Environment * ev);

void oaf_activate_from_id_async (const OAF_ActivationID aid,
                                 OAF_ActivationFlags flags,
                                 OAFCallback callback,
                                 gpointer user_data,
                                 CORBA_Environment * ev);



-- 
Mathieu Lacage <mathieu eazel com>





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]