4729 return self; |
4729 return self; |
4730 } |
4730 } |
4731 |
4731 |
4732 CCmdDialog::~CCmdDialog() |
4732 CCmdDialog::~CCmdDialog() |
4733 { |
4733 { |
|
4734 Cancel(); |
|
4735 iNotifier.Close(); |
4734 delete iTitle; |
4736 delete iTitle; |
4735 delete iBody; |
4737 delete iBody; |
4736 delete iButton1; |
4738 delete iButton1; |
4737 delete iButton2; |
4739 delete iButton2; |
4738 } |
4740 } |
4739 |
4741 |
4740 CCmdDialog::CCmdDialog() : CCommandBase(EManualComplete) |
4742 CCmdDialog::CCmdDialog() : CCommandBase(EManualComplete|ECaptureCtrlC) |
4741 { |
4743 { |
|
4744 SetExtension(this); |
4742 } |
4745 } |
4743 |
4746 |
4744 const TDesC& CCmdDialog::Name() const |
4747 const TDesC& CCmdDialog::Name() const |
4745 { |
4748 { |
4746 _LIT(KName, "dialog"); |
4749 _LIT(KName, "dialog"); |
4747 return KName; |
4750 return KName; |
4748 } |
|
4749 |
|
4750 CCmdDialog::TMode CCmdDialog::ModeL() const |
|
4751 { |
|
4752 _LIT(KDialogImpl, "DIALOG_IMPL"); |
|
4753 _LIT(KImplNotifier, "notifier"); |
|
4754 _LIT(KImplConsole, "console"); |
|
4755 _LIT(KImplNull, "null"); |
|
4756 |
|
4757 TMode mode = EModeNotifier; |
|
4758 if (Env().IsDefined(KDialogImpl)) |
|
4759 { |
|
4760 const TDesC& impl = Env().GetAsDesL(KDialogImpl); |
|
4761 if (impl == KImplNotifier) |
|
4762 { |
|
4763 mode = EModeNotifier; |
|
4764 } |
|
4765 else if (impl == KImplConsole) |
|
4766 { |
|
4767 mode = EModeConsole; |
|
4768 } |
|
4769 else if (impl == KImplNull) |
|
4770 { |
|
4771 mode = EModeNull; |
|
4772 } |
|
4773 } |
|
4774 |
|
4775 return mode; |
|
4776 } |
4751 } |
4777 |
4752 |
4778 void CCmdDialog::DoRunL() |
4753 void CCmdDialog::DoRunL() |
4779 { |
4754 { |
4780 if (iTitle == NULL) |
4755 if (iTitle == NULL) |
4801 Stdin().SetReadMode(RIoReadHandle::EFull); |
4776 Stdin().SetReadMode(RIoReadHandle::EFull); |
4802 TPtr ptr(iBody->Des()); |
4777 TPtr ptr(iBody->Des()); |
4803 Stdin().ReadL(ptr); |
4778 Stdin().ReadL(ptr); |
4804 } |
4779 } |
4805 |
4780 |
4806 switch (ModeL()) |
4781 switch (iMode) |
4807 { |
4782 { |
4808 case EModeNotifier: |
4783 case EModeNotifier: |
4809 { |
4784 { |
4810 RNotifier notifier; |
4785 RNotifier notifier; |
4811 User::LeaveIfError(notifier.Connect()); |
4786 LeaveIfErr(iNotifier.Connect(), _L("Couldn't connect to RNotifier")); |
4812 CleanupClosePushL(notifier); |
4787 iNotifier.Notify(*iTitle, *iBody, *iButton1, *iButton2, iReturnValue, iStatus); |
4813 |
4788 SetActive(); |
4814 TInt buttonValue; |
|
4815 TRequestStatus status; |
|
4816 notifier.Notify(*iTitle, *iBody, *iButton1, *iButton2, buttonValue, status); |
|
4817 User::WaitForRequest(status); |
|
4818 Complete(buttonValue); |
|
4819 |
|
4820 CleanupStack::PopAndDestroy(¬ifier); |
|
4821 break; |
4789 break; |
4822 } |
4790 } |
4823 case EModeConsole: |
4791 case EModeConsole: |
4824 { |
4792 { |
4825 RIoConsole console; |
4793 RIoConsole console; |
4892 void CCmdDialog::OptionsL(RCommandOptionList& aOptions) |
4860 void CCmdDialog::OptionsL(RCommandOptionList& aOptions) |
4893 { |
4861 { |
4894 _LIT(KOptTitle, "title"); |
4862 _LIT(KOptTitle, "title"); |
4895 _LIT(KOptButton1, "first-button"); |
4863 _LIT(KOptButton1, "first-button"); |
4896 _LIT(KOptButton2, "second-button"); |
4864 _LIT(KOptButton2, "second-button"); |
|
4865 _LIT(KOptMode, "mode"); |
4897 |
4866 |
4898 aOptions.AppendStringL(iTitle, KOptTitle); |
4867 aOptions.AppendStringL(iTitle, KOptTitle); |
4899 aOptions.AppendStringL(iButton1, KOptButton1); |
4868 aOptions.AppendStringL(iButton1, KOptButton1); |
4900 aOptions.AppendStringL(iButton2, KOptButton2); |
4869 aOptions.AppendStringL(iButton2, KOptButton2); |
|
4870 aOptions.AppendEnumL((TInt&)iMode, KOptMode); |
4901 } |
4871 } |
4902 |
4872 |
4903 void CCmdDialog::ArgumentsL(RCommandArgumentList& aArguments) |
4873 void CCmdDialog::ArgumentsL(RCommandArgumentList& aArguments) |
4904 { |
4874 { |
4905 _LIT(KArgBody, "body"); |
4875 _LIT(KArgBody, "body"); |
4906 aArguments.AppendStringL(iBody, KArgBody); |
4876 aArguments.AppendStringL(iBody, KArgBody); |
4907 } |
4877 } |
4908 |
4878 |
|
4879 void CCmdDialog::DoCancel() |
|
4880 { |
|
4881 iNotifier.NotifyCancel(); |
|
4882 } |
|
4883 |
|
4884 void CCmdDialog::RunL() |
|
4885 { |
|
4886 // text notifier gets the buttons the wrong way round, so check if it's running and if so swap the return value around |
|
4887 _LIT(KTextWindowServerName, "EWSRV.EXE[100000bf]0001"); // This is the same on winscw and target. The gui windowserver has a different UID |
|
4888 RProcess ewsrv; |
|
4889 TInt err = ewsrv.Open(KTextWindowServerName); |
|
4890 if (err == KErrNone) |
|
4891 { |
|
4892 if (iReturnValue) iReturnValue = 0; |
|
4893 else iReturnValue = 1; |
|
4894 ewsrv.Close(); |
|
4895 } |
|
4896 |
|
4897 Complete(iReturnValue); |
|
4898 } |
|
4899 |
|
4900 void CCmdDialog::CtrlCPressed() |
|
4901 { |
|
4902 //Cancel(); |
|
4903 //Complete(KErrNone); |
|
4904 Printf(_L("Sorry, clients of RNotifier cannot safely be killed, and RNotifier::NotifyCancel() doesn't work. If you really want to risk it hit CTRL-Z and run \"kill -Tm *dialog*\". Otherwise you must dismiss the dialog on the device.\r\n")); |
|
4905 } |
4909 |
4906 |
4910 // |
4907 // |
4911 // CCmdJit. |
4908 // CCmdJit. |
4912 // |
4909 // |
4913 |
4910 |