summaryrefslogtreecommitdiff
path: root/src/resources/buddylist.cpp
diff options
context:
space:
mode:
authorMateusz Kaduk <mateusz.kaduk@gmail.com>2005-05-09 12:05:04 +0000
committerMateusz Kaduk <mateusz.kaduk@gmail.com>2005-05-09 12:05:04 +0000
commit5f8d500a0282d533ea4b7db1d982e1149d345289 (patch)
treed4042b9671fd75b3ef54ca29f941e88206dcd1c3 /src/resources/buddylist.cpp
parentbe25dfc81df7e2ac253895d4c91307407446eadd (diff)
downloadmana-5f8d500a0282d533ea4b7db1d982e1149d345289.tar.gz
mana-5f8d500a0282d533ea4b7db1d982e1149d345289.tar.bz2
mana-5f8d500a0282d533ea4b7db1d982e1149d345289.tar.xz
mana-5f8d500a0282d533ea4b7db1d982e1149d345289.zip
Added buddylist model
Diffstat (limited to 'src/resources/buddylist.cpp')
-rw-r--r--src/resources/buddylist.cpp35
1 files changed, 32 insertions, 3 deletions
diff --git a/src/resources/buddylist.cpp b/src/resources/buddylist.cpp
index 580d7e10..0f64492b 100644
--- a/src/resources/buddylist.cpp
+++ b/src/resources/buddylist.cpp
@@ -21,6 +21,7 @@
*/
#include "buddylist.h"
+#include <iostream>
BuddyList::BuddyList()
{
@@ -32,22 +33,50 @@ BuddyList::~BuddyList()
bool BuddyList::addBuddy(const std::string buddy)
{
- buddylist.push_back(buddy);
+ for(buddyit = buddylist.begin(); buddyit != buddylist.end(); buddyit++)
+ {
+ // Buddy already exist
+ if(*buddyit == buddy) return false;
+ }
+
+ // Buddy doesnt exist
+ buddylist.push_back(buddy);
return true;
}
bool BuddyList::removeBuddy(const std::string buddy)
{
- return true;
+ for(buddyit = buddylist.begin(); buddyit != buddylist.end(); buddyit++)
+ {
+ // Buddy exist, remove it
+ if(*buddyit == buddy) {
+ buddylist.remove(buddy);
+ return true;
+ }
+ }
+
+ // Buddy doesnt exist
+ return false;
}
int BuddyList::getBuddyNumber(void)
{
- return 0;
+ int ret = 0;
+ for(buddyit = buddylist.begin(); buddyit != buddylist.end(); buddyit++)
+ ret++;
+ return ret;
}
std::string BuddyList::getBuddy(int number)
{
+ int i = 0;
+ for(buddyit = buddylist.begin(); buddyit != buddylist.end(); buddyit++)
+ {
+ if(i == number)
+ return *buddyit;
+ i++;
+ }
+
return "";
}