------------------------------------------------------------
revno: 247
committer: Alan Alvarez <aalva...@aliensoft.net>
branch nick: login-system
timestamp: Wed 2010-09-08 20:19:31 -0400
message:
- Forgot to add some files on last commit
- break from unnecesary loop cycles
added:
mira-client/include/network/messages/MsgGroupParted.h
mira-server/include/network/messages/MsgPartGroup.h
mira-server/include/network/messages/MsgPartWorkplace.h
modified:
mira-client/src/gui/qt/Workplace.cpp
--
lp:~mira-dev/mira/login-system
https://code.launchpad.net/~mira-dev/mira/login-system
You are subscribed to branch lp:~mira-dev/mira/login-system.
To unsubscribe from this branch go to
https://code.launchpad.net/~mira-dev/mira/login-system/+edit-subscription
=== added file 'mira-client/include/network/messages/MsgGroupParted.h'
--- mira-client/include/network/messages/MsgGroupParted.h 1970-01-01 00:00:00 +0000
+++ mira-client/include/network/messages/MsgGroupParted.h 2010-09-09 00:19:31 +0000
@@ -0,0 +1,111 @@
+/*
+ * MsgGroupParted.h
+ *
+ * Mira GroupWare
+ * Copyright (C) 2007-2010 Mira GroupWare Dev Team
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+#ifndef __MIRACLIENT__NETWORK_MSGGROUPPARTED_H
+#define __MIRACLIENT__NETWORK_MSGGROUPPARTED_H
+
+#include <string>
+#include <boost/algorithm/string.hpp>
+#include "Msg.h"
+#include "Application.h"
+#include "tools.h"
+#include "Workplace.h"
+
+#include <QString>
+
+using std::vector;
+using std::string;
+using boost::algorithm::split;
+using boost::algorithm::is_space;
+
+namespace miraclient
+{
+
+namespace network
+{
+
+class MsgGroupParted : public Msg
+{
+ public:
+ MsgGroupParted(const std::string& message) : Msg(message)
+ {}
+
+ virtual void run()
+ {
+ size_t pos = m_message.find("\"");
+ if (pos == std::string::npos)
+ return;
+
+ std::string user = m_message.substr(0, pos-1);
+ m_message.erase(0, pos+1);
+
+ pos = m_message.find_last_of("\"");
+ if (pos == std::string::npos)
+ return;
+ else
+ m_message.erase(pos);
+
+ std::string& workplace = m_message;
+
+ QSettings settings(QSettings::NativeFormat,QSettings::UserScope,MiraOrgStr,MiraNameStr);
+ settings.beginGroup("servers");
+ Server server = settings.value(QString::fromStdString(Application::user_info.server_key)).value<Server>();
+
+ // Get cached workplace
+ QList<WorkplaceCache>::iterator Iter = server.workplaces.begin();
+ for (; Iter != server.workplaces.end(); ++Iter)
+ {
+ if (Iter->name.toStdString() == workplace)
+ break;
+ }
+
+ // If user is us, then we are the one leaving the workplace
+ if (Application::user_info.username == user)
+ {
+ QMetaObject::invokeMethod(Application::get_gui_application(), "removeWorkplace", Qt::QueuedConnection,
+ MIRA_QT_GENERIC_ARG(std::string, workplace));
+
+ // delete workplace from cache
+ if (Iter != server.workplaces.end())
+ {
+ server.workplaces.erase(Iter);
+ }
+ }
+ else // Oterhwise, it's another member
+ {
+ QMetaObject::invokeMethod(Application::get_gui_application(), "removeWorkplaceMember", Qt::QueuedConnection,
+ MIRA_QT_GENERIC_ARG(std::string, workplace),
+ MIRA_QT_GENERIC_ARG(std::string, user));
+
+ if (Iter != server.workplaces.end())
+ {
+ Iter->members.removeOne(QString::fromStdString(user));
+ }
+ }
+
+ // Save data to disk
+ settings.setValue(QString::fromStdString(Application::user_info.server_key), server);
+ settings.sync();
+ }
+};
+} // namespace network
+
+} // namespace miraclient
+
+#endif // __MIRACLIENT__NETWORK_MSGGROUPPARTED_H
=== modified file 'mira-client/src/gui/qt/Workplace.cpp'
--- mira-client/src/gui/qt/Workplace.cpp 2010-08-24 20:10:25 +0000
+++ mira-client/src/gui/qt/Workplace.cpp 2010-09-09 00:19:31 +0000
@@ -120,6 +120,8 @@
QLayoutItem *item = m_utilitiesBoxLayout->takeAt(i);
if (item != 0)
delete item;
+
+ break;
}
}
}
@@ -168,6 +170,8 @@
QLayoutItem *item = m_membersBoxLayout->takeAt(i);
if (item != 0)
delete item;
+
+ break;
}
}
}
@@ -195,6 +199,8 @@
(*statusIter)->setPixmap(QPixmap(":/images/chat-offline.png"));
break;
}
+
+ break;
}
}
}
@@ -214,4 +220,6 @@
Iter->status = STATUS_OFFLINE;
(*statusIter)->setPixmap(QPixmap(":/images/chat-offline.png"));
}
+
+ // TODO: Tell Utilities to go offline
}
=== added file 'mira-server/include/network/messages/MsgPartGroup.h'
--- mira-server/include/network/messages/MsgPartGroup.h 1970-01-01 00:00:00 +0000
+++ mira-server/include/network/messages/MsgPartGroup.h 2010-09-09 00:19:31 +0000
@@ -0,0 +1,129 @@
+/*
+ * MsgPartGroup.h
+ *
+ * Mira GroupWare
+ * Copyright (C) 2007-2010 Mira GroupWare Dev Team
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+#ifndef __MIRASERVER__NETWORK_MSGPARTGROUP_H
+#define __MIRASERVER__NETWORK_MSGPARTGROUP_H
+
+#include <string>
+
+#include "Msg.h"
+#include "tools.h"
+#include "Application.h"
+
+namespace miraserver
+{
+
+namespace network
+{
+
+class MsgPartGroup : public Msg
+{
+ public:
+ MsgPartGroup(TcpConnection* source_connection, const std::string& message) : Msg(source_connection, message)
+ {}
+
+ virtual void run()
+ {
+ if (m_message.length() < 1)
+ m_source_connection->send("E PG Invalid Format ");
+
+ // Delete quotes
+ if (m_message[0] == '\"')
+ m_message.erase(0, 1);
+
+ if (m_message[m_message.length()-1] == '\"')
+ m_message.erase(m_message.length()-1, 1);
+
+ //Checking if the Group exist
+ WorkPlace workplace = Application::get_directory().find_workplace(m_message);
+
+ if (workplace.is_valid() == false)
+ {
+ string error_message = "E PG Group ";
+ error_message += m_message + " doesn't exist";
+ m_source_connection->send(error_message);
+ return;
+ }
+
+ User user = Application::get_directory().find_user(m_source_connection->get_user_id());
+ if (user.is_valid() == false)
+ {
+ m_source_connection->send("E PG Could not find User object. Please contact Server Administrator");
+ return;
+ }
+
+ std::string workplace_id = IntToString(workplace.get_id());
+
+ Field field = user.get_field(ATTRIBUTE_WORKPLACE_LIST);
+ if(field.type == Field::type_invalid) // If group doesn't even have a user list, he is not a member of workplace
+ {
+ string error_message = "E PG \"";
+ error_message += m_message + "\" You are not a member of that group.";
+ m_source_connection->send(error_message);
+ return;
+ }
+ else
+ {
+ std::list<std::string>::iterator pos = find(field.value_list.begin(), field.value_list.end(), workplace_id);
+ if(pos == field.value_list.end())
+ {
+ string error_message = "E PG \"";
+ error_message += m_message + "\" You are not a member of that group.";
+ m_source_connection->send(error_message);
+ return;
+ }
+ field.value_list.erase(pos);
+ }
+ user.set_field(field);
+ Application::get_directory().update_user(user);
+
+ //Adding user(id) to Group's user_list
+ field = workplace.get_field(ATTRIBUTE_USER_LIST);
+ std::list<std::string>::iterator pos = find(field.value_list.begin(), field.value_list.end(), IntToString(user.get_id()));
+ if(pos == field.value_list.end())
+ {
+ string error_message = "E PG \"";
+ error_message += m_message + "\" You are not a member of that group.";
+ m_source_connection->send(error_message);
+ return;
+ }
+ field.value_list.erase(pos);
+
+ workplace.set_field(field);
+ Application::get_directory().update_workplace(workplace);
+
+ m_source_connection->send("GP " + user.get_username() + " \"" + workplace.get_name() + "\"");
+ // Notify online workplace members of this (including the user that sent the message)
+ for (std::list<std::string>::iterator Iter = field.value_list.begin(); Iter != field.value_list.end(); ++Iter)
+ {
+ unsigned int user_id = StringToInt(*Iter);
+ TcpConnection* user_connection = Application::get_server().get_connection(user_id);
+ if (user_connection != NULL)
+ {
+ user_connection->send("GP " + user.get_username() + " \"" + workplace.get_name() + "\"");
+ }
+ }
+ }
+};
+
+} // namespace network
+
+} // namespace miraserver
+
+#endif // __MIRASERVER__NETWORK_MSGPARTGROUP_H
=== added file 'mira-server/include/network/messages/MsgPartWorkplace.h'
--- mira-server/include/network/messages/MsgPartWorkplace.h 1970-01-01 00:00:00 +0000
+++ mira-server/include/network/messages/MsgPartWorkplace.h 2010-09-09 00:19:31 +0000
@@ -0,0 +1,4 @@
+#ifndef MSGPARTWORKPLACE_H
+#define MSGPARTWORKPLACE_H
+
+#endif // MSGPARTWORKPLACE_H
------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:
Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
Mira-development mailing list
Mira-development@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mira-development