1 Xmpp4Js.Lang.namespace( "Xmpp4Js.Roster" );
  2 
  3 /** 
  4  *Protected constructor should only be used by Roster
  5  * @constructor
  6  */
  7 Xmpp4Js.Roster.RosterEntry = function(jid, alias, subscription, ask, groups, roster) {
  8         this.jid = jid;
  9         this.alias = alias;
 10         this.subscription = subscription;
 11         this.ask = ask;
 12         this.groups = groups;
 13         this.roster = roster;
 14 }
 15 
 16 Xmpp4Js.Roster.RosterEntry.prototype = {
 17 	
 18 
 19 	/** @deprecated new model doesn't keep the same entry around */
 20 	update: function( alias, subscription, ask, groups ) {
 21 		this.alias = alias;
 22 		this.subscription = subscription;
 23 		this.ask = ask;
 24 		this.groups = groups;
 25 	},
 26 	/** references to all groups this entry belongs to. 0 or more. */
 27 	getGroups: function() {
 28             var retGroups = [];
 29             // TODO possibly refactor this to roster.getGroups and make use of that... for each group, if contains this jid, add to list
 30             // gets groups off of con.roster
 31             if( this.groups.length == 0 ) {
 32                 retGroups.push( this.roster.getUnfiledContacts() );
 33             } else {
 34                 for(var i = 0; i < this.groups.length; i++) {
 35                     var groupName = this.groups[i];
 36                     var group = this.roster.getGroup(groupName);
 37                     // if group is undefined, that means that this entry is not associated with 
 38                     // an existing group--perhaps it was just removed.
 39                     // TODO make a test for this case.
 40                     if( group == undefined ) {
 41                         group = new Xmpp4Js.Roster.VirtualRosterGroup( groupName, [this], this.roster );
 42                     }
 43                     retGroups.push( group );
 44                 };
 45             }
 46 		return retGroups;
 47             }
 48 
 49 }
 50