📄 adapters.h
字号:
/*
** Copyright (C) 2005 Darrell Karbott (djk2005@users.sf.net)
** This code is free software; you can redistribute it and/or modify
** it under the terms of the GNU Public Licence (GPL) version 2 See
** http://www.gnu.org/ for further details of the GPL.
*/
#ifndef __ADAPTERS_H__
#define __ADAPTERS_H__ 1
#include <e32base.h>
#include "iksdemo.h"
/*
** These interfaces and classes encapsulate the parameter translation
** required to go from the const char* strings used by CIksDemo to
** Symbian TDesC& descriptors and back.
**
** This feels a bit overdesigned but it keeps a lot of repetitions,
** ugly, and error prone code out of the Symbian sources.
*/
// Translate IUserInterface to use Symbian idioms.
class MIksDemoUserInterface {
public:
virtual ~MIksDemoUserInterface() = 0;
virtual void DisplayJabberMsgFrom(const TDesC& from, const TDesC& msg ) = 0;
virtual void DisplayStatusMsg(const TDesC& msg) = 0;
virtual void DisplayErrorMsg(const TDesC& msg) = 0;
virtual void UpdateConnectionStatus(TBool) = 0;
};
// Translate IUserInterface to use Symbian idioms.
class MIksDemoUserInteractions {
public:
virtual ~MIksDemoUserInteractions() = 0;
virtual TInt Connect(const TDesC& jid, const TDesC& password, TInt port) = 0;
virtual void Disconnect() = 0;
virtual TInt SendMsg(const TDesC&, const TDesC&) = 0;
};
/*
** Helper class translates calls into IUserInterface into calls into
** MIksDemoUserInterface.
*/
class CIksDemoUserInterfaceAdapter : public CBase, public IUserInterface {
public:
CIksDemoUserInterfaceAdapter(MIksDemoUserInterface* target);
~CIksDemoUserInterfaceAdapter();
public:
virtual void displayJabberMsgFrom(const char* from, const char* msg );
virtual void displayStatusMsg(const char* msg);
virtual void displayErrorMsg(const char* msg);
// REDFLAG: remove this?
virtual void updateConnectionStatus(int bConnected);
private:
MIksDemoUserInterface* iTarget;
};
/*
** Helper class translates calls into MIksDemoUserInteractions into calls
** into IUserInteractions.
*/
class CIksDemoUserInteractionsAdapter : public CBase, public MIksDemoUserInteractions {
public:
CIksDemoUserInteractionsAdapter(IUserInteractions* target);
~CIksDemoUserInteractionsAdapter();
public:
virtual TInt Connect(const TDesC& jid, const TDesC& password, TInt port);
virtual void Disconnect();
virtual TInt SendMsg(const TDesC&, const TDesC&);
private:
IUserInteractions* iTarget;
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -