Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 141675 | Differences between
and this patch

Collapse All | Expand All

(-)kopete/protocols/oscar/liboscar/ssimanager.cpp (-13 / +62 lines)
Lines 71-88 Link Here
71
		while ( it != d->SSIList.end() && d->SSIList.count() > 0 )
71
		while ( it != d->SSIList.end() && d->SSIList.count() > 0 )
72
			it = d->SSIList.remove( it );
72
			it = d->SSIList.remove( it );
73
	};
73
	};
74
	
75
	d->nextContactId = 0;
76
	d->nextGroupId = 0;
74
}
77
}
75
78
76
WORD SSIManager::nextContactId()
79
WORD SSIManager::nextContactId()
77
{
80
{
78
	d->nextContactId++;
81
	if ( d->nextContactId == 0 )
79
	return d->nextContactId;
82
		d->nextContactId++;
83
	
84
	QValueList<Oscar::SSI>::const_iterator it, listEnd;
85
	
86
	for ( ; d->nextContactId < 0x8000; d->nextContactId++ )
87
	{
88
		bool freeId = true;
89
		listEnd = d->SSIList.end();
90
		for ( it = d->SSIList.begin(); it != listEnd; ++it )
91
		{
92
			if ( ( *it ).bid() == d->nextContactId )
93
			{
94
				freeId = false;
95
				break;
96
			}
97
		}
98
	
99
		if ( freeId )
100
			return d->nextContactId;
101
	}
102
	
103
	kdDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "No free id!" << endl;
104
	return 0xFFFF;
80
}
105
}
81
106
82
WORD SSIManager::nextGroupId()
107
WORD SSIManager::nextGroupId()
83
{
108
{
84
	d->nextGroupId++;
109
	if ( d->nextGroupId == 0 )
85
	return d->nextGroupId;
110
		d->nextGroupId++;
111
	
112
	QValueList<Oscar::SSI>::const_iterator it, listEnd;
113
	
114
	for ( ; d->nextGroupId < 0x8000; d->nextGroupId++ )
115
	{
116
		bool freeId = true;
117
		listEnd = d->SSIList.end();
118
		for ( it = d->SSIList.begin(); it != listEnd; ++it )
119
		{
120
			if ( ( *it ).type() == ROSTER_GROUP && ( *it ).gid() == d->nextGroupId )
121
			{
122
				freeId = false;
123
				break;
124
			}
125
		}
126
		
127
		if ( freeId )
128
			return d->nextGroupId;
129
	}
130
	
131
	kdDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "No free group id!" << endl;
132
	return 0xFFFF;
86
}
133
}
87
134
88
WORD SSIManager::numberOfItems() const
135
WORD SSIManager::numberOfItems() const
Lines 379-386 Link Here
379
	if ( !group.name().isEmpty() ) //avoid the group with gid 0 and bid 0
426
	if ( !group.name().isEmpty() ) //avoid the group with gid 0 and bid 0
380
	{	// the group is really new
427
	{	// the group is really new
381
		kdDebug( OSCAR_RAW_DEBUG ) << k_funcinfo << "Adding group '" << group.name() << "' to SSI list" << endl;
428
		kdDebug( OSCAR_RAW_DEBUG ) << k_funcinfo << "Adding group '" << group.name() << "' to SSI list" << endl;
382
		if ( group.gid() > d->nextGroupId )
383
			d->nextGroupId = group.gid();
384
		
429
		
385
		d->SSIList.append( group );
430
		d->SSIList.append( group );
386
		emit groupAdded( group );
431
		emit groupAdded( group );
Lines 394-399 Link Here
394
	QString groupName = group.name();
439
	QString groupName = group.name();
395
	kdDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "Removing group " << group.name() << endl;
440
	kdDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "Removing group " << group.name() << endl;
396
	int remcount = d->SSIList.remove( group );
441
	int remcount = d->SSIList.remove( group );
442
	
443
	if ( d->nextGroupId > group.gid() )
444
		d->nextGroupId = group.gid();
445
	
397
	if ( remcount == 0 )
446
	if ( remcount == 0 )
398
	{
447
	{
399
		kdDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "No groups removed" << endl;
448
		kdDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "No groups removed" << endl;
Lines 420-432 Link Here
420
469
421
bool SSIManager::newContact( const Oscar::SSI& contact )
470
bool SSIManager::newContact( const Oscar::SSI& contact )
422
{
471
{
423
	//what to validate?
424
	if ( contact.bid() > d->nextContactId )
425
	{
426
		kdDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "Setting next contact ID to " << contact.bid() << endl;
427
		d->nextContactId = contact.bid();
428
	}
429
	
430
	if ( d->SSIList.findIndex( contact ) == -1 )
472
	if ( d->SSIList.findIndex( contact ) == -1 )
431
	{
473
	{
432
		kdDebug( OSCAR_RAW_DEBUG ) << k_funcinfo << "Adding contact '" << contact.name() << "' to SSI list" << endl;
474
		kdDebug( OSCAR_RAW_DEBUG ) << k_funcinfo << "Adding contact '" << contact.name() << "' to SSI list" << endl;
Lines 443-448 Link Here
443
	QString contactName = contact.name();
485
	QString contactName = contact.name();
444
	int remcount = d->SSIList.remove( contact );
486
	int remcount = d->SSIList.remove( contact );
445
	
487
	
488
	if ( d->nextContactId > contact.bid() )
489
		d->nextContactId = contact.bid();
490
	
446
	if ( remcount == 0 )
491
	if ( remcount == 0 )
447
	{
492
	{
448
		kdDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "No contacts were removed." << endl;
493
		kdDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "No contacts were removed." << endl;
Lines 476-481 Link Here
476
bool SSIManager::removeItem( const Oscar::SSI& item )
521
bool SSIManager::removeItem( const Oscar::SSI& item )
477
{
522
{
478
	d->SSIList.remove( item );
523
	d->SSIList.remove( item );
524
	
525
	if ( d->nextContactId > item.bid() )
526
		d->nextContactId = item.bid();
527
	
479
	return true;
528
	return true;
480
}
529
}
481
530

Return to bug 141675