dquangsinh / gtalksms

Automatically exported from code.google.com/p/gtalksms
0 stars 0 forks source link

sms:unread has incorrect sender information #199

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Receive SMS from Alice, Betty and Candice.
2. Write sms:unread

What is the expected output?
<timestamp> - Candice --> Me
<text>

<timestamp> - Betty --> Me
<text>

<timestamp> - Alice --> Me
<text>

What do you see instead?
<timestamp> - Candice --> Me
<text>

<timestamp> - Candice --> Me
<text>

<timestamp> - Candice --> Me
<text>

Additional informations:
Phone model: HTC Hero 2.2
GTalkSMS version: 3.0

The problem lies in SmsMmsManager; getAllSms 
<http://code.google.com/p/gtalksms/source/browse/src/com/googlecode/gtalksms/cmd
/smsCmd/SmsMmsManager.java#88>:

If the sender is null, as it is when getting all unread SMSes, the sender will 
only be null on the first time through the loop, so the condition on line 88 
will only trigger once, leaving all SMSes as showing the first sender.

Original issue reported on code.google.com by Eckankar on 18 Jul 2011 at 11:52

GoogleCodeExporter commented 8 years ago
You are right. Thanks for the report :)

Original comment by fschm...@gmail.com on 19 Jul 2011 at 8:00

GoogleCodeExporter commented 8 years ago

Original comment by fschm...@gmail.com on 21 Jul 2011 at 4:09

GoogleCodeExporter commented 8 years ago
I get this behavior for just the "sms" command as well. 

Original comment by infophre...@gmail.com on 23 Jul 2011 at 9:16

GoogleCodeExporter commented 8 years ago
I have fixed this issue. Attached is the patch. 

Diff 
=====================================================================
diff -r 79fe97561d5c src/com/googlecode/gtalksms/cmd/smsCmd/SmsMmsManager.java
--- a/src/com/googlecode/gtalksms/cmd/smsCmd/SmsMmsManager.java Sun Jul 17 
21:32:00 2011 +0200
+++ b/src/com/googlecode/gtalksms/cmd/smsCmd/SmsMmsManager.java Sun Jul 24 
02:49:15 2011 -0700
@@ -83,12 +83,13 @@
         if (c != null) {
             for (boolean hasData = c.moveToFirst(); hasData && (getMax || nbSms < maxSms); hasData = c.moveToNext(), ++nbSms) {
                 String address = Tools.getString(c, "address");
+                String MessageSender = sender; 
                 Sms sms = new Sms(address, Tools.getString(c, "body"),  Tools.getDateMilliSeconds(c, "date"));
                 String receiver = isSentSms ? ContactsManager.getContactName(_context, address) : _context.getString(R.string.chat_me);
                 if (sender == null) {
-                    sender = isSentSms ? _context.getString(R.string.chat_me) 
: ContactsManager.getContactName(_context, Tools.getLong(c, "person"));
+                   MessageSender = isSentSms ? 
_context.getString(R.string.chat_me) : ContactsManager.getContactName(_context, 
Tools.getLong(c, "person"));
                 }
-                sms.setSender(sender + " --> " + receiver);
+                sms.setSender(MessageSender + " --> " + receiver);
                 res.add(sms);
             }
             c.close();

=====================================================================

I tested it and this fixes the issue when the sms:unread or the sms command is 
given. 

I am new to this so please me know if I have done anything wrong when fixing an 
issue! 

Cheers, 

Steven

Original comment by sdloner...@gmail.com on 24 Jul 2011 at 10:12

Attachments:

GoogleCodeExporter commented 8 years ago
Thanks for your patch sdlonergan. I did some work on this a few days before and 
had the same idea. So don't be disappointed if I didn't include your version.

Original comment by fschm...@gmail.com on 24 Jul 2011 at 6:41

GoogleCodeExporter commented 8 years ago
No worries and I understand! I love the project and just wanted to help if I 
could :)

Cheers, 

Steven

Original comment by sdloner...@gmail.com on 25 Jul 2011 at 12:59

GoogleCodeExporter commented 8 years ago
Fixed in v3.1

Original comment by Florent....@gmail.com on 13 Aug 2011 at 11:46

GoogleCodeExporter commented 8 years ago

Original comment by fschm...@gmail.com on 25 Aug 2011 at 7:50