master password gsoc project
Vivien Bernet-Rollande
vivien.bernet-rollande at etu.utc.fr
Tue Jun 3 03:58:18 EDT 2008
Hi.
Ok, so, there comes the API. Mainly comments, a couple typedefs, and the
prototype for the register function. I _think_ this should be all that
is needed, apart maybe for an "advanced" configuration tab or something.
That, however, would be interface dependent, so I'm not really sure it
should be put here.
Also, it's written in C code so I could just ask gcc to check for syntax
errors, but it's not the final header.
So, let's paste code now :)
<----------------------------------------------------------------------------------------->
/* libpurple password storage API (v 0.1)*/
/*
** This is a proposition for the new password storage API in pidgin.
** It's pretty much the result of past discussion on the devel list and on
** IRC. It's not the real C code yet (the compiler might kick you out if you
** try to compile it right now), and I'll write a nice and fancy header
** once I've figured out how doxygen works.
** Any and all feedback is most welcome, as I might have forgotten or
** overlooked something.
*/
/*
** Basically, safes handles open/close of safes automagically, therefore,
** we just need to read/write a pass for it to open.
** This considerably reduces the number of functions to be registered.
** Most functions have callbacksso we can use them in an async way.
However,
** I'm not really familiar with async programming, so maybe something is not
** as it should.
** For easier reading, we have a bunch of typedefs. Some stuff might require
** renaming to better fit in pidgin's naming convention.
*/
// callbacks take the account and the result of the operation.
typedef void(*pw_callback_t)(PurpleAccount*, int);
// read a pass; we take the account and a callback, store it in the
// PurpleAccount, and return the result through the callback
typedef void(*pw_save_simple_t)(PurpleAccount*, pw_callback_t);
// store as password
typedef void(*pw_read_simple_t)(PurpleAccount*, pw_callback_t);
// read/store a password using a master password
typedef void(*pw_save_master_t)(PurpleAccount*, char *, pw_callback_t);
typedef void(*pw_read_master_t)(PurpleAccount*, char *, pw_callback_t);
// change master password, takes current pass, new pass, and callback
// this function can be called with ("", "newpassword") to change from
// unprotected to protected mode.
typedef void(*pw_change_master_pw_t)(char*, char*, pw_callback_t);
// close safe (used to make sure we don't use memory when we've stopped
using
// the safe it. This one might not really require a callback, and could
return
// an int.
typedef void(*pw_close_t)(pw_callback_t);
/*
** this should be all we should need, or are least all that arised in
previous
** design discussions. Now, we can define our plugin info structure :
*/
typedef struct _password_storage_info
{
char * name;
pw_read_simple_t password_read_simple;
pw_save_simple_t password_save_simple;
pw_read_master_t password_read_master;
pw_save_master_t password_save_master;
pw_change_master_pw_t password_change_master;
pw_close_t close;
} password_storage_info;
/*
** And, we can register our plugin.
*/
int purple_password_storage_register(password_storage_info * info);
/*
** Also, callbacks used need to be able to return the following values :
** - ok
** - invalid master password
** - can't access safe
** - password not found
** Those will most likely just be #defined
*/
/*
** More functions might be required, specifically if we want to have a per
** plugin "advanced" configuration interface, or just if I forgot something.
** Since the main rule is to keep it simple, it should be pretty easy to
** add a function pointer or two in the structure.
*/
<-------------------------------------------------------------------------------------------------->
Also, I'm currently propagating trunk, , and will grab Trannie Carter's
code after but I'm not going to have the time to look at it before at
best tomorrow.
Also, this message is not signed because apparently, thunderbird relies
on files I didn't copy on the last update. I'll have to fix that.
--Vivien
More information about the Devel
mailing list