📄 dialogs.cpp
字号:
#include "dialogs.h"
#include "sman.h"
#include <sman.rsg>
/*************************************************************
*
* Log level dialog
*
**************************************************************/
CLogLevelDialog::~CLogLevelDialog()
{
}
CLogLevelDialog::CLogLevelDialog(TUint *logFlags)
{
localLogFlags = logFlags;
}
TBool CLogLevelDialog::OkToExitL(TInt aButtonId)
{
CEikCheckBox *controlLogBluejack = STATIC_CAST(CEikCheckBox*, Control(cLogBluejack));
CEikCheckBox *controlLogOBEX = STATIC_CAST(CEikCheckBox*, Control(cLogOBEX));
CEikCheckBox *controlLogScanning = STATIC_CAST(CEikCheckBox*, Control(cLogScanning));
CEikCheckBox *controlLogDecays = STATIC_CAST(CEikCheckBox*, Control(cLogDecays));
if (aButtonId == EEikBidOk)
{
TUint tempFlags;
tempFlags = 0;
if (controlLogBluejack->State() == CEikButtonBase::ESet)
tempFlags = (tempFlags | CLogger::logBluejack);
if (controlLogOBEX->State() == CEikButtonBase::ESet)
tempFlags = (tempFlags | CLogger::logOBEX);
if (controlLogScanning->State() == CEikButtonBase::ESet)
tempFlags = (tempFlags | CLogger::logScanning);
if (controlLogDecays->State() == CEikButtonBase::ESet)
tempFlags = (tempFlags | CLogger::logDecays);
*localLogFlags = tempFlags;
return ETrue;
}
return ETrue;
}
void CLogLevelDialog::PreLayoutDynInitL()
{
CEikCheckBox *controlLogBluejack = STATIC_CAST(CEikCheckBox*, Control(cLogBluejack));
CEikCheckBox *controlLogOBEX = STATIC_CAST(CEikCheckBox*, Control(cLogOBEX));
CEikCheckBox *controlLogScanning = STATIC_CAST(CEikCheckBox*, Control(cLogScanning));
CEikCheckBox *controlLogDecays = STATIC_CAST(CEikCheckBox*, Control(cLogDecays));
if (((*localLogFlags) & CLogger::logBluejack) == CLogger::logBluejack)
controlLogBluejack->SetState(CEikButtonBase::ESet);
if (((*localLogFlags) & CLogger::logOBEX) == CLogger::logOBEX)
controlLogOBEX->SetState(CEikButtonBase::ESet);
if (((*localLogFlags) & CLogger::logScanning) == CLogger::logScanning)
controlLogScanning->SetState(CEikButtonBase::ESet);
if (((*localLogFlags) & CLogger::logDecays) == CLogger::logDecays)
controlLogDecays->SetState(CEikButtonBase::ESet);
}
/*************************************************************
*
* Bluejack timeout dialogs
*
**************************************************************/
CBluejackTimerDialog::~CBluejackTimerDialog()
{
}
CBluejackTimerDialog::CBluejackTimerDialog(TInt *noDevicePause, TInt *noDeviceAttempts, TInt *decayTime, TInt *obexTimeout)
{
localNoDevicePause = noDevicePause;
localNoDeviceAttempts = noDeviceAttempts;
localDecayTime = decayTime;
localObexTimeout = obexTimeout;
}
TBool CBluejackTimerDialog::OkToExitL(TInt aButtonId)
{
CQikNumberEditor *noDevicePause = STATIC_CAST(CQikNumberEditor*, Control(cNoDevicePause));
CQikNumberEditor *noDeviceAttempts = STATIC_CAST(CQikNumberEditor*, Control(cNoDeviceAttempts));
CQikNumberEditor *decayTime = STATIC_CAST(CQikNumberEditor*, Control(cDecayTime));
CQikNumberEditor *obexTimeout = STATIC_CAST(CQikNumberEditor*, Control(cOBEXTimeout));
if (aButtonId == EEikBidYes)
{
noDevicePause->SetValueL(CONFIG_NO_DEVICE_PAUSE);
noDeviceAttempts->SetValueL(CONFIG_NO_DEVICE_ATTEMPTS);
decayTime->SetValueL(CONFIG_DECAY_TIME);
obexTimeout->SetValueL(CONFIG_OBEX_TIMEOUT);
return EFalse;
}
else if (aButtonId == EEikBidOk)
{
*localNoDevicePause = noDevicePause->Value();
*localNoDeviceAttempts = noDeviceAttempts->Value();
*localDecayTime = decayTime->Value();
*localObexTimeout = obexTimeout->Value();
return ETrue;
}
return ETrue;
}
void CBluejackTimerDialog::PreLayoutDynInitL()
{
CQikNumberEditor *noDevicePause = STATIC_CAST(CQikNumberEditor*, Control(cNoDevicePause));
noDevicePause->SetValueL(*localNoDevicePause);
CQikNumberEditor *noDeviceAttempts = STATIC_CAST(CQikNumberEditor*, Control(cNoDeviceAttempts));
noDeviceAttempts->SetValueL(*localNoDeviceAttempts);
CQikNumberEditor *decayTime = STATIC_CAST(CQikNumberEditor*, Control(cDecayTime));
decayTime->SetValueL(*localDecayTime);
CQikNumberEditor *obexTimeout = STATIC_CAST(CQikNumberEditor*, Control(cOBEXTimeout));
obexTimeout->SetValueL(*localObexTimeout);
CEikCaptionedControl *decayTimeControl = Line(cDecayTime);
decayTimeControl->SetDividerAfter(ETrue);
}
/*************************************************************
*
* Hotkey dialog
*
**************************************************************/
CHotkeyDialog::~CHotkeyDialog()
{
}
CHotkeyDialog::CHotkeyDialog(TInt *iHotkey)
{
localiHotkey = iHotkey;
}
TBool CHotkeyDialog::OkToExitL(TInt aButtonId)
{
if (aButtonId == EEikBidOk)
{
// Save the config changes
CEikChoiceList *myHotkey = STATIC_CAST(CEikChoiceList*, Control(cHotkeyControl));
*localiHotkey = myHotkey->CurrentItem();
return ETrue;
}
return EFalse;
}
void CHotkeyDialog::PreLayoutDynInitL()
{
CEikChoiceList *hotkeyChoiceList;
hotkeyChoiceList = STATIC_CAST(CEikChoiceList*, Control(cHotkeyControl));
hotkeyChoiceList->SetArrayL(R_HOTKEY_ARRAY);
hotkeyChoiceList->SetCurrentItem(*localiHotkey);
}
/*************************************************************
*
* Shortcut dialog
*
**************************************************************/
CShortcutDialog::CShortcutDialog(CArrayFixFlat<TUid> *shortCut)
{
tempUid = shortCut;
// For each app we get from the app server, store its caption and uid
appListArray = new (ELeave) CDesCArraySeg(3);
appListUid = new (ELeave) CArrayFixFlat<TUid>(3);
}
CShortcutDialog::~CShortcutDialog()
{
delete appListArray;
delete appListUid;
}
TBool CShortcutDialog::OkToExitL(TInt aButtonId)
{
if (aButtonId == EEikBidOk)
{
if (tempUid != NULL)
{
for (int i = 0; i < tempUid->Count(); i++)
{
CEikChoiceList *myShortCut = STATIC_CAST(CEikChoiceList*, Control(cShortcut1 + i));
if (tempUid != NULL)
tempUid->At(i) = appListUid->At(myShortCut->CurrentItem());
}
}
return ETrue;
}
return EFalse;
}
void CShortcutDialog::PreLayoutDynInitL()
{
int dump;
TKeyArrayFix keyArray = TKeyArrayFix(0, ECmpTUint);
populateAppArray();
if (tempUid != NULL)
{
for (int i = 0; i < tempUid->Count(); i++)
{
CEikChoiceList *myShortCut = STATIC_CAST(CEikChoiceList*, Control(cShortcut1 + i));
myShortCut->SetArrayL(appListArray);
myShortCut->SetArrayExternalOwnership(ETrue);
if (appListUid->Find(tempUid->At(i), keyArray, dump) == 0)
{
myShortCut->SetCurrentItem(dump);
}
else
{
myShortCut->SetCurrentItem(0);
tempUid->At(i) = KNullUid;
}
}
}
}
void CShortcutDialog::populateAppArray(void)
{
// Scan the list of applications registered with the app server
// For each shortcut uid, set focus to that item
RApaLsSession mySession;
TApaAppInfo theAppInfo;
TApaAppCapabilityBuf aCapabilityBuf;
TBuf<1> bSeparator;
TBuf<10> appUid;
HBufC* aCaption;
TUid aUid;
TPtrC currentCaption, temp, temp1;
TLex lxUid;
mySession.Connect();
mySession.GetAllApps();
bSeparator.Append(255);
// Need to add the length of appUid and bSeparator into this because in the next for-loop, we are
// appending these to aCaption. By right, we only need 10 + 1 but I'm being paranoid. Besides, what
// is an additional 19 bytes anyway? :)
aCaption = HBufC::NewL(KApaMaxAppCaption + 30);
// Query the app server
while (mySession.GetNextApp(theAppInfo) == KErrNone)
{
if (mySession.GetAppCapability(aCapabilityBuf, theAppInfo.iUid) == KErrNone)
{
// Only scan applications that are not hidden
if (aCapabilityBuf().iAppIsHidden == EFalse)
{
// For each app we get from the app server, store its caption and uid
aCaption->Des().Copy(theAppInfo.iCaption);
aCaption->Des().Append(bSeparator);
appUid.Format(_L("%u"), theAppInfo.iUid);
aCaption->Des().Append(appUid);
appListArray->AppendL(*aCaption);
}
}
}
mySession.Close();
appListArray->Sort();
// The first item is for unassigning a shortcut
if (tempUid != NULL)
{
HBufC* dataBuffer = CEikonEnv::Static()->AllocReadResourceL(R_TBUF_UNASSIGNED);
HBufC* tempCaption = HBufC::NewL(dataBuffer->Length() + 5);
tempCaption->Des().Format(*dataBuffer, 255, KNullUid);
delete dataBuffer;
appListArray->InsertL(0, *tempCaption);
delete tempCaption;
}
// After sorting, separate the UIDs out. I'm doing this because I couldn't find a
// nicer way of linking the UID to the Caption while sorting.
// The assumption is there is no app with a 0xff char in its caption...pretty safe i
// think!!
for (int i = 0; i < appListArray->Count(); i++)
{
// Get app caption & uid
currentCaption.Set(appListArray->MdcaPoint(i));
TextUtils::ColumnText(temp, 0, ¤tCaption, TChar(255));
TextUtils::ColumnText(temp1, 1, ¤tCaption, TChar(255));
aCaption->Des().Copy(temp);
lxUid.Assign(temp1);
lxUid.Val(aUid.iUid);
appListUid->AppendL(aUid);
appListArray->Delete(i);
appListArray->InsertL(i, *aCaption);
}
appListArray->Compress();
delete aCaption;
}
/*************************************************************
*
* Autostart dialog. This dialog is self-contained. It has code
* to read and write SMan.boot.
*
**************************************************************/
CAutostartDialog::CAutostartDialog()
{
appListCaption = new (ELeave) CDesCArrayFlat(3);
appListPath = new (ELeave) CArrayFixSeg<TFileName>(3);
appListUid = new (ELeave) CArrayFixFlat<TUid>(3);
for (int i = 0; i < MAX_AUTOSTART; i++)
{
autoStartConfig.autoStartApp[i].Copy(_L(""));
autoStartConfig.autoStartUid[i] = KNullUid;
autoStartConfig.autoStartDefaultDoc[i].Copy(_L(""));
}
}
CAutostartDialog::~CAutostartDialog()
{
delete appListCaption;
delete appListPath;
delete appListUid;
}
void CAutostartDialog::populateAppArray(void)
{
// Scan the list of applications registered with the app server
// Store the app's caption and path
RApaLsSession mySession;
TApaAppInfo theAppInfo;
TApaAppCapabilityBuf aCapabilityBuf;
TBuf<1> bSeparator;
HBufC* aCaption;
TPtrC currentCaption, temp, temp1, temp2;
TBuf<10> appUid;
TUid aUid;
TLex lxUid;
mySession.Connect();
mySession.GetAllApps();
bSeparator.Append(255);
aCaption = HBufC::NewL(KApaMaxAppCaption + 30 + KMaxFileName);
// Query the app server
while (mySession.GetNextApp(theAppInfo) == KErrNone)
{
if (mySession.GetAppCapability(aCapabilityBuf, theAppInfo.iUid) == KErrNone)
{
// Only scan applications that are not hidden
if (aCapabilityBuf().iAppIsHidden == EFalse)
{
// For each app we get from the app server, store its caption and path
aCaption->Des().Copy(theAppInfo.iCaption);
aCaption->Des().Append(bSeparator);
aCaption->Des().Append(theAppInfo.iFullName);
aCaption->Des().Append(bSeparator);
appUid.Format(_L("%u"), theAppInfo.iUid);
aCaption->Des().Append(appUid);
appListCaption->AppendL(*aCaption);
}
}
}
mySession.Close();
appListCaption->Sort();
// The first item is for unassigning an autostart
HBufC* dataBuffer = CEikonEnv::Static()->AllocReadResourceL(R_TBUF_UNASSIGNED2);
HBufC* tempCaption = HBufC::NewL(dataBuffer->Length() + 10);
tempCaption->Des().Format(*dataBuffer, 255, 0, 255, KNullUid);
delete dataBuffer;
appListCaption->InsertL(0, *tempCaption);
delete tempCaption;
/*
aCaption = aCaption->ReAllocL(KApaMaxAppCaption + dataBuffer->Length() + 5);
aCaption->Des().Format(*dataBuffer, 255, 0, 255, KNullUid);
delete dataBuffer;
//aCaption.Format(_L("<unassigned>%c%c%c%c"), 255, 0, 255, KNullUid);
appListCaption->InsertL(0, *aCaption);
*/
for (int i = 0; i < appListCaption->Count(); i++)
{
// Get app caption, path and uid
currentCaption.Set(appListCaption->MdcaPoint(i));
TextUtils::ColumnText(temp, 0, ¤tCaption, TChar(255));
TextUtils::ColumnText(temp1, 1, ¤tCaption, TChar(255));
TextUtils::ColumnText(temp2, 2, ¤tCaption, TChar(255));
appListPath->AppendL(temp1);
aCaption->Des().Copy(temp);
lxUid.Assign(temp2);
lxUid.Val(aUid.iUid);
appListUid->AppendL(aUid);
appListCaption->Delete(i);
appListCaption->InsertL(i, *aCaption);
}
delete aCaption;
appListCaption->Compress();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -