After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 655815 - Need API to pass a TpSimpleClientFactory or TpAccountManager
Need API to pass a TpSimpleClientFactory or TpAccountManager
Status: RESOLVED OBSOLETE
Product: folks
Classification: Platform
Component: Telepathy backend
git master
Other Linux
: Normal enhancement
: Unset
Assigned To: folks-maint
folks-maint
Depends on:
Blocks: 655799
 
 
Reported: 2011-08-02 14:05 UTC by Guillaume Desmottes
Modified: 2011-11-29 15:11 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Guillaume Desmottes 2011-08-02 14:05:47 UTC
tp-glib recently introduced TpSimpleClientFactory a new kind of factories more powerful than TpClientChannelFactory which can be used to share TpProxy subclasses (TpAccount, TpConnection, TpChannel, etc) and TpContact objects.

I started porting Empathy to this new exciting technology (bug #655799) and noticed that TpContact objects are no longer shared between Empathy and Folks. That's because they don't share the same TpAccountManager any more: Empathy uses an AM having a EmpathyClientFactory as factory.

We need a way to pass either a TpSimpleClientFactory or TpAccountManager to folks so all these objects will be nicely shared.
Comment 1 Xavier Claessens 2011-08-02 15:42:01 UTC
Or the other way around: let Empathy define what tp_account_manager_dup() will return: http://cgit.collabora.com/git/user/xclaesse/telepathy-glib.git/log/?h=default-am
Comment 2 Guillaume Desmottes 2011-08-03 08:15:09 UTC
That does fix the TpContact creation/destruction issue.

But isn't this API a bit weird? User has to:
- Instantiate his factory
- Get an AM from it (tp_simple_client_factory_ensure_account_manager()).
- Call tp_account_manager_set_default() with this AM.

Just doing tp_account_manager_set_default_factory (factory); would be easier I think.

Actually isn't it weird to have tp_simple_client_factory_ensure_account_manager()? If we consider the AM as the "root" object of all the other objects (which is the case as we pass it to the TpSimple* constructors), why should we get it from the factory instead of passing the factory when creating the AM?
Comment 3 Xavier Claessens 2011-08-03 10:15:09 UTC
I admit this isn't really nice... What about this kind of API for apps wanting a custom factory:

main()
{
  TpSimpleClientFactory *factory = my_factory_new();
  TpAccountManager *manager;

  tp_account_manager_set_default_factory(factory);
  manager = tp_account_manager_dup();
  ...
  tp_account_manager_prepare_async(manager, ...);
}

so we can actually still use tp_account_manager_dup() like previously in the app (you can remove most of the empathy patch :/)

and tp_account_manager_dup() would do something like
{
  static TpAccountManager *manager = NULL;

  if (manager != NULL)
    return g_object_ref (manager);

  if (the_default_factory != NULL)
    manager = tp_simple_client_factory_ensure_account_manager (the_default_factory);
  else
    manager = tp_account_manager_new();

  return manager;
}


Does this looks nice to you?
Comment 4 Travis Reitter 2011-08-23 16:39:02 UTC
(In reply to comment #3)
> I admit this isn't really nice... What about this kind of API for apps wanting
> a custom factory:
> 
> main()
> {
>   TpSimpleClientFactory *factory = my_factory_new();
>   TpAccountManager *manager;
> 
>   tp_account_manager_set_default_factory(factory);
>   manager = tp_account_manager_dup();
>   ...
>   tp_account_manager_prepare_async(manager, ...);
> }
> 
> so we can actually still use tp_account_manager_dup() like previously in the
> app (you can remove most of the empathy patch :/)
> 
> and tp_account_manager_dup() would do something like
> {
>   static TpAccountManager *manager = NULL;
> 
>   if (manager != NULL)
>     return g_object_ref (manager);
> 
>   if (the_default_factory != NULL)
>     manager = tp_simple_client_factory_ensure_account_manager
> (the_default_factory);
>   else
>     manager = tp_account_manager_new();
> 
>   return manager;
> }
> 
> 
> Does this looks nice to you?

This looks best to me. If the client cares about making its own factory, it can just set things up before preparing the FolksIndividualAggregator.

Xavier, has the latter code already been merged to tp-glib? It seems that way in master (though it doesn't do the ensure() step).

If tp-glib still needs changes, please add a tp-glib bug (and CC me) and list it in a new comment on this bug. Otherwise, please close this bug as NOTABUG.
Comment 5 Xavier Claessens 2011-08-23 20:52:22 UTC
everything is already in tp-glib 0.15.5 and used in empathy 3.1.5.1. Final API is sligthly different to what presented here:

factory = empathy_client_factory_new()
manager = tp_account_manager_new_with_factory(factory);
tp_account_manager_set_default(manager);

then tp_account_manager_dup() will give the one with empathy's factory. This is already done in empathy's main.
Comment 6 Guillaume Desmottes 2011-11-29 15:11:59 UTC
Closing this bug as it's not needed any more. As long as Folks use the default account manager we're good.