發文作者:wekon | 十一月 11, 2009

Making phone call on windows mobile

//—————————————————————————–
// MakePhoneCall
//—————————————————————————–


#include <tapi.h>
#include <phone.h>

void GearsLocalServer::MakePhoneCall(JsCallContext *context) {

std::string16 number;
std::string16 required_cookie;
if (!GetAndCheckParameters(context, &number, &required_cookie))
return;

std::string number_ascii;
String16ToUTF8(number.c_str(), number.length(), &number_ascii);
std::string required_cookie_ascii;
String16ToUTF8(required_cookie.c_str(), required_cookie.length(),
&required_cookie_ascii);

PHONEMAKECALLINFO pmci;
memset(&pmci, 0, sizeof(pmci));
pmci.cbSize = sizeof(pmci);
pmci.dwFlags = PMCF_DEFAULT;

WCHAR tmp[64];
swprintf(tmp, L"%S", number_ascii.c_str());
pmci.pszDestAddress = tmp;

(void)PhoneMakeCall(&pmci);

}

//——————————————————————————
// GetAndCheckParameters
//——————————————————————————
bool GearsLocalServer::GetAndCheckParameters(JsCallContext *context,
std::string16 *name,
std::string16 *required_cookie) {
JsArgument argv[] = {
{ JSPARAM_REQUIRED, JSPARAM_STRING16, name },
{ JSPARAM_OPTIONAL, JSPARAM_STRING16, required_cookie },
};
context->GetArguments(ARRAYSIZE(argv), argv);
if (context->is_exception_set())
return false;

// Validate parameters
if (name->empty()) {
context->SetException(STRING16(L"The name parameter is required."));
return false;
}

std::string16 error_message;
if (!IsUserInputValidAsPathComponent(*name, &error_message)) {
context->SetException(error_message.c_str());
return false;
}

return true;
}

Finally, add phone.lib in make file


發表迴響

在下方填入你的資料或按右方圖示以社群網站登入:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 變更 )

Twitter picture

You are commenting using your Twitter account. Log Out / 變更 )

Facebook照片

You are commenting using your Facebook account. Log Out / 變更 )

Google+ photo

You are commenting using your Google+ account. Log Out / 變更 )

連結到 %s

分類

%d 位部落客按了讚: