Shoutbox

[?] Contacts - Using the wrong status - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: [?] Contacts - Using the wrong status (/showthread.php?tid=77999)

[?] Contacts - Using the wrong status by Spunky on 10-05-2007 at 08:35 PM

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?
RE: [?] Contacts - Using the wrong status by vikke on 10-05-2007 at 08:48 PM

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.
RE: [?] Contacts - Using the wrong status by Spunky on 10-05-2007 at 10:47 PM

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


RE: [?] Contacts - Using the wrong status by Chris4 on 10-05-2007 at 10:59 PM

Tried deleting contacts cache?


RE: RE: [?] Contacts - Using the wrong status by vikke on 10-05-2007 at 11:02 PM

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.
RE: [?] Contacts - Using the wrong status by Spunky on 10-05-2007 at 11:08 PM

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


RE: [?] Contacts - Using the wrong status by phalanxii on 10-06-2007 at 01:13 AM

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.
RE: [?] Contacts - Using the wrong status by markee on 10-06-2007 at 01:58 AM

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 8-)

Oh and I did some optimising too :P
RE: [?] Contacts - Using the wrong status by Spunky on 10-06-2007 at 05:19 PM

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.
RE: [?] Contacts - Using the wrong status by Chris4 on 10-07-2007 at 02:08 PM

quote:
Originally posted by SpunkyLoveMuff
Thanks, that did it.
Glad to hear. :) No problem.