1 | /* |
2 | * Off-the-Record Messaging library |
3 | * Copyright (C) 2004-2012 Ian Goldberg, Rob Smits, Chris Alexander, |
4 | * Willy Lew, Lisa Du, Nikita Borisov |
5 | * <otr@cypherpunks.ca> |
6 | * |
7 | * This library is free software; you can redistribute it and/or |
8 | * modify it under the terms of version 2.1 of the GNU Lesser General |
9 | * Public License as published by the Free Software Foundation. |
10 | * |
11 | * This library is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | * Lesser General Public License for more details. |
15 | * |
16 | * You should have received a copy of the GNU Lesser General Public |
17 | * License along with this library; if not, write to the Free Software |
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
19 | */ |
20 | |
21 | #ifndef __INSTAG_H__ |
22 | #define __INSTAG_H__ |
23 | |
24 | #include <stdio.h> |
25 | #include <errno.h> |
26 | |
27 | #define OTRL_INSTAG_MASTER 0 |
28 | #define OTRL_INSTAG_BEST 1 /* Most secure, based on: conv status, |
29 | * then fingerprint status, then most recent. */ |
30 | #define OTRL_INSTAG_RECENT 2 |
31 | #define OTRL_INSTAG_RECENT_RECEIVED 3 |
32 | #define OTRL_INSTAG_RECENT_SENT 4 |
33 | |
34 | #define OTRL_MIN_VALID_INSTAG 0x100 /* Instag values below this are reserved |
35 | * for meta instags, defined above, */ |
36 | |
37 | typedef unsigned int otrl_instag_t; |
38 | |
39 | /* The list of instance tags used for our accounts */ |
40 | typedef struct s_OtrlInsTag { |
41 | struct s_OtrlInsTag *next; |
42 | struct s_OtrlInsTag **tous; |
43 | |
44 | char *accountname; |
45 | char *protocol; |
46 | otrl_instag_t instag; |
47 | } OtrlInsTag; |
48 | |
49 | #include "userstate.h" |
50 | |
51 | /* Forget the given instag. */ |
52 | void otrl_instag_forget(OtrlInsTag* instag); |
53 | |
54 | /* Forget all instags in a given OtrlUserState. */ |
55 | void otrl_instag_forget_all(OtrlUserState us); |
56 | |
57 | /* Fetch the instance tag from the given OtrlUserState associated with |
58 | * the given account */ |
59 | OtrlInsTag * otrl_instag_find(OtrlUserState us, const char *accountname, |
60 | const char *protocol); |
61 | |
62 | /* Read our instance tag from a file on disk into the given |
63 | * OtrlUserState. */ |
64 | gcry_error_t otrl_instag_read(OtrlUserState us, const char *filename); |
65 | |
66 | /* Read our instance tag from a file on disk into the given |
67 | * OtrlUserState. The FILE* must be open for reading. */ |
68 | gcry_error_t otrl_instag_read_FILEp(OtrlUserState us, FILE *instf); |
69 | |
70 | /* Return a new valid instance tag */ |
71 | otrl_instag_t otrl_instag_get_new(); |
72 | |
73 | /* Get a new instance tag for the given account and write to file*/ |
74 | gcry_error_t otrl_instag_generate(OtrlUserState us, const char *filename, |
75 | const char *accountname, const char *protocol); |
76 | |
77 | /* Get a new instance tag for the given account and write to file |
78 | * The FILE* must be open for writing. */ |
79 | gcry_error_t otrl_instag_generate_FILEp(OtrlUserState us, FILE *instf, |
80 | const char *accountname, const char *protocol); |
81 | |
82 | /* Write our instance tags to a file on disk. */ |
83 | gcry_error_t otrl_instag_write(OtrlUserState us, const char *filename); |
84 | |
85 | /* Write our instance tags to a file on disk. |
86 | * The FILE* must be open for writing. */ |
87 | gcry_error_t otrl_instag_write_FILEp(OtrlUserState us, FILE *instf); |
88 | |
89 | #endif |
90 | |