Commit 86d3ba75a68aff0871950904ec5dea22c33e6065

Authored by Matti Virkkunen
1 parent be21a704

Avoid new reserved keyword ("from") in thrift (closes #14)

libpurple/line.thrift
... ... @@ -198,7 +198,7 @@ struct LoginResult {
198 198 }
199 199  
200 200 struct Message {
201   - 1: string from;
  201 + 1: string from_;
202 202 2: string to;
203 203 3: MIDType toType;
204 204 4: string id;
... ...
libpurple/purpleline.cpp
... ... @@ -286,7 +286,7 @@ int PurpleLine::send_message(std::string to, const char *markup) {
286 286 line::Message msg;
287 287  
288 288 msg.contentType = line::ContentType::NONE;
289   - msg.from = profile.mid;
  289 + msg.from_ = profile.mid;
290 290 msg.to = to;
291 291 msg.text = markup_unescape(text);
292 292  
... ... @@ -296,8 +296,6 @@ int PurpleLine::send_message(std::string to, const char *markup) {
296 296 }
297 297  
298 298 if (img_found) {
299   - // Image test
300   -
301 299 int image_id = std::stoi((char *)g_datalist_get_data(&attributes, "id"));
302 300 g_datalist_clear(&attributes);
303 301  
... ... @@ -317,7 +315,7 @@ int PurpleLine::send_message(std::string to, const char *markup) {
317 315 line::Message msg;
318 316  
319 317 msg.contentType = line::ContentType::IMAGE;
320   - msg.from = profile.mid;
  318 + msg.from_ = profile.mid;
321 319 msg.to = to;
322 320  
323 321 send_message(msg, [this, img_data](line::Message &msg_back) {
... ...
libpurple/purpleline_cmds.cpp
... ... @@ -61,7 +61,6 @@ PurpleCmdRet PurpleLine::cmd_sticker(PurpleConversation *conv,
61 61 }
62 62  
63 63 msg.contentType = line::ContentType::STICKER;
64   - msg.from = profile.mid;
65 64 msg.to = purple_conversation_get_name(conv);
66 65  
67 66 write_message(msg, false);
... ...
libpurple/purpleline_write.cpp
... ... @@ -49,7 +49,7 @@ void PurpleLine::write_message(line::Message &msg, bool replay) {
49 49 int flags = 0;
50 50 time_t mtime = (time_t)(msg.createdTime / 1000);
51 51  
52   - bool sent = (msg.from == profile.mid);
  52 + bool sent = (msg.from_ == profile.mid);
53 53  
54 54 if (std::find(recent_messages.cbegin(), recent_messages.cend(), msg.id)
55 55 != recent_messages.cend())
... ... @@ -59,17 +59,17 @@ void PurpleLine::write_message(line::Message &msg, bool replay) {
59 59 }
60 60  
61 61 // Hack
62   - if (msg.from == msg.to)
  62 + if (msg.from_ == msg.to)
63 63 push_recent_message(msg.id);
64 64  
65 65 PurpleConversation *conv = purple_find_conversation_with_account(
66 66 (msg.toType == line::MIDType::USER ? PURPLE_CONV_TYPE_IM : PURPLE_CONV_TYPE_CHAT),
67   - ((!sent && msg.toType == line::MIDType::USER) ? msg.from.c_str() : msg.to.c_str()),
  67 + ((!sent && msg.toType == line::MIDType::USER) ? msg.from_.c_str() : msg.to.c_str()),
68 68 acct);
69 69  
70 70 // If this is a new received IM, create the conversation if it doesn't exist
71 71 if (!conv && !sent && msg.toType == line::MIDType::USER)
72   - conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, acct, msg.from.c_str());
  72 + conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, acct, msg.from_.c_str());
73 73  
74 74 // If this is a new conversation, we're not replaying history and history hasn't been fetched
75 75 // yet, queue the message instead of showing it.
... ... @@ -247,7 +247,7 @@ void PurpleLine::write_message(line::Message &msg, bool replay) {
247 247 if (sent) {
248 248 // Messages sent by user (sync from other devices)
249 249  
250   - write_message(conv, msg.from, text, mtime, flags | PURPLE_MESSAGE_SEND);
  250 + write_message(conv, msg.from_, text, mtime, flags | PURPLE_MESSAGE_SEND);
251 251 } else {
252 252 // Messages received from other users
253 253  
... ... @@ -256,12 +256,12 @@ void PurpleLine::write_message(line::Message &msg, bool replay) {
256 256 if (replay) {
257 257 // Write replayed messages instead of serv_got_* to avoid Pidgin's IM sound
258 258  
259   - write_message(conv, msg.from, text, mtime, flags);
  259 + write_message(conv, msg.from_, text, mtime, flags);
260 260 } else {
261 261 if (msg.toType == line::MIDType::USER) {
262 262 serv_got_im(
263 263 conn,
264   - msg.from.c_str(),
  264 + msg.from_.c_str(),
265 265 text.c_str(),
266 266 (PurpleMessageFlags)flags,
267 267 mtime);
... ... @@ -269,7 +269,7 @@ void PurpleLine::write_message(line::Message &msg, bool replay) {
269 269 serv_got_chat_in(
270 270 conn,
271 271 purple_conv_chat_get_id(PURPLE_CONV_CHAT(conv)),
272   - msg.from.c_str(),
  272 + msg.from_.c_str(),
273 273 (PurpleMessageFlags)flags,
274 274 text.c_str(),
275 275 mtime);
... ...