/* ****************************************************************
* Subject to the terms and conditions of the LICENSE AGREEMENT FOR
* SDK SOFTWARE, Phone.com, Inc. hereby grants you authorization
* to use UP.SDK software and its related documentation.
*
* Unwired Planet, the Phone.com logo, UP.Phone, UP.Link, UP.Organizer
* UP.Browser, UP.Access, UP.Mail, UP.Pager, UPLANET.COM and
* UP.SDK are trademarks of Unwired Planet, Inc.
*
******************************************************************/
/****************************************************************
* This is a simple command line utility that allows a user to
* send a Non-Secure notifciation to a subscriber on the devgate2.uplanet.com
* UP.Link. The alert will be sent with a tilte of "Alert Me" and
* with a URL that points to the index.wml deck of the UP.SDK Sample
* code. This application takes the subscriber ID as a command line argument.
* The subscriber ID can be found by using the Find Subsciber utility on the
* provisioning pages of the devgate2 UP.Link at
* http://updev.uplanet.com/dev/ts/up/gold_provision.html
*
* This file is designed to be built under Microsoft Visual C++ 5.0
* and needs to be linked with UPnotify_i.c. UPnotify_i.c is included
* with the UP.SDK and can be found in:
* <UP.SDK Install dir>\examples\source\vc\SendNtfn
*
*
* simpleNotify.cpp
*
* Version 1.0
*
* June 1, 1999
*
****************************************************************/
#include <iostream.h>
#include "UPnotify.h"
int main(int argc, char *argv[])
{
if (argc != 2){
cout << "You need to supply the subscriber ID \n";
cout << "i.e: c:\\simpleNotify 859852091-4877_devgate2.uplanet.com \n\n";
cout << "You can find out your subscriber ID by viewing your \n";
cout << "provisioned accounts on the devgate2 UP.Link. To do this \n";
cout << "use the find subscriber button on the provisioning pages \n";
cout << "at http://updev.uplanet.com/dev/ts/up/gold_provision.html \n";
return -1;
}
// Initialize COM.
CoInitialize( NULL );
INtfn3Client *m_Ntfn;
// Create ptr to the Notification Interface
// (Non-Secure).
int result = CoCreateInstance( CLSID_Ntfn3Client, NULL, CLSCTX_SERVER,
IID_INtfn3Client, (void**)&m_Ntfn);
// Create ptr to the Notification Interface
// (Secure).
// int result = CoCreateInstance( CLSID_NtfnS3Client, NULL, CLSCTX_SERVER,
// IID_INtfnS3Client, (void**)&m_Ntfn);
// Declare variables
const char* m_AlertTitle;
const char* m_AlertType;
const char* m_HostName;
const char* m_SubscriberID;
long m_TTL;
const char* m_Url;
// Declare variables as appropriate to pass to COM Object
OLECHAR host[256];
OLECHAR subs[256];
OLECHAR url[256];
OLECHAR alertTitle[256];
OLECHAR alertType[256];
HRESULT the_result;
// Set Values of Variables
m_TTL = 0;
m_AlertType = "D---";
m_AlertTitle = "My Alert";
m_Url = "http://updev.uplanet.com/dev/sdk.31w/examples/wml/index.wml";
m_SubscriberID = argv[1];
m_HostName = "devgate2.uplanet.com";
// Convert the standard ansi strings to Unicode (WCS)
// strings. The COM interface expects WCS BSTR's.
mbstowcs(host, m_HostName, sizeof(host));
mbstowcs(subs, m_SubscriberID, sizeof(subs));
mbstowcs(url, m_Url, sizeof(url));
mbstowcs(alertTitle, m_AlertTitle, sizeof(alertTitle));
mbstowcs(alertType, m_AlertType, sizeof(alertType));
// Set the UP.Link to which you will send the notification
the_result = m_Ntfn->NtfnSetHost (host);
// Send the Notification and check the result
if (S_OK != m_Ntfn->NtfnPostAlert (subs, url, m_TTL, alertType, alertTitle, 0)){
cout << "Alert Failed! \n";
}
else {
cout << "Alert Success! \n";
}
// Rlease the pointer to the Notification library
// Unload the COM object, and exit.
m_Ntfn->Release();
CoUninitialize();
return 0;
}