From evan.s@dreskin.net Fri Dec 22 21:04:46 2006 From: evan.s@dreskin.net (Evan Schoenberg) Date: Fri, 22 Dec 2006 16:04:46 -0500 Subject: [OTR-dev] Patch for account display name Message-ID: <00F46C22-6B5B-467D-BE3C-CEB644B0056E@dreskin.net> This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --Apple-Mail-4--464274185 Content-Type: multipart/mixed; boundary=Apple-Mail-3--464274384 --Apple-Mail-3--464274384 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed This patch is better than what I proposed in my previous email. It adds a ui_op for account_display_name to mirror protocol_name. Works great for me. --Apple-Mail-3--464274384 Content-Transfer-Encoding: 7bit Content-Type: application/octet-stream; x-unix-mode=0644; name=account_display_name_op.diff Content-Disposition: attachment; filename=account_display_name_op.diff Index: src/message.c =================================================================== --- src/message.c (revision 357) +++ src/message.c (working copy) @@ -770,6 +770,7 @@ char *plaintext; char *buf; char *format; + const char *displayaccountname; unsigned char flags; case OTRL_MSGSTATE_PLAINTEXT: case OTRL_MSGSTATE_FINISHED: @@ -806,14 +807,23 @@ } format = "?OTR Error: You sent encrypted " "data to %s, who wasn't expecting it."; - buf = malloc(strlen(format) + strlen(context->accountname) + if (ops->account_display_name) { + displayaccountname = ops->account_display_name(opdata, context->accountname, protocol); + } else { + displayaccountname = NULL; + } + buf = malloc(strlen(format) + strlen((displayaccountname ? displayaccountname : context->accountname)) - 1); if (buf) { - sprintf(buf, format, context->accountname); + sprintf(buf, format, (displayaccountname ? displayaccountname : context->accountname)); if (ops->inject_message) { ops->inject_message(opdata, accountname, protocol, sender, buf); } + if (displayaccountname && ops->account_display_name_free) { + ops->account_display_name_free(opdata, displayaccountname); + } + free(buf); } Index: src/message.h =================================================================== --- src/message.h (revision 357) +++ src/message.h (working copy) @@ -69,6 +69,13 @@ * state), this is called so the UI can be updated. */ void (*update_context_list)(void *opdata); + /* Return a newly-allocated string containing a human-friendly name + * for the given accountname / protocol pair */ + const char *(*account_display_name)(void *opdata, const char *accountname, const char *protocol); + + /* Deallocate a string allocated by protocol_name */ + void (*account_display_name_free)(void *opdata, const char *protocol_name); + /* Return a newly-allocated string containing a human-friendly name * for the given protocol id */ const char *(*protocol_name)(void *opdata, const char *protocol); --Apple-Mail-3--464274384 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed Cheers, Evan --Apple-Mail-3--464274384-- --Apple-Mail-4--464274185 content-type: application/pgp-signature; x-mac-type=70674453; name=PGP.sig content-description: This is a digitally signed message part content-disposition: inline; filename=PGP.sig content-transfer-encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (Darwin) iD8DBQFFjEhvI5gp6xQhrvcRAo+uAKChIymTsPc+KM+QWNPK2b+pbSJGgACfePJz LlZ0mT7k61XlKsCORXXqKlU= =rpaQ -----END PGP SIGNATURE----- --Apple-Mail-4--464274185-- From ian@cypherpunks.ca Fri Dec 22 21:39:45 2006 From: ian@cypherpunks.ca (Ian Goldberg) Date: Fri, 22 Dec 2006 16:39:45 -0500 Subject: [OTR-dev] Patch for account display name In-Reply-To: <00F46C22-6B5B-467D-BE3C-CEB644B0056E@dreskin.net> References: <00F46C22-6B5B-467D-BE3C-CEB644B0056E@dreskin.net> Message-ID: <20061222213945.GC13546@yoink.cs.uwaterloo.ca> On Fri, Dec 22, 2006 at 04:04:46PM -0500, Evan Schoenberg wrote: > This patch is better than what I proposed in my previous email. It > adds a ui_op for account_display_name to mirror protocol_name. Works > great for me. I didn't see a previous mail about this. But this looks plausible. I'll wait until after the holidays to apply and test it and stuff, though. What is the function you're passing in there for Adium X? Is gaim likely to use the same function? If so, it should probably go in the UI-independent part of gaim-otr. - Ian From evan.s@dreskin.net Fri Dec 22 21:58:30 2006 From: evan.s@dreskin.net (Evan Schoenberg) Date: Fri, 22 Dec 2006 16:58:30 -0500 Subject: [OTR-dev] Patch for account display name In-Reply-To: <20061222213945.GC13546@yoink.cs.uwaterloo.ca> References: <00F46C22-6B5B-467D-BE3C-CEB644B0056E@dreskin.net> <20061222213945.GC13546@yoink.cs.uwaterloo.ca> Message-ID: This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --Apple-Mail-6--461049538 Content-Type: multipart/alternative; boundary=Apple-Mail-5--461050429 --Apple-Mail-5--461050429 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed On Dec 22, 2006, at 4:39 PM, Ian Goldberg wrote: > I didn't see a previous mail about this. But this looks plausible. > I'll wait until after the holidays to apply and test it and stuff, > though. I'm not sure what happened to it. Here it is again: In libotr, contexts are often referred to be their account name and protocol, such as: format = "?OTR Error: You sent encrypted " "data to %s, who wasn't expecting it."; buf = malloc(strlen(format) + strlen(context->accountname) - 1); if (buf) { sprintf(buf, format, context->accountname); accountname and protocol are intended to be how to associate the context with a particular messaging account in the client. However, to make that association, since a client can have multiple accounts with the same accountname and protocol, I use accountname to store a unique identifier for the account (a number). Obviously, this results in error messages which are nonsense: OTR Error: You sent encrypted data to 5, who wasn't expecting it. > What is the function you're passing in there for Adium X? Is gaim > likely to use the same function? If so, it should probably go in the > UI-independent part of gaim-otr. I'm not sure what gaim would use in terms of uniquely identifying an account; certainly gaim does support having multiple accounts with the same name on the same protocol. Cheers, Evan --Apple-Mail-5--461050429 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=ISO-8859-1
On Dec 22, 2006, = at 4:39 PM, Ian Goldberg wrote:

I didn't see a previous mail = about this.=A0 But this = looks plausible.

I'll wait until after the holidays to apply and test it and = stuff,

though.

I'm not sure what = happened to it.

Here it is again:
In libotr, contexts are often referred to be their = account name and protocol, such as:
=A0 =A0 format =3D = "?OTR Error: You sent encrypted = "
=A0 =A0 "data to %s, who wasn't expecting it.";
=A0 =A0 buf =3D = malloc(strlen(format) + = strlen(context->accountname)
=A0 =A0 - 1);
=A0 =A0 = if (buf) = {
sprintf(buf, format, = context->accountname);
OTR Error: You = sent encrypted data to 5, who wasn't expecting = it.

<and a dumb proposal = here, which isn't as good as the patch>

What is the function you're = passing in there for Adium X?=A0 = Is gaim

likely to use the same function?=A0 If so, it should probably go = in the

UI-independent part of gaim-otr.

=
I'm not sure what gaim would use in terms of uniquely = identifying an account; certainly gaim does support having multiple = accounts with the same name on the same protocol.

Cheers,
Evan
<= /BODY>= --Apple-Mail-5--461050429-- --Apple-Mail-6--461049538 content-type: application/pgp-signature; x-mac-type=70674453; name=PGP.sig content-description: This is a digitally signed message part content-disposition: inline; filename=PGP.sig content-transfer-encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (Darwin) iD8DBQFFjFUJI5gp6xQhrvcRAgKDAJ9fKCabJ9C9TIBIQR68ZTeQP2MuFgCgjA9j 3Wwvbg5MXgn1IFpceF5mfcM= =n9f9 -----END PGP SIGNATURE----- --Apple-Mail-6--461049538--