Commit 67c95632a81f6e62773c5ca959d1943fe033b1a8

Authored by Matti Virkkunen
1 parent add71ef3

Included a minimal Thrift interface file.

.gitignore
1 1 thrift_line
2   -line_main.thrift
3 2 *.o
4 3 libline.so
5 4 .depend
... ...
Makefile
... ... @@ -11,7 +11,7 @@ PURPLE_DATA_ROOT_DIR:=$(shell pkg-config --variable=datarootdir purple)
11 11  
12 12 MAIN = libline.so
13 13  
14   -GEN_SRCS = thrift_line/line_main_constants.cpp thrift_line/line_main_types.cpp \
  14 +GEN_SRCS = thrift_line/line_constants.cpp thrift_line/line_types.cpp \
15 15 thrift_line/TalkService.cpp
16 16 REAL_SRCS = pluginmain.cpp linehttptransport.cpp thriftclient.cpp httpclient.cpp \
17 17 purpleline.cpp purpleline_login.cpp purpleline_blist.cpp purpleline_chats.cpp \
... ... @@ -29,9 +29,9 @@ $(MAIN): $(OBJS)
29 29 .cpp.o:
30 30 $(CXX) $(CXXFLAGS) -std=c++11 -c $< -o $@
31 31  
32   -thrift_line: line_main.thrift
  32 +thrift_line: line.thrift
33 33 mkdir -p thrift_line
34   - $(THRIFT) --gen cpp -out thrift_line line_main.thrift
  34 + $(THRIFT) --gen cpp -out thrift_line line.thrift
35 35  
36 36 .PHONY: clean
37 37 clean:
... ...
README.md
... ... @@ -28,8 +28,6 @@ Make sure you have the required prerequisites:
28 28 * libpurple - probably available from your package manager
29 29 * Apache Thrift compiler and C++ library - v0.9.1 should be stable. The Git version and OS packages
30 30 are sometimes a bit iffy. Compiling by hand is your best bet.
31   -* line_main.thrift - not included, must be placed in the project root directory. For the time being,
32   - you can acquire this file from the documentation at http://altrepo.eu/
33 31  
34 32 To install the plugin system-wide, run:
35 33  
... ...
line.thrift 0 → 100644
  1 +namespace cpp line
  2 +
  3 +enum ContactSetting {
  4 + CONTACT_SETTING_DELETE = 16;
  5 +}
  6 +
  7 +enum ContactStatus {
  8 + FRIEND = 1;
  9 + FRIEND_BLOCKED = 2;
  10 + RECOMMEND_BLOCKED = 4;
  11 + DELETED = 5;
  12 + DELETED_BLOCKED = 6;
  13 +}
  14 +
  15 +enum ContentType {
  16 + NONE = 0;
  17 + IMAGE = 1;
  18 + VIDEO = 2;
  19 + AUDIO = 3;
  20 + STICKER = 7;
  21 + LOCATION = 15;
  22 +}
  23 +
  24 +enum ErrorCode {
  25 + ILLEGAL_ARGUMENT = 0;
  26 + AUTHENTICATION_FAILED = 1;
  27 + DB_FAILED = 2;
  28 + INVALID_STATE = 3;
  29 + EXCESSIVE_ACCESS = 4;
  30 + NOT_FOUND = 5;
  31 + INVALID_LENGTH = 6;
  32 + NOT_AVAILABLE_USER = 7;
  33 + NOT_AUTHORIZED_DEVICE = 8;
  34 + INVALID_MID = 9;
  35 + NOT_A_MEMBER = 10;
  36 + INCOMPATIBLE_APP_VERSION = 11;
  37 + NOT_READY = 12;
  38 + NOT_AVAILABLE_SESSION = 13;
  39 + NOT_AUTHORIZED_SESSION = 14;
  40 + SYSTEM_ERROR = 15;
  41 + NO_AVAILABLE_VERIFICATION_METHOD = 16;
  42 + NOT_AUTHENTICATED = 17;
  43 + INVALID_IDENTITY_CREDENTIAL = 18;
  44 + NOT_AVAILABLE_IDENTITY_IDENTIFIER = 19;
  45 + INTERNAL_ERROR = 20;
  46 + NO_SUCH_IDENTITY_IDENFIER = 21;
  47 + DEACTIVATED_ACCOUNT_BOUND_TO_THIS_IDENTITY = 22;
  48 + ILLEGAL_IDENTITY_CREDENTIAL = 23;
  49 + UNKNOWN_CHANNEL = 24;
  50 + NO_SUCH_MESSAGE_BOX = 25;
  51 + NOT_AVAILABLE_MESSAGE_BOX = 26;
  52 + CHANNEL_DOES_NOT_MATCH = 27;
  53 + NOT_YOUR_MESSAGE = 28;
  54 + MESSAGE_DEFINED_ERROR = 29;
  55 + USER_CANNOT_ACCEPT_PRESENTS = 30;
  56 + USER_NOT_STICKER_OWNER = 32;
  57 + MAINTENANCE_ERROR = 33;
  58 + ACCOUNT_NOT_MATCHED = 34;
  59 + ABUSE_BLOCK = 35;
  60 + NOT_FRIEND = 36;
  61 + NOT_ALLOWED_CALL = 37;
  62 + BLOCK_FRIEND = 38;
  63 + INCOMPATIBLE_VOIP_VERSION = 39;
  64 + INVALID_SNS_ACCESS_TOKEN = 40;
  65 + EXTERNAL_SERVICE_NOT_AVAILABLE = 41;
  66 + NOT_ALLOWED_ADD_CONTACT = 42;
  67 + NOT_CERTIFICATED = 43;
  68 + NOT_ALLOWED_SECONDARY_DEVICE = 44;
  69 + INVALID_PIN_CODE = 45;
  70 + NOT_FOUND_IDENTITY_CREDENTIAL = 46;
  71 + EXCEED_FILE_MAX_SIZE = 47;
  72 + EXCEED_DAILY_QUOTA = 48;
  73 + NOT_SUPPORT_SEND_FILE = 49;
  74 + MUST_UPGRADE = 50;
  75 + NOT_AVAILABLE_PIN_CODE_SESSION = 51;
  76 +}
  77 +
  78 +enum IdentityProvider {
  79 + LINE = 1;
  80 +}
  81 +
  82 +enum LoginResultType {
  83 + SUCCESS = 1;
  84 + REQUIRE_DEVICE_CONFIRM = 3;
  85 +}
  86 +
  87 +enum MIDType {
  88 + USER = 0;
  89 + ROOM = 1;
  90 + GROUP = 2;
  91 +}
  92 +
  93 +enum OpType {
  94 + END_OF_OPERATION = 0;
  95 + UPDATE_PROFILE = 1;
  96 + NOTIFIED_UPDATE_PROFILE = 2;
  97 + REGISTER_USERID = 3;
  98 + ADD_CONTACT = 4;
  99 + NOTIFIED_ADD_CONTACT = 5;
  100 + BLOCK_CONTACT = 6;
  101 + UNBLOCK_CONTACT = 7;
  102 + NOTIFIED_RECOMMEND_CONTACT = 8;
  103 + CREATE_GROUP = 9;
  104 + UPDATE_GROUP = 10;
  105 + NOTIFIED_UPDATE_GROUP = 11;
  106 + INVITE_INTO_GROUP = 12;
  107 + NOTIFIED_INVITE_INTO_GROUP = 13;
  108 + LEAVE_GROUP = 14;
  109 + NOTIFIED_LEAVE_GROUP = 15;
  110 + ACCEPT_GROUP_INVITATION = 16;
  111 + NOTIFIED_ACCEPT_GROUP_INVITATION = 17;
  112 + KICKOUT_FROM_GROUP = 18;
  113 + NOTIFIED_KICKOUT_FROM_GROUP = 19;
  114 + CREATE_ROOM = 20;
  115 + INVITE_INTO_ROOM = 21;
  116 + NOTIFIED_INVITE_INTO_ROOM = 22;
  117 + LEAVE_ROOM = 23;
  118 + NOTIFIED_LEAVE_ROOM = 24;
  119 + SEND_MESSAGE = 25;
  120 + RECEIVE_MESSAGE = 26;
  121 + SEND_MESSAGE_RECEIPT = 27;
  122 + RECEIVE_MESSAGE_RECEIPT = 28;
  123 + SEND_CONTENT_RECEIPT = 29;
  124 + RECEIVE_ANNOUNCEMENT = 30;
  125 + CANCEL_INVITATION_GROUP = 31;
  126 + NOTIFIED_CANCEL_INVITATION_GROUP = 32;
  127 + NOTIFIED_UNREGISTER_USER = 33;
  128 + REJECT_GROUP_INVITATION = 34;
  129 + NOTIFIED_REJECT_GROUP_INVITATION = 35;
  130 + UPDATE_SETTINGS = 36;
  131 + NOTIFIED_REGISTER_USER = 37;
  132 + INVITE_VIA_EMAIL = 38;
  133 + NOTIFIED_REQUEST_RECOVERY = 39;
  134 + SEND_CHAT_CHECKED = 40;
  135 + SEND_CHAT_REMOVED = 41;
  136 + NOTIFIED_FORCE_SYNC = 42;
  137 + SEND_CONTENT = 43;
  138 + SEND_MESSAGE_MYHOME = 44;
  139 + NOTIFIED_UPDATE_CONTENT_PREVIEW = 45;
  140 + REMOVE_ALL_MESSAGES = 46;
  141 + NOTIFIED_UPDATE_PURCHASES = 47;
  142 + DUMMY = 48;
  143 + UPDATE_CONTACT = 49;
  144 + NOTIFIED_RECEIVED_CALL = 50;
  145 + CANCEL_CALL = 51;
  146 + NOTIFIED_REDIRECT = 52;
  147 + NOTIFIED_CHANNEL_SYNC = 53;
  148 + FAILED_SEND_MESSAGE = 54;
  149 + NOTIFIED_READ_MESSAGE = 55;
  150 + FAILED_EMAIL_CONFIRMATION = 56;
  151 + NOTIFIED_CHAT_CONTENT = 58;
  152 + NOTIFIED_PUSH_NOTICENTER_ITEM = 59;
  153 +}
  154 +
  155 +struct Contact {
  156 + 1: string mid;
  157 + 11: ContactStatus status;
  158 + 22: string displayName;
  159 + 26: string statusMessage;
  160 + 35: i32 attributes;
  161 + 37: string picturePath;
  162 +}
  163 +
  164 +struct Group {
  165 + 1: string id;
  166 + 10: string name;
  167 + 20: list<Contact> members;
  168 + 21: Contact creator;
  169 + 22: list<Contact> invitee;
  170 +}
  171 +
  172 +struct Location {
  173 + 1: string title;
  174 + 2: string address;
  175 + 3: double latitude;
  176 + 4: double longitude;
  177 +}
  178 +
  179 +struct LoginResult {
  180 + 1: string authToken;
  181 + 2: string certificate;
  182 + 3: string verifier;
  183 + 4: string pinCode;
  184 + 5: LoginResultType type;
  185 +}
  186 +
  187 +struct Message {
  188 + 1: string from;
  189 + 2: string to;
  190 + 3: MIDType toType;
  191 + 4: string id;
  192 + 5: i64 createdTime;
  193 + 10: string text;
  194 + 11: optional Location location;
  195 + 15: ContentType contentType;
  196 + 17: binary contentPreview;
  197 + 18: map<string, string> contentMetadata;
  198 +}
  199 +
  200 +struct MessageBox {
  201 + 1: string id;
  202 + 9: MIDType midType;
  203 + 10: list<Message> lastMessages;
  204 +}
  205 +
  206 +struct MessageBoxWrapUp {
  207 + 1: MessageBox messageBox;
  208 + 3: list<Contact> contacts;
  209 +}
  210 +
  211 +struct MessageBoxWrapUpList {
  212 + 1: list<MessageBoxWrapUp> messageBoxWrapUpList;
  213 +}
  214 +
  215 +struct Operation {
  216 + 1: i64 revision;
  217 + 2: i64 createdTime;
  218 + 3: OpType type;
  219 + 4: i32 reqSeq;
  220 + 10: string param1;
  221 + 11: string param2;
  222 + 12: string param3;
  223 + 20: Message message;
  224 +}
  225 +
  226 +struct Profile {
  227 + 1: string mid;
  228 + 20: string displayName;
  229 + 24: string statusMessage;
  230 + 33: string picturePath;
  231 +}
  232 +
  233 +struct Room {
  234 + 1: string mid;
  235 + 10: list<Contact> contacts;
  236 +}
  237 +
  238 +exception TalkException {
  239 + 1: ErrorCode code;
  240 + 2: string reason;
  241 +}
  242 +
  243 +service TalkService {
  244 + void acceptGroupInvitation(
  245 + 1: i32 reqSeq,
  246 + 2: string groupId) throws(1: TalkException e);
  247 +
  248 + list<Operation> fetchOperations(
  249 + 2: i64 localRev,
  250 + 3: i32 count) throws(1: TalkException e);
  251 +
  252 + list<string> getAllContactIds() throws(1: TalkException e);
  253 +
  254 + Contact getContact(
  255 + 2: string id) throws(1: TalkException e);
  256 +
  257 + list<Contact> getContacts(
  258 + 2: list<string> ids) throws(1: TalkException e);
  259 +
  260 + Group getGroup(
  261 + 2: string groupId) throws(1: TalkException e);
  262 +
  263 + list<string> getGroupIdsInvited() throws(1: TalkException e);
  264 +
  265 + list<string> getGroupIdsJoined() throws(1: TalkException e);
  266 +
  267 + list<Group> getGroups(
  268 + 2: list<string> groupIds) throws(1: TalkException e);
  269 +
  270 + i64 getLastOpRevision() throws(1: TalkException e);
  271 +
  272 + MessageBoxWrapUpList getMessageBoxCompactWrapUpList(
  273 + 2: i32 start,
  274 + 3: i32 messageBoxCount) throws(1: TalkException e);
  275 +
  276 + list<Message> getPreviousMessages(
  277 + 2: string messageBoxId,
  278 + 3: i64 endSeq,
  279 + 4: i32 messagesCount) throws(1: TalkException e);
  280 +
  281 + list<Message> getRecentMessages(
  282 + 2: string messageBoxId,
  283 + 3: i32 messagesCount) throws(1: TalkException e);
  284 +
  285 + Room getRoom(
  286 + 2: string roomId) throws(1: TalkException e);
  287 +
  288 + LoginResult loginWithIdentityCredentialForCertificate(
  289 + 8: IdentityProvider identityProvider,
  290 + 3: string identifier,
  291 + 4: string password,
  292 + 5: bool keepLoggedIn,
  293 + 6: string accessLocation,
  294 + 7: string systemName,
  295 + 9: string certificate) throws(1: TalkException e);
  296 +
  297 + LoginResult loginWithVerifierForCertificate(
  298 + 3: string verifier) throws(1: TalkException e);
  299 +
  300 + void leaveGroup(
  301 + 1: i32 reqSeq,
  302 + 2: string groupId) throws(1: TalkException e);
  303 +
  304 + void leaveRoom(
  305 + 1: i32 reqSeq,
  306 + 2: string roomId) throws(1: TalkException e);
  307 +
  308 + Profile getProfile() throws(1: TalkException e);
  309 +
  310 + void rejectGroupInvitation(
  311 + 1: i32 reqSeq,
  312 + 2: string groupId) throws(1: TalkException e);
  313 +
  314 + Message sendMessage(
  315 + 1: i32 seq,
  316 + 2: Message message) throws(1: TalkException e);
  317 +
  318 + void updateContactSetting(
  319 + 1: i32 reqSeq,
  320 + 2: string mid,
  321 + 3: ContactSetting flag,
  322 + 4: string value) throws(1: TalkException e);
  323 +}
... ...
purpleline.hpp
... ... @@ -173,7 +173,7 @@ private:
173 173 void get_contacts();
174 174 void get_groups();
175 175 void get_rooms();
176   - void update_rooms(line::TMessageBoxWrapUpResponse wrap_up_list);
  176 + void update_rooms(line::MessageBoxWrapUpList wrap_up_list);
177 177 void get_group_invites();
178 178  
179 179 void login_done();
... ...
purpleline_login.cpp
... ... @@ -248,12 +248,12 @@ void PurpleLine::get_groups() {
248 248 void PurpleLine::get_rooms() {
249 249 c_out->send_getMessageBoxCompactWrapUpList(1, 65535);
250 250 c_out->send([this]() {
251   - line::TMessageBoxWrapUpResponse wrap_up_list;
  251 + line::MessageBoxWrapUpList wrap_up_list;
252 252 c_out->recv_getMessageBoxCompactWrapUpList(wrap_up_list);
253 253  
254 254 std::set<std::string> uids;
255 255  
256   - for (line::TMessageBoxWrapUp &ent: wrap_up_list.messageBoxWrapUpList) {
  256 + for (line::MessageBoxWrapUp &ent: wrap_up_list.messageBoxWrapUpList) {
257 257 if (ent.messageBox.midType != line::MIDType::ROOM)
258 258 continue;
259 259  
... ... @@ -280,10 +280,10 @@ void PurpleLine::get_rooms() {
280 280 });
281 281 }
282 282  
283   -void PurpleLine::update_rooms(line::TMessageBoxWrapUpResponse wrap_up_list) {
  283 +void PurpleLine::update_rooms(line::MessageBoxWrapUpList wrap_up_list) {
284 284 std::set<PurpleChat *> chats_to_delete = blist_find_chats_by_type(ChatType::ROOM);
285 285  
286   - for (line::TMessageBoxWrapUp &ent: wrap_up_list.messageBoxWrapUpList) {
  286 + for (line::MessageBoxWrapUp &ent: wrap_up_list.messageBoxWrapUpList) {
287 287 if (ent.messageBox.midType != line::MIDType::ROOM)
288 288 continue;
289 289  
... ...