Help - Search - Members - Calendar
Full Version: Visual Studio MFC C DLL and Skype
Skype Community > English > Development, Betas and Skype Garage > Skype Public API
MrTAToad_
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
noonius_
Hi,

Could you please clarify your question, are you claiming that you are receiving SkypeControlAPIAttach messages with lParam value of SKYPECONTROLAPI_ATTACH_SUCCESS even if access is actually refused? This doesn't sound very probable, at least if you are using a recent version (some older API versions didn't use lParam value of SkypeControlAPIAttach message so they may have returned success (which has a value of 0)).

Some comments about your code, though:

* You cannot always expect to receive SKYPECONTROLAPI_ATTACH_PENDING_AUTHORIZATION status message: if your application is in the ACL with either accept or reject attribute, you will immediately receive a refuse or accept message. PENDING_AUTHORIZATION is only used when skype is waiting for user input.

* Your code sets processState = STATE_HASAUTHORISED upon receiving REFUSED status code, perhaps this is where the problem is?

* You shouldn't use message boxes in the message procedure, these will block execution of your message handler and will get your application detached due to timeout.


Regards,

Erik
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.