Hello
I'm trying to process the Skype messages in a OnWndMessage MFC handler. Unfortunately SKYPECONTROLAPI_ATTACH_SUCCESS is continually being returned even after the program has been refused access to Skype. This means an ineffective state machine has to be used, but the problem then arises with the PENDING part.
For those interested, the code is as follows :
// Dummy.cpp : implementation file
//
#include "stdafx.h"
#include "DBSkype.h"
#include "Dummy.h"
#include ".dummy.h"
extern UINT uiGlobal_MsgID_SkypeControlAPIAttach;
extern UINT *lResult;
extern UINT processState;
#define STATE_IGNORE 0
#define STATE_PENDINGAUTHORISATION 1
#define STATE_HASAUTHORISED 2
enum {
SKYPECONTROLAPI_ATTACH_SUCCESS=0, // Client is successfully attached and API window handle can be found in wParam parameter
SKYPECONTROLAPI_ATTACH_PENDING_AUTHORIZATION=1, // Skype has acknowledged connection request and is waiting for confirmation from the user.
// The client is not yet attached and should wait for SKYPECONTROLAPI_ATTACH_SUCCESS message
SKYPECONTROLAPI_ATTACH_REFUSED=2, // User has explicitly denied access to client
SKYPECONTROLAPI_ATTACH_NOT_AVAILABLE=3, // API is not available at the moment. For example, this happens when no user is currently logged in.
// Client should wait for SKYPECONTROLAPI_ATTACH_API_AVAILABLE broadcast before making any further
// connection attempts.
SKYPECONTROLAPI_ATTACH_API_AVAILABLE=0x8001
};
// CDummy dialog
IMPLEMENT_DYNAMIC(CDummy, CDialog)
CDummy::CDummy(CWnd* pParent /*=NULL*/)
: CDialog(CDummy::IDD, pParent)
{
}
CDummy::~CDummy()
{
}
void CDummy::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CDummy, CDialog)
END_MESSAGE_MAP()
// CDummy message handlers
BOOL CDummy::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
return CDialog::PreTranslateMessage(pMsg);
}
LRESULT CDummy::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
// TODO: Add your specialized code here and/or call the base class
return CDialog::WindowProc(message, wParam, lParam);
}
BOOL CDummy::OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
// TODO: Add your specialized code here and/or call the base class
switch (message) {
case WM_COPYDATA : //
break;
default :
if (message=uiGlobal_MsgID_SkypeControlAPIAttach )
{
switch (lParam) {
case SKYPECONTROLAPI_ATTACH_PENDING_AUTHORIZATION: // Waiting for authorisation
DefWindowProc(message, wParam, lParam);
processState=STATE_PENDINGAUTHORISATION;
break;
case SKYPECONTROLAPI_ATTACH_REFUSED: // Connection refused
switch (processState) {
case STATE_IGNORE : break;
case STATE_PENDINGAUTHORISATION : *lResult=0;
processState=STATE_HASAUTHORISED;
MessageBox("R","*",MB_OK);
break;
};
break;
case SKYPECONTROLAPI_ATTACH_SUCCESS: // Connection succeeded
switch (processState) {
case STATE_IGNORE : break;
case STATE_PENDINGAUTHORISATION : *lResult=1;
processState=STATE_HASAUTHORISED;
MessageBox("O","*",MB_OK);
break;
};
break;
};
}
};
return CDialog::OnWndMsg(message, wParam, lParam, pResult);
}
LRESULT CDummy::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
// TODO: Add your specialized code here and/or call the base class
return CDialog::DefWindowProc(message, wParam, lParam);
}
As far as I can tell, the correct window processing function is being used, so can anyone tell me how to stop the SUCCESS being returned when it shouldn't be. I have found using the Windows API to do everything (instead of MFC), this problem doesn't occur.
Nicholas