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
39 changes: 37 additions & 2 deletions RetroChessPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,31 @@ RetroChessPlugin::RetroChessPlugin()
mPeers = NULL;
config_page = NULL ;
mIcon = NULL ;
mGxsTunnels = NULL;
mIdentity = NULL;
mChats = NULL;

mRetroChessNotify = new RetroChessNotify;
}

void RetroChessPlugin::setInterfaces(RsPlugInInterfaces &interfaces)
{
mPeers = interfaces.mPeers;
mGxsTunnels = interfaces.mGxsTunnels;
mIdentity = interfaces.mIdentity;
mChats = interfaces.mChats;

RsDbg() << "CHESS: setInterfaces: mChats=" << (mChats?"OK":"NULL") << " mGxsTunnels=" << (mGxsTunnels?"OK":"NULL");

if(mRetroChess)
{
RsDbg() << "CHESS: Plugin calling service connections...";
mRetroChess->connectToGxsTunnelService(mGxsTunnels);
RsDbg() << "CHESS: Calling connectToIdentityService";
mRetroChess->connectToIdentityService(mIdentity);
RsDbg() << "CHESS: Calling connectToChatService";
mRetroChess->connectToChatService(mChats);
}
}

/*ConfigPage *RetroChessPlugin::qt_config_page() const
Expand Down Expand Up @@ -124,10 +142,10 @@ ChatWidgetHolder *RetroChessPlugin::qt_get_chat_widget_holder(ChatWidget *chatWi
switch (chatWidget->chatType())
{
case ChatWidget::CHATTYPE_PRIVATE:
case ChatWidget::CHATTYPE_DISTANT:
return new RetroChessChatWidgetHolder(chatWidget, mRetroChessNotify);
case ChatWidget::CHATTYPE_UNKNOWN:
case ChatWidget::CHATTYPE_LOBBY:
case ChatWidget::CHATTYPE_DISTANT:
break;
}

Expand All @@ -137,7 +155,24 @@ ChatWidgetHolder *RetroChessPlugin::qt_get_chat_widget_holder(ChatWidget *chatWi
p3Service *RetroChessPlugin::p3_service() const
{
if(mRetroChess == NULL)
{
rsRetroChess = mRetroChess = new p3RetroChess(mPlugInHandler,mRetroChessNotify) ; // , 3600 * 24 * 30 * 6); // 6 Months
if(mGxsTunnels)
{
RsDbg() << "CHESS: p3_service: calling connectToGxsTunnelService";
mRetroChess->connectToGxsTunnelService(mGxsTunnels);
}
if(mIdentity)
{
RsDbg() << "CHESS: p3_service: calling connectToIdentityService";
mRetroChess->connectToIdentityService(mIdentity);
}
if(mChats)
{
RsDbg() << "CHESS: p3_service: calling connectToChatService";
mRetroChess->connectToChatService(mChats);
}
}

return mRetroChess ;
}
Expand Down Expand Up @@ -181,7 +216,7 @@ std::string RetroChessPlugin::getPluginName() const
return "RetroChess";
}

QTranslator* RetroChessPlugin::qt_translator(QApplication */*app*/, const QString& languageCode, const QString& externalDir) const
QTranslator* RetroChessPlugin::qt_translator(QApplication */*app*/, const QString& /*languageCode*/, const QString& /*externalDir*/) const
{
return NULL;
}
Expand Down
3 changes: 3 additions & 0 deletions RetroChessPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ class RetroChessPlugin: public RsPlugin
mutable ConfigPage *config_page ;
mutable QIcon *mIcon;
mutable MainPage* mainpage ;
mutable RsGxsTunnelService *mGxsTunnels;
mutable RsIdentity *mIdentity;
mutable RsChats *mChats;

RetroChessNotify *mRetroChessNotify ;
RetroChessGUIHandler *mRetroChessGUIHandler ;
Expand Down
16 changes: 8 additions & 8 deletions gui/NEMainpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@

NEMainpage::NEMainpage(QWidget *parent, RetroChessNotify *notify) :
MainPage(parent),
mNotify(notify),
ui(new Ui::NEMainpage)
ui(new Ui::NEMainpage),
mNotify(notify)
{
ui->setupUi(this);
setupMenuActions();

connect(mNotify, SIGNAL(NeMsgArrived(RsPeerId,QString)), this, SLOT(NeMsgArrived(RsPeerId,QString)));
connect(mNotify, SIGNAL(chessStart(RsPeerId)), this, SLOT(chessStart(RsPeerId)));
connect(mNotify, SIGNAL(chessStart(RsPeerId,int)), this, SLOT(chessStart(RsPeerId,int)));
connect(ui->friendSelectionWidget, SIGNAL(itemSelectionChanged()), this, SLOT(friendSelectionChanged()));

// enable/disable the invite button
Expand All @@ -73,9 +73,9 @@ NEMainpage::~NEMainpage()
delete ui;
}

void NEMainpage::chessStart(const RsPeerId &peer_id)
void NEMainpage::chessStart(const RsPeerId &peer_id, int player_id)
{
create_chess_window(peer_id.toStdString(), 0);
create_chess_window(peer_id.toStdString(), player_id);
}

// decode received message here
Expand Down Expand Up @@ -137,7 +137,7 @@ void NEMainpage::NeMsgArrived(const RsPeerId &peer_id, QString str)
{
if (rsRetroChess->hasInviteTo(peer_id))
{
create_chess_window(peer_id.toStdString(), 1);
create_chess_window(peer_id.toStdString(), 1); // Guest plays Black (1)
rsRetroChess->acceptedInvite(peer_id);
}
}
Expand Down Expand Up @@ -201,7 +201,7 @@ void NEMainpage::on_inviteButton_clicked()
if( fid != "") // selected a friend
{
//make_board();
create_chess_window(fid, 1);
create_chess_window(fid, 0); // Inviter plays White (0)

QVariantMap map;
//map.insert("type", "chess_init");
Expand Down Expand Up @@ -255,7 +255,7 @@ void NEMainpage::on_filterPeersButton_clicked()

// get friend 's avatar
QPixmap friend_avatar;
AvatarDefs::getAvatarFromSslId( id, friend_avatar);
rsRetroChess->getAvatar(id, friend_avatar);

rsServiceControl->getServicesAllowed (*it, local_service_perms) ;
rsServiceControl->getServicesProvided(*it,remote_service_perms) ;
Expand Down
2 changes: 1 addition & 1 deletion gui/NEMainpage.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private slots:
void setupMenuActions();
void friendSelectionChanged();
void NeMsgArrived(const RsPeerId &peer_id, QString str);
void chessStart(const RsPeerId &peer_id);
void chessStart(const RsPeerId &peer_id, int player_id);

void on_broadcastButton_clicked();

Expand Down
Loading