X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=symbian%2Fsymbian_utils.cpp;h=9749361ed0eff4face46f0a6ad76003584e28ee3;hb=8de4179424c1ce7de2d7779c01e54e3e2e372911;hp=4fb13ac2e14937c18226fdc3ee3f4f5be09e1291;hpb=25ca88e0cbd385e70d7ea2ee4f8a34a9ff7bcc17;p=p5sagit%2Fp5-mst-13.2.git diff --git a/symbian/symbian_utils.cpp b/symbian/symbian_utils.cpp index 4fb13ac..9749361 100644 --- a/symbian/symbian_utils.cpp +++ b/symbian/symbian_utils.cpp @@ -9,14 +9,21 @@ #define SYMBIAN_UTILS_CPP #include #include -// #include // textresolver not used since seems not to work #include #include +#include + #include #include +#include "PerlUi.h" #include "PerlBase.h" +#include "PerlUtil.h" + +#include "EXTERN.h" +#include "perl.h" +#include "XSUB.h" extern "C" { EXPORT_C int symbian_sys_init(int *argcp, char ***argvp) @@ -27,11 +34,50 @@ extern "C" { (void)times(&PL_timesbase); return 0; } + XS(XS_PerlApp_TextQuery) // Can't be made static because of XS(). + { + dXSARGS; + if (items != 0) + Perl_croak(aTHX_ "PerlApp::TextQuery: no arguments, please"); + SP -= items; + // TODO: parse arguments for title, prompt, and maxsize. + // Suggested syntax: + // TextQuery(title => ..., prompt => ..., maxsize => ...) + // For an example see e.g. universal.c:XS_PerlIO_get_layers(). + _LIT(KTitle, "Title"); + _LIT(KPrompt, "Prompt"); + HBufC* cData = HBufC::New(KPerlUiOneLinerSize); + TBool cSuccess = EFalse; + if (cData) { + TPtr cPtr(cData->Des()); + if (CPerlUi::TextQueryDialogL(KTitle, + KPrompt, + cPtr, + KPerlUiOneLinerSize)) { + ST(0) = sv_2mortal(PerlUtil::newSvPVfromTDesC16(*cData)); + cSuccess = ETrue; + } + delete cData; + } + if (cSuccess) + XSRETURN(1); + else + XSRETURN_UNDEF; + } + EXPORT_C void init_os_extras(void) + { + dTHX; + char *file = __FILE__; + dXSUB_SYS; + newXS("PerlApp::TextQuery", XS_PerlApp_TextQuery, file); + } EXPORT_C SSize_t symbian_read_stdin(const int fd, char *b, int n) { #ifdef PERL_GLOBAL_STRUCT /* Avoid unused variable warning. */ dVAR; #endif + if(!PL_appctx) + ((CPerlBase*)PL_appctx) = CPerlBase::NewInterpreter(); return ((CPerlBase*)PL_appctx)->ConsoleRead(fd, b, n); } EXPORT_C SSize_t symbian_write_stdout(const int fd, const char *b, int n) @@ -39,6 +85,8 @@ extern "C" { #ifdef PERL_GLOBAL_STRUCT /* Avoid unused variable warning. */ dVAR; #endif + if(!PL_appctx) + ((CPerlBase*)PL_appctx) = CPerlBase::NewInterpreter(); return ((CPerlBase*)PL_appctx)->ConsoleWrite(fd, b, n); } static const char NullErr[] = ""; @@ -156,8 +204,13 @@ extern "C" { tick -= PL_timesbase.tms_utime; TInt64 tickus = TInt64(tick) * TInt64(periodus); TInt64 tmps = tickus / 1000000; +#ifdef __SERIES60_3X__ + if (sec) *sec = I64LOW(tmps); + if (usec) *usec = I64LOW(tickus) - I64LOW(tmps) * 1000000; +#else if (sec) *sec = tmps.Low(); if (usec) *usec = tickus.Low() - tmps.Low() * 1000000; +#endif //__SERIES60_3X__ return 0; } EXPORT_C int symbian_usleep(unsigned int usec) @@ -185,10 +238,10 @@ extern "C" { return tmsbuf->tms_utime; } } - class CE32ProcessWait : public CActive + class CProcessWait : public CActive { public: - CE32ProcessWait() : CActive(EPriorityStandard) { + CProcessWait() : CActive(EPriorityStandard) { CActiveScheduler::Add(this); } #ifdef __WINS__ @@ -208,7 +261,6 @@ extern "C" { void RunL() { CActiveScheduler::Stop(); } - CActiveSchedulerWait iWait; }; class CSpawnIoRedirect : public CBase { @@ -244,11 +296,17 @@ extern "C" { error = proc.Create(aFilename, func, KStackSize, +#ifdef __SERIES60_3X__ + KHeapMin, + KHeapMax, + (TAny*)command, +#else (TAny*)command, &lib, RThread().Heap(), KHeapMin, KHeapMax, +#endif EOwnerProcess); else error = KErrNotFound; @@ -262,7 +320,7 @@ extern "C" { #endif if (error == KErrNone) { if ((TInt)aFlag & (TInt)ESpawnWait) { - CE32ProcessWait* w = new CE32ProcessWait(); + CProcessWait* w = new CProcessWait(); if (w) { error = w->Wait(proc); delete w;