[?] Contacts - Using the wrong status |
Author: |
Message: |
Spunky
Former Super Mod
Posts: 3658 Reputation: 61
36 / /
Joined: Aug 2006
|
O.P. [?] Contacts - Using the wrong status
I'm using the following code:
code: var StatusImg = new Array('','Offline', 'Online'/*Current User*/, 'Online'/*Contact*/, 'Busy', 'Away', 'Away', 'Away', 'Busy', 'Away','Blocked',"Blocked-offline");
var Contacts = Messenger.MyContacts;
var e = new Enumerator(Contacts);
for(; !e.atEnd(); e.moveNext()) {
var Contact = e.item();
Wnd.LstView_AddItem('contacts', Contact.Email, 0);
Wnd.LstView_SetItemIcon('contacts', Wnd.LstView_GetCount('contacts'), StatusImg[Contact.Status], true);
if(Contact.Blocked==true&&Contact.Status!=1)Wnd.LstView_SetItemIcon('contacts', Wnd.LstView_GetCount('contacts'), StatusImg[10], true);
if(Contact.Blocked==true&&Contact.Status==1)Wnd.LstView_SetItemIcon('contacts', Wnd.LstView_GetCount('contacts'), StatusImg[11], true);
Debug.Trace("Contact Status: "+Contact.Status+" | StatusImg["+Contact.Status+"] = '"+StatusImg[Contact.Status]+"'");
}
MOST of my contacts appear offline (Only certain ones appear online, busy or away; about 5) and all the images are the "Away" image... Can anybody see something I can't?
<Eljay> "Problems encountered: shit blew up"
|
|
10-05-2007 08:35 PM |
|
|
vikke
Senior Member
Posts: 900 Reputation: 28
31 / /
Joined: May 2006
|
RE: [?] Contacts - Using the wrong status
code: var StatusImg = new Array();
StatusImg[1] = "Offline";
StatusImg[2] = "AppearOffline";
StatusImg[3] = "Online";
StatusImg[4] = "Busy";
StatusImg[5] = "BeRightBack";
StatusImg[6] = "Idle";
StatusImg[7] = "Away";
StatusImg[8] = "InACall";
StatusImg[9] = "OutToLunch";
StatusImg[10] = "Blocked";
StatusImg[11] = "BlockedOffline";
function OnEvent_Initialize(MessengerStart)
{
var Contacts = Messenger.MyContacts;
var e = new Enumerator(Contacts);
for(; !e.atEnd(); e.moveNext()) {
var Contact = e.item();
Wnd.LstView_AddItem('contacts', Contact.Email, 0);
Wnd.LstView_SetItemIcon('contacts', Wnd.LstView_GetCount('contacts'), StatusImg[Contact.Status], true);
if(Contact.Blocked==true&&Contact.Status!=1)Wnd.LstView_SetItemIcon('contacts', Wnd.LstView_GetCount('contacts'), StatusImg[10], true);
else
{
Wnd.LstView_SetItemIcon('contacts', Wnd.LstView_GetCount('contacts'), StatusImg[11], true);
}
Debug.Trace("Contact Status: "+Contact.Status+" | StatusImg["+Contact.Status+"] = '"+StatusImg[Contact.Status]+"'");
}
}
This should work. I havn't been able to try it though.
|
|
10-05-2007 08:48 PM |
|
|
Spunky
Former Super Mod
Posts: 3658 Reputation: 61
36 / /
Joined: Aug 2006
|
O.P. RE: [?] Contacts - Using the wrong status
I don't see whats different... It seems to be a bug with the actual status as only 5 emails are coming up as not offline. It's ALWAYS the same ones even when I sign back in or reset PC
<Eljay> "Problems encountered: shit blew up"
|
|
10-05-2007 10:47 PM |
|
|
Chris4
Elite Member
Posts: 4461 Reputation: 84
33 / /
Joined: Dec 2004
|
RE: [?] Contacts - Using the wrong status
Tried deleting contacts cache?
|
|
10-05-2007 10:59 PM |
|
|
vikke
Senior Member
Posts: 900 Reputation: 28
31 / /
Joined: May 2006
|
RE: RE: [?] Contacts - Using the wrong status
quote: Originally posted by SpunkyLoveMuff
I don't see whats different... It seems to be a bug with the actual status as only 5 emails are coming up as not offline. It's ALWAYS the same ones even when I sign back in or reset PC
In Javascript, the index is zero based, it starts at 0, not at 1.
So this would be your current value:
code: StatusImg[0] = '';
StatusImg[1] = 'Offline';
And the correct one should be:
code: StatusImg[2] = 'Offline';
Edit: Check your debug output, that would be an easy way to fix it.
This post was edited on 10-05-2007 at 11:03 PM by vikke.
|
|
10-05-2007 11:02 PM |
|
|
Spunky
Former Super Mod
Posts: 3658 Reputation: 61
36 / /
Joined: Aug 2006
|
O.P. RE: [?] Contacts - Using the wrong status
If Contact.Status == 1 then
StatusImg[Contact.Status] would be 1. So StatusImg[1] would have to be "Offline". As far as I can see thats right.
Debug.Trace shows that each contact has a status of 1 (even though an away picture is shown).
And to clarify, my Contact list is actually correct, where as Plus! is not
<Eljay> "Problems encountered: shit blew up"
|
|
10-05-2007 11:08 PM |
|
|
phalanxii
Full Member
Posts: 146 Reputation: 5
32 / /
Joined: Aug 2006
Status: Away
|
RE: [?] Contacts - Using the wrong status
The only problem that I can possibly see is that you are not setting the icon to the correct item.
For example:
At the start, I'll assume you have no items in the ListView. Then through: code: Wnd.LstView_AddItem('contacts', Contact.Email, 0);
Now you have 1 contact item in the list with an index of 0. But when you set the item's icon: code: Wnd.LstView_SetItemIcon('contacts', Wnd.LstView_GetCount('contacts'), StatusImg[Contact.Status], true);
The GetCount will be 1 (because you have 1 item in the list), but what you want to have is 0 (the index of your item). So you need to take away 1 each time you use the GetCount. Or even better, store the count at the start of the loop before you add the item and use that.
Two possible fixes (haven't tested): code: var StatusImg = new Array('','Offline', 'Online'/*Current User*/, 'Online'/*Contact*/, 'Busy', 'Away', 'Away', 'Away', 'Busy', 'Away','Blocked',"Blocked-offline");
var Contacts = Messenger.MyContacts;
var e = new Enumerator(Contacts);
for(; !e.atEnd(); e.moveNext()) {
var Contact = e.item();
Wnd.LstView_AddItem('contacts', Contact.Email, 0);
Wnd.LstView_SetItemIcon('contacts', Wnd.LstView_GetCount('contacts')-1, StatusImg[Contact.Status], true);
if(Contact.Blocked==true&&Contact.Status!=1)Wnd.LstView_SetItemIcon('contacts', Wnd.LstView_GetCount('contacts')-1, StatusImg[10], true);
if(Contact.Blocked==true&&Contact.Status==1)Wnd.LstView_SetItemIcon('contacts', Wnd.LstView_GetCount('contacts')-1, StatusImg[11], true);
Debug.Trace("Contact Status: "+Contact.Status+" | StatusImg["+Contact.Status+"] = '"+StatusImg[Contact.Status]+"'");
}
code: var StatusImg = new Array('','Offline', 'Online'/*Current User*/, 'Online'/*Contact*/, 'Busy', 'Away', 'Away', 'Away', 'Busy', 'Away','Blocked',"Blocked-offline");
var Contacts = Messenger.MyContacts;
var e = new Enumerator(Contacts);
for(; !e.atEnd(); e.moveNext()) {
var Contact = e.item();
var Count = Wnd.LstView_GetCount('contacts');
Wnd.LstView_AddItem('contacts', Contact.Email, 0);
Wnd.LstView_SetItemIcon('contacts', Count, StatusImg[Contact.Status], true);
if(Contact.Blocked==true&&Contact.Status!=1)Wnd.LstView_SetItemIcon('contacts', Count, StatusImg[10], true);
if(Contact.Blocked==true&&Contact.Status==1)Wnd.LstView_SetItemIcon('contacts', Count, StatusImg[11], true);
Debug.Trace("Contact Status: "+Contact.Status+" | StatusImg["+Contact.Status+"] = '"+StatusImg[Contact.Status]+"'");
}
Hope it works.
|
|
10-06-2007 01:13 AM |
|
|
markee
Veteran Member
Posts: 1622 Reputation: 50
36 / /
Joined: Jan 2006
|
RE: [?] Contacts - Using the wrong status
Also you may prefer to get the returned index from Wnd.LstView_AddItem rather than getting the count (which should be one less anyway I thought). This should also increase speed marginally
code: var StatusImg = new Array('','Offline', 'Online'/*Current User*/, 'Online'/*Contact*/, 'Busy', 'Away', 'Away', 'Away', 'Busy', 'Away','Blocked',"Blocked-offline");
var e = new Enumerator(Messenger.MyContacts);
for(; !e.atEnd(); e.moveNext()) {
var Contact = e.item();
var index = Wnd.LstView_AddItem('contacts', Contact.Email, 0);
Wnd.LstView_SetItemIcon('contacts', index, StatusImg[Contact.Status], true);
if(Contact.Blocked==true) Wnd.LstView_SetItemIcon('contacts', index, StatusImg[(Contact.Status==1)?11:10)], true);
Debug.Trace("Contact Status: "+Contact.Status+" | StatusImg["+Contact.Status+"] = '"+StatusImg[Contact.Status]+"'");
}
I think I told you about this just the other day
Oh and I did some optimising too
This post was edited on 10-06-2007 at 04:48 AM by markee.
|
|
10-06-2007 01:58 AM |
|
|
Spunky
Former Super Mod
Posts: 3658 Reputation: 61
36 / /
Joined: Aug 2006
|
O.P. RE: [?] Contacts - Using the wrong status
quote: Originally posted by Chris4
Tried deleting contacts cache?
Thanks, that did it. As I said, it was not a problem with the code in the end; it was Messenger's fault.
<Eljay> "Problems encountered: shit blew up"
|
|
10-06-2007 05:19 PM |
|
|
Chris4
Elite Member
Posts: 4461 Reputation: 84
33 / /
Joined: Dec 2004
|
RE: [?] Contacts - Using the wrong status
quote: Originally posted by SpunkyLoveMuff
Thanks, that did it.
Glad to hear. No problem.
|
|
10-07-2007 02:08 PM |
|
|
|
|