From: <lep...@us...> - 2006-12-11 21:14:40
|
Revision: 7622 http://svn.sourceforge.net/amsn/?rev=7622&view=rev Author: lephilousophe Date: 2006-12-11 13:14:39 -0800 (Mon, 11 Dec 2006) Log Message: ----------- Bye bye updateCount !! :d Now we have a good way to count contacts ! Removed an event for copy of a contact (already raised in ADD callback) Modified Paths: -------------- trunk/amsn/groups.tcl trunk/amsn/gui.tcl trunk/amsn/guicontactlist.tcl trunk/amsn/protocol.tcl Modified: trunk/amsn/groups.tcl =================================================================== --- trunk/amsn/groups.tcl 2006-12-11 20:28:57 UTC (rev 7621) +++ trunk/amsn/groups.tcl 2006-12-11 21:14:39 UTC (rev 7622) @@ -26,8 +26,6 @@ variable entryid -1; variable groupname ""; # Temporary variable for TCL crappiness variable bShowing; # (array) Y=shown/expanded N=hidden/collapsed - variable uMemberCnt; # (array) member count for that group - variable uMemberCnt_online; # (array) member count for that group global pgc } @@ -340,8 +338,6 @@ proc DeleteCB {pdu} { # RMG 24 12065 15 variable bShowing - variable uMemberCnt - variable uMemberCnt_online array set groups [abook::getContactData contactlist groups] if { [::config::getKey protocol] == 11 } { @@ -355,8 +351,6 @@ # Update our local information unset groups($gid) - unset uMemberCnt($gid) - unset uMemberCnt_online($gid) unset bShowing($gid) # TODO: We are out of sync, maybe we should request @@ -370,8 +364,6 @@ proc AddCB {pdu} { # ADG 23 12064 New%20Group 15 =?�-CC #variable groups - variable uMemberCnt - variable uMemberCnt_online variable bShowing array set groups [abook::getContactData contactlist groups] @@ -387,8 +379,6 @@ } set groups($gid) $gname - set uMemberCnt($gid) 0 - set uMemberCnt_online($gid) 0 set bShowing($gid) 1 if { [::config::getKey expanded_group_$gid]!="" } { set bShowing($gid) [::config::getKey expanded_group_$gid] @@ -418,29 +408,47 @@ return [set bShowing($gid)] } - - proc UpdateCount {gid rel_qty {online ""}} { - variable uMemberCnt - variable uMemberCnt_online - variable bShowing - - if {![info exists bShowing($gid)]} { - return -1 - } - if {![info exists uMemberCnt($gid)]} { - set uMemberCnt($gid) 0 - } - - if {($rel_qty == 0) || ($rel_qty == "clear")} { - set uMemberCnt($gid) 0 - set uMemberCnt_online($gid) 0 - } elseif {("$online" == "online")} { - incr uMemberCnt($gid) $rel_qty - incr uMemberCnt_online($gid) $rel_qty + + proc getGroupCount { gid } { + set contact_list [::MSN::getList FL] + set state_contacts 0 + set total_contacts 0 + if { $gid == "online" } { + #We want the number of online people + foreach contact $contact_list { + if { [::abook::getVolatileData $contact state FLN] != "FLN" } { + incr state_contacts + } + } + return [list $state_contacts 0] + } elseif { $gid == "offline" } { + foreach contact $contact_list { + if { [::abook::getVolatileData $contact state FLN] == "FLN" && [::abook::getContactData $contact msn_mobile] != "1"} { + incr state_contacts + } + } + return [list $state_contacts 0] + } elseif { $gid == "mobile" } { + foreach contact $contact_list { + if { [::abook::getVolatileData $contact state FLN] == "FLN" && [::abook::getContactData $contact msn_mobile] == "1"} { + incr state_contacts + } + } + return [list $state_contacts 0] + } elseif { $gid == "blocked" } { + #Even if it's unused now... Maybe it will be back... + return [list [llength [array names ::emailBList]] 0] } else { - incr uMemberCnt($gid) $rel_qty + foreach contact $contact_list { + if { [lsearch [::abook::getGroups $contact] $gid] != -1 } { + incr total_contacts + if { [::abook::getVolatileData $contact state FLN] != "FLN" } { + incr state_contacts + } + } + } + return [list $state_contacts $total_contacts] } - return $uMemberCnt($gid) } proc IsExpanded {gid} { @@ -499,14 +507,10 @@ #variable groups variable bShowing - variable uMemberCnt # These are the default groups. Used when not sorting the # display by user-defined groups - set uMemberCnt(online) 0 - set uMemberCnt(offline) 0 - set uMemberCnt(blocked) 0 set bShowing(online) 1 set bShowing(offline) 1 set bShowing(blocked) 1 @@ -556,15 +560,11 @@ # MSN Packet: LSG <x> <trid> <cnt> <total> <gid> <name> 0 proc Set { nr name } { # There is a new group in the list #variable groups - variable uMemberCnt - variable uMemberCnt_online variable bShowing array set groups [abook::getContactData contactlist groups] set name [urldecode $name] set groups($nr) $name - set uMemberCnt($nr) 0 - set uMemberCnt_online($nr) 0 set bShowing($nr) 1 if { [::config::getKey expanded_group_$nr]!="" } { @@ -728,13 +728,13 @@ } # Cannot and must not delete a group until it is empty - if {$::groups::uMemberCnt($gid) != 0} { - if {$ghandler != ""} { - set retval [eval "$ghandler \"[trans groupnotempty]!\""] + if {[::groups::getGroupCount $gid] != 0} { + if {$ghandler != ""} { + set retval [eval "$ghandler \"[trans groupnotempty]!\""] + } + set pgc 0 + return 0 } - set pgc 0 - return 0 - } ::MSN::WriteSB ns "RMG" $gid # MSN sends back "RMG %T %M $gid" Modified: trunk/amsn/gui.tcl =================================================================== --- trunk/amsn/gui.tcl 2006-12-11 20:28:57 UTC (rev 7621) +++ trunk/amsn/gui.tcl 2006-12-11 21:14:39 UTC (rev 7622) @@ -5031,12 +5031,6 @@ set gcnt [llength $glist] - # Now setup each of the group's defaults - for {set i 0} {$i < $gcnt} {incr i} { - set gid [lindex $glist $i] - ::groups::UpdateCount $gid clear - } - if {[::config::getKey orderbygroup] == 2 } { if { $my_mobilegroup == 1 } { lappend glist "mobile" @@ -5159,11 +5153,6 @@ } } - ::groups::UpdateCount online clear - ::groups::UpdateCount offline clear - ::groups::UpdateCount blocked clear - ::groups::UpdateCount mobile clear - #Draw the users in each group #Go thru list in reverse order, as every item is inserted at the beginning, not the end... for {set i [expr {[llength $list_users] - 1}]} {$i >= 0} {incr i -1} { @@ -5190,17 +5179,6 @@ set state_section [::MSN::stateToSection $state_code]; # Used in online/offline grouping - if { $state_section == "online"} { - ::groups::UpdateCount online +1 - } elseif {$state_section == "offline"} { - if { [::abook::getContactData $user_login msn_mobile] == "1" && $my_mobilegroup == 1 } { - ::groups::UpdateCount mobile +1 - set state_section "mobile" - } else { - ::groups::UpdateCount offline +1 - } - } - set breaking "" if { [::config::getKey orderbygroup] } { @@ -5210,8 +5188,6 @@ if { $section == "tgblocked" } {set section "blocked" } if { $section == "tgmobile" } {set section "mobile" } - ::groups::UpdateCount $user_group +1 $state_section - if { [::config::getKey orderbygroup] == 2 } { if { $state_code == "FLN" } { if { $state_section == "mobile" } { @@ -5247,7 +5223,6 @@ } if { [::config::getKey showblockedgroup] == 1 && [info exists emailBList($user_login)]} { - ::groups::UpdateCount blocked +1 if {[::groups::IsExpanded blocked]} { ShowUser $user_login $state_code $colour "blocked" [lindex [::abook::getGroups $user_login] 0] } @@ -5263,8 +5238,8 @@ # 1) we're in hybrid mode and there are no online contacts # 2) or we're in group mode and there're no contacts (online or offline) if { ($gname == 0 || ([::config::getKey removeempty] && $gname != "offline" && $gname != "mobile")) && - (($::groups::uMemberCnt_online($gname) == 0 && [::config::getKey orderbygroup] == 2) || - ($::groups::uMemberCnt($gname) == 0 && [::config::getKey orderbygroup] == 1)) } { + (([lindex [::groups::getGroupCount $gname] 1] == 0 && [::config::getKey orderbygroup] == 2) || + ([lindex [::groups::getGroupCount $gname] 1] == 0 && [::config::getKey orderbygroup] == 1)) } { set endidx [split [$pgBuddy.text index $gtag.last] "."] if { [::config::getKey nogap] } { $pgBuddy.text delete $gtag.first [expr {[lindex $endidx 0]+1}].0 @@ -5282,7 +5257,7 @@ continue } - if { ([::config::getKey removeempty] && $gname == "mobile" && $::groups::uMemberCnt(mobile) == 0) } { + if { ([::config::getKey removeempty] && $gname == "mobile" && [lindex [::groups::getGroupCount "mobile"] 0] == 0) } { if { [::groups::IsExpanded $gname] } { $pgBuddy.text delete contract$gname.first contract$gname.last $pgBuddy.text tag delete contract$gname @@ -5296,45 +5271,46 @@ if {[::config::getKey orderbygroup] == 2 } { if { $gname == "offline" } { - $pgBuddy.text insert offline.last " ($::groups::uMemberCnt(offline))" offline + $pgBuddy.text insert offline.last "[lindex [::groups::getGroupCount offline] 0]" offline $pgBuddy.text tag add dont_replace_smileys offline.first offline.last } elseif { $gname == "blocked" } { - $pgBuddy.text insert blocked.last " ($::groups::uMemberCnt(blocked))" blocked + $pgBuddy.text insert blocked.last " ([lindex [::groups::getGroupCount blocked] 0])" blocked $pgBuddy.text tag add dont_replace_smileys blocked.first blocked.last } elseif { $gname == "mobile" && $my_mobilegroup == 1 } { - $pgBuddy.text insert mobile.last " ($::groups::uMemberCnt(mobile))" mobile + $pgBuddy.text insert mobile.last " ([lindex [::groups::getGroupCount mobile] 0])" mobile $pgBuddy.text tag add dont_replace_smileys mobile.first mobile.last } else { $pgBuddy.text insert ${gtag}.last \ - " ($::groups::uMemberCnt_online(${gname}))" $gtag + " ([lindex [::groups::getGroupCount ${gname}] 0])" $gtag $pgBuddy.text tag add dont_replace_smileys $gtag.first $gtag.last } } else { if { $gname == "blocked" } { - $pgBuddy.text insert blocked.last " ($::groups::uMemberCnt(blocked))" blocked + $pgBuddy.text insert blocked.last " ([lindex [::groups::getGroupCount blocked] 0])" blocked $pgBuddy.text tag add dont_replace_smileys blocked.first blocked.last } elseif { $gname == "mobile" && $my_mobilegroup == 1 } { - $pgBuddy.text insert mobile.last " ($::groups::uMemberCnt(mobile))" mobile + $pgBuddy.text insert mobile.last " ([lindex [::groups::getGroupCount mobile] 0])" mobile $pgBuddy.text tag add dont_replace_smileys mobile.first mobile.last } else { + set groupcount [::groups::getGroupCount ${gname}] $pgBuddy.text insert ${gtag}.last \ - " ($::groups::uMemberCnt_online(${gname})/$::groups::uMemberCnt($gname))" $gtag + " ([lindex $groupcount 0]/[lindex $groupcount 1])" $gtag $pgBuddy.text tag add dont_replace_smileys $gtag.first $gtag.last } } } } else { - $pgBuddy.text insert online.last " ($::groups::uMemberCnt(online))" online - $pgBuddy.text insert offline.last " ($::groups::uMemberCnt(offline))" offline + $pgBuddy.text insert online.last " ([lindex [::groups::getGroupCount online] 0])" online + $pgBuddy.text insert offline.last " ([lindex [::groups::getGroupCount offline] 0])" offline $pgBuddy.text tag add dont_replace_smileys online.first online.last $pgBuddy.text tag add dont_replace_smileys offline.first offline.last if { $my_mobilegroup == 1 } { - $pgBuddy.text insert mobile.last " ($::groups::uMemberCnt(mobile))" mobile + $pgBuddy.text insert mobile.last " ([lindex [::groups::getGroupCount mobile] 0])" mobile $pgBuddy.text tag add dont_replace_smileys mobile.first mobile.last } if { [::config::getKey showblockedgroup] == 1 && [llength [array names emailBList]] } { - $pgBuddy.text insert blocked.last " ($::groups::uMemberCnt(blocked))" blocked + $pgBuddy.text insert blocked.last " ([lindex [::groups::getGroupCount blocked] 0])" blocked $pgBuddy.text tag add dont_replace_smileys blocked.first blocked.last } } @@ -5588,7 +5564,6 @@ } - #set imgname "img[expr {$::groups::uMemberCnt(online)+$::groups::uMemberCnt(offline)}]" set imgname "img[getUniqueValue]" set displaypicfilename [::abook::getContactData $user_login displaypicfile "" ] Modified: trunk/amsn/guicontactlist.tcl =================================================================== --- trunk/amsn/guicontactlist.tcl 2006-12-11 20:28:57 UTC (rev 7621) +++ trunk/amsn/guicontactlist.tcl 2006-12-11 21:14:39 UTC (rev 7622) @@ -870,7 +870,7 @@ # Draw the text $canvas create text $relxnickpos $ynickpos -text $textpart -anchor w -fill \ - $relnickcolour -font sunderf -tags [list contact $tag nicktext] + $relnickcolour -font splainf -tags [list contact $tag nicktext] set textwidth [font measure splainf $textpart] # Append underline coords @@ -1286,21 +1286,20 @@ # Get the group count # Depend if user in status/group/hybrid mode proc getGroupCount {element} { + set groupcounts [::groups::getGroupCount [lindex $element 0]] + set mode [::config::getKey orderbygroup] if { $mode == 0} { # Status mode - set groupcount $::groups::uMemberCnt([lindex $element 0]) + set groupcount [lindex $groupcounts 0] } elseif { $mode == 1} { # Group mode - set groupcount $::groups::uMemberCnt_online([lindex $element 0])/$::groups::uMemberCnt([lindex $element 0]) + set groupcount "[lindex $groupcounts 0]/[lindex $groupcounts 1]" } elseif { $mode == 2} { # Hybrid mode - if {[lindex $element 0] == "offline" || [lindex $element 0] == "mobile"} { - set groupcount $::groups::uMemberCnt([lindex $element 0]) - } else { - set groupcount $::groups::uMemberCnt_online([lindex $element 0]) - } + set groupcount [lindex $groupcounts 0] } + return $groupcount } Modified: trunk/amsn/protocol.tcl =================================================================== --- trunk/amsn/protocol.tcl 2006-12-11 20:28:57 UTC (rev 7621) +++ trunk/amsn/protocol.tcl 2006-12-11 21:14:39 UTC (rev 7622) @@ -1433,9 +1433,6 @@ } else { set atrid [::MSN::WriteSB ns "ADD" "FL $passport [urlencode $userName] $newGid"] } - - # An event to let the GUI know a user is copied/added to a group - ::Event::fireEvent contactAdded protocol $passport $newGid } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |