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.
|
|