📄 mobilesyncdlg.cpp
字号:
// TODO: Add your control notification handler code here
OP_UINT8 Cmd[1500];
PBOOK_ITEM_T PbookItem;
OP_UINT8 ItemData[sizeof(PBOOK_ITEM_T)];
OP_UINT16 ItemLen;
WCHAR UniStr[] = L"aaaaaaaaaabbbbbb";
Cmd[0] = 0x02;
Cmd[1] = 0x05;
memset(&PbookItem, 0x00, sizeof(PbookItem));
PbookItem.Device = 2;
PbookItem.Record = 10;
memcpy(PbookItem.Name, L"aaaaaaaaaabbbbbb", 34);
memcpy(PbookItem.Mobile, "0123456789012345678901234567890", 32);
memcpy(PbookItem.Home, "0123456789012345678901234567890", 32);
memcpy(PbookItem.Office, "0123456789012345678901234567890", 32);
memcpy(PbookItem.Email, "aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffggg", 64);
memcpy(PbookItem.Qq, "0123456789", 11);
memcpy(PbookItem.Memo, L"aaaaaaaaaabbbbbbbbbbcccccccccc", 62);
PbookItem.Group = 1;
if (syncPbookItemToStream(&PbookItem, ItemData, &ItemLen))
{
memcpy(Cmd+2, ItemData, ItemLen);
OutText("Send save Command.\n");
comm_send_command(Cmd, ItemLen+2);
}
else
{
OutText("Send save Command error.\n");
}
}
OP_BOOLEAN CMobileSyncDlg::syncPbookItemToStream
(
PBOOK_ITEM_T *pstPbookItem,
OP_UINT8 *pPbookData,
OP_UINT16 *pDataLen
)
{
OP_UINT16 Length = 0;
OP_UINT16 FieldLen;
if ((pstPbookItem == OP_NULL) || (pPbookData == OP_NULL) || (pDataLen == OP_NULL))
{
return OP_FALSE;
}
memcpy(pPbookData+2, &pstPbookItem->Device, 1);
memcpy(pPbookData+3, &pstPbookItem->Record, 2);
Length = 5;
//name
FieldLen = wcslen(pstPbookItem->Name)*2;
if (FieldLen > 0)
{
memset(pPbookData+Length, 0x01, 1);
memcpy(pPbookData+Length+1, &FieldLen, 2);
memcpy(pPbookData+Length+3, pstPbookItem->Name, FieldLen);
Length = Length + 3 + FieldLen;
}
//mobile
FieldLen = strlen(pstPbookItem->Mobile);
if (FieldLen > 0)
{
memset(pPbookData+Length, 0x02, 1);
memcpy(pPbookData+Length+1, &FieldLen, 2);
memcpy(pPbookData+Length+3, pstPbookItem->Mobile, FieldLen);
Length = Length + 3 + FieldLen;
}
//home
FieldLen = strlen(pstPbookItem->Home);
if (FieldLen > 0)
{
memset(pPbookData+Length, 0x03, 1);
memcpy(pPbookData+Length+1, &FieldLen, 2);
memcpy(pPbookData+Length+3, pstPbookItem->Home, FieldLen);
Length = Length + 3 + FieldLen;
}
//office
FieldLen = strlen(pstPbookItem->Office);
if (FieldLen > 0)
{
memset(pPbookData+Length, 0x04, 1);
memcpy(pPbookData+Length+1, &FieldLen, 2);
memcpy(pPbookData+Length+3, pstPbookItem->Office, FieldLen);
Length = Length + 3 + FieldLen;
}
//email
FieldLen = strlen(pstPbookItem->Email);
if (FieldLen > 0)
{
memset(pPbookData+Length, 0x05, 1);
memcpy(pPbookData+Length+1, &FieldLen, 2);
memcpy(pPbookData+Length+3, pstPbookItem->Email, FieldLen);
Length = Length + 3 + FieldLen;
}
//qq
FieldLen = strlen(pstPbookItem->Qq);
if (FieldLen > 0)
{
memset(pPbookData+Length, 0x06, 1);
memcpy(pPbookData+Length+1, &FieldLen, 2);
memcpy(pPbookData+Length+3, pstPbookItem->Qq, FieldLen);
Length = Length + 3 + FieldLen;
}
//memo
FieldLen = wcslen(pstPbookItem->Memo)*2;
if (FieldLen > 0)
{
memset(pPbookData+Length, 0x07, 1);
memcpy(pPbookData+Length+1, &FieldLen, 2);
memcpy(pPbookData+Length+3, pstPbookItem->Memo, FieldLen);
Length = Length + 3 + FieldLen;
}
//group
FieldLen = 1;
memset(pPbookData+Length, 0x08, 1);
memcpy(pPbookData+Length+1, &FieldLen, 2);
memcpy(pPbookData+Length+3, &pstPbookItem->Group, 1);
Length = Length + 4;
//portrait
if (pstPbookItem->Portrait > 0)
{
FieldLen = 4;
memset(pPbookData+Length, 0x09, 1);
memcpy(pPbookData+Length+1, &FieldLen, 2);
memcpy(pPbookData+Length+3, &pstPbookItem->Portrait, 4);
Length = Length + 7;
}
*pDataLen = Length;
//item length
Length = Length - 2;
memcpy(pPbookData, &Length, 2);
return OP_TRUE;
}
void CMobileSyncDlg::OnPbRead()
{
// TODO: Add your control notification handler code here
OP_UINT16 Index;
OP_UINT8 Cmd[5];
Index = 1;
Cmd[0] = 0x02;
Cmd[1] = 0x02;
Cmd[2] = 0x02; //device
memcpy(Cmd+3, &Index, 2);
// Cmd[3] = 0x04;
// Cmd[4] = 0x01;
OutText("Send read Command.\n");
comm_send_command(Cmd, sizeof(Cmd));
}
void CMobileSyncDlg::OutPbook(PBOOK_ITEM_T *pbitem)
{
CString strText;
char ascstr[50];
OutText("get a phone book.\n");
strText.Format("Device=%d, Record=%d\n", pbitem->Device, pbitem->Record);
OutText(strText);
WideCharToMultiByte(CP_ACP, 0 , pbitem->Name, -1, ascstr, 50, 0, 0);
strText.Format("Name=%s\n", ascstr);
OutText(strText);
strText.Format("Mobile=%s\n", pbitem->Mobile);
OutText(strText);
strText.Format("Home=%s\n", pbitem->Home);
OutText(strText);
strText.Format("Office=%s\n", pbitem->Office);
OutText(strText);
strText.Format("Email=%s\n", pbitem->Email);
OutText(strText);
strText.Format("QQ=%s\n", pbitem->Qq);
OutText(strText);
WideCharToMultiByte(CP_ACP, 0 , pbitem->Memo, -1, ascstr, 50, 0, 0);
strText.Format("Memo=%s\n", ascstr);
OutText(strText);
strText.Format("Group=%d, Portrait=%d\n", pbitem->Group, pbitem->Portrait);
OutText(strText);
}
void CMobileSyncDlg::OutSms(SMS_ITEM_T *smsitem)
{
CString strText;
char ascstr[2500];
OutText("get a sms.\n");
strText.Format("ListType=%d, StorageType=%d\n", smsitem->ListType, smsitem->StorageType);
OutText(strText);
strText.Format("MsgType=%d, MsgRef=%d, status=%d\n", smsitem->MsgType, smsitem->MsgRef, smsitem->Status);
OutText(strText);
strText.Format("ServiceCenter=%s\n", smsitem->ServiceCenter);
OutText(strText);
strText.Format("TimeStamp=%d %d %d %d %d %d %d\n", smsitem->TimeStamp[0], smsitem->TimeStamp[1],
smsitem->TimeStamp[2], smsitem->TimeStamp[3], smsitem->TimeStamp[4], smsitem->TimeStamp[5], smsitem->TimeStamp[6]);
OutText(strText);
strText.Format("Number=%s\n", smsitem->Number);
OutText(strText);
strText.Format("MsgLen=%d\n", smsitem->MsgLen);
OutText(strText);
memset(ascstr, 0x00, 2500);
WideCharToMultiByte(CP_ACP, 0 , (wchar_t*)smsitem->pContent, -1, ascstr, 2500, 0, 0);
strText.Format("Content=%s\n", ascstr);
//strText.Format("Content=%s", smsitem->pContent);
OutText(strText);
OutText("\n");
}
void CMobileSyncDlg::OnPbDelete()
{
// TODO: Add your control notification handler code here
OP_UINT16 Record;
OP_UINT8 Cmd[6];
Record = 1;
Cmd[0] = 0x02; //module
Cmd[1] = 0x03; //command
Cmd[2] = 0x03; //deletetype
Cmd[3] = 0x02; //device
memcpy(Cmd+4, &Record, 2);
OutText("Send delete Command.\n");
comm_send_command(Cmd, sizeof(Cmd));
}
void CMobileSyncDlg::OnPbDeleteall()
{
// TODO: Add your control notification handler code here
//OP_UINT16 Index;
OP_UINT8 Cmd[3];
//Index = 1;
Cmd[0] = 0x02; //module
Cmd[1] = 0x03; //command
Cmd[2] = 0x02; //deletetype
OutText("Send delete all Command.\n");
comm_send_command(Cmd, sizeof(Cmd));
}
void CMobileSyncDlg::OnPbUpdate()
{
// TODO: Add your control notification handler code here
OP_UINT8 Cmd[1500];
PBOOK_ITEM_T PbookItem;
OP_UINT8 ItemData[sizeof(PBOOK_ITEM_T)];
OP_UINT16 ItemLen;
WCHAR UniStr[] = L"upatetest";
Cmd[0] = 0x02;
Cmd[1] = 0x04;
memset(&PbookItem, 0x00, sizeof(PbookItem));
PbookItem.Device = 2;
PbookItem.Record = 1;
memcpy(PbookItem.Name, UniStr, wcslen(UniStr)*2);
memcpy(PbookItem.Mobile, "123456789", 10);
memcpy(PbookItem.Home, "123456789", 10);
memcpy(PbookItem.Office, "1234567890", 11);
memcpy(PbookItem.Email, "test@test", 10);
memcpy(PbookItem.Qq, "0123456789", 11);
memcpy(PbookItem.Memo, UniStr, wcslen(UniStr)*2);
PbookItem.Group = 3;
PbookItem.Portrait = 0x0b5deb14;
if (syncPbookItemToStream(&PbookItem, ItemData, &ItemLen))
{
memcpy(Cmd+2, ItemData, ItemLen);
OutText("Send update Command.\n");
comm_send_command(Cmd, ItemLen+2);
}
else
{
OutText("Send update Command error.\n");
}
}
void CMobileSyncDlg::OnSmsSend()
{
// TODO: Add your control notification handler code here
OP_UINT8 Cmd[400];
OP_UINT16 DataLen;
SMS_ITEM_T SmsItem;
WCHAR szContent[70];
Cmd[0] = 0x03;
Cmd[1] = 0x05;
memset(&SmsItem, 0x00, sizeof(SmsItem));
//strcpy((char*)SmsItem.Number, "13651203391");
strcpy((char*)SmsItem.Number, "13701123275");
wcscpy(szContent, L"能收到短信吗,我是用pc发送的。");
SmsItem.pContent = (OP_UINT8*)szContent;
SmsItem.MsgLen = wcslen(szContent)*2;
syncSmsItemToStream(&SmsItem, Cmd+2, &DataLen);
OutText("Send send sms Command.\n");
comm_send_command(Cmd, DataLen+2);
}
OP_BOOLEAN CMobileSyncDlg::syncSmsItemToStream
(
SMS_ITEM_T *pstSmsItem,
OP_UINT8 *pSmsData,
OP_UINT16 *pDataLen
)
{
if ((pstSmsItem == OP_NULL) || (pSmsData == OP_NULL) || (pDataLen == OP_NULL))
{
return OP_FALSE;
}
memcpy(pSmsData, &pstSmsItem->ListType, 1);
memcpy(pSmsData+1, &pstSmsItem->StorageType, 1);
memcpy(pSmsData+2, &pstSmsItem->MsgType, 1);
memcpy(pSmsData+3, &pstSmsItem->MsgRef, 1);
memcpy(pSmsData+4, &pstSmsItem->Status, 1);
memcpy(pSmsData+5, pstSmsItem->ServiceCenter, 22);
memcpy(pSmsData+27, pstSmsItem->TimeStamp, 7);
memcpy(pSmsData+34, pstSmsItem->Number, 22);
memcpy(pSmsData+56, &pstSmsItem->MsgLen, 4);
memcpy(pSmsData+60, pstSmsItem->pContent, pstSmsItem->MsgLen);
*pDataLen = pstSmsItem->MsgLen + 60;
return OP_TRUE;
}
void CMobileSyncDlg::OnSmsStore()
{
// TODO: Add your control notification handler code here
OP_UINT8 Cmd[1500];
OP_UINT16 DataLen;
SMS_ITEM_T SmsItem;
WCHAR szContent[1234];
char timestamp[7] = {4, 3, 3, 14, 30, 30, 0};
// char test[20];
Cmd[0] = 0x03;
Cmd[1] = 0x04;
memset(&SmsItem, 0x00, sizeof(SmsItem));
SmsItem.ListType = 0x03; //list
SmsItem.StorageType = 0x03; //device
SmsItem.MsgRef = 0;
//strcpy((char*)SmsItem.ServiceCenter, "987654321");
// memcpy(SmsItem.TimeStamp, timestamp, 7);
strcpy((char*)SmsItem.Number, "13651203391");
wcscpy(szContent, L"store modified sms dsafasdfaaaadfffffffffffffffadfadsfasdfasdfasdfasdf \
asdffffffffffffffffffffffffffffffffffffffffffffffffasdfadfasdfasdfadff \
dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd ");
// wcscpy(szContent, L"我说明显");
// strcpy(test, "我说明显");
SmsItem.pContent = (OP_UINT8*)szContent;
SmsItem.MsgLen = wcslen(szContent)*2+2;
syncSmsItemToStream(&SmsItem, Cmd+2, &DataLen);
OutText("Send store sms Command.\n");
comm_send_command(Cmd, DataLen+2);
}
void CMobileSyncDlg::OnSmsStatus()
{
// TODO: Add your control notification handler code here
OP_UINT8 Cmd[4] = {0x03, 0x01};
OP_UINT8 List;
OP_UINT8 Device;
UpdateData();
if (m_nRadioSms == 0)
{
List = m_nRadioInbox + 1;
}
else
{
List = 0x07;
}
Device = m_nRadioSim + 1;
Cmd[2] = List;
Cmd[3] = Device;
OutText("Send Inquire Status Command.\n");
comm_send_command(Cmd, sizeof(Cmd));
}
void CMobileSyncDlg::OnSmsRead()
{
// TODO: Add your control notification handler code here
OP_UINT16 Index, Count;
OP_UINT8 List, Device;
OP_UINT8 Cmd[8] = {0x03, 0x02};
Index = 0;
Count = 0;
UpdateData();
if (m_nRadioSms == 0)
{
List = m_nRadioInbox + 1;
}
else
{
List = 0x07;
}
Device = m_nRadioSim + 1;
Cmd[2] = List;
Cmd[3] = Device;
Index = m_nEditIndex;
memcpy(Cmd+4, &Index, 2);
memcpy(Cmd+6, &Count, 2);
OutText("Send read Command.\n");
comm_send_command(Cmd, sizeof(Cmd));
}
void CMobileSyncDlg::OnSmsDelete()
{
// TODO: Add your control notification handler code here
OP_UINT16 Index;
OP_UINT8 List, Device;
OP_UINT8 Cmd[6] = {0x03, 0x03};
UpdateData();
if (m_nRadioSms == 0)
{
Device = m_nRadioSim + 1;
}
else
{
Device = 0x03;
}
List = m_nRadioInbox + 1;
Cmd[2] = List;
Cmd[3] = Device;
Index = m_nEditIndex;
memcpy(Cmd+4, &Index, 2);
OutText("Send delete Command.\n");
comm_send_command(Cmd, sizeof(Cmd));
}
void CMobileSyncDlg::OnCommRequest()
{
// TODO: Add your control notification handler code here
OP_UINT8 Cmd[2] = {0x00, 0x01};
OutText("Send Request Command.\n");
comm_send_command(Cmd, sizeof(Cmd));
}
void CMobileSyncDlg::OnCommTerminate()
{
// TODO: Add your control notification handler code here
OP_UINT8 Cmd[2] = {0x00, 0x02};
OutText("Send Terminate Command.\n");
comm_send_command(Cmd, sizeof(Cmd));
}
void CMobileSyncDlg::OnCommModel()
{
// TODO: Add your control notification handler code here
OP_UINT8 Cmd[2] = {0x00, 0x03};
OutText("Send Inquire Model Command.\n");
comm_send_command(Cmd, sizeof(Cmd));
}
void CMobileSyncDlg::OnButtonPortrait()
{
// TODO: Add your control notification handler code here
OP_UINT8 Cmd[6] = {0x02, 0x07};
OP_UINT32 hash = 487265;
memcpy(Cmd+2, &hash, sizeof(hash));
OutText("Send Get Portrait Command.\n");
comm_send_command(Cmd, sizeof(Cmd));
}
void CMobileSyncDlg::OnClosePort()
{
// TODO: Add your control notification handler code here
CString string;
m_comm.SetPortOpen(FALSE);
string.Format("COM%d port closed!\n", m_nComboPort+1);
OutText(string);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -