Bug 37360

Summary: TpChannel: high level API for Password
Product: Telepathy Reporter: Guillaume Desmottes <guillaume.desmottes>
Component: tp-glibAssignee: Guillaume Desmottes <guillaume.desmottes>
Status: RESOLVED FIXED QA Contact: Telepathy bugs list <telepathy-bugs>
Severity: enhancement    
Priority: medium Keywords: patch
Version: unspecified   
Hardware: Other   
OS: All   
URL: http://cgit.collabora.com/git/user/cassidy/telepathy-glib/log/?h=channel-password-37360
Whiteboard: EmpathyTpChat, r+
i915 platform: i915 features:
Attachments: textchan-group: implement Password
TpChannel: add high-level API for Password (#37360)
automatic-proxy-factory: prepare TP_CHANNEL_FEATURE_PASSWORD

Comment 1 Guillaume Desmottes 2011-05-25 02:03:30 UTC
How do you feel about this API?

/* Channel.Interface.Password */
#define TP_CHANNEL_FEATURE_PASSWORD \
  tp_channel_get_feature_quark_password ()
GQuark tp_channel_get_feature_quark_password (void) G_GNUC_CONST;

void tp_channel_password_provide_password_async (TpChannel *self,
    const gchar *password,
    GAsyncReadyCallback callback,
    gpointer user_data);

gboolean tp_channel_password_provide_password_finish (TpChannel *self,
    GAsyncResult *result,
    GError **error);

gboolean tp_channel_password_needed (TpChannel *self);

/**
 * TpChannel:password-needed:
 *
 * If %TRUE, tp_channel_password_provide_password_async() has to be called
 * to be able to join the channel.
 *
 * This is not guaranteed to be meaningful until tp_proxy_prepare_async() has
 * finished preparing %TP_CHANNEL_FEATURE_PASSWORD; until then, it may return
 * %FALSE even if the channel is actually protected by a password.
 */


Maybe the provide async call should fail with TP_ERROR_AUTHENTICATION_FAILED if the password is not correct?
Comment 2 Guillaume Desmottes 2011-05-25 02:10:08 UTC
(In reply to comment #1)
> gboolean tp_channel_password_provide_password_finish (TpChannel *self,
>     GAsyncResult *result,
>     GError **error);


I meant:


gboolean
tp_channel_password_provide_password_finish (TpChannel *self,
    GAsyncResult *result,
    gboolean *correct,
    GError **error)

except, of course, if we decide to fail if the pass was wrong.
Comment 3 Simon McVittie 2011-05-25 02:21:55 UTC
(In reply to comment #1)
> /**
>  * TpChannel:password-needed:
>  *
>  * If %TRUE, tp_channel_password_provide_password_async() has to be called
>  * to be able to join the channel.
>  *
>  * This is not guaranteed to be meaningful until tp_proxy_prepare_async() has
>  * finished preparing %TP_CHANNEL_FEATURE_PASSWORD; until then, it may return
>  * %FALSE even if the channel is actually protected by a password.
>  */

For completeness, presumably this emits notify::password-needed when appropriate? (If so, it's worth mentioning that in the docstring.)

> Maybe the provide async call should fail with TP_ERROR_AUTHENTICATION_FAILED if
> the password is not correct?

I like this better than the "out" boolean. I'm not sure why we didn't do this in the D-Bus API...

(Looking at the D-Bus API again, I'm also not sure why ProvidePassword claims to be able to raise InvalidArgument.)
Comment 4 Guillaume Desmottes 2011-05-25 05:08:38 UTC
Created attachment 47137 [details] [review]
textchan-group: implement Password
Comment 5 Guillaume Desmottes 2011-05-25 05:08:41 UTC
Created attachment 47138 [details] [review]
TpChannel: add high-level API for Password (#37360)
Comment 6 Guillaume Desmottes 2011-05-25 05:08:45 UTC
Created attachment 47139 [details] [review]
automatic-proxy-factory: prepare TP_CHANNEL_FEATURE_PASSWORD
Comment 7 Simon McVittie 2011-05-30 07:32:56 UTC
Looks good to me.
Comment 8 Guillaume Desmottes 2011-05-31 01:47:51 UTC
Merged to master; will be in 0.15.2

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.