Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions code/flist_messenger/api/apihelpers.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
#include "flist_api.h"

#if QT_VERSION >= 0x050000
#include <QUrlQuery>
#else
#include <QUrl>
#endif
#include <QByteArray>

namespace FHttpApi {

QNetworkReply *Endpoint::request(QUrl u, QHash<QString, QString> params)
{
QUrl encParams;
#if QT_VERSION >= 0x050000
QUrlQuery encParams;
#else
QUrl encParams;
#endif
QHashIterator<QString,QString> i(params);
while(i.hasNext())
{
Expand All @@ -18,11 +26,11 @@ QNetworkReply *Endpoint::request(QUrl u, QHash<QString, QString> params)
QNetworkRequest request(u);
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
#if QT_VERSION >= 0x050000
QIODevice postData = encParams.query(QUrl::FullyEncoded).toUtf8();
QByteArray postData = encParams.query(QUrl::FullyEncoded).toUtf8();
#else
QByteArray postData = encParams.encodedQuery();
#endif
QNetworkReply *reply = qnam->post(request, postData);
QNetworkReply *reply = qnam->post(request, postData);
return reply;
}

Expand Down
18 changes: 11 additions & 7 deletions code/flist_messenger/flist_account.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,17 @@ void FAccount::loginSslErrors( QList<QSslError> sslerrors )

void FAccount::onLoginError(QString error_id, QString error_message)
{
debugMessage("account->loginHttps() error!");
emit loginError(this, "Login Error", QString("%1 (%2)").arg(error_message).arg(error_id));
debugMessage("account->loginHttps() error!");
if (error_message.compare("Password mismatch.")) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to hide the error ID for errors that aren't password failures?

emit loginError(this, "Login Error", QString("%1 (%2)").arg(error_message).arg(error_id));
} else {
emit loginError(this, "Login Error", QString("%1").arg(error_message));
}
}

void FAccount::loginHandle()
{
debugMessage("account->loginHandle()");
debugMessage("account->loginHandle()");
loginReply->deleteLater();

ticket = loginReply->ticket->ticket;
Expand All @@ -55,7 +59,7 @@ void FAccount::loginHandle()

void FAccount::loginStart()
{
debugMessage("account->loginStart()");
debugMessage("account->loginStart()");
ticketvalid = false;

loginReply = fapi->getTicket(username, password);
Expand All @@ -66,7 +70,7 @@ void FAccount::loginStart()

void FAccount::loginUserPass(QString user, QString pass)
{
debugMessage("account->loginUserPass()");
debugMessage("account->loginUserPass()");
username = user;
password = pass;
valid = true;
Expand All @@ -75,8 +79,8 @@ void FAccount::loginUserPass(QString user, QString pass)

FSession *FAccount::getSession(QString sessionid)
{
//debugMessage("account->getSession()");
int i;
//debugMessage("account->getSession()");
int i;
//Find existing session, if any.
for(i = 0; i < charactersessions.length(); i++) {
if(charactersessions[i]->sessionid == sessionid) {
Expand Down
3 changes: 0 additions & 3 deletions code/flist_messenger/flist_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,13 @@ namespace FHttpApi
// virtual Request<void> *remFriend(cpTicket t, crQString from, crQString to) = 0;
// virtual Request<void> *acceptFriendRequest(cpTicket t, int request_id) = 0;
// virtual Request<void> *cancelFriendRequest(cpTicket t, int request_id) = 0;

// virtual Request<QList<Character> > *getCharacterList(cpTicket t) = 0;

// /* Acceptable data types:
// * Data_Kinks, Data_Description, Data_CustomKinks, Data_Images, Data_Infotags
// */
// virtual Request<CharacterData> *getCharacterData(cpTicket t, crQString name, DataTypes d = Data_QuickProfile) = 0;
// virtual Request<CharacterMemo> *getCharacterMemo(cpTicket t, int idCharacter) = 0;
// virtual Request<void> *setCharacterMemo(cpTicket t, int idCharacter, crQString memo);

// virtual Request *getIgnoreList(cpTicket t) = 0;
// virtual Request *addIgnore(cpTicket t, int idCharacter) = 0;
// virtual Request *addIgnore(cpTicket t, crQString character) = 0;
Expand Down
22 changes: 11 additions & 11 deletions code/flist_messenger/flist_channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
FChannel::FChannel(QObject *parent, FSession *session, QString name, QString title) :
QObject(parent),
session(session),
name(name),
title(title),
_name(name),
_title(title),
characterlist(),
operatorlist(),
joined(true),
_joined(true),
mode(CHANNEL_MODE_BOTH)
{
if(name.startsWith("ADH-")) {
Expand All @@ -25,36 +25,36 @@ void FChannel::addCharacter(QString charactername, bool notify) {
if(!characterlist.contains(lowername) || characterlist.value(lowername).isEmpty()) {
characterlist[lowername] = charactername;
}
session->account->ui->addChannelCharacter(session, name, charactername, notify);
session->account->ui->addChannelCharacter(session, this->name(), charactername, notify);
}
void FChannel::removeCharacter(QString charactername) {
characterlist.remove(charactername.toLower());
session->account->ui->removeChannelCharacter(session, name, charactername);
session->account->ui->removeChannelCharacter(session, this->name(), charactername);
}

void FChannel::addOperator(QString charactername) {
QString lowername = charactername.toLower();
if(!operatorlist.contains(lowername) || operatorlist.value(lowername).isEmpty()) {
operatorlist[lowername] = charactername;
}
session->account->ui->setChannelOperator(session, name, charactername, true);
session->account->ui->setChannelOperator(session, this->name(), charactername, true);
}
void FChannel::removeOperator(QString charactername) {
operatorlist.remove(charactername.toLower());
session->account->ui->setChannelOperator(session, name, charactername, false);
session->account->ui->setChannelOperator(session, this->name(), charactername, false);
}


void FChannel::join()
{
joined = true;
session->account->ui->joinChannel(session, name);
_joined = true;
session->account->ui->joinChannel(session, this->name());
}

void FChannel::leave()
{
joined = false;
_joined = false;
characterlist.clear();
operatorlist.clear();
session->account->ui->leaveChannel(session, name);
session->account->ui->leaveChannel(session, this->name());
}
26 changes: 12 additions & 14 deletions code/flist_messenger/flist_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ class FChannel : public QObject
explicit FChannel(QObject *parent, FSession *session, QString name, QString title);

bool isCharacterPresent(QString charactername) {return characterlist.contains(charactername.toLower());}
bool isCharacterOperator(QString charactername) {return operatorlist.contains(charactername.toLower());}
//todo: Figure out a better function name than 'isJoined'.
bool isJoined() {return joined;}
bool isCharacterOperator(QString charactername) {return operatorlist.contains(charactername.toLower());}

void addCharacter(QString charactername, bool notify);
void removeCharacter(QString charactername);
Expand All @@ -38,27 +36,27 @@ class FChannel : public QObject
void join();
void leave();

QString getTitle() {return title;}
void setTitle(QString title) {this->title = title;}
bool joined() {return _joined;}
QString title() {return _title;}
QString name() {return _name;}
QString description() {return _description;}

QString getDescription() {return description;}
void setDescription(QString &newdescription) {description = newdescription;}
void setTitle(const QString &newTitle) {this->_title = newTitle;}
void setDescription(const QString &newdescription) {_description = newdescription;}

signals:

public slots:

public:
//todo: Make the following private.
FSession *session;
QString name; //<Server name for this channel/room
QString title; //<Title for this room.
QString description; //<Long description for the channel/room.
private:
FSession *session;
QString _name; //<Server name for this channel/room
QString _title; //<Title for this room.
QString _description; //<Long description for the channel/room.
QMap<QString, QString> characterlist; //<List of all characters within a channel.
QMap<QString, QString> operatorlist; //<List of all channel operators.
bool _joined; //<Indicates if this session is currently joined with this channel.
public:
bool joined; //<Indicates if this session is currently joined with this channel.
ChannelMode mode; //<The mode of the channel.
ChannelType type;
};
Expand Down
6 changes: 3 additions & 3 deletions code/flist_messenger/flist_channelpanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ void FChannelPanel::remChar ( FCharacter* character )

void FChannelPanel::sortChars()
{
// Gnome Sort. :3
int i;
// Gnome Sort. :3
int i;

QList<int> chancharlevels;

Expand Down Expand Up @@ -188,7 +188,7 @@ void FChannelPanel::sortChars()
}
}

//std::cout << "Gnome sorted userlist~." << std::endl;
//std::cout << "Gnome sorted userlist~." << std::endl;
}

bool FChannelPanel::isOp ( FCharacter* character )
Expand Down
1 change: 1 addition & 0 deletions code/flist_messenger/flist_channelpanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ class FChannelPanel
void printChannel ( QTextBrowser* textEdit );
QPushButton* pushButton;
static BBCodeParser* bbparser;

private:
bool active; // Will be no when the user leaves. This way, logs are kept.~
QString recipientName; // For PM tabs.
Expand Down
2 changes: 1 addition & 1 deletion code/flist_messenger/flist_global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ QString logpath;
FSettings *settings = 0;
FHttpApi::Endpoint *fapi = 0;

void debugMessage(QString str) {
void debugMessage(QString str, DebugMessageType::DBG_GENERAL) {
std::cout << str.toUtf8().data() << std::endl;
}

Expand Down
15 changes: 12 additions & 3 deletions code/flist_messenger/flist_global.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <QNetworkAccessManager>
#include "flist_api.h"
#include "flist_enums.h"

class BBCodeParser;
class FSettings;
Expand All @@ -12,9 +13,9 @@ extern BBCodeParser *bbcodeparser;
extern FHttpApi::Endpoint *fapi;
extern FSettings *settings;

void debugMessage(QString str);
void debugMessage(std::string str);
void debugMessage(const char *str);
void debugMessage(QString str, DebugMessageType d);
void debugMessage(std::string str, DebugMessageType d);
void debugMessage(const char *str, DebugMessageType d);
void globalInit();
void globalQuit();
bool is_broken_escaped_apos(std::string const &data, std::string::size_type n);
Expand All @@ -31,6 +32,14 @@ void centerOnScreen(QWidget *widge);
#define FLIST_VERSION FLIST_NAME " " FLIST_VERSIONNUM
#define FLIST_CLIENTID "F-List Desktop Client"

enum dbgMessageTypes {
DBG_GENERAL 0,
DBG_SERVER 1
};

#define DBG_GENERAL 0
#define DBG_SERVER


#define FLIST_CHAT_SERVER "chat.f-list.net"
//#define FLIST_CHAT_SERVER_PORT 8722 //Test server
Expand Down
16 changes: 8 additions & 8 deletions code/flist_messenger/flist_session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ FChannel *FSession::addChannel(QString name, QString title)
if(channellist.contains(name)) {
channel = channellist[name];
//Ensure that the channel's title is set correctly for ad-hoc channels.
if(name != title && channel->getTitle() != title) {
if(name != title && channel->title() != title) {
channel->setTitle(title);
}
return channel;
Expand Down Expand Up @@ -310,7 +310,7 @@ void FSession::wsSend(std::string &input)
//textEdit->append ( "Attempted to send a message, but client is disconnected." );
} else {
fix_broken_escaped_apos ( input );
debugMessage( ">>" + input);
// debugMessage( ">>" + input);
QByteArray buf;
QDataStream stream ( &buf, QIODevice::WriteOnly );
input.resize ( input.length() );
Expand Down Expand Up @@ -356,7 +356,7 @@ void FSession::wsSend(std::string &input)

void FSession::wsRecv(std::string packet)
{
debugMessage("<<" + packet);
// debugMessage("<<" + packet);
try {
std::string cmd = packet.substr(0, 3);
JSONNode nodes;
Expand Down Expand Up @@ -672,7 +672,7 @@ COMMAND(RMO)
return;
}
QString message = "[session=%1]%2[/session]'s mode has been changed to: %3";
message = bbcodeparser->parse(message).arg(channel->getTitle()).arg(channelname).arg(modedescription);
message = bbcodeparser->parse(message).arg(channel->title()).arg(channelname).arg(modedescription);
account->ui->setChannelMode(this, channelname, channel->mode);
account->ui->messageChannel(this, channelname, message, MESSAGE_TYPE_CHANNEL_MODE, true);
}
Expand Down Expand Up @@ -784,7 +784,7 @@ COMMAND(CBUCKU)
debugMessage(QString("[SERVER BUG] Was told about character '%1' being %4 from channel '%2' by '%3', but the channel '%2' is unknown (or never joined). %5").arg(charactername).arg(channelname).arg(operatorname).arg(kicktype).arg(QString::fromStdString(rawpacket)));
return;
}
if(!channel->isJoined()) {
if(!channel->joined()) {
debugMessage(QString("[SERVER BUG] Was told about character '%1' being %4 from channel '%2' by '%3', but this session is no longer joined with channel '%2'. %5").arg(charactername).arg(channelname).arg(operatorname).arg(kicktype).arg(QString::fromStdString(rawpacket)));
return;
}
Expand All @@ -795,7 +795,7 @@ COMMAND(CBUCKU)
if(!channel->isCharacterOperator(operatorname) && !isCharacterOperator(operatorname)) {
debugMessage(QString("[SERVER BUG] Was told about character '%1' being %4 from channel '%2' by '%3', but '%3' is not a channel operator or a server operator! %5").arg(charactername).arg(channelname).arg(operatorname).arg(kicktype).arg(QString::fromStdString(rawpacket)));
}
QString message = QString("<b>%1</b> has %4 <b>%2</b> from %3.").arg(operatorname).arg(charactername).arg(channel->getTitle()).arg(kicktype);
QString message = QString("<b>%1</b> has %4 <b>%2</b> from %3.").arg(operatorname).arg(charactername).arg(channel->title()).arg(kicktype);
if(charactername == character) {
account->ui->messageChannel(this, channelname, message, banned ? MESSAGE_TYPE_KICKBAN : MESSAGE_TYPE_KICK, true, true);
channel->removeCharacter(charactername);
Expand Down Expand Up @@ -1334,7 +1334,7 @@ void FSession::sendChannelMessage(QString channelname, QString message)
account->ui->messageSystem(this, QString("Tried to send a message to '%1' but the channel is unknown or has never been joined. Message: %2").arg(channelname).arg(message), MESSAGE_TYPE_FEEDBACK);
return;
}
if(!channel->isJoined()) {
if(!channel->joined()) {
account->ui->messageSystem(this, QString("Tried to send a message to '%1' but you are not currently in the channel. Message: %2").arg(channelname).arg(message), MESSAGE_TYPE_FEEDBACK);
return;
}
Expand Down Expand Up @@ -1362,7 +1362,7 @@ void FSession::sendChannelAdvertisement(QString channelname, QString message)
account->ui->messageSystem(this, QString("Tried to send a message to '%1' but the channel is unknown or has never been joined. Message: %2").arg(channelname).arg(message), MESSAGE_TYPE_FEEDBACK);
return;
}
if(!channel->isJoined()) {
if(!channel->joined()) {
account->ui->messageSystem(this, QString("Tried to send a message to '%1' but you are not currently in the channel. Message: %2").arg(channelname).arg(message), MESSAGE_TYPE_FEEDBACK);
return;
}
Expand Down
Loading