void CMyServer::ClipboardChanged() { __LOGSTR("CMyServer::ClipboardChanged"); Cancel(); iClipboard = CClipboard::NewForReadingL(iFs); _CPUSH(iClipboard); iClipboard->StreamDictionary().At(KClipboardUidTypePlainText); iTextPlain->DeleteL(0,iTextPlain->DocumentLength()); iTextPlain->PasteFromStoreL(iClipboard->Store(),iClipboard->StreamDictionary(),0); //iDrawTextNew.Delete(0,iDrawTextNew.Length()); iTextPlain->Extract(iDrawTextNew,0); _CPOPD(iClipboard); if( iDrawTextNew != iDrawTextOld) { __LOGSTR("Compare success"); __LOGSTR2("BEFORE COPY:::::: iDrawTextNew: %S,iDrawTextOld: %S",&iDrawTextNew,&iDrawTextOld); iDrawTextOld = iDrawTextNew; if(iDrawTextOld.Left(2) == _L("+7") || iDrawTextOld.Left(1) == _L("8")) { iTitle = _L("Вызвать"); iTypeEvent = ETypeCall; }else{ iTitle = _L("Искать"); iTypeEvent = ETypeSearch; } __LOGSTR2("AFTER COPY:::::: iDrawTextNew: %S,iDrawTextOld: %S",&iDrawTextNew,&iDrawTextOld); Draw(iDrawTextOld); iTimer->StartTimer(5); WaitWgEvent(); } }
void CMyServer::ConstructL() { __LOGSTR("Construct"); CActiveScheduler::Add(this); iWs = RWsSession(); iFs.Connect(); iTextPlain = CPlainText::NewL(); ReadConf(); __LOGSTR("ReadConfComplete"); iOldName = _L("ClipboardChanged"); iWs.Connect(iFs); iTaskList = new(ELeave) TApaTaskList(iWs); iScreen = new(ELeave) CWsScreenDevice(iWs); CleanupStack::PushL(iScreen); iScreen->Construct(); CleanupStack::Pop(iScreen); iChangeTrap = CChangeTrap::NewL(); iChangeTrap->SetObserver(this); iTimer = CPTimer::NewL(); iTimer->SetObserver(this); iCaller = CCaller::NewL(); iWg = RWindowGroup(iWs); iWg.Construct((TUint32)&iWg,EFalse); iWg.SetOrdinalPosition(0,ECoeWinPriorityAlwaysAtFront); iWg.EnableReceiptOfFocus(EFalse); iScreen->CreateContext(iGc); iWindow = RWindow(iWs); iWindow.Construct(iWg,(TUint32)&iWg+1); iWindow.Activate(); iWindow.SetExtent(TPoint(0,0),TSize(1,1)); iWindow.SetRequiredDisplayMode(EColor16MA); iWindow.SetOrdinalPosition(5555,ECoeWinPriorityAlwaysAtFront); TRgb backgroundColour = KRgbBlack; //if(KErrNone == iWindow.SetTransparencyAlphaChannel()) // { // backgroundColour.SetAlpha(0); // } iWindow.SetBackgroundColor(backgroundColour); GetFontSize(); iWindow.SetSize(iSize); __LOGSTR2("iSize1: %d,iSize2: %d",iSize.iWidth,iSize.iHeight); iPos=TPoint(iConfig.iX,iConfig.iY); iWindow.SetVisible(EFalse); iWs.Flush(); //Draw(iOldName); }
void OpenFile(const TDesC& aName) { TThreadId Id; TInt retVal; RApaLsSession apaLsSession; __CH__(apaLsSession.Connect()); __CPUSHC(apaLsSession); retVal = apaLsSession.StartDocument(aName,Id); __LOGSTR2("Open file %S returned value: %d",&aName,retVal); __CPOPD(&apaLsSession); }
void CButton::GetFontSize() { iFontName.FillZ(KMaxTypefaceNameLength); iScreen->TypefaceSupport(iTypefaceSupport, 0); iFontName = iTypefaceSupport.iTypeface.iName; // get font iFontSpec = TFontSpec(iFontName, 10*12); iFontSpec.iTypeface.SetIsProportional(ETrue); iScreen->GetNearestFontInTwips(iFont,iFontSpec); iSize=TSize(iFont->TextWidthInPixels(_L("Пропустить")),iFont->HeightInPixels()*2); __LOGSTR2("iSize.width: %d, iSize.height: %d",iSize.iWidth,iSize.iHeight); }
void CMyServer::GetFontSize() { iFontName.FillZ(KMaxTypefaceNameLength); iScreen->TypefaceSupport(iTypefaceSupport, 0); iFontName = iTypefaceSupport.iTypeface.iName; // get font iFontSpec = TFontSpec(iFontName, 10*iConfig.iHeight); iFontSpec.iTypeface.SetIsProportional(ETrue); iScreen->GetNearestFontInTwips(iFont,iFontSpec); if(iTitle.Length() > iDrawTextOld.Length()) { iSize=TSize(iFont->TextWidthInPixels(iTitle),iFont->HeightInPixels()*4);//XXX:две строки }else{ iSize=TSize(iFont->TextWidthInPixels(iDrawTextOld),iFont->HeightInPixels()*4);//XXX:две строки } __LOGSTR2("iSize.width: %d, iSize.height: %d",iSize.iWidth,iSize.iHeight); }
void CButton::GetWgEvent() { #ifdef __DEBUG __LOGSTR1("GetWgEvent,iStatus: %d",iStatus.Int()); #endif if(iStatus == KErrNone) { TWsEvent e; iWs.GetEvent(e); #ifdef __DEBUG __LOGSTR1("event: %d",e.Type()); #endif switch(e.Type()) { case EEventPointer: case EEventPointerEnter: case EEventDragDrop: { __LOGSTR("SendClose"); iMconnect->SendClose(); break; } case EEventFocusGained: __LOGSTR("Focus gained"); iIsFocus = ETrue; //iColor = KRgbGreen; break; case EEventFocusLost: __LOGSTR("Focus lost"); iIsFocus = EFalse; //iColor = KRgbRed; break; case EEventKeyDown: __LOGSTR2("EEventKeyDown,iIsFocus: %d,iScanCode: %d",iIsFocus,e.Key()->iScanCode); if(iIsFocus && e.Key()->iScanCode == 167) { iMconnect->SendClose(); } break; } } Draw(); iWs.Flush(); WaitWgEvent(); }
void WaitLong(TInt aMilliSeconds) { TInt count = 0;// Полные циклы по 35 минут TInt diff = 0;// Остаток while(true) { diff = aMilliSeconds - KMaximalTime; if(diff < KMaximalTime) break; ++count;//Считаем только максимальные сроки } __LOGSTR2("Full counts: %d, diff: %d",count,diff); for(TInt i = 0; i <= count; ++i) { User::After(KMaximalTime);//Максимальные сроки ожидания } User::After(diff);// плюс остаток }
void CMyServer::GetWgEvent() { #ifdef __DEBUG __LOGSTR1("GetWgEvent,iStatus: %d",iStatus.Int()); #endif if(iStatus == KErrNone) { TWsEvent e; iWs.GetEvent(e); #ifdef __DEBUG __LOGSTR1("event: %d",e.Type()); #endif } TInt WgId = iWs.GetFocusWindowGroup(); CApaWindowGroupName* gn = CApaWindowGroupName::NewLC(iWs, WgId); #ifdef __DEBUG __LOGSTR2("focused app with uid: 0x%x,config uid: 0x%x",gn->AppUid(),iConfig.iUid); #endif if(gn->AppUid() == iConfig.iUid) { Show(); //Draw(); //iWindow.SetVisible(ETrue); //iWs.Flush(); #ifdef __DEBUG __LOGSTR("UIDs =="); #endif }else{ //iWindow.SetVisible(EFalse); Hide(); iWs.Flush(); #ifdef __DEBUG __LOGSTR("UIDs !="); #endif } WaitWgEvent(); }
void CMyServer::LaunchStandardBrowser() { __LOGSTR("CMyServer::LaunchBrowser"); TBuf<512> url; url.Format(KUrlSearchStandard,&iDrawTextOld); TBuf8<512> url8; url8.Copy(url); TUid UID_Browser_91; UID_Browser_91.iUid = 0x1020724D; TUid UID_Browser_92; UID_Browser_92.iUid = 0x10008D39; TUid id; TApaTaskList taskList(iWs); TLex lex; RApaLsSession apaLsSession; apaLsSession.Connect(); OsVersion ver; GetOsVersion(ver); __LOGSTR2("Major: %D, Minor: %D",ver.iMajor,ver.iMinor); if(ver.iMajor == 3 && ver.iMinor == 0) { //9.1 __LOGSTR("9.1"); id = UID_Browser_91; }else{ //greather __LOGSTR("9.2 or high"); id = UID_Browser_92; } TApaTask task = taskList.FindApp(id); if(task.Exists()) { task.BringToForeground(); task.SendMessage(TUid::Uid(0), url8); // UID not used } else { //if(!apaLsSession.Handle()) //{ //User::LeaveIfError(apaLsSession.Connect()); //} TApaAppInfo appInfo; TInt retVal=apaLsSession.GetAppInfo(appInfo,id); if(KErrNone == retVal) { CApaCommandLine* cmdLine = CApaCommandLine::NewLC(); cmdLine->SetExecutableNameL(appInfo.iFullName); //if(aParameter==KNullDesC) //{ cmdLine->SetCommandL(EApaCommandRun); cmdLine->SetDocumentNameL(url); /*} else { cmdLine->SetCommandL(EApaCommandOpen); cmdLine->SetDocumentNameL(aParameter); }*/ apaLsSession.StartApp(*cmdLine); _CPOPD(cmdLine); task.BringToForeground(); task.SendMessage(TUid::Uid(0), url8); // UID not used } } }