Tuesday, September 25, 2007

SmileySMS and En2FaMail are now v1.53

Well,
Lots of changes happened during past month,and now both applications have plugins for Inbox,so you can also see smiles (and in case of En2FaMail,you Persian text + smilies) in you inbox too!

Hope you enjoyed this program so far!
Here i attached my updated Pictures of these programs.

SmileySMS


En2FaMail

Thursday, September 13, 2007

MAPI : how to delete a message(or move it into trash)?

Well.
I think deleting a message is rather easy,but i find moving a message instead to trash or wastebasket folder is not that easy.
Here is a function i use to determine the wastebasket folder.So i can use IFolder,CopyMessages routine with MAPI_MOVE flag to move my message there!

HRESULT GetWastebasketForFolder(IMAPISession *m_pSession,LPMAPIFOLDER pFolder,
LPMAPIFOLDER* ppfldrWastebasket)
{
HRESULT hr = E_FAIL;
IMsgStore* pms = NULL;
ULONG cItems;
ULONG rgtagsFldr[] = { 1, PR_OWN_STORE_ENTRYID };
ULONG rgtagsMsgStore[] = { 1, PR_IPM_WASTEBASKET_ENTRYID };
LPSPropValue rgprops = NULL;

// This method assumes that the CALLER already logged on to a MAPISession
if (!m_pSession)
CHR(E_FAIL);

// Now request the PR_OWN_STORE_ENTRYID on the folder. This is the
// ENTRYID of the message store that owns the folder object.
hr = pFolder->GetProps((LPSPropTagArray)rgtagsFldr, MAPI_UNICODE, &cItems, &rgprops);
CHR(hr);

CBR(PR_OWN_STORE_ENTRYID == rgprops[0].ulPropTag);

// Now open the message store object.
hr = m_pSession->OpenEntry(rgprops[0].Value.bin.cb,
(LPENTRYID)rgprops[0].Value.bin.lpb,
NULL, 0, NULL, (LPUNKNOWN*)&pms);
CHR(hr);

MAPIFreeBuffer(rgprops);
rgprops = NULL;

// Get the ENTRYID of the wastebasket for the message store
hr = pms->GetProps((LPSPropTagArray)rgtagsMsgStore, MAPI_UNICODE, &cItems, &rgprops);
CHR(hr);

// Now open the correct wastebasket and return it to the caller.
CBR(PR_IPM_WASTEBASKET_ENTRYID == rgprops[0].ulPropTag);

hr = m_pSession->OpenEntry(rgprops[0].Value.bin.cb,
(LPENTRYID)rgprops[0].Value.bin.lpb,
NULL, 0, NULL, (LPUNKNOWN*)ppfldrWastebasket);
CHR(hr);

Error:
MAPIFreeBuffer(rgprops);
RELEASE_OBJ(pms);

return hr;
}



and you call it like this :
GetWastebasketForFolder(pSession,pFolder,&pWasteBasket);


pFolder is a folder where you message is.
And moving is done like this.
pFolder->CopyMessages(&lst, NULL, pWasteBasket, 0, NULL, MAPI_MOVE);


Probably you might know that lst is ENTRYLIST and you construct it like this!
lst.cValues = 1;
sbin.cb = pspvEntryID->Value.bin.cb;
sbin.lpb = (LPBYTE) pspvEntryID->Value.bin.lpb;
lst.lpbin = &sbin;


And pspvEntryID is what i get from calling GetProps to getting this message property ids.

Saturday, September 8, 2007

SmileySMS Program


Well,i removed the Persian/fingilish translations materials from En2FaMail program,and released another program called SmileySMS in xda-developers today.

Here are list of things that this program do:

- Shows and displays smilies found in SMS texts.
- Assign .mp3,.ogg,.wav,.mod and other popular music file formats as your SMS ring tones.
- Remove phone number from the title of SMS notification,when the contact is known.
- Replace number in body of delivery report with the name of contact.
- Show pictures of contacts in SMS notification.
- Easier to use menus for working with SMS notifications.
- WM5.0 like notifications for WM2003 users.
- Support for vibrate.
- All features(including program) are configurable through control panel.

And of course En2FaMail does all these too.

Vibrating your PocketPC device!

How to vibrate a PocketPC WM5.0 or 2003 device?

In smartphone platforms there is a Vibrate API which you can use.
Although MSDN mentioned that it exist in WM5.0,it isn't.
There was a mistake in MSDN documentations.

Searching all over internet I find that there are 2 ways to achieve this.
One way is to use Notify functions like CeSetUserNotificationEx,and setting trigger time to now.
But unless you display a dialog(using PUN_DIALOG),you can't use it and also it seems user settings override your program settings!

Another way is using NLed functions.
Although all people in Google groups and also Microsoft MVPs,mentioned there is no way to know the led number of vibrator,I find out when you use NLedGetDeviceInfo on a Led slot,and the lCycleAdjust is -1, it is your device vibrator's led number!


Here is the code I've written to use vibrate of my device!
I also checked it on some other devices and they all worked!

void LedOn(int id)
{
NLED_SETTINGS_INFO settings;
if (id < 0)
return;
settings.LedNum= id;
settings.OffOnBlink= 1;
NLedSetDevice(NLED_SETTINGS_INFO_ID, &settings);
}

void LedOff(int id)
{
NLED_SETTINGS_INFO settings;
if (id < 0)
return;
settings.LedNum= id;
settings.OffOnBlink= 0;
NLedSetDevice(NLED_SETTINGS_INFO_ID, &settings);
}

int GetVibratorLedNum(void)//-1 means no vibrator
{
NLED_COUNT_INFO nci;
int wCount = 0,VibrLed = -1;
NLED_SUPPORTS_INFO sup;

if(NLedGetDeviceInfo(NLED_COUNT_INFO_ID, (PVOID) &nci))
wCount = (int) nci.cLeds;

for (int i=0;i<wCount;i++)
{
sup.LedNum = i;
NLedGetDeviceInfo(NLED_SUPPORTS_INFO_ID,&sup);
if (sup.lCycleAdjust == -1)
{
VibrLed = i;
break;
}
}
return VibrLed;
}- param1 + 1



You also need to add these to your source files!


#include
extern "C" {
BOOL WINAPI NLedGetDeviceInfo( UINT nInfoId, void *pOutput );
BOOL WINAPI NLedSetDevice( UINT nDeviceId, void *pInput );
};



Also note that most PocketPcs do not support vibrators,mostly PocketPc Phone editions do.