// OnlDial.cpp : Implementation of COnlDial
#include "stdafx.h"
#include "OnlineDialog.h"
#include "OnlDial.h"

// cpapa
#include <string.h>
#include <stdlib.h>
#include <malloc.h>
#include "WebInterface.H"

/////////////////////////////////////////////////////////////////////////////
// COnlDial

STDMETHODIMP COnlDial::InterfaceSupportsErrorInfo(REFIID riid)
{
	static const IID* arr[] = 
	{
		&IID_IOnlDial,
	};
	for (int i=0;i<sizeof(arr)/sizeof(arr[0]);i++)
	{
		if (InlineIsEqualGUID(*arr[i],riid))
			return S_OK;
	}
	return S_FALSE;
}


STDMETHODIMP COnlDial::ProcessUserSays(int currentState, BSTR bstrUserSays, BSTR *bstrAsstSays)
{
	USES_CONVERSION;
	// TODO: Add your implementation code here
	// cpapa: this is basic and bogus
	CComBSTR bstrText("");
	bstrText="This is some eassistant response.";

	char **nextState;
//	nextState=webProcessInput("Sassy McCrafty", "Sassy.spec", "demo.txt", 12, "show me more info, please");
	//nextState=webProcessInput("Sassy McCrafty", "Sassy.spec", "demo.txt", currentState, (char*)LPCWSTR(bstrAsstSays));
//#if 0
	nextState=new char*[2];
	nextState[0]=new char[100];
	nextState[1]=new char[100];
	strcpy(nextState[0],"first part of info...");
	strcpy(nextState[1],"second part of info...");
//#endif
	CComBSTR realreturn=A2BSTR(strcat(nextState[0],nextState[1]));	
	free(nextState[0]);
	free(nextState[1]);
	free(nextState);	
	*bstrAsstSays=realreturn.Detach();
	return S_OK;
}
