# HG changeset patch # User hgs # Date 1287408605 -10800 # Node ID 2d9cac8919d3b77d43c380e277c5c426172767de # Parent 819e59dfc032a6d85ca06ee000976b0d3bfe3acd 201041 diff -r 819e59dfc032 -r 2d9cac8919d3 creator/creator.pro --- a/creator/creator.pro Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,225 +0,0 @@ -TEMPLATE = app -TARGET = Creator - -DEPENDPATH += . -DEPENDPATH += src engine/src -INCLUDEPATH += inc engine/inc - -load(hb.prf) -symbian:CONFIG -= symbian_i18n - -HEADERS += \ - inc/mainview.h \ - inc/notifications.h - -SOURCES += main.cpp \ - src/mainview.cpp \ - src/notifications.cpp - -symbian: { - INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE - HEADERS += engine/inc/creator.hrh \ - engine/inc/creator_calendar.h \ - engine/inc/creator_calendarbase.h \ - engine/inc/creator_calendarelement.h \ - engine/inc/creator_cmdscriptrun.h \ - engine/inc/creator_contactelement.h \ - engine/inc/creator_contactsetcache.h \ - engine/inc/creator_factory.h \ - engine/inc/creator_file.h \ - engine/inc/creator_fileelement.h \ - engine/inc/creator_landmark.h \ - engine/inc/creator_landmarkelement.h \ - engine/inc/creator_log.h \ - engine/inc/creator_logelement.h \ - engine/inc/creator_mailbox.h \ - engine/inc/creator_mailboxelement.h \ - engine/inc/creator_message.h \ - engine/inc/creator_messageelement.h \ - engine/inc/creator_modulebase.h \ - engine/inc/creator_note.h \ - engine/inc/creator_notepadwrapper.h \ - engine/inc/creator_phonebook.h \ - engine/inc/creator_phonebookwrapper.h \ - engine/inc/creator_phonebookapi.h \ - engine/inc/creator_phonebookbase.h \ - engine/inc/creator_randomdatafield.h \ - engine/inc/creator_randomdataparser.h \ - engine/inc/creator_scriptelement.h \ - engine/inc/creator_scriptelementfactory.h \ - engine/inc/creator_scriptentry.h \ - engine/inc/creator_scriptparser.h \ - engine/inc/creator_std.h \ - engine/inc/creator_traces.h \ - engine/inc/creator_wepsecuritysettings.h \ - engine/inc/randomdata.txt \ - inc/engine.h \ - inc/enginewrapper.h - - SOURCES += engine/src/creator_calendar.cpp \ - engine/src/creator_calendarelement.cpp \ - engine/src/creator_cmdscriptrun.cpp \ - engine/src/creator_contactelement.cpp \ - engine/src/creator_contactsetcache.cpp \ - engine/src/creator_factory.cpp \ - engine/src/creator_file.cpp \ - engine/src/creator_fileelement.cpp \ - engine/src/creator_landmark.cpp \ - engine/src/creator_landmarkelement.cpp \ - engine/src/creator_log.cpp \ - engine/src/creator_logelement.cpp \ - engine/src/creator_mailbox.cpp \ - engine/src/creator_mailboxelement.cpp \ - engine/src/creator_message.cpp \ - engine/src/creator_messageelement.cpp \ - engine/src/creator_note.cpp \ - engine/src/creator_notepadwrapper.cpp \ - engine/src/creator_phonebook.cpp \ - engine/src/creator_phonebookwrapper.cpp \ - engine/src/creator_phonebookapi.cpp \ - engine/src/creator_phonebookbase.cpp \ - engine/src/creator_randomdataparser.cpp \ - engine/src/creator_scriptelement.cpp \ - engine/src/creator_scriptelementfactory.cpp \ - engine/src/creator_scriptentry.cpp \ - engine/src/creator_scriptparser.cpp \ - src/engine.cpp \ - src/enginewrapper.cpp - - LIBS += -lestor \ - -lws32 \ - -lPlatformEnv \ - -limageconversion \ - -leikcore \ - -leuser \ - -lapparc \ - -lcone \ - -lcntmodel \ - -lmsgs \ - -llogwrap \ - -llogcli \ - -lefsrv \ - -lgsmu \ - -limcm \ - -lbafl \ - -leikcoctl \ - -leikctl \ - -lcommdb \ - -letext \ - -lcommonengine \ - -lcommonui \ - -lplatformenv \ - -lapgrfx \ - -lapmime \ - -lobexmtmutil \ - -lsmcm \ - -laknskins \ - -laknskinsrv \ - -lflogger \ - -letel \ - -letelmm \ - -lxmlframework \ - -lcharconv \ - -lsenutils \ - -lcalinterimapi \ - -leposlandmarks \ - -llbs \ - -lecom \ - -lcaf \ - -lcafutils \ - -ldrmrights \ - -ledbms \ - -lfbscli \ - -lbitmaptransforms \ - -lcmmanager \ - -lcmmanagerdatabase \ - -lnoteseditor \ - -lxqservice \ - -lQtContacts \ - -lagendainterface - - creatorDataBlock = \ - "SOURCEPATH ." \ - "START RESOURCE data/datacreator.rss" \ - "HEADER" \ - "TARGETPATH /resource/apps" \ - "END" - - MMP_RULES += creatorDataBlock - MMP_RULES -= PAGED - MMP_RULES *= UNPAGED - - BLD_INF_RULES.prj_exports += "./rom/creator.iby CORE_IBY_EXPORT_PATH(tools,creator.iby) - BLD_INF_RULES.prj_exports += \ - "./files/backup_registration.xml Z:/private/20011383/backup_registration.xml" \ - "./files/3GPP-70kB.dat Z:/private/20011383/3GPP-70kB.3gpp" \ - "./files/AAC-100kB.dat Z:/private/20011383/AAC-100kB.aac" \ - "./files/AMR-20kB.dat Z:/private/20011383/AMR-20kB.amr" \ - "./files/BMP-25kB.dat Z:/private/20011383/BMP-25kB.bmp" \ - "./files/Deck-1kB.dat Z:/private/20011383/Deck-1kB.saveddeck" \ - "./files/DOC-20kB.dat Z:/private/20011383/DOC-20kB.doc" \ - "./files/GIF-2kB.dat Z:/private/20011383/GIF-2kB.gif" \ - "./files/HTML-20kB.dat Z:/private/20011383/HTML-20kB.html" \ - "./files/JAD-1kB.dat Z:/private/20011383/JAD-1kB.jad" \ - "./files/JAR-10kB.dat Z:/private/20011383/JAR-10kB.jar" \ - "./files/JP2-65kB.dat Z:/private/20011383/JP2-65kB.jp2" \ - "./files/JPEG-200kB.dat Z:/private/20011383/JPEG-200kB.jpg" \ - "./files/JPEG-25kB.dat Z:/private/20011383/JPEG-25kB.jpg" \ - "./files/JPEG-500kB.dat Z:/private/20011383/JPEG-500kB.jpg" \ - "./files/MIDI-10kB.dat Z:/private/20011383/MIDI-10kB.mid" \ - "./files/MP3-250kB.dat Z:/private/20011383/MP3-250kB.mp3" \ - "./files/MP4-200kB.dat Z:/private/20011383/MP4-200kB.mp4" \ - "./files/MXMF-40kB.dat Z:/private/20011383/MXMF-40kB.mxmf" \ - "./files/PNG-15kB.dat Z:/private/20011383/PNG-15kB.png" \ - "./files/PPT-40kB.dat Z:/private/20011383/PPT-40kB.ppt" \ - "./files/RAM-1kB.dat Z:/private/20011383/RAM-1kB.ram" \ - "./files/RM-95kB.dat Z:/private/20011383/RM-95kB.rm" \ - "./files/RNG-1kB.dat Z:/private/20011383/RNG-1kB.rng" \ - "./files/SVG-15kB.dat Z:/private/20011383/SVG-15kB.svg" \ - "./files/SWF-15kB.dat Z:/private/20011383/SWF-15kB.swf" \ - "./files/TIF-25kB.dat Z:/private/20011383/TIF-25kB.tif" \ - "./files/TXT-10kB.dat Z:/private/20011383/TXT-10kB.txt" \ - "./files/TXT-70kB.dat Z:/private/20011383/TXT-70kB.txt" \ - "./files/VCF-1kB.dat Z:/private/20011383/VCF-1kB.vcf" \ - "./files/VCS-1kB.dat Z:/private/20011383/VCS-1kB.vcs" \ - "./files/WAV-20kB.dat Z:/private/20011383/WAV-20kB.wav" \ - "./files/XLS-15kB.dat Z:/private/20011383/XLS-15kB.xls" \ - "./files/SISX-10kB.dat Z:/private/20011383/SISX-10kB.sisx" \ - "./files/WMA-50kB.dat Z:/private/20011383/WMA-50kB.wma" \ - "./files/WMV-200kB.dat Z:/private/20011383/WMV-200kB.wmv" \ - "./scripts/creator.xsd +/tools/s60rndtools/creator/creator.xsd" \ - "./scripts/browserEx.creatorxml +/tools/s60rndtools/creator/browserEx.creatorxml" \ - "./scripts/calendarEx.creatorxml +/tools/s60rndtools/creator/calendarEx.creatorxml" \ - "./scripts/connectionmethodEx.creatorxml +/tools/s60rndtools/creator/connectionmethodEx.creatorxml" \ - "./scripts/contactEx.creatorxml +/tools/s60rndtools/creator/contactEx.creatorxml" \ - "./scripts/filesEx.creatorxml +/tools/s60rndtools/creator/filesEx.creatorxml" \ - "./scripts/landmarkEx.creatorxml +/tools/s60rndtools/creator/landmarkEx.creatorxml" \ - "./scripts/logEx.creatorxml +/tools/s60rndtools/creator/logEx.creatorxml" \ - "./scripts/mailboxEx.creatorxml +/tools/s60rndtools/creator/mailboxEx.creatorxml" \ - "./scripts/messagesEx.creatorxml +/tools/s60rndtools/creator/messagesEx.creatorxml" \ - "./scripts/notepadEx.creatorxml +/tools/s60rndtools/creator/notepadEx.creatorxml" - - creator_buildstubsis_extension = \ - "$${LITERAL_HASH}ifdef MARM" \ - " START EXTENSION app-services/buildstubsis" \ - " OPTION SRCDIR sis" \ - " OPTION SISNAME creator_stub" \ - " END" \ - "$${LITERAL_HASH}endif" - - BLD_INF_RULES.prj_extensions += creator_buildstubsis_extension - - RSS_RULES += "group_name = \"RnD Tools\""; - TARGET.CAPABILITY = CAP_APPLICATION AllFiles - - TARGET.UID2 = 0x100039CE - TARGET.UID3 = 0x20011383 - TARGET.SID = 0x20011383 - TARGET.VID = 0x101FB657 // Nokia - TARGET.EPOCHEAPSIZE = 0x20000 0x1000000 // Min 128Kb, Max 16Mb - - ICON = icons/qgn_menu_creator.svg - -} else { - error("Only Symbian supported!") -} diff -r 819e59dfc032 -r 2d9cac8919d3 creator/data/datacreator.rss --- a/creator/data/datacreator.rss Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,665 +0,0 @@ -NAME ORBT - -#include -#include -#include - -RESOURCE RSS_SIGNATURE { } - -RESOURCE ARRAY r_data_firstnames - { - items= - { - LBUF { txt="John"; }, - LBUF { txt="Francis"; }, - LBUF { txt="Andrew"; }, - LBUF { txt="Lawrence"; }, - LBUF { txt="Gregory"; }, - LBUF { txt="Fulke"; }, - LBUF { txt="Thomas"; }, - LBUF { txt="Nicholas"; }, - LBUF { txt="Hakle"; }, - LBUF { txt="Roger"; }, - LBUF { txt="Nathaniel"; }, - LBUF { txt="Luke"; }, - LBUF { txt="William"; }, - LBUF { txt="Ralph"; }, - LBUF { txt="Leonar"; }, - LBUF { txt="Daniel"; }, - LBUF { txt="Aban"; }, - LBUF { txt="Mathias"; }, - LBUF { txt="Robert"; }, - LBUF { txt="Christopher"; }, - LBUF { txt="Martin"; }, - LBUF { txt="Michael"; }, - LBUF { txt="Barnaby"; }, - LBUF { txt="Tobias"; }, - LBUF { txt="Richard"; }, - LBUF { txt="Anthony"; }, - LBUF { txt="Simon"; }, - LBUF { txt="Samuel"; }, - LBUF { txt="Geoffrey"; }, - LBUF { txt="Isaac"; }, - LBUF { txt="Henry"; }, - LBUF { txt="Matthew"; }, - LBUF { txt="Peter"; }, - LBUF { txt="Allen"; }, - LBUF { txt="Reynold"; }, - LBUF { txt="Jerome"; }, - LBUF { txt="Elizabeth"; }, - LBUF { txt="Catherine"; }, - LBUF { txt="Frances"; }, - LBUF { txt="Cecily"; }, - LBUF { txt="Millicent"; }, - LBUF { txt="Audrey"; }, - LBUF { txt="Joan"; }, - LBUF { txt="Elinor"; }, - LBUF { txt="Joyce"; }, - LBUF { txt="Frideswide"; }, - LBUF { txt="Rose"; }, - LBUF { txt="Helen"; }, - LBUF { txt="Margaret"; }, - LBUF { txt="Isabel"; }, - LBUF { txt="Bridget"; }, - LBUF { txt="Grace"; }, - LBUF { txt="Thomasin"; }, - LBUF { txt="Janet"; }, - LBUF { txt="Agnes"; }, - LBUF { txt="Dorothy"; }, - LBUF { txt="Christian"; }, - LBUF { txt="Amy"; }, - LBUF { txt="Fortune"; }, - LBUF { txt="Sybil"; }, - LBUF { txt="Alice"; }, - LBUF { txt="Margery"; }, - LBUF { txt="Edith"; }, - LBUF { txt="Barbara"; }, - LBUF { txt="Gillian"; }, - LBUF { txt="Ursula"; } - }; - } - -RESOURCE ARRAY r_data_surnames - { - items= - { - LBUF { txt="Lux"; }, - LBUF { txt="Mandot"; }, - LBUF { txt="Mansfield"; }, - LBUF { txt="Mayberry"; }, - LBUF { txt="McCarrel"; }, - LBUF { txt="McDaniel"; }, - LBUF { txt="Mefford"; }, - LBUF { txt="Metcalf"; }, - LBUF { txt="Metchell"; }, - LBUF { txt="Moller"; }, - LBUF { txt="Margan"; }, - LBUF { txt="Keaney"; }, - LBUF { txt="Kenyon"; }, - LBUF { txt="Kesler"; }, - LBUF { txt="Kinman"; }, - LBUF { txt="Kreinert"; }, - LBUF { txt="Kummerlin"; }, - LBUF { txt="Lamgley"; }, - LBUF { txt="Leas"; }, - LBUF { txt="Leighton"; }, - LBUF { txt="Lillie"; }, - LBUF { txt="Hilms"; }, - LBUF { txt="Holt"; }, - LBUF { txt="Hosier"; }, - LBUF { txt="Howard"; }, - LBUF { txt="Hypes"; }, - LBUF { txt="Jacmor"; }, - LBUF { txt="Behnson"; }, - LBUF { txt="Kammer"; }, - LBUF { txt="Patts"; }, - LBUF { txt="West"; }, - LBUF { txt="Wilbar"; }, - LBUF { txt="Witsan"; }, - LBUF { txt="Gillams"; }, - LBUF { txt="Good"; }, - LBUF { txt="Wreght"; }, - LBUF { txt="Worthley"; }, - LBUF { txt="Adams"; }, - LBUF { txt="Allen"; }, - LBUF { txt="Ansley"; }, - LBUF { txt="Ayries"; }, - LBUF { txt="Bartlett"; }, - LBUF { txt="Barton"; }, - LBUF { txt="Payne"; }, - LBUF { txt="Pintard"; }, - LBUF { txt="Prence"; }, - LBUF { txt="Richards"; }, - LBUF { txt="Dillman"; }, - LBUF { txt="Dory"; }, - LBUF { txt="Edgards"; }, - LBUF { txt="Engell"; }, - LBUF { txt="Farprington"; }, - LBUF { txt="Fisher"; }, - LBUF { txt="Foed"; }, - LBUF { txt="Burges"; }, - LBUF { txt="Childwall"; }, - LBUF { txt="Smith"; }, - LBUF { txt="Sipon"; }, - LBUF { txt="Simmons"; }, - LBUF { txt="Stewert"; }, - LBUF { txt="Stiles"; }, - LBUF { txt="Stratton"; }, - LBUF { txt="Dennis"; }, - LBUF { txt="Talmot"; } - }; - } - -RESOURCE ARRAY r_data_companies - { - items= - { - LBUF { txt="CDP"; }, - LBUF { txt="Exbox"; }, - LBUF { txt="Munro"; }, - LBUF { txt="Majaka"; }, - LBUF { txt="Bitzumi"; }, - LBUF { txt="Melroy"; }, - LBUF { txt="Matal"; }, - LBUF { txt="Japponi"; }, - LBUF { txt="Siwaka"; }, - LBUF { txt="Keiku"; }, - LBUF { txt="Naamate"; }, - LBUF { txt="Remonti"; }, - LBUF { txt="Melleva"; }, - LBUF { txt="WEX"; }, - LBUF { txt="Chataz"; }, - LBUF { txt="Ponly"; }, - LBUF { txt="Alriva"; }, - LBUF { txt="Giate"; }, - LBUF { txt="Kesso"; }, - LBUF { txt="Nyssa"; }, - LBUF { txt="Peger"; }, - LBUF { txt="Metrio"; }, - LBUF { txt="Mitchitatchi"; }, - LBUF { txt="Neppari"; }, - LBUF { txt="Amcuila"; }, - LBUF { txt="Muipitsu"; }, - LBUF { txt="Redex"; }, - LBUF { txt="Maariz"; }, - LBUF { txt="Swerck"; }, - LBUF { txt="Makiac"; }, - LBUF { txt="Dumpia"; }, - LBUF { txt="Worldmom"; }, - LBUF { txt="Renfaul"; }, - LBUF { txt="Kmartissori"; }, - LBUF { txt="Findo"; }, - LBUF { txt="Samsanc"; }, - LBUF { txt="Dellervo"; }, - LBUF { txt="Manrel"; }, - LBUF { txt="WSMRL"; }, - LBUF { txt="Eripox"; }, - LBUF { txt="Abiturien"; }, - LBUF { txt="Vesus"; }, - LBUF { txt="MI4"; }, - LBUF { txt="Overhiba"; }, - LBUF { txt="Tridune"; }, - LBUF { txt="Kyomcera"; }, - LBUF { txt="Praston"; }, - LBUF { txt="Gapmis"; }, - LBUF { txt="WPPDCD"; } - }; - } - -RESOURCE ARRAY r_data_addresses - { - items= - { - LBUF { txt="Barnes Street"; }, - LBUF { txt="Barnes Place"; }, - LBUF { txt="Eastman Street"; }, - LBUF { txt="West Park"; }, - LBUF { txt="South Park"; }, - LBUF { txt="Park Avenue"; }, - LBUF { txt="Richards Court"; }, - LBUF { txt="Pukershire Avenue"; }, - LBUF { txt="Ellis Avenue"; }, - LBUF { txt="East Mountain"; }, - LBUF { txt="Chestnut Hill"; }, - LBUF { txt="Plains Road"; }, - LBUF { txt="Fremont Street"; }, - LBUF { txt="Heritage Court"; }, - LBUF { txt="Highland Avenue Extension"; }, - LBUF { txt="Maple Heights"; }, - LBUF { txt="McKenzie Avenue"; }, - LBUF { txt="McKenzie Lane"; }, - LBUF { txt="West Terrace Street"; }, - LBUF { txt="Windsor Avenue"; }, - LBUF { txt="Windsor Road"; }, - LBUF { txt="Mechanic Street Extension"; }, - LBUF { txt="Granite Place"; }, - LBUF { txt="Meadow Street"; }, - LBUF { txt="Sugar River"; } - }; - } - -RESOURCE ARRAY r_data_cities - { - items= - { - LBUF { txt="Kuopio"; }, - LBUF { txt="Los Angeles"; }, - LBUF { txt="Lappeenranta"; }, - LBUF { txt="London"; }, - LBUF { txt="Bangkok"; }, - LBUF { txt="St. Michel"; }, - LBUF { txt="St. Petersburg"; }, - LBUF { txt="Tokyo"; }, - LBUF { txt="Helsinki"; }, - LBUF { txt="Trondheim"; }, - LBUF { txt="Nairobi"; }, - LBUF { txt="Havana"; } - }; - } - -RESOURCE ARRAY r_data_countries - { - items= - { - LBUF { txt="Finland"; }, - LBUF { txt="Cuba"; }, - LBUF { txt="United States of America"; }, - LBUF { txt="Thailand"; }, - LBUF { txt="Sweden"; }, - LBUF { txt="Russia"; }, - LBUF { txt="Japan"; }, - LBUF { txt="Norway"; }, - LBUF { txt="Kenya"; } - }; - } - -RESOURCE ARRAY r_data_postcodes - { - items= - { - LBUF { txt="00310"; }, - LBUF { txt="FI-70100"; }, - LBUF { txt="99002"; }, - LBUF { txt="11233"; } - }; - } - -RESOURCE ARRAY r_data_states - { - items= - { - LBUF { txt="California state"; }, - LBUF { txt="Alaska state"; }, - LBUF { txt="Florida state"; } - }; - } - -RESOURCE ARRAY r_data_poboxes - { - items= - { - LBUF { txt="P.O BOX 5532"; }, - LBUF { txt="P.O BOX 701"; }, - LBUF { txt="99"; }, - LBUF { txt="1133"; }, - LBUF { txt="P.O. BOX 113322"; }, - LBUF { txt="112"; } - }; - } - -RESOURCE ARRAY r_data_prefixes - { - items= - { - LBUF { txt="Ms."; }, - LBUF { txt="Mrs."; }, - LBUF { txt="Mr."; }, - LBUF { txt="Dr."; } - - }; - } - -RESOURCE ARRAY r_data_suffixes - { - items= - { - LBUF { txt="Jr."; }, - LBUF { txt="Sr."; } - }; - } - -RESOURCE ARRAY r_data_jobtitles - { - items= - { - LBUF { txt="Doctor"; }, - LBUF { txt="SW Engineer"; }, - LBUF { txt="Administrative Assistant"; }, - LBUF { txt="Bookkeeper"; }, - LBUF { txt="Credit Controller"; }, - LBUF { txt="Data Entry Operator"; }, - LBUF { txt="Payroll Officer"; }, - LBUF { txt="Receptionist"; }, - LBUF { txt="Trainee"; }, - LBUF { txt="Accounts Clerk"; }, - LBUF { txt="Administrator"; }, - LBUF { txt="Taxation Assistant"; }, - LBUF { txt="Financial Director"; }, - LBUF { txt="Bank Manager"; }, - LBUF { txt="Mobile Lending"; }, - LBUF { txt="Overseas Transactions"; }, - LBUF { txt="Restructuring"; }, - LBUF { txt="Business Analyst"; }, - LBUF { txt="Call Centre Manager"; }, - LBUF { txt="Administration"; }, - LBUF { txt="Manager"; }, - LBUF { txt="Student"; }, - LBUF { txt="Mail Sorter"; }, - LBUF { txt="Mayor"; }, - LBUF { txt="Account Servicing"; }, - LBUF { txt="Management"; }, - LBUF { txt="Media Consultant"; }, - LBUF { txt="Newsagent"; }, - LBUF { txt="Librarian"; }, - LBUF { txt="Creative Director"; }, - LBUF { txt="Announcer"; }, - LBUF { txt="Copywriter"; }, - LBUF { txt="Presenter"; }, - LBUF { txt="Promotions Manager"; }, - LBUF { txt="Advertising Sales Representative"; }, - LBUF { txt="Editor"; }, - LBUF { txt="Marketing, Sales & Publicity"; }, - LBUF { txt="Publisher"; }, - LBUF { txt="Gallery Assistant"; }, - LBUF { txt="Photographer"; }, - LBUF { txt="Storyboard Artist"; }, - LBUF { txt="Events Manager"; }, - LBUF { txt="Cameraman"; }, - LBUF { txt="Technician"; }, - LBUF { txt="Producer"; } - }; - } - -RESOURCE ARRAY r_data_phonenumbers - { - items= - { - LBUF { txt="0307834387"; }, - LBUF { txt="0230328732"; }, - LBUF { txt="0430365562"; }, - LBUF { txt="0530328732"; }, - LBUF { txt="0433032865"; }, - LBUF { txt="0542306532"; }, - LBUF { txt="0342303777"; }, - LBUF { txt="0250235603"; }, - LBUF { txt="0492303652"; }, - LBUF { txt="0542303286"; }, - LBUF { txt="0543656546"; }, - LBUF { txt="0545545454"; }, - LBUF { txt="0543444454"; }, - LBUF { txt="0776463255"; }, - LBUF { txt="0432443343"; }, - LBUF { txt="0243334344"; }, - LBUF { txt="0544543443"; }, - LBUF { txt="0231343243"; }, - LBUF { txt="0213443434"; }, - LBUF { txt="0143234476"; }, - LBUF { txt="0785434444"; }, - LBUF { txt="0454445345"; }, - LBUF { txt="0342443433"; }, - LBUF { txt="0432434454"; }, - LBUF { txt="0455454454"; }, - LBUF { txt="0656565655"; }, - LBUF { txt="0343434443"; }, - LBUF { txt="0565645455"; }, - LBUF { txt="0343243243"; }, - LBUF { txt="0565466565"; }, - LBUF { txt="0465565655"; }, - LBUF { txt="0435445454"; }, - LBUF { txt="+35854553456"; }, - LBUF { txt="+35878453486"; }, - LBUF { txt="+35876653456"; }, - LBUF { txt="+35834435486"; }, - LBUF { txt="+35876766466"; }, - LBUF { txt="+4465665456"; }, - LBUF { txt="+4432434334"; }, - LBUF { txt="+4488776776"; }, - LBUF { txt="+4465655656"; }, - LBUF { txt="+4443433434"; }, - LBUF { txt="+4465656565"; }, - LBUF { txt="+4454454354"; } - }; - } - -RESOURCE ARRAY r_data_groupnames - { - items= - { - LBUF { txt="Nice guys"; }, - LBUF { txt="Repairs"; }, - LBUF { txt="Office works"; }, - LBUF { txt="The buddies"; }, - LBUF { txt="Football team"; }, - LBUF { txt="Gold club"; }, - LBUF { txt="Silver club"; }, - LBUF { txt="Bronze club"; }, - LBUF { txt="Best buddies"; }, - LBUF { txt="Rockers"; }, - LBUF { txt="Science group"; } - }; - } - -RESOURCE ARRAY r_data_meetingreasons - { - items= - { - LBUF { txt="Security issues"; }, - LBUF { txt="Team meeting"; }, - LBUF { txt="Discussion about"; }, - LBUF { txt="Work plans"; }, - LBUF { txt="Meeting with the professor"; }, - LBUF { txt="Meeting with the boss"; }, - LBUF { txt="Work issues"; }, - LBUF { txt="New workers"; } - }; - } - -RESOURCE ARRAY r_data_meetingplaces - { - items= - { - LBUF { txt="Room"; }, - LBUF { txt="Home"; }, - LBUF { txt="Auditorium"; }, - LBUF { txt="Company"; } - }; - } - -RESOURCE ARRAY r_data_landmark_names - { - items= - { - LBUF { txt="Good place to fish";}, - LBUF { txt="Uncle over board";}, - LBUF { txt="Best food ever!";}, - LBUF { txt="Nice beach";}, - LBUF { txt="Good hamburgers";}, - LBUF { txt="Nice view";}, - LBUF { txt="John's home";}, - LBUF { txt="Carage";}, - LBUF { txt="Gas station";}, - LBUF { txt="Food store";}, - LBUF { txt="Car wash";}, - LBUF { txt="Summer cottage";}, - LBUF { txt="My home";}, - LBUF { txt="Bank";}, - LBUF { txt="Hospital";}, - LBUF { txt="Ice hall";}, - LBUF { txt="Work place";} - }; - } - -RESOURCE ARRAY r_data_landmark_descriptions - { - items= - { - LBUF { txt="The salmons were really big here!";}, - LBUF { txt="Delicious strawberries sold here. Must visit again sometime!";}, - LBUF { txt="Place looks really nice.";}, - LBUF { txt="This is my favorite place";}, - LBUF { txt="Words are not enough to describe this landmark";}, - LBUF { txt="What a shocking place to visit! Remember to bring camera next time :-)";} - }; - } - -RESOURCE ARRAY r_data_memos - { - items= - { - LBUF { txt="No work today!"; }, - LBUF { txt="Movies tonight"; }, - LBUF { txt="Ship new binaries"; }, - LBUF { txt="New works"; }, - LBUF { txt="Exam"; }, - LBUF { txt="Community service"; }, - LBUF { txt="Volunteer work"; }, - LBUF { txt="Don't forget the dinner at the restaurant"; }, - LBUF { txt="Go the bank"; }, - LBUF { txt="Go to the store"; }, - LBUF { txt="Buy goods"; }, - LBUF { txt="Buy food"; }, - LBUF { txt="Buy new pair of socks"; }, - LBUF { txt="Buy vegetables"; }, - LBUF { txt="Buy fruits"; }, - LBUF { txt="Umbrella"; }, - LBUF { txt="New shoes"; }, - LBUF { txt="New suit"; }, - LBUF { txt="Buy flowers"; }, - LBUF { txt="School day"; } - }; - } -RESOURCE ARRAY r_data_anniversaries - { - items= - { - LBUF { txt="birthday"; }, - LBUF { txt="anniversary"; } - }; - } - -RESOURCE ARRAY r_data_todos - { - items= - { - LBUF { txt="Watch for gum on my shoe"; }, - LBUF { txt="Watch my step in the hall"; }, - LBUF { txt="Always think big"; }, - LBUF { txt="Don't ever think small"; }, - LBUF { txt="Keep pedaling my bike"; }, - LBUF { txt="Watch for bees in my pop"; }, - LBUF { txt="Keep moving forward"; }, - LBUF { txt="Don't ever stop"; }, - LBUF { txt="Keep my sled underneath me"; }, - LBUF { txt="Keep my stick on the ice"; }, - LBUF { txt="Don't swim in a whirlpool"; }, - LBUF { txt="Don't look for a fight"; }, - LBUF { txt="Don't spit in the wind"; }, - LBUF { txt="Just do what is right"; }, - LBUF { txt="Go out in the world"; }, - LBUF { txt="Enjoy a warm rain"; }, - LBUF { txt="Don't worship TV"; }, - LBUF { txt="Keep my oars in the water"; }, - LBUF { txt="Point my boat right downstream"; }, - LBUF { txt="Face head on my problems"; }, - LBUF { txt="Change underwear daily"; }, - LBUF { txt="Believe myself first"; }, - LBUF { txt="Go out and have fun"; }, - LBUF { txt="Turn the cards one by one"; }, - LBUF { txt="Get out and do something"; } - }; - } - -RESOURCE ARRAY r_data_reminders - { - items= - { - LBUF { txt="Remeber to fix car"; }, - LBUF { txt="Remeber to eat vegetables"; }, - LBUF { txt="Remeber to go shopping"; }, - LBUF { txt="Remeber to buy boxes for moving"; }, - LBUF { txt="Remeber to fix bike"; }, - LBUF { txt="Remeber to buy christmast presents"; }, - LBUF { txt="Remeber to send flowers to grandmother"; }, - LBUF { txt="Remeber to talk with son"; }, - LBUF { txt="Remeber to cut hedge"; }, - LBUF { txt="Remeber to bumper potatoes"; }, - LBUF { txt="Remeber to harvest corn field"; }, - LBUF { txt="Remeber to sleep enaugh"; }, - LBUF { txt="Remeber to wash teeths ewery morning"; }, - LBUF { txt="Remeber to get sleep early"; }, - LBUF { txt="Remeber to give some wather to flowers"; }, - LBUF { txt="Remeber to wax snowboard"; }, - LBUF { txt="Remeber to wax skiis"; }, - LBUF { txt="Remeber to wax cross country skiis"; }, - LBUF { txt="Remeber to call mother"; }, - LBUF { txt="Remeber to call father"; }, - LBUF { txt="Remeber to call brother"; }, - LBUF { txt="Remeber to call sister"; }, - LBUF { txt="Remeber to call daughter"; }, - LBUF { txt="Remeber to call son"; }, - LBUF { txt="Remeber to rent villa"; } - }; - } - -RESOURCE ARRAY r_data_messagesubjects - { - items= - { - LBUF { txt="Whaaasssaaap!!??"; }, - LBUF { txt="Hello"; }, - LBUF { txt="How are you doing?"; }, - LBUF { txt="You will win the battle, GUARANTEED!"; }, - LBUF { txt="Why pay more for something if you don't have to?"; }, - LBUF { txt="You can afford health care now"; }, - LBUF { txt="Re: *Buddy* *Lists*!!~ (it's soooo cool)!!~"; }, - LBUF { txt="Weedmon say: call, we be open 7 days, mon"; }, - LBUF { txt="Want her to look better?"; }, - LBUF { txt="Good Morning andyw, how are you?"; }, - LBUF { txt="Happy Assumption"; }, - LBUF { txt="There is NO Risk involved"; }, - LBUF { txt="Free Bottle Offer!"; }, - LBUF { txt="Introduction on MDSL"; }, - LBUF { txt="Theres Help out there for you"; }, - LBUF { txt="hello there - check this out"; }, - LBUF { txt="Darling"; }, - LBUF { txt="It doesn't have to be that way"; }, - LBUF { txt="Webmaster, Free health insurance quotes!"; }, - LBUF { txt="Join us at the OSGi 2003 World Congress"; }, - LBUF { txt="Put your subject line here"; }, - LBUF { txt="You are not protected"; }, - LBUF { txt="Please try again"; }, - LBUF { txt="you didn't reply my email ? why ? ???"; }, - LBUF { txt="A very funny game"; }, - LBUF { txt="Meeting notice"; }, - LBUF { txt="Opportunities"; } - }; - } - -RESOURCE ARRAY r_data_messagetexts - { - items= - { - LBUF { txt="The contents of these pages are copyrighted. Any rights not expressly granted herein are reserved. The use of this site is permitted to private use."; }, - LBUF { txt="Reproduction, transfer, distribution or storage of part or all of the contents in any form without the prior written permission is prohibited."; }, - LBUF { txt="We consents to you browsing the pages on your computer or printing copies of extracts from these pages for your personal use only."; }, - LBUF { txt="If you place an order for a product, request a service or submit content to this site, we may need to contact you for additional information."; }, - LBUF { txt="The use of press releases and other documents classified as public is permitted in public communications if the source for the information has been stated."; }, - LBUF { txt="For your easy accessibility we may include links to sites on the Internet that are owned or operated by third parties."; }, - LBUF { txt="You also agree that we have no control over the content of that site and cannot assume any responsibility for material by such third-party sites."; }, - LBUF { txt="In addition, a link to a such site does not imply that we endorses the site or the products or services referenced in such third party site."; }, - LBUF { txt="In order to respond to your questions or manage interactive customer programs, it may be necessary to ask for personal information."; }, - LBUF { txt="We may use this information to respond to your requests, or to contact you via mail, e-mail or phone to inform you of new products."; }, - LBUF { txt="If you place an order for a product, request a service or submit content to this site, we may need to contact you for additional information."; } - }; - } - diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/inc/creator.hrh --- a/creator/engine/inc/creator.hrh Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,180 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - - -#ifndef __CREATOR_HRH__ -#define __CREATOR_HRH__ - - -enum TCreatorIds - { - - // Phonebook entries shuld be the first, bacause some other entries references them - ECmdCreatePhoneBookEntries = 1, - ECmdCreatePhoneBookEntryContacts, - ECmdCreatePhoneBookEntryGroups, - ECmdCreatePhoneBookEntrySubscribedContacts, - - ECmdCreateFromFile, - - ECmdCreateCalendarEntries, - ECmdCreateCalendarEntryAppointments, - ECmdCreateCalendarEntryEvents, - ECmdCreateCalendarEntryAnniversaries, - ECmdCreateCalendarEntryToDos, - ECmdCreateCalendarEntryReminders, - - ECmdCreateBrowserEntries, - ECmdCreateBrowserBookmarkEntries, - ECmdCreateBrowserBookmarkFolderEntries, - ECmdCreateBrowserSavedPageEntries, - ECmdCreateBrowserSavedPageFolderEntries, - - ECmdCreateFileEntries, - ECmdCreateFileEntryEmptyFolder, - - ECmdCreateFileEntry3GPP_70kB, - ECmdCreateFileEntryAAC_100kB, - ECmdCreateFileEntryAMR_20kB, - ECmdCreateFileEntryBMP_25kB, - ECmdCreateFileEntryDeck_1kB, - ECmdCreateFileEntryDOC_20kB, - ECmdCreateFileEntryGIF_2kB, - ECmdCreateFileEntryHTML_20kB, - ECmdCreateFileEntryJAD_1kB, - ECmdCreateFileEntryJAR_10kB, - ECmdCreateFileEntryJP2_65kB, - ECmdCreateFileEntryJPEG_200kB, - ECmdCreateFileEntryJPEG_25kB, - ECmdCreateFileEntryJPEG_500kB, - ECmdCreateFileEntryMIDI_10kB, - ECmdCreateFileEntryMP3_250kB, - ECmdCreateFileEntryMP4_200kB, - ECmdCreateFileEntryMXMF_40kB, - ECmdCreateFileEntryPNG_15kB, - ECmdCreateFileEntryPPT_40kB, - ECmdCreateFileEntryRAM_1kB, - ECmdCreateFileEntryRM_95kB, - ECmdCreateFileEntryRNG_1kB, - ECmdCreateFileEntrySVG_15kB, - ECmdCreateFileEntrySWF_15kB, - ECmdCreateFileEntryTIF_25kB, - ECmdCreateFileEntryTXT_10kB, - ECmdCreateFileEntryTXT_70kB, - ECmdCreateFileEntryVCF_1kB, - ECmdCreateFileEntryVCS_1kB, - ECmdCreateFileEntryWAV_20kB, - ECmdCreateFileEntryXLS_15kB, - ECmdCreateFileEntrySISX_10kB, - ECmdCreateFileEntryWMA_50kB, - ECmdCreateFileEntryWMV_200kB, - - ECmdCreateLogEntries, - ECmdCreateLogEntryMissedCalls, - ECmdCreateLogEntryReceivedCalls, - ECmdCreateLogEntryDialledNumbers, - - ECmdCreateMessagingEntries, - ECmdCreateMessagingEntryCBSTopics, - ECmdCreateMessagingEntryDocumentsFolders, - ECmdCreateMessagingEntrySMSMessageCenters, - ECmdCreateMessagingEntryMailboxes, - ECmdCreateMessagingEntryMessages, - ECmdCreateMessagingEntryMessagesViaScript, - ECmdCreateMessagingEntryTemplates, - - ECmdCreateRandomEntrySMSInbox, - ECmdCreateRandomEntrySMSDrafts, - ECmdCreateRandomEntrySMSOutbox, - ECmdCreateRandomEntrySMSSent, - ECmdCreateRandomEntryMMSInbox, - ECmdCreateRandomEntryMMSDrafts, - ECmdCreateRandomEntryMMSOutbox, - ECmdCreateRandomEntryMMSSent, - ECmdCreateRandomEntryAMSInbox, - ECmdCreateRandomEntryAMSDrafts, - ECmdCreateRandomEntryAMSOutbox, - ECmdCreateRandomEntryAMSSent, - ECmdCreateRandomEntryEmailInbox, - ECmdCreateRandomEntryEmailDrafts, - ECmdCreateRandomEntryEmailOutbox, - ECmdCreateRandomEntryEmailSent, - ECmdCreateRandomEntryBIOInbox, - ECmdCreateRandomEntryBIODrafts, - ECmdCreateRandomEntryBIOOutbox, - ECmdCreateRandomEntryBIOSent, - ECmdCreateRandomEntryIRInbox, - ECmdCreateRandomEntryIRDrafts, - ECmdCreateRandomEntryIROutbox, - ECmdCreateRandomEntryIRSent, - ECmdCreateRandomEntryBTInbox, - ECmdCreateRandomEntryBTDrafts, - ECmdCreateRandomEntryBTOutbox, - ECmdCreateRandomEntryBTSent, - - ECmdCreateMiscEntries, - ECmdCreateMiscEntryAccessPoints, - ECmdCreateMiscEntryAppMenuFolders, - ECmdCreateMiscEntryIMPSServers, - ECmdCreateMiscEntryNotes, - ECmdCreateMiscEntrySyncSettings, - ECmdCreateMiscEntryLandmarks, - - ECmdDeleteEntries, - ECmdDeleteAllEntries, - ECmdDeleteAllCreatorEntries, - ECmdDeleteContacts, - ECmdDeleteCreatorContacts, - ECmdDeleteContactGroups, - ECmdDeleteCreatorContactGroups, - ECmdDeleteCalendarEntries, - ECmdDeleteCreatorCalendarEntries, - ECmdDeleteBrowserBookmarks, - ECmdDeleteCreatorBrowserBookmarks, - ECmdDeleteBrowserBookmarkFolders, - ECmdDeleteCreatorBrowserBookmarkFolders, - ECmdDeleteBrowserSavedPages, - ECmdDeleteCreatorBrowserSavedPages, - ECmdDeleteBrowserSavedPageFolders, - ECmdDeleteCreatorBrowserSavedPageFolders, - ECmdDeleteCreatorFiles, - ECmdDeleteLogs, - ECmdDeleteCreatorLogs, - ECmdDeleteMessages, - ECmdDeleteCreatorMessages, - ECmdDeleteMailboxes, - ECmdDeleteCreatorMailboxes, - ECmdDeleteIAPs, - ECmdDeleteCreatorIAPs, - ECmdDeleteIMPSs, - ECmdDeleteCreatorIMPSs, - ECmdDeleteNotes, - // ECmdDeleteCreatorNotes, not supported - ECmdDeleteLandmarks, - ECmdDeleteCreatorLandmarks, - - ECmdAboutCreator, - - ECmdSelectRandomDataFile, - - EProgressNote - - }; - -#endif // __CREATOR_HRH__ diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/inc/creator.pan --- a/creator/engine/inc/creator.pan Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - - -#ifndef __CREATOR_PAN__ -#define __CREATOR_PAN__ - - -/** Creator application panic codes */ -enum TCreatorPanics - { - ECreatorBasicUi = 1 - // add further panics here - }; - -#endif // __CREATOR_PAN__ diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/inc/creator_accesspoint.h --- a/creator/engine/inc/creator_accesspoint.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,126 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - - - -#ifndef __CREATORACCESSPOINTS_H__ -#define __CREATORACCESSPOINTS_H__ - -#include "engine.h" -#include "creator_modulebase.h" -#include "creator_connectionmethodbase.h" - -#include -#include -//#include -//#include -//#include -//#include -//#include -#include -#include -#include - - -class CCreatorEngine; -class CAccessPointsParameters; - - - -class CCreatorAccessPoints : public CCreatorConnectionSettingsBase, public MMsvSessionObserver - { -public: - static CCreatorAccessPoints* NewL(CCreatorEngine* aEngine); - static CCreatorAccessPoints* NewLC(CCreatorEngine* aEngine); - ~CCreatorAccessPoints(); - -private: - CCreatorAccessPoints(); - void ConstructL(CCreatorEngine* aEngine); // from MCreatorModuleBase - - void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3); // from MMsvSessionObserver - -public: - TBool AskDataFromUserL( TInt aCommand ); // from MCreatorModuleBase - - TInt CreateConnectionSettingsEntryL(CCreatorModuleBaseParameters *aParameters); - TUint32 AccessPointNameToIdL(const TDesC& aAPName, TBool aAnyIfNotFound = EFalse ); - - void DeleteAllL(); - void DeleteAllCreatedByCreatorL(); - -private: - CCommsDatabase* iCommsDb; - CApDataHandler* iApDataHandler; - CApUtils* iApUtils; - CAccessPointsParameters* iParameters; - RArray iEntryIds; // TUint32 CApDataHandler::CreateFromDataL - -public: - }; - - -class CAccessPointsParameters : public CCreatorModuleBaseParameters - { -public: - HBufC* iConnectionName; // connection name - TApBearerType iBearerType; // bearer type - HBufC* iWapStartPage; // WAP start page - TUint32 iWapWspOption; // connection type - HBufC* iGprsAcessPointName; // access point name - HBufC* iIspLoginName; // username - TBool iSecureAuthentication; // password authentication - HBufC* iIspLoginPass; // password - TBool iPromptPassword; // prompt password - HBufC* iWapGatewayAddress; // WAP gateway address - HBufC* iIspIPAddr; // phone IP - HBufC* iIspIPNameServer1; // primary name server - HBufC* iIspIPNameServer2; // secondary name server - HBufC* iIspDefaultTelNumber; // datacall number - TUint32 iIspBearerCallTypeIsdn; // datacall type - TUint32 iIspBearerSpeed; // max connection speed - HBufC* iProxyServerAddress; // proxy address - TUint32 iProxyPortNumber; // proxy number - - void SetRandomCMNameL(CCreatorEngine& aEngine); - void SetRandomLoginNameL(CCreatorEngine& aEngine); - void SetRandomLoginPassL(CCreatorEngine& aEngine); - void SetRandomSecureAuthenticationL(CCreatorEngine& aEngine); - void SetRandomPromptPasswordL(CCreatorEngine& aEngine); - void SetRandomProxyAddressL(CCreatorEngine& aEngine); - void SetRandomProxyPortL(CCreatorEngine& aEngine); - void SetRandomStartPageL(CCreatorEngine& aEngine); - void SetRandomIPAddressL(CCreatorEngine& aEngine); - void SetRandomIP4NameServer1L(CCreatorEngine& aEngine); - void SetRandomIP4NameServer2L(CCreatorEngine& aEngine); - void SetRandomTelephoneNumberL(CCreatorEngine& aEngine); - void SetRandomBearerTypeIsdnL(CCreatorEngine& aEngine); - void SetRandomBearerSpeedL(CCreatorEngine& aEngine); - void SetRandomWapWspOptionL(CCreatorEngine& aEngine); - void SetRandomGatewayAddressL(CCreatorEngine& aEngine); - - -public: - CAccessPointsParameters(); - ~CAccessPointsParameters(); - }; - - - -#endif // __CREATORACCESSPOINTS_H__ diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/inc/creator_browser.h --- a/creator/engine/inc/creator_browser.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,108 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - - - -#ifndef __CREATORBROWSER_H__ -#define __CREATORBROWSER_H__ - -#include "engine.h" -#include "creator_modulebase.h" - -#include -//#include -//#include -//#include - - - -class CCreatorEngine; -class CBrowserParameters; - - -class CCreatorBrowser : public CCreatorModuleBase - { -public: - static CCreatorBrowser* NewL(CCreatorEngine* aEngine); - static CCreatorBrowser* NewLC(CCreatorEngine* aEngine); - ~CCreatorBrowser(); - -private: - CCreatorBrowser(); - void ConstructL(CCreatorEngine* aEngine); // from MCreatorModuleBase - -public: - TBool AskDataFromUserL( TInt aCommand ); // from MCreatorModuleBase - - TInt CreateBookmarkEntryL(CBrowserParameters *aParameters); - TInt CreateBookmarkFolderEntryL(CBrowserParameters *aParameters); - TInt CreateSavedDeckEntryL(CBrowserParameters *aParameters); - TInt CreateSavedDeckFolderEntryL(CBrowserParameters *aParameters); - - void DeleteAllL(); - void DeleteAllCreatedByCreatorL(); - - void DeleteAllBookmarksL(); - void DeleteAllBookmarksCreatedByCreatorL(); - void DeleteAllBookmarkFoldersL(); - void DeleteAllBookmarkFoldersCreatedByCreatorL(); - void DeleteAllSavedPagesL(); - void DeleteAllSavedPagesCreatedByCreatorL(); - void DeleteAllSavedPageFoldersL(); - void DeleteAllSavedPageFoldersCreatedByCreatorL(); - -private: - void DeleteAllItemsL( const TDesC& aDbName, CFavouritesItem::TType aTypeFilter, TBool aOnlyCreatedWithCreator, RArray& aEntryIds, const TUid aDictUid ); - - - -private: - CBrowserParameters* iParameters; - RArray iBmEntryIds; - RArray iBmFEntryIds; - RArray iSpEntryIds; - RArray iSpFEntryIds; -public: - }; - - -class CBrowserParameters : public CCreatorModuleBaseParameters - { -public: - HBufC* iBookmarkName; - HBufC* iBookmarkAddress; - TFavouritesWapAp iBookmarkAccessPoint; - HBufC* iBookmarkUsername; - HBufC* iBookmarkPassword; - - HBufC* iBookmarkFolderName; - - HBufC* iSavedDeckLinkName; - HBufC* iSavedDeckLocalAddress; - - HBufC* iSavedDeckFolderName; - -public: - CBrowserParameters(); - ~CBrowserParameters(); - }; - - - -#endif // __CREATORBROWSER_H__ diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/inc/creator_browserelement.h --- a/creator/engine/inc/creator_browserelement.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - - -#ifndef CREATORBROWSERELEMENT_H_ -#define CREATORBROWSERELEMENT_H_ - -#include "creator_scriptelement.h" - -namespace creatorbrowser -{ -_LIT(KBookmark, "bookmark"); -_LIT(KBookmarkFolder, "bookmarkfolder"); -_LIT(KSavedPage, "savedpage"); -_LIT(KSavedPageFolder, "savedpagefolder"); - -_LIT(KName, "name"); -_LIT(KPath, "path"); -_LIT(KUsername, "username"); -_LIT(KPassword, "password"); -_LIT(KUrl, "url"); -} - -class CCreatorBrowserElement : public CCreatorScriptElement -{ -public: - static CCreatorBrowserElement* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC); - void ExecuteCommandL(); - -protected: - CCreatorBrowserElement(CCreatorEngine* aEngine); - TInt GetBrowserCommandL() const; -}; -#endif /*CREATORBROWSERELEMENT_H_*/ diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/inc/creator_calendar.h --- a/creator/engine/inc/creator_calendar.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,209 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - - - -#ifndef __CREATORCALENDARINTERIM_H__ -#define __CREATORCALENDARINTERIM_H__ - -#include "engine.h" -#include "creator_modulebase.h" -#include "creator_calendarbase.h" - -#include -#include - -//#include -#include -#include -#include -#include -#include -#include -#include -#include - - -class CCreatorEngine; -class CCalenderInterimParameters; -class CAsyncWaiter; - -class CCreatorInterimCalendar : public CCreatorCalendarBase, public MCalProgressCallBack - { -enum TCreatorCalendarStatus{ - ECreatorCalendarDelete = 0, - ECreatorCalendarStart, - ECreatorCalendarGetWeeklyEntries, - ECreatorCalendarGetAttendies, - ECreatorCalendarGetStartDate, - ECreatorCalendarGetEndDate, - ECreatorCalendarAddDefaultAlarm -}; - -public: - static CCreatorInterimCalendar* NewL(CCreatorEngine* aEngine); - static CCreatorInterimCalendar* NewLC(CCreatorEngine* aEngine); - ~CCreatorInterimCalendar(); - -private: - CCreatorInterimCalendar(); - void ConstructL(CCreatorEngine* aEngine); // from MCreatorModuleBase - void AddRepeatingRuleL(const TCalTime& aStartTime, CCalEntry& aCalEntry, CCalenderInterimParameters* parameters=0); - void SetRandomAlarmL(CCalEntry& aCalEntry); - void SetAlarmL(CCalEntry& aCalEntry, CCalenderInterimParameters* params); - void AddAttendeesL(CCalEntry& aCalEntry, CCalenderInterimParameters* parameters=0); - void SetPhoneOwnerL(CCalEntry& aCalEntry, const TDesC& aCN, const TDesC& aEmail, const TDesC& aSentBy ); - void SetOrganizerL(CCalEntry& aCalEntry, const TDesC& aCN, const TDesC& aEmail, const TDesC& aSentBy); - void SetOrganizerL(CCalEntry& aCalEntry, CCalenderInterimParameters* parameters ); - -public: - TBool AskDataFromUserL( TInt aCommand ); // from MCreatorModuleBase - void QueryDialogClosedL(TBool aPositiveAction, TInt aUserData); //from MUIObserver - - TInt CreateAppointmentEntryL(CCreatorModuleBaseParameters *aParameters); - TInt CreateEventEntryL(CCreatorModuleBaseParameters *aParameters); - TInt CreateAnniversaryEntryL(CCreatorModuleBaseParameters *aParameters); - TInt CreateTodoEntryL(CCreatorModuleBaseParameters *aParameters); - TInt CreateReminderEntryL(CCreatorModuleBaseParameters *aParameters); - - void GenerateRandomId(TDes8& aText); - void DeleteAllL(); - void DeleteAllCreatedByCreatorL(); - -private: - - CCalenderInterimParameters* iParameters; - TTime iRandomModeStartTime; - TTime iRandomModeEndTime; - TInt iNumberRepeatingEntries; - TInt iNumberOfAttendees; - CCalEntryView* iCalEntryView; - CCalSession* iCalSession; - TBool iSetAlarm; - CDesCArrayFlat* iSoundFileArray; - CAsyncWaiter* iWaiter; - HBufC* iTmpCN; - HBufC* iTmpEmail; - RArray iEntryIds; // TCalLocalUid ( == TUint32 ) CCalEntry::LocalUidL - -public: - - //Observer implementation for MCalProgressCallBack - void Progress(TInt aPercentageCompleted); - - void Completed(TInt aError); - - TBool NotifyProgress(); - - }; - -class CCreatorCalenderAttendee : public CBase -{ -public: - virtual ~CCreatorCalenderAttendee(); - static CCreatorCalenderAttendee* NewL(); - void SetCommonNameL(const TDesC& aName); - void SetEmailAddressL(const TDesC& aEmail); - void SetRole(CCalAttendee::TCalRole aRole); - void SetStatus(CCalAttendee::TCalStatus); - - const TDesC& CommonName() const; - const TDesC& EmailAddress() const; - CCalAttendee::TCalRole Role() const; - CCalAttendee::TCalStatus Status() const; - -private: - CCreatorCalenderAttendee(); - TPtrC iDummy; - HBufC* iCommonName; - HBufC* iEmailAddress; - CCalAttendee::TCalRole iRole; - CCalAttendee::TCalStatus iStatus; -}; - -class CCalenderInterimParameters : public CCreatorModuleBaseParameters - { -public: - - void ParseL(CCommandParser* parser, TParseParams aCase); - TBool IsAllowedEntryStatus(CCalEntry::TType aType, CCalEntry::TStatus aStatus); - - TCalRRule::TType iRecurrentFrequency; - TInt iRecurrentInterval; - TTime iRecurrentStartTime; - TTime iRecurrentEndTime; - TInt iRepeatingCount; // This is used when running a script... - TTime iAlarmTime; // NullTTime means no alarm - TBool iUseRandomAlarmTime; // ETrue if random alarm should be set. Overwrites the iAlarmTime. - - RPointerArray iAttendees; - RArray iAttendeeLinkIds; // For attendees. Stores the linked contact ids. - HBufC* iOrganizerName; - HBufC* iOrganizerEmail; - - HBufC* iDescription; - HBufC* iSummary; - HBufC* iLocation; - TTime iStartTime; - TTime iEndTime; - TInt iNumberRepeatingEntries; // This is used when user input is used... - TInt iNumberOfAttendees; // Number of randomly generated attendees - TInt iNumberOfExistingAttendees; // Number of attendees selected from existing contacts. - - //An appointment, which has a start time and end time. - TTime iAppointmentStartTime; - TTime iAppointmentEndTime; - HBufC* iAppointmentLocation; - HBufC* iAppointmentReason; - - //An event, which has a start time and end time. - - TTime iEventStartTime; - TTime iEventEndTime; - HBufC* iEventReason; - - //A reminder, which has a start time only. - TTime iReminderStartTime; - HBufC* iReminderReason; - - //An anniversary, which has a start time and end time. - TTime iAnniversaryStartTime; - TTime iAnniversaryEndTime; - HBufC* iAnniversaryReason; - - //A to-do, which can have a start time and end time (the end time is the due date), or can be undated. - TTime iTodoStartTime;//optional - TTime iTodoDueTime;//also end time (optional) - HBufC* iTodoTask; - TInt iTodoPriority; - - TTime iRandomModeStartTime; - TTime iRandomModeEndTime; - - CCalEntry::TStatus iStatus; - -public: - CCalenderInterimParameters(); - ~CCalenderInterimParameters(); - - }; - - - -#endif // __CREATORCALENDARINTERIM_H__ diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/inc/creator_calendarbase.h --- a/creator/engine/inc/creator_calendarbase.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - - -#ifndef CCREATORCALENDARBASE_ -#define CCREATORCALENDARBASE_ - -#include "creator_modulebase.h" - -class CCreatorModuleBaseParameters; - -class CCreatorCalendarBase : public CCreatorModuleBase{ -public: - - - //An appointment, which has a start time and end time. EAppt. - virtual TInt CreateAppointmentEntryL(CCreatorModuleBaseParameters *aParameters) = 0; - //An event, which has a start time and end time. EEvent. - virtual TInt CreateEventEntryL(CCreatorModuleBaseParameters *aParameters) = 0; - //An anniversary, which has a start time and end time. EAnniv. - virtual TInt CreateAnniversaryEntryL(CCreatorModuleBaseParameters *aParameters) = 0; - //A to-do, which can have a start time and end time (the end time is the due date), or can be undated. ETodo. - virtual TInt CreateTodoEntryL(CCreatorModuleBaseParameters *aParameters) = 0; - //A reminder, which has a start time only. EReminder. - virtual TInt CreateReminderEntryL(CCreatorModuleBaseParameters *aParameters) = 0; - -}; - -#endif /*CCREATORCALENDARBASE_*/ diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/inc/creator_calendarelement.h --- a/creator/engine/inc/creator_calendarelement.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,120 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - - -#ifndef CREATORCALENDARELEMENT_H_ -#define CREATORCALENDARELEMENT_H_ - -#include "creator_scriptelement.h" - -class CCalenderInterimParameters; - -// Calendar elements: -namespace creatorcalendar -{ - _LIT(KCalendar, "calendar"); - - // Calendar entry types: - _LIT(KType, "type"); - _LIT(KCalTypeAppointment, "appointment"); - _LIT(KCalTypeEvent, "event"); - _LIT(KCalTypeReminder, "reminder"); - _LIT(KCalTypeAnniversary, "anniversary"); - _LIT(KCalTypeTodo, "todo"); - - // Calendar entry field elements: - _LIT(KSummary, "summary"); - _LIT(KDescription, "description"); - _LIT(KLocation, "location"); - _LIT(KStarttime, "starttime"); - _LIT(KEndtime, "endtime"); - _LIT(KRecurrentFreq, "recurrentfrequency"); - _LIT(KRecurrentInterval, "recurrentinterval"); - _LIT(KRecurrentFrom, "recurrentfrom"); - _LIT(KRecurrentTo, "recurrentto"); - _LIT(KRepeatingCount, "repeatingcount"); - _LIT(KAlarmtime, "alarmtime"); - _LIT(KSynchronization, "synchronization"); - _LIT(KOrganizername, "organizername"); - _LIT(KOrganizeremail, "organizeremail"); - _LIT(KAttendees, "attendees"); - _LIT(KAttendee, "attendee"); - _LIT(KCommonname, "commonname"); - _LIT(KEmail, "email"); - _LIT(KRole, "role"); - _LIT(KStatus, "status"); - _LIT(KPriority, "priority"); - - // Recurrency frequency values: - _LIT(KNotRepeated, "not-repeated"); - _LIT(KWeekly, "weekly"); - _LIT(KDaily, "daily"); - _LIT(KMonthly, "monthly"); - _LIT(KYearly, "yearly"); - - // Attendee role values: - _LIT(KRoleRequired, "required"); - _LIT(KRoleOptional, "optional"); - _LIT(KRoleNonPart, "non-participant"); - _LIT(KRoleChair, "chair"); - - // Calendar entry status values: - _LIT(KCalStatusTentative, "tentative"); - _LIT(KCalStatusConfirmed, "confirmed"); - _LIT(KCalStatusCancelled, "cancelled"); - _LIT(KCalStatusNeedsAction, "todoneedsaction"); - _LIT(KCalStatusCompleted, "todocompleted"); - _LIT(KCalStatusInProcess, "todoinprocess"); - - // Attendee status values: - _LIT(KStatusNeedsAction, "needsaction"); - _LIT(KStatusAccepted, "accepted"); - _LIT(KStatusTentative, "tentative"); - _LIT(KStatusConfirmed, "confirmed"); - _LIT(KStatusDeclined, "declined"); - _LIT(KStatusCompleted, "completed"); - _LIT(KStatusDelegated, "delegated"); - _LIT(KStatusInProcess, "inprocess"); - - // Priority values: - _LIT(KPriorityHigh, "high"); - _LIT(KPriorityMedium, "medium"); - _LIT(KPriorityLow, "low"); -} - -class CCreatorCalendarElement : public CCreatorScriptElement -{ -public: - static CCreatorCalendarElement* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC); - void ExecuteCommandL(); -protected: - CCreatorCalendarElement(CCreatorEngine* aEngine); - - enum TEntryType { - EAppointment, - EEvent, - EReminder, - EAnniversary, - ETodo - }; - - void FillEntryParamsL(TEntryType aType, const RPointerArray& fields, CCalenderInterimParameters* parameters); -}; - -#endif /*CREATORCALENDARELEMENT_H_*/ diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/inc/creator_cmdscriptrun.h --- a/creator/engine/inc/creator_cmdscriptrun.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#ifndef __CREATORCMDSCRIPTRUN_H__ -#define __CREATORCMDSCRIPTRUN_H__ - -#include "engine.h" - -class CCreatorCmdScriptRun : public CBase, public MBeating - { -public: - - static CCreatorCmdScriptRun* NewL(CCreatorEngine* aEngine); - static CCreatorCmdScriptRun* NewLC(CCreatorEngine* aEngine); - ~CCreatorCmdScriptRun(); - - // callback from engine when the commands from the script file have been executed - void RunScriptDone(); - - // from MBeating - void Beat(); - void Synchronize(); - -private: - CCreatorCmdScriptRun(); - void ConstructL(CCreatorEngine* aEngine); - void TickL(); - -private: - CCreatorEngine* iEngine; - HBufC* iCommandLineScriptName; - HBufC* iCommandLineRandomDataFileName; - CHeartbeat* iTimer; - enum TTimerMode - { - ETimerModeNone, - ETimerModeStartScript, - ETimerModeExitAppUi - }; - TTimerMode iMode; - TInt iTickCount; - }; - -#endif // __CREATORCMDSCRIPTRUN_H__ diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/inc/creator_connectionmethod.h --- a/creator/engine/inc/creator_connectionmethod.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,155 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - - -#ifndef __CREATORCONNECTIONSETTINGS_H__ -#define __CREATORCONNECTIONSETTINGS_H__ - -#include "engine.h" -#include "creator_modulebase.h" -#include "creator_connectionmethodbase.h" - -#include -#include -#include -#include -#include - -#include -#include -#include -using namespace CMManager; - -#include //ETel Packet API needed for enums - -class CCreatorEngine; -class CConnectionSettingsParameters; - -class CCreatorConnectionSettings : public CCreatorConnectionSettingsBase, public MMsvSessionObserver - { -public: - static CCreatorConnectionSettings* NewL(CCreatorEngine* aEngine); - static CCreatorConnectionSettings* NewLC(CCreatorEngine* aEngine); - ~CCreatorConnectionSettings(); - -private: - CCreatorConnectionSettings(); - void ConstructL(CCreatorEngine* aEngine); // from MCreatorModuleBase - - void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3); // from MMsvSessionObserver - -public: - TBool AskDataFromUserL( TInt aCommand ); // from MCreatorModuleBase - - TInt CreateConnectionSettingsEntryL(CCreatorModuleBaseParameters *aParameters); - TUint32 AccessPointNameToIdL(const TDesC& aAPName, TBool aAnyIfNotFound = EFalse ); - - //Setting default connection method, if not set - void SetDefaultCML(RCmConnectionMethodExt conMethod); - //Set random parameters - void SetRandomParametersL(CConnectionSettingsParameters& parameters); - void SetRandomBearerTypeL(CConnectionSettingsParameters& parameters); - void DeleteAllL(); - void DeleteAllCreatedByCreatorL(); -private: - void DeleteAllDestinationsL( TBool aOnlyCreatedWithCreator ); -private: - CCommsDatabase* iCommsDb; - - RCmManagerExt iCmManagerExt; - - CConnectionSettingsParameters* iParameters; - - RArray iEntryIds; // TUint32 RCmDestinationExt::Id() - -public: - }; - - -class CConnectionSettingsParameters : public CCreatorModuleBaseParameters - { -public: - HBufC* iConnectionName; // connection name - TUint iBearerType; // bearer type - HBufC* iStartPage; // start page - TWapWSPOption iWapWspOption; // Indicating whether connection-oriented or connectionless API should be used. - - RPacketContext::TProtocolType iProtocolType; //Type of protocol EPdpTypeIPv4 or EPdpTypeIPv4 - - HBufC* iLoginName; // username - TBool iSecureAuthentication; // password authentication - HBufC* iLoginPass; // password - TBool iPromptPassword; // prompt password - HBufC* iGatewayAddress; // gateway address - HBufC* iSubnetMask; // subnet mask - HBufC* iIPAddr; // phone IP - HBufC* iIP4NameServer1; // primary name server - HBufC* iIP4NameServer2; // secondary name server - HBufC* iDefaultTelNumber; // datacall number - TUint32 iBearerCallTypeIsdn; // datacall type - TUint32 iBearerSpeed; // max connection speed - TBool iUseProxy; //Use proxy or not - HBufC* iProxyServerAddress; // proxy address - TUint32 iProxyPortNumber; // proxy number - HBufC* iWLANName;//WLAN network name - HBufC* iWlanIpAddr;//IP address of EPOC. - TWlanSecMode iWLanSecMode;//WLAN security modes - TWlanNetMode iWlanNetMode;//WLAN connection mode. Ad-hoc or infrastructure. - - HBufC* iIP6NameServer1; // primary name server for IP v6 - HBufC* iIP6NameServer2; // secondary name server for IP v6 - TBool iDisableTextAuth; // Disable plaintext authentication - - CCreatorEngine* iEngine; - -public: - CConnectionSettingsParameters(); - ~CConnectionSettingsParameters(); - - void SetRandomCMNameL(CCreatorEngine& aEngine); - void SetRandomWLANNameL(CCreatorEngine& aEngine); - void SetRandomWLANNetModeL(CCreatorEngine& aEngine); - void SetRandomWLANSecurityModeL(CCreatorEngine& aEngine); - void SetRandomLoginNameL(CCreatorEngine& aEngine); - void SetRandomLoginPassL(CCreatorEngine& aEngine); - void SetRandomSecureAuthenticationL(CCreatorEngine& aEngine); - void SetRandomPromptPasswordL(CCreatorEngine& aEngine); - void SetRandomUseProxyL(CCreatorEngine& aEngine); - void SetRandomProxyAddressL(CCreatorEngine& aEngine); - void SetRandomProxyPortL(CCreatorEngine& aEngine); - void SetRandomStartPageL(CCreatorEngine& aEngine); - void SetRandomIPAddressL(CCreatorEngine& aEngine); - void SetRandomIP4NameServer1L(CCreatorEngine& aEngine); - void SetRandomIP4NameServer2L(CCreatorEngine& aEngine); - void SetRandomProtocolTypeL(CCreatorEngine& aEngine); - void SetRandomTelephoneNumberL(CCreatorEngine& aEngine); - void SetRandomBearerTypeIsdnL(CCreatorEngine& aEngine); - void SetRandomBearerSpeedL(CCreatorEngine& aEngine); - void SetRandomWapWspOptionL(CCreatorEngine& aEngine); - void SetRandomSubnetMaskL(CCreatorEngine& aEngine); - void SetRandomGatewayAddressL(CCreatorEngine& aEngine); - void SetRandomWlanIpAddrL(CCreatorEngine& aEngine); - void SetRandomIPv6NameServer1L(CCreatorEngine& aEngine); - void SetRandomIPv6NameServer2L(CCreatorEngine& aEngine); - void SetRandomDisableTextAuthL(CCreatorEngine& aEngine); - }; - - - -#endif // __CREATORCONNECTIONSETTINGS_H__ diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/inc/creator_connectionmethodbase.h --- a/creator/engine/inc/creator_connectionmethodbase.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - - -#ifndef __CCREATORCONNECTIONSETTINGSBASE_H_ -#define __CCREATORCONNECTIONSETTINGSBASE_H_ - -#include "creator_modulebase.h" - -class CCreatorModuleBaseParameters; - -const TUint KRandomBearerType = 0xEEEEEEEE; - -class CCreatorConnectionSettingsBase : public CCreatorModuleBase - { -public: - - virtual ~CCreatorConnectionSettingsBase(){}; - - virtual TInt CreateConnectionSettingsEntryL(CCreatorModuleBaseParameters *aParameters) = 0; - virtual TUint32 AccessPointNameToIdL(const TDesC& aAPName, TBool aAnyIfNotFound = EFalse ) = 0; - virtual void DeleteAllConnectionMethodsL(){}; - }; - -#endif /*__CCREATORCONNECTIONSETTINGSBASE_H_*/ diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/inc/creator_connectionmethodelement.h --- a/creator/engine/inc/creator_connectionmethodelement.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,99 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - - -#ifndef CREATORCONNECTIONMETHODELEMENT_H_ -#define CREATORCONNECTIONMETHODELEMENT_H_ - -#include "creator_scriptelement.h" - -namespace creatorconnectionmethod -{ - _LIT(KCm, "connectionmethod"); - _LIT(Kconnectionname, "connectionname"); - _LIT(Kbearertype, "bearertype"); - _LIT(Kstartpage, "startpage"); - _LIT(Kwapwspoption, "wapwspoption"); - _LIT(Kprotocoltype, "protocoltype"); - _LIT(Kloginname, "loginname"); - _LIT(Ksecureauthentication, "secureauthentication"); - _LIT(Kloginpass, "loginpass"); - _LIT(Kpromptpassword, "promptpassword"); - _LIT(Kgatewayaddress, "gatewayaddress"); - _LIT(Ksubnetmask, "subnetmask"); - _LIT(Kdeviceipaddr, "deviceipaddr"); - _LIT(Kip4nameserver1, "ip4nameserver1"); - _LIT(Kip4nameserver2, "ip4nameserver2"); - _LIT(Kdatacalltelnumber, "datacalltelnumber"); - _LIT(Kdatacalltypeisdn, "datacalltypeisdn"); - _LIT(Kdatacalllinespeed, "datacalllinespeed"); - _LIT(Kuseproxy, "useproxy"); - _LIT(Kproxyserveraddress, "proxyserveraddress"); - _LIT(Kproxyportnumber, "proxyportnumber"); - _LIT(Kip6nameserver1, "ip6nameserver1"); - _LIT(Kip6nameserver2, "ip6nameserver2"); - _LIT(Kdisabletextauth, "disabletextauth"); - _LIT(Kwlanname, "wlanname"); - _LIT(Kwlanipaddr, "wlanipaddr"); - _LIT(Kwlansecmode, "wlansecmode"); - _LIT(Kwlannetmode, "wlannetmode"); - - // Bearer type: - _LIT(Kwlan, "wlan"); - _LIT(Kgprs, "gprs"); - _LIT(Kdatacall, "datacall"); - _LIT(Khsgsm, "hsgsm"); - _LIT(Kembedded, "embedded"); - _LIT(Kvpn, "vpn"); - _LIT(Klan, "lan"); - - // Data call type isdn: - _LIT(Kanalogue, "analogue"); - _LIT(Kisdnv110, "isdnv110"); - _LIT(Kisdnv120, "isdnv120"); - - // Line speed: - _LIT(Kautomatic, "automatic"); - // WAP wps options: - _LIT(Kconnectionless, "connectionless"); // ECmWapWspOptionConnectionless - _LIT(Kconnectionoriented, "connectionoriented"); // ECmWapWspOptionConnectionOriented - - // Protocol - _LIT(Kipv4, "ipv4"); - _LIT(Kipv6, "ipv6"); - - // WLAN security mode: - _LIT(Kopen, "open"); - _LIT(Kwep, "wep"); - _LIT(Ke802_1x, "e802_1x"); - _LIT(Kwpa, "wpa"); - _LIT(Kwpa2, "wpa2"); -} - -class CCreatorConnectionMethodElement : public CCreatorScriptElement -{ -public: - static CCreatorConnectionMethodElement* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC); - void ExecuteCommandL(); - -protected: - CCreatorConnectionMethodElement(CCreatorEngine* aEngine); -}; - -#endif /*CREATORCONNECTIONMETHODELEMENT_H_*/ diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/inc/creator_contactelement.h --- a/creator/engine/inc/creator_contactelement.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,187 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - - -#ifndef CREATORCONTACTELEMENT_H_ -#define CREATORCONTACTELEMENT_H_ - -#include "creator_scriptelement.h" - -namespace creatorcontact -{ - _LIT(KContact, "contact"); - _LIT(KContactSet, "contact-set"); - _LIT(KContactGroup, "contactgroup"); - _LIT(KMembers, "members"); - _LIT(KName, "name"); - - // Contact field elements: - _LIT(KFirstname, "firstname"); - _LIT(KLastname, "lastname"); - _LIT(KFirstnameReading, "firstnamereading"); - _LIT(KLastnameReading, "lastnamereading"); - _LIT(KPrefix, "prefix"); - _LIT(KSuffix, "suffix"); - _LIT(KSecondname, "secondname"); - _LIT(KLandphoneHome, "landphonehome"); - - _LIT(KMobilephoneHome, "mobilephonehome"); - _LIT(KVideonumberHome, "videonumberhome"); - _LIT(KFaxnumberHome, "faxnumberhome"); - _LIT(KVoipHome, "voiphome"); - _LIT(KEmailHome, "emailhome"); - _LIT(KUrlHome, "urlhome"); - _LIT(KAddrlabelHome, "addrlabelhome"); - _LIT(KAddrpoHome, "addrpohome"); - - _LIT(KAddrextHome, "addrexthome"); - _LIT(KAddrstreetHome, "addrstreethome"); - _LIT(KAddrlocalHome, "addrlocalhome"); - _LIT(KAddrregionHome, "addrregionhome"); - _LIT(KAddrpostcodeHome, "addrpostcodehome"); - _LIT(KAddrcountryHome, "addrcountryhome"); - _LIT(KJobtitle, "jobtitle"); - _LIT(KCompanyname, "company"); - - _LIT(KLandphoneWork, "landphonework"); - _LIT(KMobilephoneWork, "mobilephonework"); - _LIT(KVideonumberWork, "videonumberwork"); - _LIT(KFaxnumberWork, "faxnumberwork"); - _LIT(KVoipWork, "voipwork"); - _LIT(KEmailWork, "emailwork"); - _LIT(KUrlWork, "urlwork"); - _LIT(KAddrlabelWork, "addrlabelwork"); - - _LIT(KAddrpoWork, "addrpowork"); - _LIT(KAddrextWork, "addrextwork"); - _LIT(KAddrstreetWork, "addrstreetwork"); - _LIT(KAddrlocalWork, "addrlocalwork"); - _LIT(KAddrregionWork, "addrregionwork"); - _LIT(KAddrpostcodeWork, "addrpostcodework"); - _LIT(KAddrcountryWork, "addrcountrywork"); - _LIT(KLandphoneGen, "landphonegen"); - - _LIT(KMobilephoneGen, "mobilephonegen"); - _LIT(KVideonumberGen, "videonumbergen"); - _LIT(KFaxnumberGen, "faxnumbergen"); - _LIT(KVoipGen, "voipgen"); - _LIT(KPoc, "poc"); - _LIT(KSwis, "swis"); - _LIT(KSip, "sip"); - _LIT(KEmailGen, "emailgen"); - - _LIT(KUrlGen, "urlgen"); - _LIT(KAddrlabelGen, "addrlabelgen"); - _LIT(KAddrpoGen, "addrpogen"); - _LIT(KAddrextGen, "addrextgen"); - _LIT(KAddrstreetGen, "addrstreetgen"); - _LIT(KAddrlocalGen, "addrlocalgen"); - _LIT(KAddrregionGen, "addrregiongen"); - _LIT(KAddrpostcodeGen, "addrpostcodegen"); - - _LIT(KAddrcountryGen, "addrcountrygen"); - _LIT(KPagerNumber, "pagernumber"); - _LIT(KDtmfString, "dtmfstring"); - _LIT(KWvAddress, "wvaddress"); - _LIT(KDate, "date"); - _LIT(KNote, "note"); - _LIT(KThumbnailPath, "thumbnailpath"); - _LIT(KThumbnailId, "thumbnailid"); - _LIT(KRingTone, "ringtonepath"); - _LIT(KRingToneId, "ringtoneid"); - - _LIT(KCallerobjImg, "callerobjimg"); - _LIT(KCallerobjText, "callerobjtext"); - _LIT(KMiddlename, "middlename"); - _LIT(KDepartment, "department"); - _LIT(KAsstname, "asstname"); - _LIT(KSpouse, "spouse"); - _LIT(KChildren, "children"); - _LIT(KAsstphone, "asstphone"); - - _LIT(KCarphone, "caphone"); - _LIT(KAnniversary, "anniversary"); - _LIT(KSyncclass, "synchronization"); - _LIT(KLocPrivacy, "locprivacy"); - _LIT(KGenlabel, "genlabel"); -} -/** - * Contact elements - */ - -/** - * Base class for contact elements - */ -class CCreatorContactElementBase : public CCreatorScriptElement -{ -public: - static CCreatorContactElementBase* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC); -protected: - CCreatorContactElementBase(CCreatorEngine* aEngine); -}; - -/** - * Contact element - */ -class CCreatorContactElement : public CCreatorContactElementBase -{ -public: - static CCreatorContactElement* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC); - void ExecuteCommandL(); -protected: - CCreatorContactElement(CCreatorEngine* aEngine); -}; - -/** - * Contact-set element - */ -class CCreatorContactSetElement : public CCreatorContactElementBase -{ -public: - static CCreatorContactSetElement* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC); - void ExecuteCommandL(); - virtual void AddToCacheL(); -protected: - CCreatorContactSetElement(CCreatorEngine* aEngine); -}; - -/** - * Contact group element - */ -class CCreatorContactGroupElement : public CCreatorContactElementBase -{ -public: - static CCreatorContactGroupElement* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC); - void ExecuteCommandL(); -protected: - CCreatorContactGroupElement(CCreatorEngine* aEngine); -}; - -/** - * Contact field element - */ -class CCreatorContactFieldElement : public CCreatorScriptElement -{ -public: - static CCreatorContactFieldElement* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC); -protected: - CCreatorContactFieldElement(CCreatorEngine* aEngine); -}; - -#endif /*CREATORCONTACTELEMENT_H_*/ diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/inc/creator_contactsetcache.h --- a/creator/engine/inc/creator_contactsetcache.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,74 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - - -#ifndef CREATORCONTACTSETCACHE_H_ -#define CREATORCONTACTSETCACHE_H_ - -#include - -// Forward declarations -class CContactLinkCacheImp; - -class CCreatorContactSet : public CBase -{ -public: - static CCreatorContactSet* NewL(TInt aLinkId, TInt aNumOfExistingContacts); - virtual ~CCreatorContactSet(); - void AppendL(TUint32); - TInt NumberOfExistingContacts() const; - RArray ContactLinks(); - const RArray ContactLinks() const; - - TInt LinkId() const; - -private: - CCreatorContactSet(TInt aLinkId, TInt aNumOfExistingContacts); - //void ConstructL(); - TInt iLinkId; - TInt iNumOfExistingContacts; - RArray iContactLinks; -}; - -class MContactLinkCache -{ -public: - virtual void AppendL(CCreatorContactSet* aContactSet) = 0; - virtual RArray ContactLinks(TInt aLinkId) = 0; - virtual const RArray ContactLinks(TInt aLinkId) const = 0; - virtual RPointerArray& ContactSets() = 0; - virtual const RPointerArray& ContactSets() const = 0; - virtual const CCreatorContactSet& ContactSet(TInt aLinkId) const = 0; - virtual CCreatorContactSet& ContactSet(TInt aLinkId) = 0; -}; - -class ContactLinkCache -{ -public: - static void InitializeL(); - static void DestroyL(); - - static MContactLinkCache* Instance(); - -private: - ContactLinkCache(){}; - static CContactLinkCacheImp* iImp; -}; - -#endif /*CREATORCONTACTSETCACHE_H_*/ diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/inc/creator_factory.h --- a/creator/engine/inc/creator_factory.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - - -#ifndef TCREATORFACTORY_H_ -#define TCREATORFACTORY_H_ - -#include "creator_modulebase.h" - -class CCreatorEngine; -class CCreatorPhonebookBase; -//class CCreatorConnectionSettingsBase; - - -class TCreatorFactory{ - -public: - static CCreatorPhonebookBase* CreatePhoneBookL(CCreatorEngine* aEngine); - static CCreatorModuleBaseParameters* CreatePhoneBookParametersL(); - -// static CCreatorConnectionSettingsBase* CreateConnectionSettingsL(CCreatorEngine* aEngine); -// static CCreatorModuleBaseParameters* CreateConnectionSettingsParametersL(); - - -}; - -#endif /*TCREATORFACTORY_H_*/ diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/inc/creator_file.h --- a/creator/engine/inc/creator_file.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,106 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - - - -#ifndef __CREATORFiles_H__ -#define __CREATORFiles_H__ - -#include "engine.h" -#include "creator_modulebase.h" - -#include -using namespace ContentAccess; -#include - -#include -#include -#include -#include // RApaLsSession - -class CCreatorEngine; -class CFilesParameters; -class CDRMPermission; -class CDRMConstraint; - -class CCreatorFiles : public CCreatorModuleBase - { -enum TCreatorFilesState{ - ECreatorFilesDelete, - ECreatorFilesStart, - ECreatorFilesGetDirectory, - ECreatorFilesAskDRMData, - ECreatorFilesAskDRM_CD_Counts, - ECreatorFilesAskDRM_CD_Minutes -}; -public: - static CCreatorFiles* NewL(CCreatorEngine* aEngine); - static CCreatorFiles* NewLC(CCreatorEngine* aEngine); - ~CCreatorFiles(); - -private: - CCreatorFiles(); - void ConstructL(CCreatorEngine* aEngine); // from MCreatorModuleBase - -public: - TBool AskDataFromUserL( TInt aCommand ); // from MCreatorModuleBase - void QueryDialogClosedL(TBool aPositiveAction, TInt aUserData); //from MUIObserver - TInt CreateFileEntryL(CFilesParameters *aParameters, TInt aCommand); - void DeleteAllL(); - void DeleteAllCreatedByCreatorL(); - -private: - - void EncryptFileL( const TDesC& aFileName, const TDesC& aOutFileName, CFilesParameters *aParameters ); - void SetPermissionsL( CMetaDataArray* aMetaData, const TDesC& aOutFileName, CFilesParameters *aParameters ); - void SetMimeTypeL( const TDesC& aFileName, TDes8& aMime, CFilesParameters *aParameters ); - TBool AskDRMDataFromUserL(); - void StorePathsForDeleteL( CDesCArray& aPaths ); - void GenerateFileNameL( TFileName& aRootName ); - -private: - CFilesParameters* iParameters; - CFilesParameters* iUserParameters; - TFileName iDirectoryQueriedFromUser; - RFs& iFs; - RApaLsSession iApaLs; - CDesCArray* iFilePaths; - TInt iFileId; - -public: - }; - - -class CFilesParameters : public CCreatorModuleBaseParameters - { -public: - HBufC* iFullFilePath; - TInt iFileCommand; - CDRMPermission* iPermission; - TBool iEncrypt; - -public: - CFilesParameters(); - CFilesParameters( CFilesParameters& aCopy ); - ~CFilesParameters(); - }; - - - -#endif // __CREATORFiles_H__ diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/inc/creator_fileelement.h --- a/creator/engine/inc/creator_fileelement.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - - -#ifndef CREATORFILEELEMENT_H_ -#define CREATORFILEELEMENT_H_ - -#include "creator_scriptelement.h" - -namespace creatorfile -{ - _LIT(KFile, "file"); - _LIT(KType, "type"); - _LIT(KDirectory, "directory"); - _LIT(KDefaultDir, "c:\\data"); - _LIT(KEncryption, "encryption"); - _LIT(KDRMRight, "right"); - _LIT(KDRMFL, "DRM-FL"); - _LIT(KDRMCD, "DRM-CD"); - _LIT(KDRMPlayRight, "play"); - _LIT(KDRMDisplayRight, "display"); - _LIT(KDRMPrintRight, "print"); - _LIT(KDRMExecuteRight, "execute"); - _LIT(KDRMCount, "count"); - _LIT(KDRMInterval, "interval"); - _LIT(KDRMStartTime, "starttime"); - _LIT(KDRMEndTime, "endtime"); - _LIT(KDRMAccumulated, "accumulated"); -} - -class CDRMConstraint; -class CFilesParameters; - -class CCreatorFileElement : public CCreatorScriptElement -{ -public: - static CCreatorFileElement* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC); - void ExecuteCommandL(); - -protected: - CCreatorFileElement(CCreatorEngine* aEngine); - TInt GetFileCommandL( const TDesC& aFileIdStr, TBool aRandom ) const; -private: - void ParseDRMElementsL( CCreatorScriptElement* aField, CFilesParameters* aParam ); - void ParseDRMConstraintsL( CCreatorScriptElement* aRight, CDRMConstraint* aConstraint ); - TTimeIntervalSeconds ParseTimeInterval( TDesC& aTimeString ); -private: // Data - TInt64 iTimeZone; -}; - -#endif // CREATORFILEELEMENT_H_ \ No newline at end of file diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/inc/creator_landmark.h --- a/creator/engine/inc/creator_landmark.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,106 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - - -#ifndef LANDMARKS_H_ -#define LANDMARKS_H_ - -#include "engine.h" -#include "creator_modulebase.h" - -#include -#include - -class CLandmarkParameters; -class CPosLandmarkDatabase; -class CPosLmOperation; - -static const TInt KLandmarkFieldLength = 256; - -class CCreatorLandmarks : public CCreatorModuleBase - { -public: - static CCreatorLandmarks* NewL(CCreatorEngine* aEngine); - static CCreatorLandmarks* NewLC(CCreatorEngine* aEngine); - ~CCreatorLandmarks(); - -private: - CCreatorLandmarks(); - void ConstructL(CCreatorEngine* aEngine); // from MCreatorModuleBase - TPosLmItemId GetCategoryIdL( TPosLmGlobalCategory aGlobalCategoryID ); - -public: - TBool AskDataFromUserL( TInt aCommand ); // from MCreatorModuleBase - - TInt CreateLandmarkEntryL(CLandmarkParameters *aParameters); - static TPosLmGlobalCategory GetCategoryIdL(const TDesC& aCategoryStr); - void DeleteAllL(); - void DeleteAllCreatedByCreatorL(); - -private: - CPosLandmarkDatabase* iLandmarkDb; - CLandmarkParameters* iParameters; - CPosLmOperation* iLmOperation; - RArray iEntryIds; // TPosLmItemId (==TUint32) CPosLandmark::LandmarkId() -public: - }; - - -class CLandmarkParameters : public CCreatorModuleBaseParameters - { -public: - HBufC* iName; - RArray iCategories; - HBufC* iStreet; - HBufC* iCity; - HBufC* iState; - HBufC* iCountry; - HBufC* iPostCode; - HBufC* iDescription; - HBufC* iPhonenumber; - HBufC* iUrl; - TReal64 iLatitude; - TReal64 iLongitude; - TReal32 iPositionAccuracy; - TReal32 iAltitude; - TReal32 iAltitudeAccuracy; - - void SetRandomNameL(CCreatorEngine& aEngine); - void SetRandomUrlL(CCreatorEngine& aEngine); - void AddRandomCategoryL(CCreatorEngine& aEngine); - void SetRandomStreetL(CCreatorEngine& aEngine); - void SetRandomCityL(CCreatorEngine& aEngine); - void SetRandomStateL(CCreatorEngine& aEngine); - void SetRandomCountryL(CCreatorEngine& aEngine); - void SetRandomPostCodeL(CCreatorEngine& aEngine); - void SetRandomLatitudeL(CCreatorEngine& aEngine); - void SetRandomLongitudeL(CCreatorEngine& aEngine); - void SetRandomPositionAccuracyL(CCreatorEngine& aEngine); - void SetRandomAltitudeL(CCreatorEngine& aEngine); - void SetRandomAltitudeAccuracyL(CCreatorEngine& aEngine); - void SetRandomDescriptionL(CCreatorEngine& aEngine); - void SetRandomPhoneNumberL(CCreatorEngine& aEngine); - -private: - -public: - CLandmarkParameters(); - ~CLandmarkParameters(); - }; -#endif /*LANDMARKS_H_*/ diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/inc/creator_landmarkelement.h --- a/creator/engine/inc/creator_landmarkelement.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - - -#ifndef CREATORLANDMARKELEMENT_H_ -#define CREATORLANDMARKELEMENT_H_ - -#include "creator_scriptelement.h" - -namespace creatorlandmark -{ - _LIT(KLandmark, "landmark"); - _LIT(KName, "name"); - _LIT(KCategory, "category"); - _LIT(KDescription, "description"); - _LIT(KStreet, "street"); - _LIT(KPostalcode, "postalcode"); - _LIT(KCity, "city"); - _LIT(KState, "state"); - _LIT(KCountry, "country"); - _LIT(KPhonenumber, "phonenbr"); - _LIT(KUrl, "url"); - _LIT(KLatitude, "latitude"); - _LIT(KLongitude, "longitude"); - _LIT(KPositionaccuracy, "positionaccuracy"); - _LIT(KAltitude, "altitude"); - _LIT(KAltitudeaccuracy, "altitudeaccuracy"); -} - -class CCreatorLandmarkElement : public CCreatorScriptElement -{ -public: - static CCreatorLandmarkElement* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC); - void ExecuteCommandL(); - -protected: - CCreatorLandmarkElement(CCreatorEngine* aEngine); -}; - -#endif /*CREATORLANDMARKELEMENT_H_*/ diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/inc/creator_log.h --- a/creator/engine/inc/creator_log.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,112 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - - - -#ifndef __CREATORLOGS_H__ -#define __CREATORLOGS_H__ - -#include "engine.h" -#include "creator_modulebase.h" - - -#include -//#include -#include -#include -//#include -#include - - - -class CCreatorEngine; -class CLogsParameters; - - -class CCreatorLogs : public CActive, public MCreatorModuleBase, public MUIObserver - { -enum TCreatorLogsStatus{ - ECreatorLogsDelete = 0, - ECreatorLogsStart -}; - -public: - static CCreatorLogs* NewL(CCreatorEngine* aEngine); - static CCreatorLogs* NewLC(CCreatorEngine* aEngine); - ~CCreatorLogs(); - -private: - CCreatorLogs(); - void ConstructL(CCreatorEngine* aEngine); // from MCreatorModuleBase - - void RunL(); // from CActive - void DoCancel(); // from CActive - -public: - TBool AskDataFromUserL( TInt aCommand ); // from MCreatorModuleBase - void QueryDialogClosedL(TBool aPositiveAction, TInt aUserData); - - TInt CreateMissedCallEntryL(CLogsParameters *aParameters); - TInt CreateReceivedCallEntryL(CLogsParameters *aParameters); - TInt CreateDialledNumberEntryL(CLogsParameters *aParameters); - void DeleteAllL(); - void DeleteAllCreatedByCreatorL(); - -private: - CCreatorEngine* iEngine; - TInt iCommand; - TInt iEntriesToBeCreated; - TInt iDummy; - - CLogClient* iLogClient; - CLogEvent* iLogEvent; - CActiveSchedulerWait iLogWriteWait; - - CLogsParameters* iParameters; - RArray iEntryIds; // TLogId ( == TInt32) CLogEvent::Id() - -public: - }; - - -class CLogsParameters : public CCreatorModuleBaseParameters - { -public: - /*HBufC* iMissedCallPhoneNumber; - TTime iMissedCallEventTime; - - HBufC* iReceivedCallPhoneNumber; - TTime iReceivedCallEventTime; - TLogDuration iReceivedCallDuration; - - HBufC* iDialledNumberPhoneNumber; - TTime iDialledNumberEventTime; - TLogDuration iDialledNumberDuration;*/ - HBufC* iPhoneNumber; - TTime iEventTime; - TLogDuration iDuration; - -public: - CLogsParameters(); - ~CLogsParameters(); - }; - - - -#endif // __CREATORLOGS_H__ diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/inc/creator_logelement.h --- a/creator/engine/inc/creator_logelement.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - - -#ifndef CREATORLOGELEMENT_H_ -#define CREATORLOGELEMENT_H_ - -#include "creator_scriptelement.h" - -namespace creatorlog -{ - _LIT(KLog, "log"); - _LIT(KDirection, "direction"); - _LIT(KDuration, "duration"); - _LIT(KPhonenumber, "phonenumber"); - _LIT(KDatetime, "datetime"); - _LIT(KMissed, "missed"); - _LIT(KIn, "in"); - _LIT(KOut, "out"); -} - -class CCreatorLogElement : public CCreatorScriptElement -{ -public: - static CCreatorLogElement* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC); - void ExecuteCommandL(); - -protected: - CCreatorLogElement(CCreatorEngine* aEngine); - TInt GetLogCommandL( const TDesC& aFileIdStr, TBool aRandom ) const; -}; - -#endif /*CREATORLOGELEMENT_H_*/ diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/inc/creator_mailbox.h --- a/creator/engine/inc/creator_mailbox.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,190 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - - - -#ifndef __CREATORMAILBOXES_H__ -#define __CREATORMAILBOXES_H__ - -#include "engine.h" -#include "creator_modulebase.h" - - -#include -#include -#include -#include -#include -#include -#include -#include - -class CCreatorEngine; -class CMailboxesParameters; - -const TInt KDefaultSmtpPort = 25; - -enum TMailboxType - { - EMailboxPOP3, - EMailboxIMAP4 - }; - -class CCreatorMailboxes : public CCreatorModuleBase, public MMsvSessionObserver - { -public: - static CCreatorMailboxes* NewL(CCreatorEngine* aEngine); - static CCreatorMailboxes* NewLC(CCreatorEngine* aEngine); - ~CCreatorMailboxes(); - -private: - CCreatorMailboxes(); - void ConstructL(CCreatorEngine* aEngine); // from MCreatorModuleBase - - void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3); // from MMsvSessionObserver - void StoreIMEIToEntryL(const TMsvId aMailboxId); - void GetIMEIFromThePhoneL(); - - void PopulateSmtpSettingsL( - CEmailAccounts& aEmailAccount, - CImSmtpSettings& aSmtpSettings, - CImIAPPreferences& aIApSettings, - const CMailboxesParameters& aParameters ); - - void PopulateImapSettingsL( - CEmailAccounts& aEmailAccount, - CImImap4Settings& aImapSettings, - CImIAPPreferences& aIApSettings, - const CMailboxesParameters& aParameters ); - - void PopulatePopSettingsL( - CEmailAccounts& aEmailAccount, - CImPop3Settings& aPopSettings, - CImIAPPreferences& aIApSettings, - const CMailboxesParameters& aParameters ); - - -public: - TBool AskDataFromUserL( TInt aCommand ); // from MCreatorModuleBase - - TInt CreateMailboxEntryL(CMailboxesParameters *aParameters); - void DeleteAllL(); - void DeleteAllCreatedByCreatorL(); - - -private: - CMailboxesParameters* iParameters; - TBuf<50> iIMEI; - RArray iEntryIds; - -public: - }; - - -class CMailboxesParameters : public CCreatorModuleBaseParameters - { -public: -// HBufC* iMailboxName; -// HBufC* iAccessPoint; -// HBufC* iMyMailAddress; -// HBufC* iOutgoingMailServer; -// TBool iSendMessageImmediately; -// TBool iSendCopyToSelf; -// TBool iIncludeSignature; -// HBufC* iUserName; -// HBufC* iPassword; -// HBufC* iIncomingMailServer; -// TMailboxType iMailboxType; // IMAP4 or POP3 -// TBool iSecurityOn; // SecureSockets -// TBool iSSLWrapper; // SSL Wrapper -// TBool iAPOPSecureLogin; // POP3 only -// TBool iRetrieveAttachment; // IMAP4 only -// TInt32 iRetrieveHeaders; // IMAP4 only - - enum TGetEmailOption - { - EUndef = 0, - EGetHeaders, - EGetBodyText, - EGetBodyTextAndAttachments, - EGetAttachments, - EGetBodyAlternativeText, - EGetEmailOptionLast - }; - - HBufC* iMailboxName; - HBufC* iIncomingLoginName; - HBufC* iIncomingPassword; - HBufC* iIncomingServerName; - HBufC* iIncomingConnectionMethod; - HBufC* iIncomingFolderPath; - HBufC* iPathSeparator; - HBufC* iOutgoingLoginName; - HBufC* iOutgoingPassword; - HBufC* iOutgoingServerName; - HBufC* iOutgoingConnectionMethod; - HBufC* iOwnEmailAddress; - HBufC* iOwnEmailAlias; - HBufC* iReceiptAddress; - HBufC* iReplyToAddress; - - TInt iIncomingPort; - TInt iAttachmentSizeLimit; - TInt iBodyTextSizeLimit; - TInt iAttachmentFetchSize; - TInt iImapIdleTimeout; - TInt iMaxEmailSize; - TInt iSyncRate; - TInt iInboxSyncLimit; // -1 = All - TInt iMailboxSyncLimit; // -1 = All - TInt iOutgoingPort; - TInt iToCCIncludeLimit; - - TBool iIncomingSSLWrapper; - TBool iIncomingSecureSockets; - TBool iAcknowledgeReceipts; - TBool iAutoSendOnConnect; - TBool iDeleteEmailsAtDisconnect; - TBool iImapIdleCommand; - TBool iMarkSeenInSync; - TBool iEnableExpungeMode; - TBool iUseApop; - TBool iDisconnectedUserMode; - TBool iOutgoingSSLWrapper; - TBool iOutgoingSecureSockets; - TBool iIncludeSignature; - TBool iAddVCard; - TBool iRequestReceipts; - TBool iSmtpAuth; - - TGetEmailOption iGetEmailOptions; - TFolderSubscribeType iSubscribeType; - TFolderSyncType iSyncType; - TImSMTPSendCopyToSelf iSendCopyToSelf; - TImSMTPSendMessageOption iSendOption; - TMailboxType iMailboxType; // IMAP4 or POP3 - -public: - CMailboxesParameters(); - ~CMailboxesParameters(); - }; - - - -#endif // __CREATORMAILBOXES_H__ diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/inc/creator_mailboxelement.h --- a/creator/engine/inc/creator_mailboxelement.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,132 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - - -#ifndef CREATORMAILBOXELEMENT_H_ -#define CREATORMAILBOXELEMENT_H_ - -#include "creator_scriptelement.h" - -class CMailboxesParameters; - -namespace creatormailbox -{ - _LIT(Kmailbox, "mailbox"); - _LIT(Kname, "name"); - _LIT(Kincomingport, "incomingport"); - _LIT(Kincomingsslwrapper, "incomingsslwrapper"); - _LIT(Kincomingsecuresockets, "incomingsecuresockets"); - _LIT(Kincomingloginname, "incomingloginname"); - _LIT(Kincomingpassword, "incomingpassword"); - _LIT(Kincomingservername, "incomingservername"); - _LIT(Kincomingconnectionmethod, "incomingconnectionmethod"); - _LIT(Kacknowledgereceipts, "acknowledgereceipts"); - _LIT(Kattachmentsizelimit, "attachmentsizelimit"); - _LIT(Kautosendonconnect, "autosendonconnect"); - _LIT(Kbodytextsizelimit, "bodytextsizelimit"); - _LIT(Kdeletemailsatdisconnect, "deletemailsatdisconnect"); - _LIT(Kattachmentfetchsize, "attachmentfetchsize"); - _LIT(Kincomingfolderpath, "incomingfolderpath"); - _LIT(Kpathseparator, "pathseparator"); - _LIT(Kgetemailoptions, "getemailoptions"); - _LIT(Kimapidlecommand, "imapidlecommand"); - _LIT(Kimapidletimeout, "imapidletimeout"); - _LIT(Kmaxemailsize, "maxemailsize"); - _LIT(Ksubscribetype, "subscribetype"); - _LIT(Ksyncrate, "syncrate"); - _LIT(Kfoldersynctype, "foldersynctype"); - _LIT(Kmarkseeninsync, "markseeninsync"); - _LIT(Kenableexpungemode, "enableexpungemode"); - _LIT(Kuseapopsecurelogin, "useapopsecurelogin"); - _LIT(Kinboxsynclimit, "inboxsynclimit"); - _LIT(Kmailboxsynclimit, "mailboxsynclimit"); - _LIT(Kdisconnectedusermode, "disconnectedusermode"); - _LIT(Koutgoingport, "outgoingport"); - _LIT(Koutgoingsslwrapper, "outgoingsslwrapper"); - _LIT(Koutgoingsecuresockets, "outgoingsecuresockets"); - _LIT(Koutgoingloginname, "outgoingloginname"); - _LIT(Koutgoingpassword, "outgoingpassword"); - _LIT(Koutgoingservername, "outgoingservername"); - _LIT(Koutgoingconnectionmethod, "outgoingconnectionmethod"); - _LIT(Kincludesignature, "includesignature"); - _LIT(Kaddvcard, "addvcard"); - _LIT(Kownemail, "ownemail"); - _LIT(Kemailalias, "emailalias"); - _LIT(Kreceiptaddress, "receiptaddress"); - _LIT(Kreplytoaddress, "replytoaddress"); - _LIT(Krequestreceipts, "requestreceipts"); - _LIT(Ksmtpauth, "smtpauth"); - _LIT(Kcopytoself, "copytoself"); - _LIT(Ksendoption, "sendoption"); - _LIT(Ktoccincludelimit, "toccincludelimit"); - - - // Get email options: - _LIT(Kgetheaders, "getheaders"); - _LIT(Kgetbodytext, "getbodytext"); - _LIT(Kgetbodytextandattachments, "getbodytextandattachments"); - _LIT(Kgetattachments, "getattachments"); - _LIT(Kgetbodyalternativetext, "getbodyalternativetext"); - - // Subscribe types: - _LIT(Kupdateneither, "updateneither"); - _LIT(Kupdatelocal, "updatelocal"); - _LIT(Kupdateremote, "updateremote"); - _LIT(Kupdateboth, "updateboth"); - - // Folder sync. types: - _LIT(Kusecombination, "usecombination"); - _LIT(Kuselocal, "uselocal"); - _LIT(Kuseremote, "useremote"); - - // Send copy to self option: - _LIT(Kno, "no"); - _LIT(Kto, "to"); - _LIT(Kcc, "cc"); - _LIT(Kbcc, "bcc"); - - // Send option: - _LIT(Kimmediately, "immediately"); - _LIT(Konnextconnection, "onnextconnection"); - _LIT(Konrequest, "onrequest"); - - // Mailbox types: - _LIT(KMailboxType, "type"); - _LIT(Kpop3, "pop3"); - _LIT(Kimap4, "imap4"); - _LIT(Ksyncml, "syncml"); -} - -class CCreatorMailboxElement : public CCreatorScriptElement -{ -public: - static CCreatorMailboxElement* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC); - void ExecuteCommandL(); - -protected: - CCreatorMailboxElement(CCreatorEngine* aEngine); - TBool SetTextParamL(const TDesC& aElemName, const TDesC& aElemContent, CMailboxesParameters* aParams, TBool aSetRandom ); - TBool SetBooleanParamL(const TDesC& aElemName, const TDesC& aElemContent, CMailboxesParameters* aParams, TBool aSetRandom ); - TBool SetIntegerParamL(const TDesC& aElemName, const TDesC& aElemContent, CMailboxesParameters* aParams, TBool aSetRandom ); - TBool SetEnumParamL(const TDesC& aElemName, const TDesC& aElemContent, CMailboxesParameters* aParams, TBool aSetRandom ); - - TBool GetBooleanValueL(const TDesC& aElemContent, TBool aSetRandom); -}; - -#endif /*CREATORMAILBOXELEMENT_H_*/ diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/inc/creator_message.h --- a/creator/engine/inc/creator_message.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,197 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - - - -#ifndef __CREATORMESSAGES_H__ -#define __CREATORMESSAGES_H__ - -#include "engine.h" -#include "creator_modulebase.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - - -class CCreatorEngine; -class CMessagesParameters; -class CAsyncWaiter; - -enum TMessageType - { - ESMS = 0, - EMMS, - EAMS, - EEmail, - ESmartMessage, - EIrMessage, - EBTMessage - }; - -enum TFolderType - { - EInbox = 0, - EDrafts, - EOutbox, - ESent, - EMailbox - }; - -class CRecipientInfo : public CBase -{ -public: - CRecipientInfo(); - virtual ~CRecipientInfo(); - - void SetPhoneNumber(HBufC* aPhone); - void SetEmailAddress(HBufC* aEmail); - const HBufC* PhoneNumber() const; - const HBufC* EmailAddress() const; - -private: - HBufC* iPhoneNumber; - HBufC* iEmailAddress; -}; - -class CCreatorMessages : public CCreatorModuleBase, public MMsvSessionObserver - { -enum TCreatorMessagesStatus{ - ECreatorMessagesDelete = 0, - ECreatorMessagesStart, - ECreatorMessagesMessageType, - ECreatorMessagesFolderType, - ECreatorMessagesMessageStatus, - ECreatorMessagesCharsInBody, - ECreatorMessagesAttachment, -}; - -public: - static CCreatorMessages* NewL(CCreatorEngine* aEngine); - static CCreatorMessages* NewLC(CCreatorEngine* aEngine); - ~CCreatorMessages(); - -private: - CCreatorMessages(); - void ConstructL(CCreatorEngine* aEngine); // from MCreatorModuleBase - - TInt CreateSMSEntryL(const CMessagesParameters& parameters); - TInt CreateMMSEntryL(const CMessagesParameters& parameters); - TInt CreateAMSEntryL(const CMessagesParameters& parameters); - TInt CreateEmailEntryL(const CMessagesParameters& parameters); - TInt CreateSmartMessageEntryL(const CMessagesParameters& parameters); - TInt CreateObexEntryL(TUid aMtm, const CMessagesParameters& parameters); - void HandleAttachementsL(const CMessagesParameters& parameters, CMsvStore* store, TInt err ); - void HandleAttachementL(CMsvStore* store, TInt err, TFileName& sourceFileName ); - - CMsvEntrySelection* DoGetListOfAccountsL(CMsvSession& aSession, TUid aMtm, TBool aAlwaysListHidden); - TMsvId DefaultServiceForMTML(CMsvSession& aSession, TUid aMtm, TBool aFindFirstServiceIfNoDefault); - - void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3); // from MMsvSessionObserver - - void AddRecipientsL(CBaseMtm& aMtm, const CMessagesParameters& aParameters, TBool aUseEmailAddress ); - void GetLinkedAddressesL( RPointerArray& aAddressArray, - const RArray& aLinkIds, - TBool aUseEmailAddress, - TInt aNumOfExistingAddresses ); - - void GetAllRecipientsL(RPointerArray& aRecipientArray, const CMessagesParameters& aParameters, TBool aUseEmailAddress ); - void SetSenderToEntryDetailsL(TMsvEntry& aMsgEntry, const CMessagesParameters& aParameters, TBool aUseEmailAddress); - void SetRecipientToEntryDetailsL(TMsvEntry& aMsgEntry, const CMessagesParameters& aParameters, TBool aUseEmailAddress); - void AddSenderToMtmAddresseeL(CBaseMtm& aMtm, const CMessagesParameters& aParameters, TBool aUseEmailAddress ); - void AddMtmSenderL(CMmsClientMtm& aMtm, const CMessagesParameters& aParameters, TBool aUseEmailAddress ); - void GetSendersL(RPointerArray& aSenderArray, const CMessagesParameters& aParameters, TBool aUseEmailAddress, TInt aMaxNum ); - void DeleteAllMessagesL( TBool aOnlyCreatedWithCreator ); - void DeleteAllFromFolderL( const TMsvId aContext, CMsvSession* aSession, CSmsClientMtm* aClientMtm, TBool aOnlyCreatedWithCreator = EFalse ); - -public: - TBool AskDataFromUserL( TInt aCommand ); // from MCreatorModuleBase - void QueryDialogClosedL(TBool aPositiveAction, TInt aUserData); //from MUIObserver - - TInt CreateMessageEntryL(CMessagesParameters *aParameters, TBool aTakeUserGivenParameters=EFalse); - TInt CreateRandomMessageEntryL(TInt aCommand); - void DeleteAllL(); - void DeleteAllCreatedByCreatorL(); - -private: - CMessagesParameters* iParameters; - TMessageType iMessageType; - TFolderType iFolderType; - TInt iDefinedMessageLength; - CArrayFixFlat* iAttachments; - //RPointerArray iAttachmentPaths; - TBool iCreateAsUnread; - TMsvId iUserSelectedMailbox; - HBufC* iTmpPhoneNumber; - HBufC* iTmpEmail; - RArray iEntryIds; // TMsvId ( == TInt32 ) TMsvEntry::Id() - CAsyncWaiter* iWaiter; - RPointerArray iSenderArray; - RPointerArray iRecipientArray; -public: - }; - - -class CMessagesParameters : public CCreatorModuleBaseParameters - { -public: - TMessageType iMessageType; - TFolderType iFolderType; - HBufC* iSenderAddress; - HBufC* iRecipientAddress; - RPointerArray iRecipientAddressArray; - HBufC* iMessageSubject; - HBufC* iMessageBodyText; - CArrayFixFlat* iAttachments; - RPointerArray iAttachmentPaths; - TInt iDefinedMessageLength; - TUid iBIOMessageType; - TBool iCreateAsUnread; - RArray iRecipientLinkIds; - RArray iSenderLinkIds; - TInt iNumberOfExistingRecipients; - TInt iNumberOfExistingSenders; - -public: - CMessagesParameters(); - ~CMessagesParameters(); - }; - - - -#endif // __CREATORMESSAGES_H__ diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/inc/creator_messageelement.h --- a/creator/engine/inc/creator_messageelement.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,93 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - -#ifndef CREATORMESSAGEELEMENT_H_ -#define CREATORMESSAGEELEMENT_H_ - -#include "creator_scriptelement.h" -#include "creator_message.h" - -namespace creatormsg -{ - _LIT(KMessage, "message"); - _LIT(KType, "type"); - _LIT(KTo, "to"); - _LIT(KFrom, "from"); - _LIT(KFolder, "folder"); - _LIT(KSubject, "subject"); - _LIT(KText, "text"); - _LIT(KAttachmentPath, "attachmentpath"); - _LIT(KAttachmentId, "attachmentid"); - _LIT(KStatus, "status"); - _LIT(KSms, "sms"); - _LIT(KMms, "mms"); - _LIT(KAms, "ams"); - _LIT(KEmail, "email"); - _LIT(KSmart, "smart"); - _LIT(KBt, "bt"); - _LIT(KIr, "ir"); - _LIT(KSent, "sent"); - _LIT(KInbox, "inbox"); - _LIT(KDraft, "draft"); - _LIT(KOutbox, "outbox"); - _LIT(KMailbox, "mailbox"); - _LIT(KRead, "read"); - _LIT(KNew, "new"); -} - -/* - * Builds message parameters from the parsed script and adds a command to the engine - */ -class CCreatorMessageElement : public CCreatorScriptElement -{ -public: - static CCreatorMessageElement* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC); - void ExecuteCommandL(); -protected: - CCreatorMessageElement(CCreatorEngine* aEngine); - /* - * Creates message address. The address type is based on the message type. - * @return Phone number string for SMS, MMS, AMS and Smart messages. Email address for other types. - * @param msgType Message type. - */ - HBufC* CreateMessageAddressLC(const TDesC& msgType); - /* - * Sets message type to parameters - * @param aParameters Message parameters - * @param aMsgTypeStr Message type string - */ - void SetMessageTypeL(CMessagesParameters& aParameters, const TDesC& aMsgTypeStr ) const; - /* - * Gets length of the random data - * @return Length of the random data - * @param aRandomLenStr String defining the random length (from the script) - * @param aMsgType Message type string - */ - TInt GetRandomBodyLengthL(const TDesC& aRandomLenStr, const TDesC& aMsgType ) const; - /* - * Gets maximum length of the body text - * @return Maximum length of the body text - * @param aMsgType Message type string - */ - TInt GetMaxBodyLength( const TDesC& aMsgType ) const; - -}; - - -#endif /*CREATORMESSAGEELEMENT_H_*/ diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/inc/creator_modulebase.h --- a/creator/engine/inc/creator_modulebase.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,188 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#ifndef __CREATOR_MODULEBASE_H__ -#define __CREATOR_MODULEBASE_H__ - -#include - -#include "engine.h" -#include "creator_traces.h" - -// Dictionary uids for each Creator module. -// Dictionaries are for storing item identifiers created by Creator. -// Item identifiers are for enabling deletion of only items created by Creator. -const TUid KUidDictionaryUidContacts = { 0x00 }; -const TUid KUidDictionaryUidContactGroups = { 0x01 }; -const TUid KUidDictionaryUidCalendar = { 0x02 }; -const TUid KUidDictionaryUidBrowserBookmarks = { 0x03 }; -const TUid KUidDictionaryUidFiles = { 0x04 }; -const TUid KUidDictionaryUidLogs = { 0x05 }; -const TUid KUidDictionaryUidMessages = { 0x06 }; -const TUid KUidDictionaryUidMailbox = { 0x07 }; -const TUid KUidDictionaryUidIAP = { 0x08 }; -const TUid KUidDictionaryUidIMPS = { 0x09 }; -const TUid KUidDictionaryUidNotes = { 0x0A }; -const TUid KUidDictionaryUidLandmarks = { 0x0B }; -const TUid KUidDictionaryUidBrowserSavedPg = { 0x0C }; -const TUid KUidDictionaryUidBrowserBookmarkF = { 0x0D }; -const TUid KUidDictionaryUidBrowserSavedPgF = { 0x0E }; - -class CCreatorEngine; -class MCreatorModuleBaseParameters; -class CCommandParser; - -_LIT(KSavingText, "Saving"); -_LIT(KDeletingText, "Deleting"); - -class MCreatorModuleBase - { -public: - -private: - // constructs the module, add "iEngine = aEngine" and other construction stuff to the body - virtual void ConstructL( CCreatorEngine* aEngine ) = 0; - -public: - // this one is called when user select some features directly from menu, not running a script - // should call CreateRandomData() function - // returns ETrue when success, EFalse when user has cancelled - virtual TBool AskDataFromUserL( TInt aCommand ) = 0; - virtual void DeleteAllL() = 0; - virtual void DeleteAllCreatedByCreatorL() = 0; - }; - - -class CCreatorModuleBase : public CBase, public MCreatorModuleBase, public MUIObserver - { - -public: - enum TCreatorModuleStatus - { - ECreatorModuleDelete = 0, - ECreatorModuleStart - }; - - CCreatorModuleBase() - { - iEntriesToBeCreated = 1; - } - - virtual TBool AskDataFromUserL(TInt aCommand) - { - iCommand = aCommand; - return EFalse;// will finish user interaction and engine will shutdown modules - } - - virtual void QueryDialogClosedL(TBool aPositiveAction, TInt aUserData) - { - LOGSTRING("Creator: CCreatorModuleBase::QueryDialogClosedL"); - - if( aPositiveAction == EFalse ) - { - iEngine->ShutDownEnginesL(); - return; - } - const TDesC* showText = &KSavingText; - TBool finished(EFalse); - TBool retval(ETrue); - switch(aUserData) - { - case ECreatorModuleDelete: - showText = &KDeletingText; - iEntriesToBeCreated = 1; - finished = ETrue; - break; - case ECreatorModuleStart: - finished = ETrue; - break; - default: - //some error - retval = EFalse; - break; - } - if( retval == EFalse ) - { - iEngine->ShutDownEnginesL(); - } - else if( finished ) - { - // add this command to command array - iEngine->AppendToCommandArrayL(iCommand, NULL, iEntriesToBeCreated); - // started exucuting commands - iEngine->ExecuteFirstCommandL( *showText ); - } - } - -protected: - // constructs the module, add "iEngine = aEngine" and other construction stuff to the body - virtual void ConstructL(CCreatorEngine* aEngine) - { - iEngine = aEngine; - }; - -protected: - CCreatorEngine* iEngine; - TInt iCommand; - TInt iEntriesToBeCreated; - TInt iDummy; - }; - -class MCreatorModuleBaseParameters - { - // a base class for the parameters, no default implementation - - public: - enum TParseParams - { - EParamNone = 0, - ECalendarMeeting, - ECalendarMemo, - ECalendarAnniv, - ECalendarTodo - }; - -public: - virtual void ParseL(CCommandParser* /*aParser*/, TParseParams /*aCase = 0*/) = 0; - - - }; - -// Following struct represents the parameters that links for example contact groups -// to contac-sets. -typedef struct - { - TInt iLinkId; // ID - TInt iLinkAmount; // Amount of elements in linked set - } TLinkIdParam; - - -class CCreatorModuleBaseParameters : public CBase, public MCreatorModuleBaseParameters - { - public: - virtual void ParseL(CCommandParser* /*aParser*/, TParseParams /*aCase = 0*/){}; - virtual TInt ScriptLinkId() const {return -1;}; - virtual void SetScriptLinkId(TInt) {}; - // a base class for the parameters, no default implementation - }; - - - - -#endif // __CREATOR_MODULEBASE_H__ - diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/inc/creator_note.h --- a/creator/engine/inc/creator_note.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,75 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#ifndef __CREATORNOTEPAD_H__ -#define __CREATORNOTEPAD_H__ - -#include "engine.h" -#include "creator_modulebase.h" -#include "creator_notepadwrapper.h" - -#include - -static const TInt KNotepadFieldLength = 1024; - -class CCreatorEngine; -class CNotepadParameters; -class CCreatorNotepadWrapper; - - -class CCreatorNotepad : public CCreatorModuleBase - { -public: - static CCreatorNotepad* NewL(CCreatorEngine* aEngine); - static CCreatorNotepad* NewLC(CCreatorEngine* aEngine); - ~CCreatorNotepad(); - -private: - CCreatorNotepad(); - void ConstructL(CCreatorEngine* aEngine); // from MCreatorModuleBase - -public: - TBool AskDataFromUserL( TInt aCommand ); // from MCreatorModuleBase - - TInt CreateNoteEntryL(CNotepadParameters *aParameters); - void DeleteAllL(); - void DeleteAllCreatedByCreatorL(); - -private: - CCreatorNotepadWrapper* iNotepadWrapper; - - CNotepadParameters* iParameters; - RFs& iFs; - -public: - }; - - -class CNotepadParameters : public CCreatorModuleBaseParameters - { -public: - HBufC* iNoteText; - -public: - CNotepadParameters(); - ~CNotepadParameters(); - }; - - - -#endif // __CREATORNOTEPAD_H__ diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/inc/creator_noteelement.h --- a/creator/engine/inc/creator_noteelement.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - -#ifndef CREATORNOTEELEMENT_H_ -#define CREATORNOTEELEMENT_H_ - -#include "creator_scriptelement.h" - -namespace creatornote -{ - _LIT(KNote, "note"); - _LIT(KText, "text"); -} - -class CCreatorNoteElement : public CCreatorScriptElement -{ -public: - static CCreatorNoteElement* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC); - void ExecuteCommandL(); - -protected: - CCreatorNoteElement(CCreatorEngine* aEngine); -}; - -#endif /*CREATORNOTEELEMENT_H_*/ diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/inc/creator_notepadwrapper.h --- a/creator/engine/inc/creator_notepadwrapper.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef __CREATORNOTEPADWRAPPER_H__ -#define __CREATORNOTEPADWRAPPER_H__ - -//#include "engine.h" -//#include "creator_modulebase.h" - - -#include -#include -#include -#include -#include - - -class CCreatorNotepadWrapper : public CBase - { - public: - static CCreatorNotepadWrapper* NewL(); - static CCreatorNotepadWrapper* NewLC(); - ~CCreatorNotepadWrapper(); - - private: - CCreatorNotepadWrapper(); - void ConstructL(); - - public: - TInt CreateNoteL( const TDesC& aText ); - void DeleteAllL(); - - private: - AgendaUtil *iAgendaUtil; - NotesEditorInterface *iNotepadApi; //QT Notes api - QPluginLoader* iNotesEditorPluginLoader; // for loading QT Notes api - }; - -#endif // __CREATORNOTEPADWRAPPER_H__ diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/inc/creator_phonebook.h --- a/creator/engine/inc/creator_phonebook.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,142 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - -#ifndef __CREATORPHONEBOOK_H__ -#define __CREATORPHONEBOOK_H__ - -#include "creator_phonebookbase.h" -#include "creator_randomdatafield.h" -#include "creator_phonebookwrapper.h" - - - -class CCreatorEngine; -class CCreatorModuleBaseParameters; - -class CContactDatabase; -class CPhonebookParameters; -class CCreatorPhonebookWrapper; - -class CCreatorPhonebook : public CCreatorPhonebookBase - { -public: - static CCreatorPhonebook* NewL(CCreatorEngine* aEngine); - static CCreatorPhonebook* NewLC(CCreatorEngine* aEngine); - ~CCreatorPhonebook(); - -private: - CCreatorPhonebook(); - void ConstructL(CCreatorEngine* aEngine); // from MCreatorModuleBase - -public: - TInt CreateContactEntryL(CCreatorModuleBaseParameters *aParameters); - TInt CreateGroupEntryL(CCreatorModuleBaseParameters *aParameters); - TInt CreateSubscribedContactEntryL(CCreatorModuleBaseParameters *aParameters); - - - void DeleteAllL(); - void DeleteAllCreatedByCreatorL(); - void DeleteAllGroupsL(); - void DeleteAllGroupsCreatedByCreatorL(); - - void TestPrintOut(CPhonebookParameters* aParam); - inline CCreatorPhonebookWrapper* GetPhonebookWrapper(){ return iPhonebookWrapper; }; -private: - - void InitializeContactParamsL(); - TBool IsContactGroupL( TUint32& aLink ); - void StoreLinksForDeleteL( RArray& aLinks, TUid aStoreUid ); - void DeleteContactsL( RArray& aContactsToDelete, TUid aStoreUid ); - void DeleteItemsCreatedWithCreatorL( TUid aStoreUid ); - void DoDeleteItemsCreatedWithCreatorL( TUid aStoreUid, CDictionaryFileStore* aStore ); - TBool HasOtherThanGroupsL(); - - -private: - CCreatorPhonebookWrapper* iPhonebookWrapper; - TInt iOpCounter; - - CPhonebookParameters* iParameters; - - static TInt iUrlFields[]; - static TInt iEmailFields[]; - - RArray iContactLinkArray; - RArray iContactsToDelete; - RArray iContactGroupsToDelete; - - RArray iPreviousDeleteLinks; - -private: - //new variables - /// Ref: the target of the copy - - - /// Own: Contact database for this store - CContactDatabase* iContactDb; - //Contacts found in contacts db. - - }; - -/** - * phonebook parameters - */ - - -class CPhonebookParameters : public CCreatorModuleBaseParameters - { -public: - void ParseL(CCommandParser* parser, TParseParams /*aCase = 0*/); - - TInt CPhonebookParameters::ScriptLinkId() const; - void CPhonebookParameters::SetScriptLinkId(TInt aLinkId); - - TCreatorContactFields iContactFields; - - HBufC* iGroupName; - TInt iContactsInGroup; - TInt iNumberOfPhoneNumberFields; - TInt iNumberOfURLFields; - TInt iNumberOfEmailAddressFields; - TInt iContactSetPtr; - RArray iLinkIds; // For contactgroup. Stores the linked contact ids. - - -public: - CPhonebookParameters(); - ~CPhonebookParameters(); - -private: - TInt iLinkId; // For contact. Stores the contact id - }; - - -class CCreatorContactField : public CBase //, public MCreatorRandomDataField - { -public: - static CCreatorContactField* NewL(); - void AddFieldToParamL( CCreatorEngine* aEngine, CPhonebookParameters* aParam, TInt aType, TInt aRand = KErrNotFound ); - void AddFieldToParamL( CPhonebookParameters* aParam, TInt aType, TPtrC aContent ); - ~CCreatorContactField(); -private: - CCreatorContactField(); - void ConstructL(); - }; - -#endif // __CREATORPHONEBOOK_H__ diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/inc/creator_phonebookapi.h --- a/creator/engine/inc/creator_phonebookapi.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#ifndef CREATOR_PHONEBOOKAPI_H_ -#define CREATOR_PHONEBOOKAPI_H_ - -#include -#include -#include -#include -QTM_USE_NAMESPACE - - -class CCreatorPhonebookAPI - { -public: - CCreatorPhonebookAPI (); - ~CCreatorPhonebookAPI (); - - quint32 saveContact( const QList& list ); - quint32 createGroup( const QString& groupName ); - int numberOfContacts(); - int addContactToGroup( QContactLocalId group, QContactLocalId contact ); - int addToGroup(QContactLocalId group, int amount); - bool deleteAllContacts(); - bool deleteAllContacts( const QString& type ); - bool deleteContacts( const QList& list ); - QContact contact( const QContactLocalId& contactId ); - - QString phoneNumber( const QContactLocalId& contactId ); - bool contactDetails( const QContactLocalId& contactId, QString& name, QString& phoneNumber, QString& email ); - -private: - bool IsContactGroupL( const QContact& contact ); - -private: - QContactManager* mContactMngr; - - }; - -#endif /* CREATOR_PHONEBOOKAPI_H_ */ diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/inc/creator_phonebookbase.h --- a/creator/engine/inc/creator_phonebookbase.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,70 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - - -#ifndef __CCREATORPHONEBOOKBASE_H_ -#define __CCREATORPHONEBOOKBASE_H_ - -#include "creator_modulebase.h" - -static const TInt KPhonebookFieldLength = 128; -static const TInt KCreateRandomAmountOfGroups = 1; - -class CCreatorModuleBaseParameters; - -class CCreatorPhonebookBase : public CCreatorModuleBase -{ -enum TCreatorPhonebookStatus{ - ECreatorPhonebookDelete = 0, - ECreatorPhonebookStart, - ECreatorPhonebookGetContactFields, - ECreatorPhonebookGetPhoneNumbersCount, - ECreatorPhonebookGetUrlsCount, - ECreatorPhonebookGetEmailsCount, - ECreatorPhonebookContactsAllFields, - ECreatorPhonebookGetGroupFields, - ECreatorPhonebookGetContactsInGroup -}; - -public: - - virtual TInt CreateContactEntryL(CCreatorModuleBaseParameters *aParameters) = 0; - virtual TInt CreateGroupEntryL(CCreatorModuleBaseParameters *aParameters) = 0; - virtual TInt CreateSubscribedContactEntryL(CCreatorModuleBaseParameters *aParameters) = 0; - virtual TBool AskDataFromUserL( TInt aCommand ); // from MCreatorModuleBase - virtual void QueryDialogClosedL(TBool aPositiveAction, TInt aUserData); //from MUIObserver - -// virtual TBool IsActive() = 0; -// virtual void CancelOperation() = 0; - virtual void DeleteAllGroupsL() = 0; - virtual void DeleteAllGroupsCreatedByCreatorL() = 0; - -protected: - - virtual void SetDefaultParameters(); - TInt iNumberOfPhoneNumberFields; - TInt iNumberOfURLFields; - TInt iNumberOfEmailAddressFields; - TInt iContactsInGroup; - TBool iDefaultFieldsSelected; - TBool iAddAllFields; -}; - - -#endif /*__CCREATORPHONEBOOKBASE_H_*/ diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/inc/creator_phonebookwrapper.h --- a/creator/engine/inc/creator_phonebookwrapper.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,200 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - -#ifndef __CREATORPHONEBOOKWRAPPER_H__ -#define __CREATORPHONEBOOKWRAPPER_H__ - -#include "creator_phonebookbase.h" -#include "creator_randomdatafield.h" - -#include - -#include "creator_phonebookapi.h" - -class CCreatorEngine; -class CCreatorModuleBaseParameters; - -class CContactDatabase; -//class CPhonebookWrapperParameters; -class CPhonebookParameters; - -typedef typename std::map TCreatorContactFields; -typedef typename std::pair TCreatorContactField; - -class CCreatorPhonebookWrapper : public CBase - { -public: - enum ContactDetailType{ - ELastName, //0 - ELastNameReading, //1 - EFirstName, - EFirstNameReading, - EPrefix, - ESuffix, //5 - ESecondName, - ELandPhoneHome, - EMobilePhoneHome, - EVideoNumberHome, - EFaxNumberHome, //10 - EVoipHome, - EEmailHome, - EUrlHome, - EAddrLabelHome, - EAddrPoHome, //15 - EAddrExtHome, - EAddrStreetHome, - EAddrLocalHome, - EAddrRegionHome, - EAddrPostCodeHome, //20 - EAddrCountryHome, - EJobTitle, - ECompanyName, - ELandPhoneWork, - EMobilePhoneWork, //25 - EVideoNumberWork, - EFaxNumberWork, - EVoipWork, - EEmailWork, - EUrlWork, //30 - EAddrLabelWork, - EAddrPoWork, - EAddrExtWork, - EAddrStreetWork, - EAddrLocalWork, //35 - EAddrRegionWork, - EAddrPostCodeWork, - EAddrCountryWork, - ELandPhoneGen, - EMobilePhoneGen, //40 - EVideoNumberGen, - EFaxNumberGen, - EVoipGen, - EPoc, - ESwis, //45 - ESip, - EEmailGen, - EUrlGen, - EAddrLabelGen, - EAddrPoGen, //50 - EAddrExtGen, - EAddrStreetGen, - EAddrLocalGen, - EAddrRegionGen, - EAddrPostCodeGen, //55 - EAddrCountryGen, - EPagerNumber, - EDtmfString, - EWVAddress, - EDate, //60 - ENote, - EThumbnailPic, - ERingTone, - ECallerObjImg, - ECallerObjText, //65 - EMiddleName, - EDepartment, - EAsstName, - ESpouse, - EChildren, //70 - EAsstPhone, - ECarPhone, - EAnniversary, - ESyncClass, - ELocPrivacy, //75 - EGenLabel, - ETopContact, - EIMPP, - }; - - -public: - static CCreatorPhonebookWrapper* NewL(); - static CCreatorPhonebookWrapper* NewLC(); - ~CCreatorPhonebookWrapper(); - -private: - CCreatorPhonebookWrapper(); - void ConstructL(); - -public: - TUint32 CreateContactEntryL(const TCreatorContactFields& Map); - TUint32 CreateGroupEntryL( HBufC* aGroupName ); - TInt CreateSubscribedContactEntryL(); - - /** - * NumberOfContacts() will return all contacts from Contact API - */ - TInt NumberOfContacts(); - - TInt AddContactToGroup( TUint32 aGroupId, TUint32 aContact ); - TInt AddToGroup( TUint32 aGroupId, TInt aAmount ); - - - void DeleteAllL(); - void DeleteAllGroupsL(); - void DeleteContactsL( RArray& aContactsToDelete, TUid aStoreUid ); - - HBufC* GetPhoneNumberL( TUint32 aContactId ); - TBool GetContactDetailsL( TUint32 aContactId, TDes& aName, TDes& aPhoneNumber, TDes& aEmail ); - -private: - QList CreateContactDetailsFromParameters( const TCreatorContactFields& Map ); - QContactDetail CreateContactDetail( QList& aContactDetailList,QString aDetail, QString aFieldContext, QString aFieldString, QString aData ); - void AddFieldToList( QList& aDetailList, QContactDetail aDetail); - - TBool IsContactGroupL( TUint32& aLink ); - - void DeleteItemsCreatedWithCreatorL( TUid aStoreUid ); - void DoDeleteItemsCreatedWithCreatorL( TUid aStoreUid, CDictionaryFileStore* aStore ); - TBool HasOtherThanGroupsL(); - - -private: - - TInt iOpCounter; - - static QString iPhoneNumberFields[]; - static TInt iUrlFields[]; - static TInt iEmailFields[]; - - RArray iContactLinkArray; - RArray iContactsToDelete; - RArray iContactGroupsToDelete; - - RArray iPreviousDeleteLinks; - //RPointerArray iPreviousDeleteLinks; //modify - -private: - //new variables - /// Ref: the target of the copy - QContact* iStore; - - /// Own: Contact database for this store - CContactDatabase* iContactDb; - - //Contacts found in contacts db. - QList* iContactResults; - // Contact groups that are found in the store. These are used in filtering - // the groups from the find results. - QList* iContactGroupsInStore; - - CCreatorPhonebookAPI* iPhonebookAPI; - }; - -#endif // __CREATORPHONEBOOKWRAPPER_H__ diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/inc/creator_randomdatafield.h --- a/creator/engine/inc/creator_randomdatafield.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - - -#ifndef CREATORDATAFIELD_H_ -#define CREATORDATAFIELD_H_ - -#include - -class MCreatorRandomDataField -{ -public: - enum TRandomLengthType - { - ERandomLengthUndefined, - ERandomLengthDefault, // Default length (use data from engine) - ERandomLengthMax, // Maximum length - ERandomLengthExplicit // Explicitly defined length - }; - - /** - * Set field content to random. - * @param aRandomLenType Random length type - * @param aExplicitRandomLen Random length when ERandomLengthExplicit is used. Ignored otherwise. - */ - virtual void SetRandomParametersL( TRandomLengthType aRandomLenType, TInt aRandomLen ) = 0; -}; - -#endif /*CREATORDATAFIELD_H_*/ diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/inc/creator_randomdataparser.h --- a/creator/engine/inc/creator_randomdataparser.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,131 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - - -#ifndef CREATORRANDOMDATAPARSER_H_ -#define CREATORRANDOMDATAPARSER_H_ - -#include -#include -#include -#include - -//using namespace Xml; - -class CCreatorRandomDataParser : public CBase, public Xml::MContentHandler - { - -public: - enum TRandomDataType - { - EFirstName, - ESurname, - ECompany, - EAddress, - EJobTitle, - EPhoneNumber, - EGroupName, - EMeetingReason, - EMeetingPlace, - EMemoText, - EAnniversaryReason, - EToDoText, - EReminderText, - EMessageSubject, - EMessageText, - ECity, - ECountry, - EPostcode, - EState, - EPobox, - EPrefix, - ESuffix, - ELandmarkName, - ELandmarkDescription - }; - -public: - - virtual ~CCreatorRandomDataParser(); - static CCreatorRandomDataParser* NewL(); - static CCreatorRandomDataParser* NewLC(); - CDesCArrayFlat* ParseL(const TDesC& aFileName, const TRandomDataType aDataType); - - TInt GetError() const; - -private: - - CCreatorRandomDataParser(); - void ConstructL(); - - /** - * Converts 8 bit descriptor to 16 bit descriptor - * @param aDes 8 bit descriptor to be converted - * @return Pointer to the new 16 bit descriptor - */ - HBufC* Convert8BitTo16BitLC(const TDesC8& aInput); - void GetTextFileMode(RFile& aFile, TInt& aFileSize); - - -public: - // From MContentHandler: - void OnStartDocumentL(const Xml::RDocumentParameters &aDocParam, TInt aErrorCode); - void OnEndDocumentL(TInt aErrorCode); - void OnStartElementL(const Xml::RTagInfo& aElement, - const Xml::RAttributeArray& aAttributes, - TInt aErrorCode); - void OnEndElementL(const Xml::RTagInfo& aElement, TInt aErrorCode); - void OnContentL(const TDesC8& aBytes, TInt aErrorCode); - void OnStartPrefixMappingL(const RString& aPrefix, - const RString& aUri, - TInt aErrorCode); - void OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode); - void OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt aErrorCode); - void OnSkippedEntityL(const RString& aName, TInt aErrorCode); - void OnProcessingInstructionL(const TDesC8& aTarget, - const TDesC8& aData, - TInt aErrorCode); - void OnError(TInt aErrorCode); - TAny* GetExtendedInterface(const TInt32 aUid); - -private: - TRandomDataType iDataType; - CDesCArray* iElementNameArray; - HBufC* iContentData; - TBool iInsideRootElement; - TBool iContentParsingActive; - - CDesCArrayFlat* iResultArray; - - enum TFileFormat - { - EFormatANSIASCII, - EFormatUTF8, - EFormatUTF16LE, - EFormatUTF16BE - }; - - // XML parser - Xml::CParser* iParser; - - TFileFormat iScriptTextFormat; - TInt iLastError; -}; - -#endif /*CREATORRANDOMDATAPARSER_H_*/ diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/inc/creator_scriptelement.h --- a/creator/engine/inc/creator_scriptelement.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,350 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - - -#ifndef CREATORSCRIPTELEMENT_H_ -#define CREATORSCRIPTELEMENT_H_ - -#include "creator_randomdatafield.h" -#include "creator_modulebase.h" -#include "engine.h" -#include - -class CCreatorScriptElement; -class CCreatorEngine; - -_LIT(KEmpty, ""); -_LIT(KContextSep, "::"); - -// Common attributes: -_LIT(KAmount, "amount"); -_LIT(KRandomLength, "randomlength"); -_LIT(KId, "id"); -_LIT(KMaxAmount, "maxamount"); - -// Common element names: -_LIT(KScript, "creatorscript"); -_LIT(KFields, "fields"); -_LIT(KContactSetRef, "contact-set-reference"); -_LIT(KExistingContacts, "numberofexistingcontacts"); - -// Common attribute values: -_LIT(KMax, "max"); -_LIT(KDefault, "default"); -_LIT(KIncrease, "incvalueforeachcopy"); - -class CCreatorScriptElementCache : public CBase -{ -public: - static CCreatorScriptElementCache* CCreatorScriptElementCache::NewL(); - virtual ~CCreatorScriptElementCache(); - - void RemoveElements(); - void AddElementL(CCreatorScriptElement* aElement); -private: - CCreatorScriptElementCache(); - void ConstructL(); - RPointerArray iElementCache; - -}; - - -class CCreatorScriptAttribute : public CBase -{ -public: - static CCreatorScriptAttribute* NewL(const TDesC& aName, const TDesC& aValue); - static CCreatorScriptAttribute* NewLC(const TDesC& aName, const TDesC& aValue); - virtual ~CCreatorScriptAttribute(); - - TPtrC Name() const; - void SetNameL(const TDesC& aName); - TPtrC Value() const; - void SetValueL(const TDesC& aValue); - -protected: - - CCreatorScriptAttribute(); - virtual void ConstructL(const TDesC& aName, const TDesC& aValue); - -private: - HBufC* iName; - HBufC* iValue; -}; - -/** - * Base class for all elements - */ -class CCreatorScriptElement : public CBase -{ -public: - - static CCreatorScriptElement* CCreatorScriptElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC); - - /** - * Destructor - */ - virtual ~CCreatorScriptElement(); - - /** - * Returns the array of sub-elements. - * @return Reference to the sub-element array. - */ - virtual RPointerArray const& SubElements() const; - virtual RPointerArray& SubElements(); - - /** - * Returns a sub-element. - * @param aIndex Sub-element array index. - * @return Pointer to a sub-element - */ - virtual CCreatorScriptElement* SubElement(TInt aIndex); - - /** - * Finds a sub-element by a name. - * @param aName Name of the sub-element - * @return Pointer to the first matching sub-element. NULL if not found. - */ - virtual CCreatorScriptElement* FindSubElement(const TDesC& aName); - - /** - * Removes all sub-elements. - */ - virtual void RemoveSubElements(); - - /** - * Removes a sub-element - * @param aIndex Index of the element to be removed - */ - virtual void RemoveSubElementL(TInt aIndex); - - /** - * Adds an element to the sub-element list. - * Leaves with error KErrNotSupported, if sub-element is illegal. - * Leaves with error KErrArgument, if the index in out of bounds. - * @param aElem Pointer to the element to be added. Takes ownership of the pointer. - * @param aIndex Sub-element array index where to add the element. -1 means that - * the element is added to the end of the array. - */ - virtual void AddSubElementL(CCreatorScriptElement* aElem, TInt aIndex = -1); - - /** - * Returns the array of attributes. - * @return Reference to the attribute array. - */ - virtual RPointerArray const& Attributes() const; - - /** - * Returns an attribute. - * @param aIndex Attribute array index. - * @return Pointer to a attribute - */ - virtual CCreatorScriptAttribute* Attribute(TInt aIndex); - - /** - * Removes all attributes. - */ - virtual void RemoveAttributes(); - - /** - * Removes an attribute - * @param aIndex Index of the attribute to be removed - */ - virtual void RemoveAttributeL(TInt aIndex); - - /** - * Adds an attribute to the attribute list. - * Leaves with error KErrNotSupported, if attribute is illegal. - * @param aAttribute Pointer to the element to be added. Takes ownership of the pointer. - * @param aIndex Attribute array index where to add the attribute. -1 means that - * the attribute is added to the end of the array. - */ - virtual void AddAttributeL(CCreatorScriptAttribute* aAttribute, TInt aIndex = -1); - - /** - * Finds attribute with the given name. First match is returned. - */ - virtual const CCreatorScriptAttribute* FindAttributeByName(const TDesC& aName) const; - virtual CCreatorScriptAttribute* FindAttributeByName(const TDesC& aName); - - /** - * Returns element name - * @return Element name - */ - virtual TPtrC Name() const; - - /** - * Sets the element name. - * @param aName Element name - */ - virtual void SetNameL(const TDesC& aName); - - /** - * Returns element content - * @return Element content - */ - virtual TPtrC Content() const; - - /** - * Set the content of the element. - * @param aContenct Element content - */ - virtual void SetContentL(const TDesC& aContent); - virtual void AppendContentL(const TDesC& aContent); - - /** - * Returns element context - * @return Element context - */ - virtual TPtrC Context() const; - - /** - * Set the context of the element. - * @param aContenct Element context - */ - virtual void SetContextL(const TDesC& aContext); - - /** - * Tells whether the element should be cached for future use. - * @return ETrue if the element should be cached for future use, EFalse otherwise. - */ - virtual TBool IsCacheNeeded(); - virtual void AddToCacheL(CCreatorScriptElementCache& aCache); - virtual void AddToCacheL(); - virtual TBool IsCommandElement() const; - virtual void ExecuteCommandL(); - //virtual void SaveCommandResultsL(); - //virtual void DiscardCommandResultsL(); - virtual TBool IsRoot() const; - virtual RPointerArray& CommandParameters(); - virtual const RPointerArray& CommandParameters() const; - -protected: - - /** - * Constructors. - */ - CCreatorScriptElement(CCreatorEngine* aEngine = 0); - - /** - * @param aName Name of the element. - */ - virtual void ConstructL(const TDesC& aName, const TDesC& aContext = KNullDesC); - - /** - * Tells whethet the sub-element is allowed or not. - * @param aElem Sub-element to be tested. - * @return Boolean value telling whether the sub-element is allowed - * to be added or not. - */ - virtual TBool IsSubElementSupported(const CCreatorScriptElement& aElem) const; - - virtual MCreatorRandomDataField::TRandomLengthType ResolveRandomDataTypeL(const CCreatorScriptAttribute& aAttr, TInt& aRandomLen ) const; - - virtual TBool ConvertStrToBooleanL(const TDesC& aStr) const; - virtual TInt ConvertStrToIntL(const TDesC& aStr) const; - virtual TUint ConvertStrToUintL(const TDesC& aStr) const; - virtual void ConvertStrToReal64L(const TDesC& aStr, TReal64& aVal) const; - virtual void ConvertStrToReal32L(const TDesC& aStr, TReal32& aVal) const; - - virtual void AppendContactSetReferenceL(const CCreatorScriptElement& aContactSetRefElem, RArray& aLinkArray ) const; - - virtual void SetContentToTextParamL(HBufC*& aPtr, const TDesC& aContent ); - - virtual TTime ConvertToDateTimeL(const TDesC& aDtStr) const; - - virtual TInt CompareIgnoreCase(const TDesC& aStr1, const TDesC& aStr2 ) const; - - /** - * Increases phonenumber by aDelta. - * - * Special cases, that are handled: - * +9 -> +9, +10, +11... - * +3584098#99 -> +3584098#99, +3584098#100, +3584098#101... - * # -> #0, #1, #2... - * 123# -> 123#0, 123#1, 123#2... - * 099 -> 099, 100, 101... - * - * @param aOriginal original phonenumber - * @param aDelta number to be added to original number. Must be >= 0. - * @param aIncreased on return contains the increased number. - * The buffer must be allocated by the caller. - */ - void IncreasePhoneNumL( const TDesC& aOriginal, TInt aDelta, HBufC* aIncreased ) const; - -protected: - - // Sub-element array - RPointerArray iSubElements; - // Attribute array - RPointerArray iAttributes; - // Element name (e.g. "contact") - HBufC* iName; - // Element content - HBufC* iContent; - // Context - HBufC* iContext; - - TBool iIsCommandElement; - TBool iIsRoot; - CCreatorEngine* iEngine; - RPointerArray iParameters; -}; - -/** - * Script element - */ -class CCreatorScriptRoot : public CCreatorScriptElement -{ -public: - static CCreatorScriptRoot* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC); -protected: - CCreatorScriptRoot(CCreatorEngine* aEngine); -}; - -/** - * Calendar elements - */ - -/** - * Base class for calendar elements - */ -class CCreatorCalendarElementBase : public CCreatorScriptElement -{ -public: - static CCreatorCalendarElementBase* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC); -protected: - CCreatorCalendarElementBase(CCreatorEngine* aEngine); -}; - -/** - * Message elements - */ - -/** - * Base class for message elements - */ -class CCreatorMessageElementBase : public CCreatorScriptElement -{ -public: - static CCreatorMessageElementBase* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC); -protected: - CCreatorMessageElementBase(CCreatorEngine* aEngine); -}; - -#endif /*CREATORSCRIPTELEMENT_H_*/ diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/inc/creator_scriptelementfactory.h --- a/creator/engine/inc/creator_scriptelementfactory.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - - -#ifndef CREATORSCRIPTELEMENTFACTORY_H_ -#define CREATORSCRIPTELEMENTFACTORY_H_ - -#include "creator_scriptelement.h" - -/** - * Creates script element instance based on the element name and context. - */ -class TCreatorScriptElementFactory -{ -public: - static CCreatorScriptElement* CreateElementL(CCreatorEngine* aEngine, const TDesC& aElementName, const TDesC& aContext = KNullDesC); -}; - -#endif /*CREATORSCRIPTELEMENTFACTORY_H_*/ diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/inc/creator_scriptentry.h --- a/creator/engine/inc/creator_scriptentry.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,102 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - - - -#ifndef __FILEUTILS_H__ -#define __FILEUTILS_H__ - - -#include -#include -#include -#include -#include -#include -#include - - -class CCreatorEngine; - -class CreatorFileUtils -{ -public: - static TInt FindFiles(CDesCArrayFlat* aFileArray, const TDesC& aFileName, const TDesC& aPath); - static TInt FindFilesRecursiveL(CDesCArrayFlat* aFileArray, const TDesC& aFileName, const TDesC& aPath); -}; - -class CCommandParser : public CBase, public MMsvSessionObserver, MUIObserver - { -enum TCommandParserStatus{ - EGetingScript, - EGetingRandomDataFile -}; - -public: - static CCommandParser* NewL(CCreatorEngine* aEngine); - static CCommandParser* NewLC(CCreatorEngine* aEngine); - ~CCommandParser(); - - void StrParserL(HBufC*& aDestinationBuf, TUint aToken); - void StrParserL(HBufC8*& aDestinationBuf, TUint aToken); - -private: - CCommandParser(); - void ConstructL(CCreatorEngine* aEngine); - - TInt FindFilesRecursiveL(const TDesC& aFileName, const TDesC& aPath); - TInt FindFiles(const TDesC& aFileName, const TDesC& aPath); - TInt ReadLineFromFileL(RFile& aInputFile); - //void ParseCommandFromDescriptorL(); - - void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3); // from MMsvSessionObserver - -public: - /** - * Called when some dialog in UI is closed - * - * @since S60 10.1 - * @param aPositiveAction ETrue if "Ok", "Yes" or other "positive" button was pressed - * @param aUserData number that was passed to UI before dialog was opened - * @return None. - */ - virtual void QueryDialogClosedL(TBool aPositiveAction, TInt aUserData); - -public: - void OpenScriptL(); - TBool OpenScriptL(MCommandParserObserver* aObserver); - TBool GetRandomDataFilenameL(MCommandParserObserver* aObserver); - -private: - CCreatorEngine* iEngine; - CDesCArrayFlat* iSearchArray; - TInt iSelectedItem; - - TInt iParserPosition; - TInt iParserOldPosition; - - HBufC8* iReadBuf; - - MCommandParserObserver* iObserver; - }; - - - -#endif // __FILEUTILS_H__ - diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/inc/creator_scriptparser.h --- a/creator/engine/inc/creator_scriptparser.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,140 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - - -#ifndef CREATORSCRIPTPARSER_H_ -#define CREATORSCRIPTPARSER_H_ - -#include -#include -#include - -using namespace Xml; - -class CCreatorScriptElement; -class CCreatorEngine; -class CCreatorScriptElementCache; - -class TCreatorScriptElementInfo -{ -public: - enum TElementStatus - { - EStatusUndefined, // undefined - EStatusParsing, // currently being parsed - EStatusParsed // parsed - }; - TCreatorScriptElementInfo() - { - iStatus = EStatusUndefined; - iElement = 0; - } - TCreatorScriptElementInfo(TElementStatus aStatus, CCreatorScriptElement* aElement) - { - iStatus = aStatus; - iElement = aElement; - }; - - TElementStatus iStatus; - CCreatorScriptElement* iElement; -}; - -class CCreatorScriptParser : public CBase, public MContentHandler -{ -public: - - virtual ~CCreatorScriptParser(); - static CCreatorScriptParser* NewL(CCreatorEngine* aEngine); - static CCreatorScriptParser* NewLC(CCreatorEngine* aEngine); - void ParseL(const TDesC& aFileName); - void ParseL(RFile& aFile); - - TInt GetError() const; - -private: - - CCreatorScriptParser(); - void ConstructL(CCreatorEngine* aEngine); - - /** - * Converts 8 bit descriptor to 16 bit descriptor - * @param aDes 8 bit descriptor to be converted - * @return Pointer to the new 16 bit descriptor - */ - HBufC* Convert8BitTo16BitLC(const TDesC8& aInput); - const TCreatorScriptElementInfo& LastElementInfo() const; - void GetTextFileMode(RFile& aFile, TInt& aFileSize); - - -public: - // From MContentHandler: - void OnStartDocumentL(const RDocumentParameters &aDocParam, TInt aErrorCode); - void OnEndDocumentL(TInt aErrorCode); - void OnStartElementL( const RTagInfo& aElement, - const RAttributeArray& aAttributes, - TInt aErrorCode); - void OnEndElementL(const RTagInfo& aElement, TInt aErrorCode); - void OnContentL(const TDesC8& aBytes, TInt aErrorCode); - void OnStartPrefixMappingL( const RString& aPrefix, - const RString& aUri, - TInt aErrorCode); - void OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode); - void OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt aErrorCode); - void OnSkippedEntityL(const RString& aName, TInt aErrorCode); - void OnProcessingInstructionL( const TDesC8& aTarget, - const TDesC8& aData, - TInt aErrorCode); - void OnError(TInt aErrorCode); - TAny* GetExtendedInterface(const TInt32 aUid); - -private: - - enum TFileFormat - { - EFormatANSIASCII, - EFormatUTF8, - EFormatUTF16LE, - EFormatUTF16BE - }; - // XML parser - CParser* iParser; - - /** - * Element stack holding the elements that are currently being parsed. - */ - RArray iElementStack; - - /** - * Cache object containig the elements that are referred in future and thus should - * not be deleted after parsing. - */ - CCreatorScriptElementCache* iElementCache; - - /** - * Pointer to the engine - */ - CCreatorEngine* iEngine; - - TCreatorScriptElementInfo iDefaultElement; - - TFileFormat iScriptTextFormat; - TInt iLastError; -}; - -#endif /*CREATORSCRIPTPARSER_H_*/ diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/inc/creator_std.h --- a/creator/engine/inc/creator_std.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - - -#ifndef __CREATOR_STD_H__ -#define __CREATOR_STD_H__ - -#include - -class TCommand; -typedef CArrayFixSeg CCommandArray; - - -#endif // __CREATOR_STD_H__ diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/inc/creator_traces.h --- a/creator/engine/inc/creator_traces.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,107 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - - - -#ifndef __CREATOR_TRACES_H__ -#define __CREATOR_TRACES_H__ - -#include - - -// --------------------------------------------------------------------------- -// You change these logging method values below! Recompile the application to take changes effect. - - // logging methods - // 0 = No logging - // 1 = Flogger - // 2 = RDebug - // 3 = Flogger and RDebug - - #ifndef _DEBUG - - // Logging method for UREL builds: - #define CREATOR_LOGGING_METHOD 3 - - #else - - // Logging method for UDEB builds: - #define CREATOR_LOGGING_METHOD 3 - - #endif - - - -// --------------------------------------------------------------------------- -// Do not make any changes to lines below... - - #if CREATOR_LOGGING_METHOD == 1 || CREATOR_LOGGING_METHOD == 3 - - #include - _LIT(KLogFolder,"Creator"); - _LIT(KLogFile,"Creator_Trace.txt"); - - #endif - - #if CREATOR_LOGGING_METHOD == 2 || CREATOR_LOGGING_METHOD == 3 - - #include - - #endif - - - #if CREATOR_LOGGING_METHOD == 0 - - #define LOGTEXT(AAA) - #define LOGSTRING(AAA) - #define LOGSTRING2(AAA,BBB) - #define LOGSTRING3(AAA,BBB,CCC) - #define LOGSTRING4(AAA,BBB,CCC,DDD) - - - #elif CREATOR_LOGGING_METHOD == 1 - - #define LOGTEXT(AAA) RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend, AAA) - #define LOGSTRING(AAA) do { _LIT(tempLogDes,AAA); RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend,tempLogDes()); } while (0) - #define LOGSTRING2(AAA,BBB) do { _LIT(tempLogDes,AAA); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB); } while (0) - #define LOGSTRING3(AAA,BBB,CCC) do { _LIT(tempLogDes,AAA); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB,CCC); } while (0) - #define LOGSTRING4(AAA,BBB,CCC,DDD) do { _LIT(tempLogDes,AAA); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB,CCC,DDD); } while (0) - - #elif CREATOR_LOGGING_METHOD == 2 - - #define LOGTEXT(AAA) RDebug::Print(AAA) - #define LOGSTRING(AAA) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes); } while (0) - #define LOGSTRING2(AAA,BBB) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB); } while (0) - #define LOGSTRING3(AAA,BBB,CCC) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC); } while (0) - #define LOGSTRING4(AAA,BBB,CCC,DDD) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC, DDD); } while (0) - - #elif CREATOR_LOGGING_METHOD == 3 - - #define LOGTEXT(AAA) RDebug::Print(AAA); RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend, AAA) - #define LOGSTRING(AAA) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes); RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend,tempLogDes()); } while (0) - #define LOGSTRING2(AAA,BBB) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB); } while (0) - #define LOGSTRING3(AAA,BBB,CCC) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB,CCC); } while (0) - #define LOGSTRING4(AAA,BBB,CCC,DDD) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC, DDD); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB,CCC,DDD); } while (0) - - #endif - -// --------------------------------------------------------------------------- - -#endif // __LAUNCHER_TRACES_H__ - diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/inc/creator_wepsecuritysettings.h --- a/creator/engine/inc/creator_wepsecuritysettings.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,143 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - - -#ifndef CREATORWEPSECURITYSETTINGS_H_ -#define CREATORWEPSECURITYSETTINGS_H_ - -// -// Methods copied from WEPSecuritySettingsImpl.h -// (Part of : WEP Security Settings UI) -// @see \s60\mw\networking\networkingutilities\WEPSecuritySettingsUI\inc\WEPSecuritySettingsImpl.h -// - - -// INCLUDES - -//#include "engine.h" - -#include -#include -using namespace CommsDat; - -// FORWARD DECLARATIONS - -class CCommsDatabase; - -// Index of first key -const TInt KFirstKey = 0; - -// Index of second key -const TInt KSecondKey = 1; - -// Index of third key -const TInt KThirdKey = 2; - -// Index of fourth key -const TInt KFourthKey = 3; - -const TInt KMaxNumberofKeys = 4; - -// Number of characters for a 232 bits key -const TUint KKeyDataLength232Bits = 58; - -// The maximum length of key data -const TUint KMaxLengthOfKeyData = KKeyDataLength232Bits; - - - - -class CCreatorWEPSecuritySettings : public CBase - { -public: - static CCreatorWEPSecuritySettings* NewL(); - static CCreatorWEPSecuritySettings* NewLC(); - ~CCreatorWEPSecuritySettings(); - -private: - CCreatorWEPSecuritySettings(); - void ConstructL(); - - -public: -/** -* Save to database. -* @param aIapId Wlan Service Table Id of the IAP to be saved -* @param aCommsDb Comms database. -*/ -void SaveL( TUint32 aIapId, CCommsDatabase& aCommsDb ) const; - -public: -// Enumeration of the possible keys in use -enum TWEPKeyInUse - { - EKeyNumber1, // Key number 1 - EKeyNumber2, // Key number 2 - EKeyNumber3, // Key number 3 - EKeyNumber4 // Key number 4 - }; - - -// Enumeration of the possible authentication types -enum TWEPAuthentication - { - EAuthOpen, // Open authentication - EAuthShared // Shared authentication - }; - - -// Possible lengths of the keys -enum TWEPKeyLength - { - E40Bits, // 40 bits - E104Bits, // 104 bits - E232Bits // 232 bits - }; - - -// Possible formats of the keys -enum TWEPKeyFormat - { - EAscii, // Ascii format - EHexadecimal // Hex format - }; - - - -private: - -// Index of the key currently in use (EKeyNumber1, EKeyNumber2, -// EKeyNumber3, EKeyNumber4 -CCreatorWEPSecuritySettings::TWEPKeyInUse iKeyInUse; - -// Type of authentication (EAuthOpen, EAuthShared) -CCreatorWEPSecuritySettings::TWEPAuthentication iAuthentication; - -// Length of the key (E40Bits, E104Bits, E232Bits) -CCreatorWEPSecuritySettings::TWEPKeyLength iKeyLength[KMaxNumberofKeys]; - -// Format of the key (EAscii, EHexadecimal) -CCreatorWEPSecuritySettings::TWEPKeyFormat iKeyFormat[KMaxNumberofKeys]; - - - }; - - - -#endif /*CREATORWEPSECURITYSETTINGS_H_*/ diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/inc/randomdata.txt --- a/creator/engine/inc/randomdata.txt Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,589 +0,0 @@ -// --------------------------------------------------------- - -struct r_data_firstnames - { - "John"; - "Francis"; - "Andrew"; - "Lawrence"; - "Gregory"; - "Fulke"; - "Thomas"; - "Nicholas"; - "Hakle"; - "Roger"; - "Nathaniel"; - "Luke"; - "William"; - "Ralph"; - "Leonar"; - "Daniel"; - "Aban"; - "Mathias"; - "Robert"; - "Christopher"; - "Martin"; - "Michael"; - "Barnaby"; - "Tobias"; - "Richard"; - "Anthony"; - "Simon"; - "Samuel"; - "Geoffrey"; - "Isaac"; - "Henry"; - "Matthew"; - "Peter"; - "Allen"; - "Reynold"; - "Jerome"; - "Elizabeth"; - "Catherine"; - "Frances"; - "Cecily"; - "Millicent"; - "Audrey"; - "Joan"; - "Elinor"; - "Joyce"; - "Frideswide"; - "Rose"; - "Helen"; - "Margaret"; - "Isabel"; - "Bridget"; - "Grace"; - "Thomasin"; - "Janet"; - "Agnes"; - "Dorothy"; - "Christian"; - "Amy"; - "Fortune"; - "Sybil"; - "Alice"; - "Margery"; - "Edith"; - "Barbara"; - "Gillian"; - "Ursula"; - }; - -struct r_data_surnames - { - "Lux"; - "Mandot"; - "Mansfield"; - "Mayberry"; - "McCarrel"; - "McDaniel"; - "Mefford"; - "Metcalf"; - "Metchell"; - "Moller"; - "Margan"; - "Keaney"; - "Kenyon"; - "Kesler"; - "Kinman"; - "Kreinert"; - "Kummerlin"; - "Lamgley"; - "Leas"; - "Leighton"; - "Lillie"; - "Hilms"; - "Holt"; - "Hosier"; - "Howard"; - "Hypes"; - "Jacmor"; - "Behnson"; - "Kammer"; - "Patts"; - "West"; - "Wilbar"; - "Witsan"; - "Gillams"; - "Good"; - "Wreght"; - "Worthley"; - "Adams"; - "Allen"; - "Ansley"; - "Ayries"; - "Bartlett"; - "Barton"; - "Payne"; - "Pintard"; - "Prence"; - "Richards"; - "Dillman"; - "Dory"; - "Edgards"; - "Engell"; - "Farprington"; - "Fisher"; - "Foed"; - "Burges"; - "Childwall"; - "Smith"; - "Sipon"; - "Simmons"; - "Stewert"; - "Stiles"; - "Stratton"; - "Dennis"; - "Talmot"; - }; - } - -struct r_data_companies - { - "CDP"; - "Exbox"; - "Munro"; - "Majaka"; - "Bitzumi"; - "Melroy"; - "Matal"; - "Japponi"; - "Siwaka"; - "Keiku"; - "Naamate"; - "Remonti"; - "Melleva"; - "WEX"; - "Chataz"; - "Ponly"; - "Alriva"; - "Giate"; - "Kesso"; - "Nyssa"; - "Peger"; - "Metrio"; - "Mitchitatchi"; - "Neppari"; - "Amcuila"; - "Muipitsu"; - "Redex"; - "Maariz"; - "Swerck"; - "Makiac"; - "Dumpia"; - "Worldmom"; - "Renfaul"; - "Kmartissori"; - "Findo"; - "Samsanc"; - "Dellervo"; - "Manrel"; - "WSMRL"; - "Eripox"; - "Abiturien"; - "Vesus"; - "MI4"; - "Overhiba"; - "Tridune"; - "Kyomcera"; - "Praston"; - "Gapmis"; - "WPPDCD"; - }; - -struct r_data_addresses - { - "Barnes Street"; - "Barnes Place"; - "Eastman Street"; - "West Park"; - "South Park"; - "Park Avenue"; - "Richards Court"; - "Pukershire Avenue"; - "Ellis Avenue"; - "East Mountain"; - "Chestnut Hill"; - "Plains Road"; - "Fremont Street"; - "Heritage Court"; - "Highland Avenue Extension"; - "Maple Heights"; - "McKenzie Avenue"; - "McKenzie Lane"; - "West Terrace Street"; - "Windsor Avenue"; - "Windsor Road"; - "Mechanic Street Extension"; - "Granite Place"; - "Meadow Street"; - "Sugar River"; - }; - -struct r_data_cities - { - "Kuopio"; - "Los Angeles"; - "Lappeenranta"; - "London"; - "Bangkok"; - "St. Michel"; - "St. Petersburg"; - "Tokyo"; - "Helsinki"; - "Trondheim"; - "Nairobi"; - "Havana"; - }; - -struct r_data_countries - { - "Finland"; - "Cuba"; - "United States of America"; - "Thailand"; - "Sweden"; - "Russia"; - "Japan"; - "Norway"; - "Kenya"; - }; - -struct r_data_postcodes - { - "00310"; - "FI-70100"; - "99002"; - "11233"; - }; - -struct r_data_states - { - "California state"; - "Alaska state"; - "Florida state"; - }; - -struct r_data_poboxes - { - "P.O BOX 5532"; - "P.O BOX 701"; - "99"; - "1133"; - "P.O. BOX 113322"; - "112"; - }; - -struct r_data_prefixes - { - "Ms."; - "Mrs."; - "Mr."; - "Dr."; - }; - -struct r_data_suffixes - { - "Jr."; - "Sr."; - }; - -struct r_data_jobtitles - { - "Doctor"; - "SW Engineer"; - "Administrative Assistant"; - "Bookkeeper"; - "Credit Controller"; - "Data Entry Operator"; - "Payroll Officer"; - "Receptionist"; - "Trainee"; - "Accounts Clerk"; - "Administrator"; - "Taxation Assistant"; - "Financial Director"; - "Bank Manager"; - "Mobile Lending"; - "Overseas Transactions"; - "Restructuring"; - "Business Analyst"; - "Call Centre Manager"; - "Administration"; - "Manager"; - "Student"; - "Mail Sorter"; - "Mayor"; - "Account Servicing"; - "Management"; - "Media Consultant"; - "Newsagent"; - "Librarian"; - "Creative Director"; - "Announcer"; - "Copywriter"; - "Presenter"; - "Promotions Manager"; - "Advertising Sales Representative"; - "Editor"; - "Marketing, Sales & Publicity"; - "Publisher"; - "Gallery Assistant"; - "Photographer"; - "Storyboard Artist"; - "Events Manager"; - "Cameraman"; - "Technician"; - "Producer"; - }; - -struct r_data_phonenumbers - { - "0307834387"; - "0230328732"; - "0430365562"; - "0530328732"; - "0433032865"; - "0542306532"; - "0342303777"; - "0250235603"; - "0492303652"; - "0542303286"; - "0543656546"; - "0545545454"; - "0543444454"; - "0776463255"; - "0432443343"; - "0243334344"; - "0544543443"; - "0231343243"; - "0213443434"; - "0143234476"; - "0785434444"; - "0454445345"; - "0342443433"; - "0432434454"; - "0455454454"; - "0656565655"; - "0343434443"; - "0565645455"; - "0343243243"; - "0565466565"; - "0465565655"; - "0435445454"; - "+35854553456"; - "+35878453486"; - "+35876653456"; - "+35834435486"; - "+35876766466"; - "+4465665456"; - "+4432434334"; - "+4488776776"; - "+4465655656"; - "+4443433434"; - "+4465656565"; - "+4454454354"; - }; - -struct r_data_groupnames - { - "Nice guys"; - "Repairs"; - "Office works"; - "The buddies"; - "Football team"; - "Gold club"; - "Silver club"; - "Bronze club"; - "Best buddies"; - "Rockers"; - "Science group"; - }; - -struct r_data_meetingreasons - { - "Security issues"; - "Team meeting"; - "Discussion about"; - "Work plans"; - "Meeting with the professor"; - "Meeting with the boss"; - "Work issues"; - "New workers"; - }; - -struct r_data_meetingplaces - { - "Room"; - "Home"; - "Auditorium"; - "Company"; - }; - -struct r_data_landmark_names - { - "Good place to fish";}, - "Uncle over board";}, - "Best food ever!";}, - "Nice beach";}, - "Good hamburgers";}, - "Nice view";}, - "John's home";}, - "Carage";}, - "Gas station";}, - "Food store";}, - "Car wash";}, - "Summer cottage";}, - "My home";}, - "Bank";}, - "Hospital";}, - "Ice hall";}, - "Work place";} - }; - -struct r_data_landmark_descriptions - { - "The salmons were really big here!";}, - "Delicious strawberries sold here. Must visit again sometime!";}, - "Place looks really nice.";}, - "This is my favorite place";}, - "Words are not enough to describe this landmark";}, - "What a shocking place to visit! Remember to bring camera next time :-)";} - }; - -struct r_data_memos - { - "No work today!"; - "Movies tonight"; - "Ship new binaries"; - "New works"; - "Exam"; - "Community service"; - "Volunteer work"; - "Don't forget the dinner at the restaurant"; - "Go the bank"; - "Go to the store"; - "Buy goods"; - "Buy food"; - "Buy new pair of socks"; - "Buy vegetables"; - "Buy fruits"; - "Umbrella"; - "New shoes"; - "New suit"; - "Buy flowers"; - "School day"; - }; - -struct r_data_anniversaries - { - "birthday"; - "anniversary"; - }; - -struct r_data_todos - { - "Watch for gum on my shoe"; - "Watch my step in the hall"; - "Always think big"; - "Don't ever think small"; - "Keep pedaling my bike"; - "Watch for bees in my pop"; - "Keep moving forward"; - "Don't ever stop"; - "Keep my sled underneath me"; - "Keep my stick on the ice"; - "Don't swim in a whirlpool"; - "Don't look for a fight"; - "Don't spit in the wind"; - "Just do what is right"; - "Go out in the world"; - "Enjoy a warm rain"; - "Don't worship TV"; - "Keep my oars in the water"; - "Point my boat right downstream"; - "Face head on my problems"; - "Change underwear daily"; - "Believe myself first"; - "Go out and have fun"; - "Turn the cards one by one"; - "Get out and do something"; - }; - -struct r_data_reminders - { - "Remeber to fix car"; - "Remeber to eat vegetables"; - "Remeber to go shopping"; - "Remeber to buy boxes for moving"; - "Remeber to fix bike"; - "Remeber to buy christmast presents"; - "Remeber to send flowers to grandmother"; - "Remeber to talk with son"; - "Remeber to cut hedge"; - "Remeber to bumper potatoes"; - "Remeber to harvest corn field"; - "Remeber to sleep enaugh"; - "Remeber to wash teeths ewery morning"; - "Remeber to get sleep early"; - "Remeber to give some wather to flowers"; - "Remeber to wax snowboard"; - "Remeber to wax skiis"; - "Remeber to wax cross country skiis"; - "Remeber to call mother"; - "Remeber to call father"; - "Remeber to call brother"; - "Remeber to call sister"; - "Remeber to call daughter"; - "Remeber to call son"; - "Remeber to rent villa"; - }; - -struct r_data_messagesubjects - { - "Whaaasssaaap!!??"; - "Hello"; - "How are you doing?"; - "You will win the battle, GUARANTEED!"; - "Why pay more for something if you don't have to?"; - "You can afford health care now"; - "Re: *Buddy* *Lists*!!~ (it's soooo cool)!!~"; - "Weedmon say: call, we be open 7 days, mon"; - "Want her to look better?"; - "Good Morning andyw, how are you?"; - "Happy Assumption"; - "There is NO Risk involved"; - "Free Bottle Offer!"; - "Introduction on MDSL"; - "Theres Help out there for you"; - "hello there - check this out"; - "Darling"; - "It doesn't have to be that way"; - "Webmaster, Free health insurance quotes!"; - "Join us at the OSGi 2003 World Congress"; - "Put your subject line here"; - "You are not protected"; - "Please try again"; - "you didn't reply my email ? why ? ???"; - "A very funny game"; - "Meeting notice"; - "Opportunities"; - }; - -struct r_data_messagetexts - { - "The contents of these pages are copyrighted. Any rights not expressly granted herein are reserved. The use of this site is permitted to private use."; - "Reproduction, transfer, distribution or storage of part or all of the contents in any form without the prior written permission is prohibited."; - "We consents to you browsing the pages on your computer or printing copies of extracts from these pages for your personal use only."; - "If you place an order for a product, request a service or submit content to this site, we may need to contact you for additional information."; - "The use of press releases and other documents classified as public is permitted in public communications if the source for the information has been stated."; - "For your easy accessibility we may include links to sites on the Internet that are owned or operated by third parties."; - "You also agree that we have no control over the content of that site and cannot assume any responsibility for material by such third-party sites."; - "In addition, a link to a such site does not imply that we endorses the site or the products or services referenced in such third party site."; - "In order to respond to your questions or manage interactive customer programs, it may be necessary to ask for personal information."; - "We may use this information to respond to your requests, or to contact you via mail, e-mail or phone to inform you of new products."; - "If you place an order for a product, request a service or submit content to this site, we may need to contact you for additional information."; - }; - - diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/src/creator_accesspoint.cpp --- a/creator/engine/src/creator_accesspoint.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,473 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - - -//#include "creator_accesspoint.h" -#include "creator_traces.h" -#include -#include -#include "enginewrapper.h" - -static const TInt KAccessPointsFieldLength = 128; - -_LIT(KCreatorAccessPointsPrefixName, "CR_"); -_LIT(KZeroIP, "0.0.0.0"); - -//---------------------------------------------------------------------------- - -CAccessPointsParameters::CAccessPointsParameters() - { - LOGSTRING("Creator: CAccessPointsParameters::CAccessPointsParameters"); - - iConnectionName = HBufC::New(KAccessPointsFieldLength); - iWapStartPage = HBufC::New(KAccessPointsFieldLength); - iGprsAcessPointName = HBufC::New(KAccessPointsFieldLength); - iIspLoginName = HBufC::New(KAccessPointsFieldLength); - iIspLoginPass = HBufC::New(KAccessPointsFieldLength); - iWapGatewayAddress = HBufC::New(KAccessPointsFieldLength); - iIspIPAddr = HBufC::New(KAccessPointsFieldLength); - iIspIPNameServer1 = HBufC::New(KAccessPointsFieldLength); - iIspIPNameServer2 = HBufC::New(KAccessPointsFieldLength); - iIspDefaultTelNumber = HBufC::New(KAccessPointsFieldLength); - iProxyServerAddress = HBufC::New(KAccessPointsFieldLength); - } - -CAccessPointsParameters::~CAccessPointsParameters() - { - LOGSTRING("Creator: CAccessPointsParameters::~CAccessPointsParameters"); - - delete iProxyServerAddress; - delete iIspDefaultTelNumber; - delete iIspIPNameServer2; - delete iIspIPNameServer1; - delete iIspIPAddr; - delete iWapGatewayAddress; - delete iIspLoginPass; - delete iIspLoginName; - delete iGprsAcessPointName; - delete iWapStartPage; - delete iConnectionName; - } - -void CAccessPointsParameters::SetRandomCMNameL(CCreatorEngine& aEngine) - { - TInt num = aEngine.RandomNumber(1, 3); - TBuf<10> apType; - - if (num==1) - apType = _L("mms"); - else if (num==2) - apType = _L("wap"); - else - apType = _L("internet"); - - TBuf<160> company = aEngine.RandomString(CCreatorEngine::ECompany); - - iConnectionName->Des() = KCreatorAccessPointsPrefixName; - iConnectionName->Des().Append( company ); - iConnectionName->Des().Append(_L(" ")); - iConnectionName->Des().Append(apType); - } - -void CAccessPointsParameters::SetRandomLoginNameL(CCreatorEngine& aEngine) - { - iIspLoginName->Des() = aEngine.RandomString(CCreatorEngine::EFirstName); - iIspLoginName->Des().LowerCase(); - } - -void CAccessPointsParameters::SetRandomLoginPassL(CCreatorEngine& /*aEngine*/) - {} - -void CAccessPointsParameters::SetRandomSecureAuthenticationL(CCreatorEngine& /*aEngine*/) - {} - -void CAccessPointsParameters::SetRandomPromptPasswordL(CCreatorEngine& /*aEngine*/) - {} - -void CAccessPointsParameters::SetRandomProxyAddressL(CCreatorEngine& /*aEngine*/) - {} - -void CAccessPointsParameters::SetRandomProxyPortL(CCreatorEngine& /*aEngine*/) - {} - -void CAccessPointsParameters::SetRandomStartPageL(CCreatorEngine& /*aEngine*/) - {} - -void CAccessPointsParameters::SetRandomIPAddressL(CCreatorEngine& /*aEngine*/) - {} - -void CAccessPointsParameters::SetRandomIP4NameServer1L(CCreatorEngine& /*aEngine*/) - {} - -void CAccessPointsParameters::SetRandomIP4NameServer2L(CCreatorEngine& /*aEngine*/) - {} - -void CAccessPointsParameters::SetRandomTelephoneNumberL(CCreatorEngine& /*aEngine*/) - {} - -void CAccessPointsParameters::SetRandomBearerTypeIsdnL(CCreatorEngine& /*aEngine*/) - {} - -void CAccessPointsParameters::SetRandomBearerSpeedL(CCreatorEngine& /*aEngine*/) - {} - -void CAccessPointsParameters::SetRandomWapWspOptionL(CCreatorEngine& /*aEngine*/) - {} - -void CAccessPointsParameters::SetRandomGatewayAddressL(CCreatorEngine& /*aEngine*/) - {} - -//---------------------------------------------------------------------------- - -CCreatorAccessPoints* CCreatorAccessPoints::NewL(CCreatorEngine* aEngine) - { - CCreatorAccessPoints* self = CCreatorAccessPoints::NewLC(aEngine); - CleanupStack::Pop(self); - return self; - } - -CCreatorAccessPoints* CCreatorAccessPoints::NewLC(CCreatorEngine* aEngine) - { - CCreatorAccessPoints* self = new (ELeave) CCreatorAccessPoints; - CleanupStack::PushL(self); - self->ConstructL(aEngine); - return self; - } - -CCreatorAccessPoints::CCreatorAccessPoints() - { - } - -void CCreatorAccessPoints::ConstructL(CCreatorEngine* aEngine) - { - LOGSTRING("Creator: CCreatorAccessPoints::ConstructL"); - - iEngine = aEngine; - - iCommsDb = CCommsDatabase::NewL();; - iApDataHandler = CApDataHandler::NewLC(*iCommsDb); - CleanupStack::Pop(); - iApUtils = CApUtils::NewLC(*iCommsDb); - CleanupStack::Pop(); - } - -CCreatorAccessPoints::~CCreatorAccessPoints() - { - LOGSTRING("Creator: CCreatorAccessPoints::~CCreatorAccessPoints"); - - if ( iEngine && iEntryIds.Count() ) - { - TRAP_IGNORE( iEngine->WriteEntryIdsToStoreL( iEntryIds, KUidDictionaryUidIAP ) ); - } - iEntryIds.Reset(); - iEntryIds.Close(); - - delete iApUtils; - delete iApDataHandler; - delete iCommsDb; - - if (iParameters) - delete iParameters; - } - -//---------------------------------------------------------------------------- - -TBool CCreatorAccessPoints::AskDataFromUserL(TInt aCommand) - { - LOGSTRING("Creator: CCreatorAccessPoints::AskDataFromUserL"); - - CCreatorModuleBase::AskDataFromUserL( aCommand );//ignore retval - - if( aCommand == ECmdDeleteIAPs ) - { - return iEngine->GetEngineWrapper()->YesNoQueryDialog(_L("Delete all Access Points?"), this, ECreatorModuleDelete ); - } - else if( aCommand == ECmdDeleteCreatorIAPs ) - { - return iEngine->GetEngineWrapper()->YesNoQueryDialog(_L("Delete all Access Points created with Creator?"), this, ECreatorModuleDelete ); - } - - return iEngine->GetEngineWrapper()->EntriesQueryDialog(&iEntriesToBeCreated, _L("How many entries to create?"), EFalse, this, ECreatorModuleStart ); - } - - -//---------------------------------------------------------------------------- - -TInt CCreatorAccessPoints::CreateConnectionSettingsEntryL(CCreatorModuleBaseParameters *aParameters) - { - LOGSTRING("Creator: CCreatorAccessPoints::CreateAccessPointEntryL"); - - CAccessPointsParameters* parameters = (CAccessPointsParameters*) aParameters; - - // clear any existing parameter definations - delete iParameters; - iParameters = NULL; - - - - // random data needed if no predefined data available - if (!parameters) - { - TBuf<160> company = iEngine->RandomString(CCreatorEngine::ECompany); - TInt num = iEngine->RandomNumber(1, 3); - TBuf<10> apType; - - if (num==1) - apType = _L("mms"); - else if (num==2) - apType = _L("wap"); - else - apType = _L("internet"); - - iParameters = new(ELeave) CAccessPointsParameters; - parameters = iParameters; - - parameters->SetRandomCMNameL(*iEngine); - - // in random mode just create GPRS access points - parameters->iBearerType = EApBearerTypeGPRS; - - parameters->SetRandomLoginNameL(*iEngine); - - iParameters->iIspLoginPass->Des() = iEngine->RandomString(CCreatorEngine::ESurname); - iParameters->iIspLoginPass->Des().LowerCase(); - - iParameters->iSecureAuthentication = EFalse; - iParameters->iPromptPassword = EFalse; - - iParameters->iProxyServerAddress->Des() = _L("127.0.0.1"); - iParameters->iProxyPortNumber = 80; - - iParameters->iWapStartPage->Des() = _L("http://"); - iParameters->iWapStartPage->Des().Append(apType); - iParameters->iWapStartPage->Des().Append(_L(".")); - iParameters->iWapStartPage->Des().Append(company); - iParameters->iWapStartPage->Des().Append(_L(".com")); - iParameters->iWapStartPage->Des().LowerCase(); - - iParameters->iIspIPAddr->Des() = KZeroIP; - iParameters->iIspIPNameServer1->Des() = KZeroIP; - iParameters->iIspIPNameServer1->Des() = KZeroIP; - iParameters->iGprsAcessPointName->Des() = apType; - iParameters->iIspDefaultTelNumber->Des() = iEngine->RandomString(CCreatorEngine::EPhoneNumber); - iParameters->iIspBearerCallTypeIsdn = ECallTypeISDNv110; - iParameters->iIspBearerSpeed = KSpeed14400; - - iParameters->iWapWspOption = EWapWspOptionConnectionOriented; - iParameters->iWapGatewayAddress->Des() = KZeroIP; - } - else - { - // otherwise replace the parameters object - iParameters = parameters; - } - - TInt err = KErrNone; - - // access point item - CApAccessPointItem* apItem = CApAccessPointItem::NewLC(); - - // set the bearer type, if it fails try to set a default type - TRAPD(bearerErr, apItem->SetBearerTypeL(iParameters->iBearerType)); - if (bearerErr != KErrNone) - { - iParameters->iBearerType = EApBearerTypeGPRS; - TRAPD(bearerErr2, apItem->SetBearerTypeL(iParameters->iBearerType)); - bearerErr2=bearerErr2; - } - - if (iParameters->iBearerType == EApBearerTypeGPRS) // GPRS - { - err = apItem->WriteLongTextL(EApGprsAccessPointName, iParameters->iGprsAcessPointName->Des()); - } - else // CSD or HCSD - { - err = apItem->WriteTextL(EApIspDefaultTelNumber, iParameters->iIspDefaultTelNumber->Des()); - err = apItem->WriteUint(EApIspBearerCallTypeIsdn, iParameters->iIspBearerCallTypeIsdn); - err = apItem->WriteUint(EApIspBearerSpeed, iParameters->iIspBearerSpeed); - } - - err = apItem->WriteTextL(EApIspLoginName, iParameters->iIspLoginName->Des()); - err = apItem->WriteTextL(EApIspIfAuthName, iParameters->iIspLoginName->Des()); - err = apItem->WriteTextL(EApIspLoginPass, iParameters->iIspLoginPass->Des()); - err = apItem->WriteTextL(EApIspIfAuthPass, iParameters->iIspLoginPass->Des()); - err = apItem->WriteTextL(EApGprsIfAuthPassword, iParameters->iIspLoginPass->Des()); - err = apItem->WriteBool(EApIspDisablePlainTextAuth, iParameters->iSecureAuthentication); - err = apItem->WriteBool(EApIspPromptForLogin, iParameters->iPromptPassword); - err = apItem->WriteTextL(EApWapGatewayAddress, iParameters->iWapGatewayAddress->Des()); - err = apItem->WriteLongTextL(EApProxyServerAddress, iParameters->iProxyServerAddress->Des()); - err = apItem->WriteUint(EApProxyPortNumber, iParameters->iProxyPortNumber); - err = apItem->WriteLongTextL(EApWapStartPage, iParameters->iWapStartPage->Des()); - err = apItem->WriteUint(EApWapWspOption, iParameters->iWapWspOption); - err = apItem->WriteTextL(EApGprsIPNameServer1, iParameters->iIspIPNameServer1->Des()); - err = apItem->WriteTextL(EApGprsIPNameServer2, iParameters->iIspIPNameServer2->Des()); - err = apItem->WriteTextL(EApIspIPAddr, iParameters->iIspIPAddr->Des()); - - - TUint32 uid = iApDataHandler->CreateFromDataL(*apItem); // save the access point, returns the uid of the AP - - // id has been generated, store it for being able to delete - // entries created only with Creator - iEntryIds.AppendL( uid ); - - TBuf<256> name = iParameters->iConnectionName->Des(); - iApUtils->SetNameL(name, uid); // sets the AP name - - - // if no defaults set, set the created AP as a default - - // MMS access point - if (iParameters->iWapStartPage->Des().FindF(_L("mms")) >=0 || iParameters->iConnectionName->Des().FindF(_L("mms")) >=0 ) - { - //User::Panic(_L("Not done yet..."), 123); - } - - - // WAP access point - else if (iParameters->iConnectionName->Des().FindF(_L("wap")) >=0 || iParameters->iGprsAcessPointName->Des().FindF(_L("wap")) >= 0) - { - TUint32 defID = 0; - TRAP( err, defID = iApDataHandler->DefaultL(ETrue) ); // ETrue==WAP - - if (defID <= 1) - TRAP( err, iApDataHandler->SetAsDefaultL(uid, EIspTypeWAPOnly) ); - - } - - // Internet access point - else if (iParameters->iConnectionName->Des().FindF(_L("internet")) >=0 || iParameters->iGprsAcessPointName->Des().FindF(_L("internet")) >= 0) - { - TUint32 defID = 0; - TRAP( err, defID = iApDataHandler->DefaultL(EFalse) ); // EFalse==IAP - - if (defID <= 1) - TRAP( err, iApDataHandler->SetAsDefaultL(uid, EIspTypeInternetOnly) ); // <-- POSSIBLY NOT CORRECT, NEEDS MORE TESTING - } - - - - CleanupStack::PopAndDestroy(); //apItem - - return err; - } - -//---------------------------------------------------------------------------- - -TUint32 CCreatorAccessPoints::AccessPointNameToIdL(const TDesC& aAPName, TBool /*aAnyIfNotFound*/ ) - { - LOGSTRING("Creator: CCreatorEngine::AccessPointNameToIdL"); - - TBuf<256> apName = aAPName.Left(256); - apName.Trim(); - - TUint32 APId = iEngine->GetDefaultIAPL(); - - // return default IAP if requested - if (apName.CompareF(_L("DEFAULT-IAP")) == 0 || apName.CompareF(_L("DEFAULT")) == 0) - { - return APId; - } - - CCommsDatabase* db = CCommsDatabase::NewL(EDatabaseTypeIAP); - CleanupStack::PushL(db); - CApUtils* apUtils = CApUtils::NewLC(*db); - CApSelect* apSelect = CApSelect::NewLC(*db, KEApIspTypeAll, EApBearerTypeAll, KEApSortNameAscending); - - - // loop through all access points and try to find a matching name - if (apSelect->MoveToFirst()) - { - do - { - TBuf<256> apName2; - apUtils->NameL(apSelect->Uid(), apName2); - apName2.Trim(); - - if (apName2.CompareF( apName ) == 0) - { - // match found, get uid and break the loop - TRAPD( err, APId = apUtils->IapIdFromWapIdL(apSelect->Uid()) ); - err=err; - break; - } - } - while (apSelect->MoveNext()); - } - - CleanupStack::PopAndDestroy(3); //apSelect, apUtils, db - - return APId; - } - -//---------------------------------------------------------------------------- - -void CCreatorAccessPoints::HandleSessionEventL(TMsvSessionEvent /*aEvent*/, TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/) // from MMsvSessionObserver - { - } - -//---------------------------------------------------------------------------- -void CCreatorAccessPoints::DeleteAllL() - { - LOGSTRING("Creator: CCreatorEngine::DeleteAllL"); - - CApSelect* selector = CApSelect::NewLC( *iCommsDb, - KEApIspTypeAll, - EApBearerTypeAllBearers, - KEApSortUidAscending ); - - CApListItemList* list = new (ELeave) CApListItemList(); - CleanupStack::PushL( list ); - TInt count = selector->AllListItemDataL( *list ); - for ( TInt i = 0; i < count; i++ ) - { - TRAP_IGNORE( iApDataHandler->RemoveAPL( (*list)[i]->Uid() ) ); - } - - CleanupStack::PopAndDestroy( list ); - CleanupStack::PopAndDestroy( selector ); - - // reset must be done here, because iEntryIds is stored in destructor - iEntryIds.Reset(); - - // all entries deleted, remove the Logs related registry - iEngine->RemoveStoreL( KUidDictionaryUidIAP ); - } - -//---------------------------------------------------------------------------- - -void CCreatorAccessPoints::DeleteAllCreatedByCreatorL() - { - LOGSTRING("Creator: CCreatorEngine::DeleteAllCreatedByCreatorL"); - iEntryIds.Reset(); - - // fetch ids of entries created by Creator - iEngine->ReadEntryIdsFromStoreL( iEntryIds, KUidDictionaryUidIAP ); - - // delete entries - for ( TInt i = 0; i < iEntryIds.Count(); i++ ) - { - TRAP_IGNORE( iApDataHandler->RemoveAPL( iEntryIds[i] ) ); - } - - // reset must be done here, because iEntryIds is stored in destructor - iEntryIds.Reset(); - - // all entries deleted, remove the Logs related registry - iEngine->RemoveStoreL( KUidDictionaryUidIAP ); - } diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/src/creator_browser.cpp --- a/creator/engine/src/creator_browser.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,595 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#include - -#include "engine.h" -#include "enginewrapper.h" -#include "creator_browser.h" -#include "creator_traces.h" - - -static const TInt KBrowserFieldLength = 128; - -_LIT(KCreatorBrowserPrefixName, "CR_"); -_LIT(KCreatorBrowserPrefixFolderName, "CR_FLDR_"); - -//---------------------------------------------------------------------------- - -CBrowserParameters::CBrowserParameters() - { - LOGSTRING("Creator: CBrowserParameters::CBrowserParameters"); - - iBookmarkName = HBufC::New(KBrowserFieldLength); - iBookmarkAddress = HBufC::New(KBrowserFieldLength); - iBookmarkUsername = HBufC::New(KBrowserFieldLength); - iBookmarkPassword = HBufC::New(KBrowserFieldLength); - iBookmarkFolderName = HBufC::New(KBrowserFieldLength); - iSavedDeckLinkName = HBufC::New(KBrowserFieldLength); - iSavedDeckLocalAddress = HBufC::New(KBrowserFieldLength); - iSavedDeckFolderName = HBufC::New(KBrowserFieldLength); - } - -CBrowserParameters::~CBrowserParameters() - { - LOGSTRING("Creator: CBrowserParameters::~CBrowserParameters"); - - delete iSavedDeckFolderName; - delete iSavedDeckLocalAddress; - delete iSavedDeckLinkName; - delete iBookmarkFolderName; - delete iBookmarkPassword; - delete iBookmarkUsername; - delete iBookmarkAddress; - delete iBookmarkName; - - } - -//---------------------------------------------------------------------------- - -CCreatorBrowser* CCreatorBrowser::NewL(CCreatorEngine* aEngine) - { - CCreatorBrowser* self = CCreatorBrowser::NewLC(aEngine); - CleanupStack::Pop(self); - return self; - } - -CCreatorBrowser* CCreatorBrowser::NewLC(CCreatorEngine* aEngine) - { - CCreatorBrowser* self = new (ELeave) CCreatorBrowser; - CleanupStack::PushL(self); - self->ConstructL(aEngine); - return self; - } - -CCreatorBrowser::CCreatorBrowser() - { - } - -void CCreatorBrowser::ConstructL(CCreatorEngine* aEngine) - { - LOGSTRING("Creator: CCreatorBrowser::ConstructL"); - - iEngine = aEngine; - } - -CCreatorBrowser::~CCreatorBrowser() - { - LOGSTRING("Creator: CCreatorBrowser::~CCreatorBrowser"); - if ( iEngine && iBmEntryIds.Count() ) - { - TRAP_IGNORE( iEngine->WriteEntryIdsToStoreL( iBmEntryIds, KUidDictionaryUidBrowserBookmarks ) ); - } - iBmEntryIds.Reset(); - iBmEntryIds.Close(); - - if ( iEngine && iBmFEntryIds.Count() ) - { - TRAP_IGNORE( iEngine->WriteEntryIdsToStoreL( iBmFEntryIds, KUidDictionaryUidBrowserBookmarkF ) ); - } - iBmFEntryIds.Reset(); - iBmFEntryIds.Close(); - - if ( iEngine && iSpEntryIds.Count() ) - { - TRAP_IGNORE( iEngine->WriteEntryIdsToStoreL( iSpEntryIds, KUidDictionaryUidBrowserSavedPg ) ); - } - iSpEntryIds.Reset(); - iSpEntryIds.Close(); - - if ( iEngine && iSpFEntryIds.Count() ) - { - TRAP_IGNORE( iEngine->WriteEntryIdsToStoreL( iSpFEntryIds, KUidDictionaryUidBrowserSavedPgF ) ); - } - iSpFEntryIds.Reset(); - iSpFEntryIds.Close(); - - delete iParameters; - } - -//---------------------------------------------------------------------------- - -TBool CCreatorBrowser::AskDataFromUserL(TInt aCommand) - { - LOGSTRING("Creator: CCreatorBrowser::AskDataFromUserL"); - - CCreatorModuleBase::AskDataFromUserL( aCommand );//ignore retval - - TBool result( EFalse ); - switch ( aCommand ) - { - case ECmdDeleteBrowserBookmarks: - { - result = iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all Browser bookmarks?"), this, ECreatorModuleDelete ); - break; - } - case ECmdDeleteCreatorBrowserBookmarks: - { - result = iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all Browser bookmarks created with Creator?"), this, ECreatorModuleDelete ); - break; - } - case ECmdDeleteBrowserBookmarkFolders: - { - result = iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all Browser bookmark folders?"), this, ECreatorModuleDelete ); - break; - } - case ECmdDeleteCreatorBrowserBookmarkFolders: - { - result = iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all Browser bookmark folders created with Creator?"), this, ECreatorModuleDelete ); - break; - } - case ECmdDeleteBrowserSavedPages: - { - result = iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all Browser saved pages?"), this, ECreatorModuleDelete ); - break; - } - case ECmdDeleteCreatorBrowserSavedPages: - { - result = iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all Browser saved pages created with Creator?"), this, ECreatorModuleDelete ); - break; - } - case ECmdDeleteBrowserSavedPageFolders: - { - result = iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all Browser saved pages folders?"), this, ECreatorModuleDelete ); - break; - } - case ECmdDeleteCreatorBrowserSavedPageFolders: - { - result = iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all Browser saved pages folders created with Creator?"), this, ECreatorModuleDelete ); - break; - } - default: - { - result = iEngine->GetEngineWrapper()->EntriesQueryDialog(&iEntriesToBeCreated, _L("How many entries to create?"), EFalse, this, ECreatorModuleStart ); - break; - } - } - return result; - } - - -//---------------------------------------------------------------------------- - -TInt CCreatorBrowser::CreateBookmarkEntryL(CBrowserParameters *aParameters) - { - LOGSTRING("Creator: CCreatorBrowser::CreateBookmarkEntryL"); - - // clear any existing parameter definations - delete iParameters; - iParameters = NULL; - - CBrowserParameters* parameters = aParameters; - - // random data needed if no predefined data available - if( !parameters ) - { - iParameters = new(ELeave) CBrowserParameters; - parameters = iParameters; - - TFileName userAndPassword = iEngine->RandomString(CCreatorEngine::EFirstName); - TFileName name = iEngine->RandomString(CCreatorEngine::ECompany); - TFileName url = name; - url.Insert(0, _L("http://www.")); - url.Append(_L(".com/")); - name.Insert(0, KCreatorBrowserPrefixName); - - parameters->iBookmarkName->Des() = name; - parameters->iBookmarkAddress->Des() = url; - parameters->iBookmarkUsername->Des() = userAndPassword; - parameters->iBookmarkPassword->Des() = userAndPassword; - } - - TInt err = KErrNone; - - RFavouritesSession session; - User::LeaveIfError( session.Connect() ); - CleanupClosePushL(session); - RFavouritesDb db; - User::LeaveIfError( db.Open(session, KBrowserBookmarks) ); - CleanupClosePushL(db); - - CFavouritesItem* item = CFavouritesItem::NewLC(); - item->SetType( CFavouritesItem::EItem ); - item->SetParentFolder( KFavouritesRootUid ) ; - item->SetNameL( parameters->iBookmarkName->Des() ); - item->SetUrlL( parameters->iBookmarkAddress->Des() ); - item->SetUserNameL( parameters->iBookmarkUsername->Des() ); - item->SetPasswordL( parameters->iBookmarkPassword->Des() ); - err = db.Add(*item, /*aAutoRename=*/ETrue); - if (err) - db.Commit(); - - // id has been generated, store it for being able to delete - // only entries created with Creator - iBmEntryIds.AppendL( item->Uid() ); - - CleanupStack::PopAndDestroy(3); //db, session, item - - return err; - } - -//---------------------------------------------------------------------------- - -TInt CCreatorBrowser::CreateBookmarkFolderEntryL(CBrowserParameters *aParameters) - { - LOGSTRING("Creator: CCreatorBrowser::CreateBookmarkFolderEntryL"); - - // clear any existing parameter definations - delete iParameters; - iParameters = NULL; - - CBrowserParameters* parameters = aParameters; - - // random data needed if no predefined data available - if (!parameters) - { - iParameters = new(ELeave) CBrowserParameters; - parameters = iParameters; - - TFileName name = iEngine->RandomString(CCreatorEngine::ECompany); - name.Insert(0, KCreatorBrowserPrefixFolderName); - - parameters->iBookmarkFolderName->Des() = name; - } - - TInt err = KErrNone; - - RFavouritesSession session; - User::LeaveIfError( session.Connect() ); - CleanupClosePushL(session); - RFavouritesDb db; - User::LeaveIfError( db.Open(session, KBrowserBookmarks) ); - CleanupClosePushL(db); - - CFavouritesItem* item = CFavouritesItem::NewLC(); - item->SetType( CFavouritesItem::EFolder ); - item->SetParentFolder( KFavouritesRootUid ) ; - item->SetNameL( parameters->iBookmarkFolderName->Des() ); - - err = db.Add(*item, /*aAutoRename=*/ETrue); - if (err) - db.Commit(); - - // id has been generated, store it for being able to delete - // only entries created with Creator - iBmFEntryIds.AppendL( item->Uid() ); - - CleanupStack::PopAndDestroy(3); //db, session, item - - - return err; - - } - -//---------------------------------------------------------------------------- - -TInt CCreatorBrowser::CreateSavedDeckEntryL(CBrowserParameters *aParameters) - { - LOGSTRING("Creator: CCreatorBrowser::CreateSavedDeckEntryL"); - - // clear any existing parameter definations - delete iParameters; - iParameters = NULL; - - CBrowserParameters* parameters = aParameters; - - // random data needed if no predefined data available - if (!parameters) - { - iParameters = new(ELeave) CBrowserParameters; - parameters = iParameters; - - TFileName name = iEngine->RandomString(CCreatorEngine::ECompany); - name.Insert(0, KCreatorBrowserPrefixName); - - parameters->iSavedDeckLinkName->Des() = name; - parameters->iSavedDeckLocalAddress->Des() = iEngine->TestDataPathL(CCreatorEngine::ESavedDeck_1kB); - } - - TInt err = KErrNone; - - // check the deck address is correct - if ( parameters->iSavedDeckLocalAddress->Des().Length() == 0 || - !BaflUtils::FileExists( CEikonEnv::Static()->FsSession(), parameters->iSavedDeckLocalAddress->Des() )) - { - // not found, use a default deck instead - delete parameters->iSavedDeckLocalAddress; - parameters->iSavedDeckLocalAddress = 0; - TPtrC tmp = iEngine->TestDataPathL(CCreatorEngine::ESavedDeck_1kB); - parameters->iSavedDeckLocalAddress = HBufC::NewL(tmp.Length()); - parameters->iSavedDeckLocalAddress->Des() = tmp; - } - - - RFavouritesSession session; - User::LeaveIfError( session.Connect() ); - CleanupClosePushL(session); - RFavouritesDb db; - User::LeaveIfError( db.Open(session, KBrowserSavedPages) ); - CleanupClosePushL(db); - - CFavouritesItem* item = CFavouritesItem::NewLC(); - item->SetType( CFavouritesItem::EItem ); - item->SetParentFolder( KFavouritesRootUid ) ; - item->SetNameL( parameters->iSavedDeckLinkName->Des() ); - item->SetUrlL( _L(" ") ); - - TFavouritesWapAp favouritesAp; - favouritesAp.SetDefault(); - item->SetWapAp( favouritesAp ); - - - err = db.Add(*item, /*aAutoRename=*/ETrue); - if (err) - db.Commit(); - - // read the source deck to buffer - RFile sourceFile; - User::LeaveIfError( sourceFile.Open(CEikonEnv::Static()->FsSession(), parameters->iSavedDeckLocalAddress->Des(), EFileRead) ); - CleanupClosePushL(sourceFile); - TInt sourceFileSize(0); - err = sourceFile.Size(sourceFileSize); - HBufC8* sourceBuf = HBufC8::NewLC(sourceFileSize); - TPtr8 sourcePtr = sourceBuf->Des(); - sourceFile.Read(sourcePtr); - - // write the deck - RFavouritesFile destinationFile; - User::LeaveIfError( destinationFile.Replace(db, item->Uid() )); - CleanupClosePushL(destinationFile); - err = destinationFile.Write(sourceBuf->Des()); - - // id has been generated, store it for being able to delete - // only entries created with Creator - iSpEntryIds.AppendL( item->Uid() ); - - - CleanupStack::PopAndDestroy(6); //db, session, item, sourceFile, destinationFile, sourceBuf - - return err; - } - -//---------------------------------------------------------------------------- - -TInt CCreatorBrowser::CreateSavedDeckFolderEntryL(CBrowserParameters *aParameters) - { - LOGSTRING("Creator: CCreatorBrowser::CreateSavedDeckFolderEntryL"); - - // clear any existing parameter definations - delete iParameters; - iParameters = NULL; - - CBrowserParameters* parameters = aParameters; - // random data needed if no predefined data available - if (!parameters) - { - iParameters = new(ELeave) CBrowserParameters; - parameters = iParameters; - - TFileName name = iEngine->RandomString(CCreatorEngine::ECompany); - name.Insert(0, KCreatorBrowserPrefixFolderName); - - parameters->iSavedDeckFolderName->Des() = name; - } - - TInt err = KErrNone; - - RFavouritesSession session; - User::LeaveIfError( session.Connect() ); - CleanupClosePushL(session); - RFavouritesDb db; - User::LeaveIfError( db.Open(session, KBrowserSavedPages) ); - CleanupClosePushL(db); - - CFavouritesItem* item = CFavouritesItem::NewLC(); - item->SetType( CFavouritesItem::EFolder ); - item->SetParentFolder( KFavouritesRootUid ) ; - item->SetNameL( parameters->iSavedDeckFolderName->Des() ); - - err = db.Add(*item, /*aAutoRename=*/ETrue); - if (err) - db.Commit(); - - // id has been generated, store it for being able to delete - // only entries created with Creator - iSpFEntryIds.AppendL( item->Uid() ); - - CleanupStack::PopAndDestroy(3); //db, session, item - - return err; - - } - - -//---------------------------------------------------------------------------- -void CCreatorBrowser::DeleteAllL() - { - LOGSTRING("Creator: CCreatorBrowser::DeleteAllL"); - User::Leave( KErrNotSupported ); - // will not be supported, see separate implementations below - } - -//---------------------------------------------------------------------------- -void CCreatorBrowser::DeleteAllCreatedByCreatorL() - { - LOGSTRING("Creator: CCreatorBrowser::DeleteAllCreatedByCreatorL"); - User::Leave( KErrNotSupported ); - // will not be supported, see separate implementations below - } - -//---------------------------------------------------------------------------- -void CCreatorBrowser::DeleteAllBookmarksL() - { - LOGSTRING("Creator: CCreatorBrowser::DeleteAllBookmarksL"); - DeleteAllItemsL( KBrowserBookmarks, - CFavouritesItem::EItem, - EFalse, - iBmEntryIds, // ignored, because deleting all - KUidDictionaryUidBrowserBookmarks ); - } - -//---------------------------------------------------------------------------- -void CCreatorBrowser::DeleteAllBookmarksCreatedByCreatorL() - { - LOGSTRING("Creator: CCreatorBrowser::DeleteAllBookmarksCreatedByCreatorL"); - DeleteAllItemsL( KBrowserBookmarks, - CFavouritesItem::EItem, - ETrue, - iBmEntryIds, - KUidDictionaryUidBrowserBookmarks ); - } - -//---------------------------------------------------------------------------- -void CCreatorBrowser::DeleteAllBookmarkFoldersL() - { - LOGSTRING("Creator: CCreatorBrowser::DeleteAllBookmarkFoldersL"); - DeleteAllItemsL( KBrowserBookmarks, - CFavouritesItem::EFolder, - EFalse, - iBmFEntryIds, // ignored, because deleting all - KUidDictionaryUidBrowserBookmarkF ); - } - -//---------------------------------------------------------------------------- -void CCreatorBrowser::DeleteAllBookmarkFoldersCreatedByCreatorL() - { - LOGSTRING("Creator: CCreatorBrowser::DeleteAllBookmarkFoldersCreatedByCreatorL"); - DeleteAllItemsL( KBrowserBookmarks, - CFavouritesItem::EFolder, - ETrue, - iBmFEntryIds, - KUidDictionaryUidBrowserBookmarkF ); - } - -//---------------------------------------------------------------------------- -void CCreatorBrowser::DeleteAllSavedPagesL() - { - LOGSTRING("Creator: CCreatorBrowser::DeleteAllSavedPagesL"); - DeleteAllItemsL( KBrowserSavedPages, - CFavouritesItem::EItem, - EFalse, - iSpEntryIds, // ignored, because deleting all - KUidDictionaryUidBrowserSavedPg ); - } - -//---------------------------------------------------------------------------- -void CCreatorBrowser::DeleteAllSavedPagesCreatedByCreatorL() - { - LOGSTRING("Creator: CCreatorBrowser::DeleteAllSavedPagesCreatedByCreatorL"); - DeleteAllItemsL( KBrowserSavedPages, - CFavouritesItem::EItem, - ETrue, - iSpEntryIds, - KUidDictionaryUidBrowserSavedPg ); - } - -//---------------------------------------------------------------------------- -void CCreatorBrowser::DeleteAllSavedPageFoldersL() - { - LOGSTRING("Creator: CCreatorBrowser::DeleteAllSavedPageFoldersL"); - DeleteAllItemsL( KBrowserSavedPages, - CFavouritesItem::EFolder, - EFalse, - iSpFEntryIds, // ignored, because deleting all - KUidDictionaryUidBrowserSavedPgF ); - } - -//---------------------------------------------------------------------------- -void CCreatorBrowser::DeleteAllSavedPageFoldersCreatedByCreatorL() - { - LOGSTRING("Creator: CCreatorBrowser::DeleteAllSavedPageFolderssCreatedByCreatorL"); - DeleteAllItemsL( KBrowserSavedPages, - CFavouritesItem::EFolder, - ETrue, - iSpFEntryIds, - KUidDictionaryUidBrowserSavedPgF ); - } - -//---------------------------------------------------------------------------- -void CCreatorBrowser::DeleteAllItemsL( const TDesC& aDbName, - CFavouritesItem::TType aTypeFilter, - TBool aOnlyCreatedWithCreator, - RArray& aEntryIds, - const TUid aDictUid ) - { - LOGSTRING("Creator: CCreatorBrowser::DeleteItemL"); - RFavouritesSession session; - User::LeaveIfError( session.Connect() ); - CleanupClosePushL( session ); - RFavouritesDb db; - User::LeaveIfError( db.Open( session, aDbName ) ); - CleanupClosePushL( db ); - - if ( aOnlyCreatedWithCreator ) - { - // read uids from Creator internal store - aEntryIds.Reset(); - iEngine->ReadEntryIdsFromStoreL( aEntryIds, aDictUid ); - - // delete entries from db - for ( TInt i = 0; i < aEntryIds.Count(); i++ ) - { - db.Delete( aEntryIds[i] ); - } - } - else - { - CArrayFixFlat* uids = new (ELeave) CArrayFixFlat(64); - CleanupStack::PushL( uids ); - - // read uids from browser db - User::LeaveIfError( db.GetUids( *uids, KFavouritesRootUid, aTypeFilter ) ); - - // delete entries from db - for ( TInt i = 0; i < uids->Count(); i++ ) - { - db.Delete( uids->At(i) ); - } - - // db.Commit() seems to panic with EFavouritesNoTransaction - // deletion is successful even without commit, so not calling it - CleanupStack::PopAndDestroy( uids ); - } - - // entries deleted, remove the Browser related registry - aEntryIds.Reset(); - iEngine->RemoveStoreL( aDictUid ); - - CleanupStack::PopAndDestroy( &db ); - CleanupStack::PopAndDestroy( &session ); - } diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/src/creator_browserelement.cpp --- a/creator/engine/src/creator_browserelement.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,216 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - - -#include "creator_browserelement.h" -#include "creator_traces.h" -#include "creator_browser.h" - -using namespace creatorbrowser; - -/* - * - */ -CCreatorBrowserElement* CCreatorBrowserElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext ) - { - CCreatorBrowserElement* self = new (ELeave) CCreatorBrowserElement(aEngine); - CleanupStack::PushL(self); - self->ConstructL(aName, aContext); - CleanupStack::Pop(self); - return self; - } -/* - * - */ -CCreatorBrowserElement::CCreatorBrowserElement(CCreatorEngine* aEngine) -: -CCreatorScriptElement(aEngine) - { - iIsCommandElement = ETrue; - } - - -/* - * - */ -void CCreatorBrowserElement::ExecuteCommandL() - { - const CCreatorScriptAttribute* amountAttr = FindAttributeByName(KAmount); - TInt entryAmount = 1; - TBool addAll = EFalse; - if( amountAttr ) - { - entryAmount = ConvertStrToIntL(amountAttr->Value()); - } - // Get 'fields' element - CCreatorScriptElement* fieldsElement = FindSubElement(KFields); - if( fieldsElement ) - { - // Get sub-elements - const RPointerArray& fields = fieldsElement->SubElements(); - // Create browser entries, the amount of entries is defined by entryAmount: - for( TInt cI = 0; cI < entryAmount; ++cI ) - { - CBrowserParameters* param = 0; - - if( fields.Count() > 0 ) - param = new (ELeave) CBrowserParameters; - else - { - // No fields defined --> Add all fields with random values: - addAll = ETrue; - break; - } - - CleanupStack::PushL(param); - - for( TInt i = 0; i < fields.Count(); ++i ) - { - CCreatorScriptElement* field = fields[i]; - TPtrC elemName = field->Name(); - TPtrC elemContent = field->Content(); - const CCreatorScriptAttribute* randomAttr = fields[i]->FindAttributeByName(KRandomLength); - if( elemName == KName ) - { - if( randomAttr || elemContent.Length() == 0) - { - elemContent.Set(iEngine->RandomString(CCreatorEngine::ECompany)); - } - if( iName->Des() == KBookmark ) - { - SetContentToTextParamL(param->iBookmarkName, elemContent); - } - else if( iName->Des() == KBookmarkFolder ) - { - SetContentToTextParamL(param->iBookmarkFolderName, elemContent); - } - else if( iName->Des() == KSavedPage ) - { - SetContentToTextParamL(param->iSavedDeckLinkName, elemContent); - } - else if( iName->Des() == KSavedPageFolder ) - { - SetContentToTextParamL(param->iSavedDeckFolderName, elemContent); - } - } - - else if( elemName == KPath ) - { - if( randomAttr || elemContent.Length() == 0) - { - SetContentToTextParamL(param->iSavedDeckLocalAddress, iEngine->TestDataPathL(CCreatorEngine::ESavedDeck_1kB)); - } - else - { - SetContentToTextParamL(param->iSavedDeckLocalAddress, elemContent); - } - } - else if( elemName == KUsername ) - { - if( randomAttr || elemContent.Length() == 0) - { - // Set username and password to same string - if( param->iBookmarkPassword && param->iBookmarkPassword->Length() > 0 ) - { - SetContentToTextParamL(param->iBookmarkUsername, param->iBookmarkPassword->Des()); - } - else - { - SetContentToTextParamL(param->iBookmarkUsername, iEngine->RandomString(CCreatorEngine::EFirstName)); - } - } - else - { - SetContentToTextParamL(param->iBookmarkUsername, elemContent); - } - } - else if( elemName == KPassword ) - { - if( randomAttr || elemContent.Length() == 0) - { - // Set username and password to same string - if( param->iBookmarkUsername && param->iBookmarkUsername->Length() > 0 ) - { - SetContentToTextParamL(param->iBookmarkPassword, param->iBookmarkUsername->Des()); - } - else - { - SetContentToTextParamL(param->iBookmarkPassword, iEngine->RandomString(CCreatorEngine::EFirstName)); - } - } - else - { - SetContentToTextParamL(param->iBookmarkPassword, elemContent); - } - } - else if( elemName == KUrl ) - { - if( randomAttr || elemContent.Length() == 0) - { - TDesC* tmpUrl = iEngine->CreateHTTPUrlLC(); - if( tmpUrl ) - { - SetContentToTextParamL(param->iBookmarkAddress, *tmpUrl ); - } - CleanupStack::PopAndDestroy(); // tmpUrl - } - else - { - SetContentToTextParamL(param->iBookmarkAddress, elemContent); - } - } - } - iEngine->AppendToCommandArrayL(GetBrowserCommandL(), param); - CleanupStack::Pop(); // param - } - } - else - { - addAll = ETrue; - } - - if( addAll ) - { - iEngine->AppendToCommandArrayL(GetBrowserCommandL(), 0, entryAmount); - } - } - -TInt CCreatorBrowserElement::GetBrowserCommandL() const - { - if( iName->Des() == KBookmark ) - { - return ECmdCreateBrowserBookmarkEntries; - } - else if( iName->Des() == KBookmarkFolder ) - { - return ECmdCreateBrowserBookmarkFolderEntries; - } - else if( iName->Des() == KSavedPage ) - { - return ECmdCreateBrowserSavedPageEntries; - } - else if( iName->Des() == KSavedPageFolder ) - { - return ECmdCreateBrowserSavedPageFolderEntries; - } - - LOGSTRING("CCreatorFileElement::GetBrowserCommandL: Unknown browser entry"); - User::Leave(KErrGeneral); - return 0; // Not reached, but disables compiler warning... - } diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/src/creator_calendar.cpp --- a/creator/engine/src/creator_calendar.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1373 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#include "engine.h" -#include "enginewrapper.h" - -#include "creator_calendar.h" -#include "creator_traces.h" -#include "creator_scriptentry.h" -#include -#include -#include -#include -#include "creator_contactsetcache.h" -#include "creator_phonebook.h" - -static const TInt KCalendarFieldLength = 128; - - -CCreatorCalenderAttendee::CCreatorCalenderAttendee() - {} - -CCreatorCalenderAttendee::~CCreatorCalenderAttendee() - { - delete iCommonName; - delete iEmailAddress; - } - -CCreatorCalenderAttendee* CCreatorCalenderAttendee::NewL() - { - CCreatorCalenderAttendee* self = new (ELeave) CCreatorCalenderAttendee; - return self; - } - -void CCreatorCalenderAttendee::SetCommonNameL(const TDesC& aName) - { - delete iCommonName; - iCommonName = 0; - iCommonName = HBufC::NewL(aName.Length()); - iCommonName->Des().Copy(aName); - } - -void CCreatorCalenderAttendee::SetEmailAddressL(const TDesC& aEmail) - { - delete iEmailAddress; - iEmailAddress = 0; - iEmailAddress = HBufC::NewL(aEmail.Length()); - iEmailAddress->Des().Copy(aEmail); - } - -void CCreatorCalenderAttendee::SetRole(CCalAttendee::TCalRole aRole) - { - iRole = aRole; - } - -void CCreatorCalenderAttendee::SetStatus(CCalAttendee::TCalStatus aStatus) - { - iStatus = aStatus; - } - -const TDesC& CCreatorCalenderAttendee::CommonName() const - { - if( iCommonName == 0 ) - return iDummy; - return *iCommonName; - } - -const TDesC& CCreatorCalenderAttendee::EmailAddress() const - { - if( iEmailAddress == 0 ) - return iDummy; - - return *iEmailAddress; - } - -CCalAttendee::TCalRole CCreatorCalenderAttendee::Role() const - { - return iRole; - } - -CCalAttendee::TCalStatus CCreatorCalenderAttendee::Status() const - { - return iStatus; - } - -TBool CCalenderInterimParameters::IsAllowedEntryStatus(CCalEntry::TType aType, CCalEntry::TStatus aStatus) - { - if( aType == CCalEntry::ETodo ) - { - return aStatus == CCalEntry::ECancelled || - aStatus == CCalEntry::ETodoNeedsAction || - aStatus == CCalEntry::ETodoCompleted || - aStatus == CCalEntry::ETodoInProcess; - } - - return aStatus == CCalEntry::ETentative || - aStatus == CCalEntry::EConfirmed || - aStatus == CCalEntry::ECancelled; - } - -//---------------------------------------------------------------------------- - -CCalenderInterimParameters::CCalenderInterimParameters ( ) - { - LOGSTRING("Creator: CCalenderInterimParameters::CCalenderInterimParameters"); - - iAppointmentLocation = HBufC::New (KCalendarFieldLength ); - iAppointmentReason = HBufC::New (KCalendarFieldLength ); - iEventReason = HBufC::New (KCalendarFieldLength ); - iAnniversaryReason = HBufC::New (KCalendarFieldLength ); - iTodoTask = HBufC::New (KCalendarFieldLength ); - iReminderReason = HBufC::New (KCalendarFieldLength ); - iDescription = HBufC::New (KCalendarFieldLength ); - iSummary = HBufC::New (KCalendarFieldLength ); - iLocation = HBufC::New (KCalendarFieldLength ); - iOrganizerName = HBufC::New (KCalendarFieldLength ); - iOrganizerEmail = HBufC::New (KCalendarFieldLength ); - - // set defaults, start date today and end date = today + 1 month - iRandomModeStartTime.HomeTime ( ); - iRandomModeEndTime = iRandomModeStartTime; - iRandomModeEndTime += TTimeIntervalMonths (1 ); - iAlarmTime = Time::NullTTime(); - iUseRandomAlarmTime = EFalse; - iStatus = CCalEntry::ENullStatus; - } - -CCalenderInterimParameters::~CCalenderInterimParameters ( ) - { - LOGSTRING("Creator: CCalenderInterimParameters::~CCalenderInterimParameters"); - - delete iTodoTask; - delete iAnniversaryReason; - delete iEventReason; - delete iAppointmentReason; - delete iAppointmentLocation; - delete iReminderReason; - delete iDescription; - delete iSummary; - delete iLocation; - delete iOrganizerName; - delete iOrganizerEmail; - iAttendees.ResetAndDestroy(); - iAttendees.Close(); - iAttendeeLinkIds.Reset(); - iAttendeeLinkIds.Close(); - } - -void CCalenderInterimParameters::ParseL (CCommandParser* parser, - TParseParams aCase ) - { - LOGSTRING("Creator: CCalenderInterimParameters::ParseL"); - - HBufC* tempBuf= NULL; - - switch (aCase ) - { - - case MCreatorModuleBaseParameters::ECalendarTodo: - { - - parser->StrParserL (tempBuf, '|' ); - - CleanupStack::PushL (tempBuf ); - - this->iTodoDueTime = TTime (tempBuf->Des ( ) ); - - parser->StrParserL (this->iTodoTask, '|' ); - - parser->StrParserL (tempBuf, ';' ); - this->iTodoPriority = 2; - if (tempBuf->Compare (_L("LOW") ) == 0 ) - this->iTodoPriority = 3; - else - if (tempBuf->Compare (_L("HIGH") ) == 0 ) - this->iTodoPriority = 1; - - CleanupStack::PopAndDestroy (tempBuf ); - - } - break; - - case MCreatorModuleBaseParameters::ECalendarMemo: - { - - parser->StrParserL (tempBuf, '|' ); - - this->iStartTime = TTime (tempBuf->Des ( ) ); - - parser->StrParserL (tempBuf, '|' ); - this->iEndTime = TTime (tempBuf->Des ( ) ); - - parser->StrParserL (this->iDescription, ';' ); - - CleanupStack::PopAndDestroy (tempBuf ); - } - break; - - case MCreatorModuleBaseParameters::ECalendarMeeting: - { - - parser->StrParserL (tempBuf, '|' ); - - CleanupStack::PushL (tempBuf ); - - this->iStartTime = TTime (tempBuf->Des ( ) ); - - parser->StrParserL (tempBuf, '|' ); - this->iEndTime = TTime (tempBuf->Des ( ) ); - - parser->StrParserL (this->iLocation, '|' ); - parser->StrParserL (this->iDescription, ';' ); - - CleanupStack::PopAndDestroy (tempBuf ); - } - break; - - case MCreatorModuleBaseParameters::ECalendarAnniv: - { - - parser->StrParserL (tempBuf, '|' ); - - CleanupStack::PushL (tempBuf ); - - this->iStartTime = TTime (tempBuf->Des ( ) ); - - parser->StrParserL (this->iDescription, ';' ); - - CleanupStack::PopAndDestroy (tempBuf ); - - } - break; - default: - { - //implement - } - break; - } - } -//---------------------------------------------------------------------------- - -CCreatorInterimCalendar* CCreatorInterimCalendar::NewL (CCreatorEngine* aEngine ) - { - CCreatorInterimCalendar* self = CCreatorInterimCalendar::NewLC (aEngine ); - CleanupStack::Pop (self ); - return self; - } - -CCreatorInterimCalendar* CCreatorInterimCalendar::NewLC (CCreatorEngine* aEngine ) - { - CCreatorInterimCalendar* self = new (ELeave) CCreatorInterimCalendar; - CleanupStack::PushL (self ); - self->ConstructL (aEngine ); - return self; - } - -CCreatorInterimCalendar::CCreatorInterimCalendar ( ) - { - } - -void CCreatorInterimCalendar::ConstructL (CCreatorEngine* aEngine ) - { - LOGSTRING("Creator: CCreatorInterimCalendar::ConstructL"); - - iEngine = aEngine; - - // set defaults, start date today and end date = today + 1 month - iRandomModeStartTime.HomeTime ( ); - iRandomModeEndTime = iRandomModeStartTime; - iRandomModeEndTime += TTimeIntervalMonths (1 ); - - iCalSession = CCalSession::NewL ( ); - // Create and open a calendar file - const TDesC& fileName = iCalSession->DefaultFileNameL ( );//default filename is: "C:Calendar" - TRAPD(err, iCalSession->CreateCalFileL(fileName)) - ; - // ignore KErrAlreadyExists leave code - if (err != KErrAlreadyExists ) - { - User::LeaveIfError (err ); - } - // Open the calendar file - iCalSession->OpenL (fileName ); - iCalEntryView = CCalEntryView::NewL (*iCalSession, *this ); - iNumberRepeatingEntries = 0; - iNumberOfAttendees = 0; //iEngine->RandomNumber(2, 15); - iSetAlarm = EFalse; - iWaiter = CAsyncWaiter::NewL(); - } - -CCreatorInterimCalendar::~CCreatorInterimCalendar ( ) - { - LOGSTRING("Creator: CCreatorInterimCalendar::~CCreatorInterimCalendar"); - - if ( iEngine && iEntryIds.Count() ) - { - TRAP_IGNORE( iEngine->WriteEntryIdsToStoreL( iEntryIds, KUidDictionaryUidCalendar ) ); - } - - iEntryIds.Reset(); - iEntryIds.Close(); - - if (iParameters ) - { - delete iParameters; - } - - if (iCalEntryView ) - { - delete iCalEntryView; - } - - if (iCalSession ) - { - delete iCalSession; - } - delete iSoundFileArray; - delete iWaiter; - delete iTmpCN; - delete iTmpEmail; - } - -//---------------------------------------------------------------------------- - -void CCreatorInterimCalendar::QueryDialogClosedL(TBool aPositiveAction, TInt aUserData) - { - LOGSTRING("Creator: CCreatorInterimCalendar::QueryDialogClosedL"); - - if( aPositiveAction == EFalse && aUserData != ECreatorCalendarAddDefaultAlarm ) - { - iEngine->ShutDownEnginesL(); - return; - } - - const TDesC* showText = &KSavingText; - TBool finished(EFalse); - TBool retval(ETrue); - switch(aUserData) - { - case ECreatorCalendarDelete: - iEntriesToBeCreated = 1; - showText = &KDeletingText; - finished = ETrue; - break; - case ECreatorCalendarStart: - if( iCommand == ECmdCreateCalendarEntryEvents || iCommand == ECmdCreateCalendarEntryAppointments ) - { - _LIT(KRepeatingNum, "How many repeating (weekly) entries"); - retval = iEngine->GetEngineWrapper()->EntriesQueryDialog(&iNumberRepeatingEntries, KRepeatingNum, ETrue, this, ECreatorCalendarGetWeeklyEntries); - } - else - { - _LIT(KStartPeriodDate, "Start date of creation period");// \n dd/mm/yyyy - retval = iEngine->GetEngineWrapper()->TimeQueryDialog(&iRandomModeStartTime, KStartPeriodDate, this, ECreatorCalendarGetStartDate); // ask start date - } - break; - case ECreatorCalendarGetWeeklyEntries: - _LIT(KAttendeesNum, "How many attendees to create"); - retval = iEngine->GetEngineWrapper()->EntriesQueryDialog(&iNumberOfAttendees, KAttendeesNum, ETrue, this, ECreatorCalendarGetAttendies); - break; - case ECreatorCalendarGetAttendies: - { - // ask start date - _LIT(KStartPeriodDate, "Start date of creation period"); - retval = iEngine->GetEngineWrapper()->TimeQueryDialog(&iRandomModeStartTime, KStartPeriodDate, this, ECreatorCalendarGetStartDate ); - } - break; - case ECreatorCalendarGetStartDate: - { - _LIT(KEndPeriodDate, "End date of creation period\n dd/mm/yyyy"); - iEngine->GetEngineWrapper()->TimeQueryDialog (&iRandomModeEndTime, KEndPeriodDate, this, ECreatorCalendarGetEndDate ); // ask end date - } - break; - case ECreatorCalendarGetEndDate: - if (iRandomModeStartTime > iRandomModeEndTime ) // check end date is ok - { - iEngine->GetEngineWrapper()->ShowNote(_L("End date must be after start date") ); - retval = EFalse; - } - else - { - retval = iEngine->GetEngineWrapper()->YesNoQueryDialog(_L("Add default alarm?"), this, ECreatorCalendarAddDefaultAlarm); - } - break; - case ECreatorCalendarAddDefaultAlarm: - iSetAlarm = aPositiveAction; - finished = ETrue; - break; - default: - //some error - retval = EFalse; - break; - } - if( retval == EFalse ) - { - iEngine->ShutDownEnginesL(); - } - else if( finished ) - { - // add this command to command array - iEngine->AppendToCommandArrayL(iCommand, NULL, iEntriesToBeCreated); - // started exucuting commands - iEngine->ExecuteFirstCommandL( *showText ); - } - } - -//---------------------------------------------------------------------------- - -TBool CCreatorInterimCalendar::AskDataFromUserL( TInt aCommand ) - { - LOGSTRING("Creator: CCreatorInterimCalendar::AskDataFromUserL"); - - CCreatorModuleBase::AskDataFromUserL( aCommand );//ignore retval - - if( aCommand == ECmdDeleteCalendarEntries ) - { - return iEngine->GetEngineWrapper()->YesNoQueryDialog(_L("Delete all calendar entries?"), this, ECreatorCalendarDelete ); - } - if( aCommand == ECmdDeleteCreatorCalendarEntries ) - { - return iEngine->GetEngineWrapper()->YesNoQueryDialog(_L("Delete all calendar entries created with Creator?"), this, ECreatorCalendarDelete ); - } - - // display queries - return iEngine->GetEngineWrapper()->EntriesQueryDialog(&iEntriesToBeCreated, _L("How many entries to create?"), EFalse, this, ECreatorCalendarStart ); // ask number of entries to create - } - -//---------------------------------------------------------------------------- - -TInt CCreatorInterimCalendar::CreateAppointmentEntryL ( - CCreatorModuleBaseParameters *aParameters ) - { - LOGSTRING("Creator: CCreatorInterimCalendar::CreateAppointmentEntryL"); - - delete iParameters; - iParameters = 0; - - CCalenderInterimParameters* parameters = (CCalenderInterimParameters*)aParameters; - - if( !parameters ) - { - iParameters = new(ELeave) CCalenderInterimParameters; - parameters = iParameters; - parameters->iRandomModeStartTime = iRandomModeStartTime; - parameters->iRandomModeEndTime = iRandomModeEndTime; - - // difference between start and end times - TTimeIntervalMinutes differenceInMinutes; - parameters->iRandomModeEndTime.MinutesFrom ( - parameters->iRandomModeStartTime, differenceInMinutes ); - - // start time (= something between the period start and end date) - parameters->iStartTime = parameters->iRandomModeStartTime; - parameters->iStartTime - += TTimeIntervalMinutes (iEngine->RandomNumber (differenceInMinutes.Int ( ) ) ); - // set end time (= start time + some random time) - parameters->iEndTime = parameters->iStartTime; - parameters->iEndTime - += TTimeIntervalMinutes (iEngine->RandomNumber (5, 500 ) ); - - - // strings - parameters->iLocation->Des ( ) - = iEngine->RandomString (CCreatorEngine::EMeetingPlace ); - parameters->iDescription->Des ( ) - = iEngine->RandomString (CCreatorEngine::EMeetingReason ); - - parameters->iSummary->Des() - = parameters->iDescription->Des(); - - parameters->iNumberRepeatingEntries = iNumberRepeatingEntries; - parameters->iNumberOfAttendees = iNumberOfAttendees; - } - - TInt err = KErrNone; - HBufC8* guid = HBufC8::NewLC (255 ); - TPtr8 uidP=guid->Des ( ); - GenerateRandomId (uidP ); - CCalEntry* entry = CCalEntry::NewL (CCalEntry::EAppt, guid, - CCalEntry::EMethodAdd, 0 ); - CleanupStack::PushL (entry ); - - //Using same text as description and summary - entry->SetDescriptionL (parameters->iDescription->Des ( ) ); - entry->SetSummaryL (parameters->iSummary->Des ( ) ); - entry->SetLocationL (parameters->iLocation->Des ( ) ); - - TCalTime startTime; - TCalTime endTime; - // Set the start and end times using time values local to the current system time zone - TInt month = (TInt) parameters->iStartTime.DateTime().Month(); - TInt date = parameters->iStartTime.DateTime().Day(); - startTime.SetTimeLocalL (parameters->iStartTime ); - endTime.SetTimeLocalL (parameters->iEndTime ); - entry->SetStartAndEndTimeL (startTime, endTime ); - - if( parameters->IsAllowedEntryStatus(CCalEntry::EAppt, parameters->iStatus)) - { - LOGSTRING2("Creator: CCreatorInterimCalendar::CreateAppointmentEntryL setting entry status: %d", parameters->iStatus); - entry->SetStatusL(parameters->iStatus); - } - - // Repeating times: - AddRepeatingRuleL(startTime, *entry, parameters); - SetOrganizerL(*entry, parameters); - - // Alarm: - if( iSetAlarm || parameters->iUseRandomAlarmTime ) - { - SetRandomAlarmL(*entry); - } - else - { - SetAlarmL(*entry, parameters); - } - - // Add attendees: - AddAttendeesL(*entry, parameters); - - RPointerArray array; - CleanupClosePushL (array ); - array.AppendL (entry ); - - TInt success(0); - //If StoreL() leaves, 'success' contains the number of entries that were stored before it failed - iCalEntryView->StoreL (array, success ); - - // id has been generated, store it for being able to delete - // entries created only with Creator - iEntryIds.AppendL( entry->LocalUidL() ); - - //One item should be added at time - if (success != 1 ) - { - err = 1; - } - - CleanupStack::PopAndDestroy (&array ); - CleanupStack::PopAndDestroy (entry ); - CleanupStack::Pop (guid );//guid has been destroyed by entry, which has ownership to guid - - return err; - } - -void CCreatorInterimCalendar::SetOrganizerL(CCalEntry& aCalEntry, CCalenderInterimParameters* parameters ) - { - HBufC* orgName = 0; - HBufC* orgEmail = 0; - _LIT(KSpace, " "); - - // - // Common name - // - if( parameters == 0 || - parameters->iOrganizerName == 0 || - parameters->iOrganizerName->Length() == 0 ) - { - // Random: - TPtrC firstname = iEngine->RandomString(CCreatorEngine::EFirstName); - TPtrC lastname = iEngine->RandomString(CCreatorEngine::ESurname); - orgName = HBufC::NewL(firstname.Length() + lastname.Length() + 1 ); - CleanupStack::PushL(orgName); - orgName->Des().Copy(firstname); - orgName->Des().Append(KSpace); - orgName->Des().Append(lastname); - } - else - { - orgName = HBufC::NewL(parameters->iOrganizerName->Length()); - CleanupStack::PushL(orgName); - orgName->Des().Copy(parameters->iOrganizerName->Des()); - } - - // - // Email - // - if( parameters == 0 || - parameters->iOrganizerEmail == 0 || - parameters->iOrganizerEmail->Length() == 0 ) - { - // Random: - TDesC* tmp = iEngine->CreateEmailAddressLC(); - orgEmail = HBufC::NewL(tmp->Length()); - orgEmail->Des().Copy(*tmp); - CleanupStack::PopAndDestroy(); // tmp - CleanupStack::PushL(orgEmail); - } - else - { - orgEmail = HBufC::NewL(parameters->iOrganizerEmail->Length()); - CleanupStack::PushL(orgEmail); - orgEmail->Des().Copy(parameters->iOrganizerEmail->Des()); - } - - SetOrganizerL(aCalEntry, orgName->Des(), orgEmail->Des(), orgEmail->Des()); - CleanupStack::PopAndDestroy(); // orgName - CleanupStack::PopAndDestroy(); // orgEmail - } - -void CCreatorInterimCalendar::AddRepeatingRuleL(const TCalTime& aStartTime, CCalEntry& aCalEntry, CCalenderInterimParameters* parameters ) - { - RArray days; - CleanupClosePushL(days); - - // Recurrence rule. Weekly event. - if( parameters->iNumberRepeatingEntries > 0 ) - { - TCalRRule calRepeat(TCalRRule::EWeekly); - calRepeat.SetDtStart(aStartTime); - calRepeat.SetCount(parameters->iNumberRepeatingEntries); - calRepeat.SetInterval(1); - //days.AppendL((TDay) iEngine->RandomNumber((TInt)EMonday, (TInt) ESunday)); - TDay tempDay(aStartTime.TimeLocalL().DayNoInWeek()); - days.AppendL(tempDay); - calRepeat.SetByDay(days); - aCalEntry.SetRRuleL(calRepeat); - } - else if(parameters->iRecurrentFrequency > TCalRRule::EInvalid) - { - TCalTime calTime; - // Recurrent frequency - TCalRRule calRepeat(parameters->iRecurrentFrequency); - // Recurrent start - calRepeat.SetDtStart(aStartTime); - if( parameters->iRecurrentFrequency == TCalRRule::EWeekly ) - { - TDay tempDay(aStartTime.TimeLocalL().DayNoInWeek()); - days.AppendL(tempDay); - calRepeat.SetByDay(days); - } - else if( parameters->iRecurrentFrequency == TCalRRule::EMonthly ) - { - RArray< TInt > daysInMonth; - CleanupClosePushL(daysInMonth); - daysInMonth.AppendL(aStartTime.TimeLocalL().DayNoInMonth()); - calRepeat.SetByMonthDay(daysInMonth); - CleanupStack::PopAndDestroy(&daysInMonth); - } - else if( parameters->iRecurrentFrequency == TCalRRule::EYearly) - { - RArray< TMonth > monthsInYear; - CleanupClosePushL(monthsInYear); - monthsInYear.AppendL(aStartTime.TimeLocalL().DateTime().Month()); - calRepeat.SetByMonth(monthsInYear); - CleanupStack::PopAndDestroy(&monthsInYear); - } - - // Recurrent interval - if( parameters->iRecurrentInterval > 0 ) - calRepeat.SetInterval(parameters->iRecurrentInterval); - - // Recurrent end. End can be given as a number of repeating entries or as an end date. - // End date must be later than the start date, otherwise CCalEntry::SetRRuleL() panics. - if( parameters->iRepeatingCount > 0 ) - { - calRepeat.SetCount(parameters->iRepeatingCount); - aCalEntry.SetRRuleL(calRepeat); - } - else - { - TCalTime endTime; - endTime.SetTimeLocalL(parameters->iRecurrentEndTime); - if( endTime.TimeLocalL() > aStartTime.TimeLocalL()) - { - calRepeat.SetUntil(endTime); - aCalEntry.SetRRuleL(calRepeat); - } - } - } - CleanupStack::PopAndDestroy(&days); - } - -void CCreatorInterimCalendar::SetAlarmL(CCalEntry& aCalEntry, CCalenderInterimParameters* params) - { - if( params->iAlarmTime != Time::NullTTime() ) - { - CCalAlarm* alarm = CCalAlarm::NewL(); - CleanupStack::PushL(alarm); - //if( params->iAlarmTime <= params->iStartTime ) - // { - TTimeIntervalMinutes diff; - TInt err = params->iStartTime.MinutesFrom(params->iAlarmTime, diff); - if( err == KErrNone) - { - alarm->SetTimeOffset(diff); - TRAP(err, aCalEntry.SetAlarmL(alarm)); - if( err != KErrNone && err != KErrNotSupported ) - { - User::Leave(err); - } - } - // } - CleanupStack::PopAndDestroy(alarm); - } - } - -void CCreatorInterimCalendar::SetRandomAlarmL(CCalEntry& aCalEntry) - { - CCalAlarm* alarm = CCalAlarm::NewL(); - CleanupStack::PushL(alarm); - alarm->SetTimeOffset(TTimeIntervalMinutes(iEngine->RandomNumber(0, 60))); - - TRAPD(err, aCalEntry.SetAlarmL(alarm)); - if( err != KErrNone && err != KErrNotSupported ) - { - User::Leave(err); - } - CleanupStack::PopAndDestroy(alarm); - } - -void CCreatorInterimCalendar::SetPhoneOwnerL(CCalEntry& aCalEntry, const TDesC& aCN, const TDesC& aEmail, const TDesC& aSentBy ) - { - CCalUser* phOwner = CCalUser::NewL(aEmail, aSentBy); - CleanupStack::PushL(phOwner); - TRAPD(err, aCalEntry.SetPhoneOwnerL(phOwner)); - CleanupStack::Pop(phOwner); - if( err == KErrNone ) - { - phOwner->SetCommonNameL(aCN); - } - else - { - delete phOwner; - } - } - -void CCreatorInterimCalendar::SetOrganizerL(CCalEntry& aCalEntry, const TDesC& aCN, const TDesC& aEmail, const TDesC& aSentBy) - { - CCalUser* organizer = CCalUser::NewL(aEmail, aSentBy); - CleanupStack::PushL(organizer); - TRAPD(err, aCalEntry.SetOrganizerL(organizer)); - CleanupStack::Pop(organizer); - if( err == KErrNone ) - { - organizer->SetCommonNameL(aCN); - } - else - { - delete organizer; - } - } - -void CCreatorInterimCalendar::AddAttendeesL(CCalEntry& aCalEntry, CCalenderInterimParameters* parameters ) - { - if( !parameters ) - return; - - // Random attendees: - TInt numOfAttendees = parameters->iNumberOfAttendees; - for( TInt i = 0; i < numOfAttendees; ++i ) - { - TPtrC firstname = iEngine->RandomString(CCreatorEngine::EFirstName); - TPtrC lastname = iEngine->RandomString(CCreatorEngine::ESurname); - TPtrC company = iEngine->RandomString(CCreatorEngine::ECompany); - _LIT(KCountry, "com"); - TDesC* emailAddr = iEngine->CreateEmailAddressLC(firstname, lastname, company, KCountry); - CCalAttendee* attendee = CCalAttendee::NewL(*emailAddr); - CleanupStack::PushL(attendee); - aCalEntry.AddAttendeeL(attendee); - CleanupStack::Pop(attendee); - attendee->SetCommonNameL(firstname); - - // Set phone owner: - if( i == 1 ) - { - SetPhoneOwnerL(aCalEntry, firstname, *emailAddr, *emailAddr); - attendee->SetRoleL(CCalAttendee::EReqParticipant); - } - // Set organizer: - else if ( i == 0 ) - { - // Organizer is the chairman of the meeting: - SetOrganizerL(aCalEntry, firstname, *emailAddr, *emailAddr); - attendee->SetRoleL(CCalAttendee::EChair); - } - else if( i % 3 == 0 ) - { - // every third attendee is optional: - attendee->SetRoleL(CCalAttendee::EOptParticipant); - } - else - { - // Others are required attendees: - attendee->SetRoleL(CCalAttendee::EReqParticipant); - } - - TInt attStatus = iEngine->RandomNumber(0,5); - attendee->SetStatusL((CCalAttendee::TCalStatus) attStatus); - - CleanupStack::PopAndDestroy(emailAddr); - } - - // Explicit attendees: - for( TInt i = 0; i < parameters->iAttendees.Count(); ++i ) - { - CCreatorCalenderAttendee* attendeeInfo = parameters->iAttendees[i]; - if( attendeeInfo && attendeeInfo->EmailAddress().Length() > 0) - { - CCalAttendee* attendee = CCalAttendee::NewL(attendeeInfo->EmailAddress()); - CleanupStack::PushL(attendee); - if( attendeeInfo->CommonName().Length() > 0 ) - attendee->SetCommonNameL(attendeeInfo->CommonName()); - attendee->SetRoleL(attendeeInfo->Role()); - attendee->SetStatusL(attendeeInfo->Status()); - attendee->SetResponseRequested(ETrue); - aCalEntry.AddAttendeeL(attendee); - CleanupStack::Pop(); // attendee - } - } - // linked attendees: - for( TInt i = 0; i < parameters->iAttendeeLinkIds.Count(); ++i ) - { - CCreatorPhonebook* phonebook = dynamic_cast(iEngine->GetPhonebook()); - User::LeaveIfNull( phonebook ); - CCreatorPhonebookWrapper* phonebookWrapper = phonebook->GetPhonebookWrapper(); - - TLinkIdParam attendeeLinkId = parameters->iAttendeeLinkIds[i]; - const CCreatorContactSet& set = ContactLinkCache::Instance()->ContactSet(attendeeLinkId.iLinkId); - const RArray links = set.ContactLinks(); - TInt numberOfExplicitLinks = links.Count(); // Number of defined contacts in contact-set - for( TInt j = 0; j < numberOfExplicitLinks; ++j ) - { - TBuf<128> email; - TBuf<128> name; - TBuf<128> phoneNumber; - phonebookWrapper->GetContactDetailsL( links[j], name, phoneNumber, email ); - CCalAttendee* attendee = CCalAttendee::NewL( email ); - CleanupStack::PushL(attendee); - if( name.Length() > 0 ) - attendee->SetCommonNameL( name ); - attendee->SetResponseRequested(ETrue); - aCalEntry.AddAttendeeL(attendee); - CleanupStack::Pop(); // attendee - } - } - } -//---------------------------------------------------------------------------- - -TInt CCreatorInterimCalendar::CreateEventEntryL ( - CCreatorModuleBaseParameters *aParameters ) - { - LOGSTRING("Creator: CCreatorInterimCalendar::CreateEventEntryL"); - - delete iParameters; - iParameters = 0; - - CCalenderInterimParameters* parameters = (CCalenderInterimParameters*)aParameters; - - // random data needed if no predefined data available - if (!parameters ) - { - iParameters = new(ELeave) CCalenderInterimParameters; - - iParameters->iRandomModeStartTime = iRandomModeStartTime; - iParameters->iRandomModeEndTime = iRandomModeEndTime; - iParameters->iNumberRepeatingEntries = iNumberRepeatingEntries; - iParameters->iNumberOfAttendees = iNumberOfAttendees; - - // difference between start and end times - TTimeIntervalMinutes differenceInMinutes; - iParameters->iRandomModeEndTime.MinutesFrom ( - iParameters->iRandomModeStartTime, differenceInMinutes ); - - // start time (= something between the period start and end date) - iParameters->iStartTime = iParameters->iRandomModeStartTime; - iParameters->iStartTime - += TTimeIntervalMinutes (iEngine->RandomNumber (differenceInMinutes.Int ( ) ) ); - - // set end time (= start time + some random time) - iParameters->iEndTime = iParameters->iStartTime; - iParameters->iEndTime - += TTimeIntervalMinutes (iEngine->RandomNumber (5, 500 ) ); - - // strings - iParameters->iDescription->Des() - = iEngine->RandomString (CCreatorEngine::EMemoText ); - - iParameters->iSummary->Des() = iParameters->iDescription->Des(); - - // Random event status: - iParameters->iStatus = - (CCalEntry::TStatus) iEngine->RandomNumber(0, (TInt) CCalEntry::ECancelled); - - parameters = iParameters; - } - - TInt err = KErrNone; - HBufC8* guid = HBufC8::NewLC (255 ); - TPtr8 uidP=guid->Des ( ); - GenerateRandomId (uidP ); - CCalEntry* entry = CCalEntry::NewL (CCalEntry::EEvent, guid, - CCalEntry::EMethodAdd, 0 ); - CleanupStack::PushL (entry ); - // iEntryUids->AppendL( *guid->Alloc() ); - - entry->SetDescriptionL (parameters->iDescription->Des ( ) ); - entry->SetSummaryL (parameters->iSummary->Des ( ) ); - - TCalTime startTime; - TCalTime endTime; - // Set the start and end times using time values local to the current system time zone - startTime.SetTimeLocalL (parameters->iStartTime ); - endTime.SetTimeLocalL (parameters->iEndTime ); - entry->SetStartAndEndTimeL (startTime, endTime ); - - // Repeating times: - AddRepeatingRuleL(startTime, *entry, parameters); - - if( iSetAlarm || parameters->iUseRandomAlarmTime ) - { - SetRandomAlarmL(*entry); - } - else - { - SetAlarmL(*entry, parameters); - } - - // Add attendees: - AddAttendeesL(*entry, parameters); - - if( parameters->IsAllowedEntryStatus(CCalEntry::EEvent, parameters->iStatus)) - { - LOGSTRING2("Creator: CCreatorInterimCalendar::CreateEventEntryL setting entry status: %d", parameters->iStatus); - entry->SetStatusL(parameters->iStatus); - } - - RPointerArray array; - CleanupClosePushL (array ); - array.AppendL (entry ); - - TInt success(0); - //If StoreL() leaves, 'success' contains the number of entries that were stored before it failed - iCalEntryView->StoreL (array, success ); - - // id has been generated, store it for being able to delete - // entries created only with Creator - iEntryIds.AppendL( entry->LocalUidL() ); - - //One item should be added at time - if (success != 1 ) - { - err = 1; - } - - CleanupStack::PopAndDestroy (&array ); - CleanupStack::PopAndDestroy (entry ); - CleanupStack::Pop (guid );//guid has been destroyed by entry, which has ownership to guid - return err; - - } - -//---------------------------------------------------------------------------- - - -TInt CCreatorInterimCalendar::CreateReminderEntryL ( - CCreatorModuleBaseParameters *aParameters ) - { - LOGSTRING("Creator: CCreatorInterimCalendar::CreateReminderEntryL"); - - delete iParameters; - iParameters = NULL; - - CCalenderInterimParameters* parameters = (CCalenderInterimParameters*)aParameters; - - // random data needed if no predefined data available - if (!parameters ) - { - iParameters = new(ELeave) CCalenderInterimParameters; - - iParameters->iRandomModeStartTime = iRandomModeStartTime; - iParameters->iRandomModeEndTime = iRandomModeEndTime; - - // difference between start and end times - TTimeIntervalDays - differenceInDays = iParameters->iRandomModeEndTime.DaysFrom (iParameters->iRandomModeStartTime ); - - // due time (= something between the period start and end date) - iParameters->iStartTime = iParameters->iRandomModeStartTime; - iParameters->iStartTime - += TTimeIntervalDays (iEngine->RandomNumber (differenceInDays.Int ( ) ) ); - - // strings - iParameters->iDescription->Des() - = iEngine->RandomString (CCreatorEngine::EReminderText ); - - iParameters->iSummary->Des() = iParameters->iDescription->Des(); - - parameters = iParameters; - } - - TInt err = KErrNone; - - HBufC8* guid = HBufC8::NewLC (255 ); - TPtr8 uidP=guid->Des ( ); - GenerateRandomId (uidP ); - - CCalEntry* entry = CCalEntry::NewL (CCalEntry::EReminder, guid, - CCalEntry::EMethodAdd, 0 ); - CleanupStack::PushL (entry ); - - //Using same text as description and summary - entry->SetDescriptionL (parameters->iDescription->Des ( ) ); - entry->SetSummaryL (parameters->iSummary->Des ( ) ); - - TCalTime startTime; - TCalTime endTime; - // Set the start and end times using time values local to the current system time zone - startTime.SetTimeLocalL (parameters->iStartTime ); - TTime nullTime = Time::NullTTime ( ); - endTime.SetTimeLocalL (nullTime ); - entry->SetStartAndEndTimeL (startTime, endTime ); - - if( parameters->IsAllowedEntryStatus(CCalEntry::EReminder, parameters->iStatus)) - { - LOGSTRING2("Creator: CCreatorInterimCalendar::CreateReminderEntryL setting entry status: %d", parameters->iStatus); - entry->SetStatusL(parameters->iStatus); - } - - if( iSetAlarm || parameters->iUseRandomAlarmTime ) - { - SetRandomAlarmL(*entry); - } - else - { - SetAlarmL(*entry, parameters); - } - - RPointerArray array; - CleanupClosePushL (array ); - array.AppendL (entry ); - - TInt success(0); - //If StoreL() leaves, 'success' contains the number of entries that were stored before it failed - iCalEntryView->StoreL (array, success ); - - // id has been generated, store it for being able to delete - // entries created only with Creator - iEntryIds.AppendL( entry->LocalUidL() ); - - //One item should be added at time - if (success != 1 ) - { - err = 1; - } - - CleanupStack::PopAndDestroy (&array ); - CleanupStack::PopAndDestroy (entry ); - CleanupStack::Pop (guid );//guid has been destroyed by entry, which has ownership to guid - - return err; - } - -//---------------------------------------------------------------------------- - -TInt CCreatorInterimCalendar::CreateAnniversaryEntryL ( - CCreatorModuleBaseParameters *aParameters ) - { - LOGSTRING("Creator: CCreatorInterimCalendar::CreateAnniversaryEntryL"); - - delete iParameters; - iParameters = NULL; - - CCalenderInterimParameters* parameters = (CCalenderInterimParameters*)aParameters; - - // random data needed if no predefined data available - if (!parameters ) - { - iParameters = new(ELeave) CCalenderInterimParameters; - - iParameters->iRandomModeStartTime = iRandomModeStartTime; - iParameters->iRandomModeEndTime = iRandomModeEndTime; - - // difference between start and end times - TTimeIntervalDays differenceInDays = iParameters->iRandomModeEndTime.DaysFrom(iParameters->iRandomModeStartTime); - - // start time (= something between the period start and end date) - iParameters->iStartTime = iParameters->iRandomModeStartTime; - iParameters->iStartTime += TTimeIntervalDays( iEngine->RandomNumber(differenceInDays.Int()) ); - - // strings - iParameters->iDescription->Des().Copy (iEngine->RandomString (CCreatorEngine::EFirstName ) ); - iParameters->iDescription->Des().Append ( _L("'s ") ); - iParameters->iDescription->Des().Append (iEngine->RandomString (CCreatorEngine::EAnniversaryReason ) ); - iParameters->iSummary->Des() = iParameters->iDescription->Des(); - parameters = iParameters; - } - - TInt err = KErrNone; - - HBufC8* guid = HBufC8::NewLC (255 ); - TPtr8 uidP=guid->Des ( ); - GenerateRandomId (uidP ); - - CCalEntry* entry = CCalEntry::NewL (CCalEntry::EAnniv, guid, - CCalEntry::EMethodNone, 0 ); - CleanupStack::PushL (entry ); - - //Using same text as description and summary - entry->SetDescriptionL (parameters->iDescription->Des ( ) ); - entry->SetSummaryL (parameters->iSummary->Des ( ) ); - - TCalTime startTime; - TCalTime endTime; - TTime nullTime = Time::NullTTime ( ); - endTime.SetTimeLocalL (nullTime ); - - // Set the start time using time value local to the current system time zone - startTime.SetTimeLocalL (parameters->iStartTime ); - - entry->SetStartAndEndTimeL (startTime, endTime ); - - if( iSetAlarm || parameters->iUseRandomAlarmTime ) - { - SetRandomAlarmL(*entry); - } - else - { - SetAlarmL(*entry, parameters); - } - - //set repeating rule - TCalRRule yearlyRptRule(TCalRRule::EYearly); - yearlyRptRule.SetDtStart (startTime ); - //Set repeating until forever, not setting it to stop - //yearlyRptRule.SetUntil(endTime); - entry->SetRRuleL (yearlyRptRule ); - - RPointerArray array; - CleanupClosePushL (array ); - array.AppendL (entry ); - - TInt success(0); - //If StoreL() leaves, 'success' contains the number of entries that were stored before it failed - iCalEntryView->StoreL (array, success ); - - // id has been generated, store it for being able to delete - // entries created only with Creator - iEntryIds.AppendL( entry->LocalUidL() ); - - //One item should be added at time - if (success != 1 ) - { - err = 1; - } - - CleanupStack::PopAndDestroy (&array ); - CleanupStack::PopAndDestroy (entry ); - CleanupStack::Pop (guid );//guid has been destroyed by entry, which has ownership to guid - - return err; - } - -//---------------------------------------------------------------------------- - -TInt CCreatorInterimCalendar::CreateTodoEntryL ( - CCreatorModuleBaseParameters *aParameters ) - { - LOGSTRING("Creator: CCreatorInterimCalendar::CreateTodoEntryL"); - - delete iParameters; - iParameters = NULL; - - CCalenderInterimParameters* parameters = (CCalenderInterimParameters*)aParameters; - - // random data needed if no predefined data available - if (!parameters ) - { - iParameters = new(ELeave) CCalenderInterimParameters; - - iParameters->iRandomModeStartTime = iRandomModeStartTime; - iParameters->iRandomModeEndTime = iRandomModeEndTime; - - // difference between start and end times - TTimeIntervalDays - differenceInDays = iParameters->iRandomModeEndTime.DaysFrom (iParameters->iRandomModeStartTime ); - - // due time (= something between the period start and end date) - iParameters->iTodoDueTime = iParameters->iRandomModeStartTime; - iParameters->iTodoDueTime - += TTimeIntervalDays (iEngine->RandomNumber (differenceInDays.Int ( ) ) ); - - // strings - iParameters->iDescription->Des ( ) - = iEngine->RandomString (CCreatorEngine::EToDoText ); - - iParameters->iSummary->Des() = iParameters->iDescription->Des(); - - //priority - iParameters->iTodoPriority = iEngine->RandomNumber (1, 3 ); - iParameters->iStatus = (CCalEntry::TStatus) iEngine->RandomNumber((TInt) CCalEntry::ETodoNeedsAction, (TInt) CCalEntry::ETodoInProcess); - parameters = iParameters; - - } - - TInt err = KErrNone; - - HBufC8* guid = HBufC8::NewLC (255 ); - TPtr8 uidP=guid->Des ( ); - GenerateRandomId (uidP ); - - CCalEntry* entry = CCalEntry::NewL (CCalEntry::ETodo, guid, - CCalEntry::EMethodAdd, 0 ); - CleanupStack::PushL (entry ); - - //Using same text as description and summary - entry->SetDescriptionL (parameters->iDescription->Des ( ) ); - entry->SetSummaryL (parameters->iSummary->Des ( ) ); - - entry->SetPriorityL (parameters->iTodoPriority ); - - if( parameters->IsAllowedEntryStatus(CCalEntry::ETodo, parameters->iStatus)) - { - LOGSTRING2("Creator: CCreatorInterimCalendar::CreateTodoEntryL setting entry status: %d", parameters->iStatus); - entry->SetStatusL(parameters->iStatus); - } - - TCalTime startTime; - TCalTime endTime; - // Set the start and end times using time values local to the current system time zone - startTime.SetTimeLocalL (parameters->iTodoDueTime ); - endTime.SetTimeLocalL (parameters->iTodoDueTime ); - entry->SetStartAndEndTimeL (startTime, endTime ); - - if( iSetAlarm || parameters->iUseRandomAlarmTime ) - { - SetRandomAlarmL(*entry); - } - else - { - SetAlarmL(*entry, parameters); - } - - RPointerArray array; - CleanupClosePushL (array ); - array.AppendL (entry ); - - TInt success(0); - //If StoreL() leaves, 'success' contains the number of entries that were stored before it failed - iCalEntryView->StoreL (array, success ); - - // id has been generated, store it for being able to delete - // entries created only with Creator - iEntryIds.AppendL( entry->LocalUidL() ); - - //One item should be added at time - if (success != 1 ) - { - err = 1; - } - - CleanupStack::PopAndDestroy (&array ); - CleanupStack::PopAndDestroy (entry ); - CleanupStack::Pop (guid );//guid has been destroyed by entry, which has ownership to guid - - return err; - } - -//---------------------------------------------------------------------------- - -void CCreatorInterimCalendar::Progress (TInt /*aPercentageCompleted*/) - { - //Not really needed but observer need to be implement - } - -void CCreatorInterimCalendar::Completed (TInt aError ) - { - //Not really needed but observer need to be implement - LOGSTRING2("Creator: CCreatorInterimCalendar::Completed err=%d", aError); - } - -TBool CCreatorInterimCalendar::NotifyProgress ( ) - { - //Not really needed but observer need to be implement - return NULL; - } - -//---------------------------------------------------------------------------- - - -void CCreatorInterimCalendar::GenerateRandomId (TDes8& aText ) - { - LOGSTRING("Creator: CCreatorInterimCalendar::GenerateRandomId"); - - aText.Zero ( ); - - TTime now; - now.UniversalTime ( ); - TInt64 time = now.Int64 ( ); - - // The number of characters in the guid should be - // more than 8 (to ensure the guids are not too small) - // less than 255 (this is the maximum length of a guid) - // less than MaxLength of the descriptor passed in - TInt numChar(0); - do - { - numChar = Math::Rand (time ) % (aText.MaxLength ( ) - 1); - } - while (numChar > 255|| numChar < 8 ); - - for (TInt i(0); i < numChar ; ++i ) - { - TInt character = Math::Rand (time )%6; - character = Math::Rand (time ) % 26+ ((character == 2) ? 'A' : 'a'); - aText.Append (character ); - } - - } - -//---------------------------------------------------------------------------- -void CCreatorInterimCalendar::DeleteAllL() - { - LOGSTRING("Creator: CCreatorInterimCalendar::DeleteAllL"); - TCalTime zeroTime; - zeroTime.SetTimeUtcL( TCalTime::MinTime() ); - RArray allIds; - CleanupClosePushL( allIds ); - iCalEntryView->GetIdsModifiedSinceDateL( zeroTime, allIds ); - if ( allIds.Count() ) - { - TInt successCount( KErrNotFound ); - iCalEntryView->DeleteL( allIds, successCount ); - if ( successCount != allIds.Count() ) - { - User::Leave( KErrGeneral ); - } - } - CleanupStack::PopAndDestroy( &allIds ); - - // reset must be done here, because iEntryIds is stored in destructor - iEntryIds.Reset(); - - // all entries deleted, remove the Calendar related registry - iEngine->RemoveStoreL( KUidDictionaryUidCalendar ); - } - -//---------------------------------------------------------------------------- -void CCreatorInterimCalendar::DeleteAllCreatedByCreatorL() - { - LOGSTRING("Creator: CCreatorInterimCalendar::DeleteAllCreatedByCreatorL"); - iEntryIds.Reset(); - - // fetch ids of entries created by Creator - iEngine->ReadEntryIdsFromStoreL( iEntryIds, KUidDictionaryUidCalendar ); - - // delete entries - TInt successCount(0); // ignore - TRAP_IGNORE( iCalEntryView->DeleteL( iEntryIds, successCount ) ); - - // reset must be done here, because iEntryIds is stored in destructor - iEntryIds.Reset(); - - // all entries deleted, remove the Calendar related registry - iEngine->RemoveStoreL( KUidDictionaryUidCalendar ); - } - -//---------------------------------------------------------------------------- - diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/src/creator_calendarelement.cpp --- a/creator/engine/src/creator_calendarelement.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,596 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - -#include "creator_calendarelement.h" -#include "creator_traces.h" -#include "creator_calendar.h" - -using namespace creatorcalendar; - -CCreatorCalendarElement* CCreatorCalendarElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext ) - { - CCreatorCalendarElement* self = new (ELeave) CCreatorCalendarElement(aEngine); - CleanupStack::PushL(self); - self->ConstructL(aName, aContext); - CleanupStack::Pop(self); - return self; - } - -void CCreatorCalendarElement::FillEntryParamsL(TEntryType aType, const RPointerArray& fields, CCalenderInterimParameters* parameters) - { - if( parameters == 0 ) - return; - - TBool startResolved = EFalse; - TBool endResolved = EFalse; - - for( TInt i = 0; i < fields.Count(); ++i ) - { - TPtrC elemName = fields[i]->Name(); - TPtrC elemContent = fields[i]->Content(); - const CCreatorScriptAttribute* randomAttr = fields[i]->FindAttributeByName(KRandomLength); - - if( elemName == KSummary || elemName == KDescription ) - { - if( randomAttr || elemContent.Length() == 0 ) - { - TPtrC reason; - if( aType == EAppointment ) - { - reason.Set(iEngine->RandomString (CCreatorEngine::EMeetingReason )); - } - else if( aType == EEvent ) - { - reason.Set(iEngine->RandomString(CCreatorEngine::EMemoText)); - } - else if( aType == EReminder ) - { - reason.Set(iEngine->RandomString(CCreatorEngine::EReminderText)); - } - else if( aType == EAnniversary ) - { - reason.Set(iEngine->RandomString(CCreatorEngine::EAnniversaryReason)); - } - else if( aType == ETodo ) - { - reason.Set(iEngine->RandomString(CCreatorEngine::EToDoText)); - } - - if( elemName == KDescription ) - { - delete parameters->iDescription; - parameters->iDescription = 0; - parameters->iDescription = HBufC::NewL(reason.Length()); - parameters->iDescription->Des().Copy(reason); - } - else if(elemName == KSummary) - { - delete parameters->iSummary; - parameters->iSummary = 0; - parameters->iSummary = HBufC::NewL(reason.Length()); - parameters->iSummary->Des().Copy(reason); - } - } - else if( elemName == KDescription ) - { - delete parameters->iDescription; - parameters->iDescription = 0; - parameters->iDescription = HBufC::NewL(elemContent.Length()); - parameters->iDescription->Des().Copy(elemContent); - } - else if( elemName == KSummary) - { - delete parameters->iSummary; - parameters->iSummary = 0; - parameters->iSummary = HBufC::NewL(elemContent.Length()); - parameters->iSummary->Des().Copy(elemContent); - } - } - else if( elemName == KLocation ) - { - delete parameters->iLocation; - parameters->iLocation = 0; - - if( randomAttr || elemContent.Length() == 0 ) - { - TPtrC reason = iEngine->RandomString (CCreatorEngine::EMeetingPlace ); - parameters->iLocation = HBufC::NewL(reason.Length()); - parameters->iLocation->Des().Copy(reason); - } - else - { - parameters->iLocation = HBufC::NewL(elemContent.Length()); - parameters->iLocation->Des().Copy(elemContent); - } - } - else if( elemName == KStarttime ) - { - if( randomAttr || elemContent.Length() == 0 ) - { - // Random start time used. If end time is already resolved, let's use that one for the basis. - if( endResolved ) - { - parameters->iStartTime = iEngine->RandomTime(parameters->iEndTime, CCreatorEngine::EDatePast); - } - else - { - // Past or future: - CCreatorEngine::TRandomDateType pastOrfuture = - (CCreatorEngine::TRandomDateType) iEngine->RandomNumber((TInt) CCreatorEngine::EDatePast, - (TInt) CCreatorEngine::EDateFuture); - - parameters->iStartTime = - iEngine->RandomTime(iEngine->RandomDate(pastOrfuture), pastOrfuture); - } - } - else - { - parameters->iStartTime = ConvertToDateTimeL(elemContent); - } - startResolved = ETrue; - } - else if( elemName == KEndtime ) - { - if( randomAttr || elemContent.Length() == 0 ) - { - // Random end time used. If start time is already resolved, let's use that one. - if( startResolved ) - { - parameters->iEndTime = iEngine->RandomTime(parameters->iStartTime, CCreatorEngine::EDateFuture); - } - else - { - // Past or future: - CCreatorEngine::TRandomDateType pastOrfuture = - (CCreatorEngine::TRandomDateType) iEngine->RandomNumber((TInt) CCreatorEngine::EDatePast, - (TInt) CCreatorEngine::EDateFuture); - - parameters->iEndTime = - iEngine->RandomTime(iEngine->RandomDate(pastOrfuture), pastOrfuture); - } - } - else - { - parameters->iEndTime = ConvertToDateTimeL(elemContent); - } - if( aType == ETodo ) - { - parameters->iTodoDueTime = parameters->iEndTime; - } - endResolved = ETrue; - } - else if( elemName == KRecurrentFreq ) - { - TInt randomFreq = 0; - if( randomAttr || elemContent.Length() == 0 ) - { - randomFreq = iEngine->RandomNumber(1, 4); - } - if(randomFreq == 1 || CompareIgnoreCase(elemContent, KDaily) == 0 ) - parameters->iRecurrentFrequency = TCalRRule::EDaily; - else if( randomFreq == 2 || CompareIgnoreCase(elemContent, KWeekly) == 0 ) - parameters->iRecurrentFrequency = TCalRRule::EWeekly; - else if( randomFreq == 3 || CompareIgnoreCase(elemContent, KMonthly) == 0 ) - parameters->iRecurrentFrequency = TCalRRule::EMonthly; - else if( randomFreq == 4 || CompareIgnoreCase(elemContent, KYearly) == 0 ) - parameters->iRecurrentFrequency = TCalRRule::EYearly; - else - parameters->iRecurrentFrequency = TCalRRule::EInvalid; - } - else if( elemName == KRecurrentInterval ) - { - if( randomAttr || elemContent.Length() == 0 ) - { - parameters->iRecurrentInterval = iEngine->RandomNumber(1,7); - } - else - { - parameters->iRecurrentInterval = ConvertStrToIntL(elemContent); - } - } - else if( elemName == KRecurrentFrom ) - { - if( randomAttr || elemContent.Length() == 0 ) - { - if( startResolved ) - { - // Let's use the start time if it's resolved. - parameters->iRecurrentStartTime = parameters->iStartTime; - } - else - { - parameters->iRecurrentStartTime = iEngine->RandomDate(CCreatorEngine::EDateFuture); - } - } - else - { - parameters->iRecurrentStartTime = ConvertToDateTimeL(elemContent); - } - } - else if( elemName == KRecurrentTo ) - { - if( randomAttr || elemContent.Length() == 0 ) - { - parameters->iRepeatingCount = iEngine->RandomNumber(1, 6); - //parameters->iRecurrentEndTime = iEngine->RandomDate(CCreatorEngine::EDateFuture); - } - else - { - parameters->iRecurrentEndTime = ConvertToDateTimeL(elemContent); - } - } - else if( elemName == KRepeatingCount ) - { - if( randomAttr || elemContent.Length() == 0 ) - { - parameters->iRepeatingCount = iEngine->RandomNumber(1, 52); - } - else - { - parameters->iRepeatingCount = ConvertStrToIntL(elemContent); - } - } - else if( elemName == KAlarmtime ) - { - if( randomAttr || elemContent.Length() == 0 ) - { - parameters->iUseRandomAlarmTime = ETrue; - } - else - { - parameters->iAlarmTime = ConvertToDateTimeL(elemContent); - } - } - else if( elemName == KOrganizername ) - { - delete parameters->iOrganizerName; - parameters->iOrganizerName = 0; - if( randomAttr || elemContent.Length() == 0 ) - { - TPtrC name = iEngine->RandomString (CCreatorEngine::EFirstName ); - parameters->iOrganizerName = HBufC::NewL(name.Length()); - parameters->iOrganizerName->Des().Copy(name); - } - else - { - parameters->iOrganizerName = HBufC::NewL(elemContent.Length()); - parameters->iOrganizerName->Des().Copy(elemContent); - } - } - else if( elemName == KOrganizeremail ) - { - delete parameters->iOrganizerEmail; - parameters->iOrganizerEmail = 0; - if( randomAttr || elemContent.Length() == 0 ) - { - TDesC* email = iEngine->CreateEmailAddressLC(); - parameters->iOrganizerEmail = (HBufC*) email; - CleanupStack::Pop(); // email - } - else - { - parameters->iOrganizerEmail = HBufC::NewL(elemContent.Length()); - parameters->iOrganizerEmail->Des().Copy(elemContent); - } - } - else if( elemName == KStatus ) - { - if( randomAttr || elemContent.Length() == 0 ) - { - if( aType == ETodo ) - { - parameters->iStatus = (CCalEntry::TStatus) iEngine->RandomNumber(CCalEntry::ETodoNeedsAction, CCalEntry::ETodoInProcess); - } - else - { - parameters->iStatus = (CCalEntry::TStatus) iEngine->RandomNumber(CCalEntry::ETentative, CCalEntry::ECancelled); - } - } - else if( CompareIgnoreCase(elemContent, KCalStatusTentative) == 0 ) - { - parameters->iStatus = CCalEntry::ETentative; - } - else if( CompareIgnoreCase(elemContent, KCalStatusConfirmed) == 0 ) - { - parameters->iStatus = CCalEntry::EConfirmed; - } - else if( CompareIgnoreCase(elemContent, KCalStatusCancelled) == 0 ) - { - parameters->iStatus = CCalEntry::ECancelled; - } - else if( CompareIgnoreCase(elemContent, KCalStatusNeedsAction) == 0 ) - { - parameters->iStatus = CCalEntry::ETodoNeedsAction; - } - else if( CompareIgnoreCase(elemContent, KCalStatusCompleted) == 0 ) - { - parameters->iStatus = CCalEntry::ETodoCompleted; - } - else if( CompareIgnoreCase(elemContent, KCalStatusInProcess) == 0 ) - { - parameters->iStatus = CCalEntry::ETodoInProcess; - } - else - { - parameters->iStatus = CCalEntry::ENullStatus; - } - } - else if( elemName == KPriority ) - { - if( randomAttr || elemContent.Length() == 0 ) - { - parameters->iTodoPriority = iEngine->RandomNumber(1,3); - } - else if( CompareIgnoreCase(elemContent, KPriorityHigh) == 0) - { - parameters->iTodoPriority = 1; - } - else if( CompareIgnoreCase(elemContent, KPriorityMedium) == 0) - { - parameters->iTodoPriority = 2; - } - else if( CompareIgnoreCase(elemContent, KPriorityLow) == 0 ) - { - parameters->iTodoPriority = 3; - } - else - { - parameters->iTodoPriority = ConvertStrToIntL(elemContent); - } - } - else if( elemName == KAttendees ) - { - const RPointerArray& attendeesSubElems = fields[i]->SubElements(); - for( TInt j = 0; j < attendeesSubElems.Count(); ++j ) - { - TPtrC eName = attendeesSubElems[j]->Name(); - TPtrC eContent = attendeesSubElems[j]->Content(); - if( eName == KContactSetRef ) - { - AppendContactSetReferenceL(*attendeesSubElems[j], parameters->iAttendeeLinkIds); - } - else if( eName == KAttendee ) - { - CCreatorCalenderAttendee* calAtt = CCreatorCalenderAttendee::NewL(); - CleanupStack::PushL(calAtt); - const RPointerArray& attendeeFields = attendeesSubElems[j]->SubElements(); - // Make sure that at least email is given: - if(attendeeFields.Count() == 0 ) - { - CCreatorScriptElement* emailField = CCreatorScriptElement::NewL(iEngine, KEmail ); - CleanupStack::PushL(emailField); - fields[i]->SubElements().AppendL(emailField); - CleanupStack::Pop(); // emailField - } - for( TInt k = 0; k < attendeeFields.Count(); ++k ) - { - const CCreatorScriptAttribute* randomAttr = attendeeFields[k]->FindAttributeByName(KRandomLength); - TPtrC attElemName = attendeeFields[k]->Name(); - TPtrC attElemCont = attendeeFields[k]->Content(); - if( attElemName == KCommonname ) - { - if( randomAttr || attElemCont.Length() == 0) - { - // Random data: - calAtt->SetCommonNameL(iEngine->RandomString(CCreatorEngine::EFirstName)); - } - else - { - calAtt->SetCommonNameL(attElemCont); - } - } - else if( attElemName == KEmail ) - { - if( randomAttr || attElemCont.Length() == 0) - { - // Random data: - TDesC* email = iEngine->CreateEmailAddressLC(); - calAtt->SetEmailAddressL(*email); - CleanupStack::PopAndDestroy(); // email - } - else - { - calAtt->SetEmailAddressL(attElemCont); - } - } - else if( attElemName == KRole ) - { - if( randomAttr || attElemCont.Length() == 0) - { - // Random role: - CCalAttendee::TCalRole randomRole = - (CCalAttendee::TCalRole) iEngine->RandomNumber( - (TInt) CCalAttendee::EReqParticipant, - (TInt) CCalAttendee::EChair); - calAtt->SetRole(randomRole); - } - else if( CompareIgnoreCase(attElemCont, KRoleRequired) == 0 ) - { - calAtt->SetRole(CCalAttendee::EReqParticipant); - } - else if( CompareIgnoreCase(attElemCont, KRoleOptional) == 0 ) - { - calAtt->SetRole(CCalAttendee::EOptParticipant); - } - else if( CompareIgnoreCase(attElemCont, KRoleNonPart) == 0 ) - { - calAtt->SetRole(CCalAttendee::ENonParticipant); - } - else if( CompareIgnoreCase(attElemCont, KRoleChair) == 0 ) - { - calAtt->SetRole(CCalAttendee::EChair); - } - } - else if( attElemName == KStatus ) - { - if( randomAttr || attElemCont.Length() == 0) - { - // Random role: - CCalAttendee::TCalStatus randomStatus = - (CCalAttendee::TCalStatus) iEngine->RandomNumber( - (TInt) CCalAttendee::ENeedsAction, - (TInt) CCalAttendee::EInProcess); - calAtt->SetStatus(randomStatus); - } - else if( CompareIgnoreCase(attElemCont, KStatusNeedsAction) == 0 ) - { - calAtt->SetStatus(CCalAttendee::ENeedsAction); - } - else if( CompareIgnoreCase(attElemCont, KStatusAccepted) == 0 ) - { - calAtt->SetStatus(CCalAttendee::EAccepted); - } - else if( CompareIgnoreCase(attElemCont, KStatusTentative) == 0 ) - { - calAtt->SetStatus(CCalAttendee::ETentative); - } - else if( CompareIgnoreCase(attElemCont, KStatusConfirmed) == 0 ) - { - calAtt->SetStatus(CCalAttendee::EConfirmed); - } - else if( CompareIgnoreCase(attElemCont, KStatusDeclined) == 0 ) - { - calAtt->SetStatus(CCalAttendee::EDeclined); - } - else if( CompareIgnoreCase(attElemCont, KStatusCompleted) == 0 ) - { - calAtt->SetStatus(CCalAttendee::ECompleted); - } - else if( CompareIgnoreCase(attElemCont, KStatusDelegated) == 0 ) - { - calAtt->SetStatus(CCalAttendee::EDelegated); - } - else if( CompareIgnoreCase(attElemCont, KStatusInProcess) == 0 ) - { - calAtt->SetStatus(CCalAttendee::EInProcess); - } - } - } - parameters->iAttendees.AppendL(calAtt); - CleanupStack::Pop(); // calAtt - } - } - } - } - } - -void CCreatorCalendarElement::ExecuteCommandL() - { - LOGSTRING("Creator: CCreatorCalendarElement::ExecuteCommandL"); - // Amount of calendar entries: - const CCreatorScriptAttribute* calEntryAmountAttr = this->FindAttributeByName(KAmount); - const CCreatorScriptAttribute* calEntryTypeAttr = this->FindAttributeByName(KType); - TInt entryAmount = 1; - if( calEntryAmountAttr ) - { - entryAmount = ConvertStrToIntL(calEntryAmountAttr->Value()); - } - if( calEntryTypeAttr == 0 ) - { - LOGSTRING("ERROR in CCreatorCalendarElement::ExecuteCommandL: Type attribute is missing."); - User::Leave(KErrGeneral); // type is required attribute - } - - // Find fields element: - CCreatorScriptElement* fieldsElement = FindSubElement(KFields); - - for( TInt cI = 0; cI < entryAmount; ++cI ) - { - CCalenderInterimParameters* param = new (ELeave) CCalenderInterimParameters; - CleanupStack::PushL(param); - if( CompareIgnoreCase(calEntryTypeAttr->Value(), KCalTypeAppointment) == 0 ) - { - if( fieldsElement && fieldsElement->SubElements().Count() > 0 ) - { - FillEntryParamsL(EAppointment, fieldsElement->SubElements(), param); - iEngine->AppendToCommandArrayL(ECmdCreateCalendarEntryAppointments, param); - } - else - { - iEngine->AppendToCommandArrayL(ECmdCreateCalendarEntryAppointments, 0, entryAmount); - CleanupStack::PopAndDestroy(param); - break; // We can step out from the for-loop, because the amount is given to engine. - } - } - else if( CompareIgnoreCase(calEntryTypeAttr->Value(), KCalTypeEvent ) == 0 ) - { - if( fieldsElement && fieldsElement->SubElements().Count() > 0 ) - { - FillEntryParamsL(EEvent, fieldsElement->SubElements(), param); - iEngine->AppendToCommandArrayL(ECmdCreateCalendarEntryEvents, param); - } - else - { - iEngine->AppendToCommandArrayL(ECmdCreateCalendarEntryEvents, 0, entryAmount); - CleanupStack::PopAndDestroy(param); - break; // We can step out from the for-loop, because the amount is given to engine. - } - } - else if( CompareIgnoreCase(calEntryTypeAttr->Value(), KCalTypeReminder ) == 0 ) - { - if( fieldsElement && fieldsElement->SubElements().Count() > 0 ) - { - FillEntryParamsL(EReminder, fieldsElement->SubElements(), param); - iEngine->AppendToCommandArrayL(ECmdCreateCalendarEntryReminders, param); - } - else - { - iEngine->AppendToCommandArrayL(ECmdCreateCalendarEntryReminders, 0, entryAmount); - CleanupStack::PopAndDestroy(param); - break; // We can step out from the for-loop, because the amount is given to engine. - } - } - else if( CompareIgnoreCase(calEntryTypeAttr->Value(), KCalTypeAnniversary ) == 0 ) - { - if( fieldsElement && fieldsElement->SubElements().Count() > 0 ) - { - FillEntryParamsL(EAnniversary, fieldsElement->SubElements(), param); - iEngine->AppendToCommandArrayL(ECmdCreateCalendarEntryAnniversaries, param); - } - else - { - iEngine->AppendToCommandArrayL(ECmdCreateCalendarEntryAnniversaries, 0, entryAmount); - CleanupStack::PopAndDestroy(param); - break; // We can step out from the for-loop, because the amount is given to engine. - } - } - else if( CompareIgnoreCase(calEntryTypeAttr->Value(), KCalTypeTodo ) == 0 ) - { - if( fieldsElement && fieldsElement->SubElements().Count() > 0 ) - { - FillEntryParamsL(ETodo, fieldsElement->SubElements(), param); - iEngine->AppendToCommandArrayL(ECmdCreateCalendarEntryToDos, param); - } - else - { - iEngine->AppendToCommandArrayL(ECmdCreateCalendarEntryToDos, 0, entryAmount); - CleanupStack::PopAndDestroy(param); - break; // We can step out from the for-loop, because the amount is given to engine. - } - } - CleanupStack::Pop(); // param - } - } - -CCreatorCalendarElement::CCreatorCalendarElement(CCreatorEngine* aEngine) -: -CCreatorScriptElement(aEngine) - { - iIsCommandElement = ETrue; - } diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/src/creator_cmdscriptrun.cpp --- a/creator/engine/src/creator_cmdscriptrun.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,172 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#include -#include -#include -#include "creator_cmdscriptrun.h" -#include "engine.h" -#include "enginewrapper.h" -#include "creator.pan" - - -// delay before script running and application exiting in seconds -// when script is run from command line -const TInt KCommandLineDelay = 3; - -//---------------------------------------------------------------------------- - -CCreatorCmdScriptRun* CCreatorCmdScriptRun::NewL(CCreatorEngine* aEngine) - { - CCreatorCmdScriptRun* self = CCreatorCmdScriptRun::NewLC(aEngine); - CleanupStack::Pop(self); - return self; - } - -CCreatorCmdScriptRun* CCreatorCmdScriptRun::NewLC(CCreatorEngine* aEngine) - { - CCreatorCmdScriptRun* self = new (ELeave) CCreatorCmdScriptRun; - CleanupStack::PushL(self); - self->ConstructL(aEngine); - return self; - } - - -// ConstructL -void CCreatorCmdScriptRun::ConstructL(CCreatorEngine* aEngine) - { - iEngine = aEngine; - - iMode = ETimerModeNone; - iTickCount = 0; - iTimer = CHeartbeat::NewL(0); - - // parse script name and random data file name from command line - iCommandLineScriptName = HBufC::NewL(User::CommandLineLength()); - iCommandLineRandomDataFileName = HBufC::NewL(User::CommandLineLength()); - HBufC* commandLine = HBufC::NewLC(User::CommandLineLength()); - TPtr16 ptr = commandLine->Des(); - User::CommandLine(ptr); - commandLine->Des().Trim(); - - TInt pos = commandLine->Des().Find(_L(" ")); - if (pos != KErrNotFound) - { - iCommandLineScriptName->Des().Copy(commandLine->Des().Left(pos)); - iCommandLineRandomDataFileName->Des().Copy(commandLine->Des().Mid(pos)); - iCommandLineRandomDataFileName->Des().Trim(); - } - else - { - iCommandLineScriptName->Des().Copy(commandLine->Des()); - iCommandLineRandomDataFileName->Des().Copy(KNullDesC); - } - - CleanupStack::PopAndDestroy(commandLine); - - if (iCommandLineScriptName->Des().Length() > 0) - { - iMode = ETimerModeStartScript; - iTimer->Start(ETwelveOClock, this); - } - } - - - CCreatorCmdScriptRun::CCreatorCmdScriptRun() - { - // add any construction that cannot leave here - } - - - CCreatorCmdScriptRun::~CCreatorCmdScriptRun() - { - delete iCommandLineRandomDataFileName; - delete iCommandLineScriptName; - - if (iTimer) - { - iTimer->Cancel(); - delete iTimer; - iTimer = NULL; - } - } - -void CCreatorCmdScriptRun::RunScriptDone() - { - if (iMode == ETimerModeStartScript) - { - iMode = ETimerModeExitAppUi; - iTimer->Start(ETwelveOClock, this); - } - } - -void CCreatorCmdScriptRun::Beat() - { - TRAP_IGNORE( TickL() ); - } - -void CCreatorCmdScriptRun::Synchronize() - { - TRAP_IGNORE( TickL() ); - } - -void CCreatorCmdScriptRun::TickL() - { - iTickCount++; - if (iTickCount > KCommandLineDelay) - { - iTimer->Cancel(); - iTickCount = 0; - if (iMode == ETimerModeStartScript) - { - iEngine->GetRandomDataFromFileL(*iCommandLineRandomDataFileName); - TInt status = iEngine->RunScriptL(*iCommandLineScriptName); - if (status != KErrNone) - { - TBuf<128> noteMsg; - if (status == KErrNotFound) - { - _LIT(KMessage1, "Error in opening script file."); - noteMsg.Copy(KMessage1); - } - else if (status == KErrCorrupt) - { - _LIT(KMessage2, "Error in parsing script file."); - noteMsg.Copy(KMessage2); - } - else if (status == KErrCompletion) - { - _LIT(KMessage3, "Script file does not contain any elements."); - noteMsg.Copy(KMessage3); - } - else - { - _LIT(KMessage4, "Unknown error in opening script file."); - noteMsg.Copy(KMessage4); - } - iEngine->GetEngineWrapper()->ShowNote(noteMsg); - RunScriptDone(); - } - } - else if (iMode == ETimerModeExitAppUi) - { - iMode = ETimerModeNone; - iEngine->GetEngineWrapper()->CloseCreatorApp(); - } - } - } diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/src/creator_connectionmethod.cpp --- a/creator/engine/src/creator_connectionmethod.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,954 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#include "engine.h" -#include "enginewrapper.h" -#include "creator_connectionmethod.h" -#include "creator_traces.h" - - - -using namespace CMManager; -//#define KUidLanBearerType 0x1020737A -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#include -#include -#include -#include -#include -#include -#include - -//#include //For WEP setting -//#include - -static const TInt KConnectionSettingssFieldLength = 128; - -_LIT(KCreatorConnectionSettingssPrefixName, "CR_"); - -//---------------------------------------------------------------------------- - -CConnectionSettingsParameters::CConnectionSettingsParameters() - { - LOGSTRING("Creator: CConnectionSettingsParameters::CConnectionSettingsParameters"); - - iConnectionName = HBufC::New(KConnectionSettingssFieldLength); - iStartPage = HBufC::New(KConnectionSettingssFieldLength); - iLoginName = HBufC::New(KConnectionSettingssFieldLength); - iLoginPass = HBufC::New(KConnectionSettingssFieldLength); - iIPAddr = HBufC::New(KConnectionSettingssFieldLength); - iIP4NameServer1 = HBufC::New(KConnectionSettingssFieldLength); - iIP4NameServer2 = HBufC::New(KConnectionSettingssFieldLength); - iDefaultTelNumber = HBufC::New(KConnectionSettingssFieldLength); - iProxyServerAddress = HBufC::New(KConnectionSettingssFieldLength); - iSubnetMask = HBufC::New(KConnectionSettingssFieldLength); - iGatewayAddress = HBufC::New(KConnectionSettingssFieldLength); - iWLANName = HBufC::New(KConnectionSettingssFieldLength); - iWlanIpAddr = HBufC::New(KConnectionSettingssFieldLength); - iIP6NameServer1 = HBufC::New(KConnectionSettingssFieldLength); - iIP6NameServer2 = HBufC::New(KConnectionSettingssFieldLength); - } - -CConnectionSettingsParameters::~CConnectionSettingsParameters() - { - LOGSTRING("Creator: CConnectionSettingssParameters::~CConnectionSettingssParameters"); - - delete iProxyServerAddress; - delete iDefaultTelNumber; - delete iIP4NameServer2; - delete iIP4NameServer1; - delete iIPAddr; - delete iLoginPass; - delete iLoginName; - delete iStartPage; - delete iConnectionName; - delete iSubnetMask; - delete iGatewayAddress; - delete iWLANName; - delete iWlanIpAddr; - delete iIP6NameServer1; - delete iIP6NameServer2; - } - -//---------------------------------------------------------------------------- - -CCreatorConnectionSettings* CCreatorConnectionSettings::NewL(CCreatorEngine* aEngine) - { - CCreatorConnectionSettings* self = CCreatorConnectionSettings::NewLC(aEngine); - CleanupStack::Pop(self); - return self; - } - -CCreatorConnectionSettings* CCreatorConnectionSettings::NewLC(CCreatorEngine* aEngine) - { - CCreatorConnectionSettings* self = new (ELeave) CCreatorConnectionSettings; - CleanupStack::PushL(self); - self->ConstructL(aEngine); - return self; - } - -CCreatorConnectionSettings::CCreatorConnectionSettings() - { - } - -void CCreatorConnectionSettings::ConstructL(CCreatorEngine* aEngine) - { - LOGSTRING("Creator: CCreatorConnectionSettings::ConstructL"); - - iEngine = aEngine; - - iCmManagerExt.CreateTablesAndOpenL(); - } - -CCreatorConnectionSettings::~CCreatorConnectionSettings() - { - LOGSTRING("Creator: CCreatorConnectionSettings::~CCreatorConnectionSettings"); - - if ( iEngine && iEntryIds.Count() ) - { - TRAP_IGNORE( iEngine->WriteEntryIdsToStoreL( iEntryIds, KUidDictionaryUidIAP ) ); - } - iEntryIds.Reset(); - iEntryIds.Close(); - - if (iParameters) - { - delete iParameters; - } - - iCmManagerExt.Close(); - } - - -//---------------------------------------------------------------------------- - -TBool CCreatorConnectionSettings::AskDataFromUserL(TInt aCommand) - { - LOGSTRING("Creator: CCreatorConnectionSettings::AskDataFromUserL"); - - CCreatorModuleBase::AskDataFromUserL( aCommand ); - - if( aCommand == ECmdDeleteIAPs ) - { - return iEngine->GetEngineWrapper()->YesNoQueryDialog(_L("Delete all Connection Methods?"), this, ECreatorModuleDelete ); - } - else if( aCommand == ECmdDeleteCreatorIAPs ) - { - return iEngine->GetEngineWrapper()->YesNoQueryDialog(_L("Delete all Connection Methods created with Creator?"), this, ECreatorModuleDelete ); - } - else - { - return iEngine->GetEngineWrapper()->EntriesQueryDialog(&iEntriesToBeCreated, _L("How many entries to create?"), EFalse, this, ECreatorModuleStart ); - } - } - - -//---------------------------------------------------------------------------- - -TInt CCreatorConnectionSettings::CreateConnectionSettingsEntryL(CCreatorModuleBaseParameters *aParameters) - { - LOGSTRING("Creator: CCreatorConnectionSettings::CreateConnectionSettingsEntryL"); - - CConnectionSettingsParameters* parameters = (CConnectionSettingsParameters*) aParameters; - - // clear any existing parameter definations - delete iParameters; - iParameters = NULL; - - // random data needed if no predefined data available - if (!parameters) - { - iParameters = new (ELeave) CConnectionSettingsParameters(); - parameters = iParameters; - SetRandomParametersL(*parameters); - } - - if( parameters->iBearerType == KRandomBearerType ) - { - SetRandomBearerTypeL(*parameters); - } - - TInt err = KErrNone; - - // create unique name for each network destination - RCmDestinationExt dest; - TInt destinationError = KErrNone; - TInt count = 0; - TBuf name; - name.Copy(parameters->iConnectionName->Des()); - do - { - TRAP(destinationError, dest = iCmManagerExt.CreateDestinationL(name)); - if (destinationError == KErrAlreadyExists) - { - name.Copy(parameters->iConnectionName->Des()); - count++; - name.AppendFormat(_L(" (%d)"), count); - } - else if (destinationError != KErrNone) - { - User::Leave(destinationError); - } - } - while (destinationError == KErrAlreadyExists); - parameters->iConnectionName->Des().Copy(name); - - CleanupClosePushL(dest); - dest.UpdateL(); - - RCmConnectionMethodExt conMethod = dest.CreateConnectionMethodL( parameters->iBearerType);//KUidPacketDataBearerType - CleanupClosePushL( conMethod ); - - if(parameters->iBearerType == KUidWlanBearerType) - { - //IP net mask of interface - conMethod.SetStringAttributeL( EWlanIpNetMask, parameters->iSubnetMask->Des() ); - - //IP address of EPOC. - conMethod.SetStringAttributeL( EWlanIpAddr, parameters->iWlanIpAddr->Des() ); - // - //following gateway ID:s is not workin, - //logically ID would be EWlanIpGateway because EWlanIpNetMask - //is going to net mask, which is just before gateway in ui - //---> - conMethod.SetStringAttributeL( EWlanIpGateway, parameters->iGatewayAddress->Des() ); - //conMethod.SetStringAttributeL( EApIspIPGateway, parameters->iGatewayAddress->Des() ); - conMethod.SetStringAttributeL( ECmWapIPGatewayAddress, parameters->iGatewayAddress->Des() ); - conMethod.SetStringAttributeL( ECmIPGateway, parameters->iGatewayAddress->Des() ); - //<--- - - //IP Address of primary and secondary name server (IP v4). - conMethod.SetStringAttributeL( EWlanIpNameServer1, parameters->iIP4NameServer1->Des() ); - conMethod.SetStringAttributeL( EWlanIpNameServer2, parameters->iIP4NameServer2->Des() ); - //The SSID of this WLAN connection. - conMethod.SetStringAttributeL( EWlanSSID, parameters->iWLANName->Des() ); - - //IP6 address of primary and secondary name servers - conMethod.SetStringAttributeL( EWlanIp6NameServer1, parameters->iIP6NameServer1->Des() ); - conMethod.SetStringAttributeL( EWlanIp6NameServer2, parameters->iIP6NameServer2->Des() ); - - // - //Setting secure mode settings - // - - //Network status (default: EWlanSecModeOpen) // EWlanAuthenticationMode use instead? - conMethod.SetIntAttributeL( EWlanSecurityMode, parameters->iWLanSecMode ); - //WLAN Network mode - conMethod.SetIntAttributeL( EWlanConnectionMode, parameters->iWlanNetMode ); - - - if(parameters->iWLanSecMode == EWlanSecModeOpen) - {}//Nothing to set when mode is open - else if(parameters->iWLanSecMode == EWlanSecModeWep) - { - //See WEPSecuritySettingsUI.h - - - ///CWEPSecuritySettings - // conMethod.SetIntAttributeL( EWlanSecurityMode, parameters->iWLanSecMode ); - } - else if(parameters->iWLanSecMode == EWlanSecMode802_1x) - { - } - else if(parameters->iWLanSecMode == EWlanSecModeWpa) - { - } - else if(parameters->iWLanSecMode == EWlanSecModeWpa2) - { - } - - //WLAN security setting - //conMethod.SetStringAttributeL( EWlanAuthenticationMode, parameters->iIP6NameServer2->Des() ); - //Utilise this method - //conMethod.SetStringAttributeL( EWlanSecurityMode, parameters->iWLanSecMode ); - } - //Not known special attributes for packet data - else if(parameters->iBearerType == KUidPacketDataBearerType) - { - - //Access point name. - conMethod.SetStringAttributeL( EPacketDataAPName, parameters->iConnectionName->Des() );//crash - - //Authentication user name - conMethod.SetStringAttributeL( EPacketDataIFAuthName, parameters->iLoginName->Des() ); - ///TProtocolType a; - //EPdpTypeIPv4 or EPdpTypeIPv6 - conMethod.SetIntAttributeL( EPacketDataPDPType, parameters->iProtocolType ); - - //IP6 address of primary and secondary name servers - conMethod.SetStringAttributeL( EPacketDataIPIP6NameServer1, parameters->iIP6NameServer1->Des() ); - conMethod.SetStringAttributeL( EPacketDataIPIP6NameServer2, parameters->iIP6NameServer2->Des() ); - //IP address of primary name server - conMethod.SetStringAttributeL( EPacketDataIPNameServer1, parameters->iIP4NameServer1->Des() ); - //IP address of secondary name server - conMethod.SetStringAttributeL( EPacketDataIPNameServer2, parameters->iIP4NameServer2->Des() ); - - //Also existing but UI not showing them: EPacketDataHeaderCompression, EPacketDataDisablePlainTextAuth - //EPacketDataIFAuthPass, EDialIFAuthPass, EPacketDataIFPromptForAuth, EPacketDataIPAddr - } - else if(parameters->iBearerType == KUidCSDBearerType || parameters->iBearerType == KUidHSCSDBearerType) - { - //Authentication user name - conMethod.SetStringAttributeL( EDialIFAuthName, parameters->iLoginName->Des() ); - //Dial-up number - conMethod.SetStringAttributeL( EDialDefaultTelNum, parameters->iDefaultTelNumber->Des() ); - //Call type - conMethod.SetIntAttributeL( EDialCallType , parameters->iBearerCallTypeIsdn ); - //Maximum speed - conMethod.SetIntAttributeL( EDialMaxConnSpeed, parameters->iBearerSpeed ); - //Prompt user for username and password? (Only for dial out) - conMethod.SetBoolAttributeL( EDialPromptForLogin, parameters->iPromptPassword ); - //IP6 address of primary and secondary name servers - conMethod.SetStringAttributeL( EDialIP6NameServer1, parameters->iIP6NameServer1->Des() ); - conMethod.SetStringAttributeL( EDialIP6NameServer2, parameters->iIP6NameServer2->Des() ); - //Disable plaintext authentication - conMethod.SetBoolAttributeL( EDialDisablePlainTextAuth, parameters->iDisableTextAuth ); - //IP address of primary name server - conMethod.SetStringAttributeL( EDialIPNameServer1, parameters->iIP4NameServer1->Des() ); - //IP address of secondary name server - conMethod.SetStringAttributeL( EDialIPNameServer2, parameters->iIP4NameServer2->Des() ); - - //Also existing EDialEnableIPHeaderComp; EDialIFPromptForAuth;EDialIPAddress parameters - - } - else if(parameters->iBearerType == KUidLanBearerType) - { - - conMethod.SetStringAttributeL( ELanIpNetMask, parameters->iSubnetMask->Des() ); - conMethod.SetStringAttributeL( ELanIpGateway, parameters->iGatewayAddress->Des()); - conMethod.SetStringAttributeL( ELanIpAddr, parameters->iIPAddr->Des() ); - conMethod.SetStringAttributeL( ELanIpNameServer1, parameters->iIP4NameServer1->Des() ); - conMethod.SetStringAttributeL( ELanIpNameServer2, parameters->iIP4NameServer2->Des() ); - conMethod.SetStringAttributeL( ELanIp6NameServer1,parameters->iIP6NameServer1->Des() ); - conMethod.SetStringAttributeL( ELanIp6NameServer2,parameters->iIP6NameServer2->Des() ); - - } - else //KUidEmbeddedDestination and KPluginVPNBearerTypeUid - { - //NOTE: NOT Tested, because no supporting Emulator for them - - //Authentication user name - conMethod.SetStringAttributeL( ECmIFAuthName, parameters->iLoginName->Des() ); - //IP6 address of primary and secondary name servers - conMethod.SetStringAttributeL( ECmIP6NameServer1, parameters->iIP6NameServer1->Des() ); - conMethod.SetStringAttributeL( ECmIP6NameServer2, parameters->iIP6NameServer2->Des() ); - //Disable plaintext authentication - conMethod.SetBoolAttributeL( ECmDisablePlainTextAuth, parameters->iDisableTextAuth ); - //Prompt user for authentication - conMethod.SetBoolAttributeL( ECmIFPromptForAuth, parameters->iPromptPassword ); - //Authentication password - conMethod.SetStringAttributeL( ECmIFAuthPass, parameters->iLoginPass->Des() ); - } - - // - //Adding common attributes, all not neccessary used with all bearer types, but should not cause any problems eather - // - - //CM Name (Connection Method, formelly known as Access Point) - conMethod.SetStringAttributeL( ECmName, parameters->iConnectionName->Des() ); - // Start page of CM - conMethod.SetStringAttributeL( ECmStartPage, parameters->iStartPage->Des() ); - // Enable Proxy - conMethod.SetBoolAttributeL( ECmProxyUsageEnabled, parameters->iUseProxy ); - // Server Name - conMethod.SetStringAttributeL( ECmProxyServerName, parameters->iProxyServerAddress->Des() ); - // Port Number - conMethod.SetIntAttributeL( ECmProxyPortNumber, parameters->iProxyPortNumber ); - //Proxy login name - conMethod.SetStringAttributeL( ECmWapIPProxyLoginName, parameters->iLoginName->Des() ); - //Proxy login password - conMethod.SetStringAttributeL( ECmWapIPProxyLoginPass, parameters->iLoginPass->Des() ); - //IP address of gateway - conMethod.SetStringAttributeL( ECmIPGateway, parameters->iGatewayAddress->Des() ); - //connection-oriented or connectionless API should be used - //ECmWapIPWSPOption option TWapWSPOption: ECmWapWspOptionConnectionless or ECmWapWspOptionConnectionOriented - conMethod.SetIntAttributeL( ECmWapIPWSPOption, parameters->iWapWspOption ); - //NOT WORKING????? Attempt secure WTLS connection to the gateway - conMethod.SetBoolAttributeL( ECmWapIPSecurity, parameters->iSecureAuthentication ); - - // - //Adding advanced settings (Network type, Phone IP addr, DNS addr, proxy srv name, proxy port nbr - // - - //IP address of interface - conMethod.SetStringAttributeL( ECmIPAddress, parameters->iIPAddr->Des() ); - //IP address of primary name server - conMethod.SetStringAttributeL( ECmIPNameServer1, parameters->iIP4NameServer1->Des() ); - //IP address of secondary name server - conMethod.SetStringAttributeL( ECmIPNameServer2, parameters->iIP4NameServer2->Des() ); - - - conMethod.UpdateL(); - - //If no defaults set, set the created CM as a default - SetDefaultCML( conMethod ); - - // id has been generated, store it for being able to delete - // only entries created with Creator - iEntryIds.AppendL( dest.Id() ); - - conMethod.Close(); - CleanupStack::Pop( );//conMethod - - dest.UpdateL(); - dest.Close(); - CleanupStack::Pop(); // dest - - return err; - } - -//---------------------------------------------------------------------------- -void CConnectionSettingsParameters::SetRandomCMNameL(CCreatorEngine& aEngine) - { - LOGSTRING("Creator: CConnectionSettingsParameters::SetRandomCMNameL"); - - TInt num = aEngine.RandomNumber(1, 3); - TBuf<10> apType; - - if (num==1) - { - apType = _L("mms"); - } - else if (num==2) - { - apType = _L("wap"); - } - else - { - apType = _L("internet"); - } - TBuf<160> company = aEngine.RandomString(CCreatorEngine::ECompany); - iConnectionName->Des() = KCreatorConnectionSettingssPrefixName; - iConnectionName->Des().Append( company ); - iConnectionName->Des().Append(_L(" ")); - iConnectionName->Des().Append(apType); - } - -void CConnectionSettingsParameters::SetRandomWLANNameL(CCreatorEngine& aEngine) - { - LOGSTRING("Creator: CConnectionSettingsParameters::SetRandomWLANNameL"); - - TBuf<160> company = aEngine.RandomString(CCreatorEngine::ECompany); - iWLANName->Des() = KCreatorConnectionSettingssPrefixName; - iWLANName->Des().Append( company ); - iWLANName->Des().Append( _L(" WLAN") ); - } - -void CConnectionSettingsParameters::SetRandomWLANNetModeL(CCreatorEngine& aEngine) - { - LOGSTRING("Creator: CConnectionSettingsParameters::SetRandomWLANNetModeL"); - - TInt wlanNetModeRand = aEngine.RandomNumber(1, 2); - if(wlanNetModeRand == 1) - { - iWlanNetMode = EAdhoc;//Ad-Hoc mode - } - else - { - iWlanNetMode = CMManager::EInfra;//Infrastructure mode - } - } - -void CConnectionSettingsParameters::SetRandomWLANSecurityModeL(CCreatorEngine& aEngine) - { - LOGSTRING("Creator: CConnectionSettingsParameters::SetRandomWLANSecurityModeL"); - - TInt wlanSecModeRand = aEngine.RandomNumber(1, 5); - if(wlanSecModeRand == 1) - { - iWLanSecMode = EWlanSecModeOpen;///< Open security mode - } - else if(wlanSecModeRand == 2) - { - iWLanSecMode = EWlanSecModeWep;///< WEP security mode - //See WEPSecuritySettingsUI.h - - ///CWEPSecuritySettings - - //WEP key in us - - //Authentication type - - //WEP Key settings (key len, key format, key data) - } - else if(wlanSecModeRand == 3) - { - iWLanSecMode = EWlanSecMode802_1x; ///< 802.1x security mode - } - else if(wlanSecModeRand == 4) - { - iWLanSecMode = EWlanSecModeWpa;///< WPA security mode - } - else if(wlanSecModeRand == 5) - { - iWLanSecMode = EWlanSecModeWpa2;///< WPA@ security mode - } - } - -void CConnectionSettingsParameters::SetRandomLoginNameL(CCreatorEngine& aEngine) - { - iLoginName->Des() = aEngine.RandomString(CCreatorEngine::EFirstName); - iLoginName->Des().LowerCase(); - } - -void CConnectionSettingsParameters::SetRandomLoginPassL(CCreatorEngine& aEngine) - { - iLoginPass->Des() = aEngine.RandomString(CCreatorEngine::ESurname); - iLoginPass->Des().LowerCase(); - } - -void CConnectionSettingsParameters::SetRandomSecureAuthenticationL(CCreatorEngine& /*aEngine*/) - { - iSecureAuthentication = EFalse; - } - -void CConnectionSettingsParameters::SetRandomPromptPasswordL(CCreatorEngine& /*aEngine*/) - { - iPromptPassword = ETrue; - } - -void CConnectionSettingsParameters::SetRandomUseProxyL(CCreatorEngine& /*aEngine*/) - { - iUseProxy = ETrue; - } - -void CConnectionSettingsParameters::SetRandomProxyAddressL(CCreatorEngine& /*aEngine*/) - { - iProxyServerAddress->Des() = _L("127.0.0.1"); - } - -void CConnectionSettingsParameters::SetRandomProxyPortL(CCreatorEngine& /*aEngine*/) - { - iProxyPortNumber = 80; - } - -void CConnectionSettingsParameters::SetRandomStartPageL(CCreatorEngine& aEngine) - { - LOGSTRING("Creator: CConnectionSettingsParameters::SetRandomStartPageL"); - - TInt num = aEngine.RandomNumber(1, 3); - TBuf<10> apType; - - if (num==1) - { - apType = _L("mms"); - } - else if (num==2) - { - apType = _L("wap"); - } - else - { - apType = _L("internet"); - } - TBuf<160> company = aEngine.RandomString(CCreatorEngine::ECompany); - iStartPage->Des() = _L("http://"); - iStartPage->Des().Append(apType); - iStartPage->Des().Append(_L(".")); - iStartPage->Des().Append(company); - iStartPage->Des().Append(_L(".com")); - iStartPage->Des().LowerCase(); - } - -void CConnectionSettingsParameters::SetRandomIPAddressL(CCreatorEngine& /*aEngine*/) - { - iIPAddr->Des() = _L("10.10.10.10"); - } - -void CConnectionSettingsParameters::SetRandomIP4NameServer1L(CCreatorEngine& /*aEngine*/) - { - iIP4NameServer1->Des() = _L("10.1.1.1"); - } -void CConnectionSettingsParameters::SetRandomIP4NameServer2L(CCreatorEngine& /*aEngine*/) - { - iIP4NameServer2->Des() = _L("10.2.2.2"); - } - -void CConnectionSettingsParameters::SetRandomProtocolTypeL(CCreatorEngine& aEngine) - { - LOGSTRING("Creator: CConnectionSettingsParameters::SetRandomProtocolTypeL"); - - TInt protocolTypeRand = aEngine.RandomNumber(1, 2); - if(protocolTypeRand == 1) - { - iProtocolType = RPacketContext::EPdpTypeIPv4; - } - else - { - iProtocolType = RPacketContext::EPdpTypeIPv6; - } - } - -void CConnectionSettingsParameters::SetRandomTelephoneNumberL(CCreatorEngine& aEngine) - { - iDefaultTelNumber->Des() = aEngine.RandomString(CCreatorEngine::EPhoneNumber); - } - -void CConnectionSettingsParameters::SetRandomBearerTypeIsdnL(CCreatorEngine& /*aEngine*/) - { - iBearerCallTypeIsdn = ECmCallTypeISDNv110; - } - -void CConnectionSettingsParameters::SetRandomBearerSpeedL(CCreatorEngine& /*aEngine*/) - { - iBearerSpeed = ECmSpeed14400; - } - -void CConnectionSettingsParameters::SetRandomWapWspOptionL(CCreatorEngine& /*aEngine*/) - { - iWapWspOption = ECmWapWspOptionConnectionless; - } - -void CConnectionSettingsParameters::SetRandomSubnetMaskL(CCreatorEngine& /*aEngine*/) - { - iSubnetMask->Des() = _L("255.255.255.0"); - } - -void CConnectionSettingsParameters::SetRandomGatewayAddressL(CCreatorEngine& /*aEngine*/) - { - iGatewayAddress->Des() = _L("10.0.0.1"); - } - -void CConnectionSettingsParameters::SetRandomWlanIpAddrL(CCreatorEngine& /*aEngine*/) - { - iWlanIpAddr->Des() = _L("10.0.0.99"); - } - -void CConnectionSettingsParameters::SetRandomIPv6NameServer1L(CCreatorEngine& /*aEngine*/) - { - iIP6NameServer1->Des() = _L("2007:abcd:1000:2000:3000:4000:5000:6001"); - } - -void CConnectionSettingsParameters::SetRandomIPv6NameServer2L(CCreatorEngine& /*aEngine*/) - { - iIP6NameServer2->Des() = _L("2007:abcd:1000:2000:3000:4000:5000:6002"); - } - -void CConnectionSettingsParameters::SetRandomDisableTextAuthL(CCreatorEngine& /*aEngine*/) - { - iDisableTextAuth = EFalse; - } - -void CCreatorConnectionSettings::SetRandomBearerTypeL(CConnectionSettingsParameters& parameters) - { - LOGSTRING("Creator: CCreatorConnectionSettings::SetRandomBearerTypeL"); - - RArray supportedBearers = RArray( 10 ); - iCmManagerExt.SupportedBearersL(supportedBearers); - CleanupClosePushL( supportedBearers ); - - //In random mode, skipping KUidLanBearerType - //Because of Emulator migh show it as supported, when it's really not - //and that causes weird situation in UI when there is an item, but it can't be opened - TInt lanID = supportedBearers.Find(KUidLanBearerType); - if( lanID != KErrNotFound ) - { - supportedBearers.Remove(lanID); - } - - // in emulator remove WLAN - #ifdef __WINSCW__ - TInt wlanID = supportedBearers.Find(KUidWlanBearerType); - if( wlanID != KErrNotFound ) - { - supportedBearers.Remove(wlanID); - } - #endif - - /* - for(TInt i = 0; iRandomNumber(0, supportedCount-1); - - TUint bearerType = supportedBearers[bearerTypeID]; - - //Bearer types KUidEmbeddedDestination and KPluginVPNBearerTypeUid is not supported - if(bearerType == KUidWlanBearerType)//Wireless LAN - { - parameters.iBearerType = KUidWlanBearerType; - } - else if(bearerType == KUidPacketDataBearerType)//Packet data (GPRS) - { - parameters.iBearerType = KUidPacketDataBearerType; - } - else if(bearerType == KUidCSDBearerType)//Data Call - { - parameters.iBearerType = KUidCSDBearerType; - } - else if(bearerType == KUidHSCSDBearerType) //High speed GSM - { - parameters.iBearerType = KUidHSCSDBearerType; - } - else if(bearerType == KUidEmbeddedDestination) - { - parameters.iBearerType = KUidEmbeddedDestination; - } - else// if(bearerType == KPluginVPNBearerTypeUid) - { - parameters.iBearerType = KPluginVPNBearerTypeUid; - } - /* In random mode skipping LAN type - else// if(bearerType == KUidLanBearerType) - { - iBearerType = KUidLanBearerType; - }*/ - - CleanupStack::PopAndDestroy(); // supportedBearers - } - -void CCreatorConnectionSettings::SetRandomParametersL(CConnectionSettingsParameters& parameters) - { - LOGSTRING("Creator: CCreatorConnectionSettings::SetRandomParametersL"); - - // Connection method name: - parameters.SetRandomCMNameL(*iEngine); - - SetRandomBearerTypeL(parameters); - - if(parameters.iBearerType == KUidWlanBearerType)//Wireless LAN - { - // WLAN name: - parameters.SetRandomWLANNameL(*iEngine); - - //WLAN network mode - parameters.SetRandomWLANNetModeL(*iEngine); - - //WLAN security mode: - parameters.SetRandomWLANSecurityModeL(*iEngine); - } - - // Login name: - parameters.SetRandomLoginNameL(*iEngine); - - // Login password: - parameters.SetRandomLoginPassL(*iEngine); - - // Secure authentication: - parameters.SetRandomSecureAuthenticationL(*iEngine); - - // Prompt password: - parameters.SetRandomPromptPasswordL(*iEngine); - - // Use proxy: - parameters.SetRandomUseProxyL(*iEngine); - - // Proxy address - parameters.SetRandomProxyAddressL(*iEngine); - - // Proxy port number: - parameters.SetRandomProxyPortL(*iEngine); - - // Start page: - parameters.SetRandomStartPageL(*iEngine); - - // IP address: - parameters.SetRandomIPAddressL(*iEngine); - - // IPv4 name servers: - parameters.SetRandomIP4NameServer1L(*iEngine); - parameters.SetRandomIP4NameServer2L(*iEngine); - - // Protocol type: - parameters.SetRandomProtocolTypeL(*iEngine); - - // Default telephone number: - parameters.SetRandomTelephoneNumberL(*iEngine); - - // Bearer isdn - parameters.SetRandomBearerTypeIsdnL(*iEngine); - - // Bearer speed: - parameters.SetRandomBearerSpeedL(*iEngine); - - // WAP wsp option: - parameters.SetRandomWapWspOptionL(*iEngine); - - // Subnet mask: - parameters.SetRandomSubnetMaskL(*iEngine); - - // Gateway address: - parameters.SetRandomGatewayAddressL(*iEngine); - - // WLAN ip address: - parameters.SetRandomWlanIpAddrL(*iEngine); - - // IPv6 name servers: - parameters.SetRandomIPv6NameServer1L(*iEngine); - parameters.SetRandomIPv6NameServer2L(*iEngine); - - // Disable text authorization: - parameters.SetRandomDisableTextAuthL(*iEngine); - } - -//---------------------------------------------------------------------------- - -void CCreatorConnectionSettings::SetDefaultCML(RCmConnectionMethodExt conMethod) - { - LOGSTRING("Creator: CCreatorConnectionSettings::SetDefaultCM"); - - TCmDefConnValue defConnValue; - - //Returns the default connection method/SNAP. - TRAPD( err, iCmManagerExt.ReadDefConnL( defConnValue ) ); - if( err == KErrNotSupported ) - { - return; //If Default Connection NOT supported, just returning - } - else if ( err != KErrNone ) - { - User::Leave( err ); //If something else happend - } - else if ( defConnValue.iId == 0 ) // default not set - { - TCmDefConnValue newDefaultCM; - HBufC* cmName = conMethod.GetStringAttributeL( ECmName ); - CleanupStack::PushL( cmName ); - newDefaultCM.iId = AccessPointNameToIdL( cmName->Des() ); - newDefaultCM.iType = ECmDefConnDestination; - //Stores the default connection method/SNAP. - iCmManagerExt.WriteDefConnL( newDefaultCM ); - CleanupStack::PopAndDestroy( cmName ); - } - } - -//---------------------------------------------------------------------------- - -TUint32 CCreatorConnectionSettings::AccessPointNameToIdL(const TDesC& aAPName, - TBool aAnyIfNotFound ) - { - LOGSTRING("Creator: CCreatorConnectionSettings::AccessPointNameToIdL"); - - //RCmDestination destination - - RArray destIdArray = RArray( 10 ); - - iCmManagerExt.AllDestinationsL( destIdArray ); - - CleanupClosePushL( destIdArray ); - TUint32 id = 0 ; - TBool found = EFalse; - - for( TInt i = 0; i < destIdArray.Count(); i++ ) - { - RCmDestinationExt dest = iCmManagerExt.DestinationL( destIdArray[i] ); - CleanupClosePushL( dest ); - - HBufC* destName = dest.NameLC(); - - if (destName->CompareF(aAPName) == 0){ - id = dest.Id(); - found = ETrue; - } - if ( !found && id == 0 && aAnyIfNotFound ) - { - id = dest.Id(); - } - CleanupStack::PopAndDestroy( 2 ); // destName , dest - if(found) - { - break; - } - } - - CleanupStack::PopAndDestroy(); // destIdArray - return id; - } - -//---------------------------------------------------------------------------- - -void CCreatorConnectionSettings::HandleSessionEventL(TMsvSessionEvent /*aEvent*/, TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/) // from MMsvSessionObserver - { - LOGSTRING("Creator: CCreatorConnectionSettings::HandleSessionEventL"); - } - -//---------------------------------------------------------------------------- -void CCreatorConnectionSettings::DeleteAllL() - { - LOGSTRING("Creator: CCreatorConnectionSettings::DeleteAllL"); - DeleteAllDestinationsL( EFalse ); - } - -//---------------------------------------------------------------------------- -void CCreatorConnectionSettings::DeleteAllCreatedByCreatorL() - { - LOGSTRING("Creator: CCreatorConnectionSettings::DeleteAllCreatedByCreatorL"); - iEntryIds.Reset(); - - // fetch ids of entries created by Creator - iEngine->ReadEntryIdsFromStoreL( iEntryIds, KUidDictionaryUidIAP ); - - // delete entries - DeleteAllDestinationsL( ETrue ); - } - -//---------------------------------------------------------------------------- - -void CCreatorConnectionSettings::DeleteAllDestinationsL( TBool aOnlyCreatedWithCreator ) - { - LOGSTRING("Creator: CCreatorConnectionSettings::DeleteAllDestinationsL"); - RArray destIdArray(5); - CleanupClosePushL( destIdArray ); - iCmManagerExt.AllDestinationsL( destIdArray ); - - for( TInt i = 0; i < destIdArray.Count(); i++ ) - { - TRAP_IGNORE - ( - RCmDestinationExt dest = iCmManagerExt.DestinationL( destIdArray[i] ); - CleanupClosePushL( dest ); - - if ( !aOnlyCreatedWithCreator || iEntryIds.Find( destIdArray[i]) != KErrNotFound ) - { - dest.DeleteLD(); - } - CleanupStack::PopAndDestroy(); // dest - ); - } - - CleanupStack::PopAndDestroy(); // destIdArray - - // reset must be done here, because iEntryIds is stored in destructor - iEntryIds.Reset(); - - // all entries deleted, remove the IMPS related registry - iEngine->RemoveStoreL( KUidDictionaryUidIAP ); - } -//---------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/src/creator_connectionmethodelement.cpp --- a/creator/engine/src/creator_connectionmethodelement.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,333 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#include "engine.h" -#include "enginewrapper.h" -#include "creator_connectionmethodelement.h" -#include "creator_traces.h" -//#include "creator_accesspoint.h" - - -using namespace creatorconnectionmethod; - -// connection name needs extra space for possible renaming -const TInt KExtraSpace = 10; - -/* - * - */ -CCreatorConnectionMethodElement* CCreatorConnectionMethodElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext ) - { - CCreatorConnectionMethodElement* self = new (ELeave) CCreatorConnectionMethodElement(aEngine); - CleanupStack::PushL(self); - self->ConstructL(aName, aContext); - CleanupStack::Pop(self); - return self; - } -/* - * - */ -CCreatorConnectionMethodElement::CCreatorConnectionMethodElement(CCreatorEngine* aEngine) -: -CCreatorScriptElement(aEngine) - { - iIsCommandElement = ETrue; - } - -void CCreatorConnectionMethodElement::ExecuteCommandL() - { - const CCreatorScriptAttribute* amountAttr = FindAttributeByName(KAmount); - TInt cmAmount = 1; - if( amountAttr ) - { - cmAmount = ConvertStrToIntL(amountAttr->Value()); - } - // Get 'fields' element - CCreatorScriptElement* fieldsElement = FindSubElement(KFields); - if( fieldsElement ) - { - // Get sub-elements - const RPointerArray& fields = fieldsElement->SubElements(); - // Create connection method entries, the amount of entries is defined by cmAmount: - for( TInt cI = 0; cI < cmAmount; ++cI ) - { - CAccessPointsParameters* param = new (ELeave) CAccessPointsParameters; - CleanupStack::PushL(param); - - for( TInt i = 0; i < fields.Count(); ++i ) - { - CCreatorScriptElement* field = fields[i]; - TPtrC elemName = field->Name(); - TPtrC elemContent = field->Content(); - const CCreatorScriptAttribute* randomAttr = fields[i]->FindAttributeByName(KRandomLength); - TBool useRandom = EFalse; - if( randomAttr || elemContent.Length() == 0 ) - { - useRandom = ETrue; - } - - if( elemName == Kconnectionname ) - { - if( useRandom ) - { - param->SetRandomCMNameL(*iEngine); - } - else - { - SetContentToTextParamL(param->iConnectionName, elemContent); - // reserve extra space for possible renaming - TInt newLen = param->iConnectionName->Length() + KExtraSpace; - param->iConnectionName = param->iConnectionName->ReAllocL(newLen); - - SetContentToTextParamL(param->iGprsAcessPointName, elemContent); - } - } - else if( elemName == Kstartpage ) - { - if( useRandom ) - { - param->SetRandomStartPageL(*iEngine); - } - else - { - SetContentToTextParamL(param->iWapStartPage, elemContent); - } - } - else if( elemName == Kwapwspoption ) - { - if( useRandom ) - { - param->SetRandomWapWspOptionL(*iEngine); - } - else - { - if( CompareIgnoreCase(elemContent, Kconnectionless) == 0 ) - { - param->iWapWspOption = EWapWspOptionConnectionless; - } - else if( CompareIgnoreCase(elemContent, Kconnectionoriented) == 0 ) - { - param->iWapWspOption = EWapWspOptionConnectionOriented; - } - } - } - else if( elemName == Kloginname ) - { - if( useRandom ) - { - param->SetRandomLoginNameL(*iEngine); - } - else - { - SetContentToTextParamL(param->iIspLoginName, elemContent); - } - } - else if( elemName == Ksecureauthentication ) - { - if( useRandom ) - { - param->SetRandomSecureAuthenticationL(*iEngine); - } - else - { - param->iSecureAuthentication = ConvertStrToBooleanL(elemContent); - } - } - else if( elemName == Kloginpass ) - { - if( useRandom ) - { - param->SetRandomLoginPassL(*iEngine); - } - else - { - SetContentToTextParamL(param->iIspLoginPass, elemContent); - } - } - else if( elemName == Kpromptpassword ) - { - if( useRandom ) - { - param->SetRandomPromptPasswordL(*iEngine); - } - else - { - param->iPromptPassword = ConvertStrToBooleanL(elemContent); - } - } - else if( elemName == Kgatewayaddress ) - { - if( useRandom ) - { - param->SetRandomGatewayAddressL(*iEngine); - } - else - { - SetContentToTextParamL(param->iWapGatewayAddress, elemContent); - } - } - else if( elemName == Kdeviceipaddr ) - { - if( useRandom ) - { - param->SetRandomIPAddressL(*iEngine); - } - else - { - SetContentToTextParamL(param->iIspIPAddr, elemContent); - } - } - else if( elemName == Kip4nameserver1 ) - { - if( useRandom ) - { - param->SetRandomIP4NameServer1L(*iEngine); - } - else - { - SetContentToTextParamL(param->iIspIPNameServer1, elemContent); - } - } - else if( elemName == Kip4nameserver2 ) - { - if( useRandom ) - { - param->SetRandomIP4NameServer2L(*iEngine); - } - else - { - SetContentToTextParamL(param->iIspIPNameServer2, elemContent); - } - } - else if( elemName == Kdatacalltelnumber ) - { - if( useRandom ) - { - param->SetRandomTelephoneNumberL(*iEngine); - } - else - { - SetContentToTextParamL(param->iIspDefaultTelNumber, elemContent); - } - } - else if( elemName == Kdatacalltypeisdn ) - { - if( useRandom ) - { - param->SetRandomBearerTypeIsdnL(*iEngine); - } - else - { - if( CompareIgnoreCase(elemContent, Kanalogue) == 0 ) - param->iIspBearerCallTypeIsdn = ECallTypeAnalogue; - else if( CompareIgnoreCase( elemContent, Kisdnv110) == 0 ) - param->iIspBearerCallTypeIsdn = ECallTypeISDNv110; - else if( CompareIgnoreCase( elemContent, Kisdnv120) == 0 ) - param->iIspBearerCallTypeIsdn = ECallTypeISDNv120; - } - } - else if( elemName == Kbearertype ) - { - if( useRandom ) - { - param->iBearerType = EApBearerTypeGPRS; - } - else - { - if( CompareIgnoreCase(elemContent, Kwlan) == 0 ) - { - param->iBearerType = EApBearerTypeWLAN; - } - else if( CompareIgnoreCase(elemContent, Kgprs) == 0 ) - { - param->iBearerType = EApBearerTypeGPRS; - } - else if( CompareIgnoreCase(elemContent, Kdatacall) == 0 ) - { - param->iBearerType = EApBearerTypeCSD; - } - else if( CompareIgnoreCase(elemContent, Khsgsm) == 0 ) - { - param->iBearerType = EApBearerTypeHSCSD; - } - else if( CompareIgnoreCase(elemContent, Klan) == 0 ) - { - param->iBearerType = EApBearerTypeLAN; - } - } - } - else if( elemName == Kdatacalllinespeed ) - { - if( useRandom ) - { - param->SetRandomBearerSpeedL(*iEngine); - } - else - { - if( CompareIgnoreCase(elemContent, Kautomatic) == 0 ) - { - param->iIspBearerSpeed = KSpeedAutobaud; - } - else - { - TUint lineSpeed = ConvertStrToUintL(elemContent); - if( lineSpeed == 9600 ) - param->iIspBearerSpeed = KSpeed9600; - else if( lineSpeed == 14400 ) - param->iIspBearerSpeed = KSpeed14400; - else if( lineSpeed == 19200 ) - param->iIspBearerSpeed = KSpeed19200; - else if( lineSpeed == 28800 ) - param->iIspBearerSpeed = KSpeed28800; - else if( lineSpeed == 38400 ) - param->iIspBearerSpeed = KSpeed38400; - else if( lineSpeed == 43200 ) - param->iIspBearerSpeed = KSpeed43200; - else if( lineSpeed == 56000 ) - param->iIspBearerSpeed = KSpeed56000; - } - } - } - else if( elemName == Kproxyserveraddress ) - { - if( useRandom ) - { - param->SetRandomProxyAddressL(*iEngine); - } - else - { - SetContentToTextParamL(param->iProxyServerAddress, elemContent); - } - } - else if( elemName == Kproxyportnumber ) - { - if( useRandom ) - { - param->SetRandomProxyPortL(*iEngine); - } - else - { - param->iProxyPortNumber = ConvertStrToUintL(elemContent); - } - } - } - iEngine->AppendToCommandArrayL(ECmdCreateMiscEntryAccessPoints, param); - CleanupStack::Pop(); // param - } - } - } diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/src/creator_contactelement.cpp --- a/creator/engine/src/creator_contactelement.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,401 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - -#include "creator_contactelement.h" -#include "creator_traces.h" -#include "creator_phonebook.h" -#include "creator_factory.h" -#include "creator_contactsetcache.h" -#include -#include - -using namespace Xml; -using namespace creatorcontact; - -/** - * Contact field element mappings: - */ -enum TContactFieldDataType - { - EDataTypeText, - EDataTypeBinary, - EDataTypeDateTime - }; - -class FieldMapping -{ -public: - TPtrC iElementName; - TInt iFieldCode; - TContactFieldDataType iDataType; -}; -FieldMapping fieldMappingTbl[] = { - {TPtrC(KFirstname), CCreatorPhonebookWrapper::EFirstName, EDataTypeText}, - {TPtrC(KLastname), CCreatorPhonebookWrapper::ELastName, EDataTypeText}, - {TPtrC(KFirstnameReading), CCreatorPhonebookWrapper::EFirstNameReading, EDataTypeText}, - {TPtrC(KLastnameReading), CCreatorPhonebookWrapper::ELastNameReading, EDataTypeText}, - {TPtrC(KPrefix), CCreatorPhonebookWrapper::EPrefix, EDataTypeText}, - {TPtrC(KSuffix), CCreatorPhonebookWrapper::ESuffix, EDataTypeText}, - {TPtrC(KSecondname), CCreatorPhonebookWrapper::ESecondName, EDataTypeText}, - {TPtrC(KLandphoneHome), CCreatorPhonebookWrapper::ELandPhoneHome, EDataTypeText}, - - {TPtrC(KMobilephoneHome), CCreatorPhonebookWrapper::EMobilePhoneHome, EDataTypeText}, - {TPtrC(KVideonumberHome), CCreatorPhonebookWrapper::EVideoNumberHome, EDataTypeText}, - {TPtrC(KFaxnumberHome), CCreatorPhonebookWrapper::EFaxNumberHome, EDataTypeText}, - {TPtrC(KVoipHome), CCreatorPhonebookWrapper::EVoipHome, EDataTypeText}, - {TPtrC(KEmailHome), CCreatorPhonebookWrapper::EEmailHome, EDataTypeText}, - {TPtrC(KUrlHome), CCreatorPhonebookWrapper::EUrlHome, EDataTypeText}, - {TPtrC(KAddrlabelHome), CCreatorPhonebookWrapper::EAddrLabelHome, EDataTypeText}, - {TPtrC(KAddrpoHome), CCreatorPhonebookWrapper::EAddrPoHome, EDataTypeText}, - - {TPtrC(KAddrextHome), CCreatorPhonebookWrapper::EAddrExtHome, EDataTypeText}, - {TPtrC(KAddrstreetHome), CCreatorPhonebookWrapper::EAddrStreetHome, EDataTypeText}, - {TPtrC(KAddrlocalHome), CCreatorPhonebookWrapper::EAddrLocalHome, EDataTypeText}, - {TPtrC(KAddrregionHome), CCreatorPhonebookWrapper::EAddrRegionHome, EDataTypeText}, - {TPtrC(KAddrpostcodeHome), CCreatorPhonebookWrapper::EAddrPostCodeHome, EDataTypeText}, - {TPtrC(KAddrcountryHome), CCreatorPhonebookWrapper::EAddrCountryHome, EDataTypeText}, - {TPtrC(KJobtitle), CCreatorPhonebookWrapper::EJobTitle, EDataTypeText}, - {TPtrC(KCompanyname), CCreatorPhonebookWrapper::ECompanyName, EDataTypeText}, - - {TPtrC(KLandphoneWork), CCreatorPhonebookWrapper::ELandPhoneWork, EDataTypeText}, - {TPtrC(KMobilephoneWork), CCreatorPhonebookWrapper::EMobilePhoneWork, EDataTypeText}, - {TPtrC(KVideonumberWork), CCreatorPhonebookWrapper::EVideoNumberWork, EDataTypeText}, - {TPtrC(KFaxnumberWork), CCreatorPhonebookWrapper::EFaxNumberWork, EDataTypeText}, - {TPtrC(KVoipWork), CCreatorPhonebookWrapper::EVoipWork, EDataTypeText}, - {TPtrC(KEmailWork), CCreatorPhonebookWrapper::EEmailWork, EDataTypeText}, - {TPtrC(KUrlWork), CCreatorPhonebookWrapper::EUrlWork, EDataTypeText}, - {TPtrC(KAddrlabelWork), CCreatorPhonebookWrapper::EAddrLabelWork, EDataTypeText}, - - {TPtrC(KAddrpoWork), CCreatorPhonebookWrapper::EAddrPoWork, EDataTypeText}, - {TPtrC(KAddrextWork), CCreatorPhonebookWrapper::EAddrExtWork, EDataTypeText}, - {TPtrC(KAddrstreetWork), CCreatorPhonebookWrapper::EAddrStreetWork, EDataTypeText}, - {TPtrC(KAddrlocalWork), CCreatorPhonebookWrapper::EAddrLocalWork, EDataTypeText}, - {TPtrC(KAddrregionWork), CCreatorPhonebookWrapper::EAddrRegionWork, EDataTypeText}, - {TPtrC(KAddrpostcodeWork), CCreatorPhonebookWrapper::EAddrPostCodeWork, EDataTypeText}, - {TPtrC(KAddrcountryWork), CCreatorPhonebookWrapper::EAddrCountryWork, EDataTypeText}, - {TPtrC(KLandphoneGen), CCreatorPhonebookWrapper::ELandPhoneGen, EDataTypeText}, - - {TPtrC(KMobilephoneGen), CCreatorPhonebookWrapper::EMobilePhoneGen, EDataTypeText}, - {TPtrC(KVideonumberGen), CCreatorPhonebookWrapper::EVideoNumberGen, EDataTypeText}, - {TPtrC(KFaxnumberGen), CCreatorPhonebookWrapper::EFaxNumberGen, EDataTypeText}, - {TPtrC(KVoipGen), CCreatorPhonebookWrapper::EVoipGen, EDataTypeText}, - {TPtrC(KPoc), CCreatorPhonebookWrapper::EPoc, EDataTypeText}, - {TPtrC(KSwis), CCreatorPhonebookWrapper::ESwis, EDataTypeText}, - {TPtrC(KSip), CCreatorPhonebookWrapper::ESip, EDataTypeText}, - {TPtrC(KEmailGen), CCreatorPhonebookWrapper::EEmailGen, EDataTypeText}, - - {TPtrC(KUrlGen), CCreatorPhonebookWrapper::EUrlGen, EDataTypeText}, - {TPtrC(KAddrlabelGen), CCreatorPhonebookWrapper::EAddrLabelGen, EDataTypeText}, - {TPtrC(KAddrpoGen), CCreatorPhonebookWrapper::EAddrPoGen, EDataTypeText}, - {TPtrC(KAddrextGen), CCreatorPhonebookWrapper::EAddrExtGen, EDataTypeText}, - {TPtrC(KAddrstreetGen), CCreatorPhonebookWrapper::EAddrStreetGen, EDataTypeText}, - {TPtrC(KAddrlocalGen), CCreatorPhonebookWrapper::EAddrLocalGen, EDataTypeText}, - {TPtrC(KAddrregionGen), CCreatorPhonebookWrapper::EAddrRegionGen, EDataTypeText}, - {TPtrC(KAddrpostcodeGen), CCreatorPhonebookWrapper::EAddrPostCodeGen, EDataTypeText}, - - {TPtrC(KAddrcountryGen), CCreatorPhonebookWrapper::EAddrCountryGen, EDataTypeText}, - {TPtrC(KPagerNumber), CCreatorPhonebookWrapper::EPagerNumber, EDataTypeText}, - {TPtrC(KDtmfString), CCreatorPhonebookWrapper::EDtmfString, EDataTypeText}, - {TPtrC(KWvAddress), CCreatorPhonebookWrapper::EWVAddress, EDataTypeText}, - {TPtrC(KDate), CCreatorPhonebookWrapper::EDate, EDataTypeDateTime}, - {TPtrC(KNote), CCreatorPhonebookWrapper::ENote, EDataTypeText}, - {TPtrC(KThumbnailPath), CCreatorPhonebookWrapper::EThumbnailPic, EDataTypeText}, - {TPtrC(KThumbnailId), CCreatorPhonebookWrapper::EThumbnailPic, EDataTypeText}, - {TPtrC(KRingTone), CCreatorPhonebookWrapper::ERingTone, EDataTypeText}, - {TPtrC(KRingToneId), CCreatorPhonebookWrapper::ERingTone, EDataTypeText}, - - {TPtrC(KCallerobjImg), CCreatorPhonebookWrapper::ECallerObjImg, EDataTypeText}, - {TPtrC(KCallerobjText), CCreatorPhonebookWrapper::ECallerObjText, EDataTypeText}, - {TPtrC(KMiddlename), CCreatorPhonebookWrapper::EMiddleName, EDataTypeText}, - {TPtrC(KDepartment), CCreatorPhonebookWrapper::EDepartment, EDataTypeText}, - {TPtrC(KAsstname), CCreatorPhonebookWrapper::EAsstName, EDataTypeText}, - {TPtrC(KSpouse), CCreatorPhonebookWrapper::ESpouse, EDataTypeText}, - {TPtrC(KChildren), CCreatorPhonebookWrapper::EChildren, EDataTypeText}, - {TPtrC(KAsstphone), CCreatorPhonebookWrapper::EAsstPhone, EDataTypeText}, - - {TPtrC(KCarphone), CCreatorPhonebookWrapper::ECarPhone, EDataTypeText}, - {TPtrC(KAnniversary), CCreatorPhonebookWrapper::EAnniversary, EDataTypeDateTime}, - {TPtrC(KSyncclass), CCreatorPhonebookWrapper::ESyncClass, EDataTypeText}, - {TPtrC(KLocPrivacy), CCreatorPhonebookWrapper::ELocPrivacy, EDataTypeText}, - {TPtrC(KGenlabel), CCreatorPhonebookWrapper::EGenLabel, EDataTypeText} -}; - -//********************************************************************************* - -CCreatorContactElementBase* CCreatorContactElementBase::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext) - { - LOGSTRING("Creator: CCreatorContactElementBase::NewL"); - CCreatorContactElementBase* self = new (ELeave) CCreatorContactElementBase(aEngine); - CleanupStack::PushL(self); - self->ConstructL(aName, aContext); - CleanupStack::Pop(); - return self; - } -CCreatorContactElementBase::CCreatorContactElementBase(CCreatorEngine* aEngine) : CCreatorScriptElement(aEngine) - { } - -CCreatorContactElement* CCreatorContactElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext) - { - LOGSTRING("Creator: CCreatorContactElement::NewL"); - CCreatorContactElement* self = new (ELeave) CCreatorContactElement(aEngine); - CleanupStack::PushL(self); - self->ConstructL(aName, aContext); - CleanupStack::Pop(); - return self; - } -CCreatorContactElement::CCreatorContactElement(CCreatorEngine* aEngine) -: -CCreatorContactElementBase(aEngine) - { - iIsCommandElement = ETrue; - } - - -void CCreatorContactElement::ExecuteCommandL() - { - LOGSTRING("Creator: CCreatorContactElement::ExecuteCommandL"); - // Find out how many contacts should we create: - const CCreatorScriptAttribute* contactAmountAttr = this->FindAttributeByName(KAmount); - TInt contactAmount = 1; - if( contactAmountAttr ) - { - contactAmount = ConvertStrToIntL(contactAmountAttr->Value()); - } - CCreatorScriptElement* fieldsElement = FindSubElement(KFields); - TInt fieldMappingTblSize = sizeof(fieldMappingTbl)/sizeof(FieldMapping); - for( TInt cI = 0; cI < contactAmount; ++cI ) - { - CPhonebookParameters* param = (CPhonebookParameters*) TCreatorFactory::CreatePhoneBookParametersL(); - CleanupStack::PushL(param); - // Loop all the field elements - if( fieldsElement && fieldsElement->SubElements().Count() > 0 ) - { - - const RPointerArray& fieldList = fieldsElement->SubElements(); - - if( fieldList.Count() == 0 ) - { - - } - for( TInt i = 0; i < fieldList.Count(); ++i ) - { - TPtrC fieldName = fieldList[i]->Name(); - //const CCreatorScriptAttribute* amountAttr = fieldList[i]->FindAttributeByName(KAmount); - //const CCreatorScriptAttribute* rndLenAttr = fieldList[i]->FindAttributeByName(KRandomLength); - //const CCreatorScriptAttribute* increaseAttr = fieldList[i]->FindAttributeByName(KIncrease); - //TBool increase( EFalse ); - //if ( increaseAttr ) - // { - // increase = ConvertStrToBooleanL( increaseAttr->Value() ); - // } - for( TInt j = 0; j < fieldMappingTblSize; ++j ) - { - const FieldMapping& mapping = fieldMappingTbl[j]; - if( fieldName == mapping.iElementName ) - { - TPtrC content = fieldList[i]->Content(); - -// MCreatorRandomDataField::TRandomLengthType randomLenType = MCreatorRandomDataField::ERandomLengthUndefined; - - if( content == TPtrC(KEmpty) || content == TPtrC(KNullDesC) ) - { - CCreatorContactField* field = CCreatorContactField::NewL(); - CleanupStack::PushL(field); - field->AddFieldToParamL( iEngine,param, mapping.iFieldCode, KErrNotFound ); - CleanupStack::Pop(field); - } - else - { - CCreatorContactField* field = CCreatorContactField::NewL(); - CleanupStack::PushL(field); - field->AddFieldToParamL( param, mapping.iFieldCode, content ); - CleanupStack::Pop(field); - } - - - break; - - } - } - - } - } - else - { - // No fields specified, so add all fields with random content: - for( TInt i = 0; i < fieldMappingTblSize; ++i ) - { - if( fieldMappingTbl[i].iElementName == KThumbnailId || - fieldMappingTbl[i].iElementName == KRingToneId ) - { - // Skip thumbnail and ringtone IDs, since they are duplicates with thumbnailpath and ringtonepath - continue; - } - CCreatorContactField* field = CCreatorContactField::NewL(); - CleanupStack::PushL(field); - field->AddFieldToParamL( iEngine,param, fieldMappingTbl[i].iFieldCode, KErrNotFound ); - CleanupStack::Pop(field); - } - - } - iEngine->AppendToCommandArrayL(ECmdCreatePhoneBookEntryContacts, param); - iParameters.AppendL(param); // Save the pointer to the parametes. - CleanupStack::Pop(param); - } - } - - -/* -void CCreatorContactElement::ExecuteCommandL() - {} -*/ -CCreatorContactSetElement* CCreatorContactSetElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext) - { - LOGSTRING("Creator: CCreatorContactSetElement::NewL"); - CCreatorContactSetElement* self = new (ELeave) CCreatorContactSetElement(aEngine); - CleanupStack::PushL(self); - self->ConstructL(aName, aContext); - CleanupStack::Pop(); - return self; - } -CCreatorContactSetElement::CCreatorContactSetElement(CCreatorEngine* aEngine) -: -CCreatorContactElementBase(aEngine) - { } - -void CCreatorContactSetElement::ExecuteCommandL() - { } - -void CCreatorContactSetElement::AddToCacheL() - { - LOGSTRING("Creator: CCreatorContactSetElement::AddToCacheL"); - const CCreatorScriptAttribute* linkIdAttr = this->FindAttributeByName(KId); - const CCreatorScriptAttribute* existingElemsAttr = this->FindAttributeByName(KExistingContacts); - TInt numOfExistingContacts = 0; - if( existingElemsAttr ) - { - numOfExistingContacts = ConvertStrToIntL(existingElemsAttr->Value()); - } - if( linkIdAttr ) - { - TInt linkId = ConvertStrToIntL(linkIdAttr->Value()); - if( linkId > 0 ) - { - CCreatorContactSet* newSet = CCreatorContactSet::NewL(linkId, numOfExistingContacts); - CleanupStack::PushL(newSet); - ContactLinkCache::Instance()->AppendL(newSet); - CleanupStack::Pop(newSet); - - // Mark sub-elements (i.e. contacts) to this contact-set: - for( TInt i = 0; i < iSubElements.Count(); ++i ) - { - for( TInt j = 0; j < iSubElements[i]->CommandParameters().Count(); ++j) - { - CCreatorModuleBaseParameters* params = iSubElements[i]->CommandParameters()[j]; - if( params ) - { - params->SetScriptLinkId(linkId); - } - } - } - } - } - } - -CCreatorContactGroupElement* CCreatorContactGroupElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext) - { - LOGSTRING("Creator: CCreatorContactGroupElement::NewL"); - CCreatorContactGroupElement* self = new (ELeave) CCreatorContactGroupElement(aEngine); - CleanupStack::PushL(self); - self->ConstructL(aName, aContext); - CleanupStack::Pop(); - return self; - } -CCreatorContactGroupElement::CCreatorContactGroupElement(CCreatorEngine* aEngine) -: -CCreatorContactElementBase(aEngine) - { - iIsCommandElement = ETrue; - } - - -void CCreatorContactGroupElement::ExecuteCommandL() - { - LOGSTRING("Creator: CCreatorContactGroupElement::ExecuteCommandL"); - // Get attributes (amount and name) - const CCreatorScriptAttribute* groupAmountAttr = this->FindAttributeByName(KAmount); - const CCreatorScriptAttribute* groupNameAttr = this->FindAttributeByName(KName); - // How many groups to create: - TInt groupAmount = 1; - if( groupAmountAttr ) - { - groupAmount = ConvertStrToIntL(groupAmountAttr->Value()); - } - - for( TInt i = 0; i < groupAmount; ++i ) - { - CCreatorScriptElement* membersElement = FindSubElement(KMembers); - - if( membersElement ) - { - CPhonebookParameters* param = (CPhonebookParameters*) TCreatorFactory::CreatePhoneBookParametersL(); - CleanupStack::PushL(param); - - // Links to contact-sets: - const RPointerArray& linkList = membersElement->SubElements(); - if( linkList.Count() > 0 ) - { - for( TInt i = 0; i < linkList.Count(); ++i ) - { - AppendContactSetReferenceL(*linkList[i], param->iLinkIds); - } - } - - if( groupNameAttr ) - { - param->iGroupName->Des().Copy( groupNameAttr->Value() ); - } - else - { - param->iGroupName->Des().Copy( iEngine->RandomString(CCreatorEngine::EGroupName) ); - } - iEngine->AppendToCommandArrayL(ECmdCreatePhoneBookEntryGroups, param); - CleanupStack::Pop(param); - } - } - } - -/* -void CCreatorContactGroupElement::ExecuteCommandL() - {} -*/ -CCreatorContactFieldElement* CCreatorContactFieldElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext) - { - LOGSTRING("Creator: CCreatorContactFieldElement::NewL"); - CCreatorContactFieldElement* self = new (ELeave) CCreatorContactFieldElement(aEngine); - CleanupStack::PushL(self); - self->ConstructL(aName, aContext); - CleanupStack::Pop(); - return self; - } - -CCreatorContactFieldElement::CCreatorContactFieldElement(CCreatorEngine* aEngine) -: -CCreatorScriptElement(aEngine) - { } diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/src/creator_contactsetcache.cpp --- a/creator/engine/src/creator_contactsetcache.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,218 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - -#include "creator_contactsetcache.h" - - -CContactLinkCacheImp* ContactLinkCache::iImp = 0; - -CCreatorContactSet* CCreatorContactSet::NewL(TInt aLinkId, TInt aNumOfExistingContacts) - { - return new (ELeave) CCreatorContactSet(aLinkId, aNumOfExistingContacts); - } - -TInt CCreatorContactSet::LinkId() const - { - return iLinkId; - } - -void CCreatorContactSet::AppendL(TUint32 aContactLink) - { - iContactLinks.AppendL(aContactLink); - } - -RArray CCreatorContactSet::ContactLinks() - { - return iContactLinks; - } - -const RArray CCreatorContactSet::ContactLinks() const - { - return iContactLinks; - } - - -TInt CCreatorContactSet::NumberOfExistingContacts() const - { - return iNumOfExistingContacts; - } - -CCreatorContactSet::~CCreatorContactSet() - { - iContactLinks.Reset(); - iContactLinks.Close(); - } - - -CCreatorContactSet::CCreatorContactSet(TInt aLinkId, TInt aNumOfExistingContacts) - { - iLinkId = aLinkId; - iNumOfExistingContacts = aNumOfExistingContacts; - } - -class CContactLinkCacheImp : public CBase, public MContactLinkCache -{ -public: - static CContactLinkCacheImp* NewL(); - virtual ~CContactLinkCacheImp(); - virtual void AppendL(CCreatorContactSet* aContactSet); - - virtual RArray ContactLinks(TInt aLinkId); - virtual const RArray ContactLinks(TInt aLinkId) const; - - virtual RPointerArray& ContactSets(); - virtual const RPointerArray& ContactSets() const; - virtual const CCreatorContactSet& ContactSet(TInt aLinkId) const; - virtual CCreatorContactSet& ContactSet(TInt aLinkId); - -private: - void ConstructL(); - CContactLinkCacheImp(); - - RArray iEmptyLinks; - - RPointerArray iContactSets; - CCreatorContactSet* iDummyContactSet; -}; - -CContactLinkCacheImp* CContactLinkCacheImp::NewL() - { - CContactLinkCacheImp* self = new (ELeave) CContactLinkCacheImp(); - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(); - return self; - } - -void CContactLinkCacheImp::ConstructL() - { - if( iDummyContactSet == 0 ) - iDummyContactSet = CCreatorContactSet::NewL(-1, 0); - } - -CContactLinkCacheImp::CContactLinkCacheImp() -: iDummyContactSet(0) - {} - -CContactLinkCacheImp::~CContactLinkCacheImp() - { - iEmptyLinks.Reset();// just in case... - iEmptyLinks.Close(); - - iContactSets.ResetAndDestroy(); - iContactSets.Close(); - delete iDummyContactSet; - } -void CContactLinkCacheImp::AppendL(CCreatorContactSet* aContactSet) - { - iContactSets.AppendL(aContactSet); - } -RArray CContactLinkCacheImp::ContactLinks(TInt aLinkId) - { - for( TInt i = 0; i < iContactSets.Count(); ++i ) - { - if( iContactSets[i]->LinkId() == aLinkId ) - { - return iContactSets[i]->ContactLinks(); - } - } - return iEmptyLinks; - } - -const RArray CContactLinkCacheImp::ContactLinks(TInt aLinkId) const - { - for( TInt i = 0; i < iContactSets.Count(); ++i ) - { - if( iContactSets[i]->LinkId() == aLinkId ) - { - return iContactSets[i]->ContactLinks(); - } - } - return iEmptyLinks; - } - - -const CCreatorContactSet& CContactLinkCacheImp::ContactSet(TInt aLinkId) const - { - for( TInt i = 0; i < iContactSets.Count(); ++i ) - { - if( iContactSets[i]->LinkId() == aLinkId ) - { - return *iContactSets[i]; - } - } - - return *iDummyContactSet; - } - -CCreatorContactSet& CContactLinkCacheImp::ContactSet(TInt aLinkId) - { - for( TInt i = 0; i < iContactSets.Count(); ++i ) - { - if( iContactSets[i]->LinkId() == aLinkId ) - { - return *iContactSets[i]; - } - } - - return *iDummyContactSet; - } - -RPointerArray& CContactLinkCacheImp::ContactSets() - { - return iContactSets; - } - -const RPointerArray& CContactLinkCacheImp::ContactSets() const - { - return iContactSets; - } - - -void ContactLinkCache::InitializeL() - { - if( iImp == 0 ) - { - iImp = CContactLinkCacheImp::NewL(); - } - } - -void ContactLinkCache::DestroyL() - { - delete iImp; - iImp = 0; - } - -MContactLinkCache* ContactLinkCache::Instance() - { - return iImp; - } - - - /*{ -public: - static void ; - static void DestructLD(); - - static MContactLinkCache* Instance(); - -private: - CContactLinkImp* iImp; -};*/ - diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/src/creator_factory.cpp --- a/creator/engine/src/creator_factory.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#include "engine.h" -#include "creator_factory.h" - -//#include "creator_accesspoint.h" -#include "creator_phonebook.h" - -CCreatorPhonebookBase* TCreatorFactory::CreatePhoneBookL(CCreatorEngine* aEngine) -{ - return CCreatorPhonebook::NewL(aEngine); -} - -CCreatorModuleBaseParameters* TCreatorFactory::CreatePhoneBookParametersL() - { - return new(ELeave) CPhonebookParameters; - } -/* -CCreatorConnectionSettingsBase* TCreatorFactory::CreateConnectionSettingsL(CCreatorEngine* aEngine) -{ - return CCreatorAccessPoints::NewL(aEngine); -} - -CCreatorModuleBaseParameters* TCreatorFactory::CreateConnectionSettingsParametersL() - { - return new(ELeave) CAccessPointsParameters; - } -*/ diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/src/creator_file.cpp --- a/creator/engine/src/creator_file.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,829 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#include "engine.h" -#include "enginewrapper.h" -#include "creator_file.h" -#include "creator_traces.h" - -using namespace ContentAccess; - -static const TInt KFilesFieldLength = 256; - -//_LIT(KCreatorFilesPrefixName, "CR_"); -//_LIT(KCreatorFilesPrefixFolderName, "CR_FLDR_"); - -//---------------------------------------------------------------------------- - -CFilesParameters::CFilesParameters() - { - LOGSTRING("Creator: CFilesParameters::CFilesParameters"); - iFullFilePath = HBufC::New(KFilesFieldLength); - } - -CFilesParameters::CFilesParameters( CFilesParameters& aCopy ) - { - LOGSTRING("Creator: CFilesParameters::CFilesParameters"); - iFullFilePath = HBufC::New(KFilesFieldLength); - iFullFilePath->Des().Copy( *aCopy.iFullFilePath ); - iFileCommand = aCopy.iFileCommand; - iEncrypt = aCopy.iEncrypt; - if ( aCopy.iPermission ) - { - TRAP_IGNORE( - iPermission = CDRMPermission::NewL(); - iPermission->DuplicateL( *aCopy.iPermission ); - ); - } - } - -CFilesParameters::~CFilesParameters() - { - LOGSTRING("Creator: CFilesParameters::~CFilesParameters"); - delete iFullFilePath; - delete iPermission; - } - -//---------------------------------------------------------------------------- - -CCreatorFiles* CCreatorFiles::NewL(CCreatorEngine* aEngine) - { - CCreatorFiles* self = CCreatorFiles::NewLC(aEngine); - CleanupStack::Pop(self); - return self; - } - -CCreatorFiles* CCreatorFiles::NewLC(CCreatorEngine* aEngine) - { - CCreatorFiles* self = new (ELeave) CCreatorFiles; - CleanupStack::PushL(self); - self->ConstructL(aEngine); - return self; - } - -CCreatorFiles::CCreatorFiles() : - iFs ( CEikonEnv::Static()->FsSession() ) - { - } - -void CCreatorFiles::ConstructL(CCreatorEngine* aEngine) - { - LOGSTRING("Creator: CCreatorFiles::ConstructL"); - - iEngine = aEngine; - - User::LeaveIfError( iApaLs.Connect() ); - - iFilePaths = new (ELeave) CDesCArrayFlat( 4 ); - - // Restore file id - CDictionaryFileStore* store = iEngine->FileStoreLC(); - User::LeaveIfNull( store ); - if ( store->IsPresentL( KUidDictionaryUidFiles ) ) - { - RDictionaryReadStream in; - in.OpenLC( *store, KUidDictionaryUidFiles ); - TRAPD( err, iFileId = in.ReadInt32L() ); - if ( err ) - { - iFileId = 1; - } - CleanupStack::PopAndDestroy(); // in - } - else - { - iFileId = 1; - } - CleanupStack::PopAndDestroy( store ); - } - -CCreatorFiles::~CCreatorFiles() - { - LOGSTRING("Creator: CCreatorFiles::~CCreatorFiles"); - - // this is done only once per file operation: - if ( iFilePaths && iFilePaths->Count() ) - { - TRAP_IGNORE( StorePathsForDeleteL( *iFilePaths ) ); - } - delete iFilePaths; - delete iParameters; - delete iUserParameters; - iApaLs.Close(); - } - -//---------------------------------------------------------------------------- - -void CCreatorFiles::QueryDialogClosedL(TBool aPositiveAction, TInt aUserData) - { - LOGSTRING("Creator: CCreatorFiles::QueryDialogClosedL"); - - if( aPositiveAction == EFalse ) - { - iEngine->ShutDownEnginesL(); - return; - } - - const TDesC* showText = &KSavingText; - TBool finished(EFalse); - TBool retval(ETrue); - switch(aUserData) - { - case ECreatorFilesDelete: - showText = &KDeletingText; - iEntriesToBeCreated = 1; - finished = ETrue; - break; - case ECreatorFilesStart: - { - // set a default directory (eg. c:\Nokia\Images\) - iEngine->SetDefaultPathForFileCommandL(iCommand, iDirectoryQueriedFromUser); - TBuf<50> promptText; - if (iCommand == ECmdCreateFileEntryEmptyFolder) - promptText.Copy( _L("Specify the folder path and name") ); - else - promptText.Copy( _L("Specify the directory") ); - - // show directory query dialog - retval = iEngine->GetEngineWrapper()->DirectoryQueryDialog(promptText, iDirectoryQueriedFromUser, this, ECreatorFilesGetDirectory ); - } - break; - case ECreatorFilesGetDirectory: - // check that the root folder is correct - if ( iDirectoryQueriedFromUser.Length() < 3 || BaflUtils::CheckFolder( iFs, iDirectoryQueriedFromUser.Left(3) ) != KErrNone ) - { - iEngine->GetEngineWrapper()->ShowErrorMessage(_L("Invalid path")); - retval = EFalse; - } - else - { - // check the directory contains a trailing backlash - if ( iDirectoryQueriedFromUser.Right(1) != _L("\\") ) - { - iDirectoryQueriedFromUser.Append(_L("\\")); - } - // copy the directory name to a class member - if ( iCommand == ECmdCreateFileEntryEmptyFolder ) - { - finished = ETrue; - } - else - { - retval = AskDRMDataFromUserL(); - } - } - break; - case ECreatorFilesAskDRMData: - if ( iDummy > 0 ) - { - iUserParameters->iEncrypt = ETrue; - } - if ( iDummy == 2 ) - { - iUserParameters->iPermission = CDRMPermission::NewL(); - CDRMPermission* perm = iUserParameters->iPermission; - perm->iTopLevel->iActiveConstraints = EConstraintNone; - perm->iPlay->iActiveConstraints = EConstraintNone; - perm->iDisplay->iActiveConstraints = EConstraintNone; - perm->iPrint->iActiveConstraints = EConstraintNone; - perm->iExecute->iActiveConstraints = EConstraintNone; - perm->iUniqueID = 0; - // DRM Combined Delivery - iDummy = 0; - retval = iEngine->GetEngineWrapper()->EntriesQueryDialog( &iDummy, _L("How many counts(0=unlimited)?"), ETrue, this, ECreatorFilesAskDRM_CD_Counts ); - } - else - { - finished = ETrue; - } - break; - case ECreatorFilesAskDRM_CD_Counts: - if ( iDummy > 0 ) - { - TInt count = iDummy; - CDRMPermission* perm = iUserParameters->iPermission; - // apply constraints to all permission types - // applied type will be selected by setting iAvailableRights - // when determining the file type - perm->iDisplay->iActiveConstraints |= EConstraintCounter; - perm->iDisplay->iCounter = count; - perm->iDisplay->iOriginalCounter = count; - - perm->iPlay->iActiveConstraints |= EConstraintCounter; - perm->iPlay->iCounter = count; - perm->iPlay->iOriginalCounter = count; - - perm->iPrint->iActiveConstraints |= EConstraintCounter; - perm->iPrint->iCounter = count; - perm->iPrint->iOriginalCounter = count; - - perm->iExecute->iActiveConstraints |= EConstraintCounter; - perm->iExecute->iCounter = count; - perm->iExecute->iOriginalCounter = count; - } - iDummy = 0; - retval = iEngine->GetEngineWrapper()->EntriesQueryDialog( &iDummy, _L("How many minutes until expire(0=unlimited)?"), ETrue, - this, ECreatorFilesAskDRM_CD_Minutes - ); - break; - case ECreatorFilesAskDRM_CD_Minutes: - if ( iDummy > 0 ) - { - TInt minutes = iDummy; - CDRMPermission* perm = iUserParameters->iPermission; - // apply constraints to all permission types - // applied type will be selected by setting iAvailableRights - // when determining the file type - perm->iDisplay->iActiveConstraints |= EConstraintInterval; - perm->iDisplay->iInterval = TTimeIntervalSeconds( 60 * minutes ); - perm->iDisplay->iIntervalStart = Time::NullTTime(); - - perm->iPlay->iActiveConstraints |= EConstraintInterval; - perm->iPlay->iInterval = TTimeIntervalSeconds( 60 * minutes ); - perm->iPlay->iIntervalStart = Time::NullTTime(); - - perm->iPrint->iActiveConstraints |= EConstraintInterval; - perm->iPrint->iInterval = TTimeIntervalSeconds( 60 * minutes ); - perm->iPrint->iIntervalStart = Time::NullTTime(); - - perm->iExecute->iActiveConstraints |= EConstraintInterval; - perm->iExecute->iInterval = TTimeIntervalSeconds( 60 * minutes ); - perm->iExecute->iIntervalStart = Time::NullTTime(); - } - finished = ETrue; - break; - default: - //some error - retval = EFalse; - break; - } - if( retval == EFalse ) - { - iEngine->ShutDownEnginesL(); - } - else if( finished ) - { - // add this command to command array - iEngine->AppendToCommandArrayL(iCommand, NULL, iEntriesToBeCreated); - // started exucuting commands - iEngine->ExecuteFirstCommandL( *showText ); - } - } - -//---------------------------------------------------------------------------- - -TBool CCreatorFiles::AskDataFromUserL(TInt aCommand) - { - LOGSTRING("Creator: CCreatorFiles::AskDataFromUserL"); - - CCreatorModuleBase::AskDataFromUserL( aCommand ); - - if ( aCommand == ECmdDeleteCreatorFiles ) - { - return iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all files created with Creator?"), this, ECreatorFilesDelete ); - } - - delete iUserParameters; - iUserParameters = NULL; - iUserParameters = new(ELeave) CFilesParameters(); - - iDirectoryQueriedFromUser.Copy( KNullDesC ); - - return iEngine->GetEngineWrapper()->EntriesQueryDialog(&iEntriesToBeCreated, _L("How many entries to create?"), EFalse, this, ECreatorFilesStart ); - } - - -//---------------------------------------------------------------------------- - -TInt CCreatorFiles::CreateFileEntryL(CFilesParameters *aParameters, TInt aCommand) - { - LOGSTRING("Creator: CCreatorFiles::CreateFileEntryL"); - - // clear any existing parameter definations - delete iParameters; - iParameters = NULL; - TFileName directoryToBeCreated; - - CFilesParameters* parameters = aParameters; - - if (!parameters) - { - if ( iUserParameters ) - { - iParameters = new (ELeave) CFilesParameters( *iUserParameters ); - // iUserParameters = NULL; - } - else - { - // random data needed if no predefined data available - iParameters = new (ELeave) CFilesParameters; - } - parameters = iParameters; - } - - TInt err = KErrNone; - - // if we just create directories - if ( aCommand == ECmdCreateFileEntryEmptyFolder) - { - // strip the last backslash from the path - if( iDirectoryQueriedFromUser.Length() > 0) - directoryToBeCreated = iDirectoryQueriedFromUser; - else if( parameters->iFullFilePath && parameters->iFullFilePath->Des().Length() > 0 ) - directoryToBeCreated = parameters->iFullFilePath->Des(); - else - return err; - - _LIT(KSlash, "\\"); - if( directoryToBeCreated.Right(1) == KSlash ) - directoryToBeCreated.SetLength ( directoryToBeCreated.Length() - 1 ); - - // generate a unique file name - err = CApaApplication::GenerateFileName( iFs, directoryToBeCreated); - if (err != KErrNone) - return err; - - // now append the backslah back - directoryToBeCreated.Append( _L("\\") ); - - // now create the new directory - err = iFs.MkDirAll( directoryToBeCreated ); - - // Add directoryToBeCreated to store - iFilePaths->AppendL( directoryToBeCreated ); - - LOGSTRING3("Creator: CCreatorFiles::CreateFileEntryL creating empty directory %S returns err", &directoryToBeCreated, err); - } - - else // files - { - LOGSTRING2("Creator: CCreatorFiles::CreateFileEntryL file id is %d", aCommand); - - // get source - TFileName fullSourcePath; - switch (aCommand) - { - case ECmdCreateFileEntryJPEG_25kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EJPEG_25kB ); break; } - case ECmdCreateFileEntryJPEG_200kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EJPEG_200kB ); break; } - case ECmdCreateFileEntryJPEG_500kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EJPEG_500kB ); break; } - case ECmdCreateFileEntryPNG_15kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EPNG_15kB ); break; } - case ECmdCreateFileEntryGIF_2kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EGIF_2kB ); break; } - case ECmdCreateFileEntryRNG_1kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::ERNG_1kB ); break; } - case ECmdCreateFileEntryMIDI_10kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EMIDI_10kB ); break; } - case ECmdCreateFileEntryWAV_20kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EWAVE_20kB ); break; } - case ECmdCreateFileEntryAMR_20kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EAMR_20kB ); break; } - case ECmdCreateFileEntryXLS_15kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EExcel_15kB ); break; } - case ECmdCreateFileEntryDOC_20kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EWord_20kB ); break; } - case ECmdCreateFileEntryPPT_40kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EPowerPoint_40kB ); break; } - case ECmdCreateFileEntryTXT_10kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EText_10kB ); break; } - case ECmdCreateFileEntryTXT_70kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EText_70kB ); break; } - case ECmdCreateFileEntry3GPP_70kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::E3GPP_70kB ); break; } - case ECmdCreateFileEntryMP3_250kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EMP3_250kB ); break; } - case ECmdCreateFileEntryAAC_100kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EAAC_100kB ); break; } - case ECmdCreateFileEntryRM_95kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::ERM_95kB ); break; } - case ECmdCreateFileEntryBMP_25kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EBMP_25kB ); break; } - case ECmdCreateFileEntryDeck_1kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::ESavedDeck_1kB ); break; } - case ECmdCreateFileEntryHTML_20kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EHTML_20kB ); break; } - case ECmdCreateFileEntryJAD_1kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EJAD_1kB ); break; } - case ECmdCreateFileEntryJAR_10kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EJAR_10kB ); break; } - case ECmdCreateFileEntryJP2_65kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EJP2_65kB ); break; } - case ECmdCreateFileEntryMP4_200kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EMP4_200kB ); break; } - case ECmdCreateFileEntryMXMF_40kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EMXMF_40kB ); break; } - case ECmdCreateFileEntryRAM_1kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::ERAM_1kB ); break; } - case ECmdCreateFileEntrySVG_15kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::ESVG_15kB ); break; } - case ECmdCreateFileEntrySWF_15kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::ESWF_15kB ); break; } - case ECmdCreateFileEntryTIF_25kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::ETIF_25kB ); break; } - case ECmdCreateFileEntryVCF_1kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EVCF_1kB ); break; } - case ECmdCreateFileEntryVCS_1kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EVCS_1kB ); break; } - case ECmdCreateFileEntrySISX_10kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::ESISX_10kB ); break; } - case ECmdCreateFileEntryWMA_50kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EWMA_50kB ); break; } - case ECmdCreateFileEntryWMV_200kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EWMV_200kB ); break; } - case ECmdCreateFileEntryEmptyFolder: { User::Panic(_L("EmptyFolder"), 801); break; } - default: { return KErrPathNotFound; } - } - - - // define the full target path - TFileName fullTargetPath; - - if ( parameters->iFullFilePath && parameters->iFullFilePath->Des().Length() > 3 ) - { - _LIT(KSlash, "\\"); - // check the path is ok - fullTargetPath = parameters->iFullFilePath->Des(); - - if(fullTargetPath.Right(1) == KSlash) - { - // Remove '\' from the end, because the filename check does not work with it: - fullTargetPath.SetLength ( fullTargetPath.Length() - 1 ); - } - - if (!iFs.IsValidName( fullTargetPath )) - User::Leave(KErrBadName); - - // target path = directory + the file name from source path - TParse parser; - parser.Set(fullSourcePath, NULL, NULL); - - // Add '\' to the end: - fullTargetPath.Append(KSlash); - // Add filename: - fullTargetPath.Append( parser.NameAndExt() ); - - LOGSTRING2("Creator: CCreatorFiles::CreateFileEntryL iFullFilePath used, fullTargetPath: %S", &fullTargetPath); - } - - else if ( iDirectoryQueriedFromUser.Length() > 0 ) - { - // target path = directory + the file name from source path - TParse parser; - parser.Set(fullSourcePath, NULL, NULL); - - fullTargetPath = iDirectoryQueriedFromUser; - fullTargetPath.Append( parser.NameAndExt() ); - - LOGSTRING2("Creator: CCreatorFiles::CreateFileEntryL iDirectoryQueriedFromUser used, fullTargetPath: %S", &fullTargetPath); - } - - else - { - LOGSTRING("Creator: CCreatorFiles::CreateFileEntryL leaving with KErrPathNotFound"); - User::Leave(KErrPathNotFound); - } - - TBool encrypt = parameters->iEncrypt; - if ( encrypt ) fullTargetPath.Append( KOma2DcfExtension ); - // check the target path has a unique filename ie we won't overwrite existing files - // also generates any missing directories - if ( BaflUtils::FileExists( iFs, fullTargetPath ) ) - { - GenerateFileNameL( fullTargetPath ); - } - User::LeaveIfError(CApaApplication::GenerateFileName( iFs, fullTargetPath ) ); - - if ( encrypt ) - { - EncryptFileL( fullSourcePath, fullTargetPath, parameters ); - } - else - { - // copy the file (synchronous function) - err = BaflUtils::CopyFile(iFs, fullSourcePath, fullTargetPath); - LOGSTRING4("Creator: CCreatorFiles::CreateFileEntryL copy %S to %S, err=%d", &fullSourcePath, &fullTargetPath, err); - } - - if (err != KErrNone) - User::Leave(err); // leave because copying failed - - // Add fullTargetPath to store - iFilePaths->AppendL( fullTargetPath ); - - // make sure that the file won't have a read only attribute - TEntry fileEntry; - iFs.Entry(fullTargetPath, fileEntry); - iFs.SetEntry(fullTargetPath, fileEntry.iModified, NULL, KEntryAttReadOnly); - - // clear variables - parameters->iFullFilePath->Des().Copy ( KNullDesC ); - } - - return err; - } - -//---------------------------------------------------------------------------- - -void CCreatorFiles::EncryptFileL( const TDesC& aInFileName, const TDesC& aOutFileName, CFilesParameters *aParameters ) - { - LOGSTRING("Creator: CCreatorFiles::EncryptFileL"); - TBuf8<64> mime; - SetMimeTypeL( aInFileName, mime, aParameters ); - CSupplier* supplier = CSupplier::NewLC(); - - CMetaDataArray* metaData = CMetaDataArray::NewLC(); - - // Tell the agent which MIME type to use for the encrypted data - metaData->AddL( KOmaImportMimeTypeField, mime ); - - if ( aParameters && aParameters->iPermission ) - { - // Combined Delivery file will be created - SetPermissionsL( metaData, aOutFileName, aParameters ); - } - - supplier->SetOutputDirectoryL( iDirectoryQueriedFromUser ); - - // The KOmaImportContentType is a OMA DRM agent specific MIME type which - // indicates that plain content is to be encrypted - CImportFile* importFile = supplier->ImportFileL( KOmaImportContentType, - *metaData, - aOutFileName ); - CleanupStack::PushL( importFile ); - - // Peek the source file size: - TInt fileLen( 0 ); - RFile file; - User::LeaveIfError( file.Open( iFs, aInFileName, EFileRead ) ); - CleanupClosePushL( file ); - User::LeaveIfError( file.Size( fileLen ) ); - CleanupStack::PopAndDestroy( &file ); - - // Read the source file to inmemory buffer - RFileReadStream rs; - User::LeaveIfError( rs.Open( iFs, - aInFileName, - EFileStream | EFileRead ) ); - CleanupClosePushL( rs ); - HBufC8* fileBuf = HBufC8::NewLC( fileLen ); - TPtr8 p = fileBuf->Des(); - rs.ReadL( p, fileLen ); - - // Start encryption - TInt err = importFile->WriteData( p ); - if ( err == KErrCANewFileHandleRequired ) - { - RFile file; - User::LeaveIfError( file.Create( iFs, aOutFileName, EFileWrite ) ); - CleanupClosePushL( file ); - User::LeaveIfError( importFile->ContinueWithNewOutputFile( file, aOutFileName ) ); - CleanupStack::PopAndDestroy( &file ); - } - else - { - User::LeaveIfError( err ); - } - User::LeaveIfError( importFile->WriteDataComplete() ); - CleanupStack::PopAndDestroy( fileBuf ); - CleanupStack::PopAndDestroy( &rs ); - CleanupStack::PopAndDestroy( importFile ); - CleanupStack::PopAndDestroy( metaData ); - CleanupStack::PopAndDestroy( supplier ); - } - -//---------------------------------------------------------------------------- - -void CCreatorFiles::SetPermissionsL( CMetaDataArray* aMetaData, const TDesC& aOutFileName, CFilesParameters *aParameters ) - { - LOGSTRING("Creator: CCreatorFiles::SetPermissionsL"); - CDRMRights* rights = CDRMRights::NewL(); - CleanupStack::PushL( rights ); - - HBufC8* cnturi = HBufC8::NewL( KMaxFileName ); - cnturi->Des().Copy( aOutFileName ); - - CDRMAsset* asset = CDRMAsset::NewLC(); - asset->iUid = cnturi; - // Set the asset to the rights class, it will duplicate the asset - rights->SetAssetL( *asset ); - CleanupStack::PopAndDestroy( asset ); - - rights->SetPermissionL( *aParameters->iPermission ); - - // Construct externalized presentation of the rights object - TInt rightsSize = 1024 *100; - HBufC8* rightBuf = HBufC8::NewLC( rightsSize ); - TPtr8 bptr = rightBuf->Des(); - bptr.SetLength( rightsSize ); - RMemWriteStream iWriteStream; - iWriteStream.Open( (TAny*)(rightBuf->Ptr() ), rightsSize ); - CleanupClosePushL( iWriteStream ); - iWriteStream << *rights; - iWriteStream.CommitL(); - TPtr8 rp = rightBuf->Des(); - - // Add rights to metadata - aMetaData->AddL( KOmaImportRightsField, rp ); - CleanupStack::PopAndDestroy( &iWriteStream ); - CleanupStack::PopAndDestroy( rightBuf ); - CleanupStack::PopAndDestroy( rights ); - } - -//---------------------------------------------------------------------------- - -void CCreatorFiles::SetMimeTypeL( const TDesC& aFileName, TDes8& aMime, CFilesParameters *aParameters ) - { - LOGSTRING("Creator: CCreatorFiles::SetMimeTypeL"); - TUid appUid; - TDataType dataType; - User::LeaveIfError( iApaLs.AppForDocument( aFileName, appUid, dataType ) ); - if ( dataType.Des().Length() ) - { - aMime.Copy( dataType.Des() ); - } - else - { - // set default mime, because it was not recognized by iApaLs - aMime.Copy( _L("text/plain") ); - } - - // set DRM permissions according the type of the file - if ( aParameters->iPermission ) - { - if ( dataType.Des().FindF( _L("image") ) > KErrNotFound ) - { - aParameters->iPermission->iAvailableRights = ERightsDisplay | ERightsPrint; - } - else if ( dataType.Des().FindF( _L("audio") ) > KErrNotFound || - dataType.Des().FindF( _L("video") ) > KErrNotFound || - dataType.Des().FindF( _L("tone") ) > KErrNotFound || // e.g. application/vnd.nokia.ringing-tone - dataType.Des().FindF( _L("realmedia") ) > KErrNotFound ) - { - // media files - aParameters->iPermission->iAvailableRights = ERightsPlay; - } - else if ( dataType.Des().FindF( _L("archive") ) > KErrNotFound || - dataType.Des().FindF( _L("x-sis") ) > KErrNotFound ) - { - // application/java-archive - // x-epoc/x-sisx-app - aParameters->iPermission->iAvailableRights = ERightsExecute; - } - else if ( dataType.Des().FindF( _L("application") ) > KErrNotFound || - dataType.Des().FindF( _L("text") ) > KErrNotFound ) - { - // application/msexcel - // application/msword - // text/plain - // etc. - aParameters->iPermission->iAvailableRights = ERightsDisplay | ERightsPrint; - } - else - { - // other filetype - aParameters->iPermission->iAvailableRights = ERightsDisplay; - } - } - } - -//---------------------------------------------------------------------------- - -TBool CCreatorFiles::AskDRMDataFromUserL() - { - LOGSTRING("Creator: CCreatorFiles::AskDRMDataFromUserL"); - // Encryption -dialog - CDesCArrayFlat* items = new(ELeave) CDesCArrayFlat(5); - CleanupStack::PushL(items); - - // Add entires to list - items->AppendL( _L("None") ); - items->AppendL( _L("DRM Forward Lock") ); - items->AppendL( _L("DRM Combined Delivery") ); - - - // create a popup list - iDummy = 0; - TBool retval = iEngine->GetEngineWrapper()->PopupListDialog(_L("Encryption"), items, &iDummy, this, ECreatorFilesAskDRMData ); - CleanupStack::PopAndDestroy( items ); - return retval; - } - -//---------------------------------------------------------------------------- -void CCreatorFiles::DeleteAllL() - { - LOGSTRING("Creator: CCreatorFiles::DeleteAllL"); - User::Leave( KErrNotSupported ); // will not be supported - } - -//---------------------------------------------------------------------------- -void CCreatorFiles::DeleteAllCreatedByCreatorL() - { - LOGSTRING("Creator: CCreatorFiles::DeleteAllCreatedByCreatorL"); - iFileId = 1; - CDictionaryFileStore* store = iEngine->FileStoreLC(); - User::LeaveIfNull( store ); - - if ( store->IsPresentL( KUidDictionaryUidFiles ) ) - { - RDictionaryReadStream in; - in.OpenLC( *store, KUidDictionaryUidFiles ); - CFileMan* fileMan = CFileMan::NewL( iFs ); - CleanupStack::PushL( fileMan ); - TFileName fullPath; - // ignore return value, don't update iFileId here: - TRAPD( err, in.ReadInt32L() ); - while ( !err ) - { - TInt len( KErrNotFound ); - TRAP( err, len = in.ReadInt8L() ); // will leave with KErrEof - if ( !err ) - { - TRAP( err, in.ReadL( fullPath, len ) ); - } - if ( !err ) - { - TEntry fileEntry; - iFs.Entry( fullPath, fileEntry ); - if ( fileEntry.IsDir() ) - { - fileMan->RmDir( fullPath ); // ignore return value - } - else - { - iFs.Delete( fullPath ); // ignore return value - } - } - } - CleanupStack::PopAndDestroy( fileMan ); - CleanupStack::PopAndDestroy( &in ); - - // files deleted, remove the Creator internal file registry - store->Remove( KUidDictionaryUidFiles ); - store->CommitL(); - } - CleanupStack::PopAndDestroy( store ); - } - -//---------------------------------------------------------------------------- -void CCreatorFiles::StorePathsForDeleteL( CDesCArray& aPaths ) - { - LOGSTRING("Creator: CCreatorFiles::StorePathsForDeleteL"); - CDictionaryFileStore* store = iEngine->FileStoreLC(); - User::LeaveIfNull( store ); - - // backup previous filepaths from store - // otherwise they would be overwritten when calling out.WriteL - CDesCArray* previousPaths = new (ELeave) CDesCArrayFlat( 4 ); - CleanupStack::PushL( previousPaths ); - - TFileName fullPath; - - if ( store->IsPresentL( KUidDictionaryUidFiles ) ) - { - RDictionaryReadStream in; - in.OpenLC( *store, KUidDictionaryUidFiles ); - // ignore return value, don't update iFileId here: - TRAPD( err, in.ReadInt32L() ); - while ( !err ) - { - TRAP( err, - TInt len = in.ReadInt8L(); // will leave with KErrEof - in.ReadL( fullPath, len ); - previousPaths->AppendL( fullPath ); - ); - } - CleanupStack::PopAndDestroy(); // in - } - - RDictionaryWriteStream out; - out.AssignLC( *store, KUidDictionaryUidFiles ); - - // write latest file id to store - out.WriteInt32L( iFileId ); - - // restore previous paths to store - for ( TInt i = 0; i < previousPaths->Count(); i++ ) - { - out.WriteInt8L( (*previousPaths)[i].Length() ); - out.WriteL( (*previousPaths)[i] ); - } - - // write new paths to store - for ( TInt i = 0; i < aPaths.Count(); i++ ) - { - out.WriteInt8L( aPaths[i].Length() ); - out.WriteL( aPaths[i] ); - } - - out.CommitL(); - CleanupStack::PopAndDestroy(); // out - - store->CommitL(); - CleanupStack::PopAndDestroy( previousPaths ); - CleanupStack::PopAndDestroy( store ); - } - -//---------------------------------------------------------------------------- -void CCreatorFiles::GenerateFileNameL( TFileName& aRootName ) - { - LOGSTRING("Creator: CCreatorFiles::GenerateFileNameL"); - if ( iFileId ) - { - TBuf<16> extension; - if ( iFileId < 10 ) - { - extension.Format( _L("(0%d)"), iFileId ); - } - else - { - extension.Format( _L("(%d)"), iFileId ); - } - aRootName.Insert( aRootName.Locate( '.' ), extension ); - } - iFileId++; - } - -// End of file diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/src/creator_fileelement.cpp --- a/creator/engine/src/creator_fileelement.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,316 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - -#include "creator_fileelement.h" -#include -#include -#include "creator_traces.h" -#include "creator_file.h" - -using namespace creatorfile; - -// 15 minutes per time zone, 60 seconds per minute -const TInt KSecondsPerTimeZone = 900; -const TInt KMinuteInMicroseconds = 60000000; -const TInt KTimeZoneIncrement = 15; - -/* - * - */ -CCreatorFileElement* CCreatorFileElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext ) - { - CCreatorFileElement* self = new (ELeave) CCreatorFileElement(aEngine); - CleanupStack::PushL(self); - self->ConstructL(aName, aContext); - CleanupStack::Pop(self); - return self; - } -/* - * - */ -CCreatorFileElement::CCreatorFileElement(CCreatorEngine* aEngine) -: -CCreatorScriptElement(aEngine) - { - iIsCommandElement = ETrue; - - TTime currUniversal; - TTime currLocal; - TInt64 result( 0 ); - currUniversal.UniversalTime(); - currLocal.HomeTime(); - result = currLocal.Int64() - currUniversal.Int64(); - result /= KMinuteInMicroseconds; - result /= KTimeZoneIncrement; - iTimeZone = I64INT( result ); - } -/* - * - */ -void CCreatorFileElement::ExecuteCommandL() - { - const CCreatorScriptAttribute* amountAttr = FindAttributeByName(KAmount); - TInt fileAmount = 1; - if( amountAttr ) - { - fileAmount = ConvertStrToIntL(amountAttr->Value()); - } - // Get 'fields' element - CCreatorScriptElement* fieldsElement = FindSubElement(KFields); - if( fieldsElement && fieldsElement->SubElements().Count() > 0) - { - // Get sub-elements - const RPointerArray& fields = fieldsElement->SubElements(); - // Create files, the amount of files is defined by fileAmount: - for( TInt cI = 0; cI < fileAmount; ++cI ) - { - CFilesParameters* param = new (ELeave) CFilesParameters; - CleanupStack::PushL( param ); - - for( TInt i = 0; i < fields.Count(); ++i ) - { - CCreatorScriptElement* field = fields[i]; - TPtrC elemName = field->Name(); - TPtrC elemContent = field->Content(); - - const CCreatorScriptAttribute* randomAttr = field->FindAttributeByName( KRandomLength ); - - if( elemName == KType ) - { - param->iFileCommand = GetFileCommandL(elemContent, randomAttr || elemContent.Length() == 0); - } - else if( elemName == KDirectory ) - { - delete param->iFullFilePath; - param->iFullFilePath = 0; - if( randomAttr == 0 && elemContent.Length() > 0 ) - { - param->iFullFilePath = elemContent.AllocL(); - } - else - { - TFileName defaultPath; - iEngine->SetDefaultPathForFileCommandL( param->iFileCommand, defaultPath ); - param->iFullFilePath = defaultPath.AllocL(); - } - } - else if ( elemName == KEncryption ) - { - ParseDRMElementsL( field, param ); - } - } - - if ( !param->iFileCommand ) - { - param->iFileCommand = ECmdCreateFileEntryEmptyFolder; - } - iEngine->AppendToCommandArrayL( param->iFileCommand, param); - CleanupStack::Pop( param ); - } - } - else - { - _LIT(KDummy, ""); - for( TInt cI = 0; cI < fileAmount; ++cI ) - { - CFilesParameters* param = new (ELeave) CFilesParameters; - CleanupStack::PushL(param); - delete param->iFullFilePath; - param->iFullFilePath = 0; - TFileName defaultPath; - param->iFileCommand = GetFileCommandL(KDummy, ETrue); - iEngine->SetDefaultPathForFileCommandL(param->iFileCommand, defaultPath); - param->iFullFilePath = defaultPath.AllocL(); - - iEngine->AppendToCommandArrayL(param->iFileCommand, param); - CleanupStack::Pop(param); - } - } - } - -TInt CCreatorFileElement::GetFileCommandL( const TDesC& aFileIdStr, TBool aRandom ) const - { - TInt mapCount = sizeof(FileMap) / sizeof(FileMapping); - - if( aRandom ) - { - return FileMap[iEngine->RandomNumber(0, mapCount-1)].CommandId(); - } - - for( TInt i = 0; i < mapCount; ++i ) - { - if( CompareIgnoreCase(FileMap[i].FileName(), aFileIdStr) == 0 ) - return FileMap[i].CommandId(); - } - LOGSTRING2("CCreatorFileElement::GetFileCommandL: Unknown file id: %S", &aFileIdStr); - User::Leave(KErrGeneral); - return 0; // Not reached, but disables compiler warning... - } - -void CCreatorFileElement::ParseDRMElementsL( CCreatorScriptElement* aField, CFilesParameters* aParam ) - { - const CCreatorScriptAttribute* encryptionTypeAttr = aField->FindAttributeByName( KType ); - if ( encryptionTypeAttr && encryptionTypeAttr->Value().Length() > 0 ) - { - aParam->iEncrypt = ETrue; - if ( encryptionTypeAttr->Value() == KDRMCD ) - { - delete aParam->iPermission; - aParam->iPermission = NULL; - // ownership transferred: - aParam->iPermission = CDRMPermission::NewL(); - } - else if ( encryptionTypeAttr->Value() != KDRMFL ) - { - // must be either KDRMCD or KDRMFL - User::Leave( KErrArgument ); - } - } - else - { - User::Leave( KErrArgument ); - } - - const RPointerArray& rights = aField->SubElements(); - - if ( encryptionTypeAttr->Value() == KDRMFL && rights.Count() ) - { - // Right definitions not allowed with DRM Forward Lock - // User::Leave( KErrArgument ); // Do not leave here - return; // Just omit rights definitions - } - - // parse right elements - CDRMPermission* drmPermission = aParam->iPermission; - for ( TInt r = 0; r < rights.Count(); r++ ) - { - const CCreatorScriptAttribute* rightAttr = rights[r]->FindAttributeByName( KType ); - if ( rightAttr->Value() == KDRMPlayRight && - !( drmPermission->iAvailableRights & ERightsPlay ) ) - { - drmPermission->iAvailableRights |= ERightsPlay; - ParseDRMConstraintsL( rights[r], drmPermission->iPlay ); - } - else if ( rightAttr->Value() == KDRMDisplayRight && - !( drmPermission->iAvailableRights & ERightsDisplay )) - { - drmPermission->iAvailableRights |= ERightsDisplay; - ParseDRMConstraintsL( rights[r], drmPermission->iDisplay ); - } - else if ( rightAttr->Value() == KDRMPrintRight && - !( drmPermission->iAvailableRights & ERightsPrint ) ) - { - drmPermission->iAvailableRights |= ERightsPrint; - ParseDRMConstraintsL( rights[r], drmPermission->iPrint ); - } - else if ( rightAttr->Value() == KDRMExecuteRight && - !( drmPermission->iAvailableRights & ERightsExecute ) ) - { - drmPermission->iAvailableRights |= ERightsExecute; - ParseDRMConstraintsL( rights[r], drmPermission->iExecute ); - } - } - } - -void CCreatorFileElement::ParseDRMConstraintsL( CCreatorScriptElement* aRight, CDRMConstraint* aConstraint ) - { - const RPointerArray& constraints = aRight->SubElements(); - for ( TInt c = 0; c < constraints.Count(); c++ ) - { - TPtrC elemName = constraints[c]->Name(); - TPtrC elemContent = constraints[c]->Content(); - if ( elemName == KDRMCount ) - { - TInt count = ConvertStrToIntL( elemContent ); - // apply count constraint - aConstraint->iActiveConstraints |= EConstraintCounter; - aConstraint->iCounter = count; - aConstraint->iOriginalCounter = count; - } - else if ( elemName == KDRMInterval ) - { - // apply interval constraint - aConstraint->iActiveConstraints |= EConstraintInterval; - aConstraint->iInterval = ParseTimeInterval( elemContent ); - aConstraint->iIntervalStart = Time::NullTTime(); - } - else if ( elemName == KDRMStartTime ) - { - // apply start time constraint - aConstraint->iActiveConstraints |= EConstraintStartTime; - TTimeIntervalSeconds offset( iTimeZone * KSecondsPerTimeZone ); - aConstraint->iStartTime = ConvertToDateTimeL( elemContent ) - offset; - } - else if ( elemName == KDRMEndTime ) - { - // apply end time constraint - aConstraint->iActiveConstraints |= EConstraintEndTime; - TTimeIntervalSeconds offset( iTimeZone * KSecondsPerTimeZone ); - aConstraint->iEndTime = ConvertToDateTimeL( elemContent ) - offset; - } - else if ( elemName == KDRMAccumulated ) - { - // apply accumulated time constraint - aConstraint->iActiveConstraints |= EConstraintAccumulated; - if ( aConstraint->iEndTime == Time::NullTTime() ) - { - aConstraint->iEndTime = Time::MaxTTime(); - } - if ( aConstraint->iStartTime == Time::NullTTime() ) - { - aConstraint->iStartTime = Time::MinTTime(); - } - aConstraint->iAccumulatedTime = ParseTimeInterval( elemContent ); - } - } - } - -TTimeIntervalSeconds CCreatorFileElement::ParseTimeInterval( TDesC& aTimeString ) - { - // Iso8601 format (P1Y2M3DT4H5M6S) to TimeIntervalSeconds - TLex lex; - TInt year = 0; - TInt month = 0; - TInt day = 0; - TInt hour = 0; - TInt minute = 0; - TInt second = 0; - - if (aTimeString.Length() > 0) - { - lex = aTimeString; - lex.Inc(); // skip 'P' - lex.Val(year); - lex.Inc(); - lex.Val(month); - lex.Inc(); - lex.Val(day); - lex.Inc(2); - lex.Val(hour); - lex.Inc(); - lex.Val(minute); - lex.Inc(); - lex.Val(second); - } - TTimeIntervalSeconds result( ( ( ( year * 365 + month * 30 + day ) * 24 + hour ) - * 60 + minute ) * 60 + second ); - return result; - } - -// End of file diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/src/creator_landmark.cpp --- a/creator/engine/src/creator_landmark.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,502 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#include -#include -#include - -#include "engine.h" -#include "enginewrapper.h" -#include "creator_landmark.h" -#include "creator_traces.h" - -_LIT(KAccommodation, "accommodation"); -_LIT(KBusiness, "business"); -_LIT(KCommunication, "communication"); -_LIT(KEducational, "educational"); -_LIT(KEntertainment, "entertainment"); -_LIT(KFoodAndBeverage, "food"); -_LIT(KGeographical, "geographical"); -_LIT(KOutdoor, "outdoor"); -_LIT(KPeople, "people"); -_LIT(KPublic, "public"); -_LIT(KReligious, "religious"); -_LIT(KShopping, "shopping"); -_LIT(KSightseeing, "sightseeing"); -_LIT(KSports, "sports"); -_LIT(KTransport, "transport"); - - -/** - * Class mapping the strings to global landmark categories - */ -class CategoryMapping -{ -public: - CategoryMapping(TUint aId, const TDesC& aCategoryStr) - : - iGlobalId(aId), - iStr(aCategoryStr) - {} - - TPosLmGlobalCategory iGlobalId; - const TDesC& iStr; -}; - -/** - * Global landmark categories - */ -CategoryMapping LandmarkCategories[] = { - CategoryMapping(3000, KAccommodation), // Accommodation - CategoryMapping(6000, KBusiness), // Business - CategoryMapping(9000, KCommunication), // Communication - CategoryMapping(12000, KEducational), // Educational institute - CategoryMapping(15000, KEntertainment), // Entertainment - CategoryMapping(18000, KFoodAndBeverage), // Food & Beverage - CategoryMapping(21000, KGeographical), // Geographical area - CategoryMapping(24000, KOutdoor), // Outdoor activities - CategoryMapping(27000, KPeople), // People - CategoryMapping(30000, KPublic), // Public service - CategoryMapping(33000, KReligious), // Religious places - CategoryMapping(36000, KShopping), // Shopping - CategoryMapping(39000, KSightseeing), // Sightseeing - CategoryMapping(42000, KSports), // Sports - CategoryMapping(45000, KTransport) // Transport -}; - -/** - * Return landmark global id - */ -TPosLmGlobalCategory CCreatorLandmarks::GetCategoryIdL(const TDesC& aCategoryStr) - { - TUint numOfCategories = sizeof(LandmarkCategories)/sizeof(CategoryMapping); - for( TUint i = 0; i < numOfCategories; ++i ) - { - if( LandmarkCategories[i].iStr == aCategoryStr ) - return LandmarkCategories[i].iGlobalId; - } - - return 0; - } - -/** - * - */ -CLandmarkParameters::CLandmarkParameters() - { - LOGSTRING("Creator: CLandmarkParameters::CLandmarkParameters"); - } - -/** - * - */ -CLandmarkParameters::~CLandmarkParameters() - { - LOGSTRING("Creator: CLandmarkParameters::~CLandmarkParameters"); - delete iName; - delete iStreet; - delete iCity; - delete iState; - delete iCountry; - delete iPostCode; - delete iDescription; - delete iPhonenumber; - delete iUrl; - iCategories.Close(); - } - -/** - * - */ -void CLandmarkParameters::SetRandomNameL(CCreatorEngine& aEngine) - { - TPtrC name(aEngine.RandomString(CCreatorEngine::ELandmarkName)); - delete iName; - iName = 0; - iName = HBufC::NewL(name.Length()); - iName->Des().Copy(name); - } - -/** - * - */ -void CLandmarkParameters::SetRandomUrlL(CCreatorEngine& aEngine) - { - _LIT(KUrlPrefix, "http://www."); - _LIT(KUrlPostfix, ".com"); - TPtrC company(aEngine.RandomString(CCreatorEngine::ECompany)); - delete iUrl; - iUrl = 0; - iUrl = HBufC::NewL(KUrlPrefix().Length()+company.Length()+KUrlPostfix().Length()); - iUrl->Des() = KUrlPrefix; - iUrl->Des().Append( company ); - iUrl->Des().Append( KUrlPostfix ); - } - -/** - * - */ -void CLandmarkParameters::AddRandomCategoryL(CCreatorEngine& aEngine) - { - TUint numOfCategories = sizeof(LandmarkCategories)/sizeof(CategoryMapping); - iCategories.AppendL(LandmarkCategories[aEngine.RandomNumber(0, numOfCategories-1)].iGlobalId); - } - -/** - * - */ -void CLandmarkParameters::SetRandomStreetL(CCreatorEngine& aEngine) - { - TPtrC street(aEngine.RandomString(CCreatorEngine::EAddress)); - delete iStreet; - iStreet = 0; - iStreet = HBufC::NewL(street.Length()); - iStreet->Des().Copy(street); - } - -/** - * - */ -void CLandmarkParameters::SetRandomCityL(CCreatorEngine& aEngine) - { - TPtrC city(aEngine.RandomString(CCreatorEngine::ECity)); - delete iCity; - iCity = 0; - iCity = HBufC::NewL(city.Length()); - iCity->Des().Copy(city); - } - -/** - * - */ -void CLandmarkParameters::SetRandomStateL(CCreatorEngine& aEngine) - { - TPtrC state(aEngine.RandomString(CCreatorEngine::EState)); - delete iState; - iState = 0; - iState = HBufC::NewL(state.Length()); - iState->Des().Copy(state); - } - -/** - * - */ -void CLandmarkParameters::SetRandomCountryL(CCreatorEngine& aEngine) - { - TPtrC country(aEngine.RandomString(CCreatorEngine::ECountry)); - delete iCountry; - iCountry = 0; - iCountry = HBufC::NewL(country.Length()); - iCountry->Des().Copy(country); - } - -/** - * - */ -void CLandmarkParameters::SetRandomPostCodeL(CCreatorEngine& aEngine) - { - TPtrC po(aEngine.RandomString(CCreatorEngine::EPostcode)); - delete iPostCode; - iPostCode = 0; - iPostCode = HBufC::NewL(po.Length()); - iPostCode->Des().Copy(po); - } - -/** - * - */ -void CLandmarkParameters::SetRandomLatitudeL(CCreatorEngine& aEngine) - { - iLatitude = aEngine.RandomNumber(-89, 89); // Degrees - TReal64 random = aEngine.RandomNumber(0, 9999); // Desimals - iLatitude += random / 10000.0; - } - -/** - * - */ -void CLandmarkParameters::SetRandomLongitudeL(CCreatorEngine& aEngine) - { - TInt minDegrees = -179; - TInt maxDegrees = 179; - TInt minDecimal = 0; - TInt maxDecimal = 9999; - TReal64 divider = 10000.0; - iLongitude = aEngine.RandomNumber(minDegrees, maxDegrees); // Degrees - TReal64 random = aEngine.RandomNumber(minDecimal, maxDecimal); - iLongitude += random / divider; - } - -/** - * - */ -void CLandmarkParameters::SetRandomPositionAccuracyL(CCreatorEngine& aEngine) - { - this->iPositionAccuracy = aEngine.RandomNumber(0,5); - } - -/** - * - */ -void CLandmarkParameters::SetRandomAltitudeL(CCreatorEngine& aEngine) - { - this->iAltitude = aEngine.RandomNumber(0,120); - } - -/** - * - */ -void CLandmarkParameters::SetRandomAltitudeAccuracyL(CCreatorEngine& aEngine) - { - this->iAltitudeAccuracy = aEngine.RandomNumber(0,5); - } - -/** - * - */ -void CLandmarkParameters::SetRandomDescriptionL(CCreatorEngine& aEngine) - { - delete iDescription; - iDescription = 0; - TPtrC desc(aEngine.RandomString(CCreatorEngine::ELandmarkDescription)); - iDescription = HBufC::NewL(desc.Length()); - iDescription->Des().Copy(desc); - } - -/** - * - */ -void CLandmarkParameters::SetRandomPhoneNumberL(CCreatorEngine& aEngine) - { - delete iPhonenumber; - iPhonenumber = 0; - TPtrC phone(aEngine.RandomString(CCreatorEngine::EPhoneNumber)); - iPhonenumber = HBufC::NewL(phone.Length()); - iPhonenumber->Des().Copy(phone); - } - -/** - * - */ -CCreatorLandmarks::CCreatorLandmarks() - { - } - -/** - * - */ -CCreatorLandmarks* CCreatorLandmarks::NewL(CCreatorEngine* aEngine) - { - CCreatorLandmarks* self = CCreatorLandmarks::NewLC(aEngine); - CleanupStack::Pop(); // self - return self; - } - -/** - * - */ -CCreatorLandmarks* CCreatorLandmarks::NewLC(CCreatorEngine* aEngine) - { - CCreatorLandmarks* self = new (ELeave) CCreatorLandmarks; - CleanupStack::PushL(self); - self->ConstructL(aEngine); - return self; - } - -/** - * - */ -void CCreatorLandmarks::ConstructL(CCreatorEngine* aEngine) - { - LOGSTRING("Creator: CCreatorLandmarks::ConstructL"); - iEngine = aEngine; - iLandmarkDb = CPosLandmarkDatabase::OpenL(); - if( iLandmarkDb->IsInitializingNeeded() ) - { - ExecuteAndDeleteLD(iLandmarkDb->InitializeL()); - } - } - -/** - * - */ -CCreatorLandmarks::~CCreatorLandmarks() - { - LOGSTRING("Creator: CCreatorLandmarks::~CCreatorLandmarks"); - if ( iEngine && iEntryIds.Count() ) - { - TRAP_IGNORE( iEngine->WriteEntryIdsToStoreL( iEntryIds, KUidDictionaryUidLandmarks ) ); - } - iEntryIds.Reset(); - iEntryIds.Close(); - - delete iLandmarkDb; - delete iLmOperation; - delete iParameters; - } - -/** - * - */ -TBool CCreatorLandmarks::AskDataFromUserL(TInt aCommand) - { - LOGSTRING("Creator: CCreatorLandmarks::AskDataFromUserL"); - - CCreatorModuleBase::AskDataFromUserL( aCommand ); - - if ( aCommand == ECmdDeleteLandmarks ) - { - return iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all Landmarks?"), this, ECreatorModuleDelete ); - } - else if ( aCommand == ECmdDeleteCreatorLandmarks ) - { - return iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all Landmarks created with Creator?"), this, ECreatorModuleDelete ); - } - return iEngine->GetEngineWrapper()->EntriesQueryDialog(&iEntriesToBeCreated, _L("How many landmarks to create?"), EFalse, this, ECreatorModuleStart ); - } - -/** - * Convert global category id to local category id - */ -TPosLmItemId CCreatorLandmarks::GetCategoryIdL( TPosLmGlobalCategory aGlobalCategoryID ) -{ - CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL( *iLandmarkDb ); - CleanupStack::PushL( categoryManager ); - - // Find ID of the given global category in given database - TPosLmItemId id = categoryManager->GetGlobalCategoryL( aGlobalCategoryID ); - CleanupStack::PopAndDestroy(); // categoryManager - return id; -} - -/** - * - */ -TInt CCreatorLandmarks::CreateLandmarkEntryL(CLandmarkParameters *aParameters) - { - LOGSTRING("Creator: CCreatorLandmarks::CreateLandmarkEntryL"); - TInt err = KErrNone; - // clear any existing parameter definations - delete iParameters; - iParameters = NULL; - - CLandmarkParameters* parameters = aParameters; - - // random data needed if no predefined data available - if (!parameters) - { - iParameters = new(ELeave) CLandmarkParameters; - parameters = iParameters; - - TBuf<160> company = iEngine->RandomString(CCreatorEngine::ECompany); - - parameters->SetRandomNameL(*iEngine); - parameters->SetRandomUrlL(*iEngine); - parameters->AddRandomCategoryL(*iEngine); - parameters->SetRandomStreetL(*iEngine); - parameters->SetRandomCityL(*iEngine); - parameters->SetRandomStateL(*iEngine); - parameters->SetRandomCountryL(*iEngine); - parameters->SetRandomPostCodeL(*iEngine); - parameters->SetRandomLatitudeL(*iEngine); - parameters->SetRandomLongitudeL(*iEngine); - parameters->SetRandomPositionAccuracyL(*iEngine); - parameters->SetRandomAltitudeL(*iEngine); - parameters->SetRandomAltitudeAccuracyL(*iEngine); - parameters->SetRandomDescriptionL(*iEngine); - parameters->SetRandomPhoneNumberL(*iEngine); - } - - CPosLandmark* newLandmark = CPosLandmark::NewLC(); - TCoordinate crd(parameters->iLatitude, parameters->iLongitude, parameters->iAltitude); - TLocality loc(crd, parameters->iPositionAccuracy, parameters->iAltitudeAccuracy); - newLandmark->SetPositionL(loc); - - // Add categories - for( TInt i = 0; i < parameters->iCategories.Count(); ++i ) - { - newLandmark->AddCategoryL(GetCategoryIdL(parameters->iCategories[i])); - } - if( parameters->iName ) - newLandmark->SetLandmarkNameL(parameters->iName->Des()); - if( parameters->iCountry ) - newLandmark->SetPositionFieldL(EPositionFieldCountry, parameters->iCountry->Des()); - if( parameters->iCity ) - newLandmark->SetPositionFieldL(EPositionFieldCity, parameters->iCity->Des()); - if( parameters->iPostCode ) - newLandmark->SetPositionFieldL(EPositionFieldPostalCode, parameters->iPostCode->Des()); - if( parameters->iState ) - newLandmark->SetPositionFieldL(EPositionFieldState, parameters->iState->Des()); - if( parameters->iStreet ) - newLandmark->SetPositionFieldL(EPositionFieldStreet, parameters->iStreet->Des()); - if( parameters->iPhonenumber ) - newLandmark->SetPositionFieldL(EPositionFieldBuildingTelephone, parameters->iPhonenumber->Des()); - if( parameters->iDescription ) - newLandmark->SetLandmarkDescriptionL(parameters->iDescription->Des()); - if( parameters->iUrl ) - newLandmark->SetPositionFieldL(EPositionFieldMediaLinksStart, parameters->iUrl->Des()); - - TRAP(err, iLandmarkDb->AddLandmarkL(*newLandmark)); - - // id has been generated, store it for being able to delete - // entries created only with Creator - iEntryIds.AppendL( newLandmark->LandmarkId() ); - - ExecuteAndDeleteLD(iLandmarkDb->CompactL()); - - CleanupStack::PopAndDestroy(newLandmark); - return err; - } - -//---------------------------------------------------------------------------- -void CCreatorLandmarks::DeleteAllL() - { - LOGSTRING("Creator: CCreatorLandmarks::DeleteAllL"); - ExecuteAndDeleteLD( iLandmarkDb->RemoveAllLandmarksL() ); - ExecuteAndDeleteLD( iLandmarkDb->CompactL() ); - - // reset must be done here, because iEntryIds is stored in destructor - iEntryIds.Reset(); - - // all entries deleted, remove the Landmarks related registry - iEngine->RemoveStoreL( KUidDictionaryUidLandmarks ); - } - -//---------------------------------------------------------------------------- -void CCreatorLandmarks::DeleteAllCreatedByCreatorL() - { - LOGSTRING("Creator: CCreatorLandmarks::DeleteAllCreatedByCreatorL"); - iEntryIds.Reset(); - - // fetch ids of entries created by Creator - iEngine->ReadEntryIdsFromStoreL( iEntryIds, KUidDictionaryUidLandmarks ); - - // delete entries - TRAP_IGNORE( - ExecuteAndDeleteLD( iLandmarkDb->RemoveLandmarksL( iEntryIds ) ); - ExecuteAndDeleteLD( iLandmarkDb->CompactL() ); - ); - - // reset must be done here, because iEntryIds is stored in destructor - iEntryIds.Reset(); - - // all entries deleted, remove the Landmarks related registry - iEngine->RemoveStoreL( KUidDictionaryUidLandmarks ); - } - - diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/src/creator_landmarkelement.cpp --- a/creator/engine/src/creator_landmarkelement.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,257 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - -#include "creator_landmarkelement.h" -#include "creator_traces.h" -#include "creator_landmark.h" - -using namespace creatorlandmark; - -/* - * - */ -CCreatorLandmarkElement* CCreatorLandmarkElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext ) - { - CCreatorLandmarkElement* self = new (ELeave) CCreatorLandmarkElement(aEngine); - CleanupStack::PushL(self); - self->ConstructL(aName, aContext); - CleanupStack::Pop(self); - return self; - } -/* - * - */ -CCreatorLandmarkElement::CCreatorLandmarkElement(CCreatorEngine* aEngine) -: -CCreatorScriptElement(aEngine) - { - iIsCommandElement = ETrue; - } - -void CCreatorLandmarkElement::ExecuteCommandL() - { - const CCreatorScriptAttribute* amountAttr = FindAttributeByName(KAmount); - TInt lmAmount = 1; - if( amountAttr ) - { - lmAmount = ConvertStrToIntL(amountAttr->Value()); - } - // Get 'fields' element - CCreatorScriptElement* fieldsElement = FindSubElement(KFields); - if( fieldsElement && fieldsElement->SubElements().Count() > 0 ) - { - // Get sub-elements - const RPointerArray& fields = fieldsElement->SubElements(); - // Create note entries, the amount of entries is defined by noteAmount: - for( TInt cI = 0; cI < lmAmount; ++cI ) - { - CLandmarkParameters* param = new (ELeave) CLandmarkParameters; - CleanupStack::PushL(param); - - for( TInt i = 0; i < fields.Count(); ++i ) - { - CCreatorScriptElement* field = fields[i]; - TPtrC elemName = field->Name(); - TPtrC elemContent = field->Content(); - const CCreatorScriptAttribute* randomAttr = fields[i]->FindAttributeByName(KRandomLength); - TBool useRandom = EFalse; - if( randomAttr || elemContent.Length() == 0 ) - { - useRandom = ETrue; - } - - if( elemName == KName ) - { - if( useRandom ) - { - param->SetRandomNameL(*iEngine); - } - else - { - SetContentToTextParamL(param->iName, elemContent); - } - } - else if( elemName == KCategory ) - { - if( useRandom ) - { - param->AddRandomCategoryL(*iEngine); - } - else - { - TPosLmItemId categoryId = CCreatorLandmarks::GetCategoryIdL(elemContent); - if( categoryId > 0 ) - { - param->iCategories.AppendL(categoryId); - } - } - } - else if( elemName == KDescription ) - { - if( useRandom ) - { - param->SetRandomDescriptionL(*iEngine); - } - else - { - SetContentToTextParamL(param->iDescription, elemContent); - } - } - else if( elemName == KStreet ) - { - if( useRandom ) - { - param->SetRandomStreetL(*iEngine); - } - else - { - SetContentToTextParamL(param->iStreet, elemContent); - } - } - else if( elemName == KPostalcode ) - { - if( useRandom ) - { - param->SetRandomPostCodeL(*iEngine); - } - else - { - SetContentToTextParamL(param->iPostCode, elemContent); - } - } - else if( elemName == KCity ) - { - if( useRandom ) - { - param->SetRandomCityL(*iEngine); - } - else - { - SetContentToTextParamL(param->iCity, elemContent); - } - } - else if( elemName == KState ) - { - if( useRandom ) - { - param->SetRandomStateL(*iEngine); - } - else - { - SetContentToTextParamL(param->iState, elemContent); - } - } - else if( elemName == KCountry ) - { - if( useRandom ) - { - param->SetRandomCountryL(*iEngine); - } - else - { - SetContentToTextParamL(param->iCountry, elemContent); - } - } - else if( elemName == KPhonenumber ) - { - if( useRandom ) - { - param->SetRandomPhoneNumberL(*iEngine); - } - else - { - SetContentToTextParamL(param->iPhonenumber, elemContent); - } - } - else if( elemName == KUrl ) - { - if( useRandom ) - { - param->SetRandomUrlL(*iEngine); - } - else - { - SetContentToTextParamL(param->iUrl, elemContent); - } - } - else if( elemName == KLatitude ) - { - if( useRandom ) - { - param->SetRandomLatitudeL(*iEngine); - } - else - { - ConvertStrToReal64L(elemContent, param->iLatitude); - } - } - else if( elemName == KLongitude ) - { - if( useRandom ) - { - param->SetRandomLongitudeL(*iEngine); - } - else - { - ConvertStrToReal64L(elemContent, param->iLongitude); - } - } - else if( elemName == KPositionaccuracy ) - { - if( useRandom ) - { - param->SetRandomPositionAccuracyL(*iEngine); - } - else - { - param->iPositionAccuracy = ConvertStrToIntL(elemContent); - } - } - else if( elemName == KAltitude ) - { - if( useRandom ) - { - param->SetRandomAltitudeL(*iEngine); - } - else - { - ConvertStrToReal32L(elemContent, param->iAltitude); - } - } - else if( elemName == KAltitudeaccuracy ) - { - if( useRandom ) - { - param->SetRandomAltitudeAccuracyL(*iEngine); - } - else - { - param->iAltitudeAccuracy = ConvertStrToIntL(elemContent); - } - } - } - iEngine->AppendToCommandArrayL(ECmdCreateMiscEntryLandmarks, param); - CleanupStack::Pop(); // param - } - } - else - { - iEngine->AppendToCommandArrayL(ECmdCreateMiscEntryLandmarks, 0, lmAmount); - } - } diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/src/creator_log.cpp --- a/creator/engine/src/creator_log.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,486 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - -#include - -#include "engine.h" -#include "enginewrapper.h" -#include "creator_log.h" -#include "creator_traces.h" - -static const TInt KLogsFieldLength = 256; - -//_LIT(KCreatorLogsPrefixName, "CR_"); - -//---------------------------------------------------------------------------- - -CLogsParameters::CLogsParameters() - { - LOGSTRING("Creator: CLogsParameters::CLogsParameters"); - - iPhoneNumber = HBufC::New(KLogsFieldLength); - /*iMissedCallPhoneNumber = HBufC::New(KLogsFieldLength); - iReceivedCallPhoneNumber = HBufC::New(KLogsFieldLength); - iDialledNumberPhoneNumber = HBufC::New(KLogsFieldLength);*/ - } - -CLogsParameters::~CLogsParameters() - { - LOGSTRING("Creator: CLogsParameters::~CLogsParameters"); - - delete iPhoneNumber; - /*delete iDialledNumberPhoneNumber; - delete iReceivedCallPhoneNumber; - delete iMissedCallPhoneNumber;*/ - } - -//---------------------------------------------------------------------------- - -CCreatorLogs* CCreatorLogs::NewL(CCreatorEngine* aEngine) - { - CCreatorLogs* self = CCreatorLogs::NewLC(aEngine); - CleanupStack::Pop(self); - return self; - } - -CCreatorLogs* CCreatorLogs::NewLC(CCreatorEngine* aEngine) - { - CCreatorLogs* self = new (ELeave) CCreatorLogs; - CleanupStack::PushL(self); - self->ConstructL(aEngine); - return self; - } - -CCreatorLogs::CCreatorLogs() : CActive(0) - { - iEntriesToBeCreated = 1; - } - -void CCreatorLogs::ConstructL(CCreatorEngine* aEngine) - { - LOGSTRING("Creator: CCreatorLogs::ConstructL"); - - iEngine = aEngine; - - iLogClient = CLogClient::NewL(CEikonEnv::Static()->FsSession()); - iLogEvent = CLogEvent::NewL(); - - CActiveScheduler::Add(this); // needed by CActive - } - -CCreatorLogs::~CCreatorLogs() - { - LOGSTRING("Creator: CCreatorLogs::~CCreatorLogs"); - - Cancel(); //from CActive - - if ( iEngine && iEntryIds.Count() ) - { - TRAP_IGNORE( iEngine->WriteEntryIdsToStoreL( iEntryIds, KUidDictionaryUidLogs ) ); - } - iEntryIds.Reset(); - iEntryIds.Close(); - - delete iLogEvent; - delete iLogClient; - - if (iParameters) - delete iParameters; - } - -//---------------------------------------------------------------------------- - -void CCreatorLogs::QueryDialogClosedL(TBool aPositiveAction, TInt aUserData) - { - LOGSTRING("Creator: CCreatorModuleBase::QueryDialogClosedL"); - - if( aPositiveAction == EFalse ) - { - iEngine->ShutDownEnginesL(); - return; - } - - const TDesC* showText = &KSavingText; - TBool finished(EFalse); - TBool retval(ETrue); - switch(aUserData) - { - case ECreatorLogsDelete: - showText = &KDeletingText; - iEntriesToBeCreated = 1; - finished = ETrue; - break; - case ECreatorLogsStart: - finished = ETrue; - break; - default: - //some error - retval = EFalse; - break; - } - if( retval == EFalse ) - { - iEngine->ShutDownEnginesL(); - } - else if( finished ) - { - // add this command to command array - iEngine->AppendToCommandArrayL(iCommand, NULL, iEntriesToBeCreated); - // started exucuting commands - iEngine->ExecuteFirstCommandL( *showText ); - } - } - -//---------------------------------------------------------------------------- - -TBool CCreatorLogs::AskDataFromUserL(TInt aCommand) - { - LOGSTRING("Creator: CCreatorLogs::AskDataFromUserL"); - - iCommand = aCommand; - - if ( aCommand == ECmdDeleteLogs ) - { - return iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all log entries?"), this, ECreatorLogsDelete ); - } - else if ( aCommand == ECmdDeleteCreatorLogs ) - { - return iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all log entries created with Creator?"), this, ECreatorLogsDelete ); - } - return iEngine->GetEngineWrapper()->EntriesQueryDialog( &iEntriesToBeCreated, _L("How many entries to create?"), EFalse, this, ECreatorLogsStart ); - } - -//---------------------------------------------------------------------------- - -void CCreatorLogs::RunL() - { - LOGSTRING("Creator: CCreatorLogs::RunL"); - - // log writing finished, stop the async waiting - iLogWriteWait.AsyncStop(); - } - -//---------------------------------------------------------------------------- - -void CCreatorLogs::DoCancel() - { - } - -//---------------------------------------------------------------------------- - -TInt CCreatorLogs::CreateMissedCallEntryL(CLogsParameters *aParameters) - { - LOGSTRING("Creator: CCreatorLogs::CreateMissedCallEntryL"); - - // clear any existing parameter definations - delete iParameters; - iParameters = NULL; - - CLogsParameters* parameters = aParameters; - - // random data needed if no predefined data available - if (!parameters) - { - iParameters = new(ELeave) CLogsParameters; - parameters = iParameters; - - /*iParameters->iMissedCallPhoneNumber->Des().Zero(); - iParameters->iMissedCallPhoneNumber->Des().AppendNum( iEngine->RandomNumber(1000000, 9999999) ); - - iParameters->iMissedCallEventTime.UniversalTime(); - iParameters->iMissedCallEventTime -= TTimeIntervalMinutes( iEngine->RandomNumber(12000) );*/ - parameters->iPhoneNumber->Des().Zero(); - parameters->iPhoneNumber->Des().AppendNum( iEngine->RandomNumber(1000000, 9999999) ); - - parameters->iEventTime.UniversalTime(); - parameters->iEventTime -= TTimeIntervalMinutes( iEngine->RandomNumber(12000) ); - - } - - // defaults - iLogEvent->SetId( KLogNullId ); - iLogEvent->SetEventType( KNullUid ); - iLogEvent->SetRemoteParty( KNullDesC ); - iLogEvent->SetDirection( KNullDesC ); - iLogEvent->SetTime( Time::NullTTime() ); - iLogEvent->SetDurationType( KLogNullDurationType ); - iLogEvent->SetDuration( KLogNullDuration ); - iLogEvent->SetStatus( KNullDesC ); - iLogEvent->SetSubject( KNullDesC ); - iLogEvent->SetNumber( KNullDesC ); - iLogEvent->SetContact( KNullContactId ); - iLogEvent->SetLink( KLogNullLink ); - iLogEvent->SetDescription( KNullDesC ); - iLogEvent->SetFlags( KLogNullFlags ); - iLogEvent->SetEventType(KLogCallEventTypeUid); - iLogEvent->SetSubject(_L("A")); - - // set direction - TLogString missed; - iLogClient->GetString(missed, R_LOG_DIR_MISSED); - iLogEvent->SetDirection(missed); - - // set duration - iLogEvent->SetDurationType( KLogDurationNone ); - TLogDuration duration = 0; - iLogEvent->SetDuration(duration); - - // set the phone number - //iLogEvent->SetNumber( iParameters->iMissedCallPhoneNumber->Des() ); - iLogEvent->SetNumber( parameters->iPhoneNumber->Des() ); - - // set event time - //iLogEvent->SetTime( iParameters->iMissedCallEventTime ); - iLogEvent->SetTime( parameters->iEventTime ); - - // start writing - __ASSERT_ALWAYS(!IsActive(), User::Panic(_L("LogWriter"), 150)); - iLogClient->AddEvent(*iLogEvent, iStatus); - SetActive(); - - // wait till adding has finished - iLogWriteWait.Start(); - - // id has been generated, store it for being able to delete - // entries created only with Creator - TRAP_IGNORE( iEntryIds.AppendL( iLogEvent->Id() ) ); - - return iStatus.Int(); // should be KErrNone if writing was succesful - } - -//---------------------------------------------------------------------------- - -TInt CCreatorLogs::CreateReceivedCallEntryL(CLogsParameters *aParameters) - { - LOGSTRING("Creator: CCreatorLogs::CreateReceivedCallEntryL"); - - // clear any existing parameter definations - delete iParameters; - iParameters = NULL; - - CLogsParameters* parameters = aParameters; - - // random data needed if no predefined data available - if (!parameters) - { - iParameters = new(ELeave) CLogsParameters; - parameters = iParameters; - - /*iParameters->iReceivedCallPhoneNumber->Des().Zero(); - iParameters->iReceivedCallPhoneNumber->Des().AppendNum( iEngine->RandomNumber(1000000, 9999999) ); - - iParameters->iReceivedCallEventTime.UniversalTime(); - iParameters->iReceivedCallEventTime -= TTimeIntervalMinutes( iEngine->RandomNumber(12000) ); - - iParameters->iReceivedCallDuration = iEngine->RandomNumber(7200);*/ - parameters->iPhoneNumber->Des().Zero(); - parameters->iPhoneNumber->Des().AppendNum( iEngine->RandomNumber(1000000, 9999999) ); - - parameters->iEventTime.UniversalTime(); - parameters->iEventTime -= TTimeIntervalMinutes( iEngine->RandomNumber(12000) ); - - parameters->iDuration = iEngine->RandomNumber(7200); - } - - // defaults - iLogEvent->SetId( KLogNullId ); - iLogEvent->SetEventType( KNullUid ); - iLogEvent->SetRemoteParty( KNullDesC ); - iLogEvent->SetDirection( KNullDesC ); - iLogEvent->SetTime( Time::NullTTime() ); - iLogEvent->SetDurationType( KLogNullDurationType ); - iLogEvent->SetDuration( KLogNullDuration ); - iLogEvent->SetStatus( KNullDesC ); - iLogEvent->SetSubject( KNullDesC ); - iLogEvent->SetNumber( KNullDesC ); - iLogEvent->SetContact( KNullContactId ); - iLogEvent->SetLink( KLogNullLink ); - iLogEvent->SetDescription( KNullDesC ); - iLogEvent->SetFlags( KLogNullFlags ); - iLogEvent->SetEventType(KLogCallEventTypeUid); - iLogEvent->SetSubject(_L("A")); - - // set direction - TLogString incoming; - iLogClient->GetString(incoming, R_LOG_DIR_IN); - iLogEvent->SetDirection(incoming); - - // set duration - iLogEvent->SetDurationType( KLogDurationValid ); - //iLogEvent->SetDuration( iParameters->iReceivedCallDuration ); - iLogEvent->SetDuration( parameters->iDuration ); - - // set the phone number - //iLogEvent->SetNumber( iParameters->iReceivedCallPhoneNumber->Des() ); - iLogEvent->SetNumber( parameters->iPhoneNumber->Des() ); - - // set event time - //iLogEvent->SetTime( iParameters->iReceivedCallEventTime ); - iLogEvent->SetTime( parameters->iEventTime ); - - // start writing - __ASSERT_ALWAYS(!IsActive(), User::Panic(_L("LogWriter"), 151)); - iLogClient->AddEvent(*iLogEvent, iStatus); - SetActive(); - - // wait till adding has finished - iLogWriteWait.Start(); - - // id has been generated, store it for being able to delete - // entries created only with Creator - TRAP_IGNORE( iEntryIds.AppendL( iLogEvent->Id() ) ); - - return iStatus.Int(); // should be KErrNone if writing was succesful - } - -//---------------------------------------------------------------------------- - - -TInt CCreatorLogs::CreateDialledNumberEntryL(CLogsParameters *aParameters) - { - LOGSTRING("Creator: CCreatorLogs::CreateDialledNumberEntryL"); - - // clear any existing parameter definations - delete iParameters; - iParameters = NULL; - - CLogsParameters* parameters = aParameters; - - // random data needed if no predefined data available - if (!parameters) - { - iParameters = new(ELeave) CLogsParameters; - parameters = iParameters; - - /*iParameters->iDialledNumberPhoneNumber->Des().Zero(); - iParameters->iDialledNumberPhoneNumber->Des().AppendNum( iEngine->RandomNumber(1000000, 9999999) ); - - iParameters->iDialledNumberEventTime.UniversalTime(); - iParameters->iDialledNumberEventTime -= TTimeIntervalMinutes( iEngine->RandomNumber(12000) ); - - iParameters->iDialledNumberDuration = iEngine->RandomNumber(7200);*/ - parameters->iPhoneNumber->Des().Zero(); - parameters->iPhoneNumber->Des().AppendNum( iEngine->RandomNumber(1000000, 9999999) ); - - parameters->iEventTime.UniversalTime(); - parameters->iEventTime -= TTimeIntervalMinutes( iEngine->RandomNumber(12000) ); - - parameters->iDuration = iEngine->RandomNumber(7200); - - } - - // defaults - iLogEvent->SetId( KLogNullId ); - iLogEvent->SetEventType( KNullUid ); - iLogEvent->SetRemoteParty( KNullDesC ); - iLogEvent->SetDirection( KNullDesC ); - iLogEvent->SetTime( Time::NullTTime() ); - iLogEvent->SetDurationType( KLogNullDurationType ); - iLogEvent->SetDuration( KLogNullDuration ); - iLogEvent->SetStatus( KNullDesC ); - iLogEvent->SetSubject( KNullDesC ); - iLogEvent->SetNumber( KNullDesC ); - iLogEvent->SetContact( KNullContactId ); - iLogEvent->SetLink( KLogNullLink ); - iLogEvent->SetDescription( KNullDesC ); - iLogEvent->SetFlags( KLogNullFlags ); - iLogEvent->SetEventType(KLogCallEventTypeUid); - iLogEvent->SetSubject(_L("A")); - - // set direction - TLogString outgoing; - iLogClient->GetString(outgoing, R_LOG_DIR_OUT); - iLogEvent->SetDirection(outgoing); - - // set duration - iLogEvent->SetDurationType( KLogDurationValid ); - //iLogEvent->SetDuration( iParameters->iDialledNumberDuration ); - iLogEvent->SetDuration( parameters->iDuration ); - - // set the phone number - //iLogEvent->SetNumber( iParameters->iDialledNumberPhoneNumber->Des() ); - iLogEvent->SetNumber( parameters->iPhoneNumber->Des() ); - - // set event time - //iLogEvent->SetTime( iParameters->iDialledNumberEventTime ); - iLogEvent->SetTime( parameters->iEventTime ); - - // start writing - __ASSERT_ALWAYS(!IsActive(), User::Panic(_L("LogWriter"), 152)); - iLogClient->AddEvent(*iLogEvent, iStatus); - SetActive(); - - // wait till adding has finished - iLogWriteWait.Start(); - - // id has been generated, store it for being able to delete - // only entries created with Creator - TRAP_IGNORE( iEntryIds.AppendL( iLogEvent->Id() ) ); - - return iStatus.Int(); // should be KErrNone if writing was succesful - } - -//---------------------------------------------------------------------------- -void CCreatorLogs::DeleteAllL() - { - LOGSTRING("Creator: CCreatorLogs::DeleteAllL"); - iLogClient->ClearLog( TTime( Time::MaxTTime() ), iStatus ); - SetActive(); - - // wait till delete has finished - iLogWriteWait.Start(); - User::LeaveIfError( iStatus.Int() ); - - // reset must be done here, because iEntryIds is stored in destructor - iEntryIds.Reset(); - - // all entries deleted, remove the Logs related registry - iEngine->RemoveStoreL( KUidDictionaryUidLogs ); - } - -//---------------------------------------------------------------------------- -void CCreatorLogs::DeleteAllCreatedByCreatorL() - { - LOGSTRING("Creator: CCreatorLogs::DeleteAllCreatedByCreatorL"); - iEntryIds.Reset(); - - // fetch ids of entries created by Creator - iEngine->ReadEntryIdsFromStoreL( iEntryIds, KUidDictionaryUidLogs ); - - // delete entries - for ( TInt i = 0; i < iEntryIds.Count(); i++ ) - { - // This could be implemented with while loop - // with additional cancel flag. That would enable - // using CancelOp() and cancelling would be bit smoother. - // With this for loop implementation all entries will be - // deleted whether or not user cancels during logs operation. - - iLogClient->DeleteEvent( iEntryIds[i], iStatus ); - SetActive(); - // wait till delete has finished - iLogWriteWait.Start(); - } - - // reset must be done here, because iEntryIds is stored in destructor - iEntryIds.Reset(); - - // all entries deleted, remove the Logs related registry - iEngine->RemoveStoreL( KUidDictionaryUidLogs ); - } diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/src/creator_logelement.cpp --- a/creator/engine/src/creator_logelement.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,171 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - -#include "creator_logelement.h" -#include "creator_traces.h" -#include "creator_log.h" - -using namespace creatorlog; - -/* - * - */ -CCreatorLogElement* CCreatorLogElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext ) - { - CCreatorLogElement* self = new (ELeave) CCreatorLogElement(aEngine); - CleanupStack::PushL(self); - self->ConstructL(aName, aContext); - CleanupStack::Pop(self); - return self; - } -/* - * - */ -CCreatorLogElement::CCreatorLogElement(CCreatorEngine* aEngine) -: -CCreatorScriptElement(aEngine) - { - iIsCommandElement = ETrue; - } -/* - * - */ -void CCreatorLogElement::ExecuteCommandL() - { - const CCreatorScriptAttribute* amountAttr = FindAttributeByName(KAmount); - TInt logAmount = 1; - if( amountAttr ) - { - logAmount = ConvertStrToIntL(amountAttr->Value()); - } - // Get 'fields' element - CCreatorScriptElement* fieldsElement = FindSubElement(KFields); - if( fieldsElement && fieldsElement->SubElements().Count() > 0 ) - { - // Get sub-elements - const RPointerArray& fields = fieldsElement->SubElements(); - // Create log entries, the amount of entries is defined by logAmount: - for( TInt cI = 0; cI < logAmount; ++cI ) - { - TInt direction = -1; - CLogsParameters* param = new (ELeave) CLogsParameters; - CleanupStack::PushL(param); - - for( TInt i = 0; i < fields.Count(); ++i ) - { - CCreatorScriptElement* field = fields[i]; - TPtrC elemName = field->Name(); - TPtrC elemContent = field->Content(); - const CCreatorScriptAttribute* randomAttr = field->FindAttributeByName(KRandomLength); - const CCreatorScriptAttribute* increaseAttr = field->FindAttributeByName(KIncrease); - TBool increase( EFalse ); - if ( increaseAttr ) - { - increase = ConvertStrToBooleanL( increaseAttr->Value() ); - } - - if( elemName == KDirection ) - { - direction = GetLogCommandL(elemContent, randomAttr || elemContent.Length() == 0); - } - else if( elemName == KDuration ) - { - if( randomAttr || elemContent.Length() == 0 ) - { - param->iDuration = iEngine->RandomNumber(7200); - } - else - { - param->iDuration = ConvertStrToIntL(elemContent); - } - } - else if( elemName == KPhonenumber ) - { - if( randomAttr || elemContent.Length() == 0 ) - { - SetContentToTextParamL(param->iPhoneNumber, iEngine->RandomString(CCreatorEngine::EPhoneNumber)); - } - else - { - if ( increase ) - { - delete param->iPhoneNumber; - param->iPhoneNumber = NULL; - param->iPhoneNumber = HBufC::NewL( elemContent.Length() + 3 ); - IncreasePhoneNumL( elemContent, cI, param->iPhoneNumber ); - } - else - { - SetContentToTextParamL(param->iPhoneNumber, elemContent); - } - } - } - else if( elemName == KDatetime ) - { - if( randomAttr || elemContent.Length() == 0 ) - { - param->iEventTime = iEngine->RandomTime(iEngine->RandomDate(CCreatorEngine::EDatePast), CCreatorEngine::EDatePast); - } - else - { - param->iEventTime = ConvertToDateTimeL(elemContent); - } - } - } - - if( direction == -1 ) - { - direction = GetLogCommandL(KEmpty, ETrue); - } - iEngine->AppendToCommandArrayL(direction, param); - CleanupStack::Pop(); // param - } - } - else - { - for(TInt i = 0; i < logAmount; ++i ) - { - iEngine->AppendToCommandArrayL(GetLogCommandL(KEmpty, ETrue), 0, 1); - } - } - } - -TInt CCreatorLogElement::GetLogCommandL( const TDesC& aLogCmdStr, TBool aRandom ) const - { - if( aRandom ) - { - TInt commandArray[] = { - ECmdCreateLogEntryMissedCalls, - ECmdCreateLogEntryReceivedCalls, - ECmdCreateLogEntryDialledNumbers - }; - return commandArray[iEngine->RandomNumber(0, 2)]; - } - - if( CompareIgnoreCase(aLogCmdStr, KMissed) == 0 ) - return ECmdCreateLogEntryMissedCalls; - else if( CompareIgnoreCase(aLogCmdStr, KIn) == 0 ) - return ECmdCreateLogEntryReceivedCalls; - else if( CompareIgnoreCase(aLogCmdStr, KOut) == 0 ) - return ECmdCreateLogEntryDialledNumbers; - - LOGSTRING2("CCreatorLogElement::GetLogCommandL: Unknown log direction: %S", &aLogCmdStr); - User::Leave(KErrNotFound); - return -1; // Not reached, but disables compiler warning... - } diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/src/creator_mailbox.cpp --- a/creator/engine/src/creator_mailbox.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,797 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#include -#include - -#include "engine.h" -#include "enginewrapper.h" -#include "creator_mailbox.h" -#include "creator_traces.h" - -static const TInt KMailboxesFieldLength = 160; - -_LIT(KCreatorMailboxesPrefixName, "CR_"); - -_LIT(KDefaultIncomingServer, "mail.example.com"); -_LIT(KDefaultOutgoingServer, "smtp.example.com"); -_LIT(KInternet, "internet"); - - -//---------------------------------------------------------------------------- - -CMailboxesParameters::CMailboxesParameters() - { - LOGSTRING("Creator: CMailboxesParameters::CMailboxesParameters"); - - iIncomingPort = KUndef; - iOutgoingPort = KUndef; - iMaxEmailSize = KUndef; - iSyncRate = KUndef; - iAttachmentFetchSize = KUndef; - iAttachmentSizeLimit = KUndef; - iBodyTextSizeLimit = KUndef; - iAttachmentFetchSize = KUndef; - iInboxSyncLimit = -1; // -1 = All - iMailboxSyncLimit = -1; // -1 = All - iToCCIncludeLimit = KUndef; - iImapIdleTimeout = KUndef; - - /*iMailboxName = HBufC::New(KMailboxesFieldLength); - iAccessPoint = HBufC::New(KMailboxesFieldLength); - iMyMailAddress = HBufC::New(KMailboxesFieldLength); - iOutgoingMailServer = HBufC::New(KMailboxesFieldLength); - iUserName = HBufC::New(KMailboxesFieldLength); - iPassword = HBufC::New(KMailboxesFieldLength); - iIncomingMailServer = HBufC::New(KMailboxesFieldLength);*/ - } - -CMailboxesParameters::~CMailboxesParameters() - { - LOGSTRING("Creator: CMailboxesParameters::~CMailboxesParameters"); - - /*delete iIncomingMailServer; - delete iPassword; - delete iUserName; - delete iOutgoingMailServer; - delete iMyMailAddress; - delete iAccessPoint; - delete iMailboxName;*/ - - delete iMailboxName; - delete iIncomingLoginName; - delete iIncomingPassword; - delete iIncomingServerName; - delete iIncomingConnectionMethod; - delete iIncomingFolderPath; - delete iPathSeparator; - delete iOutgoingLoginName; - delete iOutgoingPassword; - delete iOutgoingServerName; - delete iOutgoingConnectionMethod; - delete iOwnEmailAddress; - delete iOwnEmailAlias; - delete iReceiptAddress; - delete iReplyToAddress; - } - -//---------------------------------------------------------------------------- - -CCreatorMailboxes* CCreatorMailboxes::NewL(CCreatorEngine* aEngine) - { - CCreatorMailboxes* self = CCreatorMailboxes::NewLC(aEngine); - CleanupStack::Pop(self); - return self; - } - -CCreatorMailboxes* CCreatorMailboxes::NewLC(CCreatorEngine* aEngine) - { - CCreatorMailboxes* self = new (ELeave) CCreatorMailboxes; - CleanupStack::PushL(self); - self->ConstructL(aEngine); - return self; - } - -CCreatorMailboxes::CCreatorMailboxes() - { - } - -void CCreatorMailboxes::ConstructL(CCreatorEngine* aEngine) - { - LOGSTRING("Creator: CCreatorMailboxes::ConstructL"); - - iEngine = aEngine; - } - -CCreatorMailboxes::~CCreatorMailboxes() - { - LOGSTRING("Creator: CCreatorMailboxes::~CCreatorMailboxes"); - if ( iEngine && iEntryIds.Count() ) - { - TRAP_IGNORE( iEngine->WriteEntryIdsToStoreL( iEntryIds, KUidDictionaryUidMailbox ) ); - } - iEntryIds.Reset(); - iEntryIds.Close(); - - if (iParameters) - delete iParameters; - } - -//---------------------------------------------------------------------------- - -TBool CCreatorMailboxes::AskDataFromUserL(TInt aCommand) - { - LOGSTRING("Creator: CCreatorMailboxes::AskDataFromUserL"); - - CCreatorModuleBase::AskDataFromUserL( aCommand );//ignore retval - - if ( aCommand == ECmdDeleteMailboxes ) - { - return iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all mailboxes?"), this, ECreatorModuleDelete ); - } - else if ( aCommand == ECmdDeleteCreatorMailboxes ) - { - return iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all mailboxes created with Creator?"), this, ECreatorModuleDelete ); - } - return iEngine->GetEngineWrapper()->EntriesQueryDialog( &iEntriesToBeCreated, _L("How many entries to create?"), EFalse, this, ECreatorModuleStart ); - } - - -//---------------------------------------------------------------------------- - -TInt CCreatorMailboxes::CreateMailboxEntryL(CMailboxesParameters *aParameters) - { - LOGSTRING("Creator: CCreatorMailboxes::CreateMailboxEntryL"); - - // clear any existing parameter definations - delete iParameters; - iParameters = NULL; - - CMailboxesParameters* parameters = aParameters; - - // random data needed if no predefined data available - if (!parameters) - { - iParameters = new(ELeave) CMailboxesParameters; - parameters = iParameters; - - TPtrC company(iEngine->RandomString(CCreatorEngine::ECompany)); - TPtrC firstName(iEngine->RandomString(CCreatorEngine::EFirstName)); - - delete parameters->iMailboxName; - parameters->iMailboxName = 0; - parameters->iMailboxName = HBufC::NewL(KMailboxesFieldLength); - parameters->iMailboxName->Des() = KCreatorMailboxesPrefixName; - parameters->iMailboxName->Des().Append( company ); - parameters->iMailboxName->Des().Append(_L(" #")); - parameters->iMailboxName->Des().AppendNum(iEngine->RandomNumber(1, 100)); - - delete parameters->iIncomingLoginName; - parameters->iIncomingLoginName = 0; - parameters->iIncomingLoginName = HBufC::NewL(KMailboxesFieldLength); - delete parameters->iOutgoingLoginName; - parameters->iOutgoingLoginName = 0; - parameters->iOutgoingLoginName = HBufC::NewL(KMailboxesFieldLength); - parameters->iIncomingLoginName->Des() = iEngine->RandomString(CCreatorEngine::EFirstName); - parameters->iIncomingLoginName->Des().LowerCase(); - parameters->iOutgoingLoginName->Des().Copy(parameters->iIncomingLoginName->Des()); - - delete parameters->iIncomingPassword; - parameters->iIncomingPassword = 0; - parameters->iIncomingPassword = HBufC::NewL(KMailboxesFieldLength); - delete parameters->iOutgoingPassword; - parameters->iOutgoingPassword = 0; - parameters->iOutgoingPassword = HBufC::NewL(KMailboxesFieldLength); - parameters->iIncomingPassword->Des() = iEngine->RandomString(CCreatorEngine::ESurname); - parameters->iIncomingPassword->Des().LowerCase(); - parameters->iOutgoingPassword->Des().Copy(parameters->iIncomingPassword->Des()); - - delete parameters->iIncomingServerName; - parameters->iIncomingServerName = 0; - parameters->iIncomingServerName = HBufC::NewL(KMailboxesFieldLength); - parameters->iIncomingServerName->Des() = _L("incoming."); - parameters->iIncomingServerName->Des().Append(company); - parameters->iIncomingServerName->Des().Append(_L(".com")); - parameters->iIncomingServerName->Des().LowerCase(); - - delete parameters->iIncomingConnectionMethod; - parameters->iIncomingConnectionMethod = 0; - parameters->iIncomingConnectionMethod = HBufC::NewL(KInternet().Length()); - parameters->iIncomingConnectionMethod->Des() = KInternet; // use always this one, if it's not found, default will be used instead - - delete parameters->iOutgoingServerName; - parameters->iOutgoingServerName = 0; - parameters->iOutgoingServerName = HBufC::NewL(KMailboxesFieldLength); - parameters->iOutgoingServerName->Des() = _L("smtp."); - parameters->iOutgoingServerName->Des().Append(company); - parameters->iOutgoingServerName->Des().Append(_L(".com")); - parameters->iOutgoingServerName->Des().LowerCase(); - - delete parameters->iOutgoingConnectionMethod; - parameters->iOutgoingConnectionMethod = 0; - parameters->iOutgoingConnectionMethod = HBufC::NewL(KInternet().Length()); - parameters->iOutgoingConnectionMethod->Des() = KInternet; // use always this one, if it's not found, default will be used instead - - delete parameters->iOwnEmailAddress; - parameters->iOwnEmailAddress = 0; - parameters->iOwnEmailAddress = iEngine->CreateEmailAddressLC(); - parameters->iOwnEmailAddress->Des().LowerCase(); - CleanupStack::Pop(); // parameters->iOwnEmailAddress - - delete parameters->iOwnEmailAlias; - parameters->iOwnEmailAlias = 0; - parameters->iOwnEmailAlias = HBufC::NewL(firstName.Length()); - parameters->iOwnEmailAlias->Des().Copy(firstName); - - delete parameters->iReceiptAddress; - parameters->iReceiptAddress = 0; - parameters->iReceiptAddress = iEngine->CreateEmailAddressLC(); - parameters->iReceiptAddress->Des().LowerCase(); - CleanupStack::Pop(); // parameters->iReceiptAddress - - delete parameters->iReplyToAddress; - parameters->iReplyToAddress = 0; - parameters->iReplyToAddress = iEngine->CreateEmailAddressLC(); - parameters->iReplyToAddress->Des().LowerCase(); - CleanupStack::Pop(); // parameters->iReplyToAddress - - parameters->iIncomingSSLWrapper = iEngine->RandomNumber(0, 1); - parameters->iIncomingSecureSockets = iEngine->RandomNumber(0, 1); - parameters->iAcknowledgeReceipts = iEngine->RandomNumber(0, 1); - parameters->iAutoSendOnConnect = iEngine->RandomNumber(0, 1); - parameters->iDeleteEmailsAtDisconnect = iEngine->RandomNumber(0, 1); - parameters->iImapIdleCommand = iEngine->RandomNumber(0, 1); - parameters->iMarkSeenInSync = iEngine->RandomNumber(0, 1); - parameters->iEnableExpungeMode = iEngine->RandomNumber(0, 1); - parameters->iUseApop = iEngine->RandomNumber(0, 1); - parameters->iDisconnectedUserMode = iEngine->RandomNumber(0, 1); - parameters->iOutgoingSSLWrapper = iEngine->RandomNumber(0, 1); - parameters->iOutgoingSecureSockets = iEngine->RandomNumber(0, 1); - parameters->iIncludeSignature = EFalse; - parameters->iAddVCard = EFalse; - parameters->iRequestReceipts = iEngine->RandomNumber(0, 1); - parameters->iSmtpAuth = iEngine->RandomNumber(0, 1); - - parameters->iIncomingPort = iEngine->RandomNumber(25, 500); - parameters->iAttachmentSizeLimit = iEngine->RandomNumber(1, KMaxTInt); - parameters->iBodyTextSizeLimit = iEngine->RandomNumber(1, KMaxTInt); - parameters->iAttachmentFetchSize = iEngine->RandomNumber(1, 40960); - parameters->iImapIdleTimeout = iEngine->RandomNumber(10, 2000); - parameters->iMaxEmailSize = iEngine->RandomNumber(1024, KMaxTInt); - parameters->iSyncRate = iEngine->RandomNumber(10, 500); - parameters->iInboxSyncLimit = iEngine->RandomNumber(-1, 256); - parameters->iMailboxSyncLimit = iEngine->RandomNumber(-1, 256); - parameters->iOutgoingPort = KDefaultSmtpPort; - parameters->iToCCIncludeLimit = iEngine->RandomNumber(0, 30); - - parameters->iGetEmailOptions = (CMailboxesParameters::TGetEmailOption) iEngine->RandomNumber(CMailboxesParameters::EUndef, CMailboxesParameters::EGetEmailOptionLast-1); - parameters->iSubscribeType = (TFolderSubscribeType) iEngine->RandomNumber(EUpdateNeither, EUpdateBoth); - parameters->iSyncType = (TFolderSyncType) iEngine->RandomNumber(EUseCombination, EUseRemote); - parameters->iSendCopyToSelf = (TImSMTPSendCopyToSelf) iEngine->RandomNumber(ESendNoCopy, ESendCopyAsBccRecipient); - parameters->iSendOption = (TImSMTPSendMessageOption) iEngine->RandomNumber(ESendMessageImmediately, ESendMessageOnRequest); - parameters->iMailboxType = (TMailboxType) iEngine->RandomNumber(EMailboxPOP3, EMailboxIMAP4); - } - - TInt err = KErrNone; - - // make sure we have some IMEI stored - if (iIMEI.Length() == 0) - { - TRAP(err, GetIMEIFromThePhoneL()); - } - - // init - CImImap4Settings* imap4Set = new(ELeave) CImImap4Settings; - CleanupStack::PushL(imap4Set); - CImPop3Settings* pop3Set = new(ELeave) CImPop3Settings; - CleanupStack::PushL(pop3Set); - CImSmtpSettings* smtpSet = new(ELeave) CImSmtpSettings; - CleanupStack::PushL(smtpSet); - CImIAPPreferences* outgoingIAPSet = CImIAPPreferences::NewLC(); - CImIAPPreferences* incomingIAPSet = CImIAPPreferences::NewLC(); - CEmailAccounts* account = CEmailAccounts::NewLC(); - - // Get SMTP settings: - PopulateSmtpSettingsL(*account, *smtpSet, *outgoingIAPSet, *parameters); - - // appending mailbox type to array to be able to use - // correct type when deleting mailboxes - iEntryIds.AppendL( parameters->iMailboxType ); - - if (parameters->iMailboxType == EMailboxIMAP4) - { - // Get IMAP settings: - PopulateImapSettingsL(*account, *imap4Set, *incomingIAPSet, *parameters); - TImapAccount imapAccountId = account->CreateImapAccountL(parameters->iMailboxName->Des(), *imap4Set, *incomingIAPSet, EFalse); - TSmtpAccount smtpAccountId = account->CreateSmtpAccountL(imapAccountId, *smtpSet, *outgoingIAPSet, EFalse); - account->SetDefaultSmtpAccountL(smtpAccountId); - - iEntryIds.AppendL( imapAccountId.iImapAccountId ); - iEntryIds.AppendL( imapAccountId.iImapService ); - iEntryIds.AppendL( imapAccountId.iSmtpService ); - iEntryIds.AppendL( smtpAccountId.iSmtpAccountId ); - iEntryIds.AppendL( smtpAccountId.iSmtpService ); - iEntryIds.AppendL( smtpAccountId.iRelatedService ); - - StoreIMEIToEntryL( imapAccountId.iImapService ); - StoreIMEIToEntryL( smtpAccountId.iSmtpService ); - } - else - { - // Get POP settings: - PopulatePopSettingsL(*account, *pop3Set, *incomingIAPSet, *parameters); - TPopAccount popAccountId = account->CreatePopAccountL(parameters->iMailboxName->Des(), *pop3Set, *incomingIAPSet, EFalse); - TSmtpAccount smtpAccountId = account->CreateSmtpAccountL(popAccountId, *smtpSet, *outgoingIAPSet, EFalse); - account->SetDefaultSmtpAccountL(smtpAccountId); - - iEntryIds.AppendL( popAccountId.iPopAccountId ); - iEntryIds.AppendL( popAccountId.iPopService ); - iEntryIds.AppendL( popAccountId.iSmtpService ); - iEntryIds.AppendL( smtpAccountId.iSmtpAccountId ); - iEntryIds.AppendL( smtpAccountId.iSmtpService ); - iEntryIds.AppendL( smtpAccountId.iRelatedService ); - - StoreIMEIToEntryL( popAccountId.iPopService ); - StoreIMEIToEntryL( smtpAccountId.iSmtpService ); - } - CleanupStack::PopAndDestroy(6); //imap4Set, pop3Set, smtpSet, outgoingIAPSet, incomingIAPSet, account - - return err; - } - -void CCreatorMailboxes::PopulateImapSettingsL( - CEmailAccounts& aEmailAccount, - CImImap4Settings& aImapSettings, - CImIAPPreferences& aIApSettings, - const CMailboxesParameters& aParameters ) - { - // Get default settings first: - aEmailAccount.PopulateDefaultImapSettingsL(aImapSettings, aIApSettings); - - TImIAPChoice iapChoice; - iapChoice.iIAP = 0; - if( aParameters.iIncomingConnectionMethod == 0 || - aParameters.iIncomingConnectionMethod->Des().Length() == 0 ) - { - TRAP_IGNORE( iapChoice.iIAP = iEngine->AccessPointNameToIdL( KInternet )); - } - else - { - TRAP_IGNORE( iapChoice.iIAP = iEngine->AccessPointNameToIdL( aParameters.iIncomingConnectionMethod->Des())); - } - iapChoice.iDialogPref = ECommDbDialogPrefDoNotPrompt; - aIApSettings.AddIAPL(iapChoice); - - TBuf8<256> buf8; - if( aParameters.iIncomingLoginName && aParameters.iIncomingLoginName->Length() > 0 ) - buf8.Copy(aParameters.iIncomingLoginName->Des()); - else - buf8.Copy(iEngine->RandomString(CCreatorEngine::EFirstName)); - aImapSettings.SetLoginNameL(buf8); //8 - - if( aParameters.iIncomingPassword && aParameters.iIncomingPassword->Length() > 0 ) - buf8.Copy(aParameters.iIncomingPassword->Des()); - else - buf8.Copy(iEngine->RandomString(CCreatorEngine::EFirstName)); - aImapSettings.SetPasswordL(buf8); //8 - - if( aParameters.iIncomingFolderPath && aParameters.iIncomingFolderPath->Length() > 0 ) - { - buf8.Copy(aParameters.iIncomingFolderPath->Des()); - aImapSettings.SetFolderPathL(buf8); - } - - if( aParameters.iPathSeparator && aParameters.iPathSeparator->Length() > 0 ) - aImapSettings.SetPathSeparator(aParameters.iIncomingFolderPath->Des()[0]); - - aImapSettings.SetDisconnectedUserMode(aParameters.iDisconnectedUserMode); - aImapSettings.SetSynchronise(aParameters.iSyncType); - aImapSettings.SetSubscribe(aParameters.iSubscribeType); - aImapSettings.SetAutoSendOnConnect(aParameters.iAutoSendOnConnect); - - if(aParameters.iMaxEmailSize != KUndef ) - aImapSettings.SetMaxEmailSize(aParameters.iMaxEmailSize); - - aImapSettings.SetDeleteEmailsWhenDisconnecting(aParameters.iDeleteEmailsAtDisconnect); - aImapSettings.SetAcknowledgeReceipts(aParameters.iAcknowledgeReceipts); - - if(aParameters.iGetEmailOptions == CMailboxesParameters::EGetBodyText ) - aImapSettings.SetGetMailOptions(EGetImap4EmailBodyText); - else if(aParameters.iGetEmailOptions == CMailboxesParameters::EGetBodyTextAndAttachments ) - aImapSettings.SetGetMailOptions(EGetImap4EmailBodyTextAndAttachments); - else if(aParameters.iGetEmailOptions == CMailboxesParameters::EGetAttachments ) - aImapSettings.SetGetMailOptions(EGetImap4EmailAttachments); - else if(aParameters.iGetEmailOptions == CMailboxesParameters::EGetBodyAlternativeText ) - aImapSettings.SetGetMailOptions(EGetImap4EmailBodyAlternativeText); - else - aImapSettings.SetGetMailOptions(EGetImap4EmailHeaders); // Default - - if( aParameters.iInboxSyncLimit != KUndef ) - aImapSettings.SetInboxSynchronisationLimit(aParameters.iInboxSyncLimit); - - if( aParameters.iMailboxSyncLimit != KUndef ) - aImapSettings.SetMailboxSynchronisationLimit(aParameters.iMailboxSyncLimit); - - aImapSettings.SetUpdatingSeenFlags(aParameters.iMarkSeenInSync); - - if( aParameters.iSyncRate != KUndef ) - aImapSettings.SetSyncRateL(aParameters.iSyncRate); - - if( aParameters.iAttachmentFetchSize != KUndef ) - aImapSettings.SetFetchSizeL(aParameters.iAttachmentFetchSize); - - aImapSettings.SetImapIdle(aParameters.iImapIdleCommand); - if( aParameters.iImapIdleTimeout != KUndef ) - aImapSettings.SetImapIdleTimeoutL(aParameters.iImapIdleTimeout); - - if( aParameters.iBodyTextSizeLimit != KUndef ) - aImapSettings.SetBodyTextSizeLimitL(aParameters.iBodyTextSizeLimit); - - if( aParameters.iAttachmentSizeLimit != KUndef ) - aImapSettings.SetAttachmentSizeLimitL(aParameters.iAttachmentSizeLimit); - -#if(!defined __SERIES60_30__ && !defined __SERIES60_31__) - aImapSettings.SetUseExpunge(aParameters.iEnableExpungeMode); -#endif - - if(aParameters.iIncomingServerName && aParameters.iIncomingServerName->Length() > 0 ) - aImapSettings.SetServerAddressL(aParameters.iIncomingServerName->Des()); - else - aImapSettings.SetServerAddressL(KDefaultIncomingServer); - - if( aParameters.iIncomingPort != KUndef ) - aImapSettings.SetPort(aParameters.iIncomingPort); - - aImapSettings.SetSecureSockets(aParameters.iIncomingSecureSockets); - aImapSettings.SetSSLWrapper(aParameters.iIncomingSSLWrapper); - } - -void CCreatorMailboxes::PopulatePopSettingsL( - CEmailAccounts& aEmailAccount, - CImPop3Settings& aPopSettings, - CImIAPPreferences& aIApSettings, - const CMailboxesParameters& aParameters ) - { - aEmailAccount.PopulateDefaultPopSettingsL(aPopSettings, aIApSettings); - - TImIAPChoice iapChoice; - iapChoice.iIAP = 0; - if( aParameters.iIncomingConnectionMethod == 0 || - aParameters.iIncomingConnectionMethod->Des().Length() == 0 ) - { - TRAP_IGNORE( iapChoice.iIAP = iEngine->AccessPointNameToIdL( KInternet )); - } - else - { - TRAP_IGNORE( iapChoice.iIAP = iEngine->AccessPointNameToIdL( aParameters.iIncomingConnectionMethod->Des() )); - } - iapChoice.iDialogPref = ECommDbDialogPrefDoNotPrompt; - aIApSettings.AddIAPL(iapChoice); - - TBuf8<256> buf8; - if( aParameters.iIncomingLoginName && aParameters.iIncomingLoginName->Length() > 0 ) - buf8.Copy(aParameters.iIncomingLoginName->Des()); - else - buf8.Copy(iEngine->RandomString(CCreatorEngine::EFirstName)); - aPopSettings.SetLoginNameL(buf8); //8 - - if( aParameters.iIncomingPassword && aParameters.iIncomingPassword->Length() > 0 ) - buf8.Copy(aParameters.iIncomingPassword->Des()); - else - buf8.Copy(iEngine->RandomString(CCreatorEngine::EFirstName)); - aPopSettings.SetPasswordL(buf8); //8 - - aPopSettings.SetAutoSendOnConnect( aParameters.iAutoSendOnConnect ); - aPopSettings.SetApop( aParameters.iUseApop ); - aPopSettings.SetDisconnectedUserMode( aParameters.iDisconnectedUserMode ); - aPopSettings.SetDeleteEmailsWhenDisconnecting( aParameters.iDeleteEmailsAtDisconnect ); - aPopSettings.SetAcknowledgeReceipts( aParameters.iAcknowledgeReceipts ); - - if( aParameters.iMaxEmailSize != KUndef ) - aPopSettings.SetMaxEmailSize(aParameters.iMaxEmailSize); - - if(aParameters.iGetEmailOptions != CMailboxesParameters::EGetHeaders && - aParameters.iGetEmailOptions != CMailboxesParameters::EUndef ) - { - aPopSettings.SetGetMailOptions(EGetPop3EmailMessages); - aPopSettings.SetPopulationLimitL( -1 ); // -1 = body and attachment - } - else - { - aPopSettings.SetGetMailOptions(EGetPop3EmailHeaders); // Default - aPopSettings.SetPopulationLimitL( -2 ); // -2 = headers only - } - - if( aParameters.iInboxSyncLimit != KUndef ) - { - aPopSettings.SetInboxSynchronisationLimit(aParameters.iInboxSyncLimit); - } - - if(aParameters.iIncomingServerName && aParameters.iIncomingServerName->Length() > 0 ) - aPopSettings.SetServerAddressL(aParameters.iIncomingServerName->Des()); - else - aPopSettings.SetServerAddressL(KDefaultIncomingServer); - - if( aParameters.iIncomingPort != KUndef ) - aPopSettings.SetPort(aParameters.iIncomingPort); - - aPopSettings.SetSecureSockets(aParameters.iIncomingSecureSockets); - aPopSettings.SetSSLWrapper(aParameters.iIncomingSSLWrapper); - } - -void CCreatorMailboxes::PopulateSmtpSettingsL( - CEmailAccounts& aEmailAccount, - CImSmtpSettings& aSmtpSettings, - CImIAPPreferences& aIApSettings, - const CMailboxesParameters& aParameters ) - { - // Get default settings first: - aEmailAccount.PopulateDefaultSmtpSettingsL(aSmtpSettings, aIApSettings); - TImIAPChoice iapChoice; - iapChoice.iIAP = 0; - if( aParameters.iOutgoingConnectionMethod == 0 || - aParameters.iOutgoingConnectionMethod->Des().Length() == 0 ) - { - TRAP_IGNORE( iapChoice.iIAP = iEngine->AccessPointNameToIdL( KInternet )); - } - else - { - TRAP_IGNORE( iapChoice.iIAP = iEngine->AccessPointNameToIdL( aParameters.iOutgoingConnectionMethod->Des() )); - } - iapChoice.iDialogPref = ECommDbDialogPrefDoNotPrompt; - aIApSettings.AddIAPL(iapChoice); - - // set SMTP preferences - if( aParameters.iOwnEmailAlias && aParameters.iOwnEmailAlias->Length() > 0 ) - aSmtpSettings.SetEmailAliasL(aParameters.iOwnEmailAlias->Des()); - - if( aParameters.iOwnEmailAddress && aParameters.iOwnEmailAddress->Length() > 0 ) - aSmtpSettings.SetEmailAddressL(aParameters.iOwnEmailAddress->Des()); - - if( aParameters.iReplyToAddress && aParameters.iReplyToAddress->Length() > 0 ) - aSmtpSettings.SetReplyToAddressL(aParameters.iReplyToAddress->Des()); - - if( aParameters.iReceiptAddress && aParameters.iReceiptAddress->Length() > 0 ) - aSmtpSettings.SetReceiptAddressL(aParameters.iReceiptAddress->Des()); - - aSmtpSettings.SetBodyEncoding(EMsgOutboxMIME); - aSmtpSettings.SetAddVCardToEmail(aParameters.iAddVCard); - aSmtpSettings.SetAddSignatureToEmail(aParameters.iIncludeSignature); - aSmtpSettings.SetRequestReceipts(aParameters.iRequestReceipts); - aSmtpSettings.SetSendCopyToSelf(aParameters.iSendCopyToSelf); - aSmtpSettings.SetSendMessageOption(aParameters.iSendOption); - - TBuf8<256> buf8; - if( aParameters.iOutgoingLoginName && aParameters.iOutgoingLoginName->Length() > 0 ) - { - buf8.Copy(aParameters.iOutgoingLoginName->Des()); - aSmtpSettings.SetLoginNameL(buf8); //8 - } - - if( aParameters.iOutgoingPassword && aParameters.iOutgoingPassword->Length() > 0) - { - buf8.Copy(aParameters.iOutgoingPassword->Des()); - aSmtpSettings.SetPasswordL(buf8); //8 - } - - aSmtpSettings.SetSMTPAuth(aParameters.iSmtpAuth); - if( aParameters.iToCCIncludeLimit != KUndef ) - aSmtpSettings.SetToCcIncludeLimitL(aParameters.iToCCIncludeLimit); - - if( aParameters.iOutgoingServerName && aParameters.iOutgoingServerName->Length() > 0 ) - aSmtpSettings.SetServerAddressL(aParameters.iOutgoingServerName->Des()); - else - aSmtpSettings.SetServerAddressL(KDefaultOutgoingServer); - - if( aParameters.iOutgoingPort != KUndef ) - aSmtpSettings.SetPort(aParameters.iOutgoingPort); - - aSmtpSettings.SetSecureSockets(aParameters.iOutgoingSecureSockets); - aSmtpSettings.SetSSLWrapper(aParameters.iOutgoingSSLWrapper); - } - -//---------------------------------------------------------------------------- - -void CCreatorMailboxes::StoreIMEIToEntryL(const TMsvId aMailboxId) - { - LOGSTRING("Creator: CCreatorMailboxes::StoreIMEIToEntryL"); - - CMsvSession* session = CMsvSession::OpenSyncL(*this); - CleanupStack::PushL(session); - - CMsvEntry* centry = session->GetEntryL(aMailboxId); - CleanupStack::PushL(centry); - - TMsvEntry tentry = centry->Entry(); - tentry.iDescription.Set(iIMEI); - centry->ChangeL(tentry); - - CleanupStack::PopAndDestroy(2); // centry, session - } - -//---------------------------------------------------------------------------- - -void CCreatorMailboxes::GetIMEIFromThePhoneL() - { - LOGSTRING("Creator: CCreatorMailboxes::GetIMEIFromThePhoneL"); - -#ifndef __WINS__ - - RTelServer telServer; - User::LeaveIfError( telServer.Connect() ); - CleanupClosePushL(telServer); - - TInt numPhones = 0; - User::LeaveIfError( telServer.EnumeratePhones( numPhones ) ); - if ( numPhones < 1 ) - { - User::Leave( KErrNotFound ); - } - RTelServer::TPhoneInfo info; - User::LeaveIfError( telServer.GetPhoneInfo( 0, info ) ); - RMobilePhone mobilePhone; - User::LeaveIfError( mobilePhone.Open( telServer, info.iName ) ); - CleanupClosePushL( mobilePhone ); - - //mobilePhone.Initialise(); - TUint32 identityCaps; - User::LeaveIfError( mobilePhone.GetIdentityCaps( identityCaps ) ); - - if ( identityCaps & RMobilePhone::KCapsGetSerialNumber ) - { - TRequestStatus status; - RMobilePhone::TMobilePhoneIdentityV1 mobilePhoneIdentity; - - mobilePhone.GetPhoneId( status, mobilePhoneIdentity ); - - User::WaitForRequest( status ); - User::LeaveIfError( status.Int() ); - - iIMEI.Copy( mobilePhoneIdentity.iSerialNumber ); - } - else - { - User::Leave( KErrNotSupported ); - } - - CleanupStack::PopAndDestroy( &mobilePhone ); - CleanupStack::PopAndDestroy( &telServer ); - -#else - - // use fixed IMEI for emulator - _LIT( KIMAEmulatorImei, "123456789012345" ); - iIMEI.Copy( KIMAEmulatorImei ); - -#endif // __WINS__ - - } - -//---------------------------------------------------------------------------- - -void CCreatorMailboxes::HandleSessionEventL(TMsvSessionEvent /*aEvent*/, TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/) // from MMsvSessionObserver - { - } - -//---------------------------------------------------------------------------- -void CCreatorMailboxes::DeleteAllL() - { - LOGSTRING("Creator: CCreatorMailboxes::DeleteAllL"); - - CEmailAccounts* accountMgr = CEmailAccounts::NewLC(); - - // Delete pop accounts - RArray popAccountsToDelete; - CleanupClosePushL( popAccountsToDelete ); - accountMgr->GetPopAccountsL( popAccountsToDelete ); - for ( TInt i = 0; i < popAccountsToDelete.Count(); i++ ) - { - accountMgr->DeletePopAccountL( popAccountsToDelete[i] ); - } - CleanupStack::PopAndDestroy( &popAccountsToDelete ); - - // Delete imap accounts - RArray imapAccountsToDelete; - CleanupClosePushL( imapAccountsToDelete ); - accountMgr->GetImapAccountsL( imapAccountsToDelete ); - for ( TInt i = 0; i < imapAccountsToDelete.Count(); i++ ) - { - accountMgr->DeleteImapAccountL( imapAccountsToDelete[i] ); - } - CleanupStack::PopAndDestroy( &imapAccountsToDelete ); - - // Delete smtp accounts - RArray smtpAccountsToDelete; - CleanupClosePushL( smtpAccountsToDelete ); - accountMgr->GetSmtpAccountsL( smtpAccountsToDelete ); - for ( TInt i = 0; i < smtpAccountsToDelete.Count(); i++ ) - { - accountMgr->DeleteSmtpAccountL( smtpAccountsToDelete[i] ); - } - CleanupStack::PopAndDestroy( &smtpAccountsToDelete ); - - iEntryIds.Reset(); - - // all entries deleted, remove the Mailbox related registry - iEngine->RemoveStoreL( KUidDictionaryUidMailbox ); - - CleanupStack::PopAndDestroy( accountMgr ); - } - -//---------------------------------------------------------------------------- -void CCreatorMailboxes::DeleteAllCreatedByCreatorL() - { - LOGSTRING("Creator: CCreatorMailboxes::DeleteAllCreatedByCreatorL"); - - iEntryIds.Reset(); - CEmailAccounts* accountMgr = CEmailAccounts::NewLC(); - - // fetch ids of entries created by Creator - iEngine->ReadEntryIdsFromStoreL( iEntryIds, KUidDictionaryUidMailbox ); - - TInt i(0); - while ( i < iEntryIds.Count() && iEntryIds.Count() > 6 ) - { - // there should be at least 7 items in the array: - // one for mailbox type - // 3 for imap OR pop ids - // 3 for smtp ids - - // delete entries - - TInt type = iEntryIds[i++]; // TMailboxType - if ( type == EMailboxPOP3 ) - { - TPopAccount popAccount; - popAccount.iPopAccountId = iEntryIds[i++]; - popAccount.iPopService = iEntryIds[i++]; - popAccount.iSmtpService = iEntryIds[i++]; - TRAP_IGNORE( accountMgr->DeletePopAccountL( popAccount ) ); - } - else if ( type == EMailboxIMAP4 ) - { - TImapAccount imapAccount; - imapAccount.iImapAccountId = iEntryIds[i++]; - imapAccount.iImapService = iEntryIds[i++]; - imapAccount.iImapService = iEntryIds[i++]; - TRAP_IGNORE( accountMgr->DeleteImapAccountL( imapAccount ) ); - } - else - { - // ignore unknown mailbox types - i +=3; - } - - // There should be one smtp service for each pop and imap service - TSmtpAccount smtpAccount; - smtpAccount.iSmtpAccountId = iEntryIds[i++]; - smtpAccount.iSmtpService = iEntryIds[i++]; - smtpAccount.iRelatedService = iEntryIds[i++]; - TRAP_IGNORE( accountMgr->DeleteSmtpAccountL( smtpAccount ) ); - } - - // reset must be done here, because iEntryIds is stored in destructor - iEntryIds.Reset(); - - // all entries deleted, remove the mailbox related registry - iEngine->RemoveStoreL( KUidDictionaryUidMailbox ); - - CleanupStack::PopAndDestroy( accountMgr ); - } -//---------------------------------------------------------------------------- - diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/src/creator_mailboxelement.cpp --- a/creator/engine/src/creator_mailboxelement.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,496 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - -#include "creator_mailboxelement.h" -#include "creator_traces.h" -#include "creator_mailbox.h" - -using namespace creatormailbox; - -/* - * - */ -CCreatorMailboxElement* CCreatorMailboxElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext ) - { - CCreatorMailboxElement* self = new (ELeave) CCreatorMailboxElement(aEngine); - CleanupStack::PushL(self); - self->ConstructL(aName, aContext); - CleanupStack::Pop(self); - return self; - } -/* - * - */ -CCreatorMailboxElement::CCreatorMailboxElement(CCreatorEngine* aEngine) -: -CCreatorScriptElement(aEngine) - { - iIsCommandElement = ETrue; - } - -TBool CCreatorMailboxElement::SetIntegerParamL(const TDesC& aElemName, const TDesC& aElemContent, CMailboxesParameters* param, TBool aSetRandom ) - { - _LIT( KAll, "all"); - - if( aElemName == Kincomingport ) - { - if( aSetRandom ) - param->iIncomingPort = iEngine->RandomNumber(25, 500); - else - param->iIncomingPort = ConvertStrToIntL(aElemContent); - } - else if( aElemName == Kattachmentsizelimit ) - { - if( aSetRandom ) - param->iAttachmentSizeLimit = iEngine->RandomNumber(1, KMaxTInt); - else - param->iAttachmentSizeLimit = ConvertStrToIntL(aElemContent); - } - else if( aElemName == Kbodytextsizelimit ) - { - if( aSetRandom ) - param->iBodyTextSizeLimit = iEngine->RandomNumber(1, KMaxTInt); - else - param->iBodyTextSizeLimit = ConvertStrToIntL(aElemContent); - } - else if( aElemName == Kattachmentfetchsize ) - { - if( aSetRandom ) - param->iAttachmentFetchSize = iEngine->RandomNumber(1, 40960); - else - param->iAttachmentFetchSize = ConvertStrToIntL(aElemContent); - } - else if( aElemName == Kimapidletimeout ) - { - if( aSetRandom ) - param->iImapIdleTimeout = iEngine->RandomNumber(10, 2000); - else - param->iImapIdleTimeout = ConvertStrToIntL(aElemContent); - } - else if( aElemName == Kmaxemailsize ) - { - if( aSetRandom ) - param->iMaxEmailSize = iEngine->RandomNumber(1024, KMaxTInt); - else - param->iMaxEmailSize = ConvertStrToIntL(aElemContent); - } - else if( aElemName == Ksyncrate ) - { - if( aSetRandom ) - param->iSyncRate = iEngine->RandomNumber(10, 500); - else - param->iSyncRate = ConvertStrToIntL(aElemContent); - } - else if( aElemName == Kinboxsynclimit ) - { - if( aSetRandom ) - param->iInboxSyncLimit = iEngine->RandomNumber(-1, 256); - else if( CompareIgnoreCase(aElemContent, KAll) == 0 ) - param->iInboxSyncLimit = -1; - else - param->iInboxSyncLimit = ConvertStrToIntL(aElemContent); - } - else if( aElemName == Kmailboxsynclimit ) - { - if( aSetRandom ) - param->iMailboxSyncLimit = iEngine->RandomNumber(-1, 256); - else if( CompareIgnoreCase(aElemContent, KAll) == 0 ) - param->iMailboxSyncLimit = -1; - else - param->iMailboxSyncLimit = ConvertStrToIntL(aElemContent); - } - else if( aElemName == Koutgoingport ) - { - if( aSetRandom ) - param->iOutgoingPort = KDefaultSmtpPort; - else - param->iOutgoingPort = ConvertStrToIntL(aElemContent); - } - else if( aElemName == Ktoccincludelimit ) - { - if( aSetRandom ) - param->iToCCIncludeLimit = iEngine->RandomNumber(0, 30); - else - param->iToCCIncludeLimit = ConvertStrToIntL(aElemContent); - } - else - return EFalse; - - return ETrue; - } - -TBool CCreatorMailboxElement::GetBooleanValueL(const TDesC& aElemContent, TBool aSetRandom) - { - if( aSetRandom ) - return iEngine->RandomNumber(0,1) == 1; - - return ConvertStrToBooleanL(aElemContent); - } - -TBool CCreatorMailboxElement::SetBooleanParamL(const TDesC& aElemName, const TDesC& aElemContent, CMailboxesParameters* param, TBool aSetRandom ) - { - TBool val = GetBooleanValueL(aElemContent, aSetRandom); - if( aElemName == Kincomingsslwrapper ) - param->iIncomingSSLWrapper = val; - else if( aElemName == Kincomingsecuresockets ) - param->iIncomingSecureSockets = val; - else if( aElemName == Kacknowledgereceipts ) - param->iAcknowledgeReceipts = val; - else if( aElemName == Kautosendonconnect ) - param->iAutoSendOnConnect = val; - else if( aElemName == Kdeletemailsatdisconnect ) - param->iDeleteEmailsAtDisconnect = val; - else if( aElemName == Kimapidlecommand ) - param->iImapIdleCommand = val; - else if( aElemName == Kmarkseeninsync ) - param->iMarkSeenInSync = val; - else if( aElemName == Kenableexpungemode ) - param->iEnableExpungeMode = val; - else if( aElemName == Kuseapopsecurelogin ) - param->iUseApop = val; - else if( aElemName == Kdisconnectedusermode ) - param->iDisconnectedUserMode = val; - else if( aElemName == Koutgoingsslwrapper ) - param->iOutgoingSSLWrapper = val; - else if( aElemName == Koutgoingsecuresockets ) - param->iOutgoingSecureSockets = val; - else if( aElemName == Kincludesignature ) - param->iIncludeSignature = val; - else if( aElemName == Kaddvcard ) - param->iAddVCard = val; - else if( aElemName == Krequestreceipts ) - param->iRequestReceipts = val; - else if( aElemName == Ksmtpauth ) - param->iSmtpAuth = val; - else - return EFalse; - - return ETrue; - } - -TBool CCreatorMailboxElement::SetTextParamL(const TDesC& aElemName, const TDesC& aElemContent, CMailboxesParameters* param, TBool aSetRandom ) - { - _LIT(KIncomingSrvPrefix, "mail."); - _LIT(KOutgoingSrvPrefix, "smtp."); - _LIT(KSrvPostfix, ".com"); - _LIT(KDefaultConnMethod, "internet"); - - if( aElemName == Kname ) - { - if( aSetRandom ) - { - TPtrC company(iEngine->RandomString(CCreatorEngine::ECompany)); - SetContentToTextParamL(param->iMailboxName, company); - } - else - SetContentToTextParamL(param->iMailboxName, aElemContent); - } - else if( aElemName == Kincomingloginname ) - { - if( aSetRandom ) - { - TPtrC random(iEngine->RandomString(CCreatorEngine::EFirstName)); - SetContentToTextParamL(param->iIncomingLoginName, random); - param->iIncomingLoginName->Des().LowerCase(); - } - else - SetContentToTextParamL(param->iIncomingLoginName, aElemContent); - } - else if( aElemName == Kincomingpassword ) - { - if( aSetRandom ) - { - TPtrC random(iEngine->RandomString(CCreatorEngine::EFirstName)); - SetContentToTextParamL(param->iIncomingPassword, random); - param->iIncomingPassword->Des().LowerCase(); - } - else - SetContentToTextParamL(param->iIncomingPassword, aElemContent); - } - else if( aElemName == Kincomingservername ) - { - if( aSetRandom ) - { - TPtrC random(iEngine->RandomString(CCreatorEngine::ECompany)); - HBufC* srvName = HBufC::NewLC(KIncomingSrvPrefix().Length()+random.Length()+KSrvPostfix().Length()); - srvName->Des().Copy(KIncomingSrvPrefix); - srvName->Des().Append(random); - srvName->Des().Append(KSrvPostfix); - SetContentToTextParamL(param->iIncomingServerName, srvName->Des()); - CleanupStack::PopAndDestroy(); // srvName - } - else - SetContentToTextParamL(param->iIncomingServerName, aElemContent); - } - else if( aElemName == Kincomingconnectionmethod ) - { - if( aSetRandom ) - SetContentToTextParamL(param->iIncomingConnectionMethod, KDefaultConnMethod); - else - SetContentToTextParamL(param->iIncomingConnectionMethod, aElemContent); - } - else if( aElemName == Kincomingfolderpath ) - SetContentToTextParamL(param->iIncomingFolderPath, aElemContent); - else if( aElemName == Kpathseparator ) - SetContentToTextParamL(param->iPathSeparator, aElemContent); - else if( aElemName == Koutgoingloginname ) - { - if( aSetRandom ) - { - TPtrC random(iEngine->RandomString(CCreatorEngine::EFirstName)); - SetContentToTextParamL(param->iOutgoingLoginName, random); - param->iOutgoingLoginName->Des().LowerCase(); - } - else - SetContentToTextParamL(param->iOutgoingLoginName, aElemContent); - } - else if( aElemName == Koutgoingpassword ) - { - if( aSetRandom ) - { - TPtrC random(iEngine->RandomString(CCreatorEngine::EFirstName)); - SetContentToTextParamL(param->iOutgoingPassword, random); - param->iOutgoingPassword->Des().LowerCase(); - } - else - SetContentToTextParamL(param->iOutgoingPassword, aElemContent); - } - else if( aElemName == Koutgoingservername ) - { - if( aSetRandom ) - { - TPtrC random(iEngine->RandomString(CCreatorEngine::ECompany)); - HBufC* srvName = HBufC::NewLC(KOutgoingSrvPrefix().Length()+random.Length()+KSrvPostfix().Length()); - srvName->Des().Copy(KOutgoingSrvPrefix); - srvName->Des().Append(random); - srvName->Des().Append(KSrvPostfix); - SetContentToTextParamL(param->iOutgoingServerName, srvName->Des()); - CleanupStack::PopAndDestroy(); // srvName - } - else - SetContentToTextParamL(param->iOutgoingServerName, aElemContent); - } - else if( aElemName == Koutgoingconnectionmethod ) - { - if( aSetRandom ) - SetContentToTextParamL(param->iOutgoingConnectionMethod, KDefaultConnMethod); - else - SetContentToTextParamL(param->iOutgoingConnectionMethod, aElemContent); - } - else if( aElemName == Kownemail ) - { - if( aSetRandom ) - { - TDesC* email = iEngine->CreateEmailAddressLC(); - SetContentToTextParamL(param->iOwnEmailAddress, *email); - CleanupStack::PopAndDestroy(); // email - } - else - SetContentToTextParamL(param->iOwnEmailAddress, aElemContent); - } - else if( aElemName == Kemailalias ) - { - if( aSetRandom ) - { - _LIT(KSpace, " "); - TPtrC firstName(iEngine->RandomString(CCreatorEngine::EFirstName)); - TPtrC lastName(iEngine->RandomString(CCreatorEngine::ESurname)); - HBufC* alias = HBufC::NewLC(firstName.Length() + lastName.Length() + KSpace().Length()); - alias->Des().Copy(firstName); - alias->Des().Append(KSpace); - alias->Des().Append(lastName); - SetContentToTextParamL(param->iOwnEmailAlias, alias->Des()); - CleanupStack::PopAndDestroy(); // alias - } - else - SetContentToTextParamL(param->iOwnEmailAlias, aElemContent); - } - else if( aElemName == Kreceiptaddress ) - { - if( aSetRandom ) - { - TDesC* email = iEngine->CreateEmailAddressLC(); - SetContentToTextParamL(param->iReceiptAddress, *email); - CleanupStack::PopAndDestroy(); // email - } - else - SetContentToTextParamL(param->iReceiptAddress, aElemContent); - } - else if( aElemName == Kreplytoaddress ) - { - if( aSetRandom ) - { - TDesC* email = iEngine->CreateEmailAddressLC(); - SetContentToTextParamL(param->iReceiptAddress, *email); - CleanupStack::PopAndDestroy(); // email - } - else - SetContentToTextParamL(param->iReplyToAddress, aElemContent); - } - else - return EFalse; - - return ETrue; - } - -TBool CCreatorMailboxElement::SetEnumParamL(const TDesC& aElemName, const TDesC& aElemContent, CMailboxesParameters* param, TBool aSetRandom ) - { - // Get email options: - if( aElemName == Kgetemailoptions ) - { - if( aSetRandom ) - param->iGetEmailOptions = (CMailboxesParameters::TGetEmailOption) iEngine->RandomNumber( - CMailboxesParameters::EGetHeaders, - CMailboxesParameters::EGetEmailOptionLast-1); - else if( CompareIgnoreCase(aElemContent, Kgetheaders ) == 0 ) - param->iGetEmailOptions = CMailboxesParameters::EGetHeaders; - else if( CompareIgnoreCase(aElemContent, Kgetbodytext) == 0 ) - param->iGetEmailOptions = CMailboxesParameters::EGetBodyText; - else if( CompareIgnoreCase(aElemContent, Kgetbodytextandattachments) == 0 ) - param->iGetEmailOptions = CMailboxesParameters::EGetBodyTextAndAttachments; - else if( CompareIgnoreCase(aElemContent, Kgetattachments) == 0 ) - param->iGetEmailOptions = CMailboxesParameters::EGetAttachments; - else if( CompareIgnoreCase(aElemContent, Kgetbodyalternativetext) == 0 ) - param->iGetEmailOptions = CMailboxesParameters::EGetBodyAlternativeText; - else - param->iGetEmailOptions = CMailboxesParameters::EUndef; - } - - // Subscribe type: - else if( aElemName == Ksubscribetype ) - { - if( aSetRandom ) - param->iSubscribeType = (TFolderSubscribeType) iEngine->RandomNumber( EUpdateNeither, EUpdateBoth ); - else if( CompareIgnoreCase( aElemContent, Kupdatelocal) == 0 ) - param->iSubscribeType = EUpdateLocal; - else if( CompareIgnoreCase( aElemContent, Kupdateremote) == 0 ) - param->iSubscribeType = EUpdateRemote; - else if( CompareIgnoreCase( aElemContent, Kupdateboth) == 0 ) - param->iSubscribeType = EUpdateBoth; - else - param->iSubscribeType = EUpdateNeither; - } - - // Folder synchronization type: - else if( aElemName == Kfoldersynctype) - { - if( aSetRandom ) - param->iSyncType = (TFolderSyncType) iEngine->RandomNumber(EUseCombination, EUseRemote); - else if( CompareIgnoreCase( aElemContent, Kuselocal) == 0 ) - param->iSyncType = EUseLocal; - else if( CompareIgnoreCase( aElemContent, Kuseremote) == 0 ) - param->iSyncType = EUseRemote; - else - param->iSyncType = EUseCombination; - } - - // Send copy to self option: - else if( aElemName == Kcopytoself ) - { - if( aSetRandom ) - param->iSendCopyToSelf = (TImSMTPSendCopyToSelf) iEngine->RandomNumber(ESendNoCopy, ESendCopyAsBccRecipient); - else if( CompareIgnoreCase( aElemContent, Kto) == 0 ) - param->iSendCopyToSelf = ESendCopyAsToRecipient; - else if( CompareIgnoreCase( aElemContent, Kcc) == 0 ) - param->iSendCopyToSelf = ESendCopyAsCcRecipient; - else if( CompareIgnoreCase( aElemContent, Kbcc) == 0 ) - param->iSendCopyToSelf = ESendCopyAsBccRecipient; - else - param->iSendCopyToSelf = ESendNoCopy; - } - - // Send option: - else if( aElemName == Ksendoption ) - { - if( aSetRandom ) - param->iSendOption = (TImSMTPSendMessageOption) iEngine->RandomNumber(ESendMessageImmediately, ESendMessageOnRequest); - else if( CompareIgnoreCase( aElemContent, Konnextconnection) == 0 ) - param->iSendOption = ESendMessageOnNextConnection; - else if( CompareIgnoreCase( aElemContent, Konrequest) == 0 ) - param->iSendOption = ESendMessageOnRequest; - else - param->iSendOption = ESendMessageImmediately; - } - else - { - return EFalse; - } - return ETrue; - } - -void CCreatorMailboxElement::ExecuteCommandL() - { - const CCreatorScriptAttribute* amountAttr = FindAttributeByName(KAmount); - const CCreatorScriptAttribute* typeAttr = FindAttributeByName(KMailboxType); - TInt amount = 1; - if( amountAttr ) - { - amount = ConvertStrToIntL(amountAttr->Value()); - } - - TMailboxType mailboxType = EMailboxPOP3; - - if( typeAttr && CompareIgnoreCase(typeAttr->Value(), Kimap4) == 0 ) - { - mailboxType = EMailboxIMAP4; - } - - // Get 'fields' element - CCreatorScriptElement* fieldsElement = FindSubElement(KFields); - if( fieldsElement && fieldsElement->SubElements().Count() > 0) - { - // Get sub-elements - const RPointerArray& fields = fieldsElement->SubElements(); - // Create mailbox entries, the amount of entries is defined by amount: - for( TInt cI = 0; cI < amount; ++cI ) - { - CMailboxesParameters* param = new (ELeave) CMailboxesParameters; - CleanupStack::PushL(param); - - param->iMailboxType = mailboxType; - - for( TInt i = 0; i < fields.Count(); ++i ) - { - CCreatorScriptElement* field = fields[i]; - TPtrC elemName = field->Name(); - TPtrC elemContent = field->Content(); - const CCreatorScriptAttribute* randomAttr = fields[i]->FindAttributeByName(KRandomLength); - TBool useRandom = EFalse; - if( randomAttr || elemContent.Length() == 0 ) - { - useRandom = ETrue; - } - - if( SetTextParamL(elemName, elemContent, param, useRandom ) == EFalse && - SetBooleanParamL(elemName, elemContent, param, useRandom ) == EFalse && - SetIntegerParamL(elemName, elemContent, param, useRandom ) == EFalse && - SetEnumParamL(elemName, elemContent, param, useRandom ) ) - { - LOGSTRING2("CCreatorMailboxElement::ExecuteCommandL: Unknown mailbox field: %S", &elemName); - } - } - iEngine->AppendToCommandArrayL(ECmdCreateMessagingEntryMailboxes, param); - CleanupStack::Pop(); // param - } - } - else - { - iEngine->AppendToCommandArrayL(ECmdCreateMessagingEntryMailboxes, 0, amount); - } - } diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/src/creator_message.cpp --- a/creator/engine/src/creator_message.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1825 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#include "engine.h" -#include "enginewrapper.h" - -#include "creator_message.h" -#include "creator_traces.h" -#include "creator_contactsetcache.h" -#include "creator_phonebook.h" -#include -#include -#include - -#include // for CleanupResetAndDestroyPushL - -//static const TInt KMessagesFieldLength = 1024; - -//_LIT(KCreatorMessagesPrefixName, "CR_"); -//_LIT(KCreatorMessagesPrefixFolderName, "CR_FLDR_"); - - -const TUid KUidBIOBusinessCardMsg = {0x10005531}; -_LIT(KEmpty, ""); - -//---------------------------------------------------------------------------- - -CMessagesParameters::CMessagesParameters() - { - LOGSTRING("Creator: CMessagesParameters::CMessagesParameters"); - - iSenderAddress = HBufC::New(128); - iRecipientAddress = HBufC::New(128); - iMessageSubject = HBufC::New(128); - iMessageBodyText = HBufC::New(10240); - TRAP_IGNORE(iAttachments = new(ELeave) CArrayFixFlat(64)); - iCreateAsUnread = ETrue; - } - -CMessagesParameters::~CMessagesParameters() - { - LOGSTRING("Creator: CMessagesParameters::~CMessagesParameters"); - - - delete iMessageBodyText; - delete iMessageSubject; - delete iRecipientAddress; - delete iSenderAddress; - delete iAttachments; - iAttachmentPaths.ResetAndDestroy(); - iAttachmentPaths.Close(); - iRecipientAddressArray.ResetAndDestroy(); - iRecipientAddressArray.Close(); - iRecipientLinkIds.Close(); - iSenderLinkIds.Close(); - } - -//---------------------------------------------------------------------------- - -CCreatorMessages* CCreatorMessages::NewL(CCreatorEngine* aEngine) - { - CCreatorMessages* self = CCreatorMessages::NewLC(aEngine); - CleanupStack::Pop(self); - return self; - } - -CCreatorMessages* CCreatorMessages::NewLC(CCreatorEngine* aEngine) - { - CCreatorMessages* self = new (ELeave) CCreatorMessages; - CleanupStack::PushL(self); - self->ConstructL(aEngine); - return self; - } - -CCreatorMessages::CCreatorMessages() - { - } - -void CCreatorMessages::ConstructL(CCreatorEngine* aEngine) - { - LOGSTRING("Creator: CCreatorMessages::ConstructL"); - iEngine = aEngine; - - TRAP_IGNORE(iAttachments = new(ELeave) CArrayFixFlat(64)); - iWaiter = CAsyncWaiter::NewL(); - } - -CCreatorMessages::~CCreatorMessages() - { - LOGSTRING("Creator: CCreatorMessages::~CCreatorMessages"); - - if ( iEngine && iEntryIds.Count() ) - { - TRAP_IGNORE( iEngine->WriteEntryIdsToStoreL( iEntryIds, KUidDictionaryUidMessages ) ); - } - iEntryIds.Reset(); - iEntryIds.Close(); - - delete iParameters; - delete iWaiter; - delete iTmpPhoneNumber; - delete iTmpEmail; - delete iAttachments; - - iRecipientArray.ResetAndDestroy(); - iRecipientArray.Close(); - iSenderArray.ResetAndDestroy(); - iSenderArray.Close(); - } - -//---------------------------------------------------------------------------- - -void CCreatorMessages::QueryDialogClosedL(TBool aPositiveAction, TInt aUserData) - { - LOGSTRING("Creator: CCreatorMessages::QueryDialogClosedL"); - - if( aPositiveAction == EFalse ) - { - iEngine->ShutDownEnginesL(); - return; - } - - const TDesC* showText = &KSavingText; - TBool finished(EFalse); - TBool retval(ETrue); - switch(aUserData) - { - case ECreatorMessagesDelete: - showText = &KDeletingText; - iEntriesToBeCreated = 1; - finished = ETrue; - break; - case ECreatorMessagesStart: - // message type query - retval = iEngine->GetEngineWrapper()->ListQueryDialog(_L("Message type"), R_MESSAGE_TYPE_QUERY, (TInt*) &iMessageType, this, ECreatorMessagesMessageType); - break; - case ECreatorMessagesMessageType: - retval = iEngine->GetEngineWrapper()->ListQueryDialog(_L("Folder type"), R_FOLDER_TYPE_QUERY, (TInt*) &iFolderType, this, ECreatorMessagesFolderType); - break; - case ECreatorMessagesFolderType: - // query create as unread - retval = iEngine->GetEngineWrapper()->ListQueryDialog(_L("Message status"), R_UNREAD_QUERY, (TInt*)&iCreateAsUnread, this, ECreatorMessagesMessageStatus); - break; - case ECreatorMessagesMessageStatus: - if( iMessageType == ESMS || iMessageType == EMMS || iMessageType == EEmail ) - { - iDefinedMessageLength = 100; - retval = iEngine->GetEngineWrapper()->EntriesQueryDialog(&iDefinedMessageLength, _L("Amount of characters in message body?"), ETrue, - this, ECreatorMessagesCharsInBody - ); - break; - } - else - { - iDefinedMessageLength = 0; - // goto query attachments ... :-) DO NOT break; - } - case ECreatorMessagesCharsInBody: - // query attachments - iAttachments->Reset(); - if( iMessageType == EMMS || iMessageType == EEmail) - { - retval = iEngine->GetEngineWrapper()->ListQueryDialog(_L("Choose attachment:"), R_ATTACHMENT_MULTI_SELECTION_QUERY, - iAttachments, this, ECreatorMessagesAttachment - ); - } - else if( iMessageType == EAMS ) - { - iAttachments->AppendL( TInt(0) ); - retval = iEngine->GetEngineWrapper()->ListQueryDialog(_L("Choose attachment:"), R_AMS_ATTACHMENT_SINGLE_SELECTION_QUERY, - &iAttachments->At(0), this, ECreatorMessagesAttachment - ); - } - else if( iMessageType == EIrMessage || iMessageType == EBTMessage ) - { - iAttachments->AppendL( TInt(0) ); - retval = iEngine->GetEngineWrapper()->ListQueryDialog(_L("Choose attachment:"), R_ATTACHMENT_SINGLE_SELECTION_QUERY, - &iAttachments->At(0), this, ECreatorMessagesAttachment - ); - } - else - { - finished = ETrue; - } - break; - case ECreatorMessagesAttachment: - finished = ETrue; - if(iMessageType== EMMS || iMessageType == EEmail) - { - // "none" is selected - if (iAttachments->At(0) == 0) - { - iAttachments->Reset(); - } - else // otherwise fix indexes - { - for (TInt i=0; iCount(); i++) - iAttachments->At(i)--; // decrease value by one - - } - } - break; - default: - //some error - retval = EFalse; - break; - } - if( retval == EFalse ) - { - iEngine->ShutDownEnginesL(); - } - else if( finished ) - { - // add this command to command array - iEngine->AppendToCommandArrayL(iCommand, NULL, iEntriesToBeCreated); - // started exucuting commands - iEngine->ExecuteFirstCommandL( *showText ); - } - } -//---------------------------------------------------------------------------- - -TBool CCreatorMessages::AskDataFromUserL(TInt aCommand) - { - LOGSTRING("Creator: CCreatorMessages::AskDataFromUserL"); - - CCreatorModuleBase::AskDataFromUserL(aCommand); - - if ( aCommand == ECmdDeleteMessages ) - { - return iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all messages?"), this, ECreatorMessagesDelete ); - } - else if ( aCommand == ECmdDeleteCreatorMessages ) - { - return iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all messages created with Creator?"), this, ECreatorMessagesDelete ); - } - - return iEngine->GetEngineWrapper()->EntriesQueryDialog( &iEntriesToBeCreated, _L("How many entries to create?"), EFalse, this, ECreatorMessagesStart ); - } - -//---------------------------------------------------------------------------- - -TInt CCreatorMessages::CreateRandomMessageEntryL(TInt aCommand) - { - LOGSTRING2("Creator: CCreatorMessages::CreateRandomMessageEntryL - Command: %d", aCommand); - - TInt err = KErrNone; - - iDefinedMessageLength = iEngine->RandomNumber(100, 300); - - - switch (aCommand) - { - case ECmdCreateRandomEntrySMSInbox: { iMessageType=ESMS; iFolderType=EInbox; err=CreateMessageEntryL(NULL); break;} - case ECmdCreateRandomEntrySMSDrafts: { iMessageType=ESMS; iFolderType=EDrafts; err=CreateMessageEntryL(NULL); break;} - case ECmdCreateRandomEntrySMSOutbox: { iMessageType=ESMS; iFolderType=EOutbox; err=CreateMessageEntryL(NULL); break;} - case ECmdCreateRandomEntrySMSSent: { iMessageType=ESMS; iFolderType=ESent; err=CreateMessageEntryL(NULL); break;} - - case ECmdCreateRandomEntryMMSInbox: { iMessageType=EMMS; iFolderType=EInbox; err=CreateMessageEntryL(NULL); break;} - case ECmdCreateRandomEntryMMSDrafts: { iMessageType=EMMS; iFolderType=EDrafts; err=CreateMessageEntryL(NULL); break;} - case ECmdCreateRandomEntryMMSOutbox: { iMessageType=EMMS; iFolderType=EOutbox; err=CreateMessageEntryL(NULL); break;} - case ECmdCreateRandomEntryMMSSent: { iMessageType=EMMS; iFolderType=ESent; err=CreateMessageEntryL(NULL); break;} - - case ECmdCreateRandomEntryEmailInbox: { iMessageType=EEmail; iFolderType=EInbox; err=CreateMessageEntryL(NULL); break;} - case ECmdCreateRandomEntryEmailDrafts: { iMessageType=EEmail; iFolderType=EDrafts; err=CreateMessageEntryL(NULL); break;} - case ECmdCreateRandomEntryEmailOutbox: { iMessageType=EEmail; iFolderType=EOutbox; err=CreateMessageEntryL(NULL); break;} - case ECmdCreateRandomEntryEmailSent: { iMessageType=EEmail; iFolderType=ESent; err=CreateMessageEntryL(NULL); break;} - - case ECmdCreateRandomEntryBIOInbox: { iMessageType=ESmartMessage; iFolderType=EInbox; err=CreateMessageEntryL(NULL); break;} - case ECmdCreateRandomEntryBIODrafts: { iMessageType=ESmartMessage; iFolderType=EDrafts; err=CreateMessageEntryL(NULL); break;} - case ECmdCreateRandomEntryBIOOutbox: { iMessageType=ESmartMessage; iFolderType=EOutbox; err=CreateMessageEntryL(NULL); break;} - case ECmdCreateRandomEntryBIOSent: { iMessageType=ESmartMessage; iFolderType=ESent; err=CreateMessageEntryL(NULL); break;} - - case ECmdCreateRandomEntryIRInbox: { iMessageType=EIrMessage; iFolderType=EInbox; iAttachments->Reset(); iAttachments->AppendL( iEngine->RandomNumber(CCreatorEngine::EJPEG_25kB, CCreatorEngine::LAST_FILE_ID-1) ); err=CreateMessageEntryL(NULL); break;} - case ECmdCreateRandomEntryIRDrafts: { iMessageType=EIrMessage; iFolderType=EDrafts; iAttachments->Reset(); iAttachments->AppendL( iEngine->RandomNumber(CCreatorEngine::EJPEG_25kB, CCreatorEngine::LAST_FILE_ID-1) ); err=CreateMessageEntryL(NULL); break;} - case ECmdCreateRandomEntryIROutbox: { iMessageType=EIrMessage; iFolderType=EOutbox; iAttachments->Reset(); iAttachments->AppendL( iEngine->RandomNumber(CCreatorEngine::EJPEG_25kB, CCreatorEngine::LAST_FILE_ID-1) ); err=CreateMessageEntryL(NULL); break;} - case ECmdCreateRandomEntryIRSent: { iMessageType=EIrMessage; iFolderType=ESent; iAttachments->Reset(); iAttachments->AppendL( iEngine->RandomNumber(CCreatorEngine::EJPEG_25kB, CCreatorEngine::LAST_FILE_ID-1) ); err=CreateMessageEntryL(NULL); break;} - - case ECmdCreateRandomEntryBTInbox: { iMessageType=EBTMessage; iFolderType=EInbox; iAttachments->Reset(); iAttachments->AppendL( iEngine->RandomNumber(CCreatorEngine::EJPEG_25kB, CCreatorEngine::LAST_FILE_ID-1) ); err=CreateMessageEntryL(NULL); break;} - case ECmdCreateRandomEntryBTDrafts: { iMessageType=EBTMessage; iFolderType=EDrafts; iAttachments->Reset(); iAttachments->AppendL( iEngine->RandomNumber(CCreatorEngine::EJPEG_25kB, CCreatorEngine::LAST_FILE_ID-1) ); err=CreateMessageEntryL(NULL); break;} - case ECmdCreateRandomEntryBTOutbox: { iMessageType=EBTMessage; iFolderType=EOutbox; iAttachments->Reset(); iAttachments->AppendL( iEngine->RandomNumber(CCreatorEngine::EJPEG_25kB, CCreatorEngine::LAST_FILE_ID-1) ); err=CreateMessageEntryL(NULL); break;} - case ECmdCreateRandomEntryBTSent: { iMessageType=EBTMessage; iFolderType=ESent; iAttachments->Reset(); iAttachments->AppendL( iEngine->RandomNumber(CCreatorEngine::EJPEG_25kB, CCreatorEngine::LAST_FILE_ID-1) ); err=CreateMessageEntryL(NULL); break;} - - case ECmdCreateRandomEntryAMSInbox: { iMessageType=EAMS; iFolderType=EInbox; iAttachments->Reset(); iAttachments->AppendL( CCreatorEngine::EMP3_250kB); err=CreateMessageEntryL(NULL); break;} - case ECmdCreateRandomEntryAMSDrafts: { iMessageType=EAMS; iFolderType=EDrafts; iAttachments->Reset(); iAttachments->AppendL( CCreatorEngine::EMP3_250kB); err=CreateMessageEntryL(NULL); break;} - case ECmdCreateRandomEntryAMSOutbox: { iMessageType=EAMS; iFolderType=EOutbox; iAttachments->Reset(); iAttachments->AppendL( CCreatorEngine::EMP3_250kB); err=CreateMessageEntryL(NULL); break;} - case ECmdCreateRandomEntryAMSSent: { iMessageType=EAMS; iFolderType=ESent; iAttachments->Reset(); iAttachments->AppendL( CCreatorEngine::EMP3_250kB); err=CreateMessageEntryL(NULL); break;} - - default: { User::Panic(_L("MessageCommand"), 901); break;} - } - - return err; - } - -//---------------------------------------------------------------------------- - -TInt CCreatorMessages::CreateMessageEntryL(CMessagesParameters *aParameters, TBool /*aTakeUserGivenParameters*/) - { - LOGSTRING("Creator: CCreatorMessages::CreateMessageEntryL"); - - delete iParameters; - iParameters = 0; - - CMessagesParameters* parameters = aParameters; - - // random data needed if no predefined data available - if (!parameters) - { - iParameters = new(ELeave) CMessagesParameters; - parameters = iParameters; - // check if values from ui needed - //if (aTakeUserGivenParameters) - // { - parameters->iMessageType = iMessageType; - parameters->iFolderType = iFolderType; - parameters->iDefinedMessageLength = iDefinedMessageLength; - parameters->iCreateAsUnread = iCreateAsUnread; - - for (TInt i=0; iCount(); i++) - parameters->iAttachments->AppendL(iAttachments->At(i)); - // } - //else - // { - // message length - // parameters->iDefinedMessageLength = iEngine->RandomNumber(100, 300); - // } - - if (parameters->iMessageType == EEmail) - { - parameters->iSenderAddress->Des().Copy( iEngine->RandomString(CCreatorEngine::EFirstName) ); - parameters->iSenderAddress->Des().Append( _L("@") ); - parameters->iSenderAddress->Des().Append( iEngine->RandomString(CCreatorEngine::ECompany) ); - parameters->iSenderAddress->Des().Append( _L(".com") ); - - parameters->iRecipientAddress->Des().Copy( iEngine->RandomString(CCreatorEngine::EFirstName) ); - parameters->iRecipientAddress->Des().Append( _L("@") ); - parameters->iRecipientAddress->Des().Append( iEngine->RandomString(CCreatorEngine::ECompany) ); - parameters->iRecipientAddress->Des().Append( _L(".net") ); - } - else if (parameters->iMessageType == EIrMessage || parameters->iMessageType == EBTMessage) - { - parameters->iSenderAddress->Des().Copy( iEngine->RandomString(CCreatorEngine::EFirstName) ); - parameters->iRecipientAddress->Des().Copy( iEngine->RandomString(CCreatorEngine::EFirstName) ); - } - else - { - parameters->iSenderAddress->Des().Copy( iEngine->RandomString(CCreatorEngine::EPhoneNumber) ); - parameters->iRecipientAddress->Des().Copy( iEngine->RandomString(CCreatorEngine::EPhoneNumber) ); - } - - // subject - parameters->iMessageSubject->Des() = iEngine->RandomString(CCreatorEngine::EMessageSubject); - - // message body - parameters->iMessageBodyText->Des().Copy(_L("")); - TPtrC randText = iEngine->RandomString(CCreatorEngine::EMessageText); - for (TInt i=0; iiDefinedMessageLength / randText.Length() +1; i++) - { - parameters->iMessageBodyText->Des().Append( randText ); - parameters->iMessageBodyText->Des().Append( _L(" ") ); - } - parameters->iMessageBodyText->Des() = parameters->iMessageBodyText->Des().Left(parameters->iDefinedMessageLength); - - // BIO message type (from bitsids.h) // TO-DO: add support for all BIO message types... - parameters->iBIOMessageType = KUidBIOBusinessCardMsg; - } - - - - TInt err = KErrNone; - - switch (parameters->iMessageType) - { - case ESMS: { err = CreateSMSEntryL(*parameters); break; } - case EMMS: { err = CreateMMSEntryL(*parameters); break; } - case EAMS: { err = CreateAMSEntryL(*parameters); break; } - case EEmail: { err = CreateEmailEntryL(*parameters); break; } - case ESmartMessage: { err = CreateSmartMessageEntryL(*parameters); break; } - case EIrMessage: { err = CreateObexEntryL( TUid::Uid(KUidMsgTypeIrTInt32), *parameters ); break; } - case EBTMessage: { err = CreateObexEntryL( TUid::Uid(KUidMsgTypeBtTInt32), *parameters ); break; } - default: { User::Panic(_L("MsgType"), 851); break;} - - } - - iSenderArray.ResetAndDestroy(); - iRecipientArray.ResetAndDestroy(); - return err; - } - -//---------------------------------------------------------------------------- - -TInt CCreatorMessages::CreateSMSEntryL(const CMessagesParameters& parameters) - { - LOGSTRING("Creator: CCreatorMessages::CreateSMSEntryL"); - - TInt err = KErrNone; - - - // init - CMsvSession* session = CMsvSession::OpenSyncL(*this); - CleanupStack::PushL(session); - CClientMtmRegistry* registry = CClientMtmRegistry::NewL(*session); - CleanupStack::PushL(registry); - - // get the client mtm and return if it isn't supported in the system - CSmsClientMtm* clientMtm = NULL; - TRAP(err, clientMtm = static_cast(registry->NewMtmL(KUidMsgTypeSMS))); - if (err || !clientMtm) - { - iEngine->GetEngineWrapper()->ShowErrorMessage(_L("SMS: Message type module not found")); - CleanupStack::PopAndDestroy(2); - User::Leave(KErrNotFound); - } - CleanupStack::PushL(clientMtm); - - // create a new object to access an existing entry - CMsvEntry* msvEntry = CMsvEntry::NewL(*session, KMsvGlobalInBoxIndexEntryId, TMsvSelectionOrdering()); - CleanupStack::PushL(msvEntry); - - // get default service - TMsvId defaultServiceId = 0; - TRAP(err, defaultServiceId = clientMtm->DefaultServiceL()); - if (err) - { - iEngine->GetEngineWrapper()->ShowErrorMessage(_L("SMS: Define a SMS centre first")); - CleanupStack::PopAndDestroy(2); - User::Leave(KErrNotFound); - } - - // set folder type - switch (parameters.iFolderType) - { - case EInbox: { msvEntry->SetEntryL(KMsvGlobalInBoxIndexEntryId); break; } - case EDrafts: { msvEntry->SetEntryL(KMsvDraftEntryId); break; } - case EOutbox: { msvEntry->SetEntryL(KMsvGlobalOutBoxIndexEntryId); break; } - case ESent: { msvEntry->SetEntryL(KMsvSentEntryId); break; } - default: { User::Panic(_L("Folder Type"), 871); break; } - } - - // mtm takes ownership of entry context - CleanupStack::Pop(msvEntry); - clientMtm->SetCurrentEntryL(msvEntry); - - // create a new message - clientMtm->CreateMessageL(defaultServiceId); - - // set the from field to sms header - // !!! This will cause CRASH - /*if (parameters.iFolderType == EInbox) - { - CSmsHeader* smsHeader = &clientMtm->SmsHeader(); - delete smsHeader; // <-- This will cause CRASH - smsHeader = NULL; - smsHeader = CSmsHeader::NewL(CSmsPDU::ESmsDeliver, clientMtm->Body()); - if( parameters.iSenderAddress ) - { - smsHeader->SetFromAddressL( parameters.iSenderAddress->Des() ); - } - else - { - smsHeader->SetFromAddressL(KEmpty); - } - } */ - - // set body - clientMtm->Body().Reset(); - clientMtm->Body().InsertL(0, parameters.iMessageBodyText->Des()); - - // get the entry of the message - TMsvEntry messageEntry = clientMtm->Entry().Entry(); - - // set the details field - if (parameters.iFolderType == EInbox) - { - SetSenderToEntryDetailsL(messageEntry, parameters, EFalse); - } - else - { - SetRecipientToEntryDetailsL(messageEntry, parameters, EFalse); - // Add all recipients to clientMtm - // iRecipientArray is up-to-date so don't call AddRecipientsL here - for( TInt i = 0; i < iRecipientArray.Count(); i++ ) - { - clientMtm->AddAddresseeL( iRecipientArray[i]->Des() ); - } - } - - // set the sending state for outbox message - // to avoid SMSMtmUI:15 panic in messages application - if (parameters.iFolderType == EOutbox ) - { - messageEntry.SetSendingState( KMsvSendStateWaiting ); - } - - // set the description field same as the first part of the message body - messageEntry.iDescription.Set( parameters.iMessageBodyText->Des().Left(KSmsDescriptionLength) ); - - // save the changes done above - clientMtm->Entry().ChangeL(messageEntry); - - // save the message - clientMtm->SaveMessageL(); - - // final fine tuning - messageEntry.SetAttachment(EFalse); - messageEntry.iDate.HomeTime(); - messageEntry.SetVisible(ETrue); - messageEntry.SetInPreparation(EFalse); - - if (parameters.iCreateAsUnread) - { - messageEntry.SetUnread(ETrue); - messageEntry.SetNew(ETrue); - } - else - { - messageEntry.SetUnread(EFalse); - messageEntry.SetNew(EFalse); - } - - messageEntry.SetComplete(ETrue); - messageEntry.iServiceId = defaultServiceId; - messageEntry.iRelatedId = 0; - clientMtm->Entry().ChangeL(messageEntry); - - // id has been generated, store it for being able to delete - // only entries created with Creator - iEntryIds.AppendL( messageEntry.Id() ); - - CleanupStack::PopAndDestroy(3); //session, registry, clientMtm - - return err; - - } - -//---------------------------------------------------------------------------- - -TInt CCreatorMessages::CreateMMSEntryL(const CMessagesParameters& parameters) - { - LOGSTRING("Creator: CCreatorMessages::CreateMMSEntryL"); - - TInt err = KErrNone; - - // init - CMsvSession* session = CMsvSession::OpenSyncL(*this); - CleanupStack::PushL(session); - CClientMtmRegistry* registry = CClientMtmRegistry::NewL(*session); - CleanupStack::PushL(registry); - - // get the client mtm and return if it isn't supported in the system - CMmsClientMtm* clientMtm = NULL; - TRAP(err, clientMtm = static_cast(registry->NewMtmL(KUidMsgTypeMultimedia))); - if (err || !clientMtm) - { - iEngine->GetEngineWrapper()->ShowErrorMessage(_L("MMS: Message type module not found")); - CleanupStack::PopAndDestroy(2); - User::Leave(KErrNotFound); - } - CleanupStack::PushL(clientMtm); - - // create a new object to access an existing entry - CMsvEntry* msvEntry = CMsvEntry::NewL(*session, KMsvGlobalInBoxIndexEntryId, TMsvSelectionOrdering()); - CleanupStack::PushL(msvEntry); - - // get default service - TMsvId defaultServiceId = 0; - TRAP(err, defaultServiceId = clientMtm->DefaultServiceL()); - if (err) - { - iEngine->GetEngineWrapper()->ShowErrorMessage(_L("MMS: Define MMS settings first")); - CleanupStack::PopAndDestroy(4); - User::Leave(KErrNotFound); - } - - // set folder type - switch (parameters.iFolderType) - { - case EInbox: { msvEntry->SetEntryL(KMsvGlobalInBoxIndexEntryId); break; } - case EDrafts: { msvEntry->SetEntryL(KMsvDraftEntryId); break; } - case EOutbox: { msvEntry->SetEntryL(KMsvGlobalOutBoxIndexEntryId); break; } - case ESent: { msvEntry->SetEntryL(KMsvSentEntryId); break; } - default: { User::Panic(_L("Folder Type"), 871); break; } - } - - // mtm takes ownership of entry context - CleanupStack::Pop(msvEntry); - clientMtm->SetCurrentEntryL(msvEntry); - - // create a new message - clientMtm->CreateMessageL(defaultServiceId); - - // set subject - clientMtm->SetSubjectL( parameters.iMessageSubject->Des() ); - - // set some mms defaults - clientMtm->SetMessageClass(EMmsClassPersonal); - clientMtm->SetExpiryInterval(86400); - clientMtm->SetDeliveryTimeInterval(3600); - clientMtm->SetMessagePriority(EMmsPriorityLow); - clientMtm->SetSenderVisibility(EMmsMaximumSenderVisibility); - clientMtm->SetDeliveryReport(EMmsDeliveryReportYes); - clientMtm->SetReadReply(EMmsReadReplyYes); - - // set the sender / addressee field - if (parameters.iFolderType == EInbox) - { - AddMtmSenderL(*clientMtm, parameters, EFalse); - } - - // Add all recipients to clientMtm - AddRecipientsL( *clientMtm, parameters, EFalse ); - - // get an access to the message store - CMsvStore* store = msvEntry->EditStoreL(); - CleanupStack::PushL(store); - - - // set body as an attachment - CMsvMimeHeaders* mimeHeaders = CMsvMimeHeaders::NewL(); - CleanupStack::PushL(mimeHeaders); - mimeHeaders->SetContentTypeL( _L8("text") ); - mimeHeaders->SetContentSubTypeL( _L8("plain") ); - mimeHeaders->SetMimeCharset( KMmsUtf8 ); - mimeHeaders->SetSuggestedFilenameL( _L("body.txt") ); - - MMsvAttachmentManager& attachMan = store->AttachmentManagerL(); - CMsvAttachment* attachmentInfo = CMsvAttachment::NewL(CMsvAttachment::EMsvFile); // ownership of attachmentInfo will be transferred - CleanupStack::PushL(attachmentInfo); - attachmentInfo->SetAttachmentNameL( _L("body.txt") ); - attachmentInfo->SetMimeTypeL( _L8("text/plain") ); - mimeHeaders->StoreL( *attachmentInfo ); - - RFile textFile; - - CAsyncWaiter* waiter = CAsyncWaiter::NewLC(); - attachMan.CreateAttachmentL(_L("body.txt"), textFile, attachmentInfo, waiter->iStatus ); - CleanupStack::Pop(); // waiter - CleanupStack::Pop(); // attachmentInfo - CleanupStack::PushL(waiter); - waiter->StartAndWait(); - CleanupStack::PopAndDestroy(waiter); - - HBufC8* tempBuf = CnvUtfConverter::ConvertFromUnicodeToUtf8L( parameters.iMessageBodyText->Des() ); - CleanupStack::PushL(tempBuf); - textFile.Write( tempBuf->Des() ); - textFile.Close(); - CleanupStack::PopAndDestroy(); //tempBuf - - CleanupStack::PopAndDestroy(); //mimeHeaders - - - // get the entry of the message - TMsvEntry messageEntry = clientMtm->Entry().Entry(); - - // set the details field - if (parameters.iFolderType == EInbox) - { - SetSenderToEntryDetailsL(messageEntry, parameters, EFalse); - } - else - { - SetRecipientToEntryDetailsL(messageEntry, parameters, EFalse); - } - - // set the description field same as the message subject - messageEntry.iDescription.Set( parameters.iMessageSubject->Des().Left(KSmsDescriptionLength) ); - - // save the changes done above - clientMtm->Entry().ChangeL(messageEntry); - - - // save the attachments - HandleAttachementsL(parameters, store, err ); -// for (TInt i=0; iCount(); i++) -// { -// TFileName sourceFileName = iEngine->TestDataPathL( (CCreatorEngine::TTestDataPath) parameters.iAttachments->At(i) ); -// -// TParse parser; -// parser.Set(sourceFileName, NULL, NULL); -// TFileName shortFileName = parser.NameAndExt(); -// -// // get the mime type -// RApaLsSession ls; -// User::LeaveIfError(ls.Connect()); -// CleanupClosePushL(ls); -// TUid appUid; -// TDataType dataType; -// ls.AppForDocument(sourceFileName, appUid, dataType); -// CleanupStack::PopAndDestroy(); //ls -// TPtrC8 mimeType = dataType.Des8(); -// -// // attachment settings -// MMsvAttachmentManager& attachMan = store->AttachmentManagerL(); -// CMsvAttachment* attachmentInfo = CMsvAttachment::NewL(CMsvAttachment::EMsvFile); // ownership of attachmentInfo will be transferred -// attachmentInfo->SetAttachmentNameL( shortFileName ); -// attachmentInfo->SetMimeTypeL( mimeType ); -// -// // save -// CAsyncWaiter* waiter = CAsyncWaiter::NewLC(); -// -// TRAP(err, attachMan.AddAttachmentL(sourceFileName, attachmentInfo, waiter->iStatus )); -// if (err == KErrNone) -// waiter->StartAndWait(); -// else -// LOGSTRING2("Creator: CCreatorMessages::CreateMMSEntryL failed to attach %S", &sourceFileName); -// -// CleanupStack::PopAndDestroy(waiter); -// } - - // save the changes made to the message store - store->CommitL(); - CleanupStack::PopAndDestroy(store); - - - // save the message - clientMtm->SaveMessageL(); - - // final fine tuning - messageEntry.SetAttachment(ETrue); - messageEntry.iDate.HomeTime(); - messageEntry.SetVisible(ETrue); - messageEntry.SetInPreparation(EFalse); - if (parameters.iCreateAsUnread) - { - messageEntry.SetUnread(ETrue); - messageEntry.SetNew(ETrue); - } - else - { - messageEntry.SetUnread(EFalse); - messageEntry.SetNew(EFalse); - } - messageEntry.SetComplete(ETrue); - messageEntry.iServiceId = defaultServiceId; - messageEntry.iRelatedId = 0; - - if (parameters.iFolderType == EDrafts) - messageEntry.SetReadOnly(EFalse); - else - messageEntry.SetReadOnly(ETrue); - - messageEntry.iMtmData1 = KMmsMessageMRetrieveConf | KMmsMessageMobileTerminated; - - clientMtm->Entry().ChangeL(messageEntry); - - // id has been generated, store it for being able to delete - // only entries created with Creator - iEntryIds.AppendL( messageEntry.Id() ); - - CleanupStack::PopAndDestroy(3); //session, registry, clientMtm - - - return err; - } - -//---------------------------------------------------------------------------- -void CCreatorMessages::HandleAttachementsL(const CMessagesParameters& parameters, CMsvStore* store, TInt err ) - { - // save the attachments (added with id's) - for (TInt i=0; iCount(); i++) - { - TFileName sourceFileName = iEngine->TestDataPathL( (CCreatorEngine::TTestDataPath) parameters.iAttachments->At(i) ); - HandleAttachementL(store, err, sourceFileName ); - - } - //Adding attachmentpaths - for (TInt i=0; iDes()); - HandleAttachementL(store, err, sourceFileName ); - } - } -//---------------------------------------------------------------------------- - -void CCreatorMessages::HandleAttachementL(CMsvStore* store, TInt err, TFileName& sourceFileName ) - { - TParse parser; - parser.Set(sourceFileName, NULL, NULL); - TFileName shortFileName = parser.NameAndExt(); - - // get the mime type - RApaLsSession ls; - User::LeaveIfError(ls.Connect()); - CleanupClosePushL(ls); - TUid appUid; - TDataType dataType; - ls.AppForDocument(sourceFileName, appUid, dataType); - CleanupStack::PopAndDestroy(); //ls - TPtrC8 mimeType = dataType.Des8(); - - // attachment settings - MMsvAttachmentManager& attachMan = store->AttachmentManagerL(); - CMsvAttachment* attachmentInfo = CMsvAttachment::NewL(CMsvAttachment::EMsvFile); // ownership of attachmentInfo will be transferred - CleanupStack::PushL(attachmentInfo); - attachmentInfo->SetAttachmentNameL( shortFileName ); - attachmentInfo->SetMimeTypeL( mimeType ); - - if ( mimeType == _L8("text/plain") ) - { - // CMsvMimeHeaders needs to be stored in case of text file - CMsvMimeHeaders* mimeHeaders = CMsvMimeHeaders::NewL(); - CleanupStack::PushL(mimeHeaders); - mimeHeaders->SetContentTypeL( _L8("text") ); - mimeHeaders->SetContentSubTypeL( _L8("plain") ); - mimeHeaders->SetMimeCharset( KMmsUtf8 ); - mimeHeaders->StoreL( *attachmentInfo ); - CleanupStack::PopAndDestroy( mimeHeaders ); - } - - // save - - CAsyncWaiter* waiter = CAsyncWaiter::NewLC(); - TRAP(err, attachMan.AddAttachmentL(sourceFileName, attachmentInfo, waiter->iStatus )); - if (err == KErrNone) - { - waiter->StartAndWait(); - CleanupStack::PopAndDestroy(waiter); - CleanupStack::Pop(); // attachmentInfo, the ownership is transferred - } - else - { - CleanupStack::PopAndDestroy(waiter); - CleanupStack::PopAndDestroy(); // attachmentInfo, ownership is not transferred (leave occurs) - LOGSTRING2("Creator: CCreatorMessages::HandleAttachementsL failed to attach %S", &sourceFileName); - } - } - //---------------------------------------------------------------------------- - -TInt CCreatorMessages::CreateAMSEntryL(const CMessagesParameters& parameters) - { - LOGSTRING("Creator: CCreatorMessages::CreateAMSEntryL"); - - TInt err = KErrNone; - - - // init - CMsvSession* session = CMsvSession::OpenSyncL(*this); - CleanupStack::PushL(session); - CClientMtmRegistry* registry = CClientMtmRegistry::NewL(*session); - CleanupStack::PushL(registry); - - // get the client mtm and return if it isn't supported in the system - CMmsClientMtm* clientMtm = NULL; - TRAP(err, clientMtm = static_cast(registry->NewMtmL(KUidMsgTypeMultimedia))); - if (err || !clientMtm) - { - iEngine->GetEngineWrapper()->ShowErrorMessage(_L("MMS: Message type module not found")); - CleanupStack::PopAndDestroy(2); - User::Leave(KErrNotFound); - } - CleanupStack::PushL(clientMtm); - - // create a new object to access an existing entry - CMsvEntry* msvEntry = CMsvEntry::NewL(*session, KMsvGlobalInBoxIndexEntryId, TMsvSelectionOrdering()); - CleanupStack::PushL(msvEntry); - - // get default service - TMsvId defaultServiceId = 0; - TRAP(err, defaultServiceId = clientMtm->DefaultServiceL()); - if (err) - { - iEngine->GetEngineWrapper()->ShowErrorMessage(_L("MMS: Define MMS settings first")); - CleanupStack::PopAndDestroy(2); - User::Leave(KErrNotFound); - } - - // set folder type - switch (parameters.iFolderType) - { - case EInbox: { msvEntry->SetEntryL(KMsvGlobalInBoxIndexEntryId); break; } - case EDrafts: { msvEntry->SetEntryL(KMsvDraftEntryId); break; } - case EOutbox: { msvEntry->SetEntryL(KMsvGlobalOutBoxIndexEntryId); break; } - case ESent: { msvEntry->SetEntryL(KMsvSentEntryId); break; } - default: { User::Panic(_L("Folder Type"), 871); break; } - } - - // mtm takes ownership of entry context - CleanupStack::Pop(msvEntry); - clientMtm->SetCurrentEntryL(msvEntry); - - // create a new message - clientMtm->CreateMessageL(defaultServiceId); - - // set subject - clientMtm->SetSubjectL(parameters.iMessageSubject->Des() ); - - // set some mms defaults - clientMtm->SetMessageClass(EMmsClassPersonal); - clientMtm->SetExpiryInterval(86400); - clientMtm->SetDeliveryTimeInterval(3600); - clientMtm->SetMessagePriority(EMmsPriorityLow); - clientMtm->SetSenderVisibility(EMmsMaximumSenderVisibility); - clientMtm->SetDeliveryReport(EMmsDeliveryReportYes); - clientMtm->SetReadReply(EMmsReadReplyYes); - - // set the sender / addressee field - if (parameters.iFolderType == EInbox) - { - AddMtmSenderL(*clientMtm, parameters, EFalse); - } - - // Add all recipients to clientMtm - AddRecipientsL( *clientMtm, parameters, EFalse ); - - - // get an access to the message store - CMsvStore* store = msvEntry->EditStoreL(); - CleanupStack::PushL(store); - - // get the entry of the message - TMsvEntry messageEntry = clientMtm->Entry().Entry(); - - // set the details field - if (parameters.iFolderType == EInbox) - { - SetSenderToEntryDetailsL(messageEntry, parameters, EFalse); - } - else - { - SetRecipientToEntryDetailsL(messageEntry, parameters, EFalse); - } - - // set the description field same as the message subject - messageEntry.iDescription.Set( parameters.iMessageSubject->Des().Left(KSmsDescriptionLength) ); - messageEntry.iBioType = KUidMsgSubTypeMmsAudioMsg.iUid; - - // save the changes done above - clientMtm->Entry().ChangeL(messageEntry); - - - TFileName sourceFileName = iEngine->TestDataPathL( CCreatorEngine::EAMR_20kB ); - TParse parser; - parser.Set(sourceFileName, NULL, NULL); - TFileName shortFileName = parser.NameAndExt(); - - // get the mime type - RApaLsSession ls; - User::LeaveIfError(ls.Connect()); - CleanupClosePushL(ls); - TUid appUid; - TDataType dataType; - ls.AppForDocument(sourceFileName, appUid, dataType); - CleanupStack::PopAndDestroy(); //ls - TPtrC8 mimeType = dataType.Des8(); - - // attachment settings - MMsvAttachmentManager& attachMan = store->AttachmentManagerL(); - CMsvAttachment* attachmentInfo = CMsvAttachment::NewL(CMsvAttachment::EMsvFile); // ownership of attachmentInfo will be transferred - attachmentInfo->SetAttachmentNameL( shortFileName ); - attachmentInfo->SetMimeTypeL( mimeType ); - - // save - CAsyncWaiter* waiter = CAsyncWaiter::NewLC(); - - TRAP(err, attachMan.AddAttachmentL(sourceFileName, attachmentInfo, waiter->iStatus )); - if (err == KErrNone) - waiter->StartAndWait(); - else - LOGSTRING2("Creator: CCreatorMessages::CreateAMSEntryL failed to attach %S", &sourceFileName); - - CleanupStack::PopAndDestroy(waiter); - - // save the changes made to the message store - store->CommitL(); - CleanupStack::PopAndDestroy(store); - - - // save the message - clientMtm->SaveMessageL(); - - // final fine tuning - messageEntry.SetAttachment(ETrue); - messageEntry.iDate.HomeTime(); - messageEntry.SetVisible(ETrue); - messageEntry.SetInPreparation(EFalse); - if (parameters.iCreateAsUnread) - { - messageEntry.SetUnread(ETrue); - messageEntry.SetNew(ETrue); - } - else - { - messageEntry.SetUnread(EFalse); - messageEntry.SetNew(EFalse); - } - messageEntry.SetComplete(ETrue); - messageEntry.iServiceId = defaultServiceId; - messageEntry.iRelatedId = 0; - - if (parameters.iFolderType == EDrafts) - messageEntry.SetReadOnly(EFalse); - else - messageEntry.SetReadOnly(ETrue); - - messageEntry.iMtmData1 = KMmsMessageMRetrieveConf | KMmsMessageMobileTerminated; - - clientMtm->Entry().ChangeL(messageEntry); - - // id has been generated, store it for being able to delete - // only entries created with Creator - iEntryIds.AppendL( messageEntry.Id() ); - - CleanupStack::PopAndDestroy(3); //session, registry, clientMtm - - - return err; - } - -//---------------------------------------------------------------------------- - -TInt CCreatorMessages::CreateEmailEntryL(const CMessagesParameters& parameters) - { - LOGSTRING("Creator: CCreatorMessages::CreateEmailEntryL"); - - TInt err = KErrNone; - - // init - CMsvSession* session = CMsvSession::OpenSyncL(*this); - CleanupStack::PushL(session); - CClientMtmRegistry* registry = CClientMtmRegistry::NewL(*session); - CleanupStack::PushL(registry); - - // get the client mtm and return if it isn't supported in the system - CSmtpClientMtm* clientMtm = NULL; - TRAP(err, clientMtm = static_cast(registry->NewMtmL(KUidMsgTypeSMTP))); - - if (err || !clientMtm) - { - iEngine->GetEngineWrapper()->ShowErrorMessage(_L("Email: Message type module not found")); - CleanupStack::PopAndDestroy(2); - User::Leave(KErrNotFound); - } - CleanupStack::PushL(clientMtm); - - // create a new object to access an existing entry - CMsvEntry* msvEntry = CMsvEntry::NewL(*session, KMsvGlobalInBoxIndexEntryId, TMsvSelectionOrdering()); - CleanupStack::PushL(msvEntry); - - // get default service - TMsvId defaultServiceId(0); - TRAP(err, defaultServiceId = clientMtm->DefaultServiceL()); - if (err) - { - iEngine->GetEngineWrapper()->ShowErrorMessage(_L("Email: Define a mailbox first")); - CleanupStack::PopAndDestroy(2); - User::Leave(KErrNotFound); - } - - // set folder type - switch (parameters.iFolderType) - { - case EInbox: { msvEntry->SetEntryL(KMsvGlobalInBoxIndexEntryId); break; } - case EDrafts: { msvEntry->SetEntryL(KMsvDraftEntryId); break; } - case EOutbox: { msvEntry->SetEntryL(KMsvGlobalOutBoxIndexEntryId); break; } - case ESent: { msvEntry->SetEntryL(KMsvSentEntryId); break; } - case EMailbox: { msvEntry->SetEntryL(iUserSelectedMailbox); break; } - default: { User::Panic(_L("Folder Type"), 871); break; } - } - - // mtm takes ownership of entry context - CleanupStack::Pop(msvEntry); - clientMtm->SetCurrentEntryL(msvEntry); - - // create a new message - clientMtm->CreateMessageL(defaultServiceId); - - // set subject - clientMtm->SetSubjectL( parameters.iMessageSubject->Des() ); - - // set body - clientMtm->Body().Reset(); - clientMtm->Body().InsertL(0, parameters.iMessageBodyText->Des()); - - // get the entry of the message - TMsvEntry messageEntry = clientMtm->Entry().Entry(); - - // set the address fields - if (parameters.iFolderType == EInbox) - { - AddSenderToMtmAddresseeL(*clientMtm, parameters, ETrue ); - SetSenderToEntryDetailsL(messageEntry, parameters, ETrue); - messageEntry.iMtm = KUidMsgTypeIMAP4; // or any other than KUidMsgTypeSMTP to display 'from' field instead of 'to' field - } - else - { - // Add all recipients to clientMtm - AddRecipientsL( *clientMtm, parameters, ETrue ); - SetRecipientToEntryDetailsL(messageEntry, parameters, EFalse); - } - - // set the description field same as the message subject - messageEntry.iDescription.Set( parameters.iMessageSubject->Des().Left(KSmsDescriptionLength) ); - - // save the changes done above - clientMtm->Entry().ChangeL(messageEntry); - - // get an access to the message store - CMsvStore* store = msvEntry->EditStoreL(); - CleanupStack::PushL(store); - - // save the attachments - HandleAttachementsL(parameters, store, err); -// for (TInt i=0; iCount(); i++) -// { -// TFileName sourceFileName = iEngine->TestDataPathL( (CCreatorEngine::TTestDataPath) parameters.iAttachments->At(i) ); -// -// TParse parser; -// parser.Set(sourceFileName, NULL, NULL); -// TFileName shortFileName = parser.NameAndExt(); -// -// // get the mime type -// RApaLsSession ls; -// User::LeaveIfError(ls.Connect()); -// CleanupClosePushL(ls); -// TUid appUid; -// TDataType dataType; -// ls.AppForDocument(sourceFileName, appUid, dataType); -// CleanupStack::PopAndDestroy(); //ls -// TPtrC8 mimeType = dataType.Des8(); -// -// // attachment settings -// MMsvAttachmentManager& attachMan = store->AttachmentManagerL(); -// CMsvAttachment* attachmentInfo = CMsvAttachment::NewL(CMsvAttachment::EMsvFile); // ownership of attachmentInfo will be transferred -// attachmentInfo->SetAttachmentNameL( shortFileName ); -// attachmentInfo->SetMimeTypeL( mimeType ); -// -// // save -// CAsyncWaiter* waiter = CAsyncWaiter::NewLC(); -// -// TRAP(err, attachMan.AddAttachmentL(sourceFileName, attachmentInfo, waiter->iStatus )); -// if (err == KErrNone) -// waiter->StartAndWait(); -// else -// LOGSTRING2("Creator: CCreatorMessages::CreateEmailEntryL failed to attach %S", &sourceFileName); -// -// CleanupStack::PopAndDestroy(waiter); -// } - - // save the changes made to the message store - store->CommitL(); - CleanupStack::PopAndDestroy(store); - - // save the message - clientMtm->SaveMessageL(); - - // final fine tuning - TMsvEmailEntry temailEntry = static_cast(messageEntry); - temailEntry.SetMessageFolderType(EFolderTypeUnknown); - temailEntry.SetDisconnectedOperation(ENoDisconnectedOperations); - temailEntry.SetEncrypted(EFalse); - temailEntry.SetSigned(EFalse); - temailEntry.SetVCard(EFalse); - temailEntry.SetVCalendar(EFalse); - temailEntry.SetReceipt(EFalse); - temailEntry.SetMHTMLEmail(EFalse); - temailEntry.SetBodyTextComplete(ETrue); - - if (parameters.iAttachments->Count() > 0) - temailEntry.SetAttachment(ETrue); - else - temailEntry.SetAttachment(EFalse); - - temailEntry.iDate.HomeTime(); - temailEntry.SetVisible(ETrue); - temailEntry.SetInPreparation(EFalse); - if (parameters.iCreateAsUnread) - { - temailEntry.SetUnread(ETrue); - temailEntry.SetNew(ETrue); - } - else - { - temailEntry.SetUnread(EFalse); - temailEntry.SetNew(EFalse); - } - temailEntry.SetComplete(ETrue); - temailEntry.iServiceId = defaultServiceId; - temailEntry.iRelatedId = 0; - - clientMtm->Entry().ChangeL(temailEntry); - - // reset email headers - CImHeader* header = CImHeader::NewLC(); - CMsvStore* msvStore = msvEntry->EditStoreL(); - CleanupStack::PushL(msvStore); - header->RestoreL(*msvStore); - header->SetSubjectL( parameters.iMessageSubject->Des() ); - if( iSenderArray.Count() == 0 ) - { - GetSendersL(iSenderArray, parameters, ETrue, KUndef ); - } - - if( iSenderArray.Count() > 0 ) - { - TInt rndNum = iEngine->RandomNumber( iSenderArray.Count() ); - header->SetFromL(iSenderArray[rndNum]->Des()); - } - else - { - header->SetFromL( parameters.iSenderAddress->Des() ); - } - if( parameters.iRecipientAddress->Length() > 0 ) - { - header->SetReceiptAddressL( parameters.iRecipientAddress->Des() ); - } - else if( parameters.iRecipientAddressArray.Count() > 0 ) - { - header->SetReceiptAddressL( parameters.iRecipientAddressArray[0]->Des()); - } - - header->StoreL( *msvStore ); - msvStore->CommitL(); - CleanupStack::PopAndDestroy(2); // msvStore, header - - // id has been generated, store it for being able to delete - // only entries created with Creator - iEntryIds.AppendL( messageEntry.Id() ); - - CleanupStack::PopAndDestroy(3); //session, registry, clientMtm - - return err; - } - -//---------------------------------------------------------------------------- - -TInt CCreatorMessages::CreateSmartMessageEntryL(const CMessagesParameters& parameters) - { - LOGSTRING("Creator: CCreatorMessages::CreateSmartMessageEntryL"); - - TInt err = KErrNone; - - // init - CMsvSession* session = CMsvSession::OpenSyncL(*this); - CleanupStack::PushL(session); - CClientMtmRegistry* registry = CClientMtmRegistry::NewL(*session); - CleanupStack::PushL(registry); - - // get the client mtm and return if it isn't supported in the system - CSmsClientMtm* clientMtm = NULL; - TRAP(err, clientMtm = static_cast(registry->NewMtmL(KUidMsgTypeSMS))); - if (err || !clientMtm) - { - iEngine->GetEngineWrapper()->ShowErrorMessage(_L("BIO: Message type module not found")); - CleanupStack::PopAndDestroy(2); - User::Leave(KErrNotFound); - } - CleanupStack::PushL(clientMtm); - - // create a new object to access an existing entry - CMsvEntry* msvEntry = CMsvEntry::NewL(*session, KMsvGlobalInBoxIndexEntryId, TMsvSelectionOrdering()); - CleanupStack::PushL(msvEntry); - - // get default service - TMsvId defaultServiceId = 0; - TRAP(err, defaultServiceId = clientMtm->DefaultServiceL()); - if (err) - { - iEngine->GetEngineWrapper()->ShowErrorMessage(_L("SMS: Define a SMS centre first")); - CleanupStack::PopAndDestroy(2); - User::Leave(KErrNotFound); - } - - // set folder type - switch (parameters.iFolderType) - { - case EInbox: { msvEntry->SetEntryL(KMsvGlobalInBoxIndexEntryId); break; } - case EDrafts: { msvEntry->SetEntryL(KMsvDraftEntryId); break; } - case EOutbox: { msvEntry->SetEntryL(KMsvGlobalOutBoxIndexEntryId); break; } - case ESent: { msvEntry->SetEntryL(KMsvSentEntryId); break; } - default: { User::Panic(_L("Folder Type"), 871); break; } - } - - // mtm takes ownership of entry context - CleanupStack::Pop(msvEntry); - clientMtm->SetCurrentEntryL(msvEntry); - - // create a new message - clientMtm->CreateMessageL(defaultServiceId); - - // set the from field to sms header - if (parameters.iFolderType == EInbox) - { - CSmsHeader* smsHeader = &clientMtm->SmsHeader(); - delete smsHeader; - smsHeader = NULL; - smsHeader = CSmsHeader::NewL(CSmsPDU::ESmsDeliver, clientMtm->Body()); - if( parameters.iSenderAddress ) - { - smsHeader->SetFromAddressL( parameters.iSenderAddress->Des() ); - } - else - { - smsHeader->SetFromAddressL(KEmpty); - } - } - - // set body, the BIO message itself - clientMtm->Body().Reset(); - clientMtm->Body().InsertL(0, _L("Business Card\nTester Mike\nThe Company Ltd.\nSoftware Engineer\ntel +358 66 1234567\n")); - - // get the entry of the message - TMsvEntry messageEntry = clientMtm->Entry().Entry(); - - // TO-DO: Add support for all BIO messages, currently just insert a business card message ... : - // set the message type - // parameters.iBIOMessageType ... - clientMtm->BioTypeChangedL(KUidBIOBusinessCardMsg); - messageEntry.iBioType = KUidBIOBusinessCardMsg.iUid; - - // set the details field - if (parameters.iFolderType == EInbox) - { - SetSenderToEntryDetailsL(messageEntry, parameters, EFalse); - } - else - { - SetRecipientToEntryDetailsL(messageEntry, parameters, EFalse); - } - - // set the subject line - messageEntry.iDescription.Set( parameters.iMessageSubject->Des().Left(KSmsDescriptionLength) ); - - // set correct MTM type - messageEntry.iMtm= KUidBIOMessageTypeMtm; - - // save the changes done above - clientMtm->Entry().ChangeL(messageEntry); - - // save the message - clientMtm->SaveMessageL(); - - // final fine tuning - messageEntry.SetAttachment(EFalse); - messageEntry.iDate.HomeTime(); - messageEntry.SetVisible(ETrue); - messageEntry.SetInPreparation(EFalse); - if (parameters.iCreateAsUnread) - { - messageEntry.SetUnread(ETrue); - messageEntry.SetNew(ETrue); - } - else - { - messageEntry.SetUnread(EFalse); - messageEntry.SetNew(EFalse); - } - messageEntry.SetComplete(ETrue); - messageEntry.iServiceId = defaultServiceId; - messageEntry.iRelatedId = 0; - clientMtm->Entry().ChangeL(messageEntry); - - // id has been generated, store it for being able to delete - // only entries created with Creator - iEntryIds.AppendL( messageEntry.Id() ); - - CleanupStack::PopAndDestroy(3); //session, registry, clientMtm - - - return err; - } - -//---------------------------------------------------------------------------- - -TInt CCreatorMessages::CreateObexEntryL(TUid aMtm, const CMessagesParameters& parameters) - { - LOGSTRING("Creator: CCreatorMessages::CreateObexEntryL"); - - TInt err = KErrNone; - - // init - CMsvSession* session = CMsvSession::OpenSyncL(*this); - CleanupStack::PushL(session); - CClientMtmRegistry* registry = CClientMtmRegistry::NewL(*session); - CleanupStack::PushL(registry); - - // get the client mtm and return if it isn't supported in the system - CObexClientMtm* clientMtm = NULL; - TRAP(err, clientMtm = static_cast(registry->NewMtmL(aMtm))); - if (err || !clientMtm) - { - iEngine->GetEngineWrapper()->ShowErrorMessage(_L("Obex: Message type module not found")); - CleanupStack::PopAndDestroy(2); - User::Leave(KErrNotFound); - } - CleanupStack::PushL(clientMtm); - - // create a new object to access an existing entry - CMsvEntry* msvEntry = CMsvEntry::NewL(*session, KMsvGlobalInBoxIndexEntryId, TMsvSelectionOrdering()); - CleanupStack::PushL(msvEntry); - - // define default service - TMsvId defaultServiceId = 0; - - // set folder type - switch (parameters.iFolderType) - { - case EInbox: { msvEntry->SetEntryL(KMsvGlobalInBoxIndexEntryId); break; } - case EDrafts: { msvEntry->SetEntryL(KMsvDraftEntryId); break; } - case EOutbox: { msvEntry->SetEntryL(KMsvGlobalOutBoxIndexEntryId); break; } - case ESent: { msvEntry->SetEntryL(KMsvSentEntryId); break; } - default: { User::Panic(_L("Folder Type"), 871); break; } - } - - // mtm takes ownership of entry context - CleanupStack::Pop(msvEntry); - clientMtm->SetCurrentEntryL(msvEntry); - - // create a new message - clientMtm->CreateMessageL(defaultServiceId); - - // get the entry of the message - TMsvEntry messageEntry = clientMtm->Entry().Entry(); - - // set subject - clientMtm->SetSubjectL( parameters.iMessageSubject->Des() ); - messageEntry.iDescription.Set( parameters.iMessageSubject->Des().Left(KSmsDescriptionLength) ); - - // set body, must be empty for obex messages - clientMtm->Body().Reset(); - - // set the details field and - if (parameters.iFolderType == EInbox) - { - SetSenderToEntryDetailsL(messageEntry, parameters, EFalse); - } - else - { - SetRecipientToEntryDetailsL(messageEntry, parameters, EFalse); - } - - // set mtm - messageEntry.iMtm = aMtm; - messageEntry.iType = KUidMsvMessageEntry; - messageEntry.iServiceId = KMsvUnknownServiceIndexEntryId; - - // save the changes done above - clientMtm->Entry().ChangeL(messageEntry); - - // save the message - clientMtm->SaveMessageL(); - - // final fine tuning - messageEntry.iDate.HomeTime(); - messageEntry.SetVisible(ETrue); - messageEntry.SetInPreparation(EFalse); - if (parameters.iCreateAsUnread) - { - messageEntry.SetUnread(ETrue); - messageEntry.SetNew(ETrue); - } - else - { - messageEntry.SetUnread(EFalse); - messageEntry.SetNew(EFalse); - } - messageEntry.SetComplete(ETrue); - clientMtm->Entry().ChangeL(messageEntry); - - // save the attachment - if (parameters.iAttachments->Count() >= 1) - { - // create a new entry for the attachment - TMsvEntry attachTEntry; - attachTEntry.iType = KUidMsvAttachmentEntry; - attachTEntry.iServiceId = KMsvUnknownServiceIndexEntryId; - attachTEntry.iMtm = KUidMsgTypeBt; //save as bt message - - msvEntry->CreateL(attachTEntry); - - CMsvEntry* attachEntry = session->GetEntryL(attachTEntry.Id()); - clientMtm->SetCurrentEntryL(attachEntry); - - // get source file - TFileName sourceFileName = iEngine->TestDataPathL( (CCreatorEngine::TTestDataPath) parameters.iAttachments->At(0) ); - - // get the mime type - RApaLsSession ls; - User::LeaveIfError(ls.Connect()); - CleanupClosePushL(ls); - TUid appUid; - TDataType mimeType; - ls.AppForDocument(sourceFileName, appUid, mimeType); - CleanupStack::PopAndDestroy(); //ls - - CAsyncWaiter* waiter = CAsyncWaiter::NewLC(); - - // add an attachment to the current message entry - TRAP(err, clientMtm->AddAttachmentL( sourceFileName, mimeType.Des8(), 0, waiter->iStatus )); - if (err == KErrNone) - waiter->StartAndWait(); - else - LOGSTRING2("Creator: CCreatorMessages::CreateObexEntryL failed to attach %S", &sourceFileName); - - CleanupStack::PopAndDestroy(waiter); - } - - // id has been generated, store it for being able to delete - // only entries created with Creator - iEntryIds.AppendL( messageEntry.Id() ); - - CleanupStack::PopAndDestroy(3); //session, registry, clientMtm - - - return err; - } - -//---------------------------------------------------------------------------- - -void CCreatorMessages::HandleSessionEventL(TMsvSessionEvent /*aEvent*/, TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/) // from MMsvSessionObserver - { - } - -//---------------------------------------------------------------------------- -void CCreatorMessages::SetSenderToEntryDetailsL(TMsvEntry& aMsgEntry, const CMessagesParameters& aParameters, TBool aUseEmailAddress) - { - // Only one sender allowed: - if( iSenderArray.Count() == 0 ) - { - GetSendersL(iSenderArray, aParameters, aUseEmailAddress, KUndef ); - } - if( iSenderArray.Count() > 0 ) - { - TInt rnd = iEngine->RandomNumber( iSenderArray.Count() ); - aMsgEntry.iDetails.Set( iSenderArray[rnd]->Des() ); - } - else - { - aMsgEntry.iDetails.Set(KEmpty); - } - } - -//---------------------------------------------------------------------------- -void CCreatorMessages::SetRecipientToEntryDetailsL(TMsvEntry& aMsgEntry, const CMessagesParameters& aParameters, TBool aUseEmailAddress) - { - // Only one sender allowed: - GetAllRecipientsL(iRecipientArray, aParameters, aUseEmailAddress); - if( iRecipientArray.Count() > 0 ) - { - const TDesC& temp = iRecipientArray[0]->Des(); - aMsgEntry.iDetails.Set( temp ); - } - else - { - aMsgEntry.iDetails.Set(KEmpty); - } - } - -//---------------------------------------------------------------------------- -void CCreatorMessages::AddSenderToMtmAddresseeL(CBaseMtm& aMtm, const CMessagesParameters& aParameters, TBool aUseEmailAddress ) - { - // Only one sender allowed: - if( iSenderArray.Count() == 0 ) - { - GetSendersL(iSenderArray, aParameters, aUseEmailAddress, 1 ); - } - - for( TInt i = 0; i < iSenderArray.Count(); ++i ) - { - aMtm.AddAddresseeL( iSenderArray[i]->Des() ); - } - } - -//---------------------------------------------------------------------------- -void CCreatorMessages::AddMtmSenderL(CMmsClientMtm& aMtm, const CMessagesParameters& aParameters, TBool aUseEmailAddress ) - { - // Only one sender allowed: - if( iSenderArray.Count() == 0 ) - { - GetSendersL(iSenderArray, aParameters, aUseEmailAddress, 1 ); - } - - if( iSenderArray.Count() > 0 ) - { - aMtm.SetSenderL( iSenderArray[0]->Des() ); - } - } - -//---------------------------------------------------------------------------- -void CCreatorMessages::GetSendersL(RPointerArray& aSenderArray, const CMessagesParameters& aParameters, TBool aUseEmailAddress, TInt aMaxNum ) - { - TInt counter = 0; - - if( counter < aMaxNum || aMaxNum == KUndef ) - { - if( aParameters.iSenderAddress && aParameters.iSenderAddress->Length() > 0 ) - { - HBufC* temp = HBufC::NewL(aParameters.iSenderAddress->Length()); - CleanupStack::PushL(temp); - temp->Des().Copy(aParameters.iSenderAddress->Des()); - aSenderArray.AppendL( temp ); - CleanupStack::Pop(); // temp - ++counter; - } - } - - if( counter < aMaxNum || aMaxNum == KUndef ) - { - RPointerArray tempArray; - CleanupResetAndDestroyPushL( tempArray ); - GetLinkedAddressesL(tempArray, aParameters.iSenderLinkIds, aUseEmailAddress, aParameters.iNumberOfExistingSenders); - for( TInt i = 0; i < tempArray.Count() && (counter < aMaxNum || aMaxNum == KUndef); ++i ) - { - HBufC* temp = tempArray[i]->AllocLC(); - aSenderArray.AppendL(temp); - CleanupStack::Pop(); // temp - ++counter; - } - CleanupStack::PopAndDestroy(); // tempArray - } - } - -//---------------------------------------------------------------------------- -void CCreatorMessages::AddRecipientsL(CBaseMtm& aMtm, const CMessagesParameters& aParameters, TBool aUseEmailAddress ) - { - GetAllRecipientsL(iRecipientArray, aParameters, aUseEmailAddress); - for( TInt i = 0; i < iRecipientArray.Count(); ++i ) - { - aMtm.AddAddresseeL( iRecipientArray[i]->Des() ); - } - } - -//---------------------------------------------------------------------------- -void CCreatorMessages::GetAllRecipientsL(RPointerArray& aRecipientArray, const CMessagesParameters& aParameters, TBool aUseEmailAddress ) - { - - // If iRecipientAddress is given, add it to the array: - if( aParameters.iRecipientAddress && aParameters.iRecipientAddress->Length() > 0 ) - { - HBufC* temp = HBufC::NewL(aParameters.iRecipientAddress->Length()); - CleanupStack::PushL(temp); - temp->Des().Copy(aParameters.iRecipientAddress->Des()); - aRecipientArray.AppendL( temp ); - CleanupStack::Pop(); // temp - } - - // Add all recipients listed in iRecipientAddressArray: - for( TInt i = 0; i < aParameters.iRecipientAddressArray.Count(); ++i ) - { - HBufC* temp = HBufC::NewL(aParameters.iRecipientAddressArray[i]->Length()); - CleanupStack::PushL(temp); - temp->Des().Copy(aParameters.iRecipientAddressArray[i]->Des()); - aRecipientArray.AppendL( temp ); - CleanupStack::Pop(); // temp - } - - // Get all linked addresses. - GetLinkedAddressesL(aRecipientArray, aParameters.iRecipientLinkIds, aUseEmailAddress, aParameters.iNumberOfExistingRecipients); - } - -/* - * Get all linked addresses. This method gets addresses that are linked with contact-set id and - * existing addresses from the contact database, if required. - */ -void CCreatorMessages::GetLinkedAddressesL( - RPointerArray& aAddressArray, - const RArray& aLinkIds, - TBool aUseEmailAddress, - TInt /*aNumOfExistingAddresses*/ ) - { - CCreatorPhonebook* phonebook = dynamic_cast(iEngine->GetPhonebook()); - User::LeaveIfNull( phonebook ); - CCreatorPhonebookWrapper* phonebookWrapper = phonebook->GetPhonebookWrapper(); - - for( TInt i = 0; i < aLinkIds.Count(); ++i ) - { - const CCreatorContactSet& set = ContactLinkCache::Instance()->ContactSet(aLinkIds[i].iLinkId); - const RArray links = set.ContactLinks();//ContactLinkCache::Instance()->ContactSets();//set.ContactLinks(); - TInt numberOfExplicitLinks = links.Count(); // Number of defined contacts in contact-set - for( TInt j = 0; j < numberOfExplicitLinks; ++j ) - { - TBuf<128> name; - TBuf<128> email; - TBuf<128> phoneNumber; - phonebookWrapper->GetContactDetailsL( links[j], name, phoneNumber, email ); - HBufC* address = ( aUseEmailAddress ? email.AllocLC() : phoneNumber.AllocLC() ); - aAddressArray.AppendL( address ); - CleanupStack::Pop( address ); - } - } - } - -//---------------------------------------------------------------------------- -void CCreatorMessages::DeleteAllL() - { - LOGSTRING("Creator: CCreatorMessages::DeleteAllL"); - DeleteAllMessagesL( EFalse ); - } - -//---------------------------------------------------------------------------- -void CCreatorMessages::DeleteAllMessagesL( TBool aOnlyCreatedWithCreator ) - { - LOGSTRING("Creator: CCreatorMessages::DeleteAllMessagesL"); - TInt err( KErrNone ); - - // init - CMsvSession* session = CMsvSession::OpenSyncL(*this); - CleanupStack::PushL( session ); - CClientMtmRegistry* registry = CClientMtmRegistry::NewL(*session); - CleanupStack::PushL( registry ); - - // get the client mtm and return if it isn't supported in the system - CSmsClientMtm* clientMtm( NULL ); - TRAP( err, clientMtm = static_cast( registry->NewMtmL( KUidMsgTypeSMS ) ) ); - if ( err || !clientMtm ) - { - iEngine->GetEngineWrapper()->ShowErrorMessage( _L( "SMS: Message type module not found" ) ); - CleanupStack::PopAndDestroy( 2 ); - User::Leave( KErrNotFound ); - } - CleanupStack::PushL( clientMtm ); - - TRAP_IGNORE( DeleteAllFromFolderL( KMsvGlobalInBoxIndexEntryId, session, clientMtm, aOnlyCreatedWithCreator ) ); - TRAP_IGNORE( DeleteAllFromFolderL( KMsvDraftEntryId, session, clientMtm, aOnlyCreatedWithCreator ) ); - TRAP_IGNORE( DeleteAllFromFolderL( KMsvGlobalOutBoxIndexEntryId, session, clientMtm, aOnlyCreatedWithCreator ) ); - TRAP_IGNORE( DeleteAllFromFolderL( KMsvSentEntryId, session, clientMtm, aOnlyCreatedWithCreator ) ); - - // reset must be done here, because iEntryIds is stored in destructor - iEntryIds.Reset(); - - // all entries deleted, remove the Messages related registry - iEngine->RemoveStoreL( KUidDictionaryUidMessages ); - - CleanupStack::PopAndDestroy( clientMtm ); - CleanupStack::PopAndDestroy( registry ); - CleanupStack::PopAndDestroy( session ); - } - -//---------------------------------------------------------------------------- -void CCreatorMessages::DeleteAllFromFolderL( const TMsvId aContext, - CMsvSession* aSession, - CSmsClientMtm* aClientMtm, - TBool aOnlyCreatedWithCreator ) - { - LOGSTRING("Creator: CCreatorMessages::DeleteAllFromFolderL"); - - TMsvSelectionOrdering sort; - sort.SetShowInvisibleEntries( ETrue ); - - CMsvEntry* inboxContext = CMsvEntry::NewL( *aSession, aContext, sort ); - CleanupStack::PushL( inboxContext ); - - CMsvEntrySelection* entries = inboxContext->ChildrenL(); - CleanupStack::PushL( entries ); - - TInt msgCount = entries->Count(); - for ( TInt i = 0; i < entries->Count(); i++) - { - TMsvId entryID = entries->At(i); - aClientMtm->SwitchCurrentEntryL( entryID ); - - if ( !aOnlyCreatedWithCreator || iEntryIds.Find( entryID ) != KErrNotFound ) - { - CMsvEntry* entry = aSession->GetEntryL( (*entries)[i] ); - CleanupStack::PushL( entry ); - - entry->DeleteL( entries->At(i) ); - CleanupStack::PopAndDestroy( entry ); - } - } - - CleanupStack::PopAndDestroy( entries ); - CleanupStack::PopAndDestroy( inboxContext ); - } - -//---------------------------------------------------------------------------- -void CCreatorMessages::DeleteAllCreatedByCreatorL() - { - LOGSTRING("Creator: CCreatorMessages::DeleteAllCreatedByCreatorL"); - - iEntryIds.Reset(); - - // fetch ids of entries created by Creator - iEngine->ReadEntryIdsFromStoreL( iEntryIds, KUidDictionaryUidMessages ); - - // delete them - DeleteAllMessagesL( ETrue ); - } - -CRecipientInfo::CRecipientInfo() - { - - } - -CRecipientInfo::~CRecipientInfo() - { - delete iPhoneNumber; - delete iEmailAddress; - } - -void CRecipientInfo::SetPhoneNumber(HBufC* aPhone) - { - delete iPhoneNumber; - iPhoneNumber = aPhone; - } - -void CRecipientInfo::SetEmailAddress(HBufC* aEmail) - { - delete iEmailAddress; - iEmailAddress = aEmail; - } - -const HBufC* CRecipientInfo::PhoneNumber() const - { - return iPhoneNumber; - } - -const HBufC* CRecipientInfo::EmailAddress() const - { - return iEmailAddress; - } diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/src/creator_messageelement.cpp --- a/creator/engine/src/creator_messageelement.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,475 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - -#include "creator_messageelement.h" -#include "creator_traces.h" -#include "creator_message.h" - -using namespace creatormsg; - -/* - * - */ -CCreatorMessageElement* CCreatorMessageElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext ) - { - CCreatorMessageElement* self = new (ELeave) CCreatorMessageElement(aEngine); - CleanupStack::PushL(self); - self->ConstructL(aName, aContext); - CleanupStack::Pop(self); - return self; - } -/* - * - */ -CCreatorMessageElement::CCreatorMessageElement(CCreatorEngine* aEngine) -: -CCreatorScriptElement(aEngine) - { - iIsCommandElement = ETrue; - } -/* - * Sets message type - */ -void CCreatorMessageElement::SetMessageTypeL(CMessagesParameters& aParameters, const TDesC& aMsgTypeStr ) const - { - if( CompareIgnoreCase(aMsgTypeStr, KSms) == 0 ) - { - aParameters.iMessageType = ESMS; - } - else if( CompareIgnoreCase(aMsgTypeStr, KMms) == 0 ) - { - aParameters.iMessageType = EMMS; - } - else if( CompareIgnoreCase(aMsgTypeStr, KAms) == 0 ) - { - aParameters.iMessageType = EAMS; - } - else if( CompareIgnoreCase(aMsgTypeStr, KEmail) == 0 ) - { - aParameters.iMessageType = EEmail; - } - else if( CompareIgnoreCase(aMsgTypeStr, KSmart) == 0 ) - { - aParameters.iMessageType = ESmartMessage; - } - else if( CompareIgnoreCase(aMsgTypeStr, KIr) == 0 ) - { - aParameters.iMessageType = EIrMessage; - } - else if( CompareIgnoreCase(aMsgTypeStr, KBt) == 0 ) - { - aParameters.iMessageType = EBTMessage; - } - else - { - LOGSTRING2("ERROR in CCreatorMessageElement::SetMessageTypeL: Unknown message type: %S", &aMsgTypeStr); - User::Leave(KErrGeneral); - } - } -/* - * Returns maximum length of the body text, when randomlength=max is used. - */ -TInt CCreatorMessageElement::GetMaxBodyLength( const TDesC& aMsgType ) const - { - TInt len = 0; - if( CompareIgnoreCase(aMsgType, KSms) == 0 ) - { - len = 160; - } - else if( CompareIgnoreCase(aMsgType, KMms) == 0 ) - { - len = 160; - } - else if( CompareIgnoreCase(aMsgType, KEmail) == 0 ) - { - len = 1024; - } - else - { - len = KUndef; - } - return len; - } -/* - * Returns random body text length - */ -TInt CCreatorMessageElement::GetRandomBodyLengthL(const TDesC& aRandomLenStr, const TDesC& aMsgType ) const - { - TInt len = 0; - if( aRandomLenStr == KMax ) - { - len = GetMaxBodyLength(aMsgType); - } - else if( aRandomLenStr == KDefault ) - { - len = KUndef; - } - else - { - len = ConvertStrToIntL(aRandomLenStr); - } - return len; - } - -/* - * Creates random message address (To/From) - * Returns phone number for SMS, MMS, AMS and Smart messages. - * Email address for others - */ -HBufC* CCreatorMessageElement::CreateMessageAddressLC(const TDesC& msgType) - { - HBufC* toAddr; - if( CompareIgnoreCase(msgType, KSms) == 0 || - CompareIgnoreCase(msgType, KMms) == 0 || - CompareIgnoreCase(msgType, KAms) == 0 || - CompareIgnoreCase(msgType, KSmart) == 0) - { - TPtrC temp = iEngine->RandomString(CCreatorEngine::EPhoneNumber); - toAddr = HBufC::NewL(temp.Length()); - CleanupStack::PushL(toAddr); - toAddr->Des().Copy(temp); - } - else - { - toAddr = iEngine->CreateEmailAddressLC(); - } - return toAddr; - } - -/* - * - */ -void CCreatorMessageElement::ExecuteCommandL() - { - LOGSTRING("Creator: CCreatorMessageElement::ExecuteCommandL"); - - // Find out the message type: - const CCreatorScriptAttribute* msgTypeAttr = this->FindAttributeByName(KType); - TPtrC msgType; - if( msgTypeAttr ) - { - msgType.Set(msgTypeAttr->Value()); - } - else - { - LOGSTRING("ERROR in CCreatorMessageElement::ExecuteCommandL: Type attribute is missing."); - User::Leave(KErrGeneral); // type is required attribute - } - - // Find out the amount of calendar entries: - const CCreatorScriptAttribute* msgAmountAttr = this->FindAttributeByName(KAmount); - TInt msgAmount = 1; - if( msgAmountAttr ) - { - msgAmount = ConvertStrToIntL(msgAmountAttr->Value()); - } - - // Get 'fields' element - CCreatorScriptElement* fieldsElement = FindSubElement(KFields); - if( fieldsElement && fieldsElement->SubElements().Count() > 0 ) - { - // Get sub-elements (i.e the message field elements) - const RPointerArray& fields = fieldsElement->SubElements(); - - // Create message entries, the amount of entries is defined by msgAmount: - for( TInt cI = 0; cI < msgAmount; ++cI ) - { - CMessagesParameters* param = new (ELeave) CMessagesParameters; - CleanupStack::PushL(param); - - // Message type: - if( msgTypeAttr ) - { - SetMessageTypeL(*param, msgTypeAttr->Value()); - } - - // Loop all the message field elements: - for( TInt i = 0; i < fields.Count(); ++i ) - { - CCreatorScriptElement* field = fields[i]; - TPtrC elemName = field->Name(); - TPtrC elemContent = field->Content(); - const RPointerArray& contactReferences = field->SubElements(); - const CCreatorScriptAttribute* randomAttr = field->FindAttributeByName(KRandomLength); - const CCreatorScriptAttribute* amountAttr = field->FindAttributeByName(KAmount); - const CCreatorScriptAttribute* increaseAttr = field->FindAttributeByName(KIncrease); - TBool increase( EFalse ); - if ( increaseAttr ) - { - increase = ConvertStrToBooleanL( increaseAttr->Value() ); - } - TInt fieldAmount = 1; - if( amountAttr ) - { - fieldAmount = ConvertStrToIntL(amountAttr->Value()); - } - - if( elemName == KTo ) - { - // Recipient ('to'-field) - for( TInt amountIndex = 0; amountIndex < fieldAmount; ++amountIndex ) - { - if( (randomAttr || elemContent.Length() == 0 ) && contactReferences.Count() == 0 ) - { - // Random content - HBufC* toAddr = CreateMessageAddressLC(msgType); - if( toAddr ) - { - param->iRecipientAddressArray.AppendL(toAddr); - CleanupStack::Pop(); // toAddr - } - } - else - { - if( elemContent.Length() > 0 && contactReferences.Count() == 0) - { - // Explicit recipient given - HBufC* recipient = HBufC::NewL( elemContent.Length() + 3 ); - CleanupStack::PushL(recipient); - if ( increase ) - { - IncreasePhoneNumL( elemContent, cI, recipient ); - } - else - { - recipient->Des().Copy(elemContent); - } - param->iRecipientAddressArray.AppendL(recipient); - CleanupStack::Pop(); // recipient - } - else - { - // Recipients specified with contact-set-references (if any) - for( TInt csI = 0; csI < contactReferences.Count(); ++csI ) - { - CCreatorScriptElement* contactSetRef = contactReferences[csI]; - AppendContactSetReferenceL(*contactSetRef, param->iRecipientLinkIds); - } - } - } - } - } - else if( elemName == KFrom ) - { - // Sender ('from'-field) - // Amount attribute for sender is ignored, because there can be only one sender - delete param->iSenderAddress; - param->iSenderAddress = 0; - if( (randomAttr || elemContent.Length() == 0 ) && contactReferences.Count() == 0 ) - { - // Get random address - param->iSenderAddress = CreateMessageAddressLC(msgType); - CleanupStack::Pop(); // param->iSenderAddress - } - else - { - if( elemContent.Length() > 0 && contactReferences.Count() == 0) - { - // Explicit sender address given - param->iSenderAddress = HBufC::NewL(elemContent.Length()); - if ( increase ) - { - IncreasePhoneNumL( elemContent, cI, param->iSenderAddress ); - } - else - { - param->iSenderAddress->Des().Copy(elemContent); - } - } - else - { - // Senders specified with contact-set-references (if any) - for( TInt csI = 0; csI < contactReferences.Count(); ++csI ) - { - CCreatorScriptElement* contactSetRef = contactReferences[csI]; - AppendContactSetReferenceL(*contactSetRef, param->iSenderLinkIds); - } - } - } - } - else if( elemName == KFolder ) - { - // Folder type - if( CompareIgnoreCase(elemContent, KSent) == 0 ) - { - param->iFolderType = ESent; - } - else if( CompareIgnoreCase(elemContent, KInbox) == 0 ) - { - param->iFolderType = EInbox; - } - else if( CompareIgnoreCase(elemContent, KOutbox) == 0 ) - { - param->iFolderType = EOutbox; - } - else if( CompareIgnoreCase(elemContent, KDraft) == 0 ) - { - param->iFolderType = EDrafts; - } - } - else if( elemName == KSubject ) - { - // Message subject - delete param->iMessageSubject; - param->iMessageSubject = 0; - - if( randomAttr || elemContent.Length() == 0 ) - { - // Random data should be used - TPtrC temp = iEngine->RandomString(CCreatorEngine::EMessageSubject); - param->iMessageSubject = HBufC::NewL(temp.Length()); - param->iMessageSubject->Des().Copy(temp); - } - else - { - param->iMessageSubject = HBufC::NewL(elemContent.Length()); - param->iMessageSubject->Des().Copy(elemContent); - } - } - else if( elemName == KText ) - { - // Body text - delete param->iMessageBodyText; - param->iMessageBodyText = 0; - - if( randomAttr || elemContent.Length() == 0 ) - { - // Put random text: - if( randomAttr && randomAttr->Value() != KDefault ) - { - // Get the random length - TInt len = GetRandomBodyLengthL(randomAttr->Value(), msgTypeAttr->Value()); - if( len != KUndef ) - { - param->iMessageBodyText = iEngine->CreateRandomStringLC(len); - CleanupStack::Pop(); // param->iMessageBodyText - } - } - else - { - // Use default random data - TPtrC temp = iEngine->RandomString(CCreatorEngine::EMessageText); - param->iMessageBodyText = HBufC::NewL(temp.Length()); - param->iMessageBodyText->Des().Copy(temp); - } - } - else - { - param->iMessageBodyText = HBufC::NewL(elemContent.Length()); - param->iMessageBodyText->Des().Copy(elemContent); - } - } - else if( elemName == KAttachmentId ) - { - // Attachment file id - for( TInt amountIndex = 0; amountIndex < fieldAmount; ++amountIndex ) - { - if( randomAttr || elemContent.Length() == 0) - { - //When type is AMS, attachement will be audio - if(param->iMessageType == EAMS) - { - param->iAttachments->AppendL(CCreatorEngine::EMP3_250kB); - } - //Otherwise attachement can be any file - else - { - //EJPEG_25kB is first (0) in the enum and LAST_FILE_ID is last in the enum, so real last item id is one before LAST_FILE_ID - param->iAttachments->AppendL( iEngine->RandomNumber(CCreatorEngine::EJPEG_25kB, CCreatorEngine::LAST_FILE_ID-1) ); - } - } - else - { - //When user has been set attechment by it self, we trust user selection (not validating value, e.g. if message is SMS and there is attachement) - TInt id = iEngine->GetAttachmentIdL(elemContent); - if( id != KUndef ) - { - param->iAttachments->AppendL( id ); - } - } - } - } - // Attachment file path handling - //E.g. C:\data\others\DOC-20kB.doc - else if( elemName == KAttachmentPath ) - { - // Attachment file id - for( TInt amountIndex = 0; amountIndex < fieldAmount; ++amountIndex ) - { - //Path is random, getting one of the files (not even using path attribute, but id with random) - if( randomAttr || elemContent.Length() == 0) - { - //EJPEG_25kB is first (0) in the enum and LAST_FILE_ID is last in the enum, so real last item id is one before LAST_FILE_ID - param->iAttachments->AppendL( iEngine->RandomNumber(CCreatorEngine::EJPEG_25kB, CCreatorEngine::LAST_FILE_ID -1) ); - } - //Otherwise adding attachement path as it is to paths. - else - { - //Adding Attachement file path - HBufC* elemData = elemContent.AllocLC(); - param->iAttachmentPaths.AppendL( elemData ); - CleanupStack::Pop(elemData); - } - } - } - else if ( elemName == KStatus ) - { - if( CompareIgnoreCase( elemContent, KNew ) == 0 ) - { - param->iCreateAsUnread = ETrue; - } - else if( CompareIgnoreCase( elemContent, KRead ) == 0 ) - { - param->iCreateAsUnread = EFalse; - } - } - } - iEngine->AppendToCommandArrayL(ECmdCreateMessagingEntryMessagesViaScript, param); - CleanupStack::Pop(); // param - } - } - else - { - for( TInt i = 0; i < msgAmount; ++i ) - { - TInt randMsg = 0; - if( msgType == KSms ) - randMsg = iEngine->RandomNumber(ECmdCreateRandomEntrySMSInbox, ECmdCreateRandomEntrySMSSent); - else if( msgType == KMms ) - randMsg = iEngine->RandomNumber(ECmdCreateRandomEntryMMSInbox, ECmdCreateRandomEntryMMSSent); - else if( msgType == KAms ) - randMsg = iEngine->RandomNumber(ECmdCreateRandomEntryAMSInbox, ECmdCreateRandomEntryAMSSent); - else if( msgType == KEmail ) - randMsg = iEngine->RandomNumber(ECmdCreateRandomEntryEmailInbox, ECmdCreateRandomEntryEmailSent); - else if( msgType == KSmart ) - randMsg = iEngine->RandomNumber(ECmdCreateRandomEntryBIOInbox, ECmdCreateRandomEntryBIOSent); - else if( msgType == KBt ) - randMsg = iEngine->RandomNumber(ECmdCreateRandomEntryBTInbox, ECmdCreateRandomEntryBTSent); - else if( msgType == KIr ) - randMsg = iEngine->RandomNumber(ECmdCreateRandomEntryIRInbox, ECmdCreateRandomEntryIRSent); - - if( randMsg > 0 ) - { - iEngine->AppendToCommandArrayL(randMsg, 0, 1); - } - } - } - } - -// End of file diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/src/creator_note.cpp --- a/creator/engine/src/creator_note.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,146 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#include "engine.h" -#include "enginewrapper.h" - -#include "creator_note.h" -#include "creator_traces.h" - -//---------------------------------------------------------------------------- - -CNotepadParameters::CNotepadParameters() - { - LOGSTRING("Creator: CNotepadParameters::CNotepadParameters"); - - iNoteText = HBufC::New(KNotepadFieldLength); - } - -CNotepadParameters::~CNotepadParameters() - { - LOGSTRING("Creator: CNotepadParameters::~CNotepadParameters"); - - delete iNoteText; - } - -//---------------------------------------------------------------------------- - -CCreatorNotepad* CCreatorNotepad::NewL(CCreatorEngine* aEngine) - { - CCreatorNotepad* self = CCreatorNotepad::NewLC(aEngine); - CleanupStack::Pop(self); - return self; - } - -CCreatorNotepad* CCreatorNotepad::NewLC(CCreatorEngine* aEngine) - { - CCreatorNotepad* self = new (ELeave) CCreatorNotepad; - CleanupStack::PushL(self); - self->ConstructL(aEngine); - return self; - } - -CCreatorNotepad::CCreatorNotepad() : iFs ( CEikonEnv::Static()->FsSession() ) - { - } - -void CCreatorNotepad::ConstructL(CCreatorEngine* aEngine) - { - LOGSTRING("Creator: CCreatorNotepad::ConstructL"); - - iEngine = aEngine; - iNotepadWrapper = CCreatorNotepadWrapper::NewL(); - } - -CCreatorNotepad::~CCreatorNotepad() - { - LOGSTRING("Creator: CCreatorNotepad::~CCreatorNotepad"); - - if (iParameters) - { - delete iParameters; - iParameters = NULL; - } - - if (iNotepadWrapper) - { - delete iNotepadWrapper; - iNotepadWrapper = NULL; - } - } - -//---------------------------------------------------------------------------- - -TBool CCreatorNotepad::AskDataFromUserL(TInt aCommand) - { - LOGSTRING("Creator: CCreatorNotepad::AskDataFromUserL"); - - CCreatorModuleBase::AskDataFromUserL(aCommand); - - if ( aCommand == ECmdDeleteNotes ) - { - return iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all Notes?"), this, ECreatorModuleDelete ); - } - - // By Creator not supported because - // note id is not available via Notepad API - - return iEngine->GetEngineWrapper()->EntriesQueryDialog( &iEntriesToBeCreated, _L("How many entries to create?"), EFalse, this, ECreatorModuleStart ); - } - - -//---------------------------------------------------------------------------- - -TInt CCreatorNotepad::CreateNoteEntryL(CNotepadParameters *aParameters) - { - LOGSTRING("Creator: CCreatorNotepad::CreateNoteEntryL"); - - // clear any existing parameter definations - delete iParameters; - iParameters = NULL; - - // random data needed if no predefined data available - if (!aParameters) - { - iParameters = new(ELeave) CNotepadParameters; - } - else - { - iParameters = aParameters; - } - - TPtr noteTextPtr = iParameters->iNoteText->Des(); - noteTextPtr.Copy( iEngine->RandomString(CCreatorEngine::EMessageText).Left( noteTextPtr.MaxLength() ) ); - - return iNotepadWrapper->CreateNoteL( noteTextPtr ); - } - -//---------------------------------------------------------------------------- -void CCreatorNotepad::DeleteAllL() - { - LOGSTRING("Creator: CCreatorNotepad::DeleteAllL"); - iNotepadWrapper->DeleteAllL(); - } - -//---------------------------------------------------------------------------- -void CCreatorNotepad::DeleteAllCreatedByCreatorL() - { - LOGSTRING("Creator: CCreatorNotepad::DeleteAllCreatedByCreatorL"); - // Not supported because note id is not available via Notepad API - User::Leave( KErrNotSupported ); - } diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/src/creator_noteelement.cpp --- a/creator/engine/src/creator_noteelement.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,108 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - -#include "creator_noteelement.h" -#include "creator_traces.h" -#include "creator_note.h" - -using namespace creatornote; - -/* - * - */ -CCreatorNoteElement* CCreatorNoteElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext ) - { - CCreatorNoteElement* self = new (ELeave) CCreatorNoteElement(aEngine); - CleanupStack::PushL(self); - self->ConstructL(aName, aContext); - CleanupStack::Pop(self); - return self; - } -/* - * - */ -CCreatorNoteElement::CCreatorNoteElement(CCreatorEngine* aEngine) -: -CCreatorScriptElement(aEngine) - { - iIsCommandElement = ETrue; - } - -void CCreatorNoteElement::ExecuteCommandL() - { - const CCreatorScriptAttribute* amountAttr = FindAttributeByName(KAmount); - TInt noteAmount = 1; - if( amountAttr ) - { - noteAmount = ConvertStrToIntL(amountAttr->Value()); - } - // Get 'fields' element - CCreatorScriptElement* fieldsElement = FindSubElement(KFields); - if( fieldsElement && fieldsElement->SubElements().Count() > 0) - { - // Get sub-elements - const RPointerArray& fields = fieldsElement->SubElements(); - // Create note entries, the amount of entries is defined by noteAmount: - for( TInt cI = 0; cI < noteAmount; ++cI ) - { - CNotepadParameters* param = new (ELeave) CNotepadParameters; - CleanupStack::PushL(param); - - for( TInt i = 0; i < fields.Count(); ++i ) - { - CCreatorScriptElement* field = fields[i]; - TPtrC elemName = field->Name(); - TPtrC elemContent = field->Content(); - const CCreatorScriptAttribute* randomAttr = fields[i]->FindAttributeByName(KRandomLength); - TBool useMax = EFalse; - if( randomAttr && randomAttr->Value() == KMax ) - { - useMax = ETrue; - } - - if( elemName == KText ) - { - if( randomAttr || elemContent.Length() == 0 ) - { - if( useMax ) - { - TDesC* temp = iEngine->CreateRandomStringLC(KNotepadFieldLength); - SetContentToTextParamL(param->iNoteText, *temp); - CleanupStack::PopAndDestroy(); // temp - } - else - { - SetContentToTextParamL(param->iNoteText, iEngine->RandomString(CCreatorEngine::EMessageText)); - } - } - else - { - SetContentToTextParamL(param->iNoteText, elemContent); - } - } - } - iEngine->AppendToCommandArrayL(ECmdCreateMiscEntryNotes, param); - CleanupStack::Pop(); // param - } - } - else - { - iEngine->AppendToCommandArrayL(ECmdCreateMiscEntryNotes, 0, noteAmount); - } - } diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/src/creator_notepadwrapper.cpp --- a/creator/engine/src/creator_notepadwrapper.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,123 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#include -#include "creator_notepadwrapper.h" - - /** - * Constructor - */ -CCreatorNotepadWrapper::CCreatorNotepadWrapper() - { - } - - /** - * Destructor - */ -CCreatorNotepadWrapper::~CCreatorNotepadWrapper() - { - - iNotepadApi = NULL; - - if(iNotesEditorPluginLoader) - { - iNotesEditorPluginLoader->unload(); - delete iNotesEditorPluginLoader; - iNotesEditorPluginLoader = NULL; - } - - if(iAgendaUtil) - { - delete iAgendaUtil; - iAgendaUtil = NULL; - } - } - - /** - * Two-Phased constructor - */ -CCreatorNotepadWrapper* CCreatorNotepadWrapper::NewL() - { - CCreatorNotepadWrapper* self = CCreatorNotepadWrapper::NewLC(); - CleanupStack::Pop(self); - return self; - } - - /** - * Two-Phased constructor - */ -CCreatorNotepadWrapper* CCreatorNotepadWrapper::NewLC() - { - CCreatorNotepadWrapper* self = new (ELeave) CCreatorNotepadWrapper; - CleanupStack::PushL(self); - self->ConstructL(); - return self; - } - - /** - * ConstructL() - */ - -void CCreatorNotepadWrapper::ConstructL() - { - iAgendaUtil = new AgendaUtil(); - - // iNotepadApi = new NotesEditor(iAgendaUtil); - - // Load notes editor plugin. - // Launch the notes editor using notes editor plugin api - QDir dir(NOTES_EDITOR_PLUGIN_PATH); - QString pluginName = dir.absoluteFilePath(NOTES_EDITOR_PLUGIN_NAME); - - QT_TRYCATCH_LEAVING( - // Create NotesEditor plugin loader object. - iNotesEditorPluginLoader = new QPluginLoader(pluginName); - - // Load the plugin - bool notesPluginLoaded = iNotesEditorPluginLoader->load(); - QObject *plugin = qobject_cast ( iNotesEditorPluginLoader->instance()); - - iNotepadApi = qobject_cast(plugin); - ); - - } - -TInt CCreatorNotepadWrapper::CreateNoteL( const TDesC& aText ) - { - User::LeaveIfNull(iNotepadApi); - - QString textNote = QString::fromUtf16( aText.Ptr(),aText.Length()); - iNotepadApi->edit(textNote,iAgendaUtil); - iNotepadApi->close(NotesEditorInterface::CloseWithSave, iAgendaUtil); - - return KErrNone; - } -void CCreatorNotepadWrapper::DeleteAllL() - { - - QList ael; - AgendaUtil::FilterFlags filter = AgendaUtil::FilterFlags(AgendaUtil::IncludeNotes); - - ael = iAgendaUtil->fetchAllEntries(filter); - for(int i=0 ; ideleteEntry(ael[i].id()); - } - - } - diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/src/creator_phonebook.cpp --- a/creator/engine/src/creator_phonebook.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,770 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#include "engine.h" -#include "enginewrapper.h" -#include "creator_contactsetcache.h" - -#include "creator_phonebook.h" -#include "creator_traces.h" - -#include - -_LIT(KTempPath, "C:\\Data\\Creator\\"); - - -typedef struct { -TInt iFieldCode; -TInt iRandomType; -} DetailFieldInfo; -static const TInt RND_TYPE_UNDEF = -99; -DetailFieldInfo CreatorPbkMiscTextFields[] = { - {CCreatorPhonebookWrapper::EFirstName, (TInt) CCreatorEngine::EFirstName}, - {CCreatorPhonebookWrapper::EFirstNameReading, (TInt) CCreatorEngine::EFirstName}, - {CCreatorPhonebookWrapper::ELastName, (TInt) CCreatorEngine::ESurname}, - {CCreatorPhonebookWrapper::ELastNameReading, (TInt) CCreatorEngine::ESurname}, - {CCreatorPhonebookWrapper::ECompanyName, (TInt) CCreatorEngine::ECompany}, - {CCreatorPhonebookWrapper::EJobTitle, (TInt) CCreatorEngine::EJobTitle}, - {CCreatorPhonebookWrapper::EPrefix, (TInt) CCreatorEngine::EPrefix}, - {CCreatorPhonebookWrapper::ESuffix, (TInt) CCreatorEngine::ESuffix}, - {CCreatorPhonebookWrapper::ESecondName, (TInt) CCreatorEngine::EFirstName}, - {CCreatorPhonebookWrapper::EAddrLabelGen, (TInt) CCreatorEngine::EAddress}, - {CCreatorPhonebookWrapper::EAddrPoGen, (TInt) CCreatorEngine::EPobox}, - {CCreatorPhonebookWrapper::EAddrExtGen, (TInt) CCreatorEngine::EAddress}, - {CCreatorPhonebookWrapper::EAddrStreetGen, (TInt) CCreatorEngine::EAddress}, - {CCreatorPhonebookWrapper::EAddrLocalGen, (TInt) CCreatorEngine::ECity}, - {CCreatorPhonebookWrapper::EAddrRegionGen, (TInt) CCreatorEngine::EState}, - {CCreatorPhonebookWrapper::EAddrPostCodeGen, (TInt) CCreatorEngine::EPostcode}, - {CCreatorPhonebookWrapper::EAddrCountryGen, (TInt) CCreatorEngine::ECountry}, - {CCreatorPhonebookWrapper::EAddrLabelHome, (TInt) CCreatorEngine::EAddress}, - {CCreatorPhonebookWrapper::EAddrPoHome, (TInt) CCreatorEngine::EPobox}, - {CCreatorPhonebookWrapper::EAddrExtHome, (TInt) CCreatorEngine::EAddress}, - {CCreatorPhonebookWrapper::EAddrStreetHome, (TInt) CCreatorEngine::EAddress}, - {CCreatorPhonebookWrapper::EAddrLocalHome, (TInt) CCreatorEngine::ECity}, - {CCreatorPhonebookWrapper::EAddrRegionHome, (TInt) CCreatorEngine::EState}, - {CCreatorPhonebookWrapper::EAddrPostCodeHome, (TInt) CCreatorEngine::EPostcode}, - {CCreatorPhonebookWrapper::EAddrCountryHome, (TInt) CCreatorEngine::ECountry}, - {CCreatorPhonebookWrapper::EAddrLabelWork, (TInt) CCreatorEngine::EAddress}, - {CCreatorPhonebookWrapper::EAddrPoWork, (TInt) CCreatorEngine::EPobox}, - {CCreatorPhonebookWrapper::EAddrExtWork, (TInt) CCreatorEngine::EAddress}, - {CCreatorPhonebookWrapper::EAddrStreetWork, (TInt) CCreatorEngine::EAddress}, - {CCreatorPhonebookWrapper::EAddrLocalWork, (TInt) CCreatorEngine::ECity}, - {CCreatorPhonebookWrapper::EAddrRegionWork, (TInt) CCreatorEngine::EState}, - {CCreatorPhonebookWrapper::EAddrPostCodeWork, (TInt) CCreatorEngine::EPostcode}, - {CCreatorPhonebookWrapper::EAddrCountryWork, (TInt) CCreatorEngine::ECountry}, - {CCreatorPhonebookWrapper::EPoc, (TInt) CCreatorEngine::EPhoneNumber}, - {CCreatorPhonebookWrapper::ESwis, (TInt) CCreatorEngine::EPhoneNumber}, - {CCreatorPhonebookWrapper::ESip, (TInt) CCreatorEngine::EPhoneNumber}, - {CCreatorPhonebookWrapper::EDtmfString, (TInt) CCreatorEngine::EFirstName}, - {CCreatorPhonebookWrapper::ENote,(TInt) CCreatorEngine::EMemoText}, - {CCreatorPhonebookWrapper::EMiddleName, (TInt) CCreatorEngine::EFirstName}, - {CCreatorPhonebookWrapper::EDepartment, (TInt) CCreatorEngine::ECompany}, - {CCreatorPhonebookWrapper::EAsstName, (TInt) CCreatorEngine::EFirstName}, - {CCreatorPhonebookWrapper::ESpouse, (TInt) CCreatorEngine::EFirstName}, - {CCreatorPhonebookWrapper::EChildren, (TInt) CCreatorEngine::EFirstName}, - {CCreatorPhonebookWrapper::ESyncClass, RND_TYPE_UNDEF}, - {CCreatorPhonebookWrapper::ELocPrivacy, RND_TYPE_UNDEF}, - {CCreatorPhonebookWrapper::EGenLabel, (TInt) CCreatorEngine::EFirstName}, - {CCreatorPhonebookWrapper::EWVAddress, (TInt) CCreatorEngine::EPhoneNumber}, - {CCreatorPhonebookWrapper::ERingTone, RND_TYPE_UNDEF}, - {CCreatorPhonebookWrapper::EThumbnailPic, RND_TYPE_UNDEF}, - {CCreatorPhonebookWrapper::ECallerObjText, (TInt) CCreatorEngine::EFirstName} - }; - - -TInt CreatorPbkBinaryFields[] = { - CCreatorPhonebookWrapper::ECallerObjImg//, - //R_VPBK_FIELD_TYPE_THUMBNAILPATH - }; - -TInt CreatorPbkDateTimeFields[] = { - CCreatorPhonebookWrapper::EAnniversary - }; - -//---------------------------------------------------------------------------- -TInt CreatorPbkPhoneNumberFields[] = - { - CCreatorPhonebookWrapper::ELandPhoneGen, - CCreatorPhonebookWrapper::ELandPhoneHome, - CCreatorPhonebookWrapper::ELandPhoneWork, - CCreatorPhonebookWrapper::EMobilePhoneGen, - CCreatorPhonebookWrapper::EMobilePhoneHome, - CCreatorPhonebookWrapper::EMobilePhoneWork, - CCreatorPhonebookWrapper::EFaxNumberGen, - CCreatorPhonebookWrapper::EFaxNumberHome, - CCreatorPhonebookWrapper::EFaxNumberWork, - CCreatorPhonebookWrapper::EPagerNumber, - CCreatorPhonebookWrapper::EVideoNumberGen, - CCreatorPhonebookWrapper::EVideoNumberHome, - CCreatorPhonebookWrapper::EVideoNumberWork, - CCreatorPhonebookWrapper::EVoipGen, - CCreatorPhonebookWrapper::EVoipHome, - CCreatorPhonebookWrapper::EVoipWork, - CCreatorPhonebookWrapper::EAsstPhone, - CCreatorPhonebookWrapper::ECarPhone - }; - -TInt CreatorPbkUrlFields[] = - { - CCreatorPhonebookWrapper::EUrlGen, - CCreatorPhonebookWrapper::EUrlHome, - CCreatorPhonebookWrapper::EUrlWork - }; - -TInt CreatorPbkEmailFields[] = - { - CCreatorPhonebookWrapper::EEmailGen, - CCreatorPhonebookWrapper::EEmailHome, - CCreatorPhonebookWrapper::EEmailWork - }; - -CPhonebookParameters::CPhonebookParameters() - { - LOGSTRING("Creator: CPhonebookParameters::CVirtualPhonebookParameters"); - iGroupName = HBufC::New(KPhonebookFieldLength); - } - -CPhonebookParameters::~CPhonebookParameters() - { - LOGSTRING("Creator: CPhonebookParameters::~CPhonebookParameters"); - - delete iGroupName; - for( TCreatorContactFields::iterator it = iContactFields.begin(); it != iContactFields.end(); ++it) - { - HBufC* temp = (*it).second; - iContactFields.erase(it); - delete temp; - } - iLinkIds.Reset(); - iLinkIds.Close(); - } - -void CPhonebookParameters::ParseL(CCommandParser* /*parser*/, TParseParams /*aCase = 0*/) - { - } - -TInt CPhonebookParameters::ScriptLinkId() const - { - return iLinkId; - } - -void CPhonebookParameters::SetScriptLinkId(TInt aLinkId) - { - iLinkId = aLinkId; - } - - -//---------------------------------------------------------------------------- - -CCreatorPhonebook* CCreatorPhonebook::NewL(CCreatorEngine* aEngine) - { - CCreatorPhonebook* self = CCreatorPhonebook::NewLC(aEngine); - CleanupStack::Pop(self); - return self; - } - -CCreatorPhonebook* CCreatorPhonebook::NewLC(CCreatorEngine* aEngine) - { - CCreatorPhonebook* self = new (ELeave) CCreatorPhonebook(); - CleanupStack::PushL(self); - self->ConstructL(aEngine); - return self; - } - - -CCreatorPhonebook::CCreatorPhonebook() - { - iAddAllFields = EFalse; - } - -void CCreatorPhonebook::ConstructL(CCreatorEngine* aEngine) - { - LOGSTRING("Creator: CCreatorPhonebook::ConstructL"); - - iEngine = aEngine; - - iPhonebookWrapper = CCreatorPhonebookWrapper::NewL(); - - SetDefaultParameters(); - } - - -CCreatorPhonebook::~CCreatorPhonebook() - { - LOGSTRING("Creator: CCreatorPhonebook::~CCreatorPhonebook"); - - if ( iContactsToDelete.Count() ) - { - TRAP_IGNORE( StoreLinksForDeleteL( iContactsToDelete, KUidDictionaryUidContacts ) ); - } - if ( iContactGroupsToDelete.Count() ) - { - TRAP_IGNORE( StoreLinksForDeleteL( iContactGroupsToDelete, KUidDictionaryUidContactGroups ) ); - } - - if( iPhonebookWrapper ) - { - delete iPhonebookWrapper; - } - - if (iParameters) - { - delete iParameters; - } - - } - -//---------------------------------------------------------------------------- - -TInt CCreatorPhonebook::CreateContactEntryL(CCreatorModuleBaseParameters *aParameters) - { - TInt err = KErrNone; - delete iParameters; - iParameters = 0; - CPhonebookParameters* parameters = 0; - - if( aParameters == 0 ) - { - InitializeContactParamsL(); - parameters = iParameters; - } - else - { - parameters = (CPhonebookParameters*) aParameters; - } - - int numberOfFields = parameters->iContactFields.size(); - // create a new contact item - - TUint32 contactId = iPhonebookWrapper->CreateContactEntryL( parameters->iContactFields ); //wrapper should return contact id to store - iContactsToDelete.AppendL( contactId ); - - - // If this contact has a link id in script (i.e. belongs to a contact-set), we must cache the contact id: - if( parameters->ScriptLinkId() > 0 ) - { - RPointerArray& contactsets = ContactLinkCache::Instance()->ContactSets(); - TBool setFound(EFalse); - for(TInt i = 0; i < contactsets.Count(); ++i ) - { - if( contactsets[i]->LinkId() == parameters->ScriptLinkId() ) - { - if( contactId ) - { - contactsets[i]->AppendL( contactId ); - iContactLinkArray.AppendL( contactId ); - } - setFound = ETrue; - break; - } - } - if( !setFound ) - { - LOGSTRING2("Error: Contact set id %d not found.", parameters->ScriptLinkId()); - } - } - - return err; - } - - -//---------------------------------------------------------------------------- - - - -//---------------------------------------------------------------------------- - -void CCreatorPhonebook::DeleteAllL() - { - iPhonebookWrapper->DeleteAllL(); - } - -//---------------------------------------------------------------------------- -void CCreatorPhonebook::DeleteAllCreatedByCreatorL() - { - LOGSTRING("Creator: CCreatorPhonebook::DeleteAllCreatedByCreatorL"); - DeleteItemsCreatedWithCreatorL( KUidDictionaryUidContacts ); - } - -//---------------------------------------------------------------------------- -void CCreatorPhonebook::DeleteAllGroupsL() - { - LOGSTRING("Creator: CCreatorPhonebook::DeleteAllGroupsL"); - iPhonebookWrapper->DeleteAllGroupsL(); - } - -//---------------------------------------------------------------------------- -void CCreatorPhonebook::DeleteAllGroupsCreatedByCreatorL() - { - LOGSTRING("Creator: CCreatorPhonebook::DeleteAllGroupsCreatedByCreatorL"); - DeleteItemsCreatedWithCreatorL( KUidDictionaryUidContactGroups ); - } - -//---------------------------------------------------------------------------- -void CCreatorPhonebook::DeleteContactsL( RArray& aContactsToDelete, TUid aStoreUid ) - { - iPhonebookWrapper->DeleteContactsL( aContactsToDelete, aStoreUid ); - } - -//---------------------------------------------------------------------------- - - -void CCreatorPhonebook::DeleteItemsCreatedWithCreatorL( TUid aStoreUid ) - { - CDictionaryFileStore* store = iEngine->FileStoreLC(); - User::LeaveIfNull( store ); - - RArray contacts; - // backup previous contact links from store - // otherwise they would be overwritten when calling out.WriteL - TUint32 creatorLink; - if ( store->IsPresentL( aStoreUid ) ) - { - RDictionaryReadStream in; - in.OpenLC( *store, aStoreUid ); - TRAP_IGNORE( - do{ - creatorLink = in.ReadUint32L(); - contacts.AppendL( creatorLink ); - }while( creatorLink ); - ); - - CleanupStack::PopAndDestroy(); // in - } - - - iPhonebookWrapper->DeleteContactsL( contacts, aStoreUid ); - - store->Remove( aStoreUid ); - store->CommitL(); - - CleanupStack::PopAndDestroy( store ); - } - -//---------------------------------------------------------------------------- -void CCreatorPhonebook::DoDeleteItemsCreatedWithCreatorL( TUid /*aStoreUid*/, CDictionaryFileStore* /*aStore*/ ) - { - - } - -//---------------------------------------------------------------------------- -TBool CCreatorPhonebook::HasOtherThanGroupsL() - { - LOGSTRING("Creator: CCreatorPhonebook::HasOtherThanGroupsL"); - TBool result( EFalse ); - return result; - } - - -//---------------------------------------------------------------------------- - - -//---------------------------------------------------------------------------- -void CCreatorPhonebook::StoreLinksForDeleteL( RArray& aLinks, TUid aStoreUid ) - { - LOGSTRING("Creator: CCreatorPhonebook::StoreLinksForDeleteL"); - CDictionaryFileStore* store = iEngine->FileStoreLC(); - User::LeaveIfNull( store ); - - // backup previous contact links from store - // otherwise they would be overwritten when calling out.WriteL - TUint32 previousLink; - if ( store->IsPresentL( aStoreUid ) ) - { - RDictionaryReadStream in; - in.OpenLC( *store, aStoreUid ); - bool r = false; - TRAP_IGNORE( - do{ //iContactMngr->CreateLinksLC( in )) != NULL ) // will leave with KErrEof - previousLink = in.ReadUint32L(); - iPreviousDeleteLinks.AppendL( previousLink ); - if(previousLink) - { - r=true; - } - else - { - r=false; - } - }while(r==true); ); - - CleanupStack::PopAndDestroy(); // in - } - - RDictionaryWriteStream out; - out.AssignLC( *store, aStoreUid ); - - // restore previous links - for ( TInt i = 0; i < iPreviousDeleteLinks.Count(); i++ ) - { - out.WriteUint32L( iPreviousDeleteLinks[i] ); - } - - // write new links - for(int i=0; i < aLinks.Count(); i++) - { - out.WriteUint32L( aLinks[i] ); - } - out.CommitL(); - CleanupStack::PopAndDestroy(); // out - - store->CommitL(); - - CleanupStack::PopAndDestroy( store ); - } - -//---------------------------------------------------------------------------- -//---------------------------------------------------------------------------- - -void CCreatorPhonebook::InitializeContactParamsL() - { - LOGSTRING("Creator: CCreatorPhonebook::InitializeContactParamsL"); - - iParameters = new (ELeave) CPhonebookParameters; - - iParameters->iNumberOfPhoneNumberFields = iNumberOfPhoneNumberFields; - iParameters->iNumberOfURLFields = iNumberOfURLFields; - iParameters->iNumberOfEmailAddressFields = iNumberOfEmailAddressFields; - - TPtrC fname = iEngine->RandomString(CCreatorEngine::EFirstName); - TPtrC lname = iEngine->RandomString(CCreatorEngine::ESurname); - - - if( iAddAllFields ) - { - TInt textFieldCount = sizeof(CreatorPbkMiscTextFields) / sizeof(DetailFieldInfo); - for( TInt tfIndex = 0; tfIndex < textFieldCount; ++tfIndex ) - { - CCreatorContactField* field = CCreatorContactField::NewL(); - CleanupStack::PushL(field); - field->AddFieldToParamL( iEngine,iParameters, CreatorPbkMiscTextFields[tfIndex].iFieldCode, CreatorPbkMiscTextFields[tfIndex].iRandomType ); - CleanupStack::Pop(field); - } - - // Add binary fields: - - RFs& fs = CCoeEnv::Static()->FsSession(); - - TBuf srcPath; - iEngine->RandomPictureFileL(srcPath); - TBuf destPath(KTempPath); - - if(!BaflUtils::FolderExists( fs, destPath )) - { - BaflUtils::EnsurePathExistsL( fs, destPath ); - } - - TInt err=BaflUtils::CopyFile( fs, srcPath, destPath ); - - TParse temp; - temp.Set( srcPath,NULL,NULL ); - destPath.Append(temp.NameAndExt()); - TPtrC picture; - picture.Set(destPath); - CCreatorContactField* picturefield = CCreatorContactField::NewL(); - CleanupStack::PushL(picturefield); - picturefield->AddFieldToParamL( iParameters, CCreatorPhonebookWrapper::EThumbnailPic, picture ); - CleanupStack::Pop(picturefield); - // Add date-time fields: - TPtrC anniv; - TBuf<20> timeString; - TTime datetime = iEngine->RandomDate( CCreatorEngine::EDateFuture ); - _LIT(KDateString,"%D%M%Y%/0%1%/1%2%/2%3%/3"); - TRAP_IGNORE( datetime.FormatL(timeString, KDateString) ); - - anniv.Set(timeString); - - CCreatorContactField* fieldAnniv = CCreatorContactField::NewL(); - CleanupStack::PushL( fieldAnniv ); - fieldAnniv->AddFieldToParamL(iParameters,CCreatorPhonebookWrapper::EAnniversary, anniv ); - CleanupStack::Pop( fieldAnniv ); - //*************************************************************************** - - } - else - { - CCreatorContactField* field = CCreatorContactField::NewL(); - CleanupStack::PushL(field); - field->AddFieldToParamL( iParameters, CCreatorPhonebookWrapper::EFirstName, fname ); - field->AddFieldToParamL( iParameters, CCreatorPhonebookWrapper::ELastName, lname ); - CleanupStack::Pop(field); - } - - // Phone numbers: - TInt phoneFieldCount = sizeof(CreatorPbkPhoneNumberFields) / sizeof(TInt); - - TInt inc=0; - for( TInt i=0; i= phoneFieldCount ) - { - inc = 0; - } - - CCreatorContactField* field = CCreatorContactField::NewL(); - CleanupStack::PushL(field); - field->AddFieldToParamL(iEngine, iParameters, CreatorPbkPhoneNumberFields[inc] ); - CleanupStack::Pop(field); - - inc++; - } - - - - // URLs: - TInt urlFieldCount = sizeof(CreatorPbkUrlFields) / sizeof(TInt); - inc = 0; - for( TInt i=0; i= urlFieldCount ) - { - inc = 0; - } - - CCreatorContactField* field = CCreatorContactField::NewL(); - CleanupStack::PushL(field); - field->AddFieldToParamL(iEngine, iParameters, CreatorPbkUrlFields[inc] ); - CleanupStack::Pop(field); - inc++; - } - - // EMail addresses: - TInt emailFieldCount = sizeof(CreatorPbkEmailFields) / sizeof(TInt); - inc = 0; - for( int i=0; i= emailFieldCount ) - { - inc = 0; - } - CCreatorContactField* field = CCreatorContactField::NewL(); - CleanupStack::PushL(field); - field->AddFieldToParamL(iEngine, iParameters, CreatorPbkEmailFields[inc] ); - CleanupStack::Pop(field); - inc++; - } - - TestPrintOut(iParameters); - - } - -void CCreatorPhonebook::TestPrintOut(CPhonebookParameters* aParam) - { - LOGSTRING("Creator: CCreatorPhonebook::TestPrintOut"); - for( TCreatorContactFields::iterator it = aParam->iContactFields.begin(); it != aParam->iContactFields.end(); ++it) - { - HBufC* temp = (*it).second; - if(temp) - { - LOGSTRING3("Type: %d Content:%S ", (*it).first, &temp->Des() ); - } - } - } - -// Checks if the link is a group or not -TBool CCreatorPhonebook::IsContactGroupL( TUint32& /*aLink*/ ) - { - //not used right now - return EFalse; - } - - -TInt CCreatorPhonebook::CreateGroupEntryL(CCreatorModuleBaseParameters *aParameters) - { - LOGSTRING("Creator: CCreatorPhonebook::CreateGroupEntryL"); - TInt err = KErrNone; - - delete iParameters; - iParameters = 0; - - CPhonebookParameters* parameters = (CPhonebookParameters*) aParameters; - - if( !parameters ) - { - iParameters = new (ELeave) CPhonebookParameters; - iParameters->iContactsInGroup = iContactsInGroup; - iParameters->iGroupName->Des().Copy( iEngine->RandomString(CCreatorEngine::EGroupName) ); - iParameters->iGroupName->Des().Append( _L(" #") ); - iParameters->iGroupName->Des().AppendNum( iEngine->RandomNumber(1000, 9999) ); - parameters = iParameters; - } - - // create a new contact group - - TUint32 newGroupId = iPhonebookWrapper->CreateGroupEntryL( parameters->iGroupName ); - - // define amounts of contacts to be added to the group - TInt amountOfContactsToBeAdded = 0; - if (parameters->iContactsInGroup == KCreateRandomAmountOfGroups) - { - amountOfContactsToBeAdded = iEngine->RandomNumber(30); - } - else - { - amountOfContactsToBeAdded = parameters->iContactsInGroup; - } - - if( parameters->iLinkIds.Count() > 0 ) - { - for( TInt i = 0; i < parameters->iLinkIds.Count(); ++i ) - { - const CCreatorContactSet& set = ContactLinkCache::Instance()->ContactSet(parameters->iLinkIds[i].iLinkId); - - const RArray links = set.ContactLinks();//ContactLinkCache::Instance()->ContactSets();//set.ContactLinks(); - TInt numberOfExplicitLinks = links.Count(); // Number of defined contacts in contact-set - TInt numberOfExistingContacts = set.NumberOfExistingContacts(); // Number of existing contacts in contact-set - TInt maxAmount = numberOfExplicitLinks + numberOfExistingContacts; - - if( parameters->iLinkIds[i].iLinkAmount > 0 ) - maxAmount = parameters->iLinkIds[i].iLinkAmount; // Max amount is limited - - TInt addedMembers = 0; - - for( TInt j = 0; j < links.Count() && addedMembers < maxAmount; ++j ) - { - - addedMembers += iPhonebookWrapper->AddContactToGroup(newGroupId,links[j]); - - } - if( addedMembers < maxAmount ) - { - // Add existing contacts, withing the limits set by maxAmount: - amountOfContactsToBeAdded += maxAmount - addedMembers; - } - } - } - if( amountOfContactsToBeAdded > 0 ) - { - TInt addedContacts = iPhonebookWrapper->AddToGroup(newGroupId, amountOfContactsToBeAdded); - - } - - // store the link to contact, so that Creator is able to delete - // it when user requests deletion of contacts that were created with Creator - iContactGroupsToDelete.AppendL( newGroupId ); - - return err; - } - -//---------------------------------------------------------------------------- - -TInt CCreatorPhonebook::CreateSubscribedContactEntryL(CCreatorModuleBaseParameters* /*aParameters*/) - { - LOGSTRING("Creator: CCreatorPhonebook::CreateSubscribedContactEntryL"); - - return KErrNotSupported; - } - -//---------------------------------------------------------------------------- - -CCreatorContactField::CCreatorContactField() - { - } -CCreatorContactField::~CCreatorContactField() - { - } - -CCreatorContactField* CCreatorContactField::NewL() - { - CCreatorContactField* self = new (ELeave) CCreatorContactField(); - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(); - return self; - } -void CCreatorContactField::ConstructL() - { - } - - -void CCreatorContactField::AddFieldToParamL( CCreatorEngine* aEngine, CPhonebookParameters* aParam, TInt aType, TInt aRand ) - { - HBufC* content = NULL; - if( aRand == KErrNotFound ) - { - TInt textFieldCount = sizeof(CreatorPbkPhoneNumberFields)/sizeof(TInt);; - for( TInt tfIndex = 0; tfIndex < textFieldCount; ++tfIndex ) - { - if( CreatorPbkPhoneNumberFields[tfIndex] == aType ) - { - content = aEngine->RandomString(CCreatorEngine::EPhoneNumber).AllocL(); - break; - } - } - - textFieldCount = sizeof(CreatorPbkUrlFields)/sizeof(TInt);; - for( TInt tfIndex = 0; tfIndex < textFieldCount; ++tfIndex ) - { - if( CreatorPbkUrlFields[tfIndex] == aType ) - { - content = aEngine->CreateHTTPUrlLC(); - CleanupStack::Pop(); - break; - } - } - textFieldCount = sizeof(CreatorPbkEmailFields)/sizeof(TInt);; - for( TInt tfIndex = 0; tfIndex < textFieldCount; ++tfIndex ) - { - if( CreatorPbkEmailFields[tfIndex] == aType ) - { - content = aEngine->CreateEmailAddressLC(); - CleanupStack::Pop(); - break; - } - } - - - //if there is textfield without specified random number - textFieldCount = sizeof(CreatorPbkMiscTextFields) / sizeof(DetailFieldInfo); - for( TInt tfIndex = 0; tfIndex < textFieldCount; ++tfIndex ) - { - if( CreatorPbkMiscTextFields[tfIndex].iFieldCode == aType && CreatorPbkMiscTextFields[tfIndex].iRandomType != RND_TYPE_UNDEF ) - { - TInt rand = CreatorPbkMiscTextFields[tfIndex].iRandomType; - content = aEngine->RandomString((CCreatorEngine::TRandomStringType) rand).AllocL(); - break; - } - } - } - - if( aRand != KErrNotFound && aRand != RND_TYPE_UNDEF ) - { - TInt textFieldCount = sizeof(CreatorPbkMiscTextFields) / sizeof(DetailFieldInfo); - for( TInt tfIndex = 0; tfIndex < textFieldCount; ++tfIndex ) - { - if( CreatorPbkMiscTextFields[tfIndex].iFieldCode == aType ) - { - content = aEngine->RandomString((CCreatorEngine::TRandomStringType) aRand).AllocL(); - } - } - } - - aParam->iContactFields.insert( TCreatorContactField(aType, content) ); - } - -void CCreatorContactField::AddFieldToParamL( CPhonebookParameters* aParam, TInt aType, TPtrC aContent ) - { - aParam->iContactFields.insert( TCreatorContactField(aType, aContent.AllocL()) ); - } - -//---------------------------------------------------------------------------- - -//---------------------------------------------------------------------------- - diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/src/creator_phonebookapi.cpp --- a/creator/engine/src/creator_phonebookapi.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,189 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include "creator_phonebookapi.h" - -CCreatorPhonebookAPI::CCreatorPhonebookAPI () - { - mContactMngr = new QContactManager("symbian"); - } - -CCreatorPhonebookAPI::~CCreatorPhonebookAPI () - { - if( mContactMngr ) - { - delete mContactMngr; - mContactMngr = NULL; - } - } - -quint32 CCreatorPhonebookAPI::saveContact( const QList& list ) - { - // create a new contact item - QContact store; - quint32 id; - for(int i = 0 ; i < list.count() ; i++ ) - { - QContactDetail cntdetail = list.at(i); - store.saveDetail(&cntdetail); - } - /*foreach( QContactDetail cntdetail, list ) - { - store.saveDetail( &cntdetail ); - } - */ - mContactMngr->saveContact( &store ); - id = store.localId(); - return id; - } - -quint32 CCreatorPhonebookAPI::createGroup( const QString& groupName ) - { - QContact newGroup; - newGroup.setType(QContactType::TypeGroup); - QContactName newGroupName; - newGroupName.setCustomLabel( groupName ); - newGroup.saveDetail(&newGroupName); - mContactMngr->saveContact(&newGroup); - return newGroup.localId(); - } - -int CCreatorPhonebookAPI::numberOfContacts() - { - QList contacts = mContactMngr->contactIds(); - return contacts.count(); - - } - -bool CCreatorPhonebookAPI::IsContactGroupL( const QContact& contact ) - { - - if( contact.type() == QContactType::TypeGroup ) - { - return true; - } - return false; - } - -int CCreatorPhonebookAPI::addContactToGroup( QContactLocalId group, QContactLocalId contact ) - { - QContact newGroup = mContactMngr->contact( group ); - QContact contactLink = mContactMngr->contact( contact ); - int ret = 0; - if( contact && IsContactGroupL( contactLink ) == false ) - { - QList relationships = contactLink.relationships(QContactRelationship::HasMember); - if( !relationships.count() && contactLink.type() == QContactType::TypeContact ) //just for contacts that are not in relationship - not in group yet - { - QContactRelationship* contactRel = new QContactRelationship(); - contactRel->setRelationshipType(QContactRelationship::HasMember); - contactRel->setFirst(newGroup.id()); - contactRel->setSecond( contactLink.id() ); - mContactMngr->saveRelationship( contactRel ); - delete contactRel; - ret++; - } - } - return ret; - } -int CCreatorPhonebookAPI::addToGroup(QContactLocalId group, int amount) - { - QList contacts = mContactMngr->contactIds(); - int ret = 0; - int tmp = 0; - int cnt = 0; - - for( int i=0; cnt < amount && i < contacts.count() ; i++ ) - { - QContact contact = mContactMngr->contact( mContactMngr->contactIds().at(i) ); - if( contact.type() == QContactType::TypeContact ) - { - tmp = addContactToGroup(group,mContactMngr->contactIds().at(i)); - ret += tmp; - if(tmp) - { - cnt++; - tmp = 0; - } - } - } - return ret; - } - - -bool CCreatorPhonebookAPI::deleteAllContacts() - { - QList all = mContactMngr->contactIds(); - return deleteContacts( all ); - } - -bool CCreatorPhonebookAPI::deleteAllContacts( const QString& type ) - { - QList contactsToDelete; - QList contacts = mContactMngr->contactIds(); - foreach(QContactLocalId contactId, contacts) - { - QContact contact = mContactMngr->contact( contactId ); - if( contact.type() == type ) - { - contactsToDelete.append( contact.localId() ); - } - } - return deleteContacts( contactsToDelete ); - } - - -bool CCreatorPhonebookAPI::deleteContacts( const QList& list ) - { - QMap errorMap; - return mContactMngr->removeContacts( list, &errorMap ); - } - -QContact CCreatorPhonebookAPI::contact( const QContactLocalId& contactId ) - { - return mContactMngr->contact( contactId ); - } - -QString CCreatorPhonebookAPI::phoneNumber( const QContactLocalId& contactId ) - { - QString strNumber; - QContact contact = mContactMngr->contact( contactId ); - if( !contact.isEmpty() ) - { - QContactPhoneNumber phoneNumber = static_cast( contact.detail( QContactPhoneNumber::DefinitionName ) ); - strNumber = phoneNumber.number(); - } - return strNumber; - } - -bool CCreatorPhonebookAPI::contactDetails( const QContactLocalId& contactId, QString& name, QString& phoneNumber, QString& email ) - { - bool success(false); - QContact contact = mContactMngr->contact( contactId ); - if( !contact.isEmpty() ) - { - QContactPhoneNumber contactPhoneNumber = static_cast( contact.detail( QContactPhoneNumber::DefinitionName ) ); - phoneNumber = contactPhoneNumber.number(); - QContactEmailAddress contactEmailAddress = static_cast( contact.detail( QContactEmailAddress::DefinitionName ) ); - email = contactEmailAddress.emailAddress(); - QContactDisplayLabel contactDisplayLabel = static_cast( contact.detail( QContactDisplayLabel::DefinitionName ) ); - name = contactDisplayLabel.label(); - success = true; - } - return success; - } -// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/src/creator_phonebookbase.cpp --- a/creator/engine/src/creator_phonebookbase.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,154 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include "engine.h" -#include "enginewrapper.h" -#include "creator_phonebookbase.h" -#include "creator_traces.h" - -void CCreatorPhonebookBase::QueryDialogClosedL(TBool aPositiveAction, TInt aUserData) - { - LOGSTRING("Creator: CCreatorPhonebookBase::QueryDialogClosedL"); - - if(aPositiveAction == EFalse && aUserData!=ECreatorPhonebookGetContactFields && aUserData!=ECreatorPhonebookContactsAllFields ) - { - iEngine->ShutDownEnginesL(); - return; - } - - const TDesC* showText = &KSavingText; - TBool finished(EFalse); - TBool retval(ETrue); - switch(aUserData) - { - case ECreatorPhonebookDelete: - showText = &KDeletingText; - finished = ETrue; - iEntriesToBeCreated = 1; - break; - case ECreatorPhonebookStart: - if(iCommand == ECmdCreatePhoneBookEntryContacts ) - { - retval = iEngine->GetEngineWrapper()->ListQueryDialog(_L("Fields in contact"), R_CONTACT_CREATION_TYPE_QUERY, - &iDummy, this, ECreatorPhonebookGetContactFields ); - } - else - { - retval = iEngine->GetEngineWrapper()->ListQueryDialog(_L("Number of contacts "), R_GROUP_CREATION_TYPE_QUERY, - &iDummy, this, ECreatorPhonebookGetGroupFields ); - } - break; - case ECreatorPhonebookGetContactFields: - if(iDummy==0)// first item, use default fields - - { - iDefaultFieldsSelected = ETrue; - finished = ETrue; - } - else - { - retval = iEngine->GetEngineWrapper()->EntriesQueryDialog(&iNumberOfPhoneNumberFields, _L("Amount of phone number fields in one contact?"), - ETrue, this, ECreatorPhonebookGetPhoneNumbersCount - ); - } - break; - case ECreatorPhonebookGetPhoneNumbersCount: - retval = iEngine->GetEngineWrapper()->EntriesQueryDialog(&iNumberOfURLFields, _L("Amount of URL fields in one contact?"), - ETrue, this, ECreatorPhonebookGetUrlsCount - ); - break; - case ECreatorPhonebookGetUrlsCount: - retval = iEngine->GetEngineWrapper()->EntriesQueryDialog(&iNumberOfEmailAddressFields, _L("Amount of email fields in one contact?"), - ETrue, this, ECreatorPhonebookGetEmailsCount - ); - break; - case ECreatorPhonebookGetEmailsCount: - retval = iEngine->GetEngineWrapper()->YesNoQueryDialog(_L("Add all the other fields to contacts?"), this, ECreatorPhonebookContactsAllFields); - break; - case ECreatorPhonebookContactsAllFields: - iAddAllFields = aPositiveAction; - // finaly we have all informations from user, start engine - finished = ETrue; - break; - case ECreatorPhonebookGetGroupFields: - iContactsInGroup = KCreateRandomAmountOfGroups; - if(iDummy==0)// first item, use default fields - { - finished = ETrue; - } - else - { - retval = iEngine->GetEngineWrapper()->EntriesQueryDialog(&iContactsInGroup, _L("Amount of contacts in one group?"), - ETrue, this, ECreatorPhonebookGetContactsInGroup); - } - break; - case ECreatorPhonebookGetContactsInGroup: - // finaly we have all informations from user, start engine - finished = ETrue; - break; - default: - //some error - retval = EFalse; - break; - } - if( retval == EFalse ) - { - iEngine->ShutDownEnginesL(); - } - else if( finished ) - { - // add this command to command array - iEngine->AppendToCommandArrayL(iCommand, NULL, iEntriesToBeCreated); - // started exucuting commands - iEngine->ExecuteFirstCommandL( *showText ); - } - } - -TBool CCreatorPhonebookBase::AskDataFromUserL(TInt aCommand) - { - LOGSTRING("Creator: CCreatorPhonebookBase::AskDataFromUserL"); - iCommand = aCommand; - - if( aCommand == ECmdDeleteContacts ) - { - return iEngine->GetEngineWrapper()->YesNoQueryDialog(_L("Delete all contacts?"), this, ECreatorPhonebookDelete ); - } - if( aCommand == ECmdDeleteCreatorContacts ) - { - return iEngine->GetEngineWrapper()->YesNoQueryDialog(_L("Delete all contacts created with Creator?"), this, ECreatorPhonebookDelete ); - } - if( aCommand == ECmdDeleteContactGroups ) - { - return iEngine->GetEngineWrapper()->YesNoQueryDialog(_L("Delete all contact groups?"), this, ECreatorPhonebookDelete ); - } - if( aCommand == ECmdDeleteCreatorContactGroups ) - { - return iEngine->GetEngineWrapper()->YesNoQueryDialog(_L("Delete all contact groups created with Creator?"), this, ECreatorPhonebookDelete ); - } - // display queries - return iEngine->GetEngineWrapper()->EntriesQueryDialog( &iEntriesToBeCreated, _L("How many entries to create?"), EFalse, this, ECreatorPhonebookStart); // ask number of entries to create - } - - -void CCreatorPhonebookBase::SetDefaultParameters() - { - iNumberOfPhoneNumberFields = 1; - iNumberOfURLFields = 0; - iNumberOfEmailAddressFields = 0; - iContactsInGroup = 50; - iDefaultFieldsSelected = EFalse; - } diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/src/creator_phonebookwrapper.cpp --- a/creator/engine/src/creator_phonebookwrapper.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,661 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#include "engine.h" -#include "enginewrapper.h" -#include "creator_contactsetcache.h" - -#include "creator_phonebookwrapper.h" -#include "creator_traces.h" - -#include - -typedef struct { -TInt iFieldCode; -QString iDetail; -QString iFieldContext; -QString iFieldString; -} QDetailFieldInfo; -//static const TInt RND_TYPE_UNDEF = -99; -QDetailFieldInfo CreatorPbkTextFields[] = { - { (TInt)CCreatorPhonebookWrapper::EFirstName,(QContactName::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactName::FieldFirstName).operator QString()}, - { (TInt)CCreatorPhonebookWrapper::ELastName,(QContactName::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactName::FieldLastName).operator QString()}, - { (TInt)CCreatorPhonebookWrapper::ECompanyName,(QContactOrganization::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactOrganization::FieldName).operator QString()}, - { (TInt)CCreatorPhonebookWrapper::EJobTitle,(QContactOrganization::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactOrganization::FieldTitle).operator QString()}, - { (TInt)CCreatorPhonebookWrapper::EPrefix,(QContactName::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactName::FieldPrefix).operator QString()}, - { (TInt)CCreatorPhonebookWrapper::ESuffix,(QContactName::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactName::FieldSuffix).operator QString()}, - { (TInt)CCreatorPhonebookWrapper::EMiddleName,(QContactName::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactName::FieldMiddleName).operator QString()}, - { (TInt)CCreatorPhonebookWrapper::EAddrStreetHome,(QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactAddress::FieldStreet).operator QString()}, - { (TInt)CCreatorPhonebookWrapper::EAddrLocalHome,(QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactAddress::FieldLocality).operator QString()}, - { (TInt)CCreatorPhonebookWrapper::EAddrRegionHome,(QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactAddress::FieldRegion).operator QString()}, - { (TInt)CCreatorPhonebookWrapper::EAddrPostCodeHome,(QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactAddress::FieldPostcode).operator QString()}, - { (TInt)CCreatorPhonebookWrapper::EAddrCountryHome,(QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactAddress::FieldCountry).operator QString()}, - { (TInt)CCreatorPhonebookWrapper::EAddrStreetGen,(QContactAddress::DefinitionName).operator QString(), "", (QContactAddress::FieldStreet).operator QString()}, - { (TInt)CCreatorPhonebookWrapper::EAddrLocalGen,(QContactAddress::DefinitionName).operator QString(), "", (QContactAddress::FieldLocality).operator QString()}, - { (TInt)CCreatorPhonebookWrapper::EAddrRegionGen,(QContactAddress::DefinitionName).operator QString(), "", (QContactAddress::FieldRegion).operator QString()}, - { (TInt)CCreatorPhonebookWrapper::EAddrPostCodeGen,(QContactAddress::DefinitionName).operator QString(), "", (QContactAddress::FieldPostcode).operator QString()}, - { (TInt)CCreatorPhonebookWrapper::EAddrCountryGen,(QContactAddress::DefinitionName).operator QString(), "", (QContactAddress::FieldCountry).operator QString()}, - { (TInt)CCreatorPhonebookWrapper::EAddrStreetWork,(QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactAddress::FieldStreet).operator QString()}, - { (TInt)CCreatorPhonebookWrapper::EAddrLocalWork,(QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactAddress::FieldLocality).operator QString()}, - { (TInt)CCreatorPhonebookWrapper::EAddrRegionWork,(QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactAddress::FieldRegion).operator QString()}, - { (TInt)CCreatorPhonebookWrapper::EAddrPostCodeWork,(QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactAddress::FieldPostcode).operator QString()}, - { (TInt)CCreatorPhonebookWrapper::EAddrCountryWork,(QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactAddress::FieldCountry).operator QString()}, - { (TInt)CCreatorPhonebookWrapper::EMobilePhoneWork,(QContactPhoneNumber::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactPhoneNumber::SubTypeMobile).operator QString()}, - { (TInt)CCreatorPhonebookWrapper::ELandPhoneWork,(QContactPhoneNumber::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactPhoneNumber::SubTypeLandline).operator QString()}, - { (TInt)CCreatorPhonebookWrapper::ENote,(QContactNote::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactNote::FieldNote).operator QString()}, - { (TInt)CCreatorPhonebookWrapper::EDepartment,(QContactOrganization::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactOrganization::FieldDepartment).operator QString()}, - { (TInt)CCreatorPhonebookWrapper::EAsstName,(QContactOrganization::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactOrganization::FieldAssistantName).operator QString()}, - { (TInt)CCreatorPhonebookWrapper::ESpouse,(QContactFamily::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactFamily::FieldSpouse).operator QString()}, - { (TInt)CCreatorPhonebookWrapper::EChildren,(QContactFamily::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactFamily::FieldChildren).operator QString()}, - { (TInt)CCreatorPhonebookWrapper::EGenLabel,(QContactName::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactName::FieldCustomLabel).operator QString()} - }; - - -typedef struct{ -TInt iFieldCode; -QString iFieldContext; -QString iFieldString; -}PhoneNumInfo; -PhoneNumInfo CreatorPhoneNumberFields[] = - { - { CCreatorPhonebookWrapper::ELandPhoneGen,"", "Landline"}, - { CCreatorPhonebookWrapper::ELandPhoneHome,"Home", "Landline"}, - { CCreatorPhonebookWrapper::ELandPhoneWork,"Work", "Landline"}, - { CCreatorPhonebookWrapper::EMobilePhoneGen,"","Mobile"}, - { CCreatorPhonebookWrapper::EMobilePhoneHome,"Home","Mobile"}, - { CCreatorPhonebookWrapper::EMobilePhoneWork,"Work", "Mobile"}, - { CCreatorPhonebookWrapper::EFaxNumberGen, "", "Facsimile"}, - { CCreatorPhonebookWrapper::EFaxNumberHome, "Home", "Facsimile"}, - { CCreatorPhonebookWrapper::EFaxNumberWork, "Work", "Facsimile"}, - { CCreatorPhonebookWrapper::EPagerNumber, "Work", "Pager"}, - { CCreatorPhonebookWrapper::EVideoNumberGen, "", "Video"}, - { CCreatorPhonebookWrapper::EVideoNumberHome, "Home", "Video"}, - { CCreatorPhonebookWrapper::EVideoNumberWork, "Work", "Video"}, //{ "Home", "Voice" },//{ "Work", "Voice" }, - { CCreatorPhonebookWrapper::EAsstPhone, "Work", "Assistant" }, - { CCreatorPhonebookWrapper::ECarPhone, "Home", "Car" } - }; - - -typedef struct{ - TInt iFieldCode; - QString iFieldContext; -}EmailInfo; -EmailInfo CreatorEmailFields[] = - { - {CCreatorPhonebookWrapper::EEmailGen,""}, - {CCreatorPhonebookWrapper::EEmailHome,(QContactDetail::ContextHome).operator QString()}, - {CCreatorPhonebookWrapper::EEmailWork,(QContactDetail::ContextWork).operator QString()} - }; - -typedef struct{ - TInt iFieldCode; - QString iFieldContext; -}UrlInfo; -UrlInfo CreatorUrlFields[] = - { - {CCreatorPhonebookWrapper::EUrlGen,""}, - {CCreatorPhonebookWrapper::EUrlHome,(QContactDetail::ContextHome).operator QString()}, - {CCreatorPhonebookWrapper::EUrlWork,(QContactDetail::ContextWork).operator QString()} - }; - -CCreatorPhonebookWrapper* CCreatorPhonebookWrapper::NewL() - { - CCreatorPhonebookWrapper* self = CCreatorPhonebookWrapper::NewLC(); - CleanupStack::Pop(self); - return self; - } - -CCreatorPhonebookWrapper* CCreatorPhonebookWrapper::NewLC() - { - CCreatorPhonebookWrapper* self = new (ELeave) CCreatorPhonebookWrapper(); - CleanupStack::PushL(self); - self->ConstructL(); - return self; - } - - -CCreatorPhonebookWrapper::CCreatorPhonebookWrapper() - { - } - -void CCreatorPhonebookWrapper::ConstructL() - { - LOGSTRING("Creator: CCreatorPhonebookWrapper::ConstructL"); - - QT_TRYCATCH_LEAVING( iPhonebookAPI = new CCreatorPhonebookAPI() ); - - } - - -CCreatorPhonebookWrapper::~CCreatorPhonebookWrapper() - { - LOGSTRING("Creator: CCreatorPhonebookWrapper::~CCreatorPhonebookWrapper"); - if( iPhonebookAPI ) - { - delete iPhonebookAPI; - iPhonebookAPI = NULL; - } - } - -//---------------------------------------------------------------------------- - -QList CCreatorPhonebookWrapper::CreateContactDetailsFromParameters( const TCreatorContactFields& aFields ) - { - QList contDetList; - QString content; - HBufC* temp; - TInt arraySize = sizeof(CreatorPbkTextFields)/sizeof(QDetailFieldInfo); - for (TInt i = 0; i < arraySize; i++) - { - TCreatorContactFields::const_iterator it = aFields.find(CreatorPbkTextFields[i].iFieldCode); - if( it != aFields.end() ) - { - temp = (*it).second; - content = QString::fromUtf16( temp->Des().Ptr(), temp->Length() ); - QContactDetail contactDetail = CreateContactDetail(contDetList, CreatorPbkTextFields[i].iDetail,CreatorPbkTextFields[i].iFieldContext,CreatorPbkTextFields[i].iFieldString, content ); - AddFieldToList( contDetList, contactDetail ); - } - } - arraySize = sizeof(CreatorPhoneNumberFields)/sizeof(PhoneNumInfo); - for (TInt i = 0; i < arraySize; i++) - { - TCreatorContactFields::const_iterator it = aFields.find(CreatorPhoneNumberFields[i].iFieldCode); - if( it != aFields.end() ) - { - temp = (*it).second; - content = QString::fromUtf16( temp->Des().Ptr(), temp->Length() ); - QContactDetail contactDetail = CreateContactDetail(contDetList, QContactPhoneNumber::DefinitionName ,CreatorPhoneNumberFields[i].iFieldContext,CreatorPhoneNumberFields[i].iFieldString, content ); - AddFieldToList( contDetList, contactDetail ); - } - } - - arraySize = sizeof(CreatorEmailFields)/sizeof(EmailInfo); - for (TInt i = 0; i < arraySize; i++) - { - TCreatorContactFields::const_iterator it = aFields.find(CreatorEmailFields[i].iFieldCode); - if( it != aFields.end() ) - { - temp = (*it).second; - content = QString::fromUtf16( temp->Des().Ptr(), temp->Length() ); - QContactDetail contactDetail = CreateContactDetail(contDetList, QContactEmailAddress::DefinitionName ,CreatorEmailFields[i].iFieldContext,"", content ); - AddFieldToList( contDetList, contactDetail ); - } - } - - arraySize = sizeof(CreatorUrlFields)/sizeof(UrlInfo); - for (TInt i = 0; i < arraySize; i++) - { - TCreatorContactFields::const_iterator it = aFields.find(CreatorUrlFields[i].iFieldCode); - if( it != aFields.end() ) - { - temp = (*it).second; - content = QString::fromUtf16( temp->Des().Ptr(), temp->Length() ); - QContactDetail contactDetail = CreateContactDetail(contDetList, QContactUrl::DefinitionName ,CreatorUrlFields[i].iFieldContext,"", content ); - AddFieldToList( contDetList, contactDetail ); - } - } - arraySize = sizeof(CreatorUrlFields)/sizeof(UrlInfo); - for (TInt i = 0; i < arraySize; i++) - { - TCreatorContactFields::const_iterator it = aFields.find(CreatorUrlFields[i].iFieldCode); - if( it != aFields.end() ) - { - temp = (*it).second; - content = QString::fromUtf16( temp->Des().Ptr(), temp->Length() ); - QContactDetail contactDetail = CreateContactDetail(contDetList, QContactUrl::DefinitionName ,CreatorUrlFields[i].iFieldContext,"", content ); - AddFieldToList( contDetList, contactDetail ); - } - } - - TCreatorContactFields::const_iterator it = aFields.find(CCreatorPhonebookWrapper::EThumbnailPic); - if( it != aFields.end() ) - { - temp = (*it).second; - if(temp) - { - content = QString::fromUtf16( temp->Des().Ptr(), temp->Length() ); - QContactDetail contactDetail = CreateContactDetail(contDetList, QContactAvatar::DefinitionName ,"","", content ); - AddFieldToList( contDetList, contactDetail ); - } - } - it = aFields.find(CCreatorPhonebookWrapper::EAnniversary); - if( it != aFields.end() ) - { - temp = (*it).second; - if(temp) - { - content = QString::fromUtf16( temp->Des().Ptr(), temp->Length() ); - QContactDetail contactDetail = CreateContactDetail(contDetList, QContactAnniversary::DefinitionName ,"","", content ); - AddFieldToList( contDetList, contactDetail ); - } - } - - return contDetList; - } -QContactDetail CCreatorPhonebookWrapper::CreateContactDetail( QList& aContactDetailList,QString aDetail, QString aFieldContext, QString aFieldString, QString aData ) - { - QContactDetail contactDetail; - - if( aDetail == QContactPhoneNumber::DefinitionName) - { - QContactPhoneNumber phoneNumber;// = contactDetail; - if(!aFieldContext.isEmpty()) - { - phoneNumber.setContexts(aFieldContext); - } - phoneNumber.setSubTypes(aFieldString); - //QString number = QString::fromUtf16(aData.Ptr(),aData.Length()); - phoneNumber.setNumber(aData); - return phoneNumber; - } - else if( aDetail == QContactName::DefinitionName ) //--Contact NAME----------------------------- - { - QContactName contactName; - for(int i = 0 ; i < aContactDetailList.count() ; i++ ) //go through all contact details to check if there is already Contact Name to set other details - { - if(aContactDetailList.at(i).definitionName() == QContactName::DefinitionName ) - { - contactName = aContactDetailList.at(i); - } - } - //QString name = QString::fromUtf16(aData.Ptr(),aData.Length()); - if(aFieldString == QContactName::FieldFirstName) - { - if(contactName.firstName().isEmpty()) - { - contactName.setFirstName( aData ); - } - } - else if(aFieldString == QContactName::FieldLastName) - { - if(contactName.lastName().isEmpty()) - { - contactName.setLastName( aData ); - } - } - else if(aFieldString == QContactName::FieldMiddleName) - { - if(contactName.middleName().isEmpty()) - { - contactName.setMiddleName( aData ); - } - } - else if(aFieldString == QContactName::FieldPrefix) - { - if(contactName.prefix().isEmpty()) - { - contactName.setPrefix( aData ); - } - } - else if(aFieldString == QContactName::FieldSuffix) - { - if(contactName.suffix().isEmpty()) - { - contactName.setSuffix( aData ); - } - } - else //QContactName::FieldCustomLabel: - { - if(contactName.customLabel().isEmpty()) - { - contactName.setCustomLabel( aData ); - } - } - return contactName; - } - else if( aDetail == QContactOrganization::DefinitionName ) //--Contact Company----------------------------- - { - QContactOrganization contactCompany; - - for(int i = 0 ; i < aContactDetailList.count() ; i++ ) //go through all contact details to check if there is already Contact Name to set other details - { - if(aContactDetailList.at(i).definitionName() == QContactOrganization::DefinitionName ) - { - contactCompany = aContactDetailList.at(i); - } - } - - //QString company = QString::fromUtf16(aData.Ptr(),aData.Length()); - if(aFieldString == QContactOrganization::FieldName) - { - if(contactCompany.name().isEmpty()) - { - contactCompany.setName( aData ); - } - } - if(aFieldString == QContactOrganization::FieldTitle) - { - if(contactCompany.title().isEmpty()) - { - contactCompany.setTitle( aData ); - } - } - if(aFieldString == QContactOrganization::FieldDepartment) - { - QStringList depList = contactCompany.department(); - depList.append(aData); - contactCompany.setDepartment(depList); - } - if(aFieldString == QContactOrganization::FieldAssistantName) - { - if(contactCompany.assistantName().isEmpty()) - { - contactCompany.setAssistantName( aData ); - } - } - return contactCompany; - } - else if( aDetail == QContactAddress::DefinitionName ) //--Contact Address----------------------------- - { - QContactAddress contactAddress; - - for(int i = 0 ; i < aContactDetailList.count() ; i++ ) //go through all contact details to check if there is already Contact Name to set other details - { - if(aContactDetailList.at(i).definitionName() == QContactAddress::DefinitionName && aContactDetailList.at(i).value(QContactDetail::FieldContext) == aFieldContext ) - { - contactAddress = aContactDetailList.at(i); - } - } - if( !aFieldContext.isEmpty() ) - { - contactAddress.setContexts( aFieldContext ); - } - //QString address = QString::fromUtf16(aData.Ptr(),aData.Length()); - if(aFieldString == QContactAddress::FieldStreet ) - { - if( contactAddress.street().isEmpty() ) - { - contactAddress.setStreet( aData ); - } - } - else if(aFieldString == QContactAddress::FieldLocality ) - { - if( contactAddress.locality().isEmpty() ) - { - contactAddress.setLocality( aData ); - } - } - else if(aFieldString == QContactAddress::FieldRegion ) - { - if( contactAddress.region().isEmpty() ) - { - contactAddress.setRegion( aData ); - } - } - else if(aFieldString == QContactAddress::FieldPostcode ) - { - if( contactAddress.postcode().isEmpty() ) - { - contactAddress.setPostcode( aData ); - } - } - else if(aFieldString == QContactAddress::FieldCountry ) - { - if( contactAddress.country().isEmpty() ) - { - contactAddress.setCountry( aData ); - } - } - else - { - return contactDetail; - } - return contactAddress; - } - else if( aDetail == QContactNote::DefinitionName ) //--Contact Note----------------------------- - { - QContactNote contactNote; - //QString note = QString::fromUtf16(aData.Ptr(),aData.Length()); - contactNote.setNote(aData); - return contactNote; - } - else if( aDetail == QContactFamily::DefinitionName ) //--Contact Family----------------------------- - { - QContactFamily contactFamily; - - for(int i = 0 ; i < aContactDetailList.count() ; i++ ) //go through all contact details to check if there is already Contact Name to set other details - { - if(aContactDetailList.at(i).definitionName() == QContactFamily::DefinitionName && aContactDetailList.at(i).value(QContactDetail::FieldContext) == aFieldContext ) - { - contactFamily = aContactDetailList.at(i); - } - } - - //QString familyData = QString::fromUtf16(aData.Ptr(),aData.Length()); - if(aFieldString == QContactFamily::FieldSpouse ) - { - if( contactFamily.spouse().isEmpty() ) - { - contactFamily.setSpouse( aData ); - } - } - if(aFieldString == QContactFamily::FieldChildren ) - { - QStringList children = contactFamily.children(); - children.append( aData ); - contactFamily.setChildren( children ); - } - - return contactFamily; - } - - if( aDetail == QContactAvatar::DefinitionName) //--Contact Picture----------------------------- - { - QContactAvatar contactAvatar; - QUrl imageUrl; - imageUrl.setUrl(aData); - contactAvatar.setImageUrl(imageUrl); - - return contactAvatar; - } - if( aDetail == QContactAnniversary::DefinitionName) //--Anniversary------------------------------ - { - QContactAnniversary contactAnniversary; - aData.replace(QChar('/'), QChar('-')); - QDate date = QDate::fromString(aData, "dd-MM-yyyy"); - //TTime datetime = aEngine->RandomDate( CCreatorEngine::EDateFuture ); - //date.setDate( datetime.DateTime().Year(),(int) (datetime.DateTime().Month()+1), datetime.DateTime().Day() ); - contactAnniversary.setOriginalDate( date ); - return contactAnniversary; - } - if( aDetail == QContactEmailAddress::DefinitionName) //--Email------------------------------------ - { - QContactEmailAddress email; - //QString emailAddr = QString::fromUtf16(aData.Ptr(),aData.Length()); - if( !aFieldContext.isEmpty() ) - { - email.setContexts( aFieldContext ); - } - email.setEmailAddress( aData ); - return email; - } - if( aDetail == QContactUrl::DefinitionName ) //--Url------------------------------------------- - { - QContactUrl url; - //QString urlStr = QString::fromUtf16(aData.Ptr(),aData.Length()); - if( !aFieldContext.isEmpty() ) - { - url.setContexts( aFieldContext ); - } - url.setUrl(aData); - return url; - } - if( aDetail == QContactBirthday::DefinitionName ) //--Birthday----------------------------------- - { - QContactBirthday birthday; - QDate date = QDate::fromString(aData); - //TTime datetime = aEngine->RandomDate( CCreatorEngine::EDatePast ); - //date.setDate( datetime.DateTime().Year(),(int) (datetime.DateTime().Month()+1), datetime.DateTime().Day() ); - birthday.setDate( date ); - return birthday; - } - - return contactDetail; - } - -void CCreatorPhonebookWrapper::AddFieldToList( QList& aDetailList, QContactDetail aDetail) - { - bool replace = false; - for(int i = 0 ; i< aDetailList.count() ; i++) //go through - { - if( !aDetail.isEmpty() && aDetail.definitionName() == aDetailList.at(i).definitionName() - && aDetail.definitionName() != QContactPhoneNumber::DefinitionName - && aDetail.definitionName() != QContactEmailAddress::DefinitionName - && aDetail.definitionName() != QContactUrl::DefinitionName ) - { - QString context = aDetail.value(QContactDetail::FieldContext); - bool isContextEmpty = context.isEmpty(); - if( isContextEmpty || ( aDetail.value(QContactDetail::FieldContext) == aDetailList.at(i).value(QContactDetail::FieldContext)) ) - { - //replace - aDetailList.replace(i,aDetail); - replace = true; - } - } - } - if(!replace) - { - if(!aDetail.isEmpty()) - { - aDetailList.append(aDetail); - } - } - - } - -TUint32 CCreatorPhonebookWrapper::CreateContactEntryL(const TCreatorContactFields& aFields) - { - QList list = CreateContactDetailsFromParameters( aFields ); - - return iPhonebookAPI->saveContact( list ); - } - - -//---------------------------------------------------------------------------- - - - -//---------------------------------------------------------------------------- - -void CCreatorPhonebookWrapper::DeleteAllL() - { - iPhonebookAPI->deleteAllContacts(); - } - -//---------------------------------------------------------------------------- -void CCreatorPhonebookWrapper::DeleteAllGroupsL() - { - LOGSTRING("Creator: CCreatorPhonebookWrapper::DeleteAllGroupsL"); - - iPhonebookAPI->deleteAllContacts( QContactType::TypeGroup ); - - } - -//---------------------------------------------------------------------------- -void CCreatorPhonebookWrapper::DeleteContactsL( RArray& aContactsToDelete, TUid aStoreUid ) - { - QList contacts; - for( TInt i = 0; i < aContactsToDelete.Count(); ++i ) - { - QContact contact = iPhonebookAPI->contact( QContactLocalId( aContactsToDelete[i] ) ); - if( (contact.type() == QContactType::TypeGroup && aStoreUid == KUidDictionaryUidContactGroups ) || (contact.type() != QContactType::TypeGroup && aStoreUid != KUidDictionaryUidContactGroups) ) - { - contacts.append( QContactLocalId( aContactsToDelete[i] ) ); - } - } - QMap errorMap; - iPhonebookAPI->deleteContacts( contacts ); - } - -//---------------------------------------------------------------------------- -TBool CCreatorPhonebookWrapper::HasOtherThanGroupsL() - { - LOGSTRING("Creator: CCreatorPhonebookWrapper::HasOtherThanGroupsL"); - TBool result( EFalse ); - return result; - } - - -TUint32 CCreatorPhonebookWrapper::CreateGroupEntryL( HBufC* aGroupName ) - { - TUint32 id = 0; - QString groupName = QString::fromUtf16( aGroupName->Des().Ptr(), aGroupName->Length() ); - - id = iPhonebookAPI->createGroup( groupName ); - - return id; - } -TInt CCreatorPhonebookWrapper::NumberOfContacts() - { - //return all stored contacts - return iPhonebookAPI->numberOfContacts(); - } - -TInt CCreatorPhonebookWrapper::AddContactToGroup( TUint32 aGroupId, TUint32 aContact ) - { - QContactLocalId group = QContactLocalId(aGroupId); - QContactLocalId contact = QContactLocalId(aContact); - - TInt ret = iPhonebookAPI->addContactToGroup(group, contact); - - return ret; - } -TInt CCreatorPhonebookWrapper::AddToGroup( TUint32 aGroupId, TInt aAmount ) - { - QContactLocalId group = QContactLocalId(aGroupId); - TInt ret = iPhonebookAPI->addToGroup( group, (int) aAmount ); - return ret; - } - - -//---------------------------------------------------------------------------- - -TInt CCreatorPhonebookWrapper::CreateSubscribedContactEntryL() - { - LOGSTRING("Creator: CCreatorPhonebookWrapper::CreateSubscribedContactEntryL"); - - return KErrNotSupported; - } - - -HBufC* CCreatorPhonebookWrapper::GetPhoneNumberL( TUint32 aContactId ) - { - QContactLocalId contact = QContactLocalId(aContactId); - QString phoneNumber = iPhonebookAPI->phoneNumber(contact); - HBufC *buf = HBufC::NewLC( phoneNumber.length() ); - buf->Des().Copy( phoneNumber.utf16() ); - CleanupStack::Pop( buf ); - return buf; - } - -TBool CCreatorPhonebookWrapper::GetContactDetailsL( TUint32 aContactId, TDes& aName, TDes& aPhoneNumber, TDes& aEmail ) - { - QString name; - QString phoneNumber; - QString email; - - QContactLocalId contact = QContactLocalId(aContactId); - bool success = iPhonebookAPI->contactDetails( contact, name, phoneNumber, email); - if( success ) - { - aName.Copy( name.utf16() ); - aPhoneNumber.Copy( phoneNumber.utf16() ); - aEmail.Copy( email.utf16() ); - } - return success ? ETrue : EFalse ; - } diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/src/creator_randomdataparser.cpp --- a/creator/engine/src/creator_randomdataparser.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,325 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - -#include -#include -#include -#include "creator_randomdataparser.h" -#include "creator_traces.h" - -// XML element names -_LIT(KRootElement, "creatordata"); -_LIT(KFirstName, "firstname"); -_LIT(KSurname, "surname"); -_LIT(KCompany, "company"); -_LIT(KAddress, "address"); -_LIT(KJobTitle, "jobtitle"); -_LIT(KPhoneNumber, "phonenumber"); -_LIT(KGroupName, "groupname"); -_LIT(KMeetingReason, "meetingreason"); -_LIT(KMeetingPlace, "meetingplace"); -_LIT(KMemoText, "memo"); -_LIT(KAnniversaryReason, "anniversary"); -_LIT(KToDoText, "todo"); -_LIT(KReminderText, "reminder"); -_LIT(KMessageSubject, "messagesubject"); -_LIT(KMessageText, "messagetext"); -_LIT(KCity, "city"); -_LIT(KCountry, "country"); -_LIT(KPostcode, "postcode"); -_LIT(KState, "state"); -_LIT(KPobox, "pobox"); -_LIT(KPrefix, "prefix"); -_LIT(KSuffix, "suffix"); -_LIT(KLandmarkName, "landmarkname"); -_LIT(KLandmarkDescription, "landmarkdescription"); - -using namespace Xml; - -CCreatorRandomDataParser::CCreatorRandomDataParser() - { - } - -void CCreatorRandomDataParser::ConstructL() - { - LOGSTRING("Creator: CCreatorRandomDataParser::ConstructL"); - iElementNameArray = new (ELeave) CDesCArrayFlat(32); - iElementNameArray->InsertL(EFirstName, KFirstName); - iElementNameArray->InsertL(ESurname, KSurname); - iElementNameArray->InsertL(ECompany, KCompany); - iElementNameArray->InsertL(EAddress, KAddress); - iElementNameArray->InsertL(EJobTitle, KJobTitle); - iElementNameArray->InsertL(EPhoneNumber, KPhoneNumber); - iElementNameArray->InsertL(EGroupName, KGroupName); - iElementNameArray->InsertL(EMeetingReason, KMeetingReason); - iElementNameArray->InsertL(EMeetingPlace, KMeetingPlace); - iElementNameArray->InsertL(EMemoText, KMemoText); - iElementNameArray->InsertL(EAnniversaryReason, KAnniversaryReason); - iElementNameArray->InsertL(EToDoText, KToDoText); - iElementNameArray->InsertL(EReminderText, KReminderText); - iElementNameArray->InsertL(EMessageSubject, KMessageSubject); - iElementNameArray->InsertL(EMessageText, KMessageText); - iElementNameArray->InsertL(ECity, KCity); - iElementNameArray->InsertL(ECountry, KCountry); - iElementNameArray->InsertL(EPostcode, KPostcode); - iElementNameArray->InsertL(EState, KState); - iElementNameArray->InsertL(EPobox, KPobox); - iElementNameArray->InsertL(EPrefix, KPrefix); - iElementNameArray->InsertL(ESuffix, KSuffix); - iElementNameArray->InsertL(ELandmarkName, KLandmarkName); - iElementNameArray->InsertL(ELandmarkDescription, KLandmarkDescription); - iContentData = HBufC::NewL(16); - iResultArray = new (ELeave) CDesCArrayFlat(16); - } - -CCreatorRandomDataParser* CCreatorRandomDataParser::NewL() - { - LOGSTRING("Creator: CCreatorRandomDataParser::NewL"); - CCreatorRandomDataParser* self = CCreatorRandomDataParser::NewLC(); - CleanupStack::Pop(); - return self; - } - -CCreatorRandomDataParser* CCreatorRandomDataParser::NewLC() - { - LOGSTRING("Creator: CCreatorRandomDataParser::NewLC"); - CCreatorRandomDataParser* self = new (ELeave) CCreatorRandomDataParser; - CleanupStack::PushL(self); - self->ConstructL(); - return self; - } - -CCreatorRandomDataParser::~CCreatorRandomDataParser() - { - delete iParser; - delete iResultArray; - delete iContentData; - delete iElementNameArray; - } - -void CCreatorRandomDataParser::GetTextFileMode(RFile& aFile, TInt& aFileSize) - { - LOGSTRING("Creator: CCreatorRandomDataParser::GetTextFileMode"); - iScriptTextFormat = EFormatANSIASCII; - - // if we are working with text files, check the type first - TBuf8<4> BOM; - - // first check for UTF-16 - if (aFileSize >= 2 && aFile.Read(0, BOM, 2) == KErrNone) - { - if (BOM.Length()==2 && BOM[0]==0xFF && BOM[1]==0xFE) - { - iScriptTextFormat = EFormatUTF16LE; - aFileSize -= 2; - return; - } - else if (BOM.Length()==2 && BOM[0]==0xFE && BOM[1]==0xFF) - { - iScriptTextFormat = EFormatUTF16BE; - aFileSize -= 2; - return; - } - } - // then check for UTF-8 - if (aFileSize >= 3 && aFile.Read(0, BOM, 3) == KErrNone) - { - if (BOM.Length()==3 && BOM[0]==0xEF && BOM[1]==0xBB && BOM[2]==0xBF) - { - iScriptTextFormat = EFormatUTF8; - aFileSize -= 3; - return; - } - } - - // none of those, seek back to beginning - TInt pos(0); - aFile.Seek(ESeekStart, pos); - } - - - -CDesCArrayFlat* CCreatorRandomDataParser::ParseL(const TDesC& aFileName, const TRandomDataType aDataType) - { - LOGSTRING2("Creator: CCreatorRandomDataParser::ParseL: %S", &aFileName); - - iDataType = aDataType; - - // Create and start XML-parser - if( iParser == 0) - { - _LIT8(KXmlMimeType, "text/xml"); - iParser = CParser::NewL(KXmlMimeType, *this); - } - - RFs filesession; - CleanupClosePushL(filesession); - User::LeaveIfError( filesession.Connect() ); - - iResultArray->Reset(); - - Xml::ParseL(*iParser, filesession, aFileName); - - CleanupStack::PopAndDestroy(&filesession); // filesession - - CDesCArrayFlat* tempArray = new (ELeave) CDesCArrayFlat(8); - CleanupStack::PushL(tempArray); - for (TInt i = 0; i < iResultArray->MdcaCount(); i++) - { - tempArray->AppendL(iResultArray->MdcaPoint(i)); - } - CleanupStack::Pop(tempArray); - return tempArray; - } - -void CCreatorRandomDataParser::OnStartDocumentL(const Xml::RDocumentParameters& /*aDocParam*/, TInt aErrorCode) - { - LOGSTRING2("Creator: CCreatorRandomDataParser::OnStartDocumentL (Error code: %d)", aErrorCode); - User::LeaveIfError(aErrorCode); - iInsideRootElement = EFalse; - iContentParsingActive = EFalse; - } - -void CCreatorRandomDataParser::OnEndDocumentL(TInt aErrorCode) - { - LOGSTRING2("Creator: CCreatorRandomDataParser::OnEndDocumentL (Error code: %d)", aErrorCode); - User::LeaveIfError(aErrorCode); - } - -void CCreatorRandomDataParser::OnStartPrefixMappingL(const RString& /*aPrefix*/, - const RString& /*aUri*/, - TInt aErrorCode) - { - LOGSTRING2("Creator: CCreatorRandomDataParser::OnStartPrefixMappingL (Error code: %d)", aErrorCode); - User::LeaveIfError(aErrorCode); - } - -void CCreatorRandomDataParser::OnEndPrefixMappingL(const RString& /*aPrefix*/, TInt aErrorCode) - { - LOGSTRING2("Creator: CCreatorRandomDataParser::OnEndPrefixMappingL (Error code: %d)", aErrorCode); - User::LeaveIfError(aErrorCode); - } - -void CCreatorRandomDataParser::OnIgnorableWhiteSpaceL(const TDesC8& /*aBytes*/, TInt aErrorCode) - { - LOGSTRING2("Creator: CCreatorRandomDataParser::OnIgnorableWhiteSpaceL (Error code: %d)", aErrorCode); - User::LeaveIfError(aErrorCode); - } - -void CCreatorRandomDataParser::OnSkippedEntityL(const RString& /*aName*/, TInt aErrorCode) - { - LOGSTRING2("Creator: CCreatorRandomDataParser::OnSkippedEntityL (Error code: %d)", aErrorCode); - User::LeaveIfError(aErrorCode); - } - -void CCreatorRandomDataParser::OnProcessingInstructionL(const TDesC8& /*aTarget*/, - const TDesC8& /*aData*/, - TInt aErrorCode) - { - LOGSTRING2("Creator: CCreatorRandomDataParser::OnProcessingInstructionL (Error code: %d)", aErrorCode); - User::LeaveIfError(aErrorCode); - } - -void CCreatorRandomDataParser::OnError(TInt aErrorCode) - { - LOGSTRING2("Creator: CCreatorRandomDataParser::OnError: %d", aErrorCode); - - iLastError = aErrorCode; - } - -TAny* CCreatorRandomDataParser::GetExtendedInterface(const TInt32 aUid) - { - LOGSTRING2("Creator: CCreatorRandomDataParser::GetExtendedInterface (UID: %d)", aUid); - return this; - } - -void CCreatorRandomDataParser::OnStartElementL(const Xml::RTagInfo& aElement, - const Xml::RAttributeArray& /*aAttributes*/, - TInt aErrorCode) - { - LOGSTRING2("Creator: CCreatorRandomDataParser::OnStartElementL (Error code: %d)", aErrorCode); - User::LeaveIfError(aErrorCode); - - const TDesC8& elementName8 = aElement.LocalName().DesC(); - HBufC* elementName16 = Convert8BitTo16BitLC(elementName8); - if (iInsideRootElement || (elementName16->Des() == KRootElement)) - { - iInsideRootElement = ETrue; - } - if (iInsideRootElement && (elementName16->Des() == iElementNameArray->MdcaPoint(iDataType))) - { - iContentParsingActive = ETrue; - iContentData->Des().Zero(); - } - CleanupStack::PopAndDestroy(elementName16); - } - -void CCreatorRandomDataParser::OnEndElementL(const Xml::RTagInfo& aElement, TInt aErrorCode) - { - LOGSTRING2("Creator: CCreatorRandomDataParser::OnEndElementL (Error code: %d)", aErrorCode); - User::LeaveIfError(aErrorCode); - - const TDesC8& elementName8 = aElement.LocalName().DesC(); - HBufC* elementName16 = Convert8BitTo16BitLC(elementName8); - if (!iInsideRootElement || (elementName16->Des() == KRootElement)) - { - iInsideRootElement = EFalse; - } - CleanupStack::PopAndDestroy(elementName16); - - if (iContentParsingActive) - { - if (iContentData->Des().Length() > 0) - { - iResultArray->AppendL(*iContentData); - } - iContentParsingActive = EFalse; - } - } - -void CCreatorRandomDataParser::OnContentL(const TDesC8& aBytes, TInt aErrorCode) - { - LOGSTRING2("Creator: CCreatorRandomDataParser::OnContentL (Error code: %d)", aErrorCode); - User::LeaveIfError(aErrorCode); - - if (iContentParsingActive) - { - HBufC* data16 = Convert8BitTo16BitLC(aBytes); - TInt newLen = iContentData->Des().Length() + data16->Des().Length(); - iContentData = iContentData->ReAllocL(newLen); - iContentData->Des().Append(*data16); - CleanupStack::PopAndDestroy(data16); - } - } - -HBufC16* CCreatorRandomDataParser::Convert8BitTo16BitLC(const TDesC8& aInput) - { - LOGSTRING("Creator: CCreatorRandomDataParser::Convert8BitTo16BitLC"); - HBufC16* output = NULL; - - output = CnvUtfConverter::ConvertToUnicodeFromUtf8L(aInput); - - CleanupStack::PushL(output); - return output; - } - -TInt CCreatorRandomDataParser::GetError() const - { - return iLastError; - } diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/src/creator_scriptelement.cpp --- a/creator/engine/src/creator_scriptelement.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,722 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - -#include "creator_traces.h" -#include "creator_scriptelement.h" -#include -#include -#include // KMaxTelNumberSize - -using namespace Xml; - -CCreatorScriptElementCache* CCreatorScriptElementCache::NewL() -{ - CCreatorScriptElementCache* self = new (ELeave) CCreatorScriptElementCache; - CleanupStack::PushL(self); - - self->ConstructL(); - CleanupStack::Pop(); - return self; -} - -CCreatorScriptElementCache::CCreatorScriptElementCache() - { - - } - -void CCreatorScriptElementCache::ConstructL() - { - - } - -CCreatorScriptElementCache::~CCreatorScriptElementCache() - { - iElementCache.Reset(); - iElementCache.Close(); - } - -void CCreatorScriptElementCache::RemoveElements() - { - iElementCache.Reset(); - } - - -void CCreatorScriptElementCache::AddElementL(CCreatorScriptElement* aElement) - { - iElementCache.AppendL(aElement); - } - -/** - * - */ -CCreatorScriptAttribute* CCreatorScriptAttribute::NewLC(const TDesC& aName, const TDesC& aValue) - { - CCreatorScriptAttribute* self = new(ELeave) CCreatorScriptAttribute(); - CleanupStack::PushL(self); - self->ConstructL(aName, aValue); - return self; - } - -CCreatorScriptAttribute* CCreatorScriptAttribute::NewL(const TDesC& aName, const TDesC& aValue) - { - CCreatorScriptAttribute* self = CCreatorScriptAttribute::NewLC(aName, aValue); - CleanupStack::Pop(); // self - return self; - } - -CCreatorScriptAttribute::~CCreatorScriptAttribute() - { - delete iName; - delete iValue; - } - -TPtrC CCreatorScriptAttribute::Name() const - { - return iName->Des(); - } - -void CCreatorScriptAttribute::SetNameL(const TDesC& aName) - { - if( iName ) - { - delete iName; - iName = 0; - } - iName = HBufC::NewL(aName.Length()); - iName->Des() = aName; - } - -TPtrC CCreatorScriptAttribute::Value() const - { - return iValue->Des(); - } - -void CCreatorScriptAttribute::SetValueL(const TDesC& aValue) - { - if( iValue ) - { - delete iValue; - iValue = 0; - } - iValue = HBufC::NewL(aValue.Length()); - iValue->Des() = aValue; - } - -CCreatorScriptAttribute::CCreatorScriptAttribute() - { - } - -void CCreatorScriptAttribute::ConstructL(const TDesC& aName, const TDesC& aValue) - { - SetNameL(aName); - SetValueL(aValue); - } - -/** - * CCreatorScriptElement - */ - -CCreatorScriptElement* CCreatorScriptElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext) - { - CCreatorScriptElement* self = new (ELeave) CCreatorScriptElement(aEngine); - CleanupStack::PushL(self); - self->ConstructL(aName, aContext); - CleanupStack::Pop(); - return self; - } - -CCreatorScriptElement::~CCreatorScriptElement() - { - LOGSTRING("Creator: CCreatorScriptElement::~CCreatorScriptElement"); - iSubElements.ResetAndDestroy(); - iAttributes.ResetAndDestroy(); - iSubElements.Close(); - iAttributes.Close(); - iParameters.Reset(); - iParameters.Close(); - delete iName; - delete iContent; - delete iContext; - } - -RPointerArray const& CCreatorScriptElement::SubElements() const - { - return iSubElements; - } - -RPointerArray& CCreatorScriptElement::SubElements() - { - return iSubElements; - } - -CCreatorScriptElement* CCreatorScriptElement::SubElement(TInt aIndex) - { - return iSubElements[aIndex]; - } - -CCreatorScriptElement* CCreatorScriptElement::FindSubElement(const TDesC& aName) - { - for( TInt i = 0; i < iSubElements.Count(); ++i ) - { - if( iSubElements[i]->Name() == aName ) - { - return iSubElements[i]; - } - } - return 0; - } - -void CCreatorScriptElement::RemoveSubElements() - { - iSubElements.ResetAndDestroy(); - } - -void CCreatorScriptElement::RemoveSubElementL(TInt aIndex) - { - if( aIndex < iSubElements.Count()) - { - delete iSubElements[aIndex]; - iSubElements.Remove(aIndex); - } - else - { - User::Leave(KErrArgument); - } - } - -void CCreatorScriptElement::AddSubElementL(CCreatorScriptElement* aElem, TInt aIndex ) - { - if( aIndex == -1 || aIndex == iSubElements.Count() ) - { - iSubElements.AppendL(aElem); - } - else if( aIndex < iSubElements.Count()) - { - iSubElements.InsertL(aElem, aIndex); - } - else - { - User::Leave(KErrArgument); - } - } - -RPointerArray const& CCreatorScriptElement::Attributes() const - { - return iAttributes; - } - - - CCreatorScriptAttribute* CCreatorScriptElement::Attribute(TInt aIndex) - { - return iAttributes[aIndex]; - } - -void CCreatorScriptElement::RemoveAttributes() - { - iAttributes.ResetAndDestroy(); - } - - -void CCreatorScriptElement::RemoveAttributeL(TInt aIndex) - { - if( aIndex < iAttributes.Count()) - { - delete iAttributes[aIndex]; - iAttributes.Remove(aIndex); - } - else - { - User::Leave(KErrArgument); - } - } - -void CCreatorScriptElement::AddAttributeL(CCreatorScriptAttribute* aAttribute, TInt aIndex ) - { - if( aIndex == -1 || aIndex == iAttributes.Count() ) - { - iAttributes.AppendL(aAttribute); - } - else if( aIndex < iAttributes.Count()) - { - iAttributes.InsertL(aAttribute, aIndex); - } - else - { - User::Leave(KErrArgument); - } - } - -TPtrC CCreatorScriptElement::Name() const - { - if( iName ) - return iName->Des(); - return TPtrC(); - } - -void CCreatorScriptElement::SetNameL(const TDesC& aName) - { - if( iName ) - { - delete iName; - iName = 0; - } - iName = HBufC::NewL(aName.Length()); - iName->Des() = aName; - } - - -TPtrC CCreatorScriptElement::Content() const - { - if (iContent) - return iContent->Des(); - return TPtrC(); - } - -void CCreatorScriptElement::SetContentL(const TDesC& aContent) - { - if( iContent ) - { - delete iContent; - iContent = 0; - } - iContent = HBufC::NewL(aContent.Length()); - iContent->Des() = aContent; - } - -void CCreatorScriptElement::AppendContentL(const TDesC& aContent) - { - if( iContent == 0 ) - { - SetContentL(aContent); - return; - } - - iContent = iContent->ReAllocL(iContent->Length() + aContent.Length() ); - - TPtr ptr(iContent->Des()); - ptr += aContent; - } - -TPtrC CCreatorScriptElement::Context() const - { - if( iContext ) - return iContext->Des(); - return TPtrC(); - } - -void CCreatorScriptElement::SetContextL(const TDesC& aContext) - { - if( iContext ) - { - delete iContext; - iContext = 0; - } - iContext = HBufC::NewL(aContext.Length()); - iContext->Des() = aContext; - } - -const CCreatorScriptAttribute* CCreatorScriptElement::FindAttributeByName(const TDesC& aName) const - { - for( TInt i = 0; i < iAttributes.Count(); ++i ) - { - CCreatorScriptAttribute* attr = iAttributes[i]; - if( attr->Name() == aName ) - { - return attr; - } - } - return 0; - } - -CCreatorScriptAttribute* CCreatorScriptElement::FindAttributeByName(const TDesC& aName) - { - for( TInt i = 0; i < iAttributes.Count(); ++i ) - { - CCreatorScriptAttribute* attr = iAttributes[i]; - if( attr->Name() == aName ) - { - return attr; - } - } - return 0; - } - -TBool CCreatorScriptElement::IsCacheNeeded() - { - _LIT(KIDAttrName, "id"); - const CCreatorScriptAttribute* attr = FindAttributeByName(KIDAttrName); - return attr != 0; - } - -void CCreatorScriptElement::AddToCacheL(CCreatorScriptElementCache& aCache) - { - aCache.AddElementL(this); - } - -RPointerArray& CCreatorScriptElement::CommandParameters() - { - return iParameters; - } - -const RPointerArray& CCreatorScriptElement::CommandParameters() const - { - return iParameters; - } - -void CCreatorScriptElement::AddToCacheL() - { - } - -TBool CCreatorScriptElement::IsCommandElement() const - { - return iIsCommandElement; - } - -void CCreatorScriptElement::ExecuteCommandL() - { - - } - -TBool CCreatorScriptElement::IsRoot() const - { - _LIT(KRootName, "creatorscript"); - if(iName->Des() == KRootName) - return ETrue; - return EFalse; - } - -CCreatorScriptElement::CCreatorScriptElement(CCreatorEngine* aEngine) -: -iIsCommandElement(EFalse), -iIsRoot(EFalse), -iEngine(aEngine) - {} - -void CCreatorScriptElement::ConstructL(const TDesC& aName, const TDesC& aContext) - { - SetNameL(aName); - SetContextL(aContext); - } - -TBool CCreatorScriptElement::IsSubElementSupported(const CCreatorScriptElement& /*aElem*/) const - { - return ETrue; - } - -TBool CCreatorScriptElement::ConvertStrToBooleanL(const TDesC& aStr) const - { - TBool boolVal = EFalse; - _LIT(KYes, "yes"); - _LIT(KTrue, "true"); - if( CompareIgnoreCase(aStr, KYes) == 0 || - CompareIgnoreCase(aStr, KTrue) == 0 ) - { - boolVal = ETrue; - } - return boolVal; - } - -TInt CCreatorScriptElement::ConvertStrToIntL(const TDesC& aStr) const - { - TInt intVal = 0; - TLex lex(aStr); - TInt errorCode=lex.Val(intVal); - User::LeaveIfError(errorCode); - return intVal; - } - -TUint CCreatorScriptElement::ConvertStrToUintL(const TDesC& aStr) const - { - TUint uintVal = 0; - TLex lex(aStr); - TInt errorCode=lex.Val(uintVal); - User::LeaveIfError(errorCode); - return uintVal; - } -void CCreatorScriptElement::ConvertStrToReal64L(const TDesC& aStr, TReal64& aVal) const - { - TLex lex(aStr); - TInt errorCode=lex.Val(aVal); - User::LeaveIfError(errorCode); - } - -void CCreatorScriptElement::ConvertStrToReal32L(const TDesC& aStr, TReal32& aVal) const - { - TLex lex(aStr); - TInt errorCode=lex.Val(aVal); - User::LeaveIfError(errorCode); - } - -MCreatorRandomDataField::TRandomLengthType CCreatorScriptElement::ResolveRandomDataTypeL(const CCreatorScriptAttribute& aAttr, TInt& aRandomLen) const - { - TPtrC attrVal = aAttr.Value(); - if(attrVal == KMax ) - return MCreatorRandomDataField::ERandomLengthMax; - if(attrVal == KDefault) - return MCreatorRandomDataField::ERandomLengthDefault; - - // Let's see if the value is numeric: - TInt val = 0; - TLex lex(attrVal); - TInt errorCode=lex.Val(val); - if( errorCode == KErrNone ) - { - aRandomLen = val; - return MCreatorRandomDataField::ERandomLengthExplicit; - } - return MCreatorRandomDataField::ERandomLengthUndefined; - } - -void CCreatorScriptElement::AppendContactSetReferenceL( - const CCreatorScriptElement& aContactSetRefElem, - RArray& aLinkArray ) const - { - const TDesC& eName = aContactSetRefElem.Name(); - if( eName != KContactSetRef ) - return; - - const CCreatorScriptAttribute* linkIdAttr = aContactSetRefElem.FindAttributeByName(KId); - if( linkIdAttr ) - { - TInt linkId = ConvertStrToIntL(linkIdAttr->Value()); - if( linkId > 0 ) - { - TLinkIdParam linkParams; - // Add contact-set-reference id to links - linkParams.iLinkId = linkId; - linkParams.iLinkAmount = KUndef; // undefined - // Resolve maxamount: - const CCreatorScriptAttribute* maxAmount = aContactSetRefElem.FindAttributeByName(KMaxAmount); - if( maxAmount ) - { - TInt maxAmountVal = ConvertStrToIntL(maxAmount->Value()); - if( maxAmountVal > 0 ) - { - linkParams.iLinkAmount = maxAmountVal; - } - } - aLinkArray.AppendL(linkParams); - } - } - } - -TTime CCreatorScriptElement::ConvertToDateTimeL(const TDesC& aDtStr) const - { - _LIT(KDateFieldSeparator, "-"); - _LIT(KTimeFieldSeparator, ":"); - _LIT(KDateTimeSeparator, "T"); - _LIT(KTimeSuffix, "."); - _LIT(KDateSuffix, ":"); - // Format date-time string: - HBufC* formatted = HBufC::NewLC(aDtStr.Length()); - formatted->Des().Copy(aDtStr); - - TBool hasTimePart = EFalse; - TBool hasDateTimeSeparator = EFalse; - TInt pos = 0; - - // Date and month numbering starts from 0 in Symbian, so first - // we need to decrease the date and month by one. Script format is following: - // yyyy-mm-ddThh:mm:ss - // Remove also date field separators ('-') - while( (pos = formatted->Find(KDateFieldSeparator)) != KErrNotFound ) - { - // decrease month or date by one - - // First char. Can be zero also: - TInt newValue = 0; - const TPtrC& char1 = formatted->Des().Mid(pos+1).Left(1); - newValue = 10 * ConvertStrToIntL(char1); - // Next char: - const TPtrC& char2 = formatted->Des().Mid(pos+2).Left(1); - newValue += ConvertStrToIntL(char2); - - if( newValue > 0 ) - { - --newValue; - } - - _LIT(KTemp, "%d"); - HBufC* formatBuf = KTemp().AllocLC(); - HBufC* buf = 0; - if( newValue < 10 ) - buf = HBufC::NewLC(1); - else - buf = HBufC::NewLC(2); - - TPtr temp(buf->Des()); - temp.Format(*formatBuf, newValue); - if( newValue < 10 ) - { - formatted->Des()[pos+1] = TChar('0'); - formatted->Des()[pos+2] = buf->Des()[0]; - } - else - { - formatted->Des()[pos+1] = buf->Des()[0]; - formatted->Des()[pos+2] = buf->Des()[1]; - } - // Finally, delete the '-' separator: - formatted->Des().Delete(pos, 1); - CleanupStack::PopAndDestroy(2); - } - - while( (pos = formatted->Find(KTimeFieldSeparator)) != KErrNotFound ) - { - formatted->Des().Delete(pos, 1); - hasTimePart = ETrue; - } - - // Replace 'T' with ':': - if( (pos = formatted->Find(KDateTimeSeparator)) != KErrNotFound ) - { - formatted->Des().Replace(pos, 1, KDateSuffix); - hasDateTimeSeparator = ETrue; - } - - if( hasTimePart ) - formatted->Des().Append(KTimeSuffix); - else if( !hasDateTimeSeparator ) - formatted->Des().Append(KDateSuffix); - - - TTime ret; - ret.Set(*formatted); - CleanupStack::PopAndDestroy(); // formatted - return ret; - } - -TInt CCreatorScriptElement::CompareIgnoreCase(const TDesC& aStr1, const TDesC& aStr2 ) const - { - // Get default collation method: - TCollationMethod defaultCollationMethod = *Mem::CollationMethodByIndex(0); - - // Add ignore case flag: - defaultCollationMethod.iFlags |= TCollationMethod::EFoldCase; - - return aStr1.CompareF(aStr2); - } - -void CCreatorScriptElement::SetContentToTextParamL(HBufC*& aPtr, const TDesC& aContent ) - { - delete aPtr; - aPtr = 0; - aPtr = HBufC::NewL(aContent.Length()); - aPtr->Des().Copy(aContent); - } - -/** - * Increases phonenumber by aDelta. - */ -void CCreatorScriptElement::IncreasePhoneNumL( const TDesC& aOriginal, TInt aDelta, HBufC* aIncreased ) const - { - LOGSTRING("Creator: CCreatorMessageElement::IncreasePhoneNumL"); - __ASSERT_ALWAYS( aDelta >= 0, User::Panic( _L("IncreasePhoneNumL"), KErrArgument ) ); - - // special cases, that are handled: - // +9 -> +9, +10, +11... - // +3584098#99 -> +3584098#99, +3584098#100, +3584098#101... - // # -> #0, #1, #2... - // 123# -> 123#0, 123#1, 123#2... - // 099 -> 099, 100, 101... - - // find out if there are any special characters, like # p or *, in the original number - TInt startIndex( aOriginal.Length() -1 ); - while ( startIndex >= 0 && - aOriginal[startIndex] >= '0' && - aOriginal[startIndex] <= '9' ) - { - startIndex--; - } - startIndex++; - - // append original head that may contain any non number characters - aIncreased->Des().Append( aOriginal.Left( startIndex ) ); - - TBuf tailBuf; - if ( aOriginal.Length() > startIndex ) - { - tailBuf.Copy( aOriginal.Right( aOriginal.Length() -startIndex ) ); - } - - // parse the tail part of the original number - TInt64 intVal = 0; - if ( aOriginal.Length() > startIndex ) - { - TLex lex( tailBuf ); - User::LeaveIfError( lex.Val( intVal ) ); // this loses leading zeros - } - - // increase - intVal += aDelta; - - // restore leading zeros to tail, if any - TBuf resultTailNoZeros; - resultTailNoZeros.AppendNum( intVal ); - TInt tailLeadingZerosToRestore = tailBuf.Length() - resultTailNoZeros.Length(); - for ( TInt i = 0; i < tailLeadingZerosToRestore; i++ ) - { - aIncreased->Des().AppendNum( 0 ); - } - - // and finally, append the increased value as tail part of the result - aIncreased->Des().Append( resultTailNoZeros ); - } - -CCreatorScriptRoot* CCreatorScriptRoot::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext) - { - CCreatorScriptRoot* self = new (ELeave) CCreatorScriptRoot(aEngine); - CleanupStack::PushL(self); - self->ConstructL(aName, aContext); - CleanupStack::Pop(); - return self; - } -CCreatorScriptRoot::CCreatorScriptRoot(CCreatorEngine* aEngine) -: -CCreatorScriptElement(aEngine) - { - iIsRoot=ETrue; - } - - -CCreatorCalendarElementBase* CCreatorCalendarElementBase::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext) - { - CCreatorCalendarElementBase* self = new (ELeave) CCreatorCalendarElementBase(aEngine); - CleanupStack::PushL(self); - self->ConstructL(aName, aContext); - CleanupStack::Pop(); - return self; - } -CCreatorCalendarElementBase::CCreatorCalendarElementBase(CCreatorEngine* aEngine) -: -CCreatorScriptElement(aEngine) - { } - -CCreatorMessageElementBase* CCreatorMessageElementBase::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext) - { - CCreatorMessageElementBase* self = new (ELeave) CCreatorMessageElementBase(aEngine); - CleanupStack::PushL(self); - self->ConstructL(aName, aContext); - CleanupStack::Pop(); - return self; - } -CCreatorMessageElementBase::CCreatorMessageElementBase(CCreatorEngine* aEngine) -: -CCreatorScriptElement(aEngine) - { } diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/src/creator_scriptelementfactory.cpp --- a/creator/engine/src/creator_scriptelementfactory.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,121 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - -#include "creator_traces.h" -#include "creator_scriptelementfactory.h" -#include "creator_contactelement.h" -#include "creator_calendarelement.h" -#include "creator_messageelement.h" -#include "creator_fileelement.h" -//#include "creator_browserelement.h" -#include "creator_logelement.h" -//#include "creator_noteelement.h" -//#include "creator_impselement.h" -#include "creator_landmarkelement.h" -#include "creator_mailboxelement.h" -//#include "creator_connectionmethodelement.h" - -CCreatorScriptElement* TCreatorScriptElementFactory::CreateElementL(CCreatorEngine* aEngine, const TDesC& aElementName, const TDesC& aContext ) - { - LOGSTRING2("TCreatorScriptElementFactory::CreateElementL: %S", &aElementName); - - if( aContext.Length() >= KFields().Length() && - aContext.Right(KFields().Length()) == KFields) - { - // This is a field element under 'fields'. - return CCreatorScriptElement::NewL(aEngine, aElementName, aContext); - } - else if( aElementName == creatorcontact::KContact ) - { - return CCreatorContactElement::NewL(aEngine, aElementName, aContext); - } - else if( aElementName == creatorcontact::KContactSet) - { - return CCreatorContactSetElement::NewL(aEngine, aElementName, aContext); - } - else if( aElementName == creatorcontact::KContactGroup ) - { - return CCreatorContactGroupElement::NewL(aEngine, aElementName, aContext); - } - else if( aElementName == KFields) - { - return CCreatorScriptElement::NewL(aEngine, aElementName, aContext); - } - else if( aElementName == KScript ) - { - return CCreatorScriptRoot::NewL(aEngine, aElementName, aContext); - } - else if( aElementName == creatorcalendar::KCalendar ) - { - return CCreatorCalendarElement::NewL(aEngine, aElementName, aContext); - } - else if( aElementName == creatormsg::KMessage ) - { - return CCreatorMessageElement::NewL(aEngine, aElementName, aContext); - } - else if( aElementName == creatorfile::KFile ) - { - return CCreatorFileElement::NewL(aEngine, aElementName, aContext); - } - /* - else if( aElementName == creatorbrowser::KBookmark || - aElementName == creatorbrowser::KBookmarkFolder || - aElementName == creatorbrowser::KSavedPage || - aElementName == creatorbrowser::KSavedPageFolder ) - { - return CCreatorBrowserElement::NewL(aEngine, aElementName, aContext); - } - */ - else if( aElementName == creatorlog::KLog ) - { - return CCreatorLogElement::NewL(aEngine, aElementName, aContext); - } -/* - else if( aElementName == creatornote::KNote ) - { - return CCreatorNoteElement::NewL(aEngine, aElementName, aContext); - } -*/ -/* - #ifdef __PRESENCE - else if( aElementName == creatorimps::KImpsServer ) - { - return CCreatorImpsServerElement::NewL(aEngine, aElementName, aContext); - } - #endif // __PRESENCE -*/ - else if( aElementName == creatorlandmark::KLandmark ) - { - return CCreatorLandmarkElement::NewL(aEngine, aElementName, aContext); - } - else if( aElementName == creatormailbox::Kmailbox ) - { - return CCreatorMailboxElement::NewL(aEngine, aElementName, aContext); - } -/* - else if( aElementName == creatorconnectionmethod::KCm ) - { - return CCreatorConnectionMethodElement::NewL(aEngine, aElementName, aContext); - } -*/ - else - { - return CCreatorScriptElement::NewL(aEngine, aElementName, aContext); - } - } diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/src/creator_scriptentry.cpp --- a/creator/engine/src/creator_scriptentry.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,682 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - -#include -#include -#include - -#include "engine.h" -#include "enginewrapper.h" -#include "creator_traces.h" -#include "creator_factory.h" -#include "creator_scriptentry.h" - - - -const TInt KReadBufSize = 8192; - -// Creator random data file filter -_LIT(KRandomDataFileFilter, "*.creatordataxml"); - -// --------------------------------------------------------------------------- - - -CCommandParser* CCommandParser::NewL(CCreatorEngine* aEngine) - { - CCommandParser* self = CCommandParser::NewLC(aEngine); - CleanupStack::Pop(self); - return self; - } - -CCommandParser* CCommandParser::NewLC(CCreatorEngine* aEngine) - { - CCommandParser* self = new (ELeave) CCommandParser; - CleanupStack::PushL(self); - self->ConstructL(aEngine); - return self; - } - -CCommandParser::CCommandParser() - { - } - -void CCommandParser::ConstructL(CCreatorEngine* aEngine) - { - LOGSTRING("Creator: CCommandParser::ConstructL"); - - iEngine = aEngine; - - iReadBuf = HBufC8::NewL(KReadBufSize); - } - -CCommandParser::~CCommandParser() - { - LOGSTRING("Creator: CCommandParser::~CCommandParser"); - - if (iSearchArray){ - delete iSearchArray; - iSearchArray = NULL; - } - - if (iReadBuf) - delete iReadBuf; - } - -// --------------------------------------------------------------------------- - -void CCommandParser::QueryDialogClosedL(TBool aPositiveAction, TInt aUserData) - { - User::LeaveIfNull(iSearchArray); - - if( aUserData == EGetingScript ) - { - if(aPositiveAction) - { - iObserver->ScriptChosenL( ETrue, iSearchArray->MdcaPoint(iSelectedItem) ); - } - else - { - iObserver->ScriptChosenL( EFalse ); - } - } - else if( aUserData == EGetingRandomDataFile && iSearchArray->Count() ) - { - if(aPositiveAction) - { - TFileName fileName; - if (iSelectedItem == (iSearchArray->Count() - 1)) - { - // "default" (resource file) selected - fileName.Copy(KNullDesC); - } - else - { - // xml file selected - fileName.Copy(iSearchArray->MdcaPoint(iSelectedItem)); - } - iObserver->RandomDataFileChosenL( ETrue, fileName ); - } - else - { - iObserver->RandomDataFileChosenL( EFalse ); - } - } - } - -// --------------------------------------------------------------------------- -//#if(!defined __SERIES60_30__ && !defined __SERIES60_31__) -void CCommandParser::OpenScriptL() {} -TBool CCommandParser::OpenScriptL(MCommandParserObserver* aObserver) - { - LOGSTRING("Creator: CCommandParser::OpenScriptL"); - - User::LeaveIfNull( aObserver ); - iObserver = aObserver; - iSelectedItem = 0; - - TBool ret = EFalse; - - // init the search array - delete iSearchArray; - iSearchArray = NULL; - iSearchArray = new(ELeave) CDesCArrayFlat(20); - - // wait dialog - // TODO - //CAknGlobalNote* waitDialog = CAknGlobalNote::NewLC(); - //waitDialog->SetSoftkeys(R_AVKON_SOFTKEYS_CANCEL); - //TInt dialogId = waitDialog->ShowNoteL(EAknGlobalWaitNote, _L("Searching")); - - - // search all the .creator files from the phone - TInt err; - TRAP(err, FindFiles(_L("*.creatorxml"), _L("\\"))); - - TRAP(err, FindFiles(_L("*.creatorxml"), _L("\\system\\apps\\Creator\\"))); - - TRAP(err, FindFiles(_L("*.creatorxml"), _L("\\data\\"))); - TRAP(err, FindFilesRecursiveL(_L("*.creatorxml"), _L("\\data\\"))); - - TRAP(err, FindFiles(_L("*.creatorxml"), _L("\\documents\\"))); - TRAP(err, FindFilesRecursiveL(_L("*.creatorxml"), _L("\\documents\\"))); - - TRAP(err, FindFiles(_L("*.creatorxml"), _L("\\creator\\"))); - TRAP(err, FindFilesRecursiveL(_L("*.creatorxml"), _L("\\creator\\"))); - - TRAP(err, FindFiles(_L("*.creatorxml"), _L("\\scripts\\"))); - TRAP(err, FindFilesRecursiveL(_L("*.creatorxml"), _L("\\scripts\\"))); - - TRAP(err, FindFiles(_L("*.creatorxml"), _L("\\temp\\"))); - TRAP(err, FindFilesRecursiveL(_L("*.creatorxml"), _L("\\temp\\"))); - - TRAP(err, FindFiles(_L("*.creatorxml"), _L("\\system\\temp\\"))); - TRAP(err, FindFilesRecursiveL(_L("*.creatorxml"), _L("\\system\\temp\\"))); - - TRAP(err, FindFiles(_L("*.creatorxml"), _L("\\private\\20011383\\"))); - TRAP(err, FindFilesRecursiveL(_L("*.creatorxml"), _L("\\private\\20011383\\"))); - - TRAP(err, FindFilesRecursiveL(_L("*.creatorxml"), _L("\\private\\1000484b\\"))); - - - // remove the wait dialog - // TODO - //waitDialog->CancelNoteL(dialogId); - //CleanupStack::PopAndDestroy(); //waitDialog; - - - if ( iSearchArray->MdcaCount() > 0) - { - // create a file name array based on the iSearchArray - CDesCArray* fileNameArray = new(ELeave) CDesCArrayFlat(iSearchArray->MdcaCount()); - CleanupStack::PushL(fileNameArray); - - for (TInt i=0; iMdcaCount(); i++) - { - - TParse filename; // file name parser - filename.Set(iSearchArray->MdcaPoint(i), NULL, NULL); - - if ( filename.Drive()[0] == 'e' || filename.Drive()[0] == 'E') // MMC - { - TFileName nameMMC; - nameMMC.Append(filename.Name()); - nameMMC.Append(_L("\t0")); // MMC icon - fileNameArray->AppendL(nameMMC); - } - else - { - fileNameArray->AppendL(filename.Name()); - } - } - - ret = iEngine->GetEngineWrapper()->PopupListDialog(_L("Select script"), fileNameArray, &iSelectedItem, this, EGetingScript); - CleanupStack::PopAndDestroy(fileNameArray); - } - else // no scripts found from the search paths - { - iEngine->GetEngineWrapper()->ShowNote(_L("No scripts found")); - delete iSearchArray; - iSearchArray = NULL; - } - - - return ret; - } -/* -#else -// --------------------------------------------------------------------------- -void CCommandParser::OpenScriptL() - { - LOGSTRING("Creator: CCommandParser::OpenScriptL"); - - // init the search array - iSearchArray = new(ELeave) CDesCArrayFlat(500); - - // wait dialog - CAknGlobalNote* waitDialog = CAknGlobalNote::NewLC(); - waitDialog->SetSoftkeys(R_AVKON_SOFTKEYS_CANCEL); - TInt dialogId = waitDialog->ShowNoteL(EAknGlobalWaitNote, _L("Searching")); - - - // search all the .creator files from the phone - TInt err; - TRAP(err, FindFiles(_L("*.creator"), _L("\\"))); - - TRAP(err, FindFiles(_L("*.creator"), _L("\\system\\apps\\Creator\\"))); - - TRAP(err, FindFiles(_L("*.creator"), _L("\\data\\"))); - TRAP(err, FindFilesRecursiveL(_L("*.creator"), _L("\\data\\"))); - - TRAP(err, FindFiles(_L("*.creator"), _L("\\documents\\"))); - TRAP(err, FindFilesRecursiveL(_L("*.creator"), _L("\\documents\\"))); - - TRAP(err, FindFiles(_L("*.creator"), _L("\\creator\\"))); - TRAP(err, FindFilesRecursiveL(_L("*.creator"), _L("\\creator\\"))); - - TRAP(err, FindFiles(_L("*.creator"), _L("\\scripts\\"))); - TRAP(err, FindFilesRecursiveL(_L("*.creator"), _L("\\scripts\\"))); - - TRAP(err, FindFiles(_L("*.creator"), _L("\\temp\\"))); - TRAP(err, FindFilesRecursiveL(_L("*.creator"), _L("\\temp\\"))); - - TRAP(err, FindFiles(_L("*.creator"), _L("\\system\\temp\\"))); - TRAP(err, FindFilesRecursiveL(_L("*.creator"), _L("\\system\\temp\\"))); - - TRAP(err, FindFiles(_L("*.creator"), _L("\\private\\101FA751\\"))); - TRAP(err, FindFilesRecursiveL(_L("*.creator"), _L("\\private\\101FA751\\"))); - - TRAP(err, FindFilesRecursiveL(_L("*.creator"), _L("\\private\\1000484b\\"))); - - - // remove the wait dialog - waitDialog->CancelNoteL(dialogId); - CleanupStack::PopAndDestroy(); //waitDialog; - - - if ( iSearchArray->MdcaCount() > 0) - { - // create a file name array based on the iSearchArray - CDesCArray* fileNameArray = new(ELeave) CDesCArrayFlat(iSearchArray->MdcaCount()); - CleanupStack::PushL(fileNameArray); - - for (TInt i=0; iMdcaCount(); i++) - { - - TParse filename; // file name parser - filename.Set(iSearchArray->MdcaPoint(i), NULL, NULL); - - if ( filename.Drive()[0] == 'e' || filename.Drive()[0] == 'E') // MMC - { - TFileName nameMMC; - nameMMC.Append(filename.Name()); - nameMMC.Append(_L("\t0")); // MMC icon - fileNameArray->AppendL(nameMMC); - } - else - { - fileNameArray->AppendL(filename.Name()); - } - } - CleanupStack::Pop(fileNameArray); - - - // create a popup list - CAknSinglePopupMenuStyleListBox* listBox = new(ELeave) CAknSinglePopupMenuStyleListBox; - CleanupStack::PushL(listBox); - CAknPopupList* popupList = CAknPopupList::NewL( listBox, R_AVKON_SOFTKEYS_SELECT_CANCEL, AknPopupLayouts::EMenuWindow ); - CleanupStack::PushL(popupList); - popupList->SetTitleL(_L("Select script")); - listBox->ConstructL( popupList, EAknListBoxSelectionList|EAknListBoxLoopScrolling ); - listBox->CreateScrollBarFrameL( ETrue ); - listBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto); - listBox->Model()->SetItemTextArray( fileNameArray ); - listBox->Model()->SetOwnershipType( ELbmOwnsItemArray ); // !!! - listBox->HandleItemAdditionL(); - - - // define MMC icon - MAknsSkinInstance* skin = AknsUtils::SkinInstance(); - _LIT( KFLDMemoryCardUiBitmapFile, "z:aknmemorycardui.mbm" ); - CAknIconArray* iconArray = new( ELeave ) CAknIconArray( 1 ); - listBox->ItemDrawer()->ColumnData()->SetIconArray( iconArray ); - - TParse* fp = new(ELeave) TParse(); - fp->Set(KFLDMemoryCardUiBitmapFile, &KDC_APP_BITMAP_DIR, NULL); - TFileName resourceFileName( fp->FullName() ); - delete fp; - - CGulIcon* icon = AknsUtils::CreateGulIconL( skin, KAknsIIDQgnIndiMmcAdd, - resourceFileName, - EMbmAknmemorycarduiQgn_indi_mmc_add, - EMbmAknmemorycarduiQgn_indi_mmc_add_mask ); - CleanupStack::PushL( icon ); - iconArray->AppendL( icon ); - CleanupStack::Pop( icon ); - - - // execute dialog - TBool result = popupList->ExecuteLD(); - CleanupStack::Pop(); // popupList - - if ( result ) - { - // open the file for reading - RFile file; - User::LeaveIfError(file.Open(CEikonEnv::Static()->FsSession(), iSearchArray->MdcaPoint(listBox->CurrentItemIndex()), EFileRead)); - while (ReadLineFromFileL(file) == KErrNone) - { - iReadBuf->Des().Trim(); // delete leading and trailing white space - - if (iReadBuf->Length() < 5) // command too short, ignoring... - { - //CEikonEnv::Static()->InfoMsg(_L("Corrupted line")); - } - - // check it's a valid line: first char is A-Z and the line ends to ';' - else if (iReadBuf->Des()[0] >= 'A' && iReadBuf->Des()[0] <= 'Z' && iReadBuf->Des()[iReadBuf->Length()-1] == ';') - { - // this line is valid -> parse the command - ParseCommandFromDescriptorL(); - } - else - { - //CEikonEnv::Static()->InfoMsg(_L("Not a valid line")); - } - - } - - file.Close(); - - // show a note if there were no valid commands in the script - if (iEngine->CommandArrayCount() == 0) - { - CAknInformationNote* note = new(ELeave) CAknInformationNote; - note->ExecuteLD(_L("No valid commands in this script")); - } - - } - - CleanupStack::PopAndDestroy(); //listBox - } - - else // no scripts found from the search paths - { - CAknInformationNote* note = new (ELeave) CAknInformationNote; - note->ExecuteLD(_L("No scripts found")); - } - - - delete iSearchArray; - iSearchArray = NULL; - - } -#endif -*/ - -TBool CCommandParser::GetRandomDataFilenameL(MCommandParserObserver *aObserver) - { - LOGSTRING("Creator: CCommandParser::GetRandomDataFilenameL"); - TBool ret = EFalse; - - User::LeaveIfNull( aObserver ); - iObserver = aObserver; - iSelectedItem = 0; - - // init the search array - if (iSearchArray) - { - delete iSearchArray; - iSearchArray = NULL; - } - iSearchArray = new(ELeave) CDesCArrayFlat(500); - - /* TODO: - // wait dialog - CAknGlobalNote* waitDialog = CAknGlobalNote::NewLC(); - waitDialog->SetSoftkeys(R_AVKON_SOFTKEYS_CANCEL); - TInt dialogId = waitDialog->ShowNoteL(EAknGlobalWaitNote, _L("Searching")); - */ - - - // search all the creator random data files from the phone - TInt err; - TRAP(err, FindFiles(KRandomDataFileFilter, _L("\\"))); - - TRAP(err, FindFiles(KRandomDataFileFilter, _L("\\system\\apps\\Creator\\"))); - - TRAP(err, FindFiles(KRandomDataFileFilter, _L("\\data\\"))); - TRAP(err, FindFilesRecursiveL(KRandomDataFileFilter, _L("\\data\\"))); - - TRAP(err, FindFiles(KRandomDataFileFilter, _L("\\documents\\"))); - TRAP(err, FindFilesRecursiveL(KRandomDataFileFilter, _L("\\documents\\"))); - - TRAP(err, FindFiles(KRandomDataFileFilter, _L("\\creator\\"))); - TRAP(err, FindFilesRecursiveL(KRandomDataFileFilter, _L("\\creator\\"))); - - TRAP(err, FindFiles(KRandomDataFileFilter, _L("\\scripts\\"))); - TRAP(err, FindFilesRecursiveL(KRandomDataFileFilter, _L("\\scripts\\"))); - - TRAP(err, FindFiles(KRandomDataFileFilter, _L("\\temp\\"))); - TRAP(err, FindFilesRecursiveL(KRandomDataFileFilter, _L("\\temp\\"))); - - TRAP(err, FindFiles(KRandomDataFileFilter, _L("\\system\\temp\\"))); - TRAP(err, FindFilesRecursiveL(KRandomDataFileFilter, _L("\\system\\temp\\"))); - - TRAP(err, FindFiles(KRandomDataFileFilter, _L("\\private\\20011383\\"))); - TRAP(err, FindFilesRecursiveL(KRandomDataFileFilter, _L("\\private\\20011383\\"))); - - TRAP(err, FindFilesRecursiveL(KRandomDataFileFilter, _L("\\private\\1000484b\\"))); - - - // remove the wait dialog - // TODO - //waitDialog->CancelNoteL(dialogId); - //CleanupStack::PopAndDestroy(); //waitDialog; - - - if (iSearchArray->MdcaCount() > 0) - { - // create a file name array based on the iSearchArray - CDesCArray* fileNameArray = new(ELeave) CDesCArrayFlat(iSearchArray->MdcaCount() + 1); - CleanupStack::PushL(fileNameArray); - - for (TInt i=0; iMdcaCount(); i++) - { - - TParse filename; // file name parser - filename.Set(iSearchArray->MdcaPoint(i), NULL, NULL); - - if ( filename.Drive()[0] == 'e' || filename.Drive()[0] == 'E') // MMC - { - TFileName nameMMC; - nameMMC.Append(filename.Name()); - nameMMC.Append(_L("\t0")); // MMC icon - fileNameArray->AppendL(nameMMC); - } - else - { - fileNameArray->AppendL(filename.Name()); - } - } - - // add "default" (resource file) to list - fileNameArray->AppendL(_L("Default")); - - ret = iEngine->GetEngineWrapper()->PopupListDialog(_L("Select random data file"), fileNameArray, &iSelectedItem, this, EGetingRandomDataFile); - CleanupStack::PopAndDestroy(fileNameArray); - } - else // no random data files found from the search paths - { - iEngine->GetEngineWrapper()->ShowNote(_L("No random data files found")); - delete iSearchArray; - iSearchArray = NULL; - } - - return ret; - } - -TInt CCommandParser::FindFilesRecursiveL(const TDesC& aFileName, const TDesC& aPath) - { - return CreatorFileUtils::FindFilesRecursiveL(iSearchArray, aFileName, aPath); - } -TInt CreatorFileUtils::FindFilesRecursiveL(CDesCArrayFlat* aFileArray, const TDesC& aFileName, const TDesC& aPath) - { - TInt err = KErrNone; - CDirScan* scan = CDirScan::NewLC(CEikonEnv::Static()->FsSession()); - scan->SetScanDataL(aPath, KEntryAttDir, ESortNone); - CDir* dirEntries = NULL; - - for(;;) - { - TRAP(err, scan->NextL(dirEntries)); - if (!dirEntries || (err!=KErrNone)) - break; - - for (TInt i=0; iCount(); i++) - { - TFileName path(scan->FullPath()); - path.Append((*dirEntries)[i].iName); - path.Append(_L("\\")); - FindFiles(aFileArray, aFileName, path); - } - delete(dirEntries); - } - - CleanupStack::PopAndDestroy(scan); - return err; - } - -TInt CreatorFileUtils::FindFiles(CDesCArrayFlat* aFileArray, const TDesC& aFileName, const TDesC& aPath) - { - TFindFile fileFinder(CEikonEnv::Static()->FsSession()); - CDir* fileList; - TInt err = fileFinder.FindWildByDir(aFileName, aPath, fileList); - - while (err == KErrNone) - { - for (TInt i=0; iCount(); i++) - { - TParse fullentry; - fullentry.Set((*fileList)[i].iName, &fileFinder.File(), NULL); - - TRAP(err, aFileArray->AppendL(fullentry.FullName())); - } - - delete fileList; - err = fileFinder.FindWild(fileList); - } - return err; - } -// --------------------------------------------------------------------------- - -TInt CCommandParser::FindFiles(const TDesC& aFileName, const TDesC& aPath) - { - return CreatorFileUtils::FindFiles(iSearchArray, aFileName, aPath); - } - -// --------------------------------------------------------------------------- - -TInt CCommandParser::ReadLineFromFileL(RFile& aInputFile) - { - LOGSTRING("Creator: CCommandParser::ReadLineFromFile"); - - _LIT8(KImcvCRLF, "\r\n"); - - TInt err = KErrNone; - - // Read into the buffer - HBufC8* tempLine = HBufC8::NewLC(KReadBufSize); - TPtr8 buffer = tempLine->Des(); - - // clear the targer - iReadBuf->Des().Copy(_L("")); - - // Get the current file position - TInt filePos = 0; - aInputFile.Seek(ESeekCurrent, filePos); - - // Read the buffer - err = aInputFile.Read(buffer); - - //end of file? - TInt s = buffer.Length(); - if ( s == 0) - err = KErrEof; - - if (err == KErrNone) - { - // Copy to the lfcr and then set the file pointer to the point after that - TInt pos = buffer.Find(KImcvCRLF); - if ( pos != -1) - { - iReadBuf->Des().Justify(buffer, pos, ELeft, ' '); - filePos += (pos+2); - - // Set the file pointer back to after the lfcr - aInputFile.Seek(ESeekStart, filePos); - } - // Else fill the whole buffer - else - { - iReadBuf->Des().Copy(buffer); - } - } - - CleanupStack::PopAndDestroy(); // tempLine - return err; - } - -// --------------------------------------------------------------------------- - -void CCommandParser::StrParserL(HBufC*& aDestinationBuf, TUint aToken) - { - // store old position - iParserOldPosition = iParserPosition; - - // make sure we are not reading outside of buffer - if (iParserPosition >= iReadBuf->Length() - 1) - return; - - // read until asked token - do - { - iParserPosition++; - } - while (iReadBuf->Des()[iParserPosition] != aToken && iParserPosition < iReadBuf->Des().Length()-1); - - // calculate length of the destination buffer - TInt bufferLength = iParserPosition-iParserOldPosition-1; - - // reset the destination buffer - if (aDestinationBuf) - { - delete aDestinationBuf; - aDestinationBuf = NULL; - } - - // allocate memory for the destination buffer - aDestinationBuf = HBufC::NewL(bufferLength); - - // copy data from the read buffer to the destination buffer - aDestinationBuf->Des().Copy(iReadBuf->Des().Mid(iParserOldPosition+1, bufferLength)); - } - -// --------------------------------------------------------------------------- - -void CCommandParser::StrParserL(HBufC8*& aDestinationBuf, TUint aToken) - { - // store old position - iParserOldPosition = iParserPosition; - - // make sure we are not reading outside of buffer - if (iParserPosition >= iReadBuf->Length() - 1) - return; - - // read until asked token - do - { - iParserPosition++; - } - while (iReadBuf->Des()[iParserPosition] != aToken && iParserPosition < iReadBuf->Des().Length()-1); - - // calculate length of the destination buffer - TInt bufferLength = iParserPosition-iParserOldPosition-1; - - // reset the destination buffer - if (aDestinationBuf) - { - delete aDestinationBuf; - aDestinationBuf = NULL; - } - - // allocate memory for the destination buffer - aDestinationBuf = HBufC8::NewL(bufferLength); - - // copy data from the read buffer to the destination buffer - aDestinationBuf->Des().Copy(iReadBuf->Des().Mid(iParserOldPosition+1, bufferLength)); - } - -//---------------------------------------------------------------------------- - -void CCommandParser::HandleSessionEventL(TMsvSessionEvent /*aEvent*/, TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/) // from MMsvSessionObserver - { - } - -//---------------------------------------------------------------------------- - diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/src/creator_scriptparser.cpp --- a/creator/engine/src/creator_scriptparser.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,394 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - -#include -#include -#include -#include "creator_scriptparser.h" -#include "creator_scriptelementfactory.h" -#include "creator_traces.h" - -using namespace Xml; - -CCreatorScriptParser::CCreatorScriptParser() -: iDefaultElement(TCreatorScriptElementInfo(TCreatorScriptElementInfo::EStatusUndefined, 0)) - { - } -void CCreatorScriptParser::ConstructL(CCreatorEngine* aEngine) - { - LOGSTRING("Creator: CCreatorScriptParser::ConstructL"); - iEngine = aEngine; - } - -CCreatorScriptParser* CCreatorScriptParser::NewL(CCreatorEngine* aEngine) - { - LOGSTRING("Creator: CCreatorScriptParser::NewL"); - CCreatorScriptParser* self = CCreatorScriptParser::NewLC(aEngine); - CleanupStack::Pop(); - return self; - } -CCreatorScriptParser* CCreatorScriptParser::NewLC(CCreatorEngine* aEngine) - { - LOGSTRING("Creator: CCreatorScriptParser::NewLC"); - CCreatorScriptParser* self = new (ELeave) CCreatorScriptParser; - CleanupStack::PushL(self); - self->ConstructL(aEngine); - return self; - } - -CCreatorScriptParser::~CCreatorScriptParser() - { - delete iParser; - if( iElementStack.Count() > 0 ) - { - delete iElementStack[0].iElement; - } - iElementStack.Reset(); - iElementStack.Close(); - } - -void CCreatorScriptParser::GetTextFileMode(RFile& aFile, TInt& aFileSize) - { - LOGSTRING("Creator: CCreatorScriptParser::GetTextFileMode"); - iScriptTextFormat = EFormatANSIASCII; - - // if we are working with text files, check the type first - TBuf8<4> BOM; - - // first check for UTF-16 - if (aFileSize >= 2 && aFile.Read(0, BOM, 2) == KErrNone) - { - if (BOM.Length()==2 && BOM[0]==0xFF && BOM[1]==0xFE) - { - iScriptTextFormat = EFormatUTF16LE; - aFileSize -= 2; - return; - } - else if (BOM.Length()==2 && BOM[0]==0xFE && BOM[1]==0xFF) - { - iScriptTextFormat = EFormatUTF16BE; - aFileSize -= 2; - return; - } - } - // then check for UTF-8 - if (aFileSize >= 3 && aFile.Read(0, BOM, 3) == KErrNone) - { - if (BOM.Length()==3 && BOM[0]==0xEF && BOM[1]==0xBB && BOM[2]==0xBF) - { - iScriptTextFormat = EFormatUTF8; - aFileSize -= 3; - return; - } - } - - // none of those, seek back to beginning - TInt pos(0); - aFile.Seek(ESeekStart, pos); - } - - - -void CCreatorScriptParser::ParseL(const TDesC& aFileName) - { - LOGSTRING2("Creator: CCreatorScriptParser::ParseL: %S", &aFileName); - // Create and start XML-parser - if( iParser == 0) - { - _LIT8(KXmlMimeType, "text/xml"); - iParser = CParser::NewL(KXmlMimeType, *this); - } - - RFs filesession; - CleanupClosePushL(filesession); - User::LeaveIfError( filesession.Connect() ); - Xml::ParseL(*iParser, filesession, aFileName); - - CleanupStack::PopAndDestroy(&filesession); // filesession - } - -void CCreatorScriptParser::ParseL(RFile& aFile) - { - LOGSTRING("Creator: CCreatorScriptParser::ParseL"); - TInt filesize = 0; - aFile.Size(filesize); - GetTextFileMode(aFile, filesize); - // Create and start XML-parser - if( iParser == 0) - { - _LIT8(KXmlMimeType, "text/xml"); - iParser = CParser::NewL(KXmlMimeType, *this); - } - Xml::ParseL(*iParser, aFile); - } - -void CCreatorScriptParser::OnStartDocumentL(const Xml::RDocumentParameters& aDocParam, TInt aErrorCode) - { - LOGSTRING2("Creator: CCreatorScriptParser::OnStartDocumentL (Error code: %d)", aErrorCode); - User::LeaveIfError(aErrorCode); - } - -void CCreatorScriptParser::OnEndDocumentL(TInt aErrorCode) - { - LOGSTRING2("Creator: CCreatorScriptParser::OnEndDocumentL (Error code: %d)", aErrorCode); - User::LeaveIfError(aErrorCode); - iEngine->SortCommands(); - } - -void CCreatorScriptParser::OnStartPrefixMappingL( const RString& /*aPrefix*/, - const RString& /*aUri*/, - TInt aErrorCode) - { - LOGSTRING2("Creator: CCreatorScriptParser::OnStartPrefixMappingL (Error code: %d)", aErrorCode); - User::LeaveIfError(aErrorCode); - } - -void CCreatorScriptParser::OnEndPrefixMappingL(const RString& /*aPrefix*/, TInt aErrorCode) - { - LOGSTRING2("Creator: CCreatorScriptParser::OnEndPrefixMappingL (Error code: %d)", aErrorCode); - User::LeaveIfError(aErrorCode); - } -void CCreatorScriptParser::OnIgnorableWhiteSpaceL(const TDesC8& /*aBytes*/, TInt aErrorCode) - { - LOGSTRING2("Creator: CCreatorScriptParser::OnIgnorableWhiteSpaceL (Error code: %d)", aErrorCode); - User::LeaveIfError(aErrorCode); - } -void CCreatorScriptParser::OnSkippedEntityL(const RString& /*aName*/, TInt aErrorCode) - { - LOGSTRING2("Creator: CCreatorScriptParser::OnSkippedEntityL (Error code: %d)", aErrorCode); - User::LeaveIfError(aErrorCode); - } -void CCreatorScriptParser::OnProcessingInstructionL( const TDesC8& /*aTarget*/, - const TDesC8& /*aData*/, - TInt aErrorCode) - { - LOGSTRING2("Creator: CCreatorScriptParser::OnProcessingInstructionL (Error code: %d)", aErrorCode); - User::LeaveIfError(aErrorCode); - } -void CCreatorScriptParser::OnError(TInt aErrorCode) - { - LOGSTRING2("Creator: CCreatorScriptParser::OnError: %d", aErrorCode); - - iLastError = aErrorCode; - - // Delete all elements from the stack: - while(iElementStack.Count() > 0 ) - { - TCreatorScriptElementInfo previousElem = LastElementInfo(); - delete previousElem.iElement; - previousElem.iElement = 0; - iElementStack.Remove(iElementStack.Count()-1); - } - } -TAny* CCreatorScriptParser::GetExtendedInterface(const TInt32 aUid) - { - LOGSTRING2("Creator: CCreatorScriptParser::GetExtendedInterface (UID: %d)", aUid); - return this; - } - -const TCreatorScriptElementInfo& CCreatorScriptParser::LastElementInfo() const -{ - LOGSTRING("Creator: CCreatorScriptParser::LastElementInfo"); - if(iElementStack.Count() > 0) - { - return iElementStack[iElementStack.Count()-1]; - } - return iDefaultElement; -} - -/** - * Create an element and add attributes to it. - */ -void CCreatorScriptParser::OnStartElementL( const RTagInfo& aElement, - const RAttributeArray& aAttributes, - TInt aErrorCode) - { - LOGSTRING2("Creator: CCreatorScriptParser::OnStartElementL (Error code: %d)", aErrorCode); - User::LeaveIfError(aErrorCode); - const TDesC8& elementName8 = aElement.LocalName().DesC(); - HBufC* elementName16 = Convert8BitTo16BitLC(elementName8); - - const TCreatorScriptElementInfo& context = LastElementInfo(); - - CCreatorScriptElement* element = 0; - if( context.iElement ) - { - HBufC* fullContext = HBufC::NewL( - context.iElement->Context().Length() + - context.iElement->Name().Length() + - 2); - CleanupStack::PushL(fullContext); - if(context.iElement->Context() != KNullDesC && - context.iElement->Context().Length() > 0 ) - { - fullContext->Des().Copy(context.iElement->Context()); - _LIT(KContextSeparator, "::"); - fullContext->Des().Append(TPtrC(KContextSeparator)); - } - const TDesC& parentName = context.iElement->Name(); - if(parentName.Length() > 0 ) - { - fullContext->Des().Append(parentName); - } - element = TCreatorScriptElementFactory::CreateElementL( iEngine, - elementName16->Des(), - fullContext->Des()); - CleanupStack::PopAndDestroy(fullContext); // fullContext - } - else - { - element = TCreatorScriptElementFactory::CreateElementL(iEngine, elementName16->Des()); - } - - CleanupStack::PopAndDestroy(elementName16); - CleanupStack::PushL(element); - - if( element == 0 ) - { - // Add NULL pointer to stack. Otherwise the stack would go out of sync. in ::OnEndElement(). - TCreatorScriptElementInfo info(TCreatorScriptElementInfo::EStatusParsing, element); - iElementStack.AppendL(info); - CleanupStack::Pop(element); - return; - } - - // Add attributes to the element: - TInt attrCount = aAttributes.Count(); - for(TInt i = 0; i < attrCount; ++i) - { - const RAttribute& attribute = aAttributes[i]; - const RTagInfo& nameInfo = attribute.Attribute(); - const TDesC8& attrName8 = nameInfo.LocalName().DesC(); - const TDesC8& value8 = attribute.Value().DesC(); - // Convert data to 16 bit: - HBufC* attrName16 = Convert8BitTo16BitLC(attrName8); - HBufC* value16 = Convert8BitTo16BitLC(value8); - CCreatorScriptAttribute* scriptAttr = CCreatorScriptAttribute::NewLC(attrName16->Des(), value16->Des()); - element->AddAttributeL(scriptAttr); - CleanupStack::Pop(scriptAttr); - CleanupStack::PopAndDestroy(value16); - CleanupStack::PopAndDestroy(attrName16); - } - - // Save element to the stack: - TCreatorScriptElementInfo info(TCreatorScriptElementInfo::EStatusParsing, element); - iElementStack.AppendL(info); - CleanupStack::Pop(element); - } - -/** - * Executes the command if needed. Also caches the element for future use, if needed. - */ -void CCreatorScriptParser::OnEndElementL(const RTagInfo& /*aElement*/, TInt aErrorCode) - { - LOGSTRING2("Creator: CCreatorScriptParser::OnEndElementL (Error code: %d)", aErrorCode); - User::LeaveIfError(aErrorCode); - - if( iElementStack.Count() == 0 ) - { - return; - } - // Get element from the stack: - TCreatorScriptElementInfo elementInfo = LastElementInfo(); - - if( elementInfo.iElement == 0 ) - { - // Remove element from the stack: - iElementStack.Remove(iElementStack.Count()-1); - return; - } - - // Execute the command if this is a command element: - if( elementInfo.iElement->IsCommandElement() ) - { - elementInfo.iElement->ExecuteCommandL(); - } - - // Remove element from the stack: - iElementStack.Remove(iElementStack.Count()-1); - - // Get the previous element from the stack: - if( iElementStack.Count() > 0 ) - { - TCreatorScriptElementInfo previousElem = LastElementInfo(); - - if( previousElem.iElement->IsRoot() ) - { - // This element is not a sub-element (except of the root element, of course). - if( elementInfo.iElement->IsCacheNeeded() ) - { - // Add element to the cache, since it will be needed in future. - elementInfo.iElement->AddToCacheL(); - } - //else - // { - // Not needed anymore, so element can be deleted: - delete elementInfo.iElement; - elementInfo.iElement = 0; - // } - } - else - { - // There is a parent element (other than root), so we add this element - // as a sub-element fot it. - previousElem.iElement->AddSubElementL(elementInfo.iElement); - } - } - else - { - // Delete root element, which will delete recursively all sub-elements: - delete elementInfo.iElement; - elementInfo.iElement = 0; - } - } - -/** - * Add content to element. - */ -void CCreatorScriptParser::OnContentL(const TDesC8& aBytes, TInt aErrorCode) - { - LOGSTRING2("Creator: CCreatorScriptParser::OnContentL (Error code: %d)", aErrorCode); - User::LeaveIfError(aErrorCode); - if( iElementStack.Count() > 0 ) - { - HBufC* contentData = Convert8BitTo16BitLC(aBytes); - TCreatorScriptElementInfo elementInfo = iElementStack[iElementStack.Count()-1]; - if( elementInfo.iElement ) - { - elementInfo.iElement->AppendContentL(*contentData); - } - CleanupStack::PopAndDestroy(contentData); - } - } - -HBufC16* CCreatorScriptParser::Convert8BitTo16BitLC(const TDesC8& aInput) - { - LOGSTRING("Creator: CCreatorScriptParser::Convert8BitTo16BitLC"); - HBufC16* output = NULL; - - output = CnvUtfConverter::ConvertToUnicodeFromUtf8L(aInput); - - CleanupStack::PushL(output); - return output; - } - -TInt CCreatorScriptParser::GetError() const -{ - return iLastError; -} diff -r 819e59dfc032 -r 2d9cac8919d3 creator/engine/src/creator_wepsecuritysettings.cpp --- a/creator/engine/src/creator_wepsecuritysettings.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,145 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - -#include "creator_traces.h" -#include "creator_wepsecuritysettings.h" -#include -//#include -#include - -//#include -//#include -//#include - - - -//---------------------------------------------------------------------------- - -CCreatorWEPSecuritySettings* CCreatorWEPSecuritySettings::NewL() - { - CCreatorWEPSecuritySettings* self = CCreatorWEPSecuritySettings::NewLC(); - CleanupStack::Pop(self); - return self; - } - -CCreatorWEPSecuritySettings* CCreatorWEPSecuritySettings::NewLC() - { - CCreatorWEPSecuritySettings* self = new (ELeave) CCreatorWEPSecuritySettings; - CleanupStack::PushL(self); - self->ConstructL(); - return self; - } - -CCreatorWEPSecuritySettings::CCreatorWEPSecuritySettings() - { - } - -void CCreatorWEPSecuritySettings::ConstructL() - { - LOGSTRING("Creator: CCreatorWEPSecuritySettings::ConstructL"); - } - -CCreatorWEPSecuritySettings::~CCreatorWEPSecuritySettings() - { - LOGSTRING("Creator: CCreatorWEPSecuritySettings::~CCreatorWEPSecuritySettings"); - - - } - - - -//---------------------------------------------------------------------------- - - - -// --------------------------------------------------------- -// CWEPSecuritySettingsImpl::SaveL -// --------------------------------------------------------- -// -void CCreatorWEPSecuritySettings::SaveL( TUint32 /*aIapId*/, - CCommsDatabase& /*aCommsDb*/ ) const - { - /* - // Data of the key - TBuf8 iKeyData[KMaxNumberofKeys]; - - CCommsDbTableView* wLanServiceTable; - - // Caller MUST initiate a transaction, WE WILL NOT. - - wLanServiceTable = aCommsDb.OpenViewMatchingUintLC( - TPtrC( WLAN_SERVICE ), TPtrC( WLAN_SERVICE_ID ), aIapId ); - TInt errorCode = wLanServiceTable->GotoFirstRecord(); - - if ( errorCode == KErrNone ) - { - wLanServiceTable->UpdateRecord(); - } - else - { - TUint32 dummyUid( 0 ); //was KUidNone - User::LeaveIfError( wLanServiceTable->InsertRecord( dummyUid ) ); - - // Save link to LAN service - wLanServiceTable->WriteUintL( TPtrC( WLAN_SERVICE_ID ), aIapId ); - } - - // Save index of key in use - wLanServiceTable->WriteUintL( TPtrC( WLAN_WEP_INDEX ), - ( TUint32& ) iKeyInUse ); - - // Save index of key in use - wLanServiceTable->WriteUintL( TPtrC( NU_WLAN_AUTHENTICATION_MODE ), - ( TUint32& ) iAuthentication ); - - // Save first WEP key - wLanServiceTable->WriteTextL( TPtrC( NU_WLAN_WEP_KEY1 ), - iKeyData[KFirstKey] ); - - // Save second WEP key - wLanServiceTable->WriteTextL( TPtrC( NU_WLAN_WEP_KEY2 ), - iKeyData[KSecondKey] ); - - // Save third WEP key - wLanServiceTable->WriteTextL( TPtrC( NU_WLAN_WEP_KEY3 ), - iKeyData[KThirdKey] ); - - // Save fourth WEP key - wLanServiceTable->WriteTextL( TPtrC( NU_WLAN_WEP_KEY4 ), - iKeyData[KFourthKey] ); - - // Save the format of the keys - wLanServiceTable->WriteUintL( TPtrC( WLAN_WEP_KEY1_FORMAT ), - ( TUint32& ) iKeyFormat[KFirstKey] ); - - wLanServiceTable->WriteUintL( TPtrC( WLAN_WEP_KEY2_FORMAT ), - ( TUint32& ) iKeyFormat[KSecondKey] ); - - wLanServiceTable->WriteUintL( TPtrC( WLAN_WEP_KEY3_FORMAT ), - ( TUint32& ) iKeyFormat[KThirdKey] ); - - wLanServiceTable->WriteUintL( TPtrC( WLAN_WEP_KEY4_FORMAT ), - ( TUint32& ) iKeyFormat[KFourthKey] ); - - wLanServiceTable->PutRecordChanges(); - - CleanupStack::PopAndDestroy( wLanServiceTable ); // wLanServiceTable - */ - } - diff -r 819e59dfc032 -r 2d9cac8919d3 creator/files/3GPP-70kB.dat Binary file creator/files/3GPP-70kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 creator/files/AAC-100kB.dat Binary file creator/files/AAC-100kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 creator/files/AMR-20kB.dat Binary file creator/files/AMR-20kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 creator/files/BMP-25kB.dat Binary file creator/files/BMP-25kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 creator/files/DOC-20kB.dat Binary file creator/files/DOC-20kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 creator/files/Deck-1kB.dat Binary file creator/files/Deck-1kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 creator/files/GIF-2kB.dat Binary file creator/files/GIF-2kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 creator/files/HTML-20kB.dat --- a/creator/files/HTML-20kB.dat Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,378 +0,0 @@ - -
-My HTML page -
- -

My HTML page

- -
  • item 1
  • -
  • item 2
  • -
  • item 3
  • -
  • item 4
  • - -

    - COPYRIGHT LICENSE -

    - - NOKIA CORPORATION END-USER SOFTWARE AGREEMENT FOR - CARBIDE.C++ AND ASSOCIATED ON-DEVICE APPLICATIONS - -

    - -This Software Agreement ("Agreement") is between You (either an -individual or an entity), the End User, and Nokia Corporation -("Nokia"). The Agreement authorizes You to use the Software specified -in Clause 1 below, which may be stored on a CD-ROM, sent to You by -electronic mail, or downloaded from Nokia's Web pages or Servers or -from other sources under the terms and conditions set forth below. -This is an agreement on end-user rights and not an agreement for sale. -Nokia continues to own the copy of the Software and the physical media -contained in the sales package and any other copy that You are -authorized to make pursuant to this Agreement. - -Read this Agreement carefully before installing, downloading, or using -the Software. By clicking on the "I Accept" button while installing, -downloading, and/or using the Software, You agree to the terms and -conditions of this Agreement. If You do not agree to all of the terms -and conditions of this Agreement, promptly click the "Decline" or -"I Do Not Accept" button, cancel the installation or downloading, or -destroy or return the Software and accompanying documentation to -Nokia. YOU AGREE THAT YOUR USE OF THE SOFTWARE ACKNOWLEDGES THAT YOU -HAVE READ THIS AGREEMENT, UNDERSTAND IT, AND AGREE TO BE BOUND BY ITS -TERMS AND CONDITIONS. - -

    - -

    - COPYRIGHT LICENSE -

    - NOKIA CORPORATION END-USER SOFTWARE AGREEMENT FOR - CARBIDE.C++ AND ASSOCIATED ON-DEVICE APPLICATIONS -

    -This Software Agreement ("Agreement") is between You (either an -individual or an entity), the End User, and Nokia Corporation -("Nokia"). The Agreement authorizes You to use the Software specified -in Clause 1 below, which may be stored on a CD-ROM, sent to You by -electronic mail, or downloaded from Nokia's Web pages or Servers or -from other sources under the terms and conditions set forth below. -This is an agreement on end-user rights and not an agreement for sale. -Nokia continues to own the copy of the Software and the physical media -contained in the sales package and any other copy that You are -authorized to make pursuant to this Agreement. - -Read this Agreement carefully before installing, downloading, or using -the Software. By clicking on the "I Accept" button while installing, -downloading, and/or using the Software, You agree to the terms and -conditions of this Agreement. If You do not agree to all of the terms -and conditions of this Agreement, promptly click the "Decline" or -"I Do Not Accept" button, cancel the installation or downloading, or -destroy or return the Software and accompanying documentation to -Nokia. YOU AGREE THAT YOUR USE OF THE SOFTWARE ACKNOWLEDGES THAT YOU -HAVE READ THIS AGREEMENT, UNDERSTAND IT, AND AGREE TO BE BOUND BY ITS -TERMS AND CONDITIONS. - -

    - -

    - COPYRIGHT LICENSE -

    - NOKIA CORPORATION END-USER SOFTWARE AGREEMENT FOR - CARBIDE.C++ AND ASSOCIATED ON-DEVICE APPLICATIONS -

    -This Software Agreement ("Agreement") is between You (either an -individual or an entity), the End User, and Nokia Corporation -("Nokia"). The Agreement authorizes You to use the Software specified -in Clause 1 below, which may be stored on a CD-ROM, sent to You by -electronic mail, or downloaded from Nokia's Web pages or Servers or -from other sources under the terms and conditions set forth below. -This is an agreement on end-user rights and not an agreement for sale. -Nokia continues to own the copy of the Software and the physical media -contained in the sales package and any other copy that You are -authorized to make pursuant to this Agreement. - -Read this Agreement carefully before installing, downloading, or using -the Software. By clicking on the "I Accept" button while installing, -downloading, and/or using the Software, You agree to the terms and -conditions of this Agreement. If You do not agree to all of the terms -and conditions of this Agreement, promptly click the "Decline" or -"I Do Not Accept" button, cancel the installation or downloading, or -destroy or return the Software and accompanying documentation to -Nokia. YOU AGREE THAT YOUR USE OF THE SOFTWARE ACKNOWLEDGES THAT YOU -HAVE READ THIS AGREEMENT, UNDERSTAND IT, AND AGREE TO BE BOUND BY ITS -TERMS AND CONDITIONS. - -

    - -

    - COPYRIGHT LICENSE -

    - NOKIA CORPORATION END-USER SOFTWARE AGREEMENT FOR - CARBIDE.C++ AND ASSOCIATED ON-DEVICE APPLICATIONS -

    -This Software Agreement ("Agreement") is between You (either an -individual or an entity), the End User, and Nokia Corporation -("Nokia"). The Agreement authorizes You to use the Software specified -in Clause 1 below, which may be stored on a CD-ROM, sent to You by -electronic mail, or downloaded from Nokia's Web pages or Servers or -from other sources under the terms and conditions set forth below. -This is an agreement on end-user rights and not an agreement for sale. -Nokia continues to own the copy of the Software and the physical media -contained in the sales package and any other copy that You are -authorized to make pursuant to this Agreement. - -Read this Agreement carefully before installing, downloading, or using -the Software. By clicking on the "I Accept" button while installing, -downloading, and/or using the Software, You agree to the terms and -conditions of this Agreement. If You do not agree to all of the terms -and conditions of this Agreement, promptly click the "Decline" or -"I Do Not Accept" button, cancel the installation or downloading, or -destroy or return the Software and accompanying documentation to -Nokia. YOU AGREE THAT YOUR USE OF THE SOFTWARE ACKNOWLEDGES THAT YOU -HAVE READ THIS AGREEMENT, UNDERSTAND IT, AND AGREE TO BE BOUND BY ITS -TERMS AND CONDITIONS. - -

    - -

    - COPYRIGHT LICENSE -

    - NOKIA CORPORATION END-USER SOFTWARE AGREEMENT FOR - CARBIDE.C++ AND ASSOCIATED ON-DEVICE APPLICATIONS -

    -This Software Agreement ("Agreement") is between You (either an -individual or an entity), the End User, and Nokia Corporation -("Nokia"). The Agreement authorizes You to use the Software specified -in Clause 1 below, which may be stored on a CD-ROM, sent to You by -electronic mail, or downloaded from Nokia's Web pages or Servers or -from other sources under the terms and conditions set forth below. -This is an agreement on end-user rights and not an agreement for sale. -Nokia continues to own the copy of the Software and the physical media -contained in the sales package and any other copy that You are -authorized to make pursuant to this Agreement. - -Read this Agreement carefully before installing, downloading, or using -the Software. By clicking on the "I Accept" button while installing, -downloading, and/or using the Software, You agree to the terms and -conditions of this Agreement. If You do not agree to all of the terms -and conditions of this Agreement, promptly click the "Decline" or -"I Do Not Accept" button, cancel the installation or downloading, or -destroy or return the Software and accompanying documentation to -Nokia. YOU AGREE THAT YOUR USE OF THE SOFTWARE ACKNOWLEDGES THAT YOU -HAVE READ THIS AGREEMENT, UNDERSTAND IT, AND AGREE TO BE BOUND BY ITS -TERMS AND CONDITIONS. - -

    - -

    - COPYRIGHT LICENSE -

    - NOKIA CORPORATION END-USER SOFTWARE AGREEMENT FOR - CARBIDE.C++ AND ASSOCIATED ON-DEVICE APPLICATIONS -

    -This Software Agreement ("Agreement") is between You (either an -individual or an entity), the End User, and Nokia Corporation -("Nokia"). The Agreement authorizes You to use the Software specified -in Clause 1 below, which may be stored on a CD-ROM, sent to You by -electronic mail, or downloaded from Nokia's Web pages or Servers or -from other sources under the terms and conditions set forth below. -This is an agreement on end-user rights and not an agreement for sale. -Nokia continues to own the copy of the Software and the physical media -contained in the sales package and any other copy that You are -authorized to make pursuant to this Agreement. - -Read this Agreement carefully before installing, downloading, or using -the Software. By clicking on the "I Accept" button while installing, -downloading, and/or using the Software, You agree to the terms and -conditions of this Agreement. If You do not agree to all of the terms -and conditions of this Agreement, promptly click the "Decline" or -"I Do Not Accept" button, cancel the installation or downloading, or -destroy or return the Software and accompanying documentation to -Nokia. YOU AGREE THAT YOUR USE OF THE SOFTWARE ACKNOWLEDGES THAT YOU -HAVE READ THIS AGREEMENT, UNDERSTAND IT, AND AGREE TO BE BOUND BY ITS -TERMS AND CONDITIONS. - -

    - -

    - COPYRIGHT LICENSE -

    - NOKIA CORPORATION END-USER SOFTWARE AGREEMENT FOR - CARBIDE.C++ AND ASSOCIATED ON-DEVICE APPLICATIONS -

    -This Software Agreement ("Agreement") is between You (either an -individual or an entity), the End User, and Nokia Corporation -("Nokia"). The Agreement authorizes You to use the Software specified -in Clause 1 below, which may be stored on a CD-ROM, sent to You by -electronic mail, or downloaded from Nokia's Web pages or Servers or -from other sources under the terms and conditions set forth below. -This is an agreement on end-user rights and not an agreement for sale. -Nokia continues to own the copy of the Software and the physical media -contained in the sales package and any other copy that You are -authorized to make pursuant to this Agreement. - -Read this Agreement carefully before installing, downloading, or using -the Software. By clicking on the "I Accept" button while installing, -downloading, and/or using the Software, You agree to the terms and -conditions of this Agreement. If You do not agree to all of the terms -and conditions of this Agreement, promptly click the "Decline" or -"I Do Not Accept" button, cancel the installation or downloading, or -destroy or return the Software and accompanying documentation to -Nokia. YOU AGREE THAT YOUR USE OF THE SOFTWARE ACKNOWLEDGES THAT YOU -HAVE READ THIS AGREEMENT, UNDERSTAND IT, AND AGREE TO BE BOUND BY ITS -TERMS AND CONDITIONS. - -

    - -

    - COPYRIGHT LICENSE -

    - NOKIA CORPORATION END-USER SOFTWARE AGREEMENT FOR - CARBIDE.C++ AND ASSOCIATED ON-DEVICE APPLICATIONS -

    -This Software Agreement ("Agreement") is between You (either an -individual or an entity), the End User, and Nokia Corporation -("Nokia"). The Agreement authorizes You to use the Software specified -in Clause 1 below, which may be stored on a CD-ROM, sent to You by -electronic mail, or downloaded from Nokia's Web pages or Servers or -from other sources under the terms and conditions set forth below. -This is an agreement on end-user rights and not an agreement for sale. -Nokia continues to own the copy of the Software and the physical media -contained in the sales package and any other copy that You are -authorized to make pursuant to this Agreement. - -Read this Agreement carefully before installing, downloading, or using -the Software. By clicking on the "I Accept" button while installing, -downloading, and/or using the Software, You agree to the terms and -conditions of this Agreement. If You do not agree to all of the terms -and conditions of this Agreement, promptly click the "Decline" or -"I Do Not Accept" button, cancel the installation or downloading, or -destroy or return the Software and accompanying documentation to -Nokia. YOU AGREE THAT YOUR USE OF THE SOFTWARE ACKNOWLEDGES THAT YOU -HAVE READ THIS AGREEMENT, UNDERSTAND IT, AND AGREE TO BE BOUND BY ITS -TERMS AND CONDITIONS. - -

    - -

    - COPYRIGHT LICENSE -

    - NOKIA CORPORATION END-USER SOFTWARE AGREEMENT FOR - CARBIDE.C++ AND ASSOCIATED ON-DEVICE APPLICATIONS -

    -This Software Agreement ("Agreement") is between You (either an -individual or an entity), the End User, and Nokia Corporation -("Nokia"). The Agreement authorizes You to use the Software specified -in Clause 1 below, which may be stored on a CD-ROM, sent to You by -electronic mail, or downloaded from Nokia's Web pages or Servers or -from other sources under the terms and conditions set forth below. -This is an agreement on end-user rights and not an agreement for sale. -Nokia continues to own the copy of the Software and the physical media -contained in the sales package and any other copy that You are -authorized to make pursuant to this Agreement. - -Read this Agreement carefully before installing, downloading, or using -the Software. By clicking on the "I Accept" button while installing, -downloading, and/or using the Software, You agree to the terms and -conditions of this Agreement. If You do not agree to all of the terms -and conditions of this Agreement, promptly click the "Decline" or -"I Do Not Accept" button, cancel the installation or downloading, or -destroy or return the Software and accompanying documentation to -Nokia. YOU AGREE THAT YOUR USE OF THE SOFTWARE ACKNOWLEDGES THAT YOU -HAVE READ THIS AGREEMENT, UNDERSTAND IT, AND AGREE TO BE BOUND BY ITS -TERMS AND CONDITIONS. - -

    - -

    - COPYRIGHT LICENSE -

    - NOKIA CORPORATION END-USER SOFTWARE AGREEMENT FOR - CARBIDE.C++ AND ASSOCIATED ON-DEVICE APPLICATIONS -

    -This Software Agreement ("Agreement") is between You (either an -individual or an entity), the End User, and Nokia Corporation -("Nokia"). The Agreement authorizes You to use the Software specified -in Clause 1 below, which may be stored on a CD-ROM, sent to You by -electronic mail, or downloaded from Nokia's Web pages or Servers or -from other sources under the terms and conditions set forth below. -This is an agreement on end-user rights and not an agreement for sale. -Nokia continues to own the copy of the Software and the physical media -contained in the sales package and any other copy that You are -authorized to make pursuant to this Agreement. - -Read this Agreement carefully before installing, downloading, or using -the Software. By clicking on the "I Accept" button while installing, -downloading, and/or using the Software, You agree to the terms and -conditions of this Agreement. If You do not agree to all of the terms -and conditions of this Agreement, promptly click the "Decline" or -"I Do Not Accept" button, cancel the installation or downloading, or -destroy or return the Software and accompanying documentation to -Nokia. YOU AGREE THAT YOUR USE OF THE SOFTWARE ACKNOWLEDGES THAT YOU -HAVE READ THIS AGREEMENT, UNDERSTAND IT, AND AGREE TO BE BOUND BY ITS -TERMS AND CONDITIONS. - -

    - -

    - COPYRIGHT LICENSE -

    - NOKIA CORPORATION END-USER SOFTWARE AGREEMENT FOR - CARBIDE.C++ AND ASSOCIATED ON-DEVICE APPLICATIONS -

    -This Software Agreement ("Agreement") is between You (either an -individual or an entity), the End User, and Nokia Corporation -("Nokia"). The Agreement authorizes You to use the Software specified -in Clause 1 below, which may be stored on a CD-ROM, sent to You by -electronic mail, or downloaded from Nokia's Web pages or Servers or -from other sources under the terms and conditions set forth below. -This is an agreement on end-user rights and not an agreement for sale. -Nokia continues to own the copy of the Software and the physical media -contained in the sales package and any other copy that You are -authorized to make pursuant to this Agreement. - -Read this Agreement carefully before installing, downloading, or using -the Software. By clicking on the "I Accept" button while installing, -downloading, and/or using the Software, You agree to the terms and -conditions of this Agreement. If You do not agree to all of the terms -and conditions of this Agreement, promptly click the "Decline" or -"I Do Not Accept" button, cancel the installation or downloading, or -destroy or return the Software and accompanying documentation to -Nokia. YOU AGREE THAT YOUR USE OF THE SOFTWARE ACKNOWLEDGES THAT YOU -HAVE READ THIS AGREEMENT, UNDERSTAND IT, AND AGREE TO BE BOUND BY ITS -TERMS AND CONDITIONS. - -

    - -

    - COPYRIGHT LICENSE -

    - NOKIA CORPORATION END-USER SOFTWARE AGREEMENT FOR - CARBIDE.C++ AND ASSOCIATED ON-DEVICE APPLICATIONS -

    -This Software Agreement ("Agreement") is between You (either an -individual or an entity), the End User, and Nokia Corporation -("Nokia"). The Agreement authorizes You to use the Software specified -in Clause 1 below, which may be stored on a CD-ROM, sent to You by -electronic mail, or downloaded from Nokia's Web pages or Servers or -from other sources under the terms and conditions set forth below. -This is an agreement on end-user rights and not an agreement for sale. -Nokia continues to own the copy of the Software and the physical media -contained in the sales package and any other copy that You are -authorized to make pursuant to this Agreement. - -Read this Agreement carefully before installing, downloading, or using -the Software. By clicking on the "I Accept" button while installing, -downloading, and/or using the Software, You agree to the terms and -conditions of this Agreement. If You do not agree to all of the terms -and conditions of this Agreement, promptly click the "Decline" or -"I Do Not Accept" button, cancel the installation or downloading, or -destroy or return the Software and accompanying documentation to -Nokia. YOU AGREE THAT YOUR USE OF THE SOFTWARE ACKNOWLEDGES THAT YOU -HAVE READ THIS AGREEMENT, UNDERSTAND IT, AND AGREE TO BE BOUND BY ITS -TERMS AND CONDITIONS. - -

    - - - - \ No newline at end of file diff -r 819e59dfc032 -r 2d9cac8919d3 creator/files/JAD-1kB.dat --- a/creator/files/JAD-1kB.dat Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ -MIDlet-1: HelloWorld, , helloworld.HelloWorld -MIDlet-Icon: \HelloWorld.png -MIDlet-Jar-Size: 6817 -MIDlet-Jar-URL: HelloWorld.jar -MIDlet-Name: HelloWorld -MIDlet-Vendor: My Vendor -MIDlet-Version: 1.0 diff -r 819e59dfc032 -r 2d9cac8919d3 creator/files/JAR-10kB.dat Binary file creator/files/JAR-10kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 creator/files/JP2-65kB.dat Binary file creator/files/JP2-65kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 creator/files/JPEG-200kB.dat Binary file creator/files/JPEG-200kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 creator/files/JPEG-25kB.dat Binary file creator/files/JPEG-25kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 creator/files/JPEG-500kB.dat Binary file creator/files/JPEG-500kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 creator/files/MIDI-10kB.dat Binary file creator/files/MIDI-10kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 creator/files/MP3-250kB.dat Binary file creator/files/MP3-250kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 creator/files/MP4-200kB.dat Binary file creator/files/MP4-200kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 creator/files/MXMF-40kB.dat Binary file creator/files/MXMF-40kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 creator/files/PNG-15kB.dat Binary file creator/files/PNG-15kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 creator/files/PPT-40kB.dat Binary file creator/files/PPT-40kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 creator/files/RAM-1kB.dat --- a/creator/files/RAM-1kB.dat Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -rtsp://nokia.com \ No newline at end of file diff -r 819e59dfc032 -r 2d9cac8919d3 creator/files/RM-95kB.dat Binary file creator/files/RM-95kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 creator/files/RNG-1kB.dat Binary file creator/files/RNG-1kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 creator/files/SISX-10kB.dat Binary file creator/files/SISX-10kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 creator/files/SVG-15kB.dat --- a/creator/files/SVG-15kB.dat Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,62 +0,0 @@ - - - - - - - - - - - - - - - - - diff -r 819e59dfc032 -r 2d9cac8919d3 creator/files/SWF-15kB.dat Binary file creator/files/SWF-15kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 creator/files/TIF-25kB.dat Binary file creator/files/TIF-25kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 creator/files/TXT-10kB.dat --- a/creator/files/TXT-10kB.dat Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,19 +0,0 @@ -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... \ No newline at end of file diff -r 819e59dfc032 -r 2d9cac8919d3 creator/files/TXT-70kB.dat --- a/creator/files/TXT-70kB.dat Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,147 +0,0 @@ -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing.Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... TestiTesting... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing..ing... Testing... - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Te. Testing... Testing... Testing... Testing... Testing... Testing... Testing... - - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... - - -Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... ng... .. \ No newline at end of file diff -r 819e59dfc032 -r 2d9cac8919d3 creator/files/VCF-1kB.dat --- a/creator/files/VCF-1kB.dat Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,17 +0,0 @@ -BEGIN:VCARD -VERSION:2.1 -N:Smith;John -FN:John Smith -ORG:Firm -TITLE:Boss -NOTE;ENCODING=QUOTED-PRINTABLE:Liirum larum.=0D=0A -TEL;WORK;VOICE:132456798 -TEL;HOME;VOICE:654654987 -TEL;CELL;VOICE:0400654987654 -TEL;WORK;FAX:2321654987987 -ADR;WORK:;;Firmstreet 1;New City;Sawo;00000;Finland -LABEL;WORK;ENCODING=QUOTED-PRINTABLE:Firmstreet 1=0D=0ANew City, Sawo 00000=0D=0AFinland -URL;WORK:http://www.nokia.com -EMAIL;PREF;INTERNET:John.Smith@firm.com -REV:20080306T115812Z -END:VCARD diff -r 819e59dfc032 -r 2d9cac8919d3 creator/files/VCS-1kB.dat --- a/creator/files/VCS-1kB.dat Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,15 +0,0 @@ -BEGIN:VCALENDAR -PRODID:-//Microsoft Corporation//Outlook 11.0 MIMEDIR//EN -VERSION:1.0 -BEGIN:VEVENT -DTSTART:20080306T060000Z -DTEND:20080306T070000Z -LOCATION;ENCODING=QUOTED-PRINTABLE:Meeting room -UID:040000008200E00074C5B7101A82E00800000000000CEF7E917FC8010000000000000000100 - 000008AA6A7A7250C0A4E97153769E69DD064 -DESCRIPTION;ENCODING=QUOTED-PRINTABLE:Remember to bring laptop and document= -ation=0D=0A -SUMMARY;ENCODING=QUOTED-PRINTABLE:Meeting with BOSS -PRIORITY:3 -END:VEVENT -END:VCALENDAR diff -r 819e59dfc032 -r 2d9cac8919d3 creator/files/WAV-20kB.dat Binary file creator/files/WAV-20kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 creator/files/WMA-50kB.dat Binary file creator/files/WMA-50kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 creator/files/WMV-200kB.dat Binary file creator/files/WMV-200kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 creator/files/XLS-15kB.dat Binary file creator/files/XLS-15kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 creator/files/backup_registration.xml --- a/creator/files/backup_registration.xml Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ - - - - - - - - diff -r 819e59dfc032 -r 2d9cac8919d3 creator/icons/qgn_menu_creator.svg --- a/creator/icons/qgn_menu_creator.svg Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,62 +0,0 @@ - - - - - - - - - - - - - - - - - diff -r 819e59dfc032 -r 2d9cac8919d3 creator/inc/engine.h --- a/creator/inc/engine.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,588 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#ifndef __CREATORENGINE_H__ -#define __CREATORENGINE_H__ - -// INCLUDES -#include -#include -#include -#include -#include -#include - -//#include -#include -#include -#include -//#include -#include -#include -#include //TFrameInfo - -#include "creator.hrh" -#include "creator_std.h" -#include "creator_randomdataparser.h" - -//class CCreatorAppUi; -class TCommand; -class CCreatorBrowser; -class CCreatorCalendarBase; -class CCreatorNotepad; -class CCreatorLogs; -//class CCreatorAccessPoints; -class CCreatorMailboxes; -class CCreatorIMPS; -class CCreatorFiles; -class CCreatorMessages; -class CCreatorLandmarks; -class MCreatorModuleBase; -class CCreatorPhonebookBase; -class CCreatorModuleBaseParameters; -//class CCreatorConnectionSettingsBase; -class CDictionaryFileStore; -class CImageDecoder; -class CFbsBitmap; -class CBitmapScaler; -class CCommandParser; -class EngineWrapper; -class CCreatorCmdScriptRun; - -static const TUid KUidCreatorApp = {0x20011383}; - -enum TListQueryId - { - R_GROUP_CREATION_TYPE_QUERY, - R_CONTACT_CREATION_TYPE_QUERY, - R_MESSAGE_TYPE_QUERY, - R_FOLDER_TYPE_QUERY, - R_UNREAD_QUERY, - R_ATTACHMENT_MULTI_SELECTION_QUERY, - R_AMS_ATTACHMENT_SINGLE_SELECTION_QUERY, - R_ATTACHMENT_SINGLE_SELECTION_QUERY - }; - -/* - * Interface for UI dialogs - */ -class MUIObserver - { -public: - /** - * Called when some dialog in UI is closed - * - * @since S60 10.1 - * @param aPositiveAction ETrue if "Ok", "Yes" or other "positive" button was pressed - * @param aUserData number that was passed to UI before dialog was opened - * @return None. - */ - virtual void QueryDialogClosedL(TBool aPositiveAction, TInt aUserData) = 0; - - }; - -/* - * Interface for CCommandParser - */ -class MCommandParserObserver - { -public: - /** - * Called when CCommandParser user has choosen script file - * - * @since S60 10.1 - * @param aSuccess ETrue if "Ok", "Yes" or other "positive" button was pressed - * @param aFileName filename chosen by user - * @return None. - */ - virtual void ScriptChosenL(TBool aSuccess, const TDesC& aFileName = KNullDesC) = 0; - - /** - * Called when CCommandParser user has choosen random data file - * - * @since S60 10.1 - * @param aSuccess ETrue if "Ok", "Yes" or other "positive" button was pressed - * @param aFileName filename chosen by user - * @return None. - */ - virtual void RandomDataFileChosenL(TBool aSuccess, const TDesC& aFileName = KNullDesC) = 0; - }; - -/** - * Device memory information - */ -class TMemoryDetails - { -public: - - TBuf<16> iFree; - TBuf<16> iSize; - TChar iDriveLetter; - - TBuf<16> iRamFree; - TBuf<16> iRomFree; - - TBool iENotAvailable; - - TBuf<16> iRamSize; - TBuf<16> iRomSize; - }; -// Common constant for undefined integer value: -const TInt KUndef = KErrNotFound; - -class CCreatorEngine : public CActive, public MUIObserver, public MCommandParserObserver - { -enum ECreatorEngineState{ - ECreatorEngineDeleteAllEntries, - ECreatorEngineDeleteAllCreatorEntries, -}; -public: - - enum TRandomStringType - { - EFirstName = 0, - ESurname, - ECompany, - EAddress, - EJobTitle, - EPhoneNumber, - EGroupName, - EMeetingReason, - EMeetingPlace, - EMemoText, - EAnniversaryReason, - EToDoText, - EReminderText, - EMessageSubject, - EMessageText, - ECity, - ECountry, - EPostcode, - EState, - EPobox, - EPrefix, - ESuffix, - ELandmarkName, - ELandmarkDescription - }; - - -// note! changing order will cause regression in other modules - - enum TTestDataPath - { - EJPEG_25kB = 0, - EJPEG_200kB, - EJPEG_500kB, - EPNG_15kB, - EGIF_2kB, - ERNG_1kB, - EMIDI_10kB, - EWAVE_20kB, - EAMR_20kB, - EExcel_15kB, - EWord_20kB, - EPowerPoint_40kB, - EText_10kB, - EText_70kB, - E3GPP_70kB, - EMP3_250kB, - EAAC_100kB, - ERM_95kB, - EBMP_25kB, - EHTML_20kB, - EJAD_1kB, - EJAR_10kB, - EJP2_65kB, - EMP4_200kB, - EMXMF_40kB, - ERAM_1kB, - ESVG_15kB, - ESWF_15kB, - ETIF_25kB, - EVCF_1kB, - EVCS_1kB, - ESISX_10kB, - EWMA_50kB, - EWMV_200kB, - ESavedDeck_1kB, - LAST_FILE_ID//When you add new items to enum, add them before last item, so random number generations does not need to be updated also - }; - - enum TRandomDateType - { - EDatePast, - EDateFuture - }; - -public: - /** - * Constructor: NewL - */ - static CCreatorEngine* NewL(EngineWrapper *aEngineWrapper); - /** - * Constructor: NewLC - */ - static CCreatorEngine* NewLC(EngineWrapper *aEngineWrapper); - ~CCreatorEngine(); - - inline const RPointerArray& GetMemoryDetailsList(){ return iMemoryDetailsList; }; - inline const TMemoryDetails& GetMemoryDetails(){ return iMemoryDetails; }; - inline EngineWrapper* GetEngineWrapper(){ return iEngineWrapper; }; - inline CCreatorPhonebookBase* GetPhonebook(){ return iPhonebook; }; - -private: - CCreatorEngine(); - /** - * EPOC default constructor for performing 2nd stage construction - */ - void ConstructL(EngineWrapper *aEngineWrapper); - - void RequestMemoryDetails(); - TBool MMC_OK() const; - void Init(); - void RunL(); - TInt RunError(TInt aError); - void DoCancel(); - - void ExecuteCommand(); - void StartEnginesL(); - void CheckForMoreCommandsL(); - - TBool IsDeleteCommand( TInt aCommand ); - - TInt ReadRandomDataL(const TRandomStringType aRandomStringType, - const TInt aResourceId, - const TDesC& aFilename, - const CCreatorRandomDataParser::TRandomDataType aRandomDataType); - void GenerateSourceImageFileL( const TTestDataPath aFileType, const TDesC& aFileName ); - void GenereteSourceTextFileL( const TDesC& aFileName, TInt aSize ); - -public: // from MUIObserver - /** - * Called when some dialog in UI is closed - * - * @since S60 10.1 - * @param aPositiveAction ETrue if "Ok", "Yes" or other "positive" button was pressed - * @param aUserData number that was passed to UI before dialog was opened - * @return ?description - */ - virtual void QueryDialogClosedL(TBool aPositiveAction, TInt aUserData); - -public: // from MCommandParserObserver - /** - * Called when CCommandParser user has choosen script file - * - * @since S60 10.1 - * @param aSuccess ETrue if "Ok", "Yes" or other "positive" button was pressed - * @param aFileName filename chosen by user - * @return None. - */ - virtual void ScriptChosenL(TBool aSuccess, const TDesC& aFileName = KNullDesC); - - /** - * Called when CCommandParser user has choosen random data file - * - * @since S60 10.1 - * @param aSuccess ETrue if "Ok", "Yes" or other "positive" button was pressed - * @param aFileName filename chosen by user - * @return None. - */ - virtual void RandomDataFileChosenL(TBool aSuccess, const TDesC& aFileName = KNullDesC); - -public: - void ExecuteOptionsMenuCommandL(TInt aCommand); - void RunScriptL(); - TInt RunScriptL(const TDesC& aScriptFile); - void ShutDownEnginesL(); - void ExecuteFirstCommandL(const TDesC& aText); - - void AppendToCommandArrayL(TInt aCommand, CCreatorModuleBaseParameters* aParameters, TInt aNumberOfEntries = 1); - TInt CommandArrayCount(); - - TPtrC TestDataPathL(enum TTestDataPath aTestDataPath); - TPtrC RandomSoundFileL(); // Returns temporary path, which will be removed on shutdown - void RandomPictureFileL(TDes& aPath); // aPath temporary path, which will be removed on shutdown - TPtrC CreateRandomSoundFileL(); // Copies file to new location and returns the new path - TPtrC CreateSoundFileL(TTestDataPath aId); // Copies file to new location and returns the new path - - void CopyFileL(const TFileName& aSourceFile, const TFileName& aTargetFile, TBool aOverwrite = EFalse ); - /* - * Gets attacment file id based on the file id string - * @return Attachment file id - * @param aAttachmentIdStr Attachment file id string - */ - TInt GetAttachmentIdL( const TDesC& aAttachmentIdStr ) const; - - TUint32 GetDefaultIAPL(); - TUint32 AccessPointNameToIdL(const TDesC& aAPName, TBool aAnyIfNotFound = EFalse ); - - TPtrC RandomString(enum TRandomStringType aRandomStringType); - TInt RandomNumber(TInt aRange); - TInt RandomNumber(TInt aMin, TInt aMax); - TTime RandomDate(TRandomDateType type, TInt aMinDays = 0, TInt aMaxDays = 360 ); - TTime RandomDate(TTime baseTime, TRandomDateType type, TInt aMinDays = 0, TInt aMaxDays = 360); - TTime RandomTime(TTime baseTime, TRandomDateType type, TInt aMinHours=0, TInt aMaxHours=24, TInt aMinMinutes=0, TInt aMaxMinutes=60 ); - CDesCArrayFlat* SoundFilesL(); - CDesCArrayFlat* PictureFilesL(); - - HBufC* CreateEmailAddressLC(); - HBufC* CreateHTTPUrlLC(); - HBufC* CreateRandomStringLC(TInt aStrLen); - - HBufC* CreateEmailAddressLC( - const TDesC& firstname, - const TDesC& lastname, - const TDesC& domain, - const TDesC& country ) const; - - HBufC* CreateUrlLC( - const TDesC& protocol, - const TDesC& prefix, - const TDesC& domain, - const TDesC& country) const; - - void SetDefaultPathForFileCommandL(TInt aCommand, TFileName& aPath); - - TBool GetRandomDataL(); - TBool GetRandomDataFromFileL(const TDesC& aFilename); - void CancelComplete(); - CDictionaryFileStore* FileStoreLC(); - void ReadEntryIdsFromStoreL( RArray& aEntryIds, const TUid aModuleUid ); - void WriteEntryIdsToStoreL( RArray& aEntryIds, const TUid aModuleUid ); - void ReadEntryIdsFromStoreL( RArray& aEntryIds, const TUid aModuleUid ); - void WriteEntryIdsToStoreL( RArray& aEntryIds, const TUid aModuleUid ); - void RemoveStoreL( const TUid aModuleUid ); - void ProgressDialogCancelledL(); - - void SortCommands(); - -private: - // needed by the engine itself - RTimer iTimer; - CEikonEnv* iEnv; - //CCreatorAppUi* iAppUi; - TInt iCurrentEntry; - TInt iFailedCommands; - - CDesCArrayFlat* iSoundFileArray; - CDesCArrayFlat* iPictureFileArray; - CCommandArray* iCommandArray; - RPointerArray iParameterArray; - // progress bar - //CAknProgressDialog* iProgressDialog; - //CEikProgressInfo* iProgressInfo; - - // for the random data generator - TInt64 iSeed; - - class TStringArrayPtr - { - public: - TStringArrayPtr(TRandomStringType aType, CDesCArray* aPtr) - { - iStringType = aType; - iArrayPtr = aPtr; - }; - TRandomStringType iStringType; - CDesCArray* iArrayPtr; - }; - - RArray iStringArrays; - - // modules - CCreatorBrowser* iBrowser; - CCreatorCalendarBase* iCalendar; - CCreatorPhonebookBase* iPhonebook; - CCreatorNotepad* iNotepad; - CCreatorLogs* iLogs; -// CCreatorConnectionSettingsBase* iAccessPoints; - CCreatorMailboxes* iMailboxes; - CCreatorIMPS* iIMPS; - CCreatorFiles* iFiles; - CCreatorMessages* iMessages; - CCreatorLandmarks* iLandmarks; - CCreatorCmdScriptRun* iCmdScriptRun; - CCommandParser* iCommandParser; - - // options menu command home module - MCreatorModuleBase* iUsedOptionsMenuModule; - - HBufC* iTempPath; - - RPointerArray iAllocatedFilePaths; - TBool iUserCancelled; - - // For generating missing bitmaps - HBufC8* iBitmapData; - CFbsBitmap* iBitmap; - CFbsBitmap* iScaledBitmap; - CImageDecoder* iDecoder; - TFrameInfo iFrameinfo; - CImageEncoder* iEncoder; - CFrameImageData* iFrameImageData; - CBitmapScaler* iScaler; - - EngineWrapper* iEngineWrapper; // Enginewrapper that is used for communicating between QT and Symbian - TMemoryDetails iMemoryDetails; - - RPointerArray iMemoryDetailsList; - - TInt iResourceFileId; - - HBufC* iCommandLineScriptName; - HBufC* iCommandLineRandomDataFileName; - }; - -// this class contains a command which will be executed -class TCommand - { -public: - TInt iCommandId; - CCreatorModuleBaseParameters* iParameters; -public: - TCommand(TInt aCommandId, CCreatorModuleBaseParameters* aParameters); - ~TCommand(); - - }; - - -// utility class for waiting for asychronous requests -class CAsyncWaiter : public CActive - { -public: - static CAsyncWaiter* NewL( TInt aPriority = EPriorityStandard ); - static CAsyncWaiter* NewLC( TInt aPriority = EPriorityStandard ); - ~CAsyncWaiter(); - - void StartAndWait(); - TInt Result() const; - -private: - CAsyncWaiter( TInt aPriority ); - - // from CActive - void RunL(); - void DoCancel(); - -private: - CActiveSchedulerWait iWait; - TInt iError; - }; - - -/* - * Maps file id string (file name) to TTestDataPath (file id) and TCreatorIds (command id) - */ -// File ids: - - _LIT(K3GPP_70KB, "3GPP-70kB"); - _LIT(KAAC_100KB, "AAC-100kB"); - _LIT(KAMR_20KB, "AMR-20kB"); - _LIT(KXLS_15KB, "XLS-15kB"); - _LIT(KGIF_2KB, "GIF-2kB"); - _LIT(KJPEG_200KB, "JPEG-200kB"); - _LIT(KJPEG_25KB, "JPEG-25kB"); - _LIT(KJPEG_500KB, "JPEG-500kB"); - _LIT(KMIDI_10KB, "MIDI-10kB"); - _LIT(KMP3_250KB, "MP3-250kB"); - _LIT(KPNG_15KB, "PNG-15kB"); - _LIT(KPPT_40KB, "PPT-40kB"); - _LIT(KRM_95KB, "RM-95kB"); - _LIT(KRNG_1KB, "RNG-1kB"); - _LIT(KTXT_10KB, "TXT-10kB"); - _LIT(KTXT_70KB, "TXT-70kB"); - _LIT(KWAV_20KB, "WAV-20kB"); - _LIT(KDOC_20KB, "DOC-20kB"); - _LIT(KSWF_15KB, "SWF-15kB"); - _LIT(KJAD_1KB, "JAD-1kB"); - _LIT(KJAR_10KB, "JAR-10kB"); - _LIT(KTIF_25KB, "TIF-25kB"); - _LIT(KMXMF_40KB, "MXMF-40kB"); - _LIT(KBMP_25KB, "BMP-25kB"); - _LIT(KJP2_25KB, "JP2-25kB"); - _LIT(KSVG_15KB, "SVG-15kB"); - _LIT(KHTML_20KB, "HTML-20kB"); - _LIT(KVCF_1KB, "VCF-1kB"); - _LIT(KVCS_1KB, "VCS-1kB"); - _LIT(KMP4_200KB, "MP4-200kB"); - _LIT(KSISX_10KB, "SISX-10kB"); - _LIT(KRAM_1KB, "RAM-1kB"); - _LIT(KDECK_1KB, "DECK-1kB"); - _LIT(KWMA_50KB, "WMA-50kB"); - _LIT(KWMV_200KB, "WMV-200kB"); - -class FileMapping - { - public: - FileMapping(const TDesC& aFileName, TInt aFileId, TInt aCommandId ); - const TDesC& FileName() const; - TInt FileId() const; - TInt CommandId() const; - - private: - const TDesC& iFileName; - TInt iFileId; - TInt iCommandId; - }; - - /* - * This table contains the string <-> TTestDataPath mappings for the file types - */ - static FileMapping FileMap[] = - { - - FileMapping(K3GPP_70KB, CCreatorEngine::E3GPP_70kB, ECmdCreateFileEntry3GPP_70kB), - FileMapping(KAAC_100KB, CCreatorEngine::EAAC_100kB, ECmdCreateFileEntryAAC_100kB), - FileMapping(KAMR_20KB, CCreatorEngine::EAMR_20kB, ECmdCreateFileEntryAMR_20kB), - FileMapping(KXLS_15KB, CCreatorEngine::EExcel_15kB, ECmdCreateFileEntryXLS_15kB), - FileMapping(KGIF_2KB, CCreatorEngine::EGIF_2kB, ECmdCreateFileEntryGIF_2kB), - FileMapping(KJPEG_200KB, CCreatorEngine::EJPEG_200kB, ECmdCreateFileEntryJPEG_200kB), - FileMapping(KJPEG_25KB, CCreatorEngine::EJPEG_25kB, ECmdCreateFileEntryJPEG_25kB), - FileMapping(KJPEG_500KB, CCreatorEngine::EJPEG_500kB, ECmdCreateFileEntryJPEG_500kB), - FileMapping(KMIDI_10KB, CCreatorEngine::EMIDI_10kB, ECmdCreateFileEntryMIDI_10kB), - FileMapping(KMP3_250KB, CCreatorEngine::EMP3_250kB, ECmdCreateFileEntryMP3_250kB), - FileMapping(KPNG_15KB, CCreatorEngine::EPNG_15kB, ECmdCreateFileEntryPNG_15kB), - FileMapping(KPPT_40KB, CCreatorEngine::EPowerPoint_40kB, ECmdCreateFileEntryPPT_40kB), - FileMapping(KRM_95KB, CCreatorEngine::ERM_95kB, ECmdCreateFileEntryRM_95kB), - FileMapping(KRNG_1KB, CCreatorEngine::ERNG_1kB, ECmdCreateFileEntryRNG_1kB), - FileMapping(KTXT_10KB, CCreatorEngine::EText_10kB, ECmdCreateFileEntryTXT_10kB), - FileMapping(KTXT_70KB, CCreatorEngine::EText_70kB, ECmdCreateFileEntryTXT_70kB), - FileMapping(KWAV_20KB, CCreatorEngine::EWAVE_20kB, ECmdCreateFileEntryWAV_20kB), - FileMapping(KDOC_20KB, CCreatorEngine::EWord_20kB, ECmdCreateFileEntryDOC_20kB), - FileMapping(KBMP_25KB, CCreatorEngine::EBMP_25kB, ECmdCreateFileEntryBMP_25kB), - FileMapping(KDECK_1KB, CCreatorEngine::ESavedDeck_1kB, ECmdCreateFileEntryDeck_1kB), - FileMapping(KHTML_20KB, CCreatorEngine::EHTML_20kB, ECmdCreateFileEntryHTML_20kB), - FileMapping(KJAD_1KB, CCreatorEngine::EJAD_1kB, ECmdCreateFileEntryJAD_1kB), - FileMapping(KJAR_10KB, CCreatorEngine::EJAR_10kB, ECmdCreateFileEntryJAR_10kB), - FileMapping(KJP2_25KB, CCreatorEngine::EJP2_65kB, ECmdCreateFileEntryJP2_65kB), - FileMapping(KMP4_200KB, CCreatorEngine::EMP4_200kB, ECmdCreateFileEntryMP4_200kB), - FileMapping(KMXMF_40KB, CCreatorEngine::EMXMF_40kB, ECmdCreateFileEntryMXMF_40kB), - FileMapping(KRAM_1KB, CCreatorEngine::ERAM_1kB, ECmdCreateFileEntryRAM_1kB), - FileMapping(KSVG_15KB, CCreatorEngine::ESVG_15kB, ECmdCreateFileEntrySVG_15kB), - FileMapping(KSWF_15KB, CCreatorEngine::ESWF_15kB, ECmdCreateFileEntrySWF_15kB), - FileMapping(KTIF_25KB, CCreatorEngine::ETIF_25kB, ECmdCreateFileEntryTIF_25kB), - FileMapping(KVCF_1KB, CCreatorEngine::EVCF_1kB, ECmdCreateFileEntryVCF_1kB), - FileMapping(KVCS_1KB, CCreatorEngine::EVCS_1kB, ECmdCreateFileEntryVCS_1kB), - FileMapping(KSISX_10KB, CCreatorEngine::ESISX_10kB, ECmdCreateFileEntrySISX_10kB), - FileMapping(KWMA_50KB, CCreatorEngine::EWMA_50kB, ECmdCreateFileEntryWMA_50kB), - FileMapping(KWMV_200KB, CCreatorEngine::EWMV_200kB, ECmdCreateFileEntryWMV_200kB) - }; - -#endif // __CREATORENGINE_H__ - diff -r 819e59dfc032 -r 2d9cac8919d3 creator/inc/enginewrapper.h --- a/creator/inc/enginewrapper.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,168 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#ifndef ENGINEWRAPPER_H -#define ENGINEWRAPPER_H - -#include -#include -#include -#include - -#include // for iProgressNote signal connect - - -class MainView; -class MemoryDetails; -class HbProgressDialog; -class HbPopup; -class HbCommonNote; -class HbAction; - - -/** - * class that is used for communicating between Symbian and Qt code. - */ -class EngineWrapper : public QObject - { - Q_OBJECT - -public: - - /** - * Constructor - */ - EngineWrapper(); - - /** - * Destructor - */ - ~EngineWrapper(); - - /** - * Initializes Engine Wrapper - * @return true if engine was started successfully - */ - bool init(); - - /** - * Get memory details - */ - MemoryDetails GetMemoryDetails(); - - /** - * Get memory details list - */ - QList GetMemoryDetailsList(); - -public: - - /* Functions that are called from UI */ - bool ExecuteOptionsMenuCommand(int commandId); - - -public: - - /* Functions that are called from engine: */ - - /** - * uses Notifications class to show error message - */ - void ShowErrorMessage(const TDesC& aErrorMessage); - - /** - * uses Notifications class to show progressbar - */ - void ShowProgressBar(const TDesC& aPrompt, int aMax); - - /** - * uses Notifications class to show user note - */ - void ShowNote(const TDesC& aNoteMessage, TInt aResourceId = 0); - - /** - * increments shown progressbar's value - */ - void IncrementProgressbarValue(); - - /** - * closes progressbar - */ - void CloseProgressbar(); - - /** - * Create entries query dialog - */ - TBool EntriesQueryDialog(TInt* aNumberOfEntries, const TDesC& aPrompt, TBool aAcceptsZero, MUIObserver* aObserver, TInt aUserData); - - /** - * Create time query dialog - */ - TBool TimeQueryDialog(TTime* aTime, const TDesC& aPrompt, MUIObserver* aObserver, TInt aUserData); - - /** - * Create yes or no query dialog - */ - TBool YesNoQueryDialog(const TDesC& aPrompt, MUIObserver* aObserver, int userData); - - /** - * Popup list dialog for selecting item from dialog list - */ - TBool PopupListDialog(const TDesC& aPrompt, const CDesCArray* aFileNameArray, TInt* aIndex, MUIObserver* aObserver, TInt aUserData); - - /** - * Directory query dialog - */ - TBool DirectoryQueryDialog(const TDesC& aPrompt, TDes& aDirectory, MUIObserver* aObserver, TInt aUserData); - - /** - * Create list query single-selection dialog - */ - TBool ListQueryDialog(const TDesC& aPrompt, TListQueryId aId, TInt* aSeletedItem, MUIObserver* aObserver, TInt aUserData); - - /** - * Create list query multi-selection dialog - */ - TBool ListQueryDialog(const TDesC& aPrompt, TListQueryId aId, CArrayFixFlat* aSelectedItems, MUIObserver* aObserver, TInt aUserData); - - - /** - * Close application when started from command line for script run. - */ - void CloseCreatorApp(); - -private slots: - - /** - * progress dialog cancelled - */ - void ProgressDialogCancelled(); - -private: - - - /* Creator engine */ - CCreatorEngine* iEngine; - - /* progress dialog that is shown */ - HbProgressDialog* iProgressDialog; - - MCreatorModuleBase *iModule; -}; - -#endif //ENGINEWRAPPER_H diff -r 819e59dfc032 -r 2d9cac8919d3 creator/inc/mainview.h --- a/creator/inc/mainview.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,201 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#ifndef MAINVIEW_H -#define MAINVIEW_H - -#include -#include - -class HbMainWindow; -class HbApplication; -class HbAction; -class QSignalMapper; - -class MemoryDetails -{ -public: - QString mFree; - QString mSize; - QString mDriveLetter; - - QString mRamFree; - bool mENotAvailable; - QString mRamSize; -}; - -/** - * Class that implements the main view of Creator - */ -class MainView : public HbView -{ - Q_OBJECT - -public: - - /** - * Constructor - */ - MainView(HbMainWindow &mainWindow); - - /** - * Destructor - */ - ~MainView(); - - /** - * Initializes Engine Wrapper - * @param app application class of Creator - */ - void init(HbApplication &app); - - /** - * Call application exit from engine. - */ - static void closeApp(); - -private: - - /** - * Creates menu - */ - void createMenu(HbApplication &app); - - /** - * Creates memory info text to UI - */ - void createMemoryInfoText(); - -private slots: - - - /** - * Shows about pop-up - */ - void showAboutPopup(); - /** - * calls engine wrapper to complete service request, specified with commandId. - */ - void executeMenuCommand(int cmd); - -private: - - /* Main window of Creator */ - HbMainWindow &mMainWindow; - - - /* Engine Wrapper */ - EngineWrapper mEngineWrapper; - - /* Actions that are used in toolbars and menus */ - HbAction* mActionRunScript; - HbAction* mActionCalendarAppointments; - HbAction* mActionCalendarEvents; - HbAction* mActionCalendarAnniversaries; - HbAction* mActionCalendarTodos; - HbAction* mActionCalendarReminders; - HbAction* mActionBrowserBookmark; - HbAction* mActionBrowserBmarkFolder; - HbAction* mActionLogsMissedCalls; - HbAction* mActionLogsReceivedCalls; - HbAction* mActionLogsDialledNumbers; - HbAction* mActionMessageMailboxes; - HbAction* mActionMessages; - HbAction* mActionFilesJpeg25; - HbAction* mActionFilesJpeg200; - HbAction* mActionFilesJpeg500; - HbAction* mActionFilesPng15; - HbAction* mActionFilesGif2; - HbAction* mActionFilesBmp25; - HbAction* mActionFilesJp265; - HbAction* mActionFilesSvg15; - HbAction* mActionFilesTif25; - HbAction* mActionFilesRng1; - HbAction* mActionFilesMidi10; - HbAction* mActionFilesWave20; - HbAction* mActionFilesAmr20; - HbAction* mActionFilesExcel15; - HbAction* mActionFilesWord20; - HbAction* mActionFilesPPoint40; - HbAction* mActionFilesText10; - HbAction* mActionFilesText70; - HbAction* mActionFilesHtml20; - HbAction* mActionFilesMxmf40; - HbAction* mActionFilesRam1; - HbAction* mActionFilesJad1; - HbAction* mActionFilesJar10; - HbAction* mActionFilesVcf1; - HbAction* mActionFilesVcs1; - HbAction* mActionFilesSisx10; - HbAction* mActionFiles3Gpp70; - HbAction* mActionFilesMp3250; - HbAction* mActionFilesAAC100; - HbAction* mActionFilesSwf15; - HbAction* mActionFilesMp4200; - HbAction* mActionFilesRm95; - HbAction* mActionFilesWma50; - HbAction* mActionFilesWmv200; - HbAction* mActionPhonebookContacts; - HbAction* mActionPhonebookGroups; - HbAction* mActionBrowserSavedPages; - HbAction* mActionBrowserSavedPageFolders; - HbAction* mActionFilesEmptyFolder; - HbAction* mActionMiscConnection; - HbAction* mActionMiscImps; - HbAction* mActionMiscNotes; - HbAction* mActionMiscLandmarks; - HbAction* mActionAbout; - HbAction* mActionExit; - HbAction* mActionDeleteAllItems; - HbAction* mActionDeleteCreatorItems; - HbAction* mActionSelectRandomFile; - HbAction* mActionDeleteCalAllItems; - HbAction* mActionDeleteCalCreatorItems; - HbAction* mActionDeleteBookmarkAllItems; - HbAction* mActionDeleteBookmarkCreatorItems; - HbAction* mActionDeleteBookmarkFolderAllItems; - HbAction* mActionDeleteBookmarkFolderCreatorItems; - HbAction* mActionDeleteSavedPagesAllItems; - HbAction* mActionDeleteSavedPagesCreatorItems; - HbAction* mActionDeleteSavedPagesFolderAllItems; - HbAction* mActionDeleteSavedPagesFolderCreatorItems; - HbAction* mActionDeleteFiles; - HbAction* mActionDeleteLogsAll; - HbAction* mActionDeleteLogsByCreator; - HbAction* mActionDeleteMessagesAll; - HbAction* mActionDeleteMessagesByCreator; - HbAction* mActionDeleteConnMethsAll; - HbAction* mActionDeleteConnMethsByCreator; - HbAction* mActionDeleteImpsAll; - HbAction* mActionDeleteImpsByCreator; - HbAction* mActionDeleteNotes; - HbAction* mActionDeleteLandmarksAll; - HbAction* mActionDeleteLandmarksByCreator; - HbAction* mActionDeleteContactsAll; - HbAction* mActionDeleteContactsByCreator; - HbAction* mActionDeleteContactGroupsAll; - HbAction* mActionDeleteContactGroupsByCreator; - - - MemoryDetails mMemoryDetails; - QList mMemoryDetailsList; - // signal mapper - QSignalMapper *mSm; -}; - -#endif // MAINVIEW_H diff -r 819e59dfc032 -r 2d9cac8919d3 creator/inc/notifications.h --- a/creator/inc/notifications.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,149 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#ifndef NOTIFICATIONS_H_ -#define NOTIFICATIONS_H_ - -#include -#include -#include - -#include "engine.h" - -#include - -class HbProgressDialog; -class HbPopup; - -class Notifications : public HbPopup - { - - Q_OBJECT - -public: - /** - * shows massage box - */ - static void showMessageBox(HbMessageBox::MessageBoxType type, const QString &text, const QString &label, int timeout ); - - /** - * shows about box - */ - static void about(); - - /** - * shows error message - */ - static void error(const QString& errorMessage); - - /** - * to shows progressbar - */ - static HbProgressDialog* showProgressBar(const QString& text, int max); - - /** - * shows global HbGlobalCommonNote type note - */ - static void showGlobalNote(const QString& text, HbMessageBox::MessageBoxType type, int timeout = 1000 ); - }; - -class CreatorDialog -{ - Q_DISABLE_COPY(CreatorDialog) -protected: - CreatorDialog(MUIObserver* observer, int userData) throw(std::exception) : mObserver(observer), mUserData(userData) - { - if(!mObserver) - throw std::invalid_argument("module cannot be the null!"); - }; -protected: - virtual void NotifyObserver(TBool aPositiveAction) - { - TRAPD( err, mObserver->QueryDialogClosedL(aPositiveAction, mUserData) ); - if(err) - { - Notifications::error( QString("Symbian Leave: %1 ").arg(err) ); - } - } - -protected: - MUIObserver* mObserver; - int mUserData; -}; - -class CreatorYesNoDialog : public HbMessageBox, public CreatorDialog -{ - Q_DISABLE_COPY(CreatorYesNoDialog) - Q_OBJECT -public: - static void launch(const QString& text, const QString& label, MUIObserver* observer, int userData) throw( std::exception ); -protected: - CreatorYesNoDialog(MUIObserver* observer, int userData); -protected slots: - void DialogClosed(HbAction*); -}; - -class CreatorInputDialog : public HbInputDialog, public CreatorDialog -{ - Q_DISABLE_COPY(CreatorInputDialog) - Q_OBJECT -public: - static void launch(const QString& label, int* value, bool acceptZero, MUIObserver* observer, int userData) throw( std::exception ); - static void launch(const QString& label, TDes& value, MUIObserver* observer, int userData) throw( std::exception ); -protected: - CreatorInputDialog(int* value, MUIObserver* observer, int userData); - CreatorInputDialog(TDes& value, MUIObserver* observer, int userData); -protected slots: - void DialogClosed(HbAction*); -private: - int *mIntValue; - TDes& mStrValue; - TBuf<1> mDummy; -}; - -class CreatorSelectionDialog : public HbSelectionDialog, public CreatorDialog -{ - Q_DISABLE_COPY(CreatorSelectionDialog) - Q_OBJECT -public: - static void launch(const QString& label, const QStringList& items, TInt* selectedItem, MUIObserver* observer, int userData) throw( std::exception ); - static void launch(const QString& label, const QStringList& items, CArrayFixFlat* aSelectedItems, MUIObserver* observer, int userData) throw( std::exception ); -protected: - CreatorSelectionDialog(TInt* selectedItem, MUIObserver* observer, int userData) throw( std::exception ); - CreatorSelectionDialog(CArrayFixFlat* aSelectedItems, MUIObserver* observer, int userData) throw( std::exception ); -protected slots: - void DialogClosed(HbAction*); -private: - TInt* mSelectedItem; - CArrayFixFlat* mSelectedItems; -}; - -class CreatorDateTimeDialog : public HbDialog, public CreatorDialog -{ - Q_DISABLE_COPY(CreatorDateTimeDialog) - Q_OBJECT -public: - static void launch(const QString& label, TTime* value, MUIObserver* observer, int userData) throw( std::exception ); -protected: - CreatorDateTimeDialog(TTime* value, MUIObserver* observer, int userData); -protected slots: - void DialogClosed(HbAction*); -private: - TTime *mValue; -}; -#endif // NOTIFICATIONS_H_ diff -r 819e59dfc032 -r 2d9cac8919d3 creator/rom/creator.iby --- a/creator/rom/creator.iby Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -/* -* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#ifndef __CREATOR_IBY__ -#define __CREATOR_IBY__ - -S60_APP_EXE(Creator) -S60_APP_RESOURCE(Creator) -S60_APP_RESOURCE(datacreator) -SCALABLE_IMAGE(APP_BITMAP_DIR,APP_BITMAP_DIR,Creator) - -data=ZPRIVATE\10003a3f\import\APPS\Creator_reg.RSC Private\10003a3f\import\Apps\Creator_reg.rsc -//#ifdef S60_UPGRADABLE_APP_REG_RSC -// S60_UPGRADABLE_APP_REG_RSC(Creator) -//#else -// S60_APP_AIF_RSC(Creator) -//#endif - -data=ZPRIVATE\20011383\backup_registration.xml private\20011383\backup_registration.xml -data=ZSYSTEM\Install\Creator_stub.sis \system\install\Creator_stub.sis - -// test files (remove largest files if running out of ROM space): -data=ZPRIVATE\20011383\3GPP-70kB.3gpp private\20011383\3GPP-70kB.3gpp -data=ZPRIVATE\20011383\AAC-100kB.aac private\20011383\AAC-100kB.aac -data=ZPRIVATE\20011383\AMR-20kB.amr private\20011383\AMR-20kB.amr -data=ZPRIVATE\20011383\Deck-1kB.saveddeck private\20011383\Deck-1kB.saveddeck -data=ZPRIVATE\20011383\DOC-20kB.doc private\20011383\DOC-20kB.doc -data=ZPRIVATE\20011383\HTML-20kB.html private\20011383\HTML-20kB.html -data=ZPRIVATE\20011383\JAD-1kB.jad private\20011383\JAD-1kB.jad -data=ZPRIVATE\20011383\JAR-10kB.jar private\20011383\JAR-10kB.jar -data=ZPRIVATE\20011383\JP2-65kB.jp2 private\20011383\JP2-65kB.jp2 -data=ZPRIVATE\20011383\MIDI-10kB.mid private\20011383\MIDI-10kB.mid -data=ZPRIVATE\20011383\MP3-250kB.mp3 private\20011383\MP3-250kB.mp3 -data=ZPRIVATE\20011383\MP4-200kB.mp4 private\20011383\MP4-200kB.mp4 -data=ZPRIVATE\20011383\MXMF-40kB.mxmf private\20011383\MXMF-40kB.mxmf -data=ZPRIVATE\20011383\PNG-15kB.png private\20011383\PNG-15kB.png -data=ZPRIVATE\20011383\PPT-40kB.ppt private\20011383\PPT-40kB.ppt -data=ZPRIVATE\20011383\RAM-1kB.ram private\20011383\RAM-1kB.ram -data=ZPRIVATE\20011383\RM-95kB.rm private\20011383\RM-95kB.rm -data=ZPRIVATE\20011383\RNG-1kB.rng private\20011383\RNG-1kB.rng -data=ZPRIVATE\20011383\SVG-15kB.svg private\20011383\SVG-15kB.svg -data=ZPRIVATE\20011383\SWF-15kB.swf private\20011383\SWF-15kB.swf -data=ZPRIVATE\20011383\TIF-25kB.tif private\20011383\TIF-25kB.tif -data=ZPRIVATE\20011383\VCF-1kB.vcf private\20011383\VCF-1kB.vcf -data=ZPRIVATE\20011383\VCS-1kB.vcs private\20011383\VCS-1kB.vcs -data=ZPRIVATE\20011383\WAV-20kB.wav private\20011383\WAV-20kB.wav -data=ZPRIVATE\20011383\XLS-15kB.xls private\20011383\XLS-15kB.xls -data=ZPRIVATE\20011383\SISX-10kB.sisx private\20011383\SISX-10kB.sisx -data=ZPRIVATE\20011383\WMA-50kB.wma private\20011383\WMA-50kB.wma -data=ZPRIVATE\20011383\WMV-200kB.wmv private\20011383\WMV-200kB.wmv - -#endif // __CREATOR_IBY__ diff -r 819e59dfc032 -r 2d9cac8919d3 creator/scripts/browserEx.creatorxml --- a/creator/scripts/browserEx.creatorxml Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,48 +0,0 @@ - - - - - - - Creator bookmark - http://example.net - User - passwd - - - - - - - - - - - - - - - - - Creator bookmarks - - - - - - - Creator saved pages - - - - - - - Creator saved page - - - - - diff -r 819e59dfc032 -r 2d9cac8919d3 creator/scripts/calendarEx.creatorxml --- a/creator/scripts/calendarEx.creatorxml Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,103 +0,0 @@ - - - - - - - - - - - - Project meeting - Let's have a bi-weekly project meeting. Welcome everyone! - Meeting room 1 - 2008-03-27T13:02:57 - 2008-03-27T16:15:00 - weekly - 2 - 2008-03-27 - 2009-03-27 - - - - - John Doe - john.doe@example.net - - - - - - - - - - - - - - - - - - Jane - - - - - - - - - - - Appointment with Jane - 2008-02-29T14:00:00 - 2008-02-29T15:00:00 - - - - - - - - - - - Tech Days - Annual tech days, let's have fun! - 2008-05-01 - 2008-05-03 - - - - - - - Remember to buy Lotto! - 2008-02-28T18:00:00 - 2008-02-28T18:00:00 - - - - - - - - - - - - - - - Should do something...? - 2008-02-29T10:00:00 - 2008-02-29T12:00:00 - - - - diff -r 819e59dfc032 -r 2d9cac8919d3 creator/scripts/connectionmethodEx.creatorxml --- a/creator/scripts/connectionmethodEx.creatorxml Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,54 +0,0 @@ - - - - - - CR_Example - GPRS - http://wap.example.net - connectionoriented - ipv4 - john - no - doe - no - 10.10.10.101 - 255.255.255.0 - 10.10.10.102 - no - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r 819e59dfc032 -r 2d9cac8919d3 creator/scripts/contactEx.creatorxml --- a/creator/scripts/contactEx.creatorxml Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - John - Smith - +35800101010101 - 00101010102 - john.smith@example.com - Mr. - - - - - - - - - - - - - - - ExampleCompany Ltd. - Software Designer - - - - - - - - - - - - - - - diff -r 819e59dfc032 -r 2d9cac8919d3 creator/scripts/creator.xsd --- a/creator/scripts/creator.xsd Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1187 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - There are three different contact related elements: contact, contact-set and contactgroup. The contact element describes one - contact in a database. The contact can be defined explicitly by giving the contact fields and their data, or it can just define the fields to be - used and let the Creator fill the fields with random data. There can also be several same type of fields, for example multiple emailwork fields. - - When contact is defined without fields sub-element, a contact with all fields containing default length random data is created. - - - - - - - - - - - - - - - - - - - - - The contact-set element can be used to bind multiple contacts together and linking them to contactgroups, messages and - calendars. When contact-set is used as a link target it must have a unique id attribute. See example usage of contact-set in - contactEx.creatorxml. - - - - - - - - - - - Amount of members in the group. Indicates how many existing contacts should be taken to the set. - - - - - - - - - - The contactgroup element describes one contact group that should be created to the device's database. - - - - - - - - - - - - - - - - - - - - Note: If alarmtime element is not set, alarm is set as not active and if alarmtime is set, alarm is set to active. - Note: If recurrentfrequency is not set, or set to not-repeated recurrentinterval will be skipped, even if set. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Note: If type is not set, a directory will be created. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Data can have following format: -nn.nnnn - nn.nnnn, where positive latitude means north and negative south, zero - point is Equator. - - - - - - - Data can have following format: -nn.nnnn - nn.nnnn, where positive longitude means east and negative west, zero - point is Prime Meridian. - - - - - - - - Data can have following format: -nn.nnnn - nn.nnnn, where zero point is sea level. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Root element of a Creator script. The sub-elements can be thought as 'commands', e.g. one contact element with explicitly - defined fields create one contact to the database of the device. - - - - - - - - - - Declares the script version. Can be used to indicate the evolution of each script. - - - - - - - Declares the schema version used when designing a script file. This version information must be in sync with the schema used. Schema version is defined - at the beginning of the creator.xsd file in comment block. - - - - - - - \ No newline at end of file diff -r 819e59dfc032 -r 2d9cac8919d3 creator/scripts/filesEx.creatorxml --- a/creator/scripts/filesEx.creatorxml Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,60 +0,0 @@ - - - - - - - - JPEG-25kB - c:\data\images - - - - - - - MIDI-10kB - c:\data\Sounds - - - - - - - - - 3GPP-70kB - c:\data\Videos - - - - - P0Y0M0DT0H21M1S - - 2 - - - - - - - - - GIF-2kB - c:\data\Images - - - - - P0Y0M0DT1H30M0S - - 2008-09-26T13:49:57 - 2009-03-27T16:15:00 - - - - - - diff -r 819e59dfc032 -r 2d9cac8919d3 creator/scripts/impsEx.creatorxml --- a/creator/scripts/impsEx.creatorxml Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,17 +0,0 @@ - - - - - - - Creator_test_imps - - - - - - - - \ No newline at end of file diff -r 819e59dfc032 -r 2d9cac8919d3 creator/scripts/landmarkEx.creatorxml --- a/creator/scripts/landmarkEx.creatorxml Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ - - - - - - - CreatorExample - accommodation - business - communication - educational - entertainment - food - geographical - outdoor - people - public - religious - shopping - sightseeing - sports - transport - This is an example landmark! - Landmark street 1 - 00445 - Landmark City - Landmark State - Landmark Country - 111222333 - http://www.example.net - -76.0023 - 98.1002 - 2 - -4.1 - 3 - - - - - - - - - - - - - - - \ No newline at end of file diff -r 819e59dfc032 -r 2d9cac8919d3 creator/scripts/logEx.creatorxml --- a/creator/scripts/logEx.creatorxml Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ - - - - - - - missed - 2008-03-25T13:11:21 - 1115555554112 - - - - - - - in - 2008-03-24T10:21:56 - 11155554112 - 241 - - - - - - - out - 2008-03-22T12:01:06 - 0555554555 - 445 - - - - - - - - - - - - - - diff -r 819e59dfc032 -r 2d9cac8919d3 creator/scripts/mailboxEx.creatorxml --- a/creator/scripts/mailboxEx.creatorxml Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ - - - - - - cr_pop mail - - - yes - no - no - - - - - - - - cr_imap4 mail - creator@example.net - cc - yes - yes - creator - creator - cr_mail.example.net - no - no - no - getbodytextandattachments - - - diff -r 819e59dfc032 -r 2d9cac8919d3 creator/scripts/messagesEx.creatorxml --- a/creator/scripts/messagesEx.creatorxml Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - - inbox - This is an example SMS created by Creator. - new - - - - - - - sent - Good music! - new - MP3-250kB - - - - - - - - - inbox - - - new - JPEG-200kB - - - - - - 123456 - inbox - This is an example SMS created by Creator. - new - - - - diff -r 819e59dfc032 -r 2d9cac8919d3 creator/scripts/notepadEx.creatorxml --- a/creator/scripts/notepadEx.creatorxml Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,27 +0,0 @@ - - - - - - - This is a Creator example note! - - - - - - - - - - - - - - - - - - diff -r 819e59dfc032 -r 2d9cac8919d3 creator/sis/Creator_stub.pkg --- a/creator/sis/Creator_stub.pkg Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,71 +0,0 @@ -; -; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -; All rights reserved. -; This component and the accompanying materials are made available -; under the terms of "Eclipse Public License v1.0" -; which accompanies this distribution, and is available -; at the URL "http://www.eclipse.org/legal/epl-v10.html". -; -; Initial Contributors: -; Nokia Corporation - initial contribution. -; -; Contributors: -; -; Description: -; - - -; Language - standard language definitions -&EN - -; Standard SIS file header -#{"Creator"},(0x20011383),1,0,0 - -; Non-localised vendor name -:"Nokia Corporation" - -; Localised vendor names -%{"Nokia Corporation"} - -; normal stuff: -""-"z:\sys\bin\creator.exe" -""-"z:\resource\apps\creator.mif" -""-"z:\resource\apps\creator.rsc" -""-"z:\resource\apps\datacreator.rsc" -""-"z:\private\10003a3f\import\apps\creator_reg.rsc" -""-"z:\private\20011383\backup_registration.xml" - -; test data: -""-"z:\private\20011383\3GPP-70kB.3gpp" -""-"z:\private\20011383\AAC-100kB.aac" -""-"z:\private\20011383\AMR-20kB.amr" -""-"z:\private\20011383\BMP-25kB.bmp" -""-"z:\private\20011383\Deck-1kB.saveddeck" -""-"z:\private\20011383\DOC-20kB.doc" -""-"z:\private\20011383\GIF-2kB.gif" -""-"z:\private\20011383\HTML-20kB.html" -""-"z:\private\20011383\JAD-1kB.jad" -""-"z:\private\20011383\JAR-10kB.jar" -""-"z:\private\20011383\JP2-65kB.jp2" -""-"z:\private\20011383\JPEG-200kB.jpg" -""-"z:\private\20011383\JPEG-25kB.jpg" -""-"z:\private\20011383\JPEG-500kB.jpg" -""-"z:\private\20011383\MIDI-10kB.mid" -""-"z:\private\20011383\MP3-250kB.mp3" -""-"z:\private\20011383\MP4-200kB.mp4" -""-"z:\private\20011383\MXMF-40kB.mxmf" -""-"z:\private\20011383\PNG-15kB.png" -""-"z:\private\20011383\PPT-40kB.ppt" -""-"z:\private\20011383\RAM-1kB.ram" -""-"z:\private\20011383\RM-95kB.rm" -""-"z:\private\20011383\RNG-1kB.rng" -""-"z:\private\20011383\SVG-15kB.svg" -""-"z:\private\20011383\SWF-15kB.swf" -""-"z:\private\20011383\TIF-25kB.tif" -""-"z:\private\20011383\TXT-10kB.txt" -""-"z:\private\20011383\TXT-70kB.txt" -""-"z:\private\20011383\VCF-1kB.vcf" -""-"z:\private\20011383\VCS-1kB.vcs" -""-"z:\private\20011383\WAV-20kB.wav" -""-"z:\private\20011383\XLS-15kB.xls" -""-"z:\private\20011383\SISX-10kB.sisx" diff -r 819e59dfc032 -r 2d9cac8919d3 creator/src/engine.cpp --- a/creator/src/engine.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2610 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#include -#include -#include - -#include - -#include - -#include "mainview.h" -#include "engine.h" -#include "enginewrapper.h" - - -#include //For Math - -#include "creator_scriptentry.h" -#include "creator_modulebase.h" -//#include "creator_browser.h" -#include "creator_calendar.h" -#include "creator_phonebookbase.h" -#include "creator_note.h" -#include "creator_log.h" -//#include "creator_connectionmethodbase.h" -#include "creator_mailbox.h" -//#include "creator_imps.h" -#include "creator_message.h" -#include "creator_landmark.h" - - -#include "creator_traces.h" -#include "creator_factory.h" -#include "creator_scriptparser.h" -#include "creator_file.h" -#include "creator_cmdscriptrun.h" -#include "creator_contactsetcache.h" - -#include -#include -#include -#include - -_LIT(KTempPathDrive, "d"); -_LIT(KTempPath, ":\\Creator\\"); -const TInt KRegisterDrive = EDriveC; -_LIT(KRegisterFileName, "creator_created_items.dat"); -_LIT(KResourceFileName, "z:\\Resource\\apps\\datacreator.RSC"); - - -// --------------------------------------------------------------------------- - -CCreatorEngine* CCreatorEngine::NewL(EngineWrapper *aEngineWrapper) - { - CCreatorEngine* self = CCreatorEngine::NewLC(aEngineWrapper); - CleanupStack::Pop(); // self; - return self; - } - -// --------------------------------------------------------------------------- - -CCreatorEngine* CCreatorEngine::NewLC(EngineWrapper *aEngineWrapper) - { - CCreatorEngine* self = new (ELeave) CCreatorEngine(); - CleanupStack::PushL(self); - self->ConstructL(aEngineWrapper); - return self; - } - -// --------------------------------------------------------------------------- - -CCreatorEngine::CCreatorEngine() -: -CActive(0) -{} - -// --------------------------------------------------------------------------- - -void CCreatorEngine::ConstructL(EngineWrapper *aEngineWrapper) - { - LOGSTRING("Creator: CCreatorEngine::ConstructL"); - - iEngineWrapper = aEngineWrapper; - iMemoryDetails.iENotAvailable = EFalse; - RequestMemoryDetails(); - iEnv = CEikonEnv::Static(); - // add second resource file to use for creator random data generation: - iResourceFileId = iEnv->AddResourceFileL(KResourceFileName); - User::LeaveIfError(iTimer.CreateLocal()); - - // these are needed by the random data generator - TTime now; - now.HomeTime(); - iSeed=now.Int64(); - - iTempPath = HBufC::NewL(KTempPathDrive().Length() + KTempPath().Length()); - iTempPath->Des().Copy(KTempPathDrive); - iTempPath->Des().Append(KTempPath); - - iCmdScriptRun = CCreatorCmdScriptRun::NewL(this); - - GetRandomDataFromFileL(KNullDesC); - - CActiveScheduler::Add(this); - - } - -// --------------------------------------------------------------------------- - -CCreatorEngine::~CCreatorEngine() - { - LOGSTRING("Creator: CCreatorEngine::~CCreatorEngine"); - - Cancel(); - - for( TInt i = 0; i < iStringArrays.Count(); ++i ) - { - delete iStringArrays[i].iArrayPtr; - } - iStringArrays.Close(); - iAllocatedFilePaths.ResetAndDestroy(); - iAllocatedFilePaths.Close(); - iTimer.Close(); - - - iEnv->DeleteResourceFile(iResourceFileId); - - iMemoryDetailsList.Reset(); - delete iPictureFileArray; - delete iSoundFileArray; - delete iTempPath; - delete iFrameImageData; - delete iEncoder; - delete iScaler; - delete iDecoder; - delete iScaledBitmap; - delete iBitmap; - delete iBitmapData; - - delete iCmdScriptRun; - iCmdScriptRun = NULL; - - delete iCommandParser; - } - -void CCreatorEngine::CopyFileL(const TFileName& aSourceFile, const TFileName& aTargetFile, TBool aOverwrite ) - { - if( !aOverwrite && ConeUtils::FileExists(aTargetFile)) - { - // File already exists - return; - } - - // Make sure that the path exists. Creates the directory if it does not exist already: - ConeUtils::EnsurePathExistsL(aTargetFile); - User::LeaveIfError(BaflUtils::CopyFile(CEikonEnv::Static()->FsSession(), aSourceFile, aTargetFile)); - } - -// --------------------------------------------------------------------------- - -void CCreatorEngine::RequestMemoryDetails() - { - - TDriveList dl; - // variables for memory and disk handling - TVolumeInfo vinfo; - - //************************************************************************* - - //************************************************************************* - // get an access to file server - RFs& fsSession = CEikonEnv::Static()->FsSession(); - - fsSession.DriveList(dl); - - for(TInt driveNum = EDriveC; driveNum <= EDriveZ ; driveNum ++ ) - { - if( dl[driveNum] ) - { - TMemoryDetails *memDet = new TMemoryDetails; - if(fsSession.Volume(vinfo, driveNum) == KErrNone) - { - memDet->iFree.Num(TInt64(vinfo.iFree/1024)); - memDet->iSize.Num(TInt64(vinfo.iSize/1024)); - } - else - { - memDet->iFree.Num( 0 ); - memDet->iSize.Num( 0 ); - } - User::LeaveIfError(fsSession.DriveToChar(driveNum,memDet->iDriveLetter)); - iMemoryDetailsList.AppendL( memDet ); - } - } - - // available work memory - TMemoryInfoV1Buf memory; - UserHal::MemoryInfo(memory); - TInt64 freeMemBytes=(TInt64)(memory().iFreeRamInBytes); - TInt64 sizeMemBytes=(TInt64)(memory().iTotalRamInBytes); - TInt64 sizeWorkMemBytes = sizeMemBytes; - TInt64 sizeRomBytes = (TInt64)(memory().iTotalRomInBytes); - iMemoryDetails.iRamFree.Num(TInt64(freeMemBytes/1024)); - iMemoryDetails.iRamSize.Num(TInt64(sizeWorkMemBytes/1024)); - iMemoryDetails.iRomSize.Num(TInt64(sizeRomBytes/1024)); - } - -// --------------------------------------------------------------------------- - -TBool CCreatorEngine::MMC_OK() const - { - TBool MMCstatus = EFalse; - - TDriveNumber eDrive=EDriveE; - TVolumeInfo vinfo; - TInt err = CEikonEnv::Static()->FsSession().Volume(vinfo, eDrive); - // check if we can access the E-drive: - if ( err == KErrNone) - { - MMCstatus = ETrue; - } - else - { - MMCstatus = EFalse; - } - - // returns ETrue if MMC working properly - return MMCstatus; - } - -// --------------------------------------------------------------------------- - -void CCreatorEngine::ExecuteFirstCommandL(const TDesC& aText) - { - LOGSTRING("Creator: CCreatorEngine::ExecuteFirstCommand"); - - if( !iCommandArray->Count()) - { - ShutDownEnginesL(); - return; - } - - // show a progress dialog - iEngineWrapper->ShowProgressBar(aText, CommandArrayCount()); - - iFailedCommands = 0; - - // starts executing commands - ExecuteCommand(); - - - } - -// --------------------------------------------------------------------------- - -void CCreatorEngine::ExecuteCommand() - { - LOGSTRING("Creator: CCreatorEngine::ExecuteCommand"); - - // make sure the engine isn't active, should never happen - __ASSERT_ALWAYS(!IsActive(), User::Panic(_L("IsActive"), 500)); - - // execute a command after a very short delay (75ms) - iTimer.After(iStatus, 75); - SetActive(); - } - -// --------------------------------------------------------------------------- - -void CCreatorEngine::RunL() - { - LOGSTRING("Creator: CCreatorEngine::RunL"); - LOGSTRING2("Creator: CCreatorEngine::RunL iCommandId=%d", iCommandArray->At(iCurrentEntry).iCommandId); - - if ( iUserCancelled ) - { - return; - } - - if (!iCommandArray->At(iCurrentEntry).iParameters) - { - LOGSTRING("Creator: CCreatorEngine::RunL - iParameters==NULL !"); - } - - // launch a command - - TCreatorIds cmd = (TCreatorIds)iCommandArray->At(iCurrentEntry).iCommandId; - switch( cmd ) - { -/* - case ECmdCreateBrowserBookmarkEntries: { iBrowser->CreateBookmarkEntryL(reinterpret_cast(iCommandArray->At(iCurrentEntry).iParameters)); } break; - case ECmdCreateBrowserBookmarkFolderEntries: { iBrowser->CreateBookmarkFolderEntryL(reinterpret_cast(iCommandArray->At(iCurrentEntry).iParameters)); } break; - case ECmdCreateBrowserSavedPageEntries: { iBrowser->CreateSavedDeckEntryL(reinterpret_cast(iCommandArray->At(iCurrentEntry).iParameters)); } break; - case ECmdCreateBrowserSavedPageFolderEntries: { iBrowser->CreateSavedDeckFolderEntryL(reinterpret_cast(iCommandArray->At(iCurrentEntry).iParameters)); } break; -*/ - case ECmdCreateCalendarEntryAppointments: { iCalendar->CreateAppointmentEntryL(iCommandArray->At(iCurrentEntry).iParameters); } break; - case ECmdCreateCalendarEntryEvents: { iCalendar->CreateEventEntryL(iCommandArray->At(iCurrentEntry).iParameters); } break; - case ECmdCreateCalendarEntryAnniversaries: { iCalendar->CreateAnniversaryEntryL(iCommandArray->At(iCurrentEntry).iParameters); } break; - case ECmdCreateCalendarEntryToDos: { iCalendar->CreateTodoEntryL(iCommandArray->At(iCurrentEntry).iParameters); } break; - case ECmdCreateCalendarEntryReminders: { iCalendar->CreateReminderEntryL(iCommandArray->At(iCurrentEntry).iParameters); } break; - - - case ECmdCreatePhoneBookEntryContacts: { iPhonebook->CreateContactEntryL(iCommandArray->At(iCurrentEntry).iParameters) ; } break; - case ECmdCreatePhoneBookEntryGroups: { iPhonebook->CreateGroupEntryL(iCommandArray->At(iCurrentEntry).iParameters) ; } break; - case ECmdCreatePhoneBookEntrySubscribedContacts: { iPhonebook->CreateSubscribedContactEntryL(iCommandArray->At(iCurrentEntry).iParameters) ; } break; - - case ECmdCreateMiscEntryNotes: { iNotepad->CreateNoteEntryL(reinterpret_cast(iCommandArray->At(iCurrentEntry).iParameters)); } break; - - case ECmdCreateLogEntryMissedCalls: { iLogs->CreateMissedCallEntryL(reinterpret_cast(iCommandArray->At(iCurrentEntry).iParameters)); } break; - case ECmdCreateLogEntryReceivedCalls: { iLogs->CreateReceivedCallEntryL(reinterpret_cast(iCommandArray->At(iCurrentEntry).iParameters)); } break; - case ECmdCreateLogEntryDialledNumbers: { iLogs->CreateDialledNumberEntryL(reinterpret_cast(iCommandArray->At(iCurrentEntry).iParameters)); } break; -/* - case ECmdCreateMiscEntryAccessPoints: { iAccessPoints->CreateConnectionSettingsEntryL(iCommandArray->At(iCurrentEntry).iParameters); } break; - case ECmdDeleteIAPs: { iAccessPoints->DeleteAllL(); } break; - case ECmdDeleteCreatorIAPs: { iAccessPoints->DeleteAllCreatedByCreatorL(); } break; -*/ - case ECmdCreateMiscEntryLandmarks: { iLandmarks->CreateLandmarkEntryL(reinterpret_cast(iCommandArray->At(iCurrentEntry).iParameters)); } break; - - case ECmdCreateMessagingEntryMailboxes: { iMailboxes->CreateMailboxEntryL(reinterpret_cast(iCommandArray->At(iCurrentEntry).iParameters)); } break; -/* - #ifdef __PRESENCE - case ECmdCreateMiscEntryIMPSServers: { iIMPS->CreateIMPSServerEntryL(reinterpret_cast(iCommandArray->At(iCurrentEntry).iParameters)); } break; - #endif -*/ - case ECmdCreateMessagingEntryMessages: { iMessages->CreateMessageEntryL(reinterpret_cast(iCommandArray->At(iCurrentEntry).iParameters), ETrue); } break; - case ECmdCreateMessagingEntryMessagesViaScript: { iMessages->CreateMessageEntryL(reinterpret_cast(iCommandArray->At(iCurrentEntry).iParameters)); } break; - - case ECmdCreateRandomEntrySMSInbox: - case ECmdCreateRandomEntrySMSDrafts: - case ECmdCreateRandomEntrySMSOutbox: - case ECmdCreateRandomEntrySMSSent: - case ECmdCreateRandomEntryMMSInbox: - case ECmdCreateRandomEntryMMSDrafts: - case ECmdCreateRandomEntryMMSOutbox: - case ECmdCreateRandomEntryMMSSent: - case ECmdCreateRandomEntryAMSInbox: - case ECmdCreateRandomEntryAMSDrafts: - case ECmdCreateRandomEntryAMSOutbox: - case ECmdCreateRandomEntryAMSSent: - case ECmdCreateRandomEntryEmailInbox: - case ECmdCreateRandomEntryEmailDrafts: - case ECmdCreateRandomEntryEmailOutbox: - case ECmdCreateRandomEntryEmailSent: - case ECmdCreateRandomEntryBIOInbox: - case ECmdCreateRandomEntryBIODrafts: - case ECmdCreateRandomEntryBIOOutbox: - case ECmdCreateRandomEntryBIOSent: - case ECmdCreateRandomEntryIRInbox: - case ECmdCreateRandomEntryIRDrafts: - case ECmdCreateRandomEntryIROutbox: - case ECmdCreateRandomEntryIRSent: - case ECmdCreateRandomEntryBTInbox: - case ECmdCreateRandomEntryBTDrafts: - case ECmdCreateRandomEntryBTOutbox: - case ECmdCreateRandomEntryBTSent: - { iMessages->CreateRandomMessageEntryL(iCommandArray->At(iCurrentEntry).iCommandId); } break; - - case ECmdCreateFileEntryEmptyFolder: - case ECmdCreateFileEntry3GPP_70kB: - case ECmdCreateFileEntryAAC_100kB: - case ECmdCreateFileEntryAMR_20kB: - case ECmdCreateFileEntryBMP_25kB: - case ECmdCreateFileEntryDeck_1kB: - case ECmdCreateFileEntryDOC_20kB: - case ECmdCreateFileEntryGIF_2kB: - case ECmdCreateFileEntryHTML_20kB: - case ECmdCreateFileEntryJAD_1kB: - case ECmdCreateFileEntryJAR_10kB: - case ECmdCreateFileEntryJP2_65kB: - case ECmdCreateFileEntryJPEG_200kB: - case ECmdCreateFileEntryJPEG_25kB: - case ECmdCreateFileEntryJPEG_500kB: - case ECmdCreateFileEntryMIDI_10kB: - case ECmdCreateFileEntryMP3_250kB: - case ECmdCreateFileEntryMP4_200kB: - case ECmdCreateFileEntryMXMF_40kB: - case ECmdCreateFileEntryPNG_15kB: - case ECmdCreateFileEntryPPT_40kB: - case ECmdCreateFileEntryRAM_1kB: - case ECmdCreateFileEntryRM_95kB: - case ECmdCreateFileEntryRNG_1kB: - case ECmdCreateFileEntrySVG_15kB: - case ECmdCreateFileEntrySWF_15kB: - case ECmdCreateFileEntryTIF_25kB: - case ECmdCreateFileEntryTXT_10kB: - case ECmdCreateFileEntryTXT_70kB: - case ECmdCreateFileEntryVCF_1kB: - case ECmdCreateFileEntryVCS_1kB: - case ECmdCreateFileEntryWAV_20kB: - case ECmdCreateFileEntryXLS_15kB: - case ECmdCreateFileEntrySISX_10kB: - case ECmdCreateFileEntryWMA_50kB: - case ECmdCreateFileEntryWMV_200kB: - { iFiles->CreateFileEntryL( reinterpret_cast(iCommandArray->At(iCurrentEntry).iParameters), iCommandArray->At(iCurrentEntry).iCommandId ); } break; - case ECmdDeleteContacts: - { - iPhonebook->DeleteAllL(); - break; - } - case ECmdDeleteContactGroups: - { - iPhonebook->DeleteAllGroupsL(); - break; - } - case ECmdDeleteCreatorContacts: - { - iPhonebook->DeleteAllCreatedByCreatorL(); - break; - } - case ECmdDeleteCreatorContactGroups: - { - iPhonebook->DeleteAllGroupsCreatedByCreatorL(); - break; - } - case ECmdDeleteCalendarEntries: - { - iCalendar->DeleteAllL(); - break; - } - case ECmdDeleteCreatorCalendarEntries: - { - iCalendar->DeleteAllCreatedByCreatorL(); - break; - } - case ECmdDeleteLogs: - { - iLogs->DeleteAllL(); - break; - } - case ECmdDeleteCreatorLogs: - { - iLogs->DeleteAllCreatedByCreatorL(); - break; - } - case ECmdDeleteMessages: - { - iMessages->DeleteAllL(); - break; - } - case ECmdDeleteCreatorMessages: - { - iMessages->DeleteAllCreatedByCreatorL(); - break; - } - case ECmdDeleteLandmarks: - { - iLandmarks->DeleteAllL(); - break; - } - case ECmdDeleteCreatorLandmarks: - { - iLandmarks->DeleteAllCreatedByCreatorL(); - break; - } - case ECmdDeleteMailboxes: - { - iMailboxes->DeleteAllL(); - break; - } - case ECmdDeleteCreatorMailboxes: - { - iMailboxes->DeleteAllCreatedByCreatorL(); - break; - } - - case ECmdDeleteNotes: - { - iNotepad->DeleteAllL(); - break; - } - - case ECmdDeleteIMPSs: - { -// iIMPS->DeleteAllL(); - break; - } - case ECmdDeleteCreatorIMPSs: - { -// iIMPS->DeleteAllCreatedByCreatorL(); - break; - } -/* - case ECmdDeleteBrowserBookmarks: - { - iBrowser->DeleteAllBookmarksL(); - break; - } - case ECmdDeleteCreatorBrowserBookmarks: - { - iBrowser->DeleteAllBookmarksCreatedByCreatorL(); - break; - } - case ECmdDeleteBrowserBookmarkFolders: - { - iBrowser->DeleteAllBookmarkFoldersL(); - break; - } - case ECmdDeleteCreatorBrowserBookmarkFolders: - { - iBrowser->DeleteAllBookmarkFoldersCreatedByCreatorL(); - break; - } - case ECmdDeleteBrowserSavedPages: - { - iBrowser->DeleteAllSavedPagesL(); - break; - } - case ECmdDeleteCreatorBrowserSavedPages: - { - iBrowser->DeleteAllSavedPagesCreatedByCreatorL(); - break; - } - case ECmdDeleteBrowserSavedPageFolders: - { - iBrowser->DeleteAllSavedPageFoldersL(); - break; - } - case ECmdDeleteCreatorBrowserSavedPageFolders: - { - iBrowser->DeleteAllSavedPageFoldersCreatedByCreatorL(); - break; - } -*/ - case ECmdDeleteCreatorFiles: - { - iFiles->DeleteAllCreatedByCreatorL(); - break; - } - default: - User::Panic (_L("ExecuteOptionsMenuCommandL"), 205); - break; - } - - TRAP_IGNORE( CheckForMoreCommandsL() ); - - } - -CDesCArrayFlat* CCreatorEngine::PictureFilesL() - { - if( iPictureFileArray == 0 ) - { - _LIT(KImageFile, "JPEG*.jpg"); - _LIT(KImageFileDir, "C:\\Data\\"); - _LIT(KImageFileDir2, "Z:\\Data\\"); - iPictureFileArray = new (ELeave) CDesCArrayFlat(8); - TInt err = CreatorFileUtils::FindFilesRecursiveL(iPictureFileArray, KImageFile, KImageFileDir); - if( iPictureFileArray->Count() == 0 ) - { - err = CreatorFileUtils::FindFilesRecursiveL(iPictureFileArray, KImageFile, KImageFileDir2); - } - } - return iPictureFileArray; - } - -CDesCArrayFlat* CCreatorEngine::SoundFilesL() - { - if( iSoundFileArray == 0 ) - { - _LIT(KSoundFile, "*.aac"); - _LIT(KSoundFileDir, "Z:\\data\\Sounds\\"); - iSoundFileArray = new (ELeave) CDesCArrayFlat(8); - TInt err = CreatorFileUtils::FindFilesRecursiveL(iSoundFileArray, KSoundFile, KSoundFileDir); - } - return iSoundFileArray; - } -// --------------------------------------------------------------------------- - -TInt CCreatorEngine::RunError(TInt aError) - { - LOGSTRING2("Creator: CCreatorEngine::RunError %d", aError); - - iFailedCommands++; - - _LIT(KMessage, "Command error %d"); - TBuf<128> noteMsg; - noteMsg.Format(KMessage, aError); -// iEnv->InfoMsg(noteMsg); - iEngineWrapper->ShowNote(noteMsg); - TRAP_IGNORE( CheckForMoreCommandsL() ); - - return KErrNone; - } - -// --------------------------------------------------------------------------- - -void CCreatorEngine::CheckForMoreCommandsL() - { - LOGSTRING("Creator: CCreatorEngine::CheckForMoreCommandsL"); - if ( iUserCancelled ) - { - return; - } - // update the progress bar - //iProgressInfo->IncrementAndDraw(1); - iEngineWrapper->IncrementProgressbarValue(); - - // check if we have more commands to be executed - if (iCurrentEntry >= CommandArrayCount() - 1) - { - LOGSTRING("Creator: CCreatorEngine::CheckForMoreCommandsL all done"); - - // all done, free resources and show a note - ShutDownEnginesL(); - - //iProgressDialog->ProcessFinishedL(); - - // remove the progress dialog from the screen - iEngineWrapper->CloseProgressbar(); - - if (iFailedCommands == 0) - { - iEngineWrapper->ShowNote(_L("Done")); - } - else - { - _LIT(KMessage, "Done, %d commands failed"); - TBuf<128> noteMsg; - noteMsg.Format(KMessage, iFailedCommands); - iEngineWrapper->ShowNote(noteMsg); - } - - iCmdScriptRun->RunScriptDone(); - - } - else - { - // maintain requests - iCurrentEntry++; - - LOGSTRING2("Creator: CCreatorEngine::CheckForMoreCommandsL iCurrentEntry=%d", iCurrentEntry); - - ExecuteCommand(); - } - } - -// --------------------------------------------------------------------------- -void CCreatorEngine::SortCommands() - { - TKeyArrayFix iBufKey(_FOFF(TCommand, iCommandId),ECmpTInt); - iCommandArray->Sort(iBufKey); - } -// --------------------------------------------------------------------------- - -// This callback function is called when cancel button of the progress bar was pressed - -void CCreatorEngine::ProgressDialogCancelledL() - { - LOGSTRING("Creator: CCreatorEngine::ProgressDialogCancelledL"); - - iUserCancelled = ETrue; - // cancel the active object, command executer - Cancel(); - - // delete parameters from the command array, otherwise there might be memory leaks - for (TInt i=iCurrentEntry; iAt(i).iParameters ) - { - delete iCommandArray->At(i).iParameters; - iCommandArray->At(i).iParameters = NULL; - } - } - - if ( iDecoder ) - { - iDecoder->Cancel(); - // CancelComplete() will be called from GenerateSourceImageFileL - } - else if ( iScaler ) - { - iScaler->Cancel(); - // CancelComplete() will be called from GenerateSourceImageFileL - } - else if ( iEncoder ) - { - iEncoder->Cancel(); - // CancelComplete() will be called from GenerateSourceImageFileL - } - else - { - // free resources and show a note - ShutDownEnginesL(); - iEngineWrapper->ShowNote(_L("Cancelled")); - } - - } - -// --------------------------------------------------------------------------- - -void CCreatorEngine::StartEnginesL() - { - LOGSTRING("Creator: CCreatorEngine::StartEnginesL"); - - // reset user cancel flag - iUserCancelled = EFalse; - - // start from the beginning - iCurrentEntry = 0; - - // init the command array - __ASSERT_ALWAYS(!iCommandArray, User::Panic(_L("iCommandArray"), 701)); - iCommandArray = new(ELeave) CCommandArray(10000); - - // init all modules here - TInt err(KErrNone); -// TRAP(err, iBrowser = CCreatorBrowser::NewL(this)); - TRAP(err, iCalendar = CCreatorInterimCalendar::NewL(this)); - TRAP(err, iPhonebook = (CCreatorPhonebookBase*)TCreatorFactory::CreatePhoneBookL(this)); - TRAP(err, iNotepad = CCreatorNotepad::NewL(this)); - TRAP(err, iLogs = CCreatorLogs::NewL(this)); -// TRAP(err, iAccessPoints = (CCreatorConnectionSettingsBase*)TCreatorFactory::CreateConnectionSettingsL(this)); - TRAP(err, iMailboxes = CCreatorMailboxes::NewL(this)); - TRAP(err, iFiles = CCreatorFiles::NewL(this)); - TRAP(err, iMessages = CCreatorMessages::NewL(this)); - TRAP(err, iLandmarks = CCreatorLandmarks::NewL(this)); - ContactLinkCache::InitializeL(); -/* - #ifdef __PRESENCE - TRAP(err, iIMPS = CCreatorIMPS::NewL(this)); - #endif -*/ - - - // ... - // ... - // ... - - } -// --------------------------------------------------------------------------- - -void CCreatorEngine::ShutDownEnginesL() - { - LOGSTRING("Creator: CCreatorEngine::ShutDownEnginesL"); - - - // delete all modules here and free resources which aren't anymore needed - -/* - #ifdef __PRESENCE - delete iIMPS; - iIMPS = NULL; - #endif -*/ - delete iMessages; - iMessages = NULL; - delete iFiles; - iFiles = NULL; - delete iMailboxes; - iMailboxes = NULL; - // delete iAccessPoints; -// iAccessPoints = NULL; - delete iLogs; - iLogs = NULL; - delete iNotepad; - iNotepad = NULL; - delete iPhonebook; - iPhonebook = NULL; - delete iCalendar; - iCalendar = NULL; - // delete iBrowser; - // iBrowser = NULL; - delete iLandmarks; - iLandmarks = NULL; - - ContactLinkCache::DestroyL(); - // now delete the command array - delete iCommandArray; - iCommandArray = NULL; - - // delete parameter array - iParameterArray.ResetAndDestroy(); - iParameterArray.Close(); - - if(iCommandParser) - { - delete iCommandParser; - iCommandParser = NULL; - } - - - // clear temp drive - CFileMan* fileMan = CFileMan::NewL( iEnv->FsSession() ); - CleanupStack::PushL( fileMan ); - fileMan->RmDir( iTempPath->Des() ); - CleanupStack::PopAndDestroy(); //fileMan - } - -// --------------------------------------------------------------------------- - -void CCreatorEngine::DoCancel() - { - LOGSTRING("Creator: CCreatorEngine::DoCancel"); - - iTimer.Cancel(); - } - -void CCreatorEngine::ScriptChosenL( TBool aSuccess, const TDesC& aFileName ) - { - if( aSuccess ) - { - // open the file for reading - RFile scriptFile; - User::LeaveIfError( scriptFile.Open( iEnv->FsSession(), aFileName, EFileRead ) ); - CleanupClosePushL(scriptFile); - - - // wait dialog - /* TODO - CAknGlobalNote* waitDialog = CAknGlobalNote::NewLC(); - waitDialog->SetSoftkeys( R_AVKON_SOFTKEYS_CANCEL ); - TInt dialogId = waitDialog->ShowNoteL( EAknGlobalWaitNote, _L("Parsing") ); - */ - TInt parseErr( KErrNone ); - CCreatorScriptParser* scriptParser = CCreatorScriptParser::NewLC(this); - scriptParser->ParseL(scriptFile); - parseErr = scriptParser->GetError(); - CleanupStack::PopAndDestroy( scriptParser ); - - CleanupStack::PopAndDestroy( &scriptFile ); - - //waitDialog->CancelNoteL( dialogId ); - //CleanupStack::PopAndDestroy( waitDialog ); - - if(parseErr != KErrNone) - { - // show error note - _LIT(KErrMsg, "Parser error: %d"); - TBuf<32> msgBuf; - msgBuf.Format(KErrMsg, parseErr); - iEngineWrapper->ShowErrorMessage(msgBuf); - ShutDownEnginesL(); - return; - } - } - - // start executing commands if commands in the command array - if (CommandArrayCount() > 0) - { - ExecuteFirstCommandL( KSavingText ); - } - else - { - ShutDownEnginesL(); - } - } -// --------------------------------------------------------------------------- - -void CCreatorEngine::RunScriptL() - { - LOGSTRING("Creator: CCreatorEngine::RunScriptL"); - - // startup modules (also inits the command array): - StartEnginesL(); - - // use the command parser module to init the command array from a script file - delete iCommandParser; - iCommandParser = NULL; - iCommandParser = CCommandParser::NewL(this); - TBool ret = EFalse; - TRAPD(err, ret = iCommandParser->OpenScriptL( this ) ); - if( err != KErrNone || ret == EFalse) - { - ShutDownEnginesL(); - User::LeaveIfError(err); - } - } - -// --------------------------------------------------------------------------- - -TInt CCreatorEngine::RunScriptL(const TDesC& aScriptFile) - { - LOGSTRING("Creator: CCreatorEngine::RunScriptL"); - - // startup modules (also inits the command array): - StartEnginesL(); - - RFile scriptFile; - if (scriptFile.Open(CEikonEnv::Static()->FsSession(), aScriptFile, EFileRead) != KErrNone) - { - ShutDownEnginesL(); - return KErrNotFound; // file error - } - - CleanupClosePushL(scriptFile); - CCreatorScriptParser* scriptParser = CCreatorScriptParser::NewLC(this); - scriptParser->ParseL(scriptFile); - TInt err = scriptParser->GetError(); - CleanupStack::PopAndDestroy(); //scriptParser - CleanupStack::Pop(); // scriptFile - scriptFile.Close(); - - if (err != KErrNone) - { - ShutDownEnginesL(); - return KErrCorrupt; // parser error - } - - // start executing commands if commands in the command array - if (CommandArrayCount() > 0) - { - ExecuteFirstCommandL( KSavingText ); - return KErrNone; // executing commands is started - } - else - { - ShutDownEnginesL(); - return KErrCompletion; // nothing to do - } - } - -// --------------------------------------------------------------------------- -void CCreatorEngine::QueryDialogClosedL( TBool aPositiveAction, TInt aUserData ) - { - LOGSTRING("Creator: CCreatorEngine::QueryDialogClosedL"); - - if( aPositiveAction == EFalse ) - { - ShutDownEnginesL(); - return; - } - - switch(aUserData) - { - case ECreatorEngineDeleteAllEntries: - AppendToCommandArrayL( ECmdDeleteContacts, NULL, 1 ); - AppendToCommandArrayL( ECmdDeleteContactGroups, NULL, 1 ); - AppendToCommandArrayL( ECmdDeleteCalendarEntries, NULL, 1 ); - //AppendToCommandArrayL( ECmdDeleteBrowserBookmarks, NULL, 1 ); - //AppendToCommandArrayL( ECmdDeleteBrowserBookmarkFolders, NULL, 1 ); - //AppendToCommandArrayL( ECmdDeleteBrowserSavedPages, NULL, 1 ); - //AppendToCommandArrayL( ECmdDeleteBrowserSavedPageFolders, NULL, 1 ); - AppendToCommandArrayL( ECmdDeleteLogs, NULL, 1 ); - AppendToCommandArrayL( ECmdDeleteMessages, NULL, 1 ); - //AppendToCommandArrayL( ECmdDeleteIAPs, NULL, 1 ); - //AppendToCommandArrayL( ECmdDeleteIMPSs, NULL, 1 ); - AppendToCommandArrayL( ECmdDeleteNotes, NULL, 1 ); - AppendToCommandArrayL( ECmdDeleteLandmarks, NULL, 1 ); - AppendToCommandArrayL( ECmdDeleteCreatorFiles, NULL, 1 ); - - // started exucuting delete commands - ExecuteFirstCommandL( KDeletingText ); - break; - case ECreatorEngineDeleteAllCreatorEntries: - AppendToCommandArrayL( ECmdDeleteCreatorContacts, NULL, 1 ); - AppendToCommandArrayL( ECmdDeleteCreatorContactGroups, NULL, 1 ); - AppendToCommandArrayL( ECmdDeleteCreatorCalendarEntries, NULL, 1 ); - /* - AppendToCommandArrayL( ECmdDeleteCreatorBrowserBookmarks, NULL, 1 ); - AppendToCommandArrayL( ECmdDeleteCreatorBrowserBookmarkFolders, NULL, 1 ); - AppendToCommandArrayL( ECmdDeleteCreatorBrowserSavedPages, NULL, 1 ); - AppendToCommandArrayL( ECmdDeleteCreatorBrowserSavedPageFolders, NULL, 1 ); - */ - AppendToCommandArrayL( ECmdDeleteCreatorFiles, NULL, 1 ); - AppendToCommandArrayL( ECmdDeleteCreatorLogs, NULL, 1 ); - AppendToCommandArrayL( ECmdDeleteCreatorMessages, NULL, 1 ); - //AppendToCommandArrayL( ECmdDeleteCreatorIAPs, NULL, 1 ); - //AppendToCommandArrayL( ECmdDeleteCreatorIMPSs, NULL, 1 ); - AppendToCommandArrayL( ECmdDeleteCreatorLandmarks, NULL, 1 ); - - // started exucuting delete commands - ExecuteFirstCommandL( KDeletingText ); - break; - default: - //some error - ShutDownEnginesL(); - break; - } - } - -// --------------------------------------------------------------------------- - -void CCreatorEngine::ExecuteOptionsMenuCommandL(TInt aCommand) - { - LOGSTRING("Creator: CCreatorEngine::ExecuteOptionsMenuCommandL"); - - // startup modules (also inits the command array): - StartEnginesL(); - - // set the home module - switch(aCommand) - { -/* - case ECmdCreateBrowserBookmarkEntries: - case ECmdCreateBrowserBookmarkFolderEntries: - case ECmdCreateBrowserSavedPageEntries: - case ECmdCreateBrowserSavedPageFolderEntries: - case ECmdDeleteBrowserBookmarks: - case ECmdDeleteBrowserBookmarkFolders: - case ECmdDeleteBrowserSavedPages: - case ECmdDeleteBrowserSavedPageFolders: - case ECmdDeleteCreatorBrowserBookmarks: - case ECmdDeleteCreatorBrowserBookmarkFolders: - case ECmdDeleteCreatorBrowserSavedPages: - case ECmdDeleteCreatorBrowserSavedPageFolders: - { - iUsedOptionsMenuModule = iBrowser; - } - break; -*/ - case ECmdCreateCalendarEntryAppointments: - case ECmdCreateCalendarEntryEvents: - case ECmdCreateCalendarEntryAnniversaries: - case ECmdCreateCalendarEntryToDos: - case ECmdCreateCalendarEntryReminders: - case ECmdDeleteCalendarEntries: - case ECmdDeleteCreatorCalendarEntries: - { - iUsedOptionsMenuModule = iCalendar; - } - break; - - case ECmdCreatePhoneBookEntryContacts: - case ECmdCreatePhoneBookEntryGroups: - case ECmdCreatePhoneBookEntrySubscribedContacts: - case ECmdDeleteContacts: - case ECmdDeleteCreatorContacts: - case ECmdDeleteContactGroups: - case ECmdDeleteCreatorContactGroups: - { - iUsedOptionsMenuModule = iPhonebook; - } - break; - - case ECmdCreateMiscEntryNotes: - case ECmdDeleteNotes: - { - iUsedOptionsMenuModule = iNotepad; - } - break; - - case ECmdCreateLogEntryMissedCalls: - case ECmdCreateLogEntryReceivedCalls: - case ECmdCreateLogEntryDialledNumbers: - case ECmdDeleteLogs: - case ECmdDeleteCreatorLogs: - { - iUsedOptionsMenuModule = iLogs; - } - break; -/* - case ECmdCreateMiscEntryAccessPoints: - case ECmdDeleteIAPs: - case ECmdDeleteCreatorIAPs: - { - iUsedOptionsMenuModule = iAccessPoints; - } - break; -*/ - case ECmdCreateMessagingEntryMailboxes: - case ECmdDeleteMailboxes: - case ECmdDeleteCreatorMailboxes: - { - iUsedOptionsMenuModule = iMailboxes; - } - break; -/* - #ifdef __PRESENCE - case ECmdCreateMiscEntryIMPSServers: - case ECmdDeleteIMPSs: - case ECmdDeleteCreatorIMPSs: - { - iUsedOptionsMenuModule = iIMPS; - } - break; - #endif -*/ - case ECmdCreateFileEntryEmptyFolder: - case ECmdCreateFileEntry3GPP_70kB: - case ECmdCreateFileEntryAAC_100kB: - case ECmdCreateFileEntryAMR_20kB: - case ECmdCreateFileEntryBMP_25kB: - case ECmdCreateFileEntryDeck_1kB: - case ECmdCreateFileEntryDOC_20kB: - case ECmdCreateFileEntryGIF_2kB: - case ECmdCreateFileEntryHTML_20kB: - case ECmdCreateFileEntryJAD_1kB: - case ECmdCreateFileEntryJAR_10kB: - case ECmdCreateFileEntryJP2_65kB: - case ECmdCreateFileEntryJPEG_200kB: - case ECmdCreateFileEntryJPEG_25kB: - case ECmdCreateFileEntryJPEG_500kB: - case ECmdCreateFileEntryMIDI_10kB: - case ECmdCreateFileEntryMP3_250kB: - case ECmdCreateFileEntryMP4_200kB: - case ECmdCreateFileEntryMXMF_40kB: - case ECmdCreateFileEntryPNG_15kB: - case ECmdCreateFileEntryPPT_40kB: - case ECmdCreateFileEntryRAM_1kB: - case ECmdCreateFileEntryRM_95kB: - case ECmdCreateFileEntryRNG_1kB: - case ECmdCreateFileEntrySVG_15kB: - case ECmdCreateFileEntrySWF_15kB: - case ECmdCreateFileEntryTIF_25kB: - case ECmdCreateFileEntryTXT_10kB: - case ECmdCreateFileEntryTXT_70kB: - case ECmdCreateFileEntryVCF_1kB: - case ECmdCreateFileEntryVCS_1kB: - case ECmdCreateFileEntryWAV_20kB: - case ECmdCreateFileEntryXLS_15kB: - case ECmdCreateFileEntrySISX_10kB: - case ECmdCreateFileEntryWMA_50kB: - case ECmdCreateFileEntryWMV_200kB: - case ECmdDeleteCreatorFiles: - - { - iUsedOptionsMenuModule = iFiles; - } - break; - - - case ECmdCreateMessagingEntryMessages: - case ECmdDeleteMessages: - case ECmdDeleteCreatorMessages: - { - iUsedOptionsMenuModule = iMessages; - } - break; - - case ECmdCreateMiscEntryLandmarks: - case ECmdDeleteLandmarks: - case ECmdDeleteCreatorLandmarks: - { - iUsedOptionsMenuModule = iLandmarks; - } - break; - case ECmdDeleteAllEntries: - case ECmdDeleteAllCreatorEntries: - { - break; - } - default: - User::Panic (_L("ExecuteOptionsMenuCommandL"), 201); - break; - } - - - //If it's a delete command, asking do you really want to delete - if( IsDeleteCommand( aCommand ) ) - { - if ( aCommand == ECmdDeleteAllEntries ) - { - if ( !iEngineWrapper->YesNoQueryDialog( _L("Delete all entries?"), this, ECreatorEngineDeleteAllEntries) ) - { - // cancelled, free resources - ShutDownEnginesL(); - } - } - else if ( aCommand == ECmdDeleteAllCreatorEntries ) - { - if ( !iEngineWrapper->YesNoQueryDialog( _L("Delete all entries created with Creator?"), this, ECreatorEngineDeleteAllCreatorEntries ) ) - { - // cancelled, free resources - ShutDownEnginesL(); - } - } - else if ( !iUsedOptionsMenuModule->AskDataFromUserL( aCommand ) ) - { - // cancelled or error, free resources - ShutDownEnginesL(); - } - } - - // ask user data, if query accepted start processing... - else if (!iUsedOptionsMenuModule->AskDataFromUserL(aCommand)) - { - // cancelled or error, free resources - ShutDownEnginesL(); - } - } - - - -TBool CCreatorEngine::IsDeleteCommand(TInt aCommand) - { - LOGSTRING("Creator: CCreatorEngine::IsDeleteCommand"); - - switch(aCommand) - { - //Add supported delete command here - case ECmdDeleteAllEntries: - case ECmdDeleteAllCreatorEntries: - case ECmdDeleteEntries: - case ECmdDeleteContacts: - case ECmdDeleteCreatorContacts: - case ECmdDeleteContactGroups: - case ECmdDeleteCreatorContactGroups: - case ECmdDeleteCalendarEntries: - case ECmdDeleteCreatorCalendarEntries: - case ECmdDeleteBrowserBookmarks: - case ECmdDeleteCreatorBrowserBookmarks: - case ECmdDeleteBrowserBookmarkFolders: - case ECmdDeleteCreatorBrowserBookmarkFolders: - case ECmdDeleteBrowserSavedPages: - case ECmdDeleteCreatorBrowserSavedPages: - case ECmdDeleteBrowserSavedPageFolders: - case ECmdDeleteCreatorBrowserSavedPageFolders: - case ECmdDeleteCreatorFiles: - case ECmdDeleteLogs: - case ECmdDeleteCreatorLogs: - case ECmdDeleteMessages: - case ECmdDeleteCreatorMessages: - case ECmdDeleteMailboxes: - case ECmdDeleteCreatorMailboxes: - case ECmdDeleteIAPs: - case ECmdDeleteCreatorIAPs: - case ECmdDeleteIMPSs: - case ECmdDeleteCreatorIMPSs: - case ECmdDeleteNotes: - case ECmdDeleteLandmarks: - case ECmdDeleteCreatorLandmarks: - { - return ETrue; - } - default: - { - return EFalse; - } - } - - } -// --------------------------------------------------------------------------- -void CCreatorEngine::RandomDataFileChosenL( TBool aSuccess, const TDesC& aFileName ) - { - if( aSuccess ) - { - GetRandomDataFromFileL( aFileName ); - } - } - -// --------------------------------------------------------------------------- - -TBool CCreatorEngine::GetRandomDataL() - { - delete iCommandParser; - iCommandParser = NULL; - iCommandParser = CCommandParser::NewL( this ); - return iCommandParser->GetRandomDataFilenameL( this ); - } - -// --------------------------------------------------------------------------- - -TBool CCreatorEngine::GetRandomDataFromFileL(const TDesC& aFilename) - { - // wait dialog - // TODO - //CAknGlobalNote* waitDialog = CAknGlobalNote::NewLC(); - //waitDialog->SetSoftkeys(R_AVKON_SOFTKEYS_CANCEL); - //TInt dialogId = waitDialog->ShowNoteL(EAknGlobalWaitNote, _L("Reading random data")); - - for (TInt i = 0; i < iStringArrays.Count(); ++i) - { - delete iStringArrays[i].iArrayPtr; - } - iStringArrays.Reset(); - - TBool errorDetected = EFalse; - - // NOTE: These must be exactly in same order as in enumeration: - - if (ReadRandomDataL(EFirstName, R_DATA_FIRSTNAMES, aFilename, CCreatorRandomDataParser::EFirstName) != KErrNone) - { - errorDetected = ETrue; - } - if (ReadRandomDataL(ESurname, R_DATA_SURNAMES, aFilename, CCreatorRandomDataParser::ESurname) != KErrNone) - { - errorDetected = ETrue; - } - if (ReadRandomDataL(ECompany, R_DATA_COMPANIES, aFilename, CCreatorRandomDataParser::ECompany) != KErrNone) - { - errorDetected = ETrue; - } - if (ReadRandomDataL(EAddress, R_DATA_ADDRESSES, aFilename, CCreatorRandomDataParser::EAddress) != KErrNone) - { - errorDetected = ETrue; - } - if (ReadRandomDataL(EJobTitle, R_DATA_JOBTITLES, aFilename, CCreatorRandomDataParser::EJobTitle) != KErrNone) - { - errorDetected = ETrue; - } - if (ReadRandomDataL(EPhoneNumber, R_DATA_PHONENUMBERS, aFilename, CCreatorRandomDataParser::EPhoneNumber) != KErrNone) - { - errorDetected = ETrue; - } - if (ReadRandomDataL(EGroupName, R_DATA_GROUPNAMES, aFilename, CCreatorRandomDataParser::EGroupName) != KErrNone) - { - errorDetected = ETrue; - } - if (ReadRandomDataL(EMeetingReason, R_DATA_MEETINGREASONS, aFilename, CCreatorRandomDataParser::EMeetingReason) != KErrNone) - { - errorDetected = ETrue; - } - if (ReadRandomDataL(EMeetingPlace, R_DATA_MEETINGPLACES, aFilename, CCreatorRandomDataParser::EMeetingPlace) != KErrNone) - { - errorDetected = ETrue; - } - if (ReadRandomDataL(EMemoText, R_DATA_MEMOS, aFilename, CCreatorRandomDataParser::EMemoText) != KErrNone) - { - errorDetected = ETrue; - } - if (ReadRandomDataL(EAnniversaryReason, R_DATA_ANNIVERSARIES, aFilename, CCreatorRandomDataParser::EAnniversaryReason) != KErrNone) - { - errorDetected = ETrue; - } - if (ReadRandomDataL(EToDoText, R_DATA_TODOS, aFilename, CCreatorRandomDataParser::EToDoText) != KErrNone) - { - errorDetected = ETrue; - } - if (ReadRandomDataL(EReminderText, R_DATA_REMINDERS, aFilename, CCreatorRandomDataParser::EReminderText) != KErrNone) - { - errorDetected = ETrue; - } - if (ReadRandomDataL(EMessageSubject, R_DATA_MESSAGESUBJECTS, aFilename, CCreatorRandomDataParser::EMessageSubject) != KErrNone) - { - errorDetected = ETrue; - } - if (ReadRandomDataL(EMessageText, R_DATA_MESSAGETEXTS, aFilename, CCreatorRandomDataParser::EMessageText) != KErrNone) - { - errorDetected = ETrue; - } - if (ReadRandomDataL(ECity, R_DATA_CITIES, aFilename, CCreatorRandomDataParser::ECity) != KErrNone) - { - errorDetected = ETrue; - } - if (ReadRandomDataL(ECountry, R_DATA_COUNTRIES, aFilename, CCreatorRandomDataParser::ECountry) != KErrNone) - { - errorDetected = ETrue; - } - if (ReadRandomDataL(EPostcode, R_DATA_POSTCODES, aFilename, CCreatorRandomDataParser::EPostcode) != KErrNone) - { - errorDetected = ETrue; - } - if (ReadRandomDataL(EState, R_DATA_STATES, aFilename, CCreatorRandomDataParser::EState) != KErrNone) - { - errorDetected = ETrue; - } - if (ReadRandomDataL(EPobox, R_DATA_POBOXES, aFilename, CCreatorRandomDataParser::EPobox) != KErrNone) - { - errorDetected = ETrue; - } - if (ReadRandomDataL(EPrefix, R_DATA_PREFIXES, aFilename, CCreatorRandomDataParser::EPrefix) != KErrNone) - { - errorDetected = ETrue; - } - if (ReadRandomDataL(ESuffix, R_DATA_SUFFIXES, aFilename, CCreatorRandomDataParser::ESuffix) != KErrNone) - { - errorDetected = ETrue; - } - if (ReadRandomDataL(ELandmarkName, R_DATA_LANDMARK_NAMES, aFilename, CCreatorRandomDataParser::ELandmarkName) != KErrNone) - { - errorDetected = ETrue; - } - if (ReadRandomDataL(ELandmarkDescription, R_DATA_LANDMARK_DESCRIPTIONS, aFilename, CCreatorRandomDataParser::ELandmarkDescription) != KErrNone) - { - errorDetected = ETrue; - } - - // remove the wait dialog - //waitDialog->CancelNoteL(dialogId); - //CleanupStack::PopAndDestroy(waitDialog); - - if (errorDetected) - { - iEngineWrapper->ShowNote(_L("Error in reading random data.")); - } - return !errorDetected; - } - -// --------------------------------------------------------------------------- - -TInt CCreatorEngine::ReadRandomDataL(const TRandomStringType aRandomStringType, - const TInt aResourceId, - const TDesC& aFilename, - const CCreatorRandomDataParser::TRandomDataType aRandomDataType) - { - TInt error = KErrNone; - if (aFilename == KNullDesC) - { - iStringArrays.AppendL(TStringArrayPtr(aRandomStringType, iEnv->ReadDesCArrayResourceL(aResourceId))); - } - else - { - CCreatorRandomDataParser* dataParser = CCreatorRandomDataParser::NewLC(); - CDesCArrayFlat* array = NULL; - - TRAP(error, array = dataParser->ParseL(aFilename, aRandomDataType)); - if (error == KErrNone) - { - error = dataParser->GetError(); - } - if ((error == KErrNone) && (array->MdcaCount() > 0)) - { - iStringArrays.AppendL(TStringArrayPtr(aRandomStringType, array)); - } - else - { - if (array) - { - array->Reset(); - delete array; - } - iStringArrays.AppendL(TStringArrayPtr(aRandomStringType, iEnv->ReadDesCArrayResourceL(aResourceId))); - } - CleanupStack::PopAndDestroy(dataParser); - } - return error; - } - -// --------------------------------------------------------------------------- - -void CCreatorEngine::AppendToCommandArrayL(TInt aCommand, CCreatorModuleBaseParameters* aParameters, TInt aNumberOfEntries) - { - LOGSTRING("Creator: CCreatorEngine::AppendToCommandArrayL"); - iParameterArray.AppendL(aParameters); - - for (TInt i=0; iAppendL( TCommand(aCommand, aParameters) ); - } - -// --------------------------------------------------------------------------- - -TInt CCreatorEngine::CommandArrayCount() - { - TInt count(0); - - if (iCommandArray) - count = iCommandArray->Count(); - - LOGSTRING2("Creator: CCreatorEngine::CommandArrayCount returns %d", count); - - return count; - } - -// --------------------------------------------------------------------------- - -//returs fileid by its name, eg. 1 in -TInt CCreatorEngine::GetAttachmentIdL( const TDesC& aAttachmentIdStr ) const - { - TInt mapCount = sizeof(FileMap) / sizeof(FileMapping); - - for( TInt i = 0; i < mapCount; ++i ) - { - if( FileMap[i].FileName() == aAttachmentIdStr ) - return FileMap[i].FileId(); - } - LOGSTRING2("CCreatorEngine::GetAttachmentIdL: Unknown attachment file id: %s", &aAttachmentIdStr); - User::Leave(KErrGeneral); - return KErrNotFound; // Not reached, but disables a compiler warning - } - -// --------------------------------------------------------------------------- - -// returns a random string from the resource files -TPtrC CCreatorEngine::TestDataPathL (enum TTestDataPath aTestDataPath ) - { - LOGSTRING("Creator: CCreatorEngine::TestDataPathL"); - - static TFileName filePath; - - switch (aTestDataPath ) - { - case ESavedDeck_1kB: - { - filePath.Copy (_L("Deck-1kB.saveddeck") ); - } - break; - - case EJPEG_25kB: - { - filePath.Copy (_L("JPEG-25kB.jpg") ); - } - break; - - case EJPEG_200kB: - { - filePath.Copy (_L("JPEG-200kB.jpg") ); - } - break; - - case EJPEG_500kB: - { - filePath.Copy (_L("JPEG-500kB.jpg") ); - } - break; - - case EPNG_15kB: - { - filePath.Copy (_L("PNG-15kB.png") ); - } - break; - - case EGIF_2kB: - { - filePath.Copy (_L("GIF-2kB.gif") ); - } - break; - - case ERNG_1kB: - { - filePath.Copy (_L("RNG-1kB.rng") ); - } - break; - - case EMIDI_10kB: - { - filePath.Copy (_L("MIDI-10kB.mid") ); - } - break; - - case EWAVE_20kB: - { - filePath.Copy (_L("WAV-20kB.wav") ); - } - break; - - case EAMR_20kB: - { - filePath.Copy (_L("AMR-20kB.amr") ); - } - break; - - case EExcel_15kB: - { - filePath.Copy (_L("XLS-15kB.xls") ); - } - break; - - case EWord_20kB: - { - filePath.Copy (_L("DOC-20kB.doc") ); - } - break; - - case EPowerPoint_40kB: - { - filePath.Copy (_L("PPT-40kB.ppt") ); - } - break; - - case EText_10kB: - { - filePath.Copy (_L("TXT-10kB.txt") ); - } - break; - - case EText_70kB: - { - filePath.Copy (_L("TXT-70kB.txt") ); - } - break; - - case E3GPP_70kB: - { - filePath.Copy (_L("3GPP-70kB.3gpp") ); - } - break; - - case EMP3_250kB: - { - filePath.Copy (_L("MP3-250kB.mp3") ); - } - break; - - case EAAC_100kB: - { - filePath.Copy (_L("AAC-100kB.aac") ); - } - break; - - case ERM_95kB: - { - filePath.Copy (_L("RM-95kB.rm") ); - } - break; - - case EBMP_25kB: - { - filePath.Copy (_L("BMP-25kB.bmp") ); - } - break; - case EHTML_20kB: - { - filePath.Copy (_L("HTML-20kB.html") ); - } - break; - case EJAD_1kB: - { - filePath.Copy (_L("JAD-1kB.jad") ); - } - break; - case EJAR_10kB: - { - filePath.Copy (_L("JAR-10kB.jar") ); - } - break; - case EJP2_65kB: - { - filePath.Copy (_L("JP2-65kB.jp2") ); - } - break; - case EMP4_200kB: - { - filePath.Copy (_L("MP4-200kB.mp4") ); - } - break; - case EMXMF_40kB: - { - filePath.Copy (_L("MXMF-40kB.mxmf") ); - } - break; - case ERAM_1kB: - { - filePath.Copy (_L("RAM-1kB.ram") ); - } - break; - case ESVG_15kB: - { - filePath.Copy (_L("SVG-15kB.svg") ); - } - break; - case ESWF_15kB: - { - filePath.Copy (_L("SWF-15kB.swf") ); - } - break; - case ETIF_25kB: - { - filePath.Copy (_L("TIF-25kB.tif") ); - } - break; - case EVCF_1kB: - { - filePath.Copy (_L("VCF-1kB.vcf") ); - } - break; - case EVCS_1kB: - { - filePath.Copy (_L("VCS-1kB.vcs") ); - } - break; - case ESISX_10kB: - { - filePath.Copy (_L("SISX-10kB.sisx") ); - } - break; - case EWMA_50kB: - { - filePath.Copy (_L("WMA-50kB.wma") ); - } - break; - case EWMV_200kB: - { - filePath.Copy (_L("WMV-200kB.wmv") ); - } - break; - - default: - User::Panic (_L("Test data"), 401 ); - break; - } - - TFileName fullTargetPath; - fullTargetPath.Copy( iTempPath->Des() ); - fullTargetPath.Append( filePath ); - if (ConeUtils::FileExists(fullTargetPath)) - { - // No need to copy, if the file already exists. - LOGSTRING2("Creator: CCreatorEngine::TestDataPathL %S already exists", &fullTargetPath); - return fullTargetPath; - } - - // Define the path where the testdata can be retrieved - // get the data from the private directory in secure platform - TFileName fullAppPath = iEnv->EikAppUi()->Application()->AppFullName(); - TChar driveLetter = fullAppPath[0]; - TInt driveNumber; - - iEnv->FsSession().CharToDrive(driveLetter, driveNumber); - iEnv->FsSession().SetSessionToPrivate( driveNumber ); // "\\private\\20011383\\" - - - // check the file exists - if (!ConeUtils::FileExists(filePath)) - { - LOGSTRING2("Creator: CCreatorEngine::TestDataPathL %S not found", &filePath); - - TInt generatingError( KErrNone ); - - // The file could be on C drive - iEnv->FsSession().SetSessionToPrivate( KRegisterDrive ); - - if ( !ConeUtils::FileExists( filePath ) ) - { - // The file is not on C drive, see if we can generate it - - // Make sure that the private path of this app in c-drive exists - iEnv->FsSession().CreatePrivatePath( KRegisterDrive ); - - TFileName privatePath; - iEnv->FsSession().PrivatePath( privatePath ); - privatePath.Append( filePath ); - TChar privateDriveChar; - iEnv->FsSession().DriveToChar( KRegisterDrive, privateDriveChar ); - TFileName fullPrivatePath; // full path of a file to be generated - fullPrivatePath.Append( privateDriveChar ); - fullPrivatePath.Append( ':' ); - fullPrivatePath.Append( privatePath ); - - switch ( aTestDataPath ) - { - case EJPEG_25kB: - case EJPEG_200kB: - case EJPEG_500kB: - case EBMP_25kB: - case EGIF_2kB: - { - TRAP( generatingError, GenerateSourceImageFileL( aTestDataPath, fullPrivatePath ) ); - // GenerateSourceImageFileL calls TestDataPathL -> private session points to z - // change it back to KRegisterDrive, because generated source file is there - // and we need to copy it at the end of this function. - iEnv->FsSession().SetSessionToPrivate( KRegisterDrive ); - break; - } - case EText_10kB: - { - TRAP( generatingError, GenereteSourceTextFileL( fullPrivatePath, 10000 ) ); - // GenerateSourceImageFileL calls TestDataPathL -> private session points to z - // change it back to KRegisterDrive, because generated source file is there - // and we need to copy it at the end of this function. - iEnv->FsSession().SetSessionToPrivate( KRegisterDrive ); - break; - } - case EText_70kB: - { - TRAP( generatingError, GenereteSourceTextFileL( fullPrivatePath, 70000 ) ); - break; - } - default: - { - generatingError = KErrNotSupported; - break; - } - } - } - - if ( iUserCancelled ) - { - LOGSTRING("Creator: CCreatorEngine::TestDataPathL iUserCancelled" ); - User::Leave( KErrCancel ); - } - - if ( generatingError ) - { - // Generating the file failed - - // cancel the dialog - //iProgressDialog->ProcessFinishedL(); - //DialogDismissedL(EAknSoftkeyBack); - - // remove the progress dialog from the screen - iEngineWrapper->CloseProgressbar(); - - - // show error note - iEngineWrapper->ShowNote(_L("Test data missing")); - - User::Leave(KErrPathNotFound); - } - } - - // now copy the data to D-drive to make the file public - iEnv->FsSession().MkDirAll( iTempPath->Des() ); - TInt copyErr = BaflUtils::CopyFile(iEnv->FsSession(), filePath, fullTargetPath); - LOGSTRING4("Creator: CCreatorEngine::TestDataPathL copy %S to %S returns=%d", &filePath, &fullTargetPath, copyErr); - - // make sure that the file won't have a read only attribute - TEntry fileEntry; - iEnv->FsSession().Entry(fullTargetPath, fileEntry); - iEnv->FsSession().SetEntry(fullTargetPath, fileEntry.iModified, NULL, KEntryAttReadOnly); - - filePath = fullTargetPath; // change the reference to the temp path - return filePath; - } - - -// --------------------------------------------------------------------------- - - - -// a method to return a default Internet Access Point -TUint32 CCreatorEngine::GetDefaultIAPL() - { - LOGSTRING("Creator: CCreatorEngine::GetDefaultIAPL"); - - TUint32 lIAPid = 1; // Default value - - CCommsDatabase* cDatabase = CCommsDatabase::NewL(); - CleanupStack::PushL(cDatabase); - - CCommsDbTableView* tableView = cDatabase->OpenTableLC(TPtrC(IAP)); - - TInt errorCode = tableView->GotoFirstRecord(); - - if ( errorCode == KErrNone ) - { - TUint32 iValue; - tableView->ReadUintL(TPtrC(COMMDB_ID),iValue); - lIAPid = iValue; - } - - CleanupStack::PopAndDestroy(2); // cDatabase,tableView - - return lIAPid; - } - -// --------------------------------------------------------------------------- - -TUint32 CCreatorEngine::AccessPointNameToIdL(const TDesC& /*aAPName*/, TBool /*aAnyIfNotFound*/ ) - { - LOGSTRING("Creator: CCreatorEngine::AccessPointNameToIdL"); - // Accespoint impl moved from engine to accespoint implementations for supporting 3.0-3.1 and 3.2-> - //return iAccessPoints->AccessPointNameToIdL(aAPName, aAnyIfNotFound ); - return 0; - } - -static CCreatorEngine::TTestDataPath SoundFiles[] = { - CCreatorEngine::EMIDI_10kB, - CCreatorEngine::EWAVE_20kB, - CCreatorEngine::EMP3_250kB, - CCreatorEngine::EAAC_100kB - }; - -static CCreatorEngine::TTestDataPath PictureFiles[] = - { - CCreatorEngine::EJPEG_25kB, - CCreatorEngine::EJPEG_200kB, - CCreatorEngine::EJPEG_500kB, - CCreatorEngine::EPNG_15kB, - CCreatorEngine::EGIF_2kB - }; - -TPtrC CCreatorEngine::CreateSoundFileL(TTestDataPath aId) -{ - TPtrC tempPath(TestDataPathL(aId)); - // Copy file to permanent location: - TParse parser; - parser.Set(tempPath, NULL, NULL); - TPtrC fileName(parser.NameAndExt()); - HBufC* fullTargetPath = HBufC::NewLC( KMaxFileName ); - fullTargetPath->Des().Copy( PathInfo::PhoneMemoryRootPath() ); - fullTargetPath->Des().Append( PathInfo::DigitalSoundsPath() ); - - fullTargetPath->Des().Append(fileName); - CopyFileL(tempPath, *fullTargetPath); - iAllocatedFilePaths.AppendL(fullTargetPath); - CleanupStack::Pop(); // fullTargetPath - return fullTargetPath->Des(); -} -TPtrC CCreatorEngine::CreateRandomSoundFileL() -{ - TInt numOfFiles = sizeof(SoundFiles) / sizeof(TTestDataPath); - return CreateSoundFileL(SoundFiles[RandomNumber(0, numOfFiles-1)]); -} -TPtrC CCreatorEngine::RandomSoundFileL() -{ - TInt numOfFiles = sizeof(SoundFiles) / sizeof(TTestDataPath); - return TestDataPathL(SoundFiles[RandomNumber(0, numOfFiles-1)]); -} - -void CCreatorEngine::RandomPictureFileL(TDes& aPath) -{ - TInt numOfFiles = sizeof(PictureFiles) / sizeof(TTestDataPath); - aPath = TestDataPathL(PictureFiles[RandomNumber(0, numOfFiles-1)]); -} -// --------------------------------------------------------------------------- - -// returns a random string from the resource files -TPtrC CCreatorEngine::RandomString(enum TRandomStringType aRandomStringType) - { - LOGSTRING("Creator: CCreatorEngine::RandomString"); - - // Let's see if the array is OK and the string arrays are in correct order: - if( ((TInt) aRandomStringType) < iStringArrays.Count() && - iStringArrays[aRandomStringType].iStringType == aRandomStringType) - { - TInt rand = (TInt) (iStringArrays[aRandomStringType].iArrayPtr->Count() * Math::FRand(iSeed)); - return (*iStringArrays[aRandomStringType].iArrayPtr)[rand]; - } - - // Now let's loop the arrays and try to find one with the type: - for( TInt i = 0; i < iStringArrays.Count(); ++i ) - { - if( iStringArrays[i].iStringType == aRandomStringType ) - { - TInt rand = (TInt) (iStringArrays[i].iArrayPtr->Count() * Math::FRand(iSeed)); - return (*iStringArrays[i].iArrayPtr)[rand]; - } - } - - User::Panic (_L("Random string"), 402); - return NULL; - } - -// --------------------------------------------------------------------------- - -// returns a random number -TInt CCreatorEngine::RandomNumber(TInt aRange) - { - LOGSTRING2("Creator: CCreatorEngine::RandomNumber aRange=%d", aRange); - - return (TInt) (aRange*Math::FRand(iSeed)); - } - -// --------------------------------------------------------------------------- - -// returns a random number -TInt CCreatorEngine::RandomNumber(TInt aMin, TInt aMax) - { - LOGSTRING3("Creator: CCreatorEngine::RandomNumber aMin=%d aMax=%d", aMin, aMax); - - TInt range = (aMax > aMin ? aMax - aMin : aMin - aMax) + 1; - TInt random = (TInt) (range*Math::FRand(iSeed)); - - random = (random % range) + aMin; - - if (random > aMax) - random = aMax; - else if (random < aMin) - random = aMin; - - return random; - } - -TTime CCreatorEngine::RandomTime(TTime baseTime, TRandomDateType type, TInt aMinHours, TInt aMaxHours, TInt aMinMinutes, TInt aMaxMinutes ) - { - TInt randomHours = RandomNumber(aMinHours, aMaxHours); - TInt randomMinutes = RandomNumber(aMinMinutes, aMaxMinutes); - - switch( type ) - { - case EDatePast: - return (baseTime - TTimeIntervalHours(randomHours)) - TTimeIntervalMinutes(randomMinutes); - case EDateFuture: - return (baseTime + TTimeIntervalHours(randomHours)) + TTimeIntervalMinutes(randomMinutes); - default: - break; - } - return baseTime; - } - -TTime CCreatorEngine::RandomDate(TTime baseTime, TRandomDateType type, TInt aMinDays, TInt aMaxDays) - { - TInt random = RandomNumber(aMinDays, aMaxDays); - - switch( type ) - { - case EDatePast: - return baseTime - TTimeIntervalDays(random); - case EDateFuture: - return baseTime + TTimeIntervalDays(random); - default: - break; - } - - return baseTime; - } - -TTime CCreatorEngine::RandomDate(TRandomDateType type, TInt aMinDays, TInt aMaxDays) - { - TTime time; - // Set to current time: - time.HomeTime(); - return RandomDate(time, type, aMinDays, aMaxDays); - } - -HBufC* CCreatorEngine::CreateEmailAddressLC() - { - _LIT(KCountry, "com"); - return CreateEmailAddressLC(RandomString(EFirstName), RandomString(ESurname), RandomString(ECompany), KCountry); - } - -HBufC* CCreatorEngine::CreateHTTPUrlLC() - { - _LIT(KProtocol, "http://"); - _LIT(KPrefix, "www"); - _LIT(KCountry, "com"); - return CreateUrlLC(KProtocol, KPrefix, RandomString(ECompany), KCountry); - } - -HBufC* CCreatorEngine::CreateRandomStringLC(TInt aStrLen) - { - TInt minAscii = 65; - TInt maxAscii = 90; - HBufC* str = HBufC::NewL(aStrLen); - CleanupStack::PushL(str); - for( TInt i = 0; i < aStrLen; ++i ) - { - TInt random = RandomNumber(minAscii, maxAscii); - TChar randomChar = TChar((TUint) random); - str->Des().Append(randomChar); - } - return str; - } - -HBufC* CCreatorEngine::CreateEmailAddressLC( - const TDesC& firstname, - const TDesC& lastname, - const TDesC& domain, - const TDesC& country ) const - { - HBufC* email = HBufC::New(firstname.Length() + lastname.Length() + domain.Length() + country.Length() + 3); - CleanupStack::PushL(email); - _LIT(KEmailAddr, "%S.%S@%S.%S"); - email->Des().Format(KEmailAddr, &firstname, &lastname, &domain, &country); - return email; - } - -HBufC* CCreatorEngine::CreateUrlLC( - const TDesC& protocol, - const TDesC& prefix, - const TDesC& domain, - const TDesC& country) const - { - HBufC* url = HBufC::New(protocol.Size() + prefix.Size() + domain.Size() + country.Size() + 2); - CleanupStack::PushL(url); - _LIT(KUrl, "%S%S.%S.%S"); - url->Des().Format(KUrl, &protocol, &prefix, &domain, &country); - return url; - } -// --------------------------------------------------------------------------- - -void CCreatorEngine::SetDefaultPathForFileCommandL(TInt aCommand, TFileName& aPath) - { - aPath.Copy( PathInfo::PhoneMemoryRootPath() ); - switch (aCommand) - { - case ECmdCreateFileEntryJPEG_25kB: - case ECmdCreateFileEntryJPEG_200kB: - case ECmdCreateFileEntryJPEG_500kB: - case ECmdCreateFileEntryPNG_15kB: - case ECmdCreateFileEntryGIF_2kB: - case ECmdCreateFileEntryBMP_25kB: - case ECmdCreateFileEntrySVG_15kB: - case ECmdCreateFileEntryTIF_25kB: - case ECmdCreateFileEntryJP2_65kB: - - { aPath.Append( PathInfo::ImagesPath() ); break; } - - case ECmdCreateFileEntryRNG_1kB: - { aPath.Append( PathInfo::SimpleSoundsPath() ); break; } - - case ECmdCreateFileEntryMIDI_10kB: - case ECmdCreateFileEntryWAV_20kB: - case ECmdCreateFileEntryAMR_20kB: - case ECmdCreateFileEntryMP3_250kB: - case ECmdCreateFileEntryAAC_100kB: - case ECmdCreateFileEntryWMA_50kB: - { aPath.Append( PathInfo::DigitalSoundsPath() ); break; } - - case ECmdCreateFileEntry3GPP_70kB: - case ECmdCreateFileEntryRM_95kB: - case ECmdCreateFileEntryMP4_200kB: - case ECmdCreateFileEntryWMV_200kB: - - { aPath.Append( PathInfo::VideosPath() ); break; } - - case ECmdCreateFileEntryEmptyFolder: - { aPath.Append( _L("MyFolder\\") ); break; } - - default: - { aPath.Append( PathInfo::OthersPath() ); break; } - - } - } - - -// --------------------------------------------------------------------------- - -void CCreatorEngine::CancelComplete() - { - LOGSTRING("Creator: CCreatorEngine::CancelComplete"); - // free resources and show a note - TRAP_IGNORE( ShutDownEnginesL() ); - - TRAP_IGNORE(iEngineWrapper->ShowNote(_L("Cancelled"))); - - } - -// --------------------------------------------------------------------------- - -TCommand::TCommand(TInt aCommandId, CCreatorModuleBaseParameters* aParameters) - { - iCommandId = aCommandId; - iParameters = aParameters; - } - -// --------------------------------------------------------------------------- - -TCommand::~TCommand() - { - } - -// --------------------------------------------------------------------------- - -CAsyncWaiter* CAsyncWaiter::NewL(TInt aPriority) - { - CAsyncWaiter* self = new(ELeave) CAsyncWaiter(aPriority); - return self; - } - -CAsyncWaiter* CAsyncWaiter::NewLC(TInt aPriority) - { - CAsyncWaiter* self = new(ELeave) CAsyncWaiter(aPriority); - CleanupStack::PushL(self); - return self; - } - -CAsyncWaiter::CAsyncWaiter(TInt aPriority) : CActive(aPriority) - { - CActiveScheduler::Add(this); - } - -CAsyncWaiter::~CAsyncWaiter() - { - Cancel(); - } - -void CAsyncWaiter::StartAndWait() - { - LOGSTRING("Creator: CAsyncWaiter::StartAndWait"); - iStatus = KRequestPending; - SetActive(); - iWait.Start(); - } - -TInt CAsyncWaiter::Result() const - { - return iError; - } - -void CAsyncWaiter::RunL() - { - LOGSTRING("Creator: CAsyncWaiter::RunL"); - - iError = iStatus.Int(); - //CAknEnv::StopSchedulerWaitWithBusyMessage( iWait ); - iWait.AsyncStop(); - } - -void CAsyncWaiter::DoCancel() - { - LOGSTRING("Creator: CAsyncWaiter::DoCancel"); - - iError = KErrCancel; - if( iStatus == KRequestPending ) - { - TRequestStatus* s=&iStatus; - User::RequestComplete( s, KErrCancel ); - } - iWait.AsyncStop(); - //CAknEnv::StopSchedulerWaitWithBusyMessage( iWait ); - } - -FileMapping::FileMapping( const TDesC& aAttName, TInt aAttId, TInt aCommandId ) - : - iFileName(aAttName), - iFileId(aAttId), - iCommandId(aCommandId) - {} - - const TDesC& FileMapping::FileName() const - { - return iFileName; - } - - TInt FileMapping::FileId() const - { - return iFileId; - } - - TInt FileMapping::CommandId() const - { - return iCommandId; - } - -// --------------------------------------------------------------------------- -CDictionaryFileStore* CCreatorEngine::FileStoreLC() - { - LOGSTRING("Creator: CCreatorEngine::FileStoreLC"); - CDictionaryFileStore* store; - - // make sure that the private path of this app in c-drive exists - CEikonEnv::Static()->FsSession().CreatePrivatePath( KRegisterDrive ); // c:\\private\\20011383\\ - - // handle register always in the private directory - User::LeaveIfError( CEikonEnv::Static()->FsSession().SetSessionToPrivate( KRegisterDrive ) ); - store = CDictionaryFileStore::OpenLC( CEikonEnv::Static()->FsSession(), KRegisterFileName, KUidCreatorApp ); - return store; - } - -// --------------------------------------------------------------------------- -void CCreatorEngine::ReadEntryIdsFromStoreL( RArray& aEntryIds, const TUid aModuleUid ) - { - LOGSTRING("Creator: CCreatorEngine::ReadEntryIdsFromStoreL"); - CDictionaryFileStore* store = FileStoreLC(); - User::LeaveIfNull( store ); - if ( store->IsPresentL( aModuleUid ) ) - { - RDictionaryReadStream in; - in.OpenLC( *store, aModuleUid ); - TFileName fullPath; - TInt err( KErrNone ); - TInt id( KErrNotFound ); - while ( !err ) - { - TRAP( err, id = in.ReadInt32L() ); // will leave with KErrEof - if ( !err ) - { - aEntryIds.AppendL( id ); - } - } - CleanupStack::PopAndDestroy( &in ); - } - CleanupStack::PopAndDestroy( store ); - } - -// --------------------------------------------------------------------------- -void CCreatorEngine::WriteEntryIdsToStoreL( RArray& aEntryIds, const TUid aModuleUid ) - { - LOGSTRING("Creator: CCreatorEngine::WriteEntryIdsToStoreL"); - CDictionaryFileStore* store = FileStoreLC(); - User::LeaveIfNull( store ); - - // backup previous ids from store - // otherwise they would be overwritten when calling out.WriteL - RArray previousIds; - CleanupClosePushL( previousIds ); - - if ( store->IsPresentL( aModuleUid ) ) - { - RDictionaryReadStream in; - in.OpenLC( *store, aModuleUid ); - TInt err( KErrNone ); - TInt id( KErrNotFound ); - while ( !err ) - { - TRAP( err, id = in.ReadInt32L() ); // will leave with KErrEof - if ( !err ) - { - previousIds.AppendL( id ); - } - } - CleanupStack::PopAndDestroy( &in ); - } - - RDictionaryWriteStream out; - out.AssignLC( *store, aModuleUid ); - - // restore previous ids to store - for ( TInt i = 0; i < previousIds.Count(); i++ ) - { - out.WriteInt32L( previousIds[i] ); - } - - // write new ids to store - for ( TInt i = 0; i < aEntryIds.Count(); i++ ) - { - out.WriteInt32L( aEntryIds[i] ); - } - - out.CommitL(); - CleanupStack::PopAndDestroy( &out ); - - store->CommitL(); - CleanupStack::PopAndDestroy( &previousIds ); - CleanupStack::PopAndDestroy( store ); - } - -// --------------------------------------------------------------------------- -void CCreatorEngine::ReadEntryIdsFromStoreL( RArray& aEntryIds, const TUid aModuleUid ) - { - LOGSTRING("Creator: CCreatorEngine::ReadEntryIdsFromStoreL"); - CDictionaryFileStore* store = FileStoreLC(); - User::LeaveIfNull( store ); - if ( store->IsPresentL( aModuleUid ) ) - { - RDictionaryReadStream in; - in.OpenLC( *store, aModuleUid ); - TFileName fullPath; - TInt err( KErrNone ); - TUint32 id( KErrNone ); - while ( !err ) - { - TRAP( err, id = in.ReadUint32L() ); // will leave with KErrEof - if ( !err ) - { - aEntryIds.AppendL( id ); - } - } - CleanupStack::PopAndDestroy( &in ); - } - CleanupStack::PopAndDestroy( store ); - } - -// --------------------------------------------------------------------------- -void CCreatorEngine::WriteEntryIdsToStoreL( RArray& aEntryIds, const TUid aModuleUid ) - { - LOGSTRING("Creator: CCreatorEngine::WriteEntryIdsToStoreL"); - CDictionaryFileStore* store = FileStoreLC(); - User::LeaveIfNull( store ); - - // backup previous ids from store - // otherwise they would be overwritten when calling out.WriteL - RArray previousIds; - CleanupClosePushL( previousIds ); - - if ( store->IsPresentL( aModuleUid ) ) - { - RDictionaryReadStream in; - in.OpenLC( *store, aModuleUid ); - TInt err( KErrNone ); - TUint32 id( KErrNone ); - while ( !err ) - { - TRAP( err, id = in.ReadUint32L() ); // will leave with KErrEof - if ( !err ) - { - previousIds.AppendL( id ); - } - } - CleanupStack::PopAndDestroy( &in ); - } - - RDictionaryWriteStream out; - out.AssignLC( *store, aModuleUid ); - - // restore previous ids to store - for ( TInt i = 0; i < previousIds.Count(); i++ ) - { - out.WriteUint32L( previousIds[i] ); - } - - // write new ids to store - for ( TInt i = 0; i < aEntryIds.Count(); i++ ) - { - out.WriteUint32L( aEntryIds[i] ); - } - - out.CommitL(); - CleanupStack::PopAndDestroy( &out ); - - store->CommitL(); - CleanupStack::PopAndDestroy( &previousIds ); - CleanupStack::PopAndDestroy( store ); - } - -// --------------------------------------------------------------------------- -void CCreatorEngine::RemoveStoreL( const TUid aModuleUid ) - { - LOGSTRING("Creator: CCreatorEngine::RemoveStoreL"); - CDictionaryFileStore* store = FileStoreLC(); - User::LeaveIfNull( store ); - if ( store->IsPresentL( aModuleUid ) ) - { - // entries of this module should be deleted by now, - // remove the Creator internal registry for this module - store->Remove( aModuleUid ); - store->CommitL(); - } - CleanupStack::PopAndDestroy( store ); - } - -//---------------------------------------------------------------------------- -void CCreatorEngine::GenerateSourceImageFileL( - const CCreatorEngine::TTestDataPath aFileType, - const TDesC& aFileName ) - { - LOGSTRING("Creator: CCreatorEngine::GenerateSourceImageFileL"); - - // Peek file size - RFile file; - TInt fileSize( 0 ); - // Using png file as the source file - TFileName fileName = TestDataPathL( CCreatorEngine::EPNG_15kB ); - User::LeaveIfError( file.Open( iEnv->FsSession(), - fileName, - EFileRead | EFileShareAny ) ); - CleanupClosePushL( file ); - User::LeaveIfError( file.Size( fileSize ) ); - CleanupStack::PopAndDestroy( &file ); - - // Using heap variables, because bitmaps - // may reserve large amount of memory. - - // Read data from the file - RFileReadStream ws; - User::LeaveIfError( ws.Open( iEnv->FsSession(), - fileName, - EFileStream | EFileRead | EFileShareAny ) ); - CleanupClosePushL( ws ); - delete iBitmapData; - iBitmapData = NULL; - iBitmapData = HBufC8::NewL( fileSize ); - TPtr8 dataPtr = iBitmapData->Des(); - ws.ReadL( dataPtr, fileSize ); - CleanupStack::PopAndDestroy( &ws ); - - // Create decoder for the data - delete iDecoder; - iDecoder = NULL; - iDecoder = CImageDecoder::DataNewL( iEnv->FsSession(), dataPtr ); - iFrameinfo = iDecoder->FrameInfo(); - - // Create bitmap handle for the source image - iBitmap = new (ELeave) CFbsBitmap(); - User::LeaveIfError( iBitmap->Create( iFrameinfo.iFrameCoordsInPixels.Size(), EColor16M ) ); - - // Convert the data from the file into bitmap format (inmemory) - CAsyncWaiter* waiter = CAsyncWaiter::NewLC(); - iDecoder->Convert( &waiter->iStatus, *iBitmap ); - waiter->StartAndWait(); - delete iDecoder; - iDecoder = NULL; - delete iBitmapData; - iBitmapData = NULL; - if ( iUserCancelled ) - { - CancelComplete(); - User::Leave( KErrCancel ); - } - User::LeaveIfError( waiter->Result() ); - - // Define the target dimensions and image quality - // so that the generated file size will match required size. - // Quality and scaling factors are defined experimentally. - delete iScaler; - iScaler = NULL; - iScaler = CBitmapScaler::NewL(); - iScaledBitmap = new (ELeave) CFbsBitmap(); - // use original size as base - TSize scaledSize( iFrameinfo.iFrameCoordsInPixels.Size() ); - delete iFrameImageData; - iFrameImageData = NULL; - iFrameImageData = CFrameImageData::NewL(); - TBuf8<64> mimeType; - TJpegImageData* jpegImageData( NULL ); - TBmpImageData* bmpImageData( NULL ); - switch ( aFileType ) - { - case CCreatorEngine::EJPEG_25kB: - // QualityFactor = 93 and size factor = 2 -> 25kB jpeg file - mimeType.Copy( _L8("image/jpeg") ); - jpegImageData = new (ELeave) TJpegImageData; - // Set some format specific data - jpegImageData->iSampleScheme = TJpegImageData::EColor444; - jpegImageData->iQualityFactor = 93; // 0..100 - // ownership passed to iFrameImageData after AppendImageData - User::LeaveIfError( iFrameImageData->AppendImageData( jpegImageData ) ); - scaledSize.iHeight *= 2; - scaledSize.iWidth *= 2; - break; - case CCreatorEngine::EJPEG_200kB: - { - mimeType.Copy( _L8("image/jpeg") ); - jpegImageData = new (ELeave) TJpegImageData; - // Set some format specific data - jpegImageData->iSampleScheme = TJpegImageData::EColor444; -#ifdef __WINS__ - // QualityFactor = 95 and size factor = 7 -> 196kB jpeg file - jpegImageData->iQualityFactor = 95; // 0..100 - scaledSize.iHeight *= 7; - scaledSize.iWidth *= 7; -#else - // In hw the image compression seems to work - // more efficiently. Need to set greater values. - jpegImageData->iQualityFactor = 100; // 0..100 - scaledSize.iHeight *= 7; - scaledSize.iWidth *= 7; - // 100, 7, 7 -> 213kB -#endif - // ownership passed to iFrameImageData after AppendImageData - User::LeaveIfError( iFrameImageData->AppendImageData( jpegImageData ) ); - break; - } - case CCreatorEngine::EJPEG_500kB: - { - mimeType.Copy( _L8("image/jpeg") ); - jpegImageData = new (ELeave) TJpegImageData; - // Set some format specific data - jpegImageData->iSampleScheme = TJpegImageData::EColor444; -#ifdef __WINS__ - // QualityFactor = 99 and size factor = 8 -> 514kB jpeg file - jpegImageData->iQualityFactor = 99; // 0..100 - scaledSize.iHeight *= 8; - scaledSize.iWidth *= 8; -#else - // In hw the image compression seems to work - // more efficiently. Need to set greater values. - jpegImageData->iQualityFactor = 100; // 0..100 - scaledSize.iHeight *= 13; - scaledSize.iWidth *= 13; - // 100, 13, 13 -> 535kB -#endif - // ownership passed to iFrameImageData after AppendImageData - User::LeaveIfError( iFrameImageData->AppendImageData( jpegImageData ) ); - break; - } - case CCreatorEngine::EBMP_25kB: - { - // bit depyh 8 and 11/10 size factor -> 25kB bmp - mimeType.Copy( _L8("image/bmp") ); - bmpImageData = new (ELeave) TBmpImageData; - bmpImageData->iBitsPerPixel = 8; - // ownership passed to iFrameImageData after AppendImageData - User::LeaveIfError( iFrameImageData->AppendImageData( bmpImageData ) ); - scaledSize.iHeight *= 11; - scaledSize.iWidth *= 11; - scaledSize.iHeight /= 10; - scaledSize.iWidth /= 10; - break; - } - case CCreatorEngine::EGIF_2kB: - { - // size factor 1/2 -> 2560B gif - mimeType.Copy( _L8("image/gif") ); - // GIF encoder is not configurable, only the size matters here - scaledSize.iHeight /= 2; - scaledSize.iWidth /= 2; - break; - } - default: break; - } - - // Scale to reach target size - User::LeaveIfError( iScaledBitmap->Create( scaledSize, EColor16M ) ); - iScaler->Scale( &waiter->iStatus, *iBitmap, *iScaledBitmap ); - waiter->StartAndWait(); - delete iBitmap; - iBitmap = NULL; - delete iScaler; - iScaler = NULL; - if ( iUserCancelled ) - { - CancelComplete(); - User::Leave( KErrCancel ); - } - User::LeaveIfError( waiter->Result() ); - - // Encode to target format - delete iEncoder; - iEncoder = NULL; - // Creating CImageEncoder opens the target file - iEncoder = CImageEncoder::FileNewL( iEnv->FsSession(), aFileName, mimeType ); - - // Do the conversion to target format, this will write to the file - iEncoder->Convert( &waiter->iStatus, *iScaledBitmap, iFrameImageData ); - waiter->StartAndWait(); - delete iEncoder; - iEncoder = NULL; - delete iFrameImageData; - iFrameImageData = NULL; - delete iScaledBitmap; - iScaledBitmap = NULL; - if ( iUserCancelled ) - { - CancelComplete(); - User::Leave( KErrCancel ); - } - User::LeaveIfError( waiter->Result() ); - CleanupStack::PopAndDestroy( waiter ); - } - -//---------------------------------------------------------------------------- -void CCreatorEngine::GenereteSourceTextFileL( const TDesC& aFileName, TInt aSize ) - { - LOGSTRING("Creator: CCreatorEngine::GenereteSourceTextFileL"); - RFile txtFile; - _LIT8( KTestContent, "Testing... "); - _LIT8( KTestContentCRLF, "\r\n"); - txtFile.Create( iEnv->FsSession(), - aFileName, - EFileStreamText | EFileWrite | EFileShareAny ); - CleanupClosePushL( txtFile ); - for ( TInt i = 1; i*KTestContent().Length() < aSize; i++ ) - { - User::LeaveIfError( txtFile.Write( KTestContent ) ); - if ( !( i % 10 ) ) // linefeed for every 10th - { - User::LeaveIfError( txtFile.Write( KTestContentCRLF ) ); - } - } - CleanupStack::PopAndDestroy( &txtFile ); - } - -//---------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 creator/src/enginewrapper.cpp --- a/creator/src/enginewrapper.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,377 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#include -#include -#include - -#include -#include - -#include -#include - -#include "creator.hrh" // for command ids -#include "notifications.h" -#include "enginewrapper.h" -#include "engine.h" -#include "mainview.h" - - - -// --------------------------------------------------------------------------- - -EngineWrapper::EngineWrapper() -: iEngine(0), iProgressDialog(0) -{ -} - -// --------------------------------------------------------------------------- - -EngineWrapper::~EngineWrapper() -{ - if (iEngine != 0) { - delete iEngine; - iEngine = NULL; - } - if (iProgressDialog != 0) { - delete iProgressDialog; - iProgressDialog = NULL; - } -} - -// --------------------------------------------------------------------------- - -bool EngineWrapper::init() -{ - TRAPD(err, iEngine = CCreatorEngine::NewL(this)); - if(err != KErrNone) { - return false; - } - else { - return true; - } -} - -// --------------------------------------------------------------------------- - -QList EngineWrapper::GetMemoryDetailsList() - { - RPointerArray tMemDetList = iEngine->GetMemoryDetailsList(); - QList memDetList; - MemoryDetails memDet; - for(int i=0; iiFree.Ptr(), temp->iFree.Length() ); - QString size = QString::fromUtf16( temp->iSize.Ptr(), temp->iSize.Length() ); - QChar drive(temp->iDriveLetter.GetUpperCase()); - memDet.mFree = free; //QString((QChar*)tMemDetList[i]->iFree.Ptr(), tMemDetList[i]->iFree.Length()); - memDet.mSize = size; //QString((QChar*) tMemDetList[i]->iSize.Ptr(), tMemDetList[i]->iSize.Length()); - memDet.mDriveLetter = QString(drive); - - //memDetList[i].mDriveLetter = QString::fromUtf8( (char *) &tMemDetList[i]->iDriveLetter, (int) sizeof( char ) ); - memDetList.append( memDet ); - } - return memDetList; - } - -MemoryDetails EngineWrapper::GetMemoryDetails() -{ - - TMemoryDetails tMemoryDetails = iEngine->GetMemoryDetails(); - MemoryDetails memoryDetails; - - // Convert TMemoryDetails to MemoryDetails - memoryDetails.mRamFree = QString::fromUtf16( tMemoryDetails.iRamFree.Ptr(), tMemoryDetails.iRamFree.Length() ); - memoryDetails.mRamSize = QString::fromUtf16( tMemoryDetails.iRamSize.Ptr(), tMemoryDetails.iRamSize.Length() ); - - return memoryDetails; -} - - -// --------------------------------------------------------------------------- - -void EngineWrapper::ShowErrorMessage(const TDesC& aErrorMessage) -{ - QString errorMessage((QChar*)aErrorMessage.Ptr(),aErrorMessage.Length()); - Notifications::error(errorMessage); - -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::ShowNote(const TDesC& aNoteMessage, TInt /*aResourceId*/) -{ - QString note((QChar*)aNoteMessage.Ptr(),aNoteMessage.Length()); - Notifications::showGlobalNote(note, HbMessageBox::MessageTypeInformation, 1000); -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::ShowProgressBar(const TDesC& aPrompt, int aMax) -{ - QString text((QChar*)aPrompt.Ptr(), aPrompt.Length()); - CloseProgressbar(); - iProgressDialog = Notifications::showProgressBar(text, aMax); - connect(iProgressDialog, SIGNAL(cancelled()), this, SLOT(ProgressDialogCancelled())); -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::IncrementProgressbarValue() -{ - if(iProgressDialog) - iProgressDialog->setProgressValue(iProgressDialog->progressValue() + 1); -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::CloseProgressbar() -{ - if(iProgressDialog){ - disconnect(iProgressDialog, SIGNAL(cancelled()), this, SLOT(ProgressDialogCancelled())); - delete iProgressDialog; - iProgressDialog = NULL; - } -} - -// --------------------------------------------------------------------------- - -TBool EngineWrapper::EntriesQueryDialog(TInt* aNumberOfEntries, const TDesC& aPrompt, TBool aAcceptsZero, MUIObserver* observer, int userData) - { - QString text((QChar*)aPrompt.Ptr(), aPrompt.Length()); - TBool success(EFalse); - try{ - CreatorInputDialog::launch(text, aNumberOfEntries, aAcceptsZero ? true : false, observer, userData); - success = ETrue; - } - catch (std::exception& e) - { - Notifications::error( QString("exception: ")+e.what() ); - } - return success; - } - -// --------------------------------------------------------------------------- - -TBool EngineWrapper::TimeQueryDialog(TTime* aTime, const TDesC& aPrompt, MUIObserver* observer, int userData) - { - QString text((QChar*)aPrompt.Ptr(), aPrompt.Length()); - TBool success(EFalse); - try{ - CreatorDateTimeDialog::launch(text, aTime, observer, userData); - success = ETrue; - } - catch (std::exception& e) - { - Notifications::error( QString("exception: ")+e.what() ); - } - return success; - } - -TBool EngineWrapper::YesNoQueryDialog(const TDesC& aPrompt, MUIObserver* observer, int userData) -{ - QString text((QChar*)aPrompt.Ptr(), aPrompt.Length()); - TBool success(EFalse); - try{ - CreatorYesNoDialog::launch(text, "", observer, userData); - success = ETrue; - } - catch (std::exception& e) - { - Notifications::error( QString("exception: ")+e.what() ); - } - return success; -} - -// --------------------------------------------------------------------------- - -bool EngineWrapper::ExecuteOptionsMenuCommand(int commandId) -{ - TInt err = KErrNone; - if (commandId == ECmdCreateFromFile) { - TRAP(err, iEngine->RunScriptL()); - } - else if (commandId == ECmdSelectRandomDataFile) { - TBool ret = EFalse; - TRAP(err, ret = iEngine->GetRandomDataL()); - if ( err != KErrNone || ret == EFalse ) { - Notifications::error("Error in getting random data."); - return false; - } - } - else { - TRAP(err, iEngine->ExecuteOptionsMenuCommandL(commandId)); - } - // error handling - if(err != KErrNone) { - return false; - } - else { - return true; - } -} - -// --------------------------------------------------------------------------- - -TBool EngineWrapper::PopupListDialog(const TDesC& aPrompt, const CDesCArray* aFileNameArray, TInt* aIndex, MUIObserver* aObserver, TInt aUserData) -{ - QString text((QChar*)aPrompt.Ptr(), aPrompt.Length()); - QStringList itemList; - - for (int i = 0; i < aFileNameArray->Count(); i++) { - itemList.append(QString::fromUtf16( - aFileNameArray->MdcaPoint(i).Ptr(), - aFileNameArray->MdcaPoint(i).Length())); - } - TBool success(EFalse); - try{ - CreatorSelectionDialog::launch(text, itemList, aIndex, aObserver, aUserData); - success = ETrue; - } - catch (std::exception& e) - { - Notifications::error( QString("exception: ")+e.what() ); - } - return success; -} - -// --------------------------------------------------------------------------- - -TBool EngineWrapper::DirectoryQueryDialog(const TDesC& aPrompt, TDes& aDirectory, MUIObserver* aObserver, TInt aUserData) -{ - QString text((QChar*)aPrompt.Ptr(), aPrompt.Length()); - TBool success(EFalse); - try{ - CreatorInputDialog::launch(text, aDirectory, aObserver, aUserData); - success = ETrue; - } - catch (std::exception& e) - { - Notifications::error( QString("exception: ")+e.what() ); - } - return success; -} - - -// --------------------------------------------------------------------------- - -void EngineWrapper::ProgressDialogCancelled() -{ - TRAPD(err, iEngine->ProgressDialogCancelledL()); - // error handling - if(err != KErrNone) { - Notifications::error("Error in operation cancel."); - } - // disconnect & delete iProgressDialog to free memory - disconnect(iProgressDialog, SIGNAL(cancelled()), this, SLOT(ProgressDialogCancelled())); - iProgressDialog->deleteLater(); - iProgressDialog = NULL; -} - -// --------------------------------------------------------------------------- - -TBool EngineWrapper::ListQueryDialog(const TDesC& aPrompt, TListQueryId aId, TInt* aIndex, MUIObserver* aObserver, TInt aUserData) -{ - bool ret = false; - QString text((QChar*)aPrompt.Ptr(), aPrompt.Length()); - QStringList itemList; - - switch (aId) { - case R_CONTACT_CREATION_TYPE_QUERY: { - itemList << "Default fields" << "Define..."; - break; - } - case R_GROUP_CREATION_TYPE_QUERY: { - itemList << "Random" << "Define..."; - break; - } - case R_MESSAGE_TYPE_QUERY: { - itemList << "SMS" << "MMS" << "AMS" << "Email" << "Smart Message" << "IR Message" << "BT Message"; - break; - } - case R_FOLDER_TYPE_QUERY: { - itemList << "Inbox" << "Drafts" << "Outbox" << "Sent"; - break; - } - case R_UNREAD_QUERY: { - itemList << "Read" << "New"; - break; - } - case R_ATTACHMENT_MULTI_SELECTION_QUERY: { - Notifications::error("Not supported resource id."); - break; - } - case R_AMS_ATTACHMENT_SINGLE_SELECTION_QUERY: { - itemList << "AMR 20kB"; - break; - } - case R_ATTACHMENT_SINGLE_SELECTION_QUERY: { - itemList << "JPEG 25kB" << "JPEG 300kB" << "JPEG 500kB" << "PNG 15kB" << "GIF 2kB" << "RNG 1kB" - << "MIDI 10kB" << "WAVE 20kB" << "AMR 20kB" << "Excel 15kB" << "Word 20kB" << "PowerPoint 40kB" - << "Text 10kB" << "Text 70kB" << "3GPP 70kB" << "MP3 250kB" << "AAC 100kB" << "RM 95kB"; - break; - } - default: { - Notifications::error("Error in resource id."); - return ret; - } - } - TBool success(EFalse); - try{ - CreatorSelectionDialog::launch(text, itemList, aIndex, aObserver, aUserData); - success = ETrue; - } - catch (std::exception& e) - { - Notifications::error( QString("exception: ")+e.what() ); - } - return success; -} - -TBool EngineWrapper::ListQueryDialog(const TDesC& aPrompt, TListQueryId aId, CArrayFixFlat* aSelectedItems, MUIObserver* aObserver, TInt aUserData) -{ - TBool success(EFalse); - QStringList itemList; - QString text((QChar*)aPrompt.Ptr(), aPrompt.Length()); - if (aId == R_ATTACHMENT_MULTI_SELECTION_QUERY) { - itemList << "None" << "JPEG 25kB" << "JPEG 300kB" << "JPEG 500kB" << "PNG 15kB" << "GIF 2kB" << "RNG 1kB" - << "MIDI 10kB" << "WAVE 20kB" << "AMR 20kB" << "Excel 15kB" << "Word 20kB" << "PowerPoint 40kB" - << "Text 10kB" << "Text 70kB" << "3GPP 70kB" << "MP3 250kB" << "AAC 100kB" << "RM 95kB"; - } - else{ - Notifications::error("Error in resource id."); - return EFalse; - } - - try{ - CreatorSelectionDialog::launch(text, itemList, aSelectedItems, aObserver, aUserData); - success = ETrue; - } - catch (std::exception& e) - { - Notifications::error( QString("exception: ")+e.what() ); - } - return success; -} - -void EngineWrapper::CloseCreatorApp() -{ - MainView::closeApp(); -} diff -r 819e59dfc032 -r 2d9cac8919d3 creator/src/main.cpp --- a/creator/src/main.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,48 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#include -#include -#include - -#include "mainview.h" -#include "enginewrapper.h" - -int main(int argc, char *argv[]) -{ - - - - HbApplication app(argc, argv); - HbMainWindow mainWindow; - - //Create main view - MainView* view = new MainView(mainWindow); - - //initialize main view - view->init(app); - - // Add View to main window and reveal it. - mainWindow.addView(view); - mainWindow.show(); - - int result = app.exec(); - - return result; -} - diff -r 819e59dfc032 -r 2d9cac8919d3 creator/src/mainview.cpp --- a/creator/src/mainview.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,659 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "notifications.h" -#include "enginewrapper.h" -#include "mainview.h" -#include "hbtoolbar.h" -#include "creator.hrh" // for command ids - -// --------------------------------------------------------------------------- - -MainView::MainView(HbMainWindow &mainWindow): - mMainWindow(mainWindow) -{ -} - -// --------------------------------------------------------------------------- - -MainView::~MainView() -{ - delete mSm; -} - -// --------------------------------------------------------------------------- - -void MainView::init(HbApplication &app) -{ - mEngineWrapper.init(); - this->setTitle("Creator"); - createMenu(app); - createMemoryInfoText(); -} - -void MainView::createMenu(HbApplication& app) -{ - HbMenu* menu = this->menu(); - - // signal mapper for identifying the different command actions - // in executeCommand() handler function: - mSm = new QSignalMapper(this); - connect(mSm, SIGNAL(mapped(int)), this, SLOT(executeMenuCommand(int))); - - if (menu != NULL) { - - // Run script menu item: - mActionRunScript = menu->addAction("Run script"); - connect(mActionRunScript, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionRunScript, ECmdCreateFromFile); - - // Calendar sub-menu items: - HbMenu* calendarSubMenu = new HbMenu("Calendar"); - menu->addMenu(calendarSubMenu); - mActionCalendarAppointments = calendarSubMenu->addAction("Appointments"); - mActionCalendarEvents = calendarSubMenu->addAction("Events"); - mActionCalendarAnniversaries = calendarSubMenu->addAction("Anniversaries"); - mActionCalendarTodos = calendarSubMenu->addAction("Todos"); - mActionCalendarReminders = calendarSubMenu->addAction("Reminders"); - - connect(mActionCalendarAppointments, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionCalendarAppointments, ECmdCreateCalendarEntryAppointments); - - connect(mActionCalendarEvents, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionCalendarEvents, ECmdCreateCalendarEntryEvents); - - connect(mActionCalendarAnniversaries, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionCalendarAnniversaries, ECmdCreateCalendarEntryAnniversaries); - - connect(mActionCalendarTodos, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionCalendarTodos, ECmdCreateCalendarEntryToDos); - - connect(mActionCalendarReminders, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionCalendarReminders, ECmdCreateCalendarEntryReminders); -/* - // Browser sub-menu items: - HbMenu* browserSubMenu = new HbMenu("Browser"); - menu->addMenu(browserSubMenu); - mActionBrowserBookmark = browserSubMenu->addAction("Bookmarks"); - mActionBrowserBmarkFolder = browserSubMenu->addAction("Bookmark folders"); - mActionBrowserSavedPages = browserSubMenu->addAction("Saved pages"); - mActionBrowserSavedPageFolders = browserSubMenu->addAction("Saved page folders"); - - connect(mActionBrowserBookmark, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionBrowserBookmark, ECmdCreateBrowserBookmarkEntries); - - connect(mActionBrowserBmarkFolder, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionBrowserBmarkFolder, ECmdCreateBrowserBookmarkFolderEntries); - - connect(mActionBrowserSavedPages, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionBrowserSavedPages, ECmdCreateBrowserSavedPageEntries); - - connect(mActionBrowserSavedPageFolders, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionBrowserSavedPageFolders, ECmdCreateBrowserSavedPageFolderEntries); -*/ - // Files sub-menu items: - HbMenu* filesSubMenu = new HbMenu("Files"); - menu->addMenu(filesSubMenu); - - mActionFilesEmptyFolder = filesSubMenu->addAction("Empty folder"); - - connect(mActionFilesEmptyFolder, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionFilesEmptyFolder, ECmdCreateFileEntryEmptyFolder); - - mActionFilesJpeg25 = filesSubMenu->addAction("JPEG 25kB"); - connect(mActionFilesJpeg25, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionFilesJpeg25, ECmdCreateFileEntryJPEG_25kB); - - mActionFilesJpeg200 = filesSubMenu->addAction("JPEG 200kB"); - connect(mActionFilesJpeg200, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionFilesJpeg200, ECmdCreateFileEntryJPEG_200kB); - - mActionFilesJpeg500 = filesSubMenu->addAction("JPEG 500kB"); - connect(mActionFilesJpeg500, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionFilesJpeg500, ECmdCreateFileEntryJPEG_500kB); - - mActionFilesPng15 = filesSubMenu->addAction("PNG 15kB"); - connect(mActionFilesPng15, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionFilesPng15, ECmdCreateFileEntryPNG_15kB); - - mActionFilesGif2 = filesSubMenu->addAction("GIF 2kB"); - connect(mActionFilesGif2, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionFilesGif2, ECmdCreateFileEntryGIF_2kB); - - mActionFilesBmp25 = filesSubMenu->addAction("BMP 25kB"); - connect(mActionFilesBmp25, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionFilesBmp25, ECmdCreateFileEntryBMP_25kB); - - mActionFilesJp265 = filesSubMenu->addAction("JP2 65kB"); - connect(mActionFilesJp265, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionFilesJp265, ECmdCreateFileEntryJP2_65kB); - - mActionFilesSvg15 = filesSubMenu->addAction("SVG 15kB"); - connect(mActionFilesSvg15, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionFilesSvg15, ECmdCreateFileEntrySVG_15kB); - - mActionFilesTif25 = filesSubMenu->addAction("TIF 25kB"); - connect(mActionFilesTif25, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionFilesTif25, ECmdCreateFileEntryTIF_25kB); - - mActionFilesRng1 = filesSubMenu->addAction("RNG 1kB"); - connect(mActionFilesRng1, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionFilesRng1, ECmdCreateFileEntryRNG_1kB); - - mActionFilesMidi10 = filesSubMenu->addAction("MIDI 10kB"); - connect(mActionFilesMidi10, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionFilesMidi10, ECmdCreateFileEntryMIDI_10kB); - - mActionFilesWave20 = filesSubMenu->addAction("WAVE 20kB"); - connect(mActionFilesWave20, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionFilesWave20, ECmdCreateFileEntryWAV_20kB); - - mActionFilesAmr20 = filesSubMenu->addAction("AMR 20kB"); - connect(mActionFilesAmr20, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionFilesAmr20, ECmdCreateFileEntryAMR_20kB); - - mActionFilesExcel15 = filesSubMenu->addAction("Excel 15kB"); - connect(mActionFilesExcel15, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionFilesExcel15, ECmdCreateFileEntryXLS_15kB); - - mActionFilesWord20 = filesSubMenu->addAction("Word 20kB"); - connect(mActionFilesWord20, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionFilesWord20, ECmdCreateFileEntryDOC_20kB); - - mActionFilesPPoint40 = filesSubMenu->addAction("PowerPoint 40kB"); - connect(mActionFilesPPoint40, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionFilesPPoint40, ECmdCreateFileEntryPPT_40kB); - - mActionFilesText10 = filesSubMenu->addAction("Text 10kB"); - connect(mActionFilesText10, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionFilesText10, ECmdCreateFileEntryTXT_10kB); - - mActionFilesText70 = filesSubMenu->addAction("Text 70kB"); - connect(mActionFilesText70, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionFilesText70, ECmdCreateFileEntryTXT_70kB); - - mActionFilesHtml20 = filesSubMenu->addAction("HTML 20kB"); - connect(mActionFilesHtml20, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionFilesHtml20, ECmdCreateFileEntryHTML_20kB); - - mActionFilesMxmf40 = filesSubMenu->addAction("MXMF 40kB"); - connect(mActionFilesMxmf40, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionFilesMxmf40, ECmdCreateFileEntryMXMF_40kB); - - mActionFilesRam1 = filesSubMenu->addAction("RAM 1kB"); - connect(mActionFilesRam1, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionFilesRam1, ECmdCreateFileEntryRAM_1kB); - - mActionFilesJad1 = filesSubMenu->addAction("JAD 1kB"); - connect(mActionFilesJad1, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionFilesJad1, ECmdCreateFileEntryJAD_1kB); - - mActionFilesJar10 = filesSubMenu->addAction("JAR 10kB"); - connect(mActionFilesJar10, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionFilesJar10, ECmdCreateFileEntryJAR_10kB); - - mActionFilesVcf1 = filesSubMenu->addAction("VCF 1kB"); - connect(mActionFilesVcf1, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionFilesVcf1, ECmdCreateFileEntryVCF_1kB); - - mActionFilesVcs1 = filesSubMenu->addAction("VCS 1kB"); - connect(mActionFilesVcs1, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionFilesVcs1, ECmdCreateFileEntryVCS_1kB); - - mActionFilesSisx10 = filesSubMenu->addAction("SISX 10kB"); - connect(mActionFilesSisx10, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionFilesSisx10, ECmdCreateFileEntrySISX_10kB); - - mActionFiles3Gpp70 = filesSubMenu->addAction("3GPP 70kB"); - connect(mActionFiles3Gpp70, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionFiles3Gpp70, ECmdCreateFileEntry3GPP_70kB); - - mActionFilesMp3250 = filesSubMenu->addAction("MP3 250kB"); - connect(mActionFilesMp3250, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionFilesMp3250, ECmdCreateFileEntryMP3_250kB); - - mActionFilesAAC100 = filesSubMenu->addAction("AAC 100kB"); - connect(mActionFilesAAC100, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionFilesAAC100, ECmdCreateFileEntryAAC_100kB); - - mActionFilesSwf15 = filesSubMenu->addAction("SWF 15kB"); - connect(mActionFilesSwf15, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionFilesSwf15, ECmdCreateFileEntrySWF_15kB); - - mActionFilesMp4200 = filesSubMenu->addAction("MP4 200kB"); - connect(mActionFilesMp4200, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionFilesMp4200, ECmdCreateFileEntryMP4_200kB); - - mActionFilesRm95 = filesSubMenu->addAction("RM 95kB"); - connect(mActionFilesRm95, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionFilesRm95, ECmdCreateFileEntryRM_95kB); - - mActionFilesWma50 = filesSubMenu->addAction("WMA 50kB"); - connect(mActionFilesWma50, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionFilesWma50, ECmdCreateFileEntryWMA_50kB); - - mActionFilesWmv200 = filesSubMenu->addAction("WMV 200kB"); - connect(mActionFilesWmv200, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionFilesWmv200, ECmdCreateFileEntryWMV_200kB); - - // Logs sub-menu items: - HbMenu* logsSubMenu = new HbMenu("Logs"); - menu->addMenu(logsSubMenu); - - mActionLogsMissedCalls = logsSubMenu->addAction("Missed calls"); - connect(mActionLogsMissedCalls, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionLogsMissedCalls, ECmdCreateLogEntryMissedCalls); - - mActionLogsReceivedCalls = logsSubMenu->addAction("Received calls"); - connect(mActionLogsReceivedCalls, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionLogsReceivedCalls, ECmdCreateLogEntryReceivedCalls); - - mActionLogsDialledNumbers = logsSubMenu->addAction("Dialled numbers"); - connect(mActionLogsDialledNumbers, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionLogsDialledNumbers, ECmdCreateLogEntryDialledNumbers); - - // Messaging sub-menu items: - HbMenu* messageSubMenu = new HbMenu("Messaging"); - menu->addMenu(messageSubMenu); - - mActionMessageMailboxes = messageSubMenu->addAction("Mailboxes"); - connect(mActionMessageMailboxes, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionMessageMailboxes, ECmdCreateMessagingEntryMailboxes); - - mActionMessages = messageSubMenu->addAction("Messages"); - connect(mActionMessages, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionMessages, ECmdCreateMessagingEntryMessages); - - // Misc sub-menu items: - HbMenu* miscSubMenu = new HbMenu("Misc"); - menu->addMenu(miscSubMenu); - - //mActionMiscConnection = miscSubMenu->addAction("Connection methods"); - //mActionMiscImps = miscSubMenu->addAction("IMPS servers"); - mActionMiscNotes = miscSubMenu->addAction("Notes"); - //mActionMiscLandmarks = miscSubMenu->addAction("Landmarks"); -/* - connect(mActionMiscConnection, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionMiscConnection, ECmdCreateMiscEntryAccessPoints); - - connect(mActionMiscImps, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionMiscImps, ECmdCreateMiscEntryIMPSServers); -*/ - connect(mActionMiscNotes, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionMiscNotes, ECmdCreateMiscEntryNotes); -/* - connect(mActionMiscLandmarks, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionMiscLandmarks, ECmdCreateMiscEntryLandmarks); -*/ - // Phonebook sub-menu items: - HbMenu* phonebookSubMenu = new HbMenu("Phonebook"); - menu->addMenu(phonebookSubMenu); - - mActionPhonebookContacts = phonebookSubMenu->addAction("Contacts"); - connect(mActionPhonebookContacts, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionPhonebookContacts, ECmdCreatePhoneBookEntryContacts); - - mActionPhonebookGroups = phonebookSubMenu->addAction("Groups"); - connect(mActionPhonebookGroups, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionPhonebookGroups, ECmdCreatePhoneBookEntryGroups); - - // Delete sub-menu items: - HbMenu* deleteSubMenu = new HbMenu("Delete"); - menu->addMenu(deleteSubMenu); - - HbMenu* deleteAllSubMenu = new HbMenu("All items"); - deleteSubMenu->addMenu(deleteAllSubMenu); - - mActionDeleteAllItems = deleteAllSubMenu->addAction("All"); - connect(mActionDeleteAllItems, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionDeleteAllItems, ECmdDeleteAllEntries); - - mActionDeleteCreatorItems = deleteAllSubMenu->addAction("By Creator"); - connect(mActionDeleteCreatorItems, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionDeleteCreatorItems, ECmdDeleteAllCreatorEntries); - - HbMenu* deleteCalendarSubMenu = new HbMenu("Calendar entries"); - deleteSubMenu->addMenu(deleteCalendarSubMenu); - - mActionDeleteCalAllItems = deleteCalendarSubMenu->addAction("All"); - connect(mActionDeleteCalAllItems, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionDeleteCalAllItems, ECmdDeleteCalendarEntries); - - mActionDeleteCalCreatorItems = deleteCalendarSubMenu->addAction("By Creator"); - connect(mActionDeleteCalCreatorItems, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionDeleteCalCreatorItems, ECmdDeleteCreatorCalendarEntries); -/* - HbMenu* deleteBookmarksSubMenu = new HbMenu("Br bookmarks"); - deleteSubMenu->addMenu(deleteBookmarksSubMenu); - - mActionDeleteBookmarkAllItems = deleteBookmarksSubMenu->addAction("All"); - connect(mActionDeleteBookmarkAllItems, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionDeleteBookmarkAllItems, ECmdDeleteBrowserBookmarks); - - mActionDeleteBookmarkCreatorItems = deleteBookmarksSubMenu->addAction("By Creator"); - connect(mActionDeleteBookmarkCreatorItems, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionDeleteBookmarkCreatorItems, ECmdDeleteCreatorBrowserBookmarks); - - HbMenu* deleteBookmarkFoldersSubMenu = new HbMenu("Br bookmark folders"); - deleteSubMenu->addMenu(deleteBookmarkFoldersSubMenu); - - mActionDeleteBookmarkFolderAllItems = deleteBookmarkFoldersSubMenu->addAction("All"); - connect(mActionDeleteBookmarkFolderAllItems, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionDeleteBookmarkFolderAllItems, ECmdDeleteBrowserBookmarkFolders); - - mActionDeleteBookmarkFolderCreatorItems = deleteBookmarkFoldersSubMenu->addAction("By Creator"); - connect(mActionDeleteBookmarkFolderCreatorItems, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionDeleteBookmarkFolderCreatorItems, ECmdDeleteCreatorBrowserBookmarkFolders); - - HbMenu* deleteSavedPagesSubMenu = new HbMenu("Br saved pages"); - deleteSubMenu->addMenu(deleteSavedPagesSubMenu); - - mActionDeleteSavedPagesAllItems = deleteSavedPagesSubMenu->addAction("All"); - connect(mActionDeleteSavedPagesAllItems, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionDeleteSavedPagesAllItems, ECmdDeleteBrowserSavedPages); - - mActionDeleteSavedPagesCreatorItems = deleteSavedPagesSubMenu->addAction("By Creator"); - connect(mActionDeleteSavedPagesCreatorItems, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionDeleteSavedPagesCreatorItems, ECmdDeleteCreatorBrowserSavedPages); - - HbMenu* deleteSavedPagesFolderSubMenu = new HbMenu("Br saved page folders"); - deleteSubMenu->addMenu(deleteSavedPagesFolderSubMenu); - - mActionDeleteSavedPagesFolderAllItems = deleteSavedPagesFolderSubMenu->addAction("All"); - connect(mActionDeleteSavedPagesFolderAllItems, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionDeleteSavedPagesFolderAllItems, ECmdDeleteBrowserSavedPageFolders); - - mActionDeleteSavedPagesFolderCreatorItems = deleteSavedPagesFolderSubMenu->addAction("By Creator"); - connect(mActionDeleteSavedPagesFolderCreatorItems, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionDeleteSavedPagesFolderCreatorItems, ECmdDeleteCreatorBrowserSavedPageFolders); -*/ - HbMenu* deleteFilesSubMenu = new HbMenu("Files"); - deleteSubMenu->addMenu(deleteFilesSubMenu); - - mActionDeleteFiles = deleteFilesSubMenu->addAction("By Creator"); - connect(mActionDeleteFiles, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionDeleteFiles, ECmdDeleteCreatorFiles); - - HbMenu* deleteLogsSubMenu = new HbMenu("Logs"); - deleteSubMenu->addMenu(deleteLogsSubMenu); - - mActionDeleteLogsAll = deleteLogsSubMenu->addAction("All"); - connect(mActionDeleteLogsAll, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionDeleteLogsAll, ECmdDeleteLogs); - - mActionDeleteLogsByCreator = deleteLogsSubMenu->addAction("By Creator"); - connect(mActionDeleteLogsByCreator, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionDeleteLogsByCreator, ECmdDeleteCreatorLogs); - - HbMenu* deleteMessagesSubMenu = new HbMenu("Messages"); - deleteSubMenu->addMenu(deleteMessagesSubMenu); - - mActionDeleteMessagesAll = deleteMessagesSubMenu->addAction("All"); - connect(mActionDeleteMessagesAll, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionDeleteMessagesAll, ECmdDeleteMessages); - - mActionDeleteMessagesByCreator = deleteMessagesSubMenu->addAction("By Creator"); - connect(mActionDeleteMessagesByCreator, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionDeleteMessagesByCreator, ECmdDeleteCreatorMessages); -/* - HbMenu* deleteConnMethsSubMenu = new HbMenu("Connection methods"); - deleteSubMenu->addMenu(deleteConnMethsSubMenu); - - mActionDeleteConnMethsAll = deleteConnMethsSubMenu->addAction("All"); - connect(mActionDeleteConnMethsAll, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionDeleteConnMethsAll, ECmdDeleteMessages); - - mActionDeleteConnMethsByCreator = deleteConnMethsSubMenu->addAction("By Creator"); - connect(mActionDeleteConnMethsByCreator, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionDeleteConnMethsByCreator, ECmdDeleteCreatorMessages); - - HbMenu* deleteImpsSubMenu = new HbMenu("IMPS servers"); - deleteSubMenu->addMenu(deleteImpsSubMenu); - - mActionDeleteImpsAll = deleteImpsSubMenu->addAction("All"); - connect(mActionDeleteImpsAll, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionDeleteImpsAll, ECmdDeleteIMPSs); - - mActionDeleteImpsByCreator = deleteImpsSubMenu->addAction("By Creator"); - connect(mActionDeleteImpsByCreator, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionDeleteImpsByCreator, ECmdDeleteCreatorIMPSs); -*/ - HbMenu* deleteNotesSubMenu = new HbMenu("Notes"); - deleteSubMenu->addMenu(deleteNotesSubMenu); - - mActionDeleteNotes = deleteNotesSubMenu->addAction("All"); - connect(mActionDeleteNotes, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionDeleteNotes, ECmdDeleteNotes); -/* - HbMenu* deleteLandmarksSubMenu = new HbMenu("Landmarks"); - deleteSubMenu->addMenu(deleteLandmarksSubMenu); - - mActionDeleteLandmarksAll = deleteLandmarksSubMenu->addAction("All"); - connect(mActionDeleteLandmarksAll, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionDeleteLandmarksAll, ECmdDeleteLandmarks); - - mActionDeleteLandmarksByCreator = deleteLandmarksSubMenu->addAction("By Creator"); - connect(mActionDeleteLandmarksByCreator, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionDeleteLandmarksByCreator, ECmdDeleteCreatorLandmarks); -*/ - HbMenu* deleteContactsSubMenu = new HbMenu("Contacts"); - deleteSubMenu->addMenu(deleteContactsSubMenu); - - mActionDeleteContactsAll = deleteContactsSubMenu->addAction("All"); - connect(mActionDeleteContactsAll, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionDeleteContactsAll, ECmdDeleteContacts); - - mActionDeleteContactsByCreator = deleteContactsSubMenu->addAction("By Creator"); - connect(mActionDeleteContactsByCreator, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionDeleteContactsByCreator, ECmdDeleteCreatorContacts); - - HbMenu* deleteContactGroupsSubMenu = new HbMenu("Contact groups"); - deleteSubMenu->addMenu(deleteContactGroupsSubMenu); - - mActionDeleteContactGroupsAll = deleteContactGroupsSubMenu->addAction("All"); - connect(mActionDeleteContactGroupsAll, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionDeleteContactGroupsAll, ECmdDeleteContactGroups); - - mActionDeleteContactGroupsByCreator = deleteContactGroupsSubMenu->addAction("By Creator"); - connect(mActionDeleteContactGroupsByCreator, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionDeleteContactGroupsByCreator, ECmdDeleteCreatorContactGroups); -/* - // select random data file: - mActionSelectRandomFile = menu->addAction("Select random data file"); - connect(mActionSelectRandomFile, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mActionSelectRandomFile, ECmdSelectRandomDataFile); -*/ - // About & exit menu items: - mActionAbout = menu->addAction("About Creator"); - connect(mActionAbout, SIGNAL( triggered() ), this, SLOT( showAboutPopup() ) ); - - mActionExit = menu->addAction("Exit"); - connect(mActionExit, SIGNAL(triggered()), &app, SLOT( quit() ) ); - - this->setMenu(menu); - } -} - -// --------------------------------------------------------------------------- - -void MainView::createMemoryInfoText() -{ - QGraphicsLinearLayout* layout = new QGraphicsLinearLayout(Qt::Vertical, this); - - // get memory details from engine; - mMemoryDetails = mEngineWrapper.GetMemoryDetails(); - - QList memDet = mEngineWrapper.GetMemoryDetailsList(); - - if (layout != NULL) - { - HbLabel* edit = new HbLabel(this); - //HbTextEdit* edit = new HbTextEdit(this); - if(edit != NULL) - { - QString text = QString("

    Free RAM Memory:
    %1 of %2 kB").arg(mMemoryDetails.mRamFree).arg(mMemoryDetails.mRamSize); - //QString text = QString("\n\nFree RAM Memory:\n %1 of %2 kB").arg(mMemoryDetails.mRamFree).arg(mMemoryDetails.mRamSize); - for(int i=0 ; i < memDet.count() ; i++ ) - { - text += QString("

    Free %1: Memory:
    %2 of %3 kB").arg(memDet[i].mDriveLetter).arg(memDet[i].mFree).arg(memDet[i].mSize);//text += QString("\n\nFree %1: Memory:\n %2 of %3 kB").arg(memDet[i].mDriveLetter).arg(memDet[i].mFree).arg(memDet[i].mSize); - } - edit->setTextWrapping(Hb::TextWordWrap); - edit->setHtml(text); - //edit->setPlainText(text); - - //edit->setReadOnly(true); - //edit->setCursorHidden(true); - edit->setAttribute(Qt::WA_InputMethodEnabled, false); - layout->addItem(edit); - layout->setContentsMargins(5, 5, 5, 5); - this->setLayout(layout); - } - - } - -} - - -// --------------------------------------------------------------------------- - -void MainView::showAboutPopup() -{ - Notifications::about(); - -} - -// --------------------------------------------------------------------------- - -void MainView::executeMenuCommand(int cmd) -{ - switch (cmd) { - case ECmdCreateFromFile: - case ECmdCreateCalendarEntryAppointments: - case ECmdCreateCalendarEntryEvents: - case ECmdCreateCalendarEntryAnniversaries: - case ECmdCreateCalendarEntryToDos: - case ECmdCreateCalendarEntryReminders: - case ECmdCreateBrowserBookmarkEntries: - case ECmdCreateBrowserBookmarkFolderEntries: - case ECmdCreateBrowserSavedPageEntries: - case ECmdCreateBrowserSavedPageFolderEntries: - case ECmdCreateFileEntryEmptyFolder: - case ECmdCreateFileEntry3GPP_70kB: - case ECmdCreateFileEntryAAC_100kB: - case ECmdCreateFileEntryAMR_20kB: - case ECmdCreateFileEntryBMP_25kB: - case ECmdCreateFileEntryDeck_1kB: - case ECmdCreateFileEntryDOC_20kB: - case ECmdCreateFileEntryGIF_2kB: - case ECmdCreateFileEntryHTML_20kB: - case ECmdCreateFileEntryJAD_1kB: - case ECmdCreateFileEntryJAR_10kB: - case ECmdCreateFileEntryJP2_65kB: - case ECmdCreateFileEntryJPEG_200kB: - case ECmdCreateFileEntryJPEG_25kB: - case ECmdCreateFileEntryJPEG_500kB: - case ECmdCreateFileEntryMIDI_10kB: - case ECmdCreateFileEntryMP3_250kB: - case ECmdCreateFileEntryMP4_200kB: - case ECmdCreateFileEntryMXMF_40kB: - case ECmdCreateFileEntryPNG_15kB: - case ECmdCreateFileEntryPPT_40kB: - case ECmdCreateFileEntryRAM_1kB: - case ECmdCreateFileEntryRM_95kB: - case ECmdCreateFileEntryRNG_1kB: - case ECmdCreateFileEntrySVG_15kB: - case ECmdCreateFileEntrySWF_15kB: - case ECmdCreateFileEntryTIF_25kB: - case ECmdCreateFileEntryTXT_10kB: - case ECmdCreateFileEntryTXT_70kB: - case ECmdCreateFileEntryVCF_1kB: - case ECmdCreateFileEntryVCS_1kB: - case ECmdCreateFileEntryWAV_20kB: - case ECmdCreateFileEntryXLS_15kB: - case ECmdCreateFileEntrySISX_10kB: - case ECmdCreateFileEntryWMA_50kB: - case ECmdCreateFileEntryWMV_200kB: - case ECmdCreateLogEntryMissedCalls: - case ECmdCreateLogEntryReceivedCalls: - case ECmdCreateLogEntryDialledNumbers: - case ECmdCreateMessagingEntryMailboxes: - case ECmdCreateMessagingEntryMessages: - case ECmdCreateMiscEntryAccessPoints: - case ECmdCreateMiscEntryIMPSServers: - case ECmdCreateMiscEntryNotes: - case ECmdCreateMiscEntryLandmarks: - case ECmdCreatePhoneBookEntryContacts: - case ECmdCreatePhoneBookEntryGroups: - case ECmdDeleteAllEntries: - case ECmdDeleteAllCreatorEntries: - case ECmdDeleteContacts: - case ECmdDeleteCreatorContacts: - case ECmdDeleteContactGroups: - case ECmdDeleteCreatorContactGroups: - case ECmdDeleteCalendarEntries: - case ECmdDeleteCreatorCalendarEntries: - case ECmdDeleteBrowserBookmarks: - case ECmdDeleteCreatorBrowserBookmarks: - case ECmdDeleteBrowserBookmarkFolders: - case ECmdDeleteCreatorBrowserBookmarkFolders: - case ECmdDeleteBrowserSavedPages: - case ECmdDeleteCreatorBrowserSavedPages: - case ECmdDeleteBrowserSavedPageFolders: - case ECmdDeleteCreatorBrowserSavedPageFolders: - case ECmdDeleteCreatorFiles: - case ECmdDeleteLogs: - case ECmdDeleteCreatorLogs: - case ECmdDeleteMessages: - case ECmdDeleteCreatorMessages: - case ECmdDeleteMailboxes: - case ECmdDeleteCreatorMailboxes: - case ECmdDeleteIAPs: - case ECmdDeleteCreatorIAPs: - case ECmdDeleteIMPSs: - case ECmdDeleteCreatorIMPSs: - case ECmdDeleteNotes: - case ECmdDeleteLandmarks: - case ECmdDeleteCreatorLandmarks: - case ECmdSelectRandomDataFile: { - mEngineWrapper.ExecuteOptionsMenuCommand(cmd); - break; - } - default: { - Notifications::error(QString("Unsupported command: %1").arg(cmd)); - break; - } - } -} - -void MainView::closeApp() -{ - qApp->quit(); -} - -// --------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 creator/src/notifications.cpp --- a/creator/src/notifications.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,308 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "notifications.h" - -// --------------------------------------------------------------------------- - -void Notifications::showMessageBox(HbMessageBox::MessageBoxType type, const QString &text, const QString &label, int timeout ) -{ - HbMessageBox *messageBox = new HbMessageBox(type); - messageBox->setText(text); - messageBox->setStandardButtons( HbMessageBox::Ok ); - if(label.length()) - { - HbLabel *header = new HbLabel(label, messageBox); - messageBox->setHeadingWidget(header); - } - messageBox->setAttribute(Qt::WA_DeleteOnClose); - messageBox->setTimeout(timeout); - messageBox->open(); -} - -// --------------------------------------------------------------------------- - -void Notifications::about() -{ - showMessageBox(HbMessageBox::MessageTypeInformation, - "Version 6.1.2 - September 9th 2010. Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. Licensed under Eclipse Public License v1.0.", - "About Creator", - HbPopup::NoTimeout - ); -} - -// --------------------------------------------------------------------------- - -void Notifications::error(const QString& errorMessage) -{ - showMessageBox(HbMessageBox::MessageTypeWarning, errorMessage, QString("Error"), 3000); -} - - -// --------------------------------------------------------------------------- - -HbProgressDialog* Notifications::showProgressBar(const QString& text, int max) -{ - HbProgressDialog *note = new HbProgressDialog(HbProgressDialog::ProgressDialog); - note->setText(text); - note->setMaximum(max); - note->setAutoClose(false); - note->show(); - return note; - -} - -// --------------------------------------------------------------------------- - -void Notifications::showGlobalNote(const QString& text, HbMessageBox::MessageBoxType type, int timeout) -{ - showMessageBox(type, text, QString("Creator"), timeout); -} - - -// --------------------------------------------------------------------------- - -CreatorYesNoDialog::CreatorYesNoDialog(MUIObserver* observer, int userData) : - HbMessageBox(HbMessageBox::MessageTypeQuestion, NULL), - CreatorDialog(observer, userData) -{ -} - -void CreatorYesNoDialog::launch(const QString& text, const QString& label, MUIObserver* observer, int userData) throw(std::exception) -{ - CreatorYesNoDialog* dlg = new CreatorYesNoDialog(observer, userData); - dlg->setStandardButtons( HbMessageBox::Yes | HbMessageBox::No ); - dlg->setText(text); - if(label.length()) - dlg->setHeadingWidget(new HbLabel(label, dlg)); - dlg->setAttribute(Qt::WA_DeleteOnClose); - dlg->setTimeout(HbPopup::NoTimeout); - dlg->open(dlg, SLOT(DialogClosed(HbAction*))); -} - -void CreatorYesNoDialog::DialogClosed(HbAction *action) -{ - TBool PositiveAction(EFalse); - if(action && (action->softKeyRole()==QAction::PositiveSoftKey || !action->text().compare("yes", Qt::CaseInsensitive))){ - PositiveAction = ETrue; - } - NotifyObserver(PositiveAction); -} - -CreatorInputDialog::CreatorInputDialog(int* value, MUIObserver* module, int userData) : - HbInputDialog(NULL), - CreatorDialog(module, userData), - mIntValue(value), - mStrValue(mDummy)// will not be used -{ - if(!value) - throw std::invalid_argument("value cannot be the null!"); -} - -CreatorInputDialog::CreatorInputDialog(TDes& value, MUIObserver* module, int userData) : - HbInputDialog(NULL), - CreatorDialog(module, userData), - mIntValue(NULL), - mStrValue(value) -{ -} - -void CreatorInputDialog::launch(const QString& label, int* value, bool acceptsZero, MUIObserver* observer, int userData) throw( std::exception ) -{ - CreatorInputDialog* dlg = new CreatorInputDialog(value, observer, userData); - dlg->setPromptText(label); - dlg->setInputMode(IntInput); - HbValidator *validator = new HbValidator(dlg); - QString tmp; - if (acceptsZero == false) { - tmp.append("^[1-9]{1}\\d{0,4}"); - } - else { - tmp.append("^[0-9]{1,5}"); - } - - QRegExp rxBasic(tmp); - validator->addField(new QRegExpValidator(rxBasic, 0), ""); - dlg->setValidator(validator); - dlg->setValue(QVariant(*value)); - dlg->lineEdit()->setSelection(0, dlg->value().toString().length()); - dlg->setAttribute(Qt::WA_DeleteOnClose); - dlg->open(dlg, SLOT(DialogClosed(HbAction*))); -} - -void CreatorInputDialog::launch(const QString& label, TDes& value, MUIObserver* observer, int userData) throw( std::exception ) -{ - CreatorInputDialog* dlg = new CreatorInputDialog(value, observer, userData); - dlg->setPromptText(label); - dlg->lineEdit()->setMaxLength(value.MaxLength()); - dlg->setValue(QString::fromUtf16(value.Ptr(), value.Length())); - dlg->lineEdit()->setSelection(0, dlg->value().toString().length()); - dlg->setInputMode(TextInput); - dlg->setAttribute(Qt::WA_DeleteOnClose); - dlg->open(dlg, SLOT(DialogClosed(HbAction*))); -} - -void CreatorInputDialog::DialogClosed(HbAction *action) -{ - TBool PositiveAction(EFalse); - if(action && (action->softKeyRole()==QAction::PositiveSoftKey || !action->text().compare("ok", Qt::CaseInsensitive))){ - bool ok = true; - if( inputMode() == IntInput ) - *mIntValue = value().toInt(&ok); - else if( inputMode() == TextInput && mStrValue.MaxLength() >= value().toString().length() ) - mStrValue.Copy(value().toString().utf16()); - else - ok = false; - PositiveAction = ok ? ETrue : EFalse; - } - NotifyObserver(PositiveAction); -} - -CreatorSelectionDialog::CreatorSelectionDialog(int* selectedItem, MUIObserver* observer, int userData) throw(std::exception) : - HbSelectionDialog(NULL), - CreatorDialog(observer, userData), - mSelectedItem(selectedItem), - mSelectedItems(NULL) -{ - if(!mSelectedItem) - throw std::invalid_argument("selectedItem cannot be null!"); -} - -CreatorSelectionDialog::CreatorSelectionDialog(CArrayFixFlat* selectedItems, MUIObserver* observer, int userData) throw(std::exception) : - HbSelectionDialog(NULL), - CreatorDialog(observer, userData), - mSelectedItem(NULL), - mSelectedItems(selectedItems) -{ - if(!mSelectedItems) - throw std::invalid_argument("selectedItems cannot be null!"); -} - -void CreatorSelectionDialog::launch(const QString& label, const QStringList& items, int* selectedItem, MUIObserver* observer, int userData) throw(std::exception) -{ - CreatorSelectionDialog* dlg = new CreatorSelectionDialog(selectedItem, observer, userData); - if(label.length()) - dlg->setHeadingWidget(new HbLabel(label, dlg)); - dlg->setStringItems(items); - dlg->setSelectionMode(HbAbstractItemView::SingleSelection); - dlg->setSelectedItems(QList()); - dlg->setAttribute(Qt::WA_DeleteOnClose); - dlg->open(dlg, SLOT(DialogClosed(HbAction*))); -} - -void CreatorSelectionDialog::launch(const QString& label, const QStringList& items, CArrayFixFlat* selectedItems, MUIObserver* observer, int userData) throw(std::exception) -{ - CreatorSelectionDialog* dlg = new CreatorSelectionDialog(selectedItems, observer, userData); - if(label.length()) - dlg->setHeadingWidget(new HbLabel(label, dlg)); - dlg->setStringItems(items); - dlg->setSelectionMode(HbAbstractItemView::MultiSelection); - dlg->setAttribute(Qt::WA_DeleteOnClose); - dlg->open(dlg, SLOT(DialogClosed(HbAction*))); -} - -void CreatorSelectionDialog::DialogClosed(HbAction *action) -{ - TBool PositiveAction(EFalse); - //CreatorSelectionDialog* dlg = qobject_cast(sender()); - if(!action || (action && action->softKeyRole()==QAction::SelectSoftKey) || (action && !action->text().compare("ok", Qt::CaseInsensitive))){ - if(selectedItems().count()){ - try{ - if( selectionMode() == HbAbstractItemView::SingleSelection && mSelectedItem){ - bool ok(false); - *mSelectedItem = selectedItems().at(0).toInt(&ok); - if(!ok) - throw std::invalid_argument("cannot obtain selected item!"); - } - if( selectionMode() == HbAbstractItemView::MultiSelection && mSelectedItems){ - QList items = selectedItems(); - foreach( QVariant item, items){ - QT_TRAP_THROWING( mSelectedItems->AppendL( item.toInt() ) ); - } - } - PositiveAction = ETrue; - } - catch (std::exception& e){ - Notifications::error( QString("exception: ")+e.what() ); - } - } - } - NotifyObserver(PositiveAction); -} - -CreatorDateTimeDialog::CreatorDateTimeDialog(TTime* value, MUIObserver* observer, int userData) : - HbDialog(NULL), - CreatorDialog(observer, userData), - mValue(value) -{ -} - -void CreatorDateTimeDialog::launch(const QString& label, TTime* value, MUIObserver* observer, int userData) throw( std::exception ) -{ - CreatorDateTimeDialog* dlg = new CreatorDateTimeDialog(value, observer, userData); - if(!value) - throw std::invalid_argument("value cannot be the null!"); - if(label.length()) - dlg->setHeadingWidget( new HbLabel(label, dlg) ); - - // TTime to QDate - TBuf<20> timeString; - _LIT(KDateString,"%D%M%Y%/0%1%/1%2%/2%3%/3"); - TRAP_IGNORE( value->FormatL(timeString, KDateString) ); - QString temp = QString::fromUtf16(timeString.Ptr(), timeString.Length()); - temp.replace(QChar('/'), QChar('-')); - QDate date = QDate::fromString(temp, "dd-MM-yyyy"); - HbDateTimePicker* widget = new HbDateTimePicker( date, dlg ); - dlg->setContentWidget( widget ); - dlg->addAction(new HbAction("Ok", dlg)); - dlg->addAction(new HbAction("Cancel", dlg)); - dlg->setModal(true); // Dialog is modal - dlg->setAttribute(Qt::WA_DeleteOnClose); - dlg->setTimeout(HbPopup::NoTimeout); - dlg->open(dlg, SLOT(DialogClosed(HbAction*))); -} - -void CreatorDateTimeDialog::DialogClosed(HbAction *action) -{ - TBool PositiveAction(EFalse); - if(action && (action->softKeyRole()==QAction::PositiveSoftKey || !action->text().compare("ok", Qt::CaseInsensitive))){ - QString str = qobject_cast(contentWidget())->date().toString(Qt::ISODate); - str.remove('-'); - str += ":000000";// 0h 0m 0s - TBuf<30> dateTimeString(str.utf16()); - mValue->Set(dateTimeString); - PositiveAction = ETrue; - } - NotifyObserver(PositiveAction); -} -//End of File diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/engine/FB.hrh --- a/filebrowser/engine/FB.hrh Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,294 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef FILEBROWSER_HRH -#define FILEBROWSER_HRH - -enum TFileBrowserCommandIds - { - EFileBrowserCmdFile = 1, - EFileBrowserCmdFileBack, - EFileBrowserCmdFileOpen, - EFileBrowserCmdFileOpenApparc, - EFileBrowserCmdFileOpenDocHandlerEmbed, - EFileBrowserCmdFileOpenDocHandlerStandAlone, - EFileBrowserCmdFileOpenFileService, - EFileBrowserCmdFileOpenDrive, - EFileBrowserCmdFileOpenDirectory, - EFileBrowserCmdFileView, - EFileBrowserCmdFileViewText, - EFileBrowserCmdFileViewHex, - EFileBrowserCmdFileEdit, - EFileBrowserCmdFileEditText, - EFileBrowserCmdFileEditHex, - EFileBrowserCmdFileSearch, - EFileBrowserCmdFileSendTo, - EFileBrowserCmdFileNew, - EFileBrowserCmdFileNewFile, - EFileBrowserCmdFileNewDirectory, - EFileBrowserCmdFileDelete, - EFileBrowserCmdFileRename, - EFileBrowserCmdFileTouch, - EFileBrowserCmdFileProperties, - EFileBrowserCmdFileChecksums, - EFileBrowserCmdFileChecksumsMD5, - EFileBrowserCmdFileChecksumsMD2, - EFileBrowserCmdFileChecksumsSHA1, - EFileBrowserCmdFileSetAttributes, - EFileBrowserCmdFileCompress, - EFileBrowserCmdFileDecompress, - EFileBrowserCmdEdit, - EFileBrowserCmdSnapShot, - EFileBrowserCmdEditCut, - EFileBrowserCmdEditCopy, - EFileBrowserCmdEditPaste, - EFileBrowserCmdEditCopyToFolder, - EFileBrowserCmdEditMoveToFolder, - EFileBrowserCmdEditSelect, - EFileBrowserCmdEditUnselect, - EFileBrowserCmdEditSelectAll, - EFileBrowserCmdEditUnselectAll, - EFileBrowserCmdView, - EFileBrowserCmdViewSort, - EFileBrowserCmdViewSortByName, - EFileBrowserCmdViewSortByExtension, - EFileBrowserCmdViewSortByDate, - EFileBrowserCmdViewSortBySize, - EFileBrowserCmdViewOrder, - EFileBrowserCmdViewOrderAscending, - EFileBrowserCmdViewOrderDescending, - EFileBrowserCmdViewFilterEntries, - EFileBrowserCmdViewRefresh, - EFileBrowserCmdDiskAdmin, - EFileBrowserCmdDiskAdminSetDrivePassword, - EFileBrowserCmdDiskAdminUnlockDrive, - EFileBrowserCmdDiskAdminClearDrivePassword, - EFileBrowserCmdDiskAdminEraseDrivePassword, - EFileBrowserCmdDiskAdminFormatDrive, - EFileBrowserCmdDiskAdminQuickFormatDrive, - EFileBrowserCmdDiskAdminCheckDisk, - EFileBrowserCmdDiskAdminScanDrive, - EFileBrowserCmdDiskAdminSetDriveName, - EFileBrowserCmdDiskAdminSetDriveVolumeLabel, - EFileBrowserCmdDiskAdminEraseMBR, - EFileBrowserCmdDiskAdminDrivePartition, - EFileBrowserCmdDiskAdminEjectDrive, - EFileBrowserCmdDiskAdminDismountFileSystem, - EFileBrowserCmdTools, - EFileBrowserCmdToolsAllFiles, - EFileBrowserCmdToolsAvkonIconCache, - EFileBrowserCmdToolsAvkonIconCacheEnable, - EFileBrowserCmdToolsAvkonIconCacheDisable, - EFileBrowserCmdToolsDisableExtErrors, - EFileBrowserCmdToolsEditDataTypes, - EFileBrowserCmdToolsEnableExtErrors, - EFileBrowserCmdToolsErrorSimulate, - EFileBrowserCmdToolsErrorSimulateLeave, - EFileBrowserCmdToolsErrorSimulatePanic, - EFileBrowserCmdToolsErrorSimulateException, - EFileBrowserCmdToolsLocalConnectivity, - EFileBrowserCmdToolsLocalConnectivityActivateInfrared, - EFileBrowserCmdToolsLocalConnectivityLaunchBTUI, - EFileBrowserCmdToolsLocalConnectivityLaunchUSBUI, - EFileBrowserCmdToolsInstalledApps, - EFileBrowserCmdToolsOpenFiles, - EFileBrowserCmdToolsMsgAttachments, - EFileBrowserCmdToolsMsgAttachmentsInbox, - EFileBrowserCmdToolsMsgAttachmentsDrafts, - EFileBrowserCmdToolsMsgAttachmentsSentItems, - EFileBrowserCmdToolsMsgAttachmentsOutbox, - EFileBrowserCmdToolsMsgStoreWalk, - EFileBrowserCmdToolsSecureBackup, - EFileBrowserCmdToolsSecureBackupStartBackup, - EFileBrowserCmdToolsSecureBackupStartRestore, - EFileBrowserCmdToolsSecureBackupStop, - EFileBrowserCmdToolsSetDebugMask, - EFileBrowserCmdToolsMemoryInfo, - EFileBrowserCmdSettings, - EFileBrowserCmdAbout, - EFileBrowserCmdSettingsChange, - EFileBrowserCmdSettingsExit, - EFileBrowserCmdSettingsBack, - EFileBrowserSettingItemList, - EFileBrowserCmdDataTypesChangeMapping, - EFileBrowserCmdDataTypesSetDefaultMapping, - EFileBrowserCmdDataTypesRefresh, - EFileBrowserCmdDataTypesExit, - EFileBrowserCmdDataTypesBack, - EFileBrowserDataTypesList, - EFileBrowserProgressNote, - EFileBrowserWaitNote, - EFileBrowserAttributeEditorSetArchive, - EFileBrowserAttributeEditorSetHidden, - EFileBrowserAttributeEditorSetReadOnly, - EFileBrowserAttributeEditorSetSystem, - EFileBrowserAttributeEditorSetRecurse, - EFileBrowserSearchQuerySearchDir, - EFileBrowserSearchQueryWildCards, - EFileBrowserSearchQueryTextInFile, - EFileBrowserSearchQueryMinSize, - EFileBrowserSearchQueryMaxSize, - EFileBrowserSearchQueryMinDate, - EFileBrowserSearchQueryMaxDate, - EFileBrowserSearchQueryRecurse, - EFileBrowserCmdFileEditorViewAsText, - EFileBrowserCmdFileEditorViewAsHex, - EFileBrowserCmdFileEditorSave, - EFileBrowserCmdFileEditorSaveAs, - EFileBrowserCmdFileEditorSaveFormat, - EFileBrowserCmdFileEditorSaveFormatANSIASCII, - EFileBrowserCmdFileEditorSaveFormatUTF8, - EFileBrowserCmdFileEditorSaveFormatUTF16LE, - EFileBrowserCmdFileEditorSaveFormatUTF16BE, - EFileBrowserCmdFileEditorEditAsText, - EFileBrowserCmdFileEditorEditAsHex, - EFileBrowserCmdFileEditorExit, - EFileBrowserFileOpCommandAttribs, - EFileBrowserFileOpCommandCopy, - EFileBrowserFileOpCommandMove, - EFileBrowserFileOpCommandRename, - EFileBrowserFileOpCommandDelete, - EFileBrowserFileOpCommandDriveSnapShot - }; - -enum TFileBrowserFixedIconIds - { - EFixedIconMarking = 0, - EFixedIconEmpty, - EFixedIconPhoneMemory, - EFixedIconMemoryCard, - EFixedIconMemoryCardDisabled, - EFixedIconFolder, - EFixedIconFolderSub, - EFixedIconFolderCurrent, - EFixedIconListLength // this should be last - }; - -enum TFileBrowserEntryOverwriteActions - { - EFileActionOverwriteAll = 0, - EFileActionSkipAllExisting, - EFileActionGenerateUniqueFilenames, - EFileActionQueryPostFix - }; - -enum TFileBrowserSecureBackupState - { - ESecureBackupStateFull = 0, - ESecureBackupStatePartial - }; - -enum TFileBrowserSecureBackupType - { - ESecureBackupTypeBase = 0, - ESecureBackupTypeIncremental - }; - -enum TFileBrowserDataTypePriorities - { - EDataTypePriorityMaximum = 0, - EDataTypePriorityHigh, - EDataTypePriorityNormal, - EDataTypePriorityLow, - EDataTypePriorityLastResort - }; - -enum TFileBrowserCommonFileActions - { - ECommonFileActionViewAsTextHex = 0, - ECommonFileActionOpenWithApparc, - ECommonFileActionOpenWithDocHandlerEmbed - }; - -enum TFileBrowserSettingListTabs - { - ETabGeneral = 0, - ETabFileOps - }; - -enum TFileBrowserSettingListIds - { - ESettingListDisplayModeSelection = 0, - ESettingListFileViewModeSelection, - ESettingListShowSubdirectoryInfoSelection, - ESettingListShowAssociatedIconsSelection, - ESettingListRememberLastPathSelection, - ESettingListRememberFolderSelection, - ESettingListEnableToolbar, - - ESettingListSupportNetworkDrivesSelection, - ESettingListBypassPlatformSecuritySelection, - ESettingListRemoveFileLocksSelection, - ESettingListIgnoreProtectionsAttsSelection, - ESettingListRemoveROMWriteProtectionSelection - }; - -enum TFileBrowserSettingDisplayModes - { - EDisplayModeFullScreen = 0, - EDisplayModeNormal - }; - -enum TFileBrowserSettingFileViewModes - { - EFileViewModeSimple = 0, - EFileViewModeExtended - }; - -enum TFileBrowserFileEditorModes - { - EFileEditorViewAsText = 0, - EFileEditorViewAsHex, - EFileEditorEditAsText, - EFileEditorEditAsHex - }; - -enum - { - EFileViewerDialogControl = 0x5FEC - }; - -enum - { - EFileEditorDialogId = 1 - }; - -enum TFileBrowserCmdFileChecksums - { - EFileChecksumsMD5 = 0, - EFileChecksumsMD2, - EFileChecksumsSHA1 - }; - -enum TListingMode - { - ENormalEntries = 0, - ESearchResults, - EOpenFiles, - EMsgAttachmentsInbox, - EMsgAttachmentsDrafts, - EMsgAttachmentsSentItems, - EMsgAttachmentsOutbox - }; - -enum TClipBoardMode - { - EClipBoardModeCut = 0, - EClipBoardModeCopy - }; - -#endif // FILEBROWSER_HRH diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/engine/FBFileOps.cpp --- a/filebrowser/engine/FBFileOps.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1164 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -// INCLUDE FILES -#include "FBFileOps.h" -#include "FBFileUtils.h" -#include "engine.h" -#include "FBTraces.h" - -#ifndef FILEBROWSER_LITE - #include "FBFileOpClient.h" -#endif - -#include -#include -#include -#include - -const TInt KSecureBackupStartDelay = 750000; -const TInt KSecureBackupLoopDelay = 100000; -const TInt KSecureBackupEndDelay = 200000; -const TInt KMaxFileLockAttempts = 3; - - -// ================= MEMBER FUNCTIONS ======================= - -CFileBrowserFileOps* CFileBrowserFileOps::NewL(CEngine* aEngine) - { - CFileBrowserFileOps* self = new(ELeave) CFileBrowserFileOps(aEngine); - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(); - return self; - } - -// -------------------------------------------------------------------------------------------- - -CFileBrowserFileOps::CFileBrowserFileOps(CEngine* aEngine) : iEngine(aEngine) - { - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileOps::ConstructL() - { - iRecursiveState = EFileOpInvalid; - iSecureBackUpActive = EFalse; - iFileCommandActivatedSecureBackup = EFalse; - - User::LeaveIfError(iFs.Connect()); - iFileMan = CFileMan::NewL( iFs, this ); - } - -// -------------------------------------------------------------------------------------------- - -CFileBrowserFileOps::~CFileBrowserFileOps() - { - if (iSBEClient) - delete iSBEClient; - - #ifndef FILEBROWSER_LITE - if (iFileOpClient) - delete iFileOpClient; - #endif - - delete iFileMan; - iFs.Close(); - } - -// -------------------------------------------------------------------------------------------- - -TInt CFileBrowserFileOps::ActivateSecureBackUpViaFileOp() - { - iFileManObserverResult = MFileManObserver::EContinue; - // if already activate by a file command, return ok - if (iFileCommandActivatedSecureBackup) - return KErrNone; - else - { - // if secure backup is already active, disable it first, because it may in wrong state - if (iSecureBackUpActive) - DeActivateSecureBackUp(); - } - - // try to activate full secure backup - TInt err = ActivateSecureBackUp(conn::EBURBackupFull, conn::EBackupBase); - - if (err == KErrNone) - iFileCommandActivatedSecureBackup = ETrue; - - return err; - } - -// -------------------------------------------------------------------------------------------- - -TInt CFileBrowserFileOps::DeActivateSecureBackUpViaFileOp() - { - TInt err(KErrGeneral); - iFileManObserverResult = MFileManObserver::EContinue; - - // if activate by a file command, try to reactivate it - if (iFileCommandActivatedSecureBackup) - { - err = DeActivateSecureBackUp(); - - // even if it fails, forget the state - iFileCommandActivatedSecureBackup = EFalse; - } - - return err; - } - -// -------------------------------------------------------------------------------------------- - -TInt CFileBrowserFileOps::ActivateSecureBackUp(conn::TBURPartType aPartType, conn::TBackupIncType aBackupIncType) - { - iFileManObserverResult = MFileManObserver::EContinue; - // check for invalid parameters - if (aPartType == conn::EBURNormal || aBackupIncType == conn::ENoBackup) - User::Panic(_L("Inv.Usage.SE"), 532); - - TInt err(KErrNone); - - if (!iSBEClient) - { - TRAP(err, iSBEClient = conn::CSBEClient::NewL()); - if (err != KErrNone) - return err; - } - - TDriveList driveList; - err = iFs.DriveList(driveList); - - if (err == KErrNone) - { - // make sure that the application has a system status to prevent getting shut down events - iEngine->EikonEnv()->SetSystem(ETrue); - - // activating secure back up removes locks from files which respect this fuctionality - TRAP(err, iSBEClient->SetBURModeL(driveList, aPartType, aBackupIncType)); - - if (err == KErrNone) - { - iSecureBackUpActive = ETrue; - User::After(KSecureBackupStartDelay); // a short delay to wait to activate - } - } - - return err; - } - -// -------------------------------------------------------------------------------------------- - -TInt CFileBrowserFileOps::DeActivateSecureBackUp() - { - TInt err(KErrNone); - - if (!iSBEClient) - { - TRAP(err, iSBEClient = conn::CSBEClient::NewL()); - if (err != KErrNone) - return err; - - // make sure that the application has a system status - iEngine->EikonEnv()->SetSystem(ETrue); - } - - TDriveList driveList; - err = iFs.DriveList(driveList); - - if (err == KErrNone) - { - // deactivate secure backup - TRAP(err, iSBEClient->SetBURModeL(driveList, conn::EBURNormal, conn::ENoBackup)); - - User::After(KSecureBackupEndDelay); // a short delay to wait to deactivate - - // system status not needed anymore - iEngine->EikonEnv()->SetSystem(EFalse); - } - - iSecureBackUpActive = EFalse; - - return err; - } - -// -------------------------------------------------------------------------------------------- - -TInt CFileBrowserFileOps::DoFindEntries(const TDesC& aFileName, const TDesC& aPath) - { - TFindFile fileFinder(iFs); - CDir* dir; - TInt err = fileFinder.FindWildByPath(aFileName, &aPath, dir); - - while (err == KErrNone && iFileManObserverResult != MFileManObserver::ECancel) - { - for (TInt i=0; iCount(); i++) - { - TEntry entry = (*dir)[i]; - - if (entry.iName.Length() && aPath.Length()) - { - // parse the entry - TParse parsedName; - parsedName.Set(entry.iName, &fileFinder.File(), NULL); - - if (parsedName.Drive().Length() && aPath.Length() && parsedName.Drive()[0] == aPath[0]) - { - // get full source path - TFileName fullSourcePath = parsedName.FullName(); - if (entry.IsDir()) - fullSourcePath.Append(_L("\\")); - - // call the file operation command - switch(iRecursiveState) - { - case EFileOpAttribs: - { - // the same attribs command can be given for both directories and files - FileOpAttribs(fullSourcePath, iUint1, iUint2, iTime1, iUint3); - } - break; - - case EFileOpCopy: - { - // calculate length of new entries added to the original source path - TUint newEntriesLength = fullSourcePath.Length() - iBuf1.Length(); - - // get pointer description to the rightmost data - TPtr16 newEntriesPtr = fullSourcePath.RightTPtr(newEntriesLength); - - // generate target path - TFileName fullTargetPath = iBuf2; - fullTargetPath.Append(newEntriesPtr); - - if (entry.IsDir()) - { - // if it is a directory entry, just create it based on the entry's attributes - FileOpMkDirAll(fullTargetPath, entry.iAtt); - } - else - { - // ensure that root target folder exists - BaflUtils::EnsurePathExistsL(iFs, iBuf2); - // otherwise copy the file - FileOpCopy(fullSourcePath, fullTargetPath, iUint1); - } - } - break; - - case EFileOpDelete: - { - if (entry.IsDir()) - { - // for directories call rmdir - FileOpRmDir(fullSourcePath, iUint1); - } - else - { - // for files call the normal file deletion operation - FileOpDeleteFile(fullSourcePath, iUint1); - } - } - break; - - default: - User::Panic (_L("FileOpRecurs"), 775); - break; - } - } - } - if ( iFileManObserverResult == MFileManObserver::ECancel ) break; - } - - delete dir; - dir = NULL; - if ( iFileManObserverResult != MFileManObserver::ECancel ) - { - err = fileFinder.FindWild(dir); - } - } - - return err; - } - -// -------------------------------------------------------------------------------------------- - -TInt CFileBrowserFileOps::DoFindEntriesRecursiveL(const TDesC& aFileName, const TDesC& aPath) - { - TInt err(KErrNone); - - // it is logical to scan upwards when deleting and changing attributes - CDirScan::TScanDirection scanDirection = CDirScan::EScanUpTree; - - // when copying files, it is more logical to move downwards - if (iRecursiveState == EFileOpCopy) - scanDirection = CDirScan::EScanDownTree; - - - CDirScan* scan = CDirScan::NewLC(iFs); - scan->SetScanDataL(aPath, KEntryAttDir|KEntryAttMatchMask, ESortByName | EAscending | EDirsFirst, scanDirection); - CDir* dir = NULL; - - for(;;) - { - TRAP(err, scan->NextL(dir)); - if (!dir || (err != KErrNone)) - break; - - for (TInt i=0; iCount(); i++) - { - TEntry entry = (*dir)[i]; - - if (entry.IsDir()) - { - TFileName path(scan->FullPath()); - - if (path.Length()) - { - path.Append(entry.iName); - path.Append(_L("\\")); - // test path.Left(iBuf2.Length()).Compare(iBuf2) - to prevent never ending recursive copy (in case of copy folder under itself) - if( !(iRecursiveState == EFileOpCopy && !path.Left(iBuf2.Length()).Compare(iBuf2)) ) - { - DoFindEntries(aFileName, path); - } - } - } - if ( iFileManObserverResult == MFileManObserver::ECancel ) - { - break; - } - } - delete(dir); - if ( iFileManObserverResult == MFileManObserver::ECancel ) - { - break; - } - } - - CleanupStack::PopAndDestroy(scan); - return err; - } - -// -------------------------------------------------------------------------------------------- -// -------------------------------------------------------------------------------------------- - -TInt CFileBrowserFileOps::Copy(const TFileEntry& aSourceEntry, const TDesC& aTargetFullName, TUint aSwitch, TBool aDeleteSource) - { - iOperationError = KErrNone; - iFileManObserverResult = MFileManObserver::EContinue; - - TFileName sourcePath = aSourceEntry.iPath; - sourcePath.Append(aSourceEntry.iEntry.iName); - - TInt err(KErrNone); - - if (aSourceEntry.iEntry.IsDir() && (aSwitch & CFileMan::ERecurse)) - { - // find all files recursively and run the operation for them - iRecursiveState = EFileOpCopy; - sourcePath.Append(_L("\\")); - - TFileName targetPath = aTargetFullName; - targetPath.Append(_L("\\")); - - // remove the recursion flag because we will implement our own recursion - TUint newSwitch(aSwitch); - newSwitch &= ~CFileMan::ERecurse; - - iBuf1.Copy(sourcePath); - iBuf2.Copy(targetPath); - iUint1 = newSwitch; - - TRAP(err, DoFindEntries(_L("*"), sourcePath)); // entries under current directory entry - if ( iFileManObserverResult != MFileManObserver::ECancel ) - { - TRAP(err, DoFindEntriesRecursiveL(_L("*"), sourcePath)); // recursively under directories of current directory entry - } - // ensure that target folder exists in case of copying empty folder - BaflUtils::EnsurePathExistsL(iFs, targetPath); - // a path has a trailing backslash so it needs to be removed before the call - err = FileOpAttribs(targetPath.Left(targetPath.Length()-1), aSourceEntry.iEntry.iAtt, 0, 0, 0); - } - - else if (aSourceEntry.iEntry.IsDir()) - { - TFileName targetPath = aTargetFullName; - targetPath.Append(_L("\\")); - - // just create a directory based on the file attributes of the source directory - err = FileOpMkDirAll(targetPath, aSourceEntry.iEntry.iAtt); - } - - else - { - // remove a recursion flag if present (this should never happen, but some extra error checking) - if (aSwitch & CFileMan::ERecurse) - aSwitch &= ~CFileMan::ERecurse; - - // do the operation for a file entry - err = FileOpCopy(sourcePath, aTargetFullName, aSwitch); - } - - - // delete source if needed and copy succeeded without any errors (== move operation) - if ( aDeleteSource && iOperationError == KErrNone && - iFileManObserverResult != MFileManObserver::ECancel ) - { - err = Delete(aSourceEntry, aSwitch); - } - - if ( !iOperationError && iFileManObserverResult == MFileManObserver::ECancel ) - { - iOperationError = KErrCancel; - } - - return iOperationError; - } - -// -------------------------------------------------------------------------------------------- - -TInt CFileBrowserFileOps::FileOpCopy(const TDesC& aSourceFullName, const TDesC& aTargetFullName, TUint aSwitch) - { - TInt err = DoFileOpCopy(aSourceFullName, aTargetFullName, aSwitch); - - // if locked, unlock the file and retry - if (iEngine->Settings().iRemoveFileLocks && err == KErrInUse) - { - // try to remove the file lock by activating secure backup mode - if (ActivateSecureBackUpViaFileOp() == KErrNone) - { - // try the operation several times - for (TInt i=0; iSettings().iIgnoreProtectionsAtts && err == KErrAccessDenied && BaflUtils::FileExists(iFs, aTargetFullName)) - { - if (FileOpDeleteFile(aTargetFullName, 0) == KErrNone) - { - err = DoFileOpCopy(aSourceFullName, aTargetFullName, aSwitch); - } - } - - // if the file already exists, it is not an error - if (err == KErrAlreadyExists) - err = KErrNone; - - - // if copying from a ROM drive, remove the writing protection flag - if (iEngine->Settings().iRemoveROMWriteProrection && err == KErrNone && aSourceFullName.Length() > 3 && (aSourceFullName[0]=='z' || aSourceFullName[0]=='Z')) - { - FileOpAttribs(aTargetFullName, 0, KEntryAttReadOnly, 0, 0); - } - - - // remember the "lowest" error - if (err < iOperationError) - iOperationError = err; - - LOGSTRING4("FileBrowser: FileOpCopy %S -> %S, err=%d", &aSourceFullName, &aTargetFullName, err); - - return err; - } - -// -------------------------------------------------------------------------------------------- - -TInt CFileBrowserFileOps::DoFileOpCopy(const TDesC& aSourceFullName, const TDesC& aTargetFullName, TUint aSwitch) - { - #ifndef FILEBROWSER_LITE - if (iEngine->Settings().iBypassPlatformSecurity) - { - if (!iFileOpClient) - iFileOpClient = CFBFileOpClient::NewL(); - - return iFileOpClient->Copy(aSourceFullName, aTargetFullName, aSwitch); - } - else - { - #endif - //CAsyncWaiter* waiter = CAsyncWaiter::NewLC(); - //TInt result = iFileMan->Copy( aSourceFullName, aTargetFullName, aSwitch, waiter->iStatus ); - //waiter->StartAndWait(); - //if ( !result ) result = waiter->Result(); - //CleanupStack::PopAndDestroy( waiter ); - TInt result = iFileMan->Copy( aSourceFullName, aTargetFullName, aSwitch ); - return result; - #ifndef FILEBROWSER_LITE - } - #endif - } - -// -------------------------------------------------------------------------------------------- -// -------------------------------------------------------------------------------------------- - -TInt CFileBrowserFileOps::Rename(const TFileEntry& aSourceEntry, const TDesC& aNew, TUint aSwitch) - { - iOperationError = KErrNone; - iFileManObserverResult = MFileManObserver::EContinue; - - TFileName sourcePath = aSourceEntry.iPath; - sourcePath.Append(aSourceEntry.iEntry.iName); - - if (aSourceEntry.iEntry.IsDir()) - { - // do the operation for a directory entry - FileOpRename(sourcePath, aNew, aSwitch); - } - else - { - // do the operation for a file - FileOpRename(sourcePath, aNew, aSwitch); - } - - return iOperationError; - } - -// -------------------------------------------------------------------------------------------- - -TInt CFileBrowserFileOps::FileOpRename(const TDesC& aName, const TDesC& aNew, TUint aSwitch) - { - TBool setBackROFlag(EFalse); - - TInt err = DoFileOpRename(aName, aNew, aSwitch); - - // if locked, unlock the file and retry - if (iEngine->Settings().iRemoveFileLocks && err == KErrInUse) - { - // try to remove the file lock by activating secure backup mode - if (ActivateSecureBackUpViaFileOp() == KErrNone) - { - // try the operation several times - for (TInt i=0; iSettings().iIgnoreProtectionsAtts && err == KErrAccessDenied) - { - // remove write protection and try again - if (FileOpAttribs(aName, 0, KEntryAttReadOnly, 0, 0) == KErrNone) - { - err = DoFileOpRename(aName, aNew, aSwitch); - - setBackROFlag = ETrue; - } - } - - // if still access denied, then try to remove the target path and try again - if (iEngine->Settings().iIgnoreProtectionsAtts && err == KErrAccessDenied && BaflUtils::FileExists(iFs, aNew)) - { - if (FileOpDeleteFile(aNew, 0) == KErrNone) - { - err = DoFileOpRename(aName, aNew, aSwitch); - } - } - - // set back the read only flag - if (setBackROFlag) - FileOpAttribs(aName, KEntryAttReadOnly, 0, 0, 0); - - - // remember the "lowest" error - if (err < iOperationError) - iOperationError = err; - - LOGSTRING3("FileBrowser: FileOpRename %S, err=%d", &aName, err); - - return err; - } - -// -------------------------------------------------------------------------------------------- - -TInt CFileBrowserFileOps::DoFileOpRename(const TDesC& aName, const TDesC& aNew, TUint aSwitch) - { - #ifndef FILEBROWSER_LITE - if (iEngine->Settings().iBypassPlatformSecurity) - { - if (!iFileOpClient) - iFileOpClient = CFBFileOpClient::NewL(); - - return iFileOpClient->Rename(aName, aNew, aSwitch); - } - else - { - #endif - return iFileMan->Rename(aName, aNew, aSwitch); - #ifndef FILEBROWSER_LITE - } - #endif - } - -// -------------------------------------------------------------------------------------------- -// -------------------------------------------------------------------------------------------- - -TInt CFileBrowserFileOps::Attribs(const TFileEntry& aSourceEntry, TUint aSetMask, TUint aClearMask, const TTime& aTime, TUint aSwitch) - { - iOperationError = KErrNone; - iFileManObserverResult = MFileManObserver::EContinue; - - TFileName sourcePath = aSourceEntry.iPath; - sourcePath.Append(aSourceEntry.iEntry.iName); - - TInt err(KErrNone); - - if (aSourceEntry.iEntry.IsDir() && (aSwitch & CFileMan::ERecurse)) - { - // do the operation for a current directory entry - err = FileOpAttribs(sourcePath, aSetMask, aClearMask, aTime, 0); - - // find all files recursively and run the operation for them - iRecursiveState = EFileOpAttribs; - sourcePath.Append(_L("\\")); - - iBuf1.Copy(sourcePath); - iUint1 = aSetMask; - iUint2 = aClearMask; - iTime1 = aTime; - iUint3 = 0; - - TRAP(err, DoFindEntriesRecursiveL(_L("*"), sourcePath)); // recursively under directories of current directory entry - TRAP(err, DoFindEntries(_L("*"), sourcePath)); // entries under current directory entry - } - - else if (aSourceEntry.iEntry.IsDir()) - { - //sourcePath.Append(_L("\\")); // <-- do not apply! - - // do the operation for a directory entry - err = FileOpAttribs(sourcePath, aSetMask, aClearMask, aTime, 0); - } - - else - { - // do the operation for a file entry - err = FileOpAttribs(sourcePath, aSetMask, aClearMask, aTime, 0); - } - - return iOperationError; - } - -// -------------------------------------------------------------------------------------------- - -TInt CFileBrowserFileOps::FileOpAttribs(const TDesC& aName, TUint aSetMask, TUint aClearMask, const TTime& aTime, TUint aSwitch) - { - TInt err = DoFileOpAttribs(aName, aSetMask, aClearMask, aTime, aSwitch); - - // if locked, unlock the file and retry - if (iEngine->Settings().iRemoveFileLocks && err == KErrInUse) - { - // try to remove the file lock by activating secure backup mode - if (ActivateSecureBackUpViaFileOp() == KErrNone) - { - // try the operation several times - for (TInt i=0; iSettings().iBypassPlatformSecurity) - { - if (!iFileOpClient) - iFileOpClient = CFBFileOpClient::NewL(); - - return iFileOpClient->Attribs(aName, aSetMask, aClearMask, aTime, aSwitch); - } - else - { - #endif - return iFileMan->Attribs(aName, aSetMask, aClearMask, aTime, aSwitch); - #ifndef FILEBROWSER_LITE - } - #endif - } - -// -------------------------------------------------------------------------------------------- -// -------------------------------------------------------------------------------------------- - -TInt CFileBrowserFileOps::Delete(const TFileEntry& aSourceEntry, TUint aSwitch) - { - iOperationError = KErrNone; - iFileManObserverResult = MFileManObserver::EContinue; - - TFileName sourcePath = aSourceEntry.iPath; - sourcePath.Append(aSourceEntry.iEntry.iName); - - TInt err(KErrNone); - - if (aSourceEntry.iEntry.IsDir() && (aSwitch & CFileMan::ERecurse)) - { - // find all files recursively and run the operation for them - iRecursiveState = EFileOpDelete; - sourcePath.Append(_L("\\")); - - iBuf1.Copy(sourcePath); - iUint1 = 0; - - TRAP(err, DoFindEntriesRecursiveL(_L("*"), sourcePath)); // recursively under directories of current directory entry - if ( iFileManObserverResult != MFileManObserver::ECancel ) - { - TRAP(err, DoFindEntries(_L("*"), sourcePath)); // entries under current directory entry - } - - if ( iFileManObserverResult != MFileManObserver::ECancel ) - { - // do the operation for a current directory entry as well - err = FileOpRmDir(sourcePath, 0); - } - } - - else if (aSourceEntry.iEntry.IsDir()) - { - sourcePath.Append(_L("\\")); - - // do the operation for a directory entry - err = FileOpRmDir(sourcePath, 0); - } - - else - { - // do the operation for a file entry - err = FileOpDeleteFile(sourcePath, 0); - } - if ( !iOperationError && iFileManObserverResult == MFileManObserver::ECancel ) - { - iOperationError = KErrCancel; - } - return iOperationError; - } - -// -------------------------------------------------------------------------------------------- - -TInt CFileBrowserFileOps::FileOpDeleteFile(const TDesC& aName, TUint aSwitch) - { - TInt err = DoFileOpDeleteFile(aName, aSwitch); - - // if locked, unlock the file and retry - if (iEngine->Settings().iRemoveFileLocks && err == KErrInUse) - { - // try to remove the file lock by activating secure backup mode - if (ActivateSecureBackUpViaFileOp() == KErrNone) - { - // try the operation several times - for (TInt i=0; iSettings().iIgnoreProtectionsAtts && (err == KErrAccessDenied || err == KErrNotFound)) - { - // remove protections and try again - if (FileOpAttribs(aName, 0, KEntryAttReadOnly|KEntryAttSystem|KEntryAttHidden, 0, 0) == KErrNone) - { - err = DoFileOpDeleteFile(aName, aSwitch); - } - } - - // remember the "lowest" error - if (err < iOperationError) - iOperationError = err; - - LOGSTRING3("FileBrowser: FileOpDeleteFile %S, err=%d", &aName, err); - - return err; - } - -// -------------------------------------------------------------------------------------------- - -TInt CFileBrowserFileOps::DoFileOpDeleteFile(const TDesC& aName, TUint aSwitch) - { - #ifndef FILEBROWSER_LITE - if (iEngine->Settings().iBypassPlatformSecurity) - { - if (!iFileOpClient) - iFileOpClient = CFBFileOpClient::NewL(); - - return iFileOpClient->Delete(aName, aSwitch); - } - else - { - #endif -// CAsyncWaiter* waiter = CAsyncWaiter::NewLC(); -// TInt result = iFileMan->Delete( aName, aSwitch, waiter->iStatus ); -// waiter->StartAndWait(); -// if ( iFileManObserverResult == MFileManObserver::ECancel ) result = KErrCancel; -// if ( !result ) result = waiter->Result(); -// CleanupStack::PopAndDestroy( waiter ); - TInt result = iFileMan->Delete( aName, aSwitch ); - return result; - #ifndef FILEBROWSER_LITE - } - #endif - } - -// -------------------------------------------------------------------------------------------- - -TInt CFileBrowserFileOps::FileOpRmDir(const TDesC& aName, TUint aSwitch) - { - TInt err = DoFileOpRmDir(aName, aSwitch); - - // if write protected or system directory, remove protections and retry - if (iEngine->Settings().iIgnoreProtectionsAtts && (err == KErrAccessDenied || err == KErrInUse)) - { - // remove protections and try again - if (FileOpAttribs(aName.Left(aName.Length()-1), 0, KEntryAttReadOnly|KEntryAttSystem|KEntryAttHidden, 0, 0) == KErrNone) - { - err = DoFileOpRmDir(aName, aSwitch); - } - } - - // remember the "lowest" error - if (err < iOperationError) - iOperationError = err; - - LOGSTRING3("FileBrowser: FileOpRmDir %S, err=%d", &aName, err); - - return err; - } - -// -------------------------------------------------------------------------------------------- - -TInt CFileBrowserFileOps::DoFileOpRmDir(const TDesC& aDirName, TUint aSwitch) - { - #ifndef FILEBROWSER_LITE - if (iEngine->Settings().iBypassPlatformSecurity) - { - if (!iFileOpClient) - iFileOpClient = CFBFileOpClient::NewL(); - - return iFileOpClient->RmDir(aDirName, aSwitch); - } - else - { - #endif - if ( aSwitch & CFileMan::ERecurse ) - { -// CAsyncWaiter* waiter = CAsyncWaiter::NewLC(); -// TInt result = iFileMan->RmDir( aDirName, waiter->iStatus ); -// waiter->StartAndWait(); -// if ( iFileManObserverResult == MFileManObserver::ECancel ) result = KErrCancel; -// if ( !result ) result = waiter->Result(); -// CleanupStack::PopAndDestroy( waiter); - TInt result = iFileMan->RmDir( aDirName ); - return result; - } - else - return iFs.RmDir(aDirName); - #ifndef FILEBROWSER_LITE - } - #endif - } - -// -------------------------------------------------------------------------------------------- -// -------------------------------------------------------------------------------------------- - -TInt CFileBrowserFileOps::MkDirAll(const TDesC& aPath, TInt aSetAtts, TBool aQuickOperation) - { - iFileManObserverResult = MFileManObserver::EContinue; - if (aQuickOperation) - return DoFileOpMkDirAll(aPath); - else - return FileOpMkDirAll(aPath, aSetAtts); - } - -// -------------------------------------------------------------------------------------------- - -TInt CFileBrowserFileOps::FileOpMkDirAll(const TDesC& aPath, TInt aSetAtts) - { - TInt err = DoFileOpMkDirAll(aPath); - - // if the directory already exists, it is not an error - if (err == KErrAlreadyExists) - err = KErrNone; - - - // set attributes for directory just created - if (aSetAtts > 0 && err == KErrNone && aPath.Length() > 3) - { - // a path has a trailing backslash so it needs to be removed before the call - err = FileOpAttribs(aPath.Left(aPath.Length()-1), aSetAtts, 0, 0, 0); - } - - - // remember the "lowest" error - if (err < iOperationError) - iOperationError = err; - - LOGSTRING3("FileBrowser: FileOpMkDirAll %S, err=%d", &aPath, err); - - return err; - } - -// -------------------------------------------------------------------------------------------- - -TInt CFileBrowserFileOps::DoFileOpMkDirAll(const TDesC& aPath) - { - #ifndef FILEBROWSER_LITE - if (iEngine->Settings().iBypassPlatformSecurity) - { - if (!iFileOpClient) - iFileOpClient = CFBFileOpClient::NewL(); - - return iFileOpClient->MkDirAll(aPath); - } - else - { - #endif - return iFs.MkDirAll(aPath); - #ifndef FILEBROWSER_LITE - } - #endif - } - -// -------------------------------------------------------------------------------------------- -// -------------------------------------------------------------------------------------------- - -TInt CFileBrowserFileOps::CreateEmptyFile(const TDesC& aName) - { - return DoFileOpCreateEmptyFile(aName); - } - -// -------------------------------------------------------------------------------------------- - -TInt CFileBrowserFileOps::FileOpCreateEmptyFile(const TDesC& aName) - { - TInt err = DoFileOpCreateEmptyFile(aName); - - // remember the "lowest" error - if (err < iOperationError) - iOperationError = err; - - LOGSTRING3("FileBrowser: FileOpCreateEmptyFile %S, err=%d", &aName, err); - - return err; - } - -// -------------------------------------------------------------------------------------------- - -TInt CFileBrowserFileOps::DoFileOpCreateEmptyFile(const TDesC& aName) - { - #ifndef FILEBROWSER_LITE - if (iEngine->Settings().iBypassPlatformSecurity) - { - if (!iFileOpClient) - iFileOpClient = CFBFileOpClient::NewL(); - - return iFileOpClient->CreateEmptyFile(aName); - } - else - { - #endif - TInt err(KErrNone); - - RFile newFile; - err = newFile.Create(iFs, aName, EFileShareExclusive); - if (err == KErrNone) - err = newFile.Flush(); - newFile.Close(); - - return err; - #ifndef FILEBROWSER_LITE - } - #endif - } - -// -------------------------------------------------------------------------------------------- - -TInt CFileBrowserFileOps::DriveSnapShot(TChar aSourceDriveLetter, TChar aTargetDriveLetter) - { - TInt err(KErrNone); - iFileManObserverResult = MFileManObserver::EContinue; - - // remember old settings and force them to be true for this operation - TBool currentRemoveFileLocksValue = iEngine->Settings().iRemoveFileLocks; - TBool currentIgnoreProtectionAttsValue = iEngine->Settings().iIgnoreProtectionsAtts; - TBool currentRemoveROMWriteProrection = iEngine->Settings().iRemoveROMWriteProrection; - iEngine->Settings().iRemoveFileLocks = ETrue; - iEngine->Settings().iIgnoreProtectionsAtts = ETrue; - iEngine->Settings().iRemoveROMWriteProrection = ETrue; - - - TFileName sourceDir; - sourceDir.Append(aSourceDriveLetter); - sourceDir.Append(_L(":")); - - _LIT(KTargetDir, "%c:\\SnapShot_%c_drive"); - TFileName targetDir; - targetDir.Format(KTargetDir, TUint(aTargetDriveLetter), TUint(aSourceDriveLetter)); - - // remove any existing content, first get TEntry - TEntry entry; - err = iFs.Entry(targetDir, entry); - - // entry directory exists, delete it - if (err == KErrNone && entry.IsDir()) - { - TFileName targetRoot; - targetRoot.Append(aTargetDriveLetter); - targetRoot.Append(_L(":\\")); - - TFileEntry targetEntry; - targetEntry.iPath = targetRoot; - targetEntry.iEntry = entry; - - err = Delete(targetEntry, CFileMan::ERecurse); - } - - // do not care if removing succeeded or not, just continue with copying - TEntry fakeEntry; - fakeEntry.iAtt |= KEntryAttDir; - - TFileEntry sourceEntry; - sourceEntry.iPath = sourceDir; - sourceEntry.iEntry = fakeEntry; - - err = Copy(sourceEntry, targetDir, CFileMan::ERecurse|CFileMan::EOverWrite); - - - // restore back settings - iEngine->Settings().iRemoveFileLocks = currentRemoveFileLocksValue; - iEngine->Settings().iIgnoreProtectionsAtts = currentIgnoreProtectionAttsValue; - iEngine->Settings().iRemoveROMWriteProrection = currentRemoveROMWriteProrection; - - - return iOperationError; - } - -// -------------------------------------------------------------------------------------------- - -TInt CFileBrowserFileOps::EraseMBR(TUint aDriveNumber) - { - #ifndef FILEBROWSER_LITE - - if (!iFileOpClient) - iFileOpClient = CFBFileOpClient::NewL(); - - return iFileOpClient->EraseMBR(aDriveNumber); - - #else - return KErrNotSupported; - #endif - } - -// -------------------------------------------------------------------------------------------- - -TInt CFileBrowserFileOps::PartitionDrive(TUint aDriveNumber, TUint aNumberOfPartitions) - { - #ifndef FILEBROWSER_LITE - - if (!iFileOpClient) - iFileOpClient = CFBFileOpClient::NewL(); - - return iFileOpClient->PartitionDrive(aDriveNumber, aNumberOfPartitions); - - #else - return KErrNotSupported - #endif - } - -// -------------------------------------------------------------------------------------------- - -MFileManObserver::TControl CFileBrowserFileOps::NotifyFileManStarted() - { - return iFileManObserverResult; - } - -// -------------------------------------------------------------------------------------------- - -MFileManObserver::TControl CFileBrowserFileOps::NotifyFileManOperation() - { - return iFileManObserverResult; - } -// -------------------------------------------------------------------------------------------- - -MFileManObserver::TControl CFileBrowserFileOps::NotifyFileManEnded() - { - return iFileManObserverResult; - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileOps::CancelOp() - { -#ifndef FILEBROWSER_LITE - - if ( iEngine->Settings().iBypassPlatformSecurity ) - { - if ( !iFileOpClient ) - iFileOpClient = CFBFileOpClient::NewL(); - - iFileOpClient->CancelOp(); - } - - // we need this information even when using iFileOpClient - // to be able to not execute aggregate operations - iFileManObserverResult = MFileManObserver::ECancel; - -#else - iFileManObserverResult = MFileManObserver::ECancel; -#endif - } - -// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/engine/FBFileOps.h --- a/filebrowser/engine/FBFileOps.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,133 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef FILEBROWSER_FILEOPS_H -#define FILEBROWSER_FILEOPS_H - -// INCLUDES -#include -#include -#include - -// FORWARD DECLARATIONS -class TFileEntry; -class CFBFileOpClient; -class CFileMan; -class CEngine; -class CSBEClient; - - -class CFileBrowserFileOps : public CBase, - public MFileManObserver - { -private: - enum TRecursiveOperation - { - EFileOpInvalid = -1, - EFileOpCopy, - EFileOpMove, - EFileOpRename, - EFileOpAttribs, - EFileOpDelete, - EFileOpMkDirAll, - EFileOpCreateEmptyFile, - EFileOpEraseMBR, - EFileOpPartitionDrive - }; -public: - static CFileBrowserFileOps* NewL(CEngine* aEngine); - ~CFileBrowserFileOps(); - -public: // From MFileManObserver - - TControl NotifyFileManStarted(); - TControl NotifyFileManOperation(); - TControl NotifyFileManEnded(); - -private: - CFileBrowserFileOps(CEngine* aEngine); - void ConstructL(); - -public: - TInt ActivateSecureBackUpViaFileOp(); - TInt DeActivateSecureBackUpViaFileOp(); - TInt ActivateSecureBackUp(conn::TBURPartType aPartType=conn::EBURBackupFull, conn::TBackupIncType aBackupIncType=conn::EBackupBase); - TInt DeActivateSecureBackUp(); - TInt Copy(const TFileEntry& aSourceEntry, const TDesC& aTargetFullName, TUint aSwitch=CFileMan::EOverWrite, TBool aDeleteSource=EFalse); - TInt Rename(const TFileEntry& aSourceEntry, const TDesC& aNew, TUint aSwitch=CFileMan::EOverWrite); - TInt Attribs(const TFileEntry& aSourceEntry, TUint aSetMask, TUint aClearMask, const TTime& aTime, TUint aSwitch=0); - TInt Delete(const TFileEntry& aSourceEntry, TUint aSwitch=0); - TInt MkDirAll(const TDesC& aPath, TInt aSetAtts=0, TBool aQuickOperation=EFalse); - TInt CreateEmptyFile(const TDesC& aName); - TInt DriveSnapShot(TChar aSourceDriveLetter, TChar aTargetDriveLetter); - TInt EraseMBR(TUint aDriveNumber); - TInt PartitionDrive(TUint aDriveNumber, TUint aNumberOfPartitions); - void CancelOp(); - -private: - TInt DoFindEntries(const TDesC& aFileName, const TDesC& aPath); - TInt DoFindEntriesRecursiveL(const TDesC& aFileName, const TDesC& aPath); - - TInt FileOpCopy(const TDesC& aSourceFullName, const TDesC& aTargetFullName, TUint aSwitch); - TInt DoFileOpCopy(const TDesC& aSourceFullName, const TDesC& aTargetFullName, TUint aSwitch); - - TInt FileOpRename(const TDesC& aName, const TDesC& aNew, TUint aSwitch); - TInt DoFileOpRename(const TDesC& aName, const TDesC& aNew, TUint aSwitch); - - TInt FileOpAttribs(const TDesC& aName, TUint aSetMask, TUint aClearMask, const TTime& aTime, TUint aSwitch); - TInt DoFileOpAttribs(const TDesC& aName, TUint aSetMask, TUint aClearMask, const TTime& aTime, TUint aSwitch); - - TInt FileOpDeleteFile(const TDesC& aName, TUint aSwitch); - TInt DoFileOpDeleteFile(const TDesC& aName, TUint aSwitch); - - TInt FileOpRmDir(const TDesC& aDirName, TUint aSwitch); - TInt DoFileOpRmDir(const TDesC& aDirName, TUint aSwitch); - - TInt FileOpMkDirAll(const TDesC& aPath, TInt aSetAtts=0); - TInt DoFileOpMkDirAll(const TDesC& aPath); - - TInt FileOpCreateEmptyFile(const TDesC& aName); - TInt DoFileOpCreateEmptyFile(const TDesC& aName); - -public: - inline TBool SecureBackUpActive() { return iSecureBackUpActive; } - inline TBool FileCommandActivatedSecureBackup() { return iFileCommandActivatedSecureBackup; } - -private: - TInt iRecursiveState; - CEngine* iEngine; - CFBFileOpClient* iFileOpClient; - CFileMan* iFileMan; - RFs iFs; - TInt iOperationError; - conn::CSBEClient* iSBEClient; - TBool iSecureBackUpActive; - TBool iFileCommandActivatedSecureBackup; - - TFileName iBuf1; - TFileName iBuf2; - TUint iUint1; - TUint iUint2; - TUint iUint3; - TTime iTime1; - MFileManObserver::TControl iFileManObserverResult; - }; - -#endif - -// End of File - diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/engine/FBFileUtils.cpp --- a/filebrowser/engine/FBFileUtils.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4628 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -// INCLUDE FILES -#include "FBFileUtils.h" -#include "FBFileOps.h" -#include "engine.h" -#include "FB.hrh" -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -//#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -//#include -#include -#if (!defined __SERIES60_30__ && !defined __SERIES60_31__) -#include -#endif // !defined __SERIES60_30__ && !defined __SERIES60_31__ - -#ifndef __SERIES60_30__ -// #include -#endif - -//_LIT(KGZipExt, ".gz"); -_LIT8(KFileNewLine, "\r\n"); -const TInt KForcedFormatTimeout = 1000000; - -// copied from coreapplicationuisdomainpskeys.h -const TUid KPSUidCoreApplicationUIs = { 0x101F8767 }; -const TUint32 KCoreAppUIsMmcRemovedWithoutEject = 0x00000109; -enum TCoreAppUIsMmcRemovedWithoutEject - { - ECoreAppUIsEjectCommandUsedUninitialized = 0, - ECoreAppUIsEjectCommandNotUsed, - ECoreAppUIsEjectCommandUsed, - ECoreAppUIsEjectCommandUsedToDrive // Low 16-bits contain this value and high 16-bits TDriveNumber to eject - }; -const TInt KDriveLetterStringLength = 3; // e.g. C:\ - -// ================= MEMBER FUNCTIONS ======================= - -CFileBrowserFileUtils* CFileBrowserFileUtils::NewL(CEngine* aEngine) - { - CFileBrowserFileUtils* self = new(ELeave) CFileBrowserFileUtils(aEngine); - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(); - return self; - } - -// -------------------------------------------------------------------------------------------- - -CFileBrowserFileUtils::CFileBrowserFileUtils(CEngine* aEngine) : CActive(EPriorityStandard), iEngine(aEngine) - { - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::ConstructL() - { - User::LeaveIfError(iTimer.CreateLocal()); - User::LeaveIfError(iFs.Connect()); - User::LeaveIfError(iTz.Connect()); - - iState = EIdle; - iListingMode = ENormalEntries; - - iSortMode = EFileBrowserCmdViewSortByName; - iOrderMode = EFileBrowserCmdViewOrderAscending; - iCurrentPath = KNullDesC; - - iFileOps = CFileBrowserFileOps::NewL(iEngine); - - iDriveEntryList = new(ELeave) CDriveEntryList(8); - iFileEntryList = new(ELeave) CFileEntryList(64); - iFindFileEntryList = new(ELeave) CFileEntryList(64); - iAppIconList = new(ELeave) CAppIconList(16); - iClipBoardList = new(ELeave) CFileEntryList(64); - iCurrentSelectionList = new(ELeave) CFileEntryList(64); - - iDocHandler = CDocumentHandler::NewL(); -// iDocHandler->SetExitObserver(this); - - // set defaults to the search settings - iSearchAttributes.iSearchDir = KNullDesC; - iSearchAttributes.iWildCards = _L("*.jpg"); - iSearchAttributes.iTextInFile = KNullDesC; - iSearchAttributes.iMinSize = 0; - iSearchAttributes.iMaxSize = 999999999; - iSearchAttributes.iMinDate = TDateTime(1980, EJanuary, 0,0,0,0,0); - iSearchAttributes.iMaxDate = TDateTime(2060, EDecember, 30,0,0,0,0); - iSearchAttributes.iRecurse = ETrue; - - // init the command array - iCommandArray = new(ELeave) CCommandArray(64); - - // get current path from settings - if (iEngine->Settings().iRememberLastPath) - { - TFileName settingPath = iEngine->Settings().iLastPath; - if (BaflUtils::PathExists(iFs, settingPath)) - iCurrentPath = settingPath; - - if (iCurrentPath != KNullDesC) - GetDriveListL(); - } - - CActiveScheduler::Add(this); - } - -// -------------------------------------------------------------------------------------------- - -CFileBrowserFileUtils::~CFileBrowserFileUtils() - { - Cancel(); - - // save current path from settings - if (iEngine->Settings().iRememberLastPath) - { - iEngine->Settings().iLastPath = iCurrentPath; - TRAP_IGNORE(iEngine->SaveSettingsL(EFalse)); - } - -// if (iWaitDialog) -// TRAP_IGNORE(iWaitDialog->ProcessFinishedL()); -// -// if (iProgressDialog) -// TRAP_IGNORE(iProgressDialog->ProcessFinishedL()); - - delete iFileOps; - - delete iDocHandler; - -// if (iOpenFileService) -// delete iOpenFileService; - - delete iCurrentSelectionList; - delete iClipBoardList; - delete iAppIconList; - delete iFindFileEntryList; - delete iFileEntryList; - delete iDriveEntryList; - - delete iFileMan; - - if (iCommandArray) - { - ResetCommandArray(); - delete iCommandArray; - } - - iTz.Close(); - iFs.Close(); - iTimer.Close(); - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::DoCancel() - { - iTimer.Cancel(); - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::StartExecutingCommandsL(const TDesC& aLabel) - { - if (iCommandArray->Count() >= 2) - { - // init progress bar -// iProgressDialog = new(ELeave) CAknProgressDialog((reinterpret_cast(&iProgressDialog)), ETrue); -// iProgressDialog->SetCallback(this); -// iProgressDialog->PrepareLC(R_GENERAL_PROGRESS_NOTE); -// iProgressDialog->SetCurrentLabelL( EAknCtNote, aLabel ); -// iProgressInfo = iProgressDialog->GetProgressInfoL(); -// iProgressInfo->SetFinalValue( CommandArrayCount() ); -// iProgressDialog->RunLD(); -// iProgressDialog->MakeVisible( ETrue ); - iEngine->FileBrowserUI()->ShowProgressDialog(aLabel, 0, CommandArrayCount()); - isProgressDialog = ETrue; - } - else if (iCommandArray->Count() >= 1) - { - // init wait dialog -// iWaitDialog = new(ELeave) CAknWaitDialog((reinterpret_cast(&iWaitDialog)), ETrue); -// iWaitDialog->SetCallback(this); -// iWaitDialog->PrepareLC(R_GENERAL_WAIT_NOTE); -// iWaitDialog->SetTextL( aLabel ); -// iWaitDialog->RunLD(); - iEngine->FileBrowserUI()->ShowWaitDialog(aLabel); - isWaitDialog = ETrue; - } - else - { - // no commands, just do nothing - return; - } - - - // start with the first operation - iCurrentEntry = 0; - iSucceededOperations = 0; - iFailedOperations = 0; - - // starts executing commands - ExecuteCommand(); - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::ExecuteCommand() - { - // make sure the engine isn't active, should never happen - __ASSERT_ALWAYS(!IsActive(), User::Panic(_L("FileUtils:IsActive"), 333)); - - // execute a command after a very short delay (25ms) - if (isWaitDialog) - { - iEngine->FileBrowserUI()->ProcessEvents(); - } - if (isProgressDialog) - { - TInt newValue = iCurrentEntry; - iEngine->FileBrowserUI()->SetProgressValue(newValue); - } - iTimer.After(iStatus, 25); - SetActive(); - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::RunL() - { - TInt err(KErrNone); - TInt currentCommand = iCommandArray->At(iCurrentEntry).iCommandId; - - // execute a command from the queue - switch(currentCommand) - { - case EFileBrowserFileOpCommandAttribs: - { - CCommandParamsAttribs* params = static_cast(iCommandArray->At(iCurrentEntry).iParameters); - err = iFileOps->Attribs(params->iSourceEntry, params->iSetMask, params->iClearMask, params->iTime, params->iSwitch); - } - break; - - case EFileBrowserFileOpCommandCopy: - { - CCommandParamsCopyOrMove* params = static_cast(iCommandArray->At(iCurrentEntry).iParameters); - err = iFileOps->Copy(params->iSourceEntry, params->iTargetPath, params->iSwitch); - } - break; - - case EFileBrowserFileOpCommandMove: - { - CCommandParamsCopyOrMove* params = static_cast(iCommandArray->At(iCurrentEntry).iParameters); - err = iFileOps->Copy(params->iSourceEntry, params->iTargetPath, params->iSwitch, ETrue); - } - break; - - case EFileBrowserFileOpCommandRename: - { - CCommandParamsRename* params = static_cast(iCommandArray->At(iCurrentEntry).iParameters); - err = iFileOps->Rename(params->iSourceEntry, params->iTargetPath, params->iSwitch); - } - break; - - case EFileBrowserFileOpCommandDelete: - { - CCommandParamsDelete* params = static_cast(iCommandArray->At(iCurrentEntry).iParameters); - err = iFileOps->Delete(params->iSourceEntry, params->iSwitch); - } - break; - - case EFileBrowserFileOpCommandDriveSnapShot: - { - CCommandParamsDriveSnapShot* params = static_cast(iCommandArray->At(iCurrentEntry).iParameters); - err = iFileOps->DriveSnapShot(params->iSourceDriveLetter, params->iTargetDriveLetter); - } - break; - - default: - User::Panic (_L("Unknown command"), 400); - break; - } - - - if (err == KErrNone) - { - iSucceededOperations++; - } - else if ( err != KErrCancel ) - { - iFailedOperations++; - } - - iLastError = err; - - // check for more commands in queue - TRAP_IGNORE( CheckForMoreCommandsL() ); - } - -// --------------------------------------------------------------------------- - -TInt CFileBrowserFileUtils::RunError(TInt aError) - { - _LIT(KMessage, "Command error %d"); - TBuf<128> noteMsg; - noteMsg.Format(KMessage, aError); - - iEngine->EikonEnv()->InfoMsg(noteMsg); - - TRAP_IGNORE( CheckForMoreCommandsL() ); - - return KErrNone; - } - -// --------------------------------------------------------------------------- - -void CFileBrowserFileUtils::CheckForMoreCommandsL() - { - //LOGSTRING("Creator: CCreatorEngine::CheckForMoreCommandsL"); - - // update the progress bar -// if (iProgressInfo) -// iProgressInfo->IncrementAndDraw(1); - - // check if we have more commands to be executed - if (iCurrentEntry >= CommandArrayCount() - 1) - { - //LOGSTRING("Creator: CCreatorEngine::CheckForMoreCommandsL all done"); - - // all done, free resources - ResetCommandArray(); - - // deactive secure backup if it was activated by a file command - iFileOps->DeActivateSecureBackUpViaFileOp(); - - // dismiss any wait/progress dialogs - if (isWaitDialog) - { - iEngine->FileBrowserUI()->CancelWaitDialog(); - isWaitDialog = EFalse; - } - if (isProgressDialog) - { - iEngine->FileBrowserUI()->CancelProgressDialog(); - isProgressDialog = EFalse; - } -// if (iWaitDialog) -// { -// TRAP_IGNORE(iWaitDialog->ProcessFinishedL()); -// iWaitDialog = NULL; -// } -// if (iProgressDialog) -// { -// TRAP_IGNORE(iProgressDialog->ProcessFinishedL()); -// iProgressDialog = NULL; -// } - - - // show result note - if ( iSucceededOperations == 0 && iFailedOperations == 0 ) - { - // single operation cancelled -> show nothing - } - else if (iSucceededOperations == 1 && iFailedOperations == 0) - { - _LIT(KMessage, "Operation succeeded"); - iEngine->FileBrowserUI()->ShowConfirmationNote(KMessage); - } - else if (iSucceededOperations > 0 && iFailedOperations == 0) - { - _LIT(KMessage, "%d operations succeeded"); - TBuf<128> noteMsg; - noteMsg.Format(KMessage, iSucceededOperations); - iEngine->FileBrowserUI()->ShowConfirmationNote(noteMsg); - } - else if (iSucceededOperations == 0 && iFailedOperations > 1) - { - _LIT(KMessage, "%d operations failed"); - TBuf<128> noteMsg; - noteMsg.Format(KMessage, iFailedOperations); - - iEngine->FileBrowserUI()->ShowErrorNote(noteMsg); - } - else if (iSucceededOperations > 0 && iFailedOperations > 0) - { - _LIT(KMessage, "%d operations succeeded, %d failed"); - TBuf<128> noteMsg; - noteMsg.Format(KMessage, iSucceededOperations, iFailedOperations); - - iEngine->FileBrowserUI()->ShowInformationNote(noteMsg, _L("")); - } - else - { - CTextResolver* textResolver = CTextResolver::NewLC(*iEngine->EikonEnv()); - - iEngine->FileBrowserUI()->ShowErrorNote( - textResolver->ResolveErrorString(iLastError, CTextResolver::ECtxNoCtxNoSeparator) ); - - CleanupStack::PopAndDestroy(); //textResolver - } - - RefreshViewL(); - iEngine->FileBrowserUI()->NotifyModelHasChanged(); - - } - else - { - // maintain requests - iCurrentEntry++; - - //LOGSTRING2("Creator: CCreatorEngine::CheckForMoreCommandsL iCurrentEntry=%d", iCurrentEntry); - - ExecuteCommand(); - } - } -// -------------------------------------------------------------------------------------------- - -// This callback function is called when cancel button of the progress bar was pressed -void CFileBrowserFileUtils::DialogDismissedL(/*TInt aButtonId*/) - { -// iProgressDialog = NULL; -// iProgressInfo = NULL; -// iWaitDialog = NULL; - - // check if cancel button was pressed -// if (aButtonId == EAknSoftkeyCancel) -// { - // cancel the active object, command executer - Cancel(); - - iFileOps->CancelOp(); - - ResetCommandArray(); - - isProgressDialog = EFalse; - - iEngine->FileBrowserUI()->ShowInformationNote(_L("Cancelled"), _L("")); -// } - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::AppendToCommandArrayL(TInt aCommand, CCommandParamsBase* aParameters) - { - if (iCommandArray) - iCommandArray->AppendL( TCommand(aCommand, aParameters) ); - else - User::Leave(KErrNotReady); - } - -// -------------------------------------------------------------------------------------------- - -TInt CFileBrowserFileUtils::CommandArrayCount() const - { - TInt count(0); - - if (iCommandArray) - count = iCommandArray->Count(); - - return count; - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::ResetCommandArray() - { - // delete params first - for (TInt i=0; iAt(i).iParameters ) - { - delete iCommandArray->At(i).iParameters; - iCommandArray->At(i).iParameters = NULL; - } - } - - // reset the entries - iCommandArray->Reset(); - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::HandleSettingsChangeL() - { - // TODO - -// if (iEngine->FileListContainer()) -// { -// iEngine->FileListContainer()->SetScreenLayoutL(iEngine->Settings().iDisplayMode); -// iEngine->FileListContainer()->CreateListBoxL(iEngine->Settings().iFileViewMode); - //iEngine->FileListContainer()->SetNaviPaneTextL(iCurrentPath); - RefreshViewL(); -// } - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::SetSortModeL(TInt aSortMode) - { - iSortMode = aSortMode; - RefreshViewL(); - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::SetOrderModeL(TInt aOrderMode) - { - iOrderMode = aOrderMode; - RefreshViewL(); - } - -// -------------------------------------------------------------------------------------------- - -TKeyResponse CFileBrowserFileUtils::HandleOfferKeyEventL(const TKeyEvent& /*aKeyEvent*/, TEventCode /*aType*/) - { - // TODO - /* - if(aType != EEventKey) - return EKeyWasNotConsumed; - - TBool shiftKeyPressed = (aKeyEvent.iModifiers & EModifierShift) || - (aKeyEvent.iModifiers & EModifierLeftShift) || - (aKeyEvent.iModifiers & EModifierRightShift); - TBool controlKeyPressed = (aKeyEvent.iModifiers & EModifierCtrl) || - (aKeyEvent.iModifiers & EModifierRightCtrl); - - // handle left arrow key press - if (aKeyEvent.iCode == EKeyLeftArrow) - { - MoveUpOneLevelL(); - return EKeyWasConsumed; - } - - // handle right arrow key press - else if (aKeyEvent.iCode == EKeyRightArrow) - { - if (IsDriveListViewActive() && iDriveEntryList->Count() > 0) - { - MoveDownToDirectoryL(); - return EKeyWasConsumed; - } - else if (iFileEntryList->Count() > 0) - { - MoveDownToDirectoryL(); - return EKeyWasConsumed; - } - } - - // skip OK/Enter keys when shift or ctrl is pressed because those are needed by the listbox - else if ((aKeyEvent.iCode == EKeyOK || aKeyEvent.iCode == EKeyEnter) && (shiftKeyPressed || controlKeyPressed)) - { - return EKeyWasNotConsumed; - } - - // handle OK/Enter keys - else if (aKeyEvent.iCode == EKeyOK || aKeyEvent.iCode == EKeyEnter) - { - if (IsDriveListViewActive() && iDriveEntryList->Count() > 0) - { - MoveDownToDirectoryL(); - return EKeyWasConsumed; - } - else if (iFileEntryList->Count() > 0) - { - TFileEntry fileEntry = iFileEntryList->At(iEngine->FileListContainer()->CurrentListBoxItemIndex()); - - if (fileEntry.iEntry.IsDir()) - MoveDownToDirectoryL(); - else - OpenCommonFileActionQueryL(); - - return EKeyWasConsumed; - } - } - - // handle Delete/Backspace keys - else if (!iEngine->FileListContainer()->SearchField() && (aKeyEvent.iCode == EKeyBackspace || aKeyEvent.iCode == EKeyDelete) && - !iEngine->FileUtils()->IsCurrentDriveReadOnly() && !iEngine->FileUtils()->IsDriveListViewActive()) - { - DeleteL(); - return EKeyWasConsumed; - } - */ - return EKeyWasNotConsumed; - } -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::RefreshViewL() - { -// if (iEngine->FileListContainer()) -// { -// -// // make sure that the search field is disabled -// iEngine->FileListContainer()->DisableSearchFieldL(); - - // read directory listing - GenerateDirectoryDataL(); - -// // set an icon array -// iEngine->FileListContainer()->SetListBoxIconArrayL(GenerateIconArrayL()); -// -// // set text items -// iEngine->FileListContainer()->SetListBoxTextArrayL(GenerateItemTextArrayL()); -// } - } - -// -------------------------------------------------------------------------------------------- - -//CAknIconArray* CFileBrowserFileUtils::GenerateIconArrayL(TBool aGenerateNewBasicIconArray) -// { -// // TODO -// -// CAknIconArray* iconArray = NULL; -// -// if (aGenerateNewBasicIconArray) -// { -// iconArray = new(ELeave) CAknIconArray(16); -// } -// else -// { -// if (iEngine->FileListContainer()) -// iconArray = iEngine->FileListContainer()->ListBoxIconArrayL(); -// -// if (!iconArray) -// iconArray = new(ELeave) CAknIconArray(16); -// } -// -// -// CleanupStack::PushL(iconArray); -// -// // generate basic items if not already existing -// if (iconArray->Count() < EFixedIconListLength) -// { -// // reset arrays -// iconArray->Reset(); -// iAppIconList->Reset(); -// -// // get default control color -// TRgb defaultColor; -// defaultColor = iEngine->EikonEnv()->Color(EColorControlText); -// -// // create a color icon of the marking indicator -// CFbsBitmap* markBitmap = NULL; -// CFbsBitmap* markBitmapMask = NULL; -// -// AknsUtils::CreateColorIconL(AknsUtils::SkinInstance(), -// KAknsIIDQgnIndiMarkedAdd, -// KAknsIIDQsnIconColors, -// EAknsCIQsnIconColorsCG13, -// markBitmap, -// markBitmapMask, -// AknIconUtils::AvkonIconFileName(), -// EMbmAvkonQgn_indi_marked_add, -// EMbmAvkonQgn_indi_marked_add_mask, -// defaultColor -// ); -// -// // 0 marking indicator -// CGulIcon* markIcon = CGulIcon::NewL(markBitmap, markBitmapMask); -// iconArray->AppendL(markIcon); -// -// // 1 empty -// AppendGulIconToIconArrayL(iconArray, AknIconUtils::AvkonIconFileName(), -// EMbmAvkonQgn_prop_empty, EMbmAvkonQgn_prop_empty_mask, KAknsIIDQgnPropEmpty); -// // 2 phone memory -// AppendGulIconToIconArrayL(iconArray, AknIconUtils::AvkonIconFileName(), -// EMbmAvkonQgn_prop_phone_memc, EMbmAvkonQgn_prop_phone_memc_mask, KAknsIIDQgnPropPhoneMemc); -// // 3 memory card -// AppendGulIconToIconArrayL(iconArray, KMemoryCardUiBitmapFile, -// EMbmAknmemorycarduiQgn_prop_mmc_memc, EMbmAknmemorycarduiQgn_prop_mmc_memc_mask, KAknsIIDQgnPropMmcMemc); -// // 4 memory card disabled -// AppendGulIconToIconArrayL(iconArray, KMemoryCardUiBitmapFile, -// EMbmAknmemorycarduiQgn_prop_mmc_non, EMbmAknmemorycarduiQgn_prop_mmc_non_mask, KAknsIIDQgnPropMmcNon); -// // 5 folder -// AppendGulIconToIconArrayL(iconArray, AknIconUtils::AvkonIconFileName(), -// EMbmAvkonQgn_prop_folder_small, EMbmAvkonQgn_prop_folder_small_mask, KAknsIIDQgnPropFolderSmall); -// // 6 folder with subfolders -// AppendGulIconToIconArrayL(iconArray, AknIconUtils::AvkonIconFileName(), -// EMbmAvkonQgn_prop_folder_sub_small, EMbmAvkonQgn_prop_folder_sub_small_mask, KAknsIIDQgnPropFolderSubSmall); -// // 7 current folder -// AppendGulIconToIconArrayL(iconArray, AknIconUtils::AvkonIconFileName(), -// EMbmAvkonQgn_prop_folder_current, EMbmAvkonQgn_prop_folder_current_mask, KAknsIIDQgnPropFolderCurrent); -// } -// -// // append custom icons if not in drive list view and setting is enabled -// if (!aGenerateNewBasicIconArray && !IsDriveListViewActive() && iEngine->Settings().iShowAssociatedIcons) -// { -// // init id counter -// TInt idCounter(EFixedIconListLength + iAppIconList->Count()); -// -// // loop all items in the file list -// for (TInt i=0; iCount(); i++) -// { -// TFileEntry& fileEntry = iFileEntryList->At(i); -// -// // just check for normal files -// if (!fileEntry.iEntry.IsDir()) -// { -// TUid appUid = GetAppUid(fileEntry); -// TInt iconId = AppIconIdForUid(appUid); -// -// if (appUid != KNullUid && iconId == KErrNotFound) -// { -// // icon not found from the icon array, generate it -// CFbsBitmap* bitmap = NULL; -// CFbsBitmap* mask = NULL; -// CGulIcon* appIcon = NULL; -// -// TRAPD(err, -// AknsUtils::CreateAppIconLC(AknsUtils::SkinInstance(), appUid, EAknsAppIconTypeList, bitmap, mask); -// appIcon = CGulIcon::NewL(bitmap, mask); -// CleanupStack::Pop(2); //bitmap, mask -// ); -// -// if (err == KErrNone) -// { -// TAppIcon appIconEntry; -// appIconEntry.iId = idCounter; -// appIconEntry.iUid = appUid; -// -// appIcon->SetBitmapsOwnedExternally(EFalse); -// iconArray->AppendL(appIcon); -// iAppIconList->AppendL(appIconEntry); -// -// fileEntry.iIconId = idCounter; -// -// idCounter++; -// } -// else -// { -// delete bitmap; -// delete mask; -// -// TAppIcon appIconEntry; -// appIconEntry.iId = EFixedIconEmpty; -// appIconEntry.iUid = appUid; -// -// iAppIconList->AppendL(appIconEntry); -// } -// } -// -// else if (appUid != KNullUid && iconId >= 0) -// { -// // we already have already generated an icon for this uid, use it -// fileEntry.iIconId = iconId; -// } -// } -// } -// } -// -// CleanupStack::Pop(); //iconArray -// return iconArray; -// -// } -// -// -------------------------------------------------------------------------------------------- - -//void CFileBrowserFileUtils::AppendGulIconToIconArrayL(CAknIconArray* aIconArray, const TDesC& aIconFile, TInt aIconId, TInt aMaskId, const TAknsItemID aAknsItemId) -// { -// CGulIcon* icon = AknsUtils::CreateGulIconL( -// AknsUtils::SkinInstance(), -// aAknsItemId, -// aIconFile, -// aIconId, -// aMaskId); -// CleanupStack::PushL(icon); -// -// icon->SetBitmapsOwnedExternally(EFalse); -// aIconArray->AppendL(icon); -// -// CleanupStack::Pop(); //icon -// } - -// -------------------------------------------------------------------------------------------- - -TInt CFileBrowserFileUtils::AppIconIdForUid(TUid aUid) - { - TInt result(KErrNotFound); - - for (TInt i=0; iCount(); i++) - { - if (iAppIconList->At(i).iUid == aUid) - { - result = iAppIconList->At(i).iId; - break; - } - } - - return result; - } - -// -------------------------------------------------------------------------------------------- - -TUid CFileBrowserFileUtils::GetAppUid(TFileEntry aFileEntry) - { - TFileName fullPath; - fullPath.Copy(aFileEntry.iPath); - fullPath.Append(aFileEntry.iEntry.iName); - - TParse parsedName; - parsedName.Set(fullPath, NULL, NULL); - - // this will boost performance in \sys\bin folder - if (parsedName.Ext().CompareF(_L(".dll")) == 0 || parsedName.Ext().CompareF(_L(".rsc")) == 0) - return KNullUid; - - TInt err1(KErrNone), err2(KErrNone); - TUid appUid; - TDataType dataType; - TBool isProgram; - - err1 = iEngine->LsSession().AppForDocument(fullPath, appUid, dataType); - err2 = iEngine->LsSession().IsProgram(fullPath, isProgram); - - if (err1 == KErrNone && err2 == KErrNone) - { - if (isProgram) - { - // get the real app Uid from the app list - TApaAppInfo appInfo; - iEngine->LsSession().GetAllApps(); - - while (iEngine->LsSession().GetNextApp(appInfo) == KErrNone) - { - if (fullPath.CompareF(appInfo.iFullName) == 0) - return appInfo.iUid; - } - } - else - { - // return the app Uid associated for it - return appUid; - } - } - - return KNullUid; - } - - -CFileEntryList* CFileBrowserFileUtils::FileEntries() const -{ - return iFileEntryList; -} -CDriveEntryList* CFileBrowserFileUtils::DriveEntries() const -{ - return iDriveEntryList; -} - -//// -------------------------------------------------------------------------------------------- -// -//CDesCArray* CFileBrowserFileUtils::GenerateItemTextArrayL() -// { -// iTextArray = new(ELeave) CDesCArrayFlat(64); -//// CleanupStack::PushL(textArray); -// -// if (IsDriveListViewActive()) -// { -// _LIT(KSimpleDriveEntry, "%d\t%c: <%S>\t\t"); -// _LIT(KExtendedDriveEntry, "%d\t%c: <%S>\t%LD / %LD kB\t"); -// -// for (TInt i=0; iCount(); i++) -// { -// TFileName textEntry; -// TDriveEntry driveEntry = iDriveEntryList->At(i); -// -// if (iEngine->Settings().iFileViewMode == EFileViewModeSimple) -// { -// textEntry.Format(KSimpleDriveEntry, driveEntry.iIconId, TUint(driveEntry.iLetter), &driveEntry.iMediaTypeDesc); -// } -// else if (iEngine->Settings().iFileViewMode == EFileViewModeExtended) -// { -// textEntry.Format(KExtendedDriveEntry, driveEntry.iIconId, TUint(driveEntry.iLetter), &driveEntry.iMediaTypeDesc, driveEntry.iVolumeInfo.iFree/1024, driveEntry.iVolumeInfo.iSize/1024); -// } -// -// iTextArray->AppendL(textEntry); -// } -// } -// -// else -// { -// _LIT(KSimpleFileEntry, "%d\t%S\t\t"); -// _LIT(KExtendedFileEntry, "%d\t%S\t%S\t"); -// -// for (TInt i=0; iCount(); i++) -// { -// TFileName textEntry; -// TFileEntry fileEntry = iFileEntryList->At(i); -// -// // format text line entries -// if (iEngine->Settings().iFileViewMode == EFileViewModeSimple) -// { -// textEntry.Format(KSimpleFileEntry, fileEntry.iIconId, &fileEntry.iEntry.iName); -// } -// else if (iEngine->Settings().iFileViewMode == EFileViewModeExtended) -// { -// TBuf<128> extraData; -// -// // append entry date -// TTime entryModified = fileEntry.iEntry.iModified; -// if ( iTz.ConvertToLocalTime( entryModified ) == KErrNone ) -// { -// entryModified = fileEntry.iEntry.iModified; -// } -// -// _LIT(KCurrentDate,"%D%M%*Y%/0%1%/1%2%/2%3%/3 %-B%:0%J%:1%T%:2%S%:3%+B"); -// entryModified.FormatL(extraData, KCurrentDate); -// -// // for a directory append number of entries and for a file the file size -// if (fileEntry.iEntry.IsDir() && fileEntry.iDirEntries >= 0) -// { -// extraData.Append(_L(" - ")); -// extraData.AppendNum(fileEntry.iDirEntries); -// -// if (fileEntry.iDirEntries == 1) -// extraData.Append(_L(" entry")); -// else -// extraData.Append(_L(" entries")); -// } -// -// // normal file entry -// else if (!fileEntry.iEntry.IsDir()) -// { -// extraData.Append(_L(" - ")); -// -// if (fileEntry.iEntry.iSize < 1024) -// { -// extraData.AppendNum(fileEntry.iEntry.iSize); -// extraData.Append(_L(" B")); -// } -// else if (fileEntry.iEntry.iSize < 1024*1024) -// { -// TReal sizeKB = (TReal)fileEntry.iEntry.iSize / 1024; -// extraData.AppendNum(sizeKB, TRealFormat(KDefaultRealWidth, 1)); -// extraData.Append(_L(" kB")); -// } -// else -// { -// TReal sizeMB = (TReal)fileEntry.iEntry.iSize / (1024*1024); -// extraData.AppendNum(sizeMB, TRealFormat(KDefaultRealWidth, 1)); -// extraData.Append(_L(" MB")); -// } -// } -// -// // append attribute flags if any -// TBuf<4> atts; -// if (fileEntry.iEntry.IsArchive()) -// atts.Append(_L("A")); -// if (fileEntry.iEntry.IsHidden()) -// atts.Append(_L("H")); -// if (fileEntry.iEntry.IsReadOnly()) -// atts.Append(_L("R")); -// if (fileEntry.iEntry.IsSystem()) -// atts.Append(_L("S")); -// -// if (atts.Length() > 0) -// { -// extraData.Append(_L(" - [")); -// extraData.Append(atts); -// extraData.Append(_L("]")); -// } -// -// // format -// textEntry.Format(KExtendedFileEntry, fileEntry.iIconId, &fileEntry.iEntry.iName, &extraData); -// } -// -// iTextArray->AppendL(textEntry); -// } -// } -// -//// CleanupStack::Pop(); //textArray -// return iTextArray; -// } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::GenerateDirectoryDataL() - { - if (iListingMode == ENormalEntries) - { - if (IsDriveListViewActive()) - GetDriveListL(); - else - GetDirectoryListingL(); - } - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::GetDriveListL() - { - TDriveList driveList; - - // get drive listing depending of the support for network drives - if (iEngine->Settings().iSupportNetworkDrives) - { - #ifndef __SERIES60_30__ - #ifndef __SERIES60_31__ - User::LeaveIfError(iFs.DriveList(driveList, KDriveAttAll)); - #endif - #else - User::LeaveIfError(iFs.DriveList(driveList)); - #endif - } - else - { - User::LeaveIfError(iFs.DriveList(driveList)); - } - - iDriveEntryList->Reset(); - - for (TInt i=0; iCount(); - } - - iDriveEntryList->AppendL(driveEntry); - } - } - - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::GetDirectoryListingL() - { - iFileEntryList->Reset(); - - TInt sortMode(ESortByName); - if (iSortMode == EFileBrowserCmdViewSortByExtension) - sortMode = ESortByExt; - else if (iSortMode == EFileBrowserCmdViewSortBySize) - sortMode = ESortBySize; - else if (iSortMode == EFileBrowserCmdViewSortByDate) - sortMode = ESortByDate; - - TInt orderMode(EAscending); - if (iOrderMode == EFileBrowserCmdViewOrderDescending) - orderMode = EDescending; - - CDir* dir = NULL; - if (iFs.GetDir(iCurrentPath, KEntryAttMatchMask, sortMode | orderMode | EDirsFirst, dir) == KErrNone) - { - CleanupStack::PushL(dir); - - for (TInt i=0; iCount(); i++) - { - TFileEntry fileEntry; - fileEntry.iPath = iCurrentPath; - fileEntry.iEntry = (*dir)[i]; - fileEntry.iDirEntries = KErrNotFound; - fileEntry.iIconId = EFixedIconEmpty; - - if ( iPrevFolderName != KNullDesC && iPrevFolderName == fileEntry.iEntry.iName ) - { - iPrevFolderIndex = i; - } - - // check for directory entries - if (fileEntry.iEntry.IsDir()) - { - fileEntry.iIconId = EFixedIconFolder; - - TFileName subPath = fileEntry.iPath; - subPath.Append(fileEntry.iEntry.iName); - subPath.Append(_L("\\")); - - // get number of entries in this directory if extended info about sub directories enabled - if (iEngine->Settings().iShowSubDirectoryInfo && iEngine->Settings().iFileViewMode == EFileViewModeExtended) - { - CDir* subDir = NULL; - if (iFs.GetDir(subPath, KEntryAttMatchMask, ESortNone | EDirsFirst, subDir) == KErrNone) - { - fileEntry.iDirEntries = subDir->Count(); - delete subDir; - } - } - - // apply subfolder icon for known directories (speed improvement) - if (subPath[0]=='Z' && (subPath.CompareF(_L("Z:\\data\\"))==0 || subPath.CompareF(_L("Z:\\Nokia\\"))==0 - || subPath.Compare(_L("Z:\\private\\"))==0 || subPath.Compare(_L("Z:\\resource\\"))==0 - || subPath.Compare(_L("Z:\\sys\\"))==0 || subPath.Compare(_L("Z:\\system\\"))==0)) - { - fileEntry.iIconId = EFixedIconFolderSub; - } - else if (subPath[0]=='Z' && (subPath.CompareF(_L("Z:\\sys\\bin\\"))==0)) - { - // normal folder icon for these ones - fileEntry.iIconId = EFixedIconFolder; - } - else - { - // check if this folder has subdirectories - CDir* subDir = NULL; - if (iFs.GetDir(subPath, KEntryAttDir|KEntryAttMatchMask, ESortNone | EDirsFirst, subDir) == KErrNone) - { - for (TInt j=0; jCount(); j++) - { - TEntry entry = (*subDir)[j]; - - if (entry.IsDir()) - { - fileEntry.iIconId = EFixedIconFolderSub; - break; - } - } - - delete subDir; - } - } - } - - iFileEntryList->AppendL(fileEntry); - } - - CleanupStack::PopAndDestroy(); //dir - } - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::MoveUpOneLevelL() - { - iPrevFolderIndex = KErrNotFound; - iPrevFolderName.Zero(); - - // change back to normal mode or move up - if (iListingMode != ENormalEntries) - { - iListingMode = ENormalEntries; - } - else - { - // do nothing if displaying drive list view - if (IsDriveListViewActive()) - return; - - if (iCurrentPath.Length() <= KDriveLetterStringLength) - { - if ( iCurrentPath.Length() > 0 ) - { - iPrevFolderName.Append( iCurrentPath[0] ); - } - // move to drive list view if the current path is already short enough - iCurrentPath = KNullDesC; - } - else - { - // move one directory up - TInt marker(iCurrentPath.Length()); - - // find second last dir marker - for (TInt i=iCurrentPath.Length()-2; i>=0; i--) - { - if (iCurrentPath[i] == '\\') - { - marker = i; - break; - } - - } - - // update iPrevDir with the directory name that we just left - iPrevFolderName.Copy( iCurrentPath.RightTPtr( iCurrentPath.Length() - marker - 1 ) ); - iPrevFolderName.Delete( iPrevFolderName.Length() -1, 2 ); // remove extra '\\' - - iCurrentPath = iCurrentPath.LeftTPtr(marker+1); - } - } - -// if (iEngine->FileListContainer()) -// { - //iEngine->FileListContainer()->DisableSearchFieldL(); - //iEngine->FileListContainer()->ListBox()->ClearSelection(); - //iEngine->FileListContainer()->ListBox()->SetCurrentItemIndex(0); - //iEngine->FileListContainer()->SetNaviPaneTextL(iCurrentPath); -// } - - // update view - RefreshViewL(); - - if (iEngine->Settings().iRememberFolderSelection - //&& iEngine->FileListContainer() - && iPrevFolderIndex > KErrNotFound ) - { - -// TInt visibleItems = iEngine->FileListContainer()->ListBox()->Rect().Height() / -// iEngine->FileListContainer()->ListBox()->ItemHeight() -// - 1; // for the title row -// -// // By default, the selected item would be the last visible item on the listbox. -// // We want the selected item be displayed at the middle of the listbox, so we -// // select one of the successor items first to scroll down a bit -// iEngine->FileListContainer()->ListBox()->SetCurrentItemIndex( -// Min( iEngine->FileListContainer()->ListBox()->Model()->ItemTextArray()->MdcaCount() -1, -// iPrevFolderIndex + visibleItems / 2 ) ); -// -// // ...and after that we select the the correct item. -// iEngine->FileListContainer()->ListBox()->SetCurrentItemIndex( iPrevFolderIndex ); - - // update view - RefreshViewL(); - } - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::MoveDownToDirectoryL(TInt aIndex) - { - - // change back to normal mode - if (iListingMode != ENormalEntries) - { - iListingMode = ENormalEntries; - } - - if (aIndex >= 0) - { - TBool needsRefresh(EFalse); - - if (IsDriveListViewActive()) - { - // currently in a drive list view, move to root of selected drive - if (iDriveEntryList->Count() > aIndex) - { - TDriveEntry driveEntry = iDriveEntryList->At(aIndex); - - iCurrentPath.Append(driveEntry.iLetter); - iCurrentPath.Append(_L(":\\")); - - needsRefresh = ETrue; - } - } - else - { - // otherwise just append the new directory - if (iFileEntryList->Count() > aIndex) - { - TFileEntry fileEntry = iFileEntryList->At(aIndex); - - if (fileEntry.iEntry.IsDir()) - { - iCurrentPath.Copy(fileEntry.iPath); - iCurrentPath.Append(fileEntry.iEntry.iName); - iCurrentPath.Append(_L("\\")); - - needsRefresh = ETrue; - } - } - } - - if (needsRefresh /*&& iEngine->FileListContainer()*/) - { - //iEngine->FileListContainer()->DisableSearchFieldL(); - //iEngine->FileListContainer()->ListBox()->ClearSelection(); - //iEngine->FileListContainer()->ListBox()->SetCurrentItemIndex(0); - //iEngine->FileListContainer()->SetNaviPaneTextL(iCurrentPath); - - // update view - RefreshViewL(); - } - } - } - -// -------------------------------------------------------------------------------------------- - -TBool CFileBrowserFileUtils::IsCurrentDriveReadOnly() - { - if (iListingMode !=ENormalEntries || iCurrentPath.Length() < 2) - return EFalse; - else - { - for (TInt i=0; iCount(); i++) - { - TDriveEntry driveEntry = iDriveEntryList->At(i); - - if (driveEntry.iLetter == iCurrentPath[0]) - { - if (driveEntry.iVolumeInfo.iDrive.iMediaAtt == KMediaAttWriteProtected || driveEntry.iVolumeInfo.iDrive.iMediaAtt == KMediaAttLocked || driveEntry.iVolumeInfo.iDrive.iDriveAtt == KDriveAbsent) - return ETrue; - else - return EFalse; - } - } - } - - return EFalse; - } - -// -------------------------------------------------------------------------------------------- - -TBool CFileBrowserFileUtils::IsItemDirectory(TInt aCurrentItemIndex) - { - if (aCurrentItemIndex < 0) - { - return EFalse; - } - else - { - if (iFileEntryList->Count() > aCurrentItemIndex) - { - TFileEntry fileEntry = iFileEntryList->At(aCurrentItemIndex) ; - return fileEntry.iEntry.IsDir(); - } - else - { - return EFalse; - } - } - } - -// -------------------------------------------------------------------------------------------- - -TInt CFileBrowserFileUtils::SetSelectedItemsOrCurrentItemL(const CArrayFix* selectionIndexes, - CFileEntryList* aFileEntryList) - { - aFileEntryList->Reset(); - - // by default use selected items - if (selectionIndexes && selectionIndexes->Count() > 0) - { - TInt ref(0); - TKeyArrayFix key(0, ECmpTUint16); - TInt index(0); - - for (TInt i=0; iCount(); i++) - { - ref = i; - - if (selectionIndexes->Find(ref, key, index) == 0) - { - aFileEntryList->AppendL(iFileEntryList->At(i)); - } - } - } - return aFileEntryList->Count(); - } - -// -------------------------------------------------------------------------------------------- - -TInt CFileBrowserFileUtils::ClipboardCutL(const CArrayFix* aSelectionIndices) - { - - iClipBoardMode = EClipBoardModeCut; - TInt operations = SetSelectedItemsOrCurrentItemL(aSelectionIndices, iClipBoardList); - return operations; - } - -// -------------------------------------------------------------------------------------------- - -TInt CFileBrowserFileUtils::ClipboardCopyL(const CArrayFix* aSelectionIndices) - { - iClipBoardMode = EClipBoardModeCopy; - TInt operations = SetSelectedItemsOrCurrentItemL(aSelectionIndices, iClipBoardList); - return operations; - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::ClipboardPasteL(const TOverwriteOptions &aOverwriteOptions) - { - if (iClipBoardMode == EClipBoardModeCut) - { - DoCopyToFolderL(iClipBoardList, iCurrentPath, aOverwriteOptions, ETrue ); - iClipBoardList->Reset(); - } - else if (iClipBoardMode == EClipBoardModeCopy) - { - DoCopyToFolderL(iClipBoardList, iCurrentPath, aOverwriteOptions, EFalse); - } - } - -// -------------------------------------------------------------------------------------------- - -TInt CFileBrowserFileUtils::SetCurrentSelection(const CArrayFix* aSelectionIndices) - { - TInt operations = SetSelectedItemsOrCurrentItemL(aSelectionIndices, iCurrentSelectionList); - return operations; - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::CopyToFolderL(TFileName aTargetDir, - const TOverwriteOptions &aOverwriteOptions, - TBool aMove) - { - - // TFileName destinationFolder; - - // generate an icon array - // CAknIconArray* iconArray = GenerateIconArrayL(ETrue); - // CleanupStack::PushL(iconArray); - - // run folder selection dialog - // CFileBrowserDestinationFolderSelectionDlg* dlg = CFileBrowserDestinationFolderSelectionDlg::NewL(destinationFolder, iDriveEntryList, iconArray); - - // do the file operations - //DoCopyToFolderL(entryList, aTargetDir, aOverwriteOptions, aMove); - DoCopyToFolderL(iCurrentSelectionList, aTargetDir, aOverwriteOptions, aMove); - - // CleanupStack::Pop(); //iconArray - } - -// -------------------------------------------------------------------------------------------- - -TBool CFileBrowserFileUtils::IsDestinationEntriesExists(const TDesC& aTargetDir) - { - TBool someEntryExists(EFalse); - if (iCurrentSelectionList && iCurrentSelectionList->Count() > 0) - { - // check if some destination entries also exists - for (TInt i=0; iCount(); i++) - { - TFileEntry fileEntry = iCurrentSelectionList->At(i); - - TFileName targetEntry = aTargetDir; - targetEntry.Append(fileEntry.iEntry.iName); - - if (fileEntry.iEntry.IsDir()) - { - targetEntry.Append(_L("\\")); - - if (BaflUtils::PathExists(iFs, targetEntry)) - { - someEntryExists = ETrue; - break; - } - } - else - { - if (BaflUtils::FileExists(iFs, targetEntry)) - { - someEntryExists = ETrue; - break; - } - } - } - } - return someEntryExists; - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::DoCopyToFolderL(CFileEntryList* aEntryList, - const TDesC& aTargetDir, - const TOverwriteOptions &aOverwriteOptions, - TBool aDeleteSource) - { - if (aEntryList && aEntryList->Count() > 0) - { - if (aOverwriteOptions.iDoFileOperations) - { - // set correct command id depending if we are copying or moving - TInt commandId(EFileBrowserFileOpCommandCopy); - if (aDeleteSource) - commandId = EFileBrowserFileOpCommandMove; - - // do the file operations for each entry - for (TInt i=0; iCount(); i++) - { - TFileEntry fileEntry = aEntryList->At(i); - - TFileName targetEntry = aTargetDir; - targetEntry.Append(fileEntry.iEntry.iName); - - if (aOverwriteOptions.iQueryIndex == EFileActionGenerateUniqueFilenames) - { - CApaApplication::GenerateFileName(iFs, targetEntry); - } - else if (aOverwriteOptions.iQueryIndex == EFileActionQueryPostFix) - { - targetEntry.Append(aOverwriteOptions.iPostFix); - } - - - // append the new command to the command array - if (fileEntry.iEntry.IsDir()) - { - AppendToCommandArrayL(commandId, - new(ELeave)CCommandParamsCopyOrMove(fileEntry, targetEntry, aOverwriteOptions.iOverWriteFlags|CFileMan::ERecurse) - ); - } - else - { - AppendToCommandArrayL(commandId, - new(ELeave)CCommandParamsCopyOrMove(fileEntry, targetEntry, aOverwriteOptions.iOverWriteFlags) - ); - } - - } - } - } - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::DeleteL() - { - // do the file operations for each entry - for (TInt i=0; iCount(); i++) - { - TFileEntry fileEntry = iCurrentSelectionList->At(i); - - // append the new command to the command array - if (fileEntry.iEntry.IsDir()) - { - AppendToCommandArrayL(EFileBrowserFileOpCommandDelete, - new(ELeave)CCommandParamsDelete(fileEntry, CFileMan::ERecurse) - ); - } - else - { - AppendToCommandArrayL(EFileBrowserFileOpCommandDelete, - new(ELeave)CCommandParamsDelete(fileEntry, 0) - ); - } - - } - } - - -// -------------------------------------------------------------------------------------------- - -TBool CFileBrowserFileUtils::SelectionHasDirs() -{ - TBool isDir(EFalse); - - // check if any directories and ask recursion - for (TInt i=0; iCount(); i++) - { - TFileEntry fileEntry = iCurrentSelectionList->At(i); - - if (fileEntry.iEntry.IsDir()) - { - isDir = ETrue; - break; - } - } - return isDir; -} - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::TouchL(TBool aRecurse) - { - // now go through all entries - for (TInt i=0; iCount(); i++) - { - TFileEntry fileEntry = iCurrentSelectionList->At(i); - - // touch to current time - TTime now; - now.UniversalTime(); - - - // append the new command to the command array - if (fileEntry.iEntry.IsDir() && aRecurse) - { - AppendToCommandArrayL(EFileBrowserFileOpCommandAttribs, - new(ELeave)CCommandParamsAttribs(fileEntry, NULL, NULL, now, CFileMan::ERecurse) - ); - } - else - { - AppendToCommandArrayL(EFileBrowserFileOpCommandAttribs, - new(ELeave)CCommandParamsAttribs(fileEntry, NULL, NULL, now, 0) - ); - } - } - } - -TBool CFileBrowserFileUtils::TargetExists(const TInt aIndex, const TFileName &newName) - { - TBool alreadyExists(EFalse); - if (iFileEntryList->Count() > aIndex && aIndex >= 0) - { - - TFileEntry fileEntry = iFileEntryList->At(aIndex); - TFileName targetEntry = fileEntry.iPath; - targetEntry.Append(newName); - if (fileEntry.iEntry.IsDir()) - { - //targetEntry.Append(_L("\\")); - alreadyExists = BaflUtils::PathExists(iFs, targetEntry); - } - else - { - alreadyExists = BaflUtils::FileExists(iFs, targetEntry); - } - } - return alreadyExists; - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::RenameL(const TInt aIndex, const TFileName &newName) - { - if (iFileEntryList->Count() > aIndex && aIndex >= 0) - { - TFileEntry fileEntry = iFileEntryList->At(aIndex); - - TFileName targetEntry = fileEntry.iPath; - targetEntry.Append(newName); - - // append the new command to the command array - AppendToCommandArrayL(EFileBrowserFileOpCommandRename, - new(ELeave)CCommandParamsRename(fileEntry, targetEntry, CFileMan::EOverWrite) - ); - } - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::SetAttributesL(TUint &aSetAttMask, TUint &aClearAttMask, TBool &aRecurse) - { - for (TInt i=0; iCount(); i++) - { - TFileEntry fileEntry = iCurrentSelectionList->At(i); - - // append the new command to the command array - if (fileEntry.iEntry.IsDir() && aRecurse) - { - AppendToCommandArrayL(EFileBrowserFileOpCommandAttribs, - new(ELeave)CCommandParamsAttribs(fileEntry, aSetAttMask, aClearAttMask, fileEntry.iEntry.iModified, CFileMan::ERecurse) - ); - } - else - { - AppendToCommandArrayL(EFileBrowserFileOpCommandAttribs, - new(ELeave)CCommandParamsAttribs(fileEntry, aSetAttMask, aClearAttMask, fileEntry.iEntry.iModified, 0) - ); - } - } - - // execute all operations - StartExecutingCommandsL(_L("Changing attributes")); - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::SearchL() - { -// iEngine->FileListContainer()->SetScreenLayoutL(EDisplayModeNormal); -// iEngine->FileListContainer()->SetNaviPaneTextL(KNullDesC); -// -// iSearchAttributes.iSearchDir = iCurrentPath; -// -// CFileBrowserSearchQueryDlg* dlg = CFileBrowserSearchQueryDlg::NewL(iSearchAttributes); -// TBool dlgResult = dlg->RunQueryLD(); -// -// iEngine->FileListContainer()->SetScreenLayoutL(iEngine->Settings().iDisplayMode); -// iEngine->FileListContainer()->SetNaviPaneTextL(iCurrentPath); -// -// if (dlgResult) -// { -// iEngine->EikonEnv()->BusyMsgL(_L("** Searching **"), TGulAlignment(EHCenterVTop)); - - - iEngine->FileBrowserUI()->ShowWaitDialog(_L("Searching")); - iFileEntryList->Reset(); - - // if search dir is empty, find from all drives - if (iSearchAttributes.iSearchDir == KNullDesC) - { - for (TInt i=0; iCount(); i++) - { - TDriveEntry driveEntry = iDriveEntryList->At(i); - - TBuf<10> driveRoot; - driveRoot.Append(driveEntry.iLetter); - driveRoot.Append(_L(":\\")); - - DoSearchFiles(iSearchAttributes.iWildCards, driveRoot); - - if (iSearchAttributes.iRecurse) - DoSearchFilesRecursiveL(iSearchAttributes.iWildCards, driveRoot); - } - - } - - // otherwise just search from the selected directory - else - { - DoSearchFiles(iSearchAttributes.iWildCards, iSearchAttributes.iSearchDir); - - if (iSearchAttributes.iRecurse) - DoSearchFilesRecursiveL(iSearchAttributes.iWildCards, iSearchAttributes.iSearchDir); - } - -// iEngine->EikonEnv()->BusyMsgCancel(); - iEngine->FileBrowserUI()->CancelWaitDialog(); - -// TInt operations = iFileEntryList->Count(); - - iListingMode = ESearchResults; - // TODO iEngine->FileListContainer()->ListBox()->SetCurrentItemIndex(0); - RefreshViewL(); - -// _LIT(KMessage, "%d entries found"); -// TFileName noteMsg; -// noteMsg.Format(KMessage, operations); -// -// iEngine->FileBrowserUI()->ShowInformationNote(noteMsg, _L("")); -// } - } - -// -------------------------------------------------------------------------------------------- - -TInt CFileBrowserFileUtils::DoSearchFiles(const TDesC& aFileName, const TDesC& aPath) - { - TFindFile fileFinder(iFs); - CDir* dir; - TInt err = fileFinder.FindWildByPath(aFileName, &aPath, dir); - - while (err == KErrNone && iAllowProcessing) - { - iEngine->FileBrowserUI()->ProcessEvents(); - for (TInt i=0; iCount(); i++) - { - TEntry entry = (*dir)[i]; - - TTime entryModified = entry.iModified; - // convert from universal time - if ( iTz.ConvertToLocalTime( entryModified ) == KErrNone ) - { - entryModified = entry.iModified; - } - if ((entry.IsDir() && entryModified >= iSearchAttributes.iMinDate && entryModified <= iSearchAttributes.iMaxDate) || - (!entry.IsDir() &&entry.iSize >= iSearchAttributes.iMinSize && entry.iSize <= iSearchAttributes.iMaxSize && - entryModified >= iSearchAttributes.iMinDate && entryModified <= iSearchAttributes.iMaxDate)) - { - TParse parsedName; - parsedName.Set(entry.iName, &fileFinder.File(), NULL); - - if (parsedName.Drive().Length() && aPath.Length() && parsedName.Drive()[0] == aPath[0]) - { - TFileEntry fileEntry; - fileEntry.iPath = parsedName.DriveAndPath(); - fileEntry.iEntry = entry; - fileEntry.iDirEntries = KErrNotFound; - - TBool appendToArray(EFalse); - - // append directories always - if (entry.IsDir() && !iSearchAttributes.iTextInFile.Length()) - { - fileEntry.iIconId = EFixedIconFolder; - appendToArray = ETrue; - } - - // normal file - else - { - fileEntry.iIconId = EFixedIconEmpty; - - // check if a string needs to be found inside the file - if (iSearchAttributes.iTextInFile.Length()) - { - // currently only 8-bit searching, so convert from 16-bit - TBuf8<256> searchText; - searchText.Copy(iSearchAttributes.iTextInFile); - - // specify buffer size and create a buffer - const TInt KReadBufSize = 1024*1024; - HBufC8* buffer = HBufC8::NewLC(KReadBufSize); - TPtr8 bufferPtr = buffer->Des(); - - // open the file for reading - RFile file; - if (file.Open(iFs, parsedName.FullName(), EFileRead) == KErrNone) - { - TInt currentPos(0); - - for (;;) - { - // read from the file - file.Read(currentPos, bufferPtr, KReadBufSize); - - // stop looping if the read buffer isn't long enough - if (bufferPtr.Length() < searchText.Length()) - { - break; - } - - // try to find the text - if (bufferPtr.FindF(searchText) >= 0) - { - // match found! - appendToArray = ETrue; - break; - } - - // calculate the next position - currentPos += KReadBufSize - searchText.Length(); - } - - file.Close(); - } - - CleanupStack::PopAndDestroy(); //buffer - } - else - { - appendToArray = ETrue; - } - } - - if (appendToArray) - TRAP(err, iFileEntryList->AppendL(fileEntry)); - } - } - } - - delete dir; - err = fileFinder.FindWild(dir); - } - - return err; - } - -// -------------------------------------------------------------------------------------------- - -TInt CFileBrowserFileUtils::DoSearchFilesRecursiveL(const TDesC& aFileName, const TDesC& aPath) - { - TInt err(KErrNone); - CDirScan* scan = CDirScan::NewLC(iFs); - scan->SetScanDataL(aPath, KEntryAttDir|KEntryAttMatchMask, ESortByName | EAscending | EDirsFirst); - CDir* dir = NULL; - - for(;;) - { - TRAP(err, scan->NextL(dir)); - if (!dir || (err != KErrNone)) - break; - - for (TInt i=0; iCount(); i++) - { - TEntry entry = (*dir)[i]; - - if (entry.IsDir()) - { - TFileName path(scan->FullPath()); - - if (path.Length()) - { - path.Append(entry.iName); - path.Append(_L("\\")); - DoSearchFiles(aFileName, path); - } - } - } - delete(dir); - } - - CleanupStack::PopAndDestroy(scan); - return err; - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::NewFileL(const TFileName &aNewFileName) - { - TFileName fullPath = iCurrentPath; - fullPath.Append(aNewFileName); - - TParse nameParser; - TInt err = nameParser.SetNoWild(fullPath, NULL, NULL); - - if (err == KErrNone) - { - // do not try to recreate the file if it already exists - if (BaflUtils::PathExists(iFs, nameParser.DriveAndPath())) - { - err = iFileOps->CreateEmptyFile(fullPath); - } - else - err = KErrAlreadyExists; - } - - if (err == KErrNone) - { - iEngine->FileBrowserUI()->ShowConfirmationNote(_L("New file created")); - } - - else if (err == KErrAlreadyExists) - { - iEngine->FileBrowserUI()->ShowInformationNote(_L("File already exists"), _L("")); - } - - else - { - CTextResolver* textResolver = CTextResolver::NewLC(*iEngine->EikonEnv()); - - iEngine->FileBrowserUI()->ShowErrorNote( textResolver->ResolveErrorString(err, CTextResolver::ECtxNoCtxNoSeparator) ); - - CleanupStack::PopAndDestroy(); //textResolver - } - - RefreshViewL(); - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::NewDirectoryL(const TFileName &aNewDirectoryName) - { - TFileName fullPath = iCurrentPath; - fullPath.Append(aNewDirectoryName); - fullPath.Append(_L("\\")); - - TInt err = iFileOps->MkDirAll(fullPath, 0, ETrue); - - if (err == KErrNone) - { - iEngine->FileBrowserUI()->ShowConfirmationNote(_L("New directory created")); - } - - else if (err == KErrAlreadyExists) - { - iEngine->FileBrowserUI()->ShowInformationNote(_L("Directory already exists"), _L("")); - } - - else - { - CTextResolver* textResolver = CTextResolver::NewLC(*iEngine->EikonEnv()); - - iEngine->FileBrowserUI()->ShowErrorNote( textResolver->ResolveErrorString(err, CTextResolver::ECtxNoCtxNoSeparator) ); - - CleanupStack::PopAndDestroy(); //textResolver - } - - RefreshViewL(); - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::SendToL() - { -// CFileEntryList* entries = new(ELeave) CFileEntryList(32); -// GetSelectedItemsOrCurrentItemL(entries); -// CleanupStack::PushL(entries); -// -// TInt operations(0); -// -// CSendUi* sendUi = CSendUi::NewL(); -// CleanupStack::PushL(sendUi); -// CMessageData* messageData = CMessageData::NewL(); -// CleanupStack::PushL(messageData); -// -// for (TInt i=0; iCount(); i++) -// { -// TFileEntry fileEntry = entries->At(i); -// -// // only supported for normal file entries -// if (!fileEntry.iEntry.IsDir()) -// { -// TFileName fullPath = fileEntry.iPath; -// fullPath.Append(fileEntry.iEntry.iName); -// -// messageData->AppendAttachmentL(fullPath); -// operations++; -// -// } -// } -// -// if (operations > 0) -// { -// sendUi->ShowQueryAndSendL(messageData, TSendingCapabilities(0, 0, TSendingCapabilities::ESupportsAttachments)); -// -// // I guess this note is not needed.. -//// _LIT(KMessage, "%d entries sent"); -//// TFileName noteMsg; -//// noteMsg.Format(KMessage, operations); -//// -//// iEngine->FileBrowserUI()->ShowConfirmationNote(noteMsg); -// } -// else -// { -// _LIT(KMessage, "Nothing to send"); -// iEngine->FileBrowserUI()->ShowInformationNote(KMessage, _L("")); -// } -// -// CleanupStack::PopAndDestroy(3); // entries, sendUi, messageData - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::CompressL() - { -// CFileEntryList* entries = new(ELeave) CFileEntryList(16); -// GetSelectedItemsOrCurrentItemL(entries); -// CleanupStack::PushL(entries); -// -// for (TInt i=0; iCount(); i++) -// { -// TFileEntry fileEntry = entries->At(i); -// -// TFileName sourceEntry = fileEntry.iPath; -// sourceEntry.Append(fileEntry.iEntry.iName); -// -// TFileName targetEntry = sourceEntry; -// targetEntry.Append(KGZipExt); -// -// TFileName targetEntryShort; -// targetEntryShort.Copy(fileEntry.iEntry.iName); -// targetEntryShort.Append(KGZipExt); -// -// if (BaflUtils::FileExists(iFs, targetEntry)) -// { -// _LIT(KMessage, "%S already exists"); -// TFileName noteMsg; -// noteMsg.Format(KMessage, &targetEntryShort); -// -// iEngine->FileBrowserUI()->ShowInformationNote(noteMsg, _L("")); -// } -// else -// { -// TRAPD(err, -// RFile inputFile; -// User::LeaveIfError(inputFile.Open(iFs, sourceEntry, EFileStream | EFileRead | EFileShareAny)); -// CleanupClosePushL(inputFile); -// -// CEZFileToGZip* gZip = CEZFileToGZip::NewLC(iFs, targetEntry, inputFile); -// -// while (gZip->DeflateL()) -// ; -// -// CleanupStack::PopAndDestroy(2); //inputFile, gZip -// ); -// -// if (err == KErrNone) -// { -// _LIT(KMessage, "%S created succesfully"); -// TFileName noteMsg; -// noteMsg.Format(KMessage, &targetEntryShort); -// -// iEngine->FileBrowserUI()->ShowConfirmationNote(noteMsg); -// } -// else -// { -// _LIT(KMessage, "Unable to create %S"); -// TFileName noteMsg; -// noteMsg.Format(KMessage, &targetEntryShort); -// -// iEngine->FileBrowserUI()->ShowErrorNote(noteMsg); -// } -// -// RefreshViewL(); -// } -// } -// -// CleanupStack::PopAndDestroy(); //entries - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::DecompressL() - { -// CFileEntryList* entries = new(ELeave) CFileEntryList(16); -// GetSelectedItemsOrCurrentItemL(entries); -// CleanupStack::PushL(entries); -// -// for (TInt i=0; iCount(); i++) -// { -// TFileEntry fileEntry = entries->At(i); -// -// TFileName sourceEntry = fileEntry.iPath; -// sourceEntry.Append(fileEntry.iEntry.iName); -// -// TFileName targetEntry; -// TFileName targetEntryShort; -// -// TInt sourceNameLen = fileEntry.iEntry.iName.Length(); -// TInt gZipExtLen = KGZipExt().Length(); -// -// if (sourceNameLen > gZipExtLen && sourceEntry.Right(gZipExtLen).CompareF(KGZipExt) == 0) -// { -// targetEntry = sourceEntry.Left(sourceEntry.Length() - gZipExtLen); -// targetEntryShort = fileEntry.iEntry.iName.Left(sourceNameLen - gZipExtLen); -// -// if (BaflUtils::FileExists(iFs, targetEntry)) -// { -// _LIT(KMessage, "%S already exists"); -// TFileName noteMsg; -// noteMsg.Format(KMessage, &targetEntryShort); -// -// iEngine->FileBrowserUI()->ShowInformationNote(noteMsg, _L("")); -// } -// else -// { -// TRAPD(err, -// RFile outputFile; -// User::LeaveIfError(outputFile.Create(iFs, targetEntry, EFileStream | EFileWrite | EFileShareExclusive)); -// CleanupClosePushL(outputFile); -// -// CEZGZipToFile* gZip = CEZGZipToFile::NewLC(iFs, sourceEntry, outputFile); -// -// while (gZip->InflateL()) -// ; -// -// CleanupStack::PopAndDestroy(2); //outputFile, gZip -// ); -// -// if (err == KErrNone) -// { -// _LIT(KMessage, "%S decompressed succesfully"); -// TFileName noteMsg; -// noteMsg.Format(KMessage, &fileEntry.iEntry.iName); -// -// iEngine->FileBrowserUI()->ShowConfirmationNote(noteMsg); -// } -// else -// { -// _LIT(KMessage, "Unable to decompress %S"); -// TFileName noteMsg; -// noteMsg.Format(KMessage, &fileEntry.iEntry.iName); -// -// iEngine->FileBrowserUI()->ShowErrorNote(noteMsg); -// } -// -// RefreshViewL(); -// } -// } -// else -// { -// _LIT(KMessage, "%S does not have %S extension"); -// TFileName noteMsg; -// noteMsg.Format(KMessage, &fileEntry.iEntry.iName, &KGZipExt); -// -// iEngine->FileBrowserUI()->ShowInformationNote(noteMsg, _L("")); -// } -// } -// -// CleanupStack::PopAndDestroy(); //entries - } - -// -------------------------------------------------------------------------------------------- - -bool CFileBrowserFileUtils::PropertiesL(TInt aCurrentItemIndex, CDesCArray* entryLines, TFileName &titleText) - { - - TBool showDialog(EFalse); - - _LIT(KPropertiesEntryStr, "%S\t%S"); - _LIT(KPropertiesEntryInt, "%S\t%d"); - _LIT(KPropertiesEntryUintHex, "%S\t0x%x"); - - _LIT(KDateFormat, "%D%M%Y%/0%1%/1%2%/2%3%/3"); - _LIT(KTimeFormat, "%-B%:0%J%:1%T%:2%S%:3%+B"); - - _LIT(KMediaType, "Media"); - _LIT(KAttributes, "Atts"); - _LIT(KVolumeName, "Name"); - _LIT(KUniqueID, "ID"); - _LIT(KNumberOfEntries, "Entries"); - _LIT(KNumberOfFiles, "Files"); - _LIT(KUsed, "Used (B)"); - _LIT(KFree, "Free (B)"); - _LIT(KSize, "Size (B)"); - _LIT(KPath, "Path"); - _LIT(KDate, "Date"); - _LIT(KTime, "Time"); - _LIT(KMimeType, "Mime"); - _LIT(KOpensWith, "Opens"); - - - // create an array for the items -// CDesCArray* entryLines = new(ELeave) CDesCArrayFlat(16); -// CleanupStack::PushL(entryLines); -// TFileName titleText; - - // just get current item -// TInt currentItemIndex = iEngine->QueryCurrentItemIndex(); - - if (IsDriveListViewActive() && iDriveEntryList->Count() > aCurrentItemIndex && aCurrentItemIndex >= 0) - { - // it is a drive entry - TDriveEntry driveEntry = iDriveEntryList->At(aCurrentItemIndex); - TFileName textEntry; - - // set title - titleText.Append(driveEntry.iLetter); - titleText.Append(_L(":")); - - // media type - textEntry.Format(KPropertiesEntryStr, &KMediaType, &driveEntry.iMediaTypeDesc); - entryLines->AppendL(textEntry); - - // attributes - textEntry.Format(KPropertiesEntryStr, &KAttributes, &driveEntry.iAttributesDesc); - entryLines->AppendL(textEntry); - - // volume name - if (driveEntry.iVolumeInfo.iName.Length()) - { - textEntry.Format(KPropertiesEntryStr, &KVolumeName, &driveEntry.iVolumeInfo.iName); - entryLines->AppendL(textEntry); - } - - // unique id - textEntry.Format(KPropertiesEntryUintHex, &KUniqueID, driveEntry.iVolumeInfo.iUniqueID); - entryLines->AppendL(textEntry); - - // number of files - if (iEngine->Settings().iShowSubDirectoryInfo) - { - iFindFileEntryList->Reset(); - - TBuf<10> driveRoot; - driveRoot.Append(driveEntry.iLetter); - driveRoot.Append(_L(":\\")); - - DoFindFiles(_L("*"), driveRoot); - DoFindFilesRecursiveL(_L("*"), driveRoot); - - textEntry.Format(KPropertiesEntryInt, &KNumberOfFiles, iFindFileEntryList->Count()); - entryLines->AppendL(textEntry); - - iFindFileEntryList->Reset(); - } - - // used - TBuf<32> usedBuf; - usedBuf.AppendNum(driveEntry.iVolumeInfo.iSize-driveEntry.iVolumeInfo.iFree, TRealFormat(KDefaultRealWidth, 0)); - textEntry.Format(KPropertiesEntryStr, &KUsed, &usedBuf); - entryLines->AppendL(textEntry); - - // free - TBuf<32> freeBuf; - freeBuf.AppendNum(driveEntry.iVolumeInfo.iFree, TRealFormat(KDefaultRealWidth, 0)); - textEntry.Format(KPropertiesEntryStr, &KFree, &freeBuf); - entryLines->AppendL(textEntry); - - // size - TBuf<32> sizeBuf; - sizeBuf.AppendNum(driveEntry.iVolumeInfo.iSize, TRealFormat(KDefaultRealWidth, 0)); - textEntry.Format(KPropertiesEntryStr, &KSize, &sizeBuf); - entryLines->AppendL(textEntry); - - showDialog = ETrue; - } - - else if (iFileEntryList->Count() > aCurrentItemIndex && aCurrentItemIndex >= 0) - { - // it is a file or a directory entry - TFileEntry fileEntry = iFileEntryList->At(aCurrentItemIndex); - TFileName textEntry; - - // set title - titleText.Append(fileEntry.iEntry.iName); - - // path - textEntry.Format(KPropertiesEntryStr, &KPath, &fileEntry.iPath); - entryLines->AppendL(textEntry); - - // date - TTime entryModified = fileEntry.iEntry.iModified; - - // convert from universal time - if ( iTz.ConvertToLocalTime( entryModified ) == KErrNone ) - { - entryModified = fileEntry.iEntry.iModified; // use universal time - } - - TBuf<32> dateBuf; - entryModified.FormatL(dateBuf, KDateFormat); - textEntry.Format(KPropertiesEntryStr, &KDate, &dateBuf); - entryLines->AppendL(textEntry); - - // time - TBuf<32> timeBuf; - entryModified.FormatL(timeBuf, KTimeFormat); - textEntry.Format(KPropertiesEntryStr, &KTime, &timeBuf); - entryLines->AppendL(textEntry); - - if (!fileEntry.iEntry.IsDir()) - { - // size - TBuf<32> sizeBuf; - sizeBuf.AppendNum(fileEntry.iEntry.iSize, TRealFormat(KDefaultRealWidth, 0)); - textEntry.Format(KPropertiesEntryStr, &KSize, &sizeBuf); - entryLines->AppendL(textEntry); - } - else if (fileEntry.iEntry.IsDir() && iEngine->Settings().iShowSubDirectoryInfo) - { - iFindFileEntryList->Reset(); - - TFileName fullPath; - fullPath.Append(fileEntry.iPath); - fullPath.Append(fileEntry.iEntry.iName); - fullPath.Append(_L("\\")); - - // number of entries - CDir* subDir = NULL; - if (iFs.GetDir(fullPath, KEntryAttMatchMask, ESortNone | EDirsFirst, subDir) == KErrNone) - { - CleanupStack::PushL(subDir); - textEntry.Format(KPropertiesEntryInt, &KNumberOfEntries, subDir->Count()); - entryLines->AppendL(textEntry); - CleanupStack::PopAndDestroy(); //subDir - } - - // number of files - DoFindFiles(_L("*"), fullPath); - DoFindFilesRecursiveL(_L("*"), fullPath); - textEntry.Format(KPropertiesEntryInt, &KNumberOfFiles, iFindFileEntryList->Count()); - entryLines->AppendL(textEntry); - - // size - TInt64 size(0); - for (TInt i=0; iCount(); i++) - { - TFileEntry fileEntry = iFindFileEntryList->At(i); - size += fileEntry.iEntry.iSize; - } - - TBuf<32> sizeBuf; - sizeBuf.AppendNum(size, TRealFormat(KDefaultRealWidth, 0)); - textEntry.Format(KPropertiesEntryStr, &KSize, &sizeBuf); - entryLines->AppendL(textEntry); - - iFindFileEntryList->Reset(); - } - - // attributes - TBuf<32> attBuf; - if (fileEntry.iEntry.IsArchive()) - attBuf.Append(_L("Arc ")); - if (fileEntry.iEntry.IsHidden()) - attBuf.Append(_L("Hid ")); - if (fileEntry.iEntry.IsReadOnly()) - attBuf.Append(_L("R/O ")); - if (fileEntry.iEntry.IsSystem()) - attBuf.Append(_L("Sys")); - textEntry.Format(KPropertiesEntryStr, &KAttributes, &attBuf); - entryLines->AppendL(textEntry); - - if (!fileEntry.iEntry.IsDir()) - { - // mime type - TFileName fullPath = fileEntry.iPath; - fullPath.Append(fileEntry.iEntry.iName); - TDataType dataType; - TUid appUid; - if (iEngine->LsSession().AppForDocument(fullPath, appUid, dataType) == KErrNone) - { - TBuf<128> mimeTypeBuf; - mimeTypeBuf.Copy(dataType.Des8()); - if (mimeTypeBuf == KNullDesC) - mimeTypeBuf.Copy(_L("N/A")); - textEntry.Format(KPropertiesEntryStr, &KMimeType, &mimeTypeBuf); - entryLines->AppendL(textEntry); - } - - // opens with - TApaAppInfo appInfo; - if (iEngine->LsSession().GetAppInfo(appInfo, appUid) == KErrNone) - { - TFileName opensWithBuf; - _LIT(KOpensWithFormat, "%S (0x%08X)"); - opensWithBuf.Format(KOpensWithFormat, &appInfo.iCaption, appInfo.iUid); - textEntry.Format(KPropertiesEntryStr, &KOpensWith, &opensWithBuf); - entryLines->AppendL(textEntry); - } - } - - showDialog = ETrue; - } - return showDialog; - -// if (showDialog) -// { -// CAknSingleHeadingPopupMenuStyleListBox* listBox = new(ELeave) CAknSingleHeadingPopupMenuStyleListBox; -// CleanupStack::PushL(listBox); -// -// CAknPopupList* popupList = CAknPopupList::NewL(listBox, R_AVKON_SOFTKEYS_OK_EMPTY, AknPopupLayouts::EMenuDoubleWindow); -// CleanupStack::PushL(popupList); -// -// listBox->ConstructL(popupList, CEikListBox::ELeftDownInViewRect); -// listBox->ItemDrawer()->ColumnData()->EnableMarqueeL(ETrue); -// listBox->CreateScrollBarFrameL(ETrue); -// listBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto); -// listBox->Model()->SetItemTextArray(entryLines); -// listBox->Model()->SetOwnershipType(ELbmDoesNotOwnItemArray); -// listBox->HandleItemAdditionL(); -// -// popupList->SetTitleL(titleText); -// popupList->ExecuteLD(); -// -// CleanupStack::Pop(); // popupList -// CleanupStack::PopAndDestroy(); // listBox -// } -// -// CleanupStack::PopAndDestroy(); //entryLines - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::OpenWithApparcL(TFileName aFileName) - { - - TFileName fullPath = aFileName; - TInt err1(KErrNone), err2(KErrNone); - TUid appUid; - TDataType dataType; - TBool isProgram; - - - err1 = iEngine->LsSession().AppForDocument(fullPath, appUid, dataType); - err2 = iEngine->LsSession().IsProgram(fullPath, isProgram); - - if (err1 == KErrNone && err2 == KErrNone) - { - if (appUid != KNullUid) - { - // found an app, run using it - TApaTaskList taskList(CEikonEnv::Static()->WsSession()); - TApaTask task = (taskList.FindApp(appUid)); - if (task.Exists()) - { - User::LeaveIfError(task.SwitchOpenFile(fullPath)); - task.BringToForeground(); - } - else - { - TThreadId id; - iEngine->LsSession().StartDocument(fullPath, appUid, id, RApaLsSession::ESwitchFiles); - } - } - else if (isProgram) - { - LaunchProgramL(fullPath); - } - } - //} - } - -// -------------------------------------------------------------------------------------------- - -//void CFileBrowserFileUtils::HandleServerAppExit(TInt aReason) -// { -// if (iOpenFileService) -// { -// delete iOpenFileService; -// iOpenFileService = NULL; -// } -// MAknServerAppExitObserver::HandleServerAppExit(aReason); -// } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::OpenWithDocHandlerL(TFileName aFileName, TBool aEmbed) - { - TFileName fullPath = aFileName; - RFile sharableFile; - iDocHandler->OpenTempFileL(fullPath, sharableFile); - CleanupClosePushL(sharableFile); - TDataType dataType; - if (aEmbed) - { - iDocHandler->OpenFileEmbeddedL(sharableFile, dataType); - } - else - { - iDocHandler->OpenFileL(sharableFile, dataType); - } - CleanupStack::PopAndDestroy(); //sharableFile - // } - } - - // -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::OpenWithFileServiceL(TInt aCurrentItemIndex) - { - if (iFileEntryList->Count() > aCurrentItemIndex && aCurrentItemIndex >= 0) - { - TFileEntry fileEntry = iFileEntryList->At(aCurrentItemIndex); - - TFileName fullPath = fileEntry.iPath; - fullPath.Append(fileEntry.iEntry.iName); - - TBool itemSelected(EFalse); - RFile sharableFile; -// TUid appUidExtracted; - - TRAPD(err, - - // use doc handler to get a sharable file handle - iDocHandler->OpenTempFileL(fullPath, sharableFile); - CleanupClosePushL(sharableFile); - - // find the data type - TDataRecognitionResult dataType; - User::LeaveIfError(iEngine->LsSession().RecognizeData(sharableFile, dataType)); - - // get all apps that support OpenFileService for this datatype - CApaAppServiceInfoArray* apps = iEngine->LsSession().GetServiceImplementationsLC(KOpenServiceUid, dataType.iDataType); - TArray appServiceInfos = apps->Array(); - - if (appServiceInfos.Count() > 0) - { - // build an array of the app names - CDesCArray* names = new (ELeave) CDesCArrayFlat(16); - CleanupStack::PushL(names); - for (TInt ii=0; iiLsSession().GetAppInfo(appInfo, appUid) == KErrNone) - { - names->AppendL(appInfo.iCaption); - } - else - { - TBuf<10> buf; - buf.Format(_L("0x%08x"), appUid); - names->AppendL(buf); - } - } - - // use a list query to select the app -// TInt index(0); -// CAknListQueryDialog* dlg = new(ELeave) CAknListQueryDialog(&index); -// dlg->PrepareLC(R_APP_SELECTION_QUERY); -// dlg->SetItemTextArray(names); -// dlg->SetOwnershipType(ELbmDoesNotOwnItemArray); -// -// if(dlg->RunLD()) -// { -// // extract the chosen UID -// appUidExtracted = appServiceInfos[index].Uid(); -// itemSelected = ETrue; -// } - - CleanupStack::PopAndDestroy(); // names - } - - if (itemSelected) - { - // start OpenFileService for the selected app - CAiwGenericParamList& paramList = iDocHandler->InParamListL(); - -// if (iOpenFileService) -// { -// delete iOpenFileService; -// iOpenFileService = NULL; -// } - -// iOpenFileService = CAknOpenFileService::NewL(appUidExtracted, sharableFile, this, ¶mList); - } - - CleanupStack::PopAndDestroy(2); // sharableFile, apps - - ); // TRAPD - - if (err != KErrNone) - { - _LIT(KMessage, "No file service available for %S"); - TFileName noteMsg; - noteMsg.Format(KMessage, &fileEntry.iEntry.iName); - - iEngine->FileBrowserUI()->ShowInformationNote(noteMsg, _L("")); - } - } - } - -// -------------------------------------------------------------------------------------------- - -TBool CFileBrowserFileUtils::FileExists(const TDesC& aPath) - { - return BaflUtils::FileExists(iFs, aPath); - } - -// -------------------------------------------------------------------------------------------- - -TInt CFileBrowserFileUtils::LaunchProgramL(const TDesC& aPath) - { - CApaCommandLine* commandLine = CApaCommandLine::NewLC(); - commandLine->SetExecutableNameL(aPath); - commandLine->SetCommandL(EApaCommandRun); - TInt err = iEngine->LsSession().StartApp(*commandLine); - CleanupStack::PopAndDestroy(); //commandLine - return err; - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::MemoryInfoPopupL() - { - _LIT(KUsedBytesEntry, "Used: %S bytes\n"); - _LIT(KFreeBytesEntry, "Free: %S bytes\n"); - _LIT(KSizeBytesEntry, "Size: %S bytes\n"); - - HBufC* messageBuf = HBufC::NewLC(2048); - TPtr messagePtr = messageBuf->Des(); - TBuf<128> entryLine; - - // RAM - TMemoryInfoV1Buf ramMemory; - UserHal::MemoryInfo(ramMemory); - messagePtr.Append(_L("RAM\n")); - - // used - TBuf<32> usedBuf; - usedBuf.AppendNum(ramMemory().iMaxFreeRamInBytes-ramMemory().iFreeRamInBytes, TRealFormat(KDefaultRealWidth, 0)); - entryLine.Format(KUsedBytesEntry, &usedBuf); - messagePtr.Append(entryLine); - - // free - TBuf<32> freeBuf; - freeBuf.AppendNum(ramMemory().iFreeRamInBytes, TRealFormat(KDefaultRealWidth, 0)); - entryLine.Format(KFreeBytesEntry, &freeBuf); - messagePtr.Append(entryLine); - - // size - TBuf<32> sizeBuf; - sizeBuf.AppendNum(ramMemory().iMaxFreeRamInBytes, TRealFormat(KDefaultRealWidth, 0)); - entryLine.Format(KSizeBytesEntry, &sizeBuf); - messagePtr.Append(entryLine); - - // All drives - for (TInt i=0; iCount(); i++) - { - TDriveEntry driveEntry = iDriveEntryList->At(i); - - messagePtr.Append(_L("\n")); - messagePtr.Append(driveEntry.iLetter); - messagePtr.Append(_L(":\n")); - - // used - TBuf<32> usedBuf; - usedBuf.AppendNum(driveEntry.iVolumeInfo.iSize-driveEntry.iVolumeInfo.iFree, TRealFormat(KDefaultRealWidth, 0)); - entryLine.Format(KUsedBytesEntry, &usedBuf); - messagePtr.Append(entryLine); - - // free - TBuf<32> freeBuf; - freeBuf.AppendNum(driveEntry.iVolumeInfo.iFree, TRealFormat(KDefaultRealWidth, 0)); - entryLine.Format(KFreeBytesEntry, &freeBuf); - messagePtr.Append(entryLine); - - // size - TBuf<32> sizeBuf; - sizeBuf.AppendNum(driveEntry.iVolumeInfo.iSize, TRealFormat(KDefaultRealWidth, 0)); - entryLine.Format(KSizeBytesEntry, &sizeBuf); - messagePtr.Append(entryLine); - } - -// CAknMessageQueryDialog* dialog = new(ELeave) CAknMessageQueryDialog; -// dialog->PrepareLC(R_MEMORYINFO_DIALOG); -// dialog->SetMessageTextL(messagePtr); -// dialog->RunLD(); - - CleanupStack::PopAndDestroy(); //messageBuf - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::ShowFileCheckSumsL(TInt aCurrentItemIndex, TInt aType) - { - if (iFileEntryList->Count() > aCurrentItemIndex && aCurrentItemIndex >= 0) - { - TFileEntry fileEntry = iFileEntryList->At(aCurrentItemIndex); - TFileName fullPath = fileEntry.iPath; - fullPath.Append(fileEntry.iEntry.iName); - - // try to open the file for reading - RFile fileP; - TInt err = fileP.Open(iEngine->EikonEnv()->FsSession(), fullPath, EFileRead|EFileShareReadersOnly); - - if (err == KErrNone) - { - CleanupClosePushL(fileP); - - TBuf<128> checkSum; - HBufC* messageBuf = HBufC::NewLC(2048); - TPtr messagePtr = messageBuf->Des(); - - // get MD5 checksum - if (aType == EFileChecksumsMD5) - { - CMD5* md5 = CMD5::NewL(); - CleanupStack::PushL(md5); - HBufC8* md5Buf = MessageDigestInHexLC(md5, fileP); - checkSum.Copy(*md5Buf); - messagePtr.Append(_L("MD5\n")); - messagePtr.Append(checkSum); - CleanupStack::PopAndDestroy(2); // md5, md5Buf - } - - // get MD2 checksum - else if (aType == EFileChecksumsMD2) - { - CMD2* md2 = CMD2::NewL(); - CleanupStack::PushL(md2); - HBufC8* md2Buf = MessageDigestInHexLC(md2, fileP); - checkSum.Copy(*md2Buf); - messagePtr.Append(_L("MD2\n")); - messagePtr.Append(checkSum); - CleanupStack::PopAndDestroy(2); // md2, md2Buf - } - - // get SHA-1 checksum - else if (aType == EFileChecksumsSHA1) - { - CSHA1* sha1 = CSHA1::NewL(); - CleanupStack::PushL(sha1); - HBufC8* sha1Buf = MessageDigestInHexLC(sha1, fileP); - checkSum.Copy(*sha1Buf); - messagePtr.Append(_L("SHA-1\n")); - messagePtr.Append(checkSum); - CleanupStack::PopAndDestroy(2); // sha1, sha1Buf - } - - else - { - User::Panic(_L("Inv.CS.Type"), 723); - } - - // show dialog - iEngine->FileBrowserUI()->ShowInformationNote(messagePtr, fileEntry.iEntry.iName); - - CleanupStack::PopAndDestroy(2); // messageBuf, fileP - } - else - { - // open failed, show an error note - CTextResolver* textResolver = CTextResolver::NewLC(*iEngine->EikonEnv()); - - iEngine->FileBrowserUI()->ShowErrorNote( - textResolver->ResolveErrorString(err, CTextResolver::ECtxNoCtxNoSeparator) ); - - CleanupStack::PopAndDestroy(); //textResolver - } - } - } - -// -------------------------------------------------------------------------------------------- - -HBufC8* CFileBrowserFileUtils::MessageDigestInHexLC(CMessageDigest* aMD, RFile& aFile) - { - // seek to file start - TInt startPos(0); - aFile.Seek(ESeekStart, startPos); - - // create result buffer - HBufC8* result = HBufC8::NewLC(128); - - const TInt KBufSize(1024); - TInt fileSize(0); - TInt fileOffset(0); - - // get file size - aFile.Size(fileSize); - - HBufC8* buf = HBufC8::NewMaxLC(KBufSize); - TPtr8 bufPtr(buf->Des()); - - // read to buffer - while (fileOffset < fileSize - KBufSize) - { - aFile.Read(bufPtr, KBufSize); - aMD->Hash(bufPtr); - fileOffset += bufPtr.Length(); - } - - aFile.Read(bufPtr, fileSize - fileOffset); - bufPtr.SetLength(fileSize - fileOffset); - - // get final message digest - TPtrC8 hashedSig(aMD->Final(bufPtr)); - - // change size of the result buffer - result->ReAllocL(hashedSig.Length() * 2); - TPtr8 resultPtr = result->Des(); - - // convert to hex format - for (TInt i=0; iSettings().iBypassPlatformSecurity) - { - TInt err(KErrNone); - - if (aEnable) - { - // make sure that the directory exists - iFileOps->MkDirAll(KErrRdPath); - - // create the file - err = iFileOps->CreateEmptyFile(KErrRdPath); - } - else - { - // get TEntry of ErrRd - TEntry entry; - err = iFs.Entry(KErrRdPath, entry); - - if (err == KErrNone) - { - TFileEntry fileEntry; - fileEntry.iPath = KErrRdDir; - fileEntry.iEntry = entry; - - err = iFileOps->Delete(fileEntry); - } - } - - // update view - RefreshViewL(); - - if (err == KErrNone) - { - iEngine->FileBrowserUI()->ShowConfirmationNote(_L("State changed")); - } - else - { - iEngine->FileBrowserUI()->ShowErrorNote(_L("Cannot change the state")); - } - } - else - { - iEngine->FileBrowserUI()->ShowInformationNote(_L("Enable \"bypass platform security\" from the settings first"), _L("")); - } - #else - aEnable = aEnable; - iEngine->FileBrowserUI()->ShowInformationNote(_L("Not supported in lite version"), _L("")); - #endif - } - -// -------------------------------------------------------------------------------------------- - -//void CFileBrowserFileUtils::EnableAvkonIconCacheL(TBool aEnable) -// { -//#ifndef __SERIES60_30__ -// if (AknIconConfig::EnableAknIconSrvCache(aEnable) == KErrNone) -// { -// iEngine->FileBrowserUI()->ShowConfirmationNote(_L("State changed")); -// } -// else -// { -// iEngine->FileBrowserUI()->ShowErrorNote(_L("Unknown error occured")); -// } -// #else -// aEnable = aEnable; -// iEngine->FileBrowserUI()->ShowInformationNote(_L("Not supported in S60 3.0"), _L("")); -// #endif -// -// } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::SimulateLeaveL(TInt aLeaveCode) - { - User::Leave(aLeaveCode); - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::SimulatePanicL(const TDesC& aPanicCategory, TInt aPanicCode) - { - User::Panic(aPanicCategory, aPanicCode); - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::SimulateExceptionL(TInt aExceptionCode) - { - User::RaiseException((TExcType)aExceptionCode); - } - -// -------------------------------------------------------------------------------------------- - -TUint32 CFileBrowserFileUtils::GetDebugMask() - { - return UserSvr::DebugMask(); - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::SetDebugMaskL(TUint32 aDbgMask) - { - User::SetDebugMask(aDbgMask); - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::WriteAllAppsL() - { - _LIT(KAllAppsFileName, "AllApps.txt"); - TFileName allAppsPath = PathInfo::PhoneMemoryRootPath(); - allAppsPath.Append(KAllAppsFileName); - - RFile file; - if (file.Replace(iFs, allAppsPath, EFileWrite) == KErrNone) - { - CleanupClosePushL(file); - - CDesC8Array* appsArray = new(ELeave) CDesC8ArrayFlat(192); - CleanupStack::PushL(appsArray); - - TBuf8 fileEntry; - TBuf8 appFullPath; - _LIT8(KAppEntryFormat, "%S (0x%08X)%S"); - TApaAppInfo appInfo; - - iEngine->LsSession().GetAllApps(); - - while (iEngine->LsSession().GetNextApp(appInfo) == KErrNone) - { - appFullPath.Copy(appInfo.iFullName); - fileEntry.Format(KAppEntryFormat, &appFullPath, appInfo.iUid, &KFileNewLine); - appsArray->AppendL(fileEntry); - } - - appsArray->Sort(); - - for (TInt i=0; iCount(); i++) - { - file.Write(appsArray->MdcaPoint(i)); - } - - CleanupStack::PopAndDestroy(2); //appsArray, file - - _LIT(KMessage, "App list written to %S"); - TFileName noteMsg; - noteMsg.Format(KMessage, &allAppsPath); - - iEngine->FileBrowserUI()->ShowConfirmationNote(noteMsg, ETrue); // NoTimeout - } - else - { - _LIT(KMessage, "Failed writing to %S"); - TFileName noteMsg; - noteMsg.Format(KMessage, &allAppsPath); - - iEngine->FileBrowserUI()->ShowErrorNote(noteMsg, ETrue); // NoTimeout - } - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::WriteAllFilesL() - { - _LIT(KAllFilesFileName, "AllFiles.txt"); - TFileName allFilesPath = PathInfo::PhoneMemoryRootPath(); - allFilesPath.Append(KAllFilesFileName); - - RFile file; - if (file.Replace(iFs, allFilesPath, EFileWrite) == KErrNone) - { - CleanupClosePushL(file); - iFindFileEntryList->Reset(); - - iEngine->FileBrowserUI()->ShowWaitDialog(_L("Generating")); - - for (TInt i=0; iCount(); i++) - { - TDriveEntry driveEntry = iDriveEntryList->At(i); - - TBuf<10> driveRoot; - driveRoot.Append(driveEntry.iLetter); - driveRoot.Append(_L(":\\")); - - // current dir - DoFindFiles(_L("*"), driveRoot); - - // recurse into sub directories - DoFindFilesRecursiveL(_L("*"), driveRoot); - } - - // write entries - TBuf8 writeBuf; - for (TInt i=0; iCount(); i++) - { - TFileEntry fileEntry = iFindFileEntryList->At(i); - - writeBuf.Copy(fileEntry.iPath); - writeBuf.Append(fileEntry.iEntry.iName); - writeBuf.Append(_L(",")); - writeBuf.AppendNum(fileEntry.iEntry.iSize); - writeBuf.Append(_L(" B")); - -// // date -// TTime entryModified = fileEntry.iEntry.iModified; -// // convert from universal time -// if ( iTz.ConvertToLocalTime( entryModified ) == KErrNone ) -// { -// entryModified = fileEntry.iEntry.iModified; // use universal time -// } -// -// _LIT(KDateFormat, "%D%M%Y%/0%1%/1%2%/2%3%/3"); -// TBuf<32> dateBuf; -// entryModified.FormatL(dateBuf, KDateFormat); -// writeBuf.Append(dateBuf); -// -// writeBuf.Append(_L(" ")); -// // time -// _LIT(KTimeFormat, "%-B%:0%J%:1%T%:2%S%:3%+B"); -// TBuf<32> timeBuf; -// entryModified.FormatL(timeBuf, KTimeFormat); -// writeBuf.Append(timeBuf); -// - writeBuf.Append(KFileNewLine); - file.Write(writeBuf); - } - - iEngine->FileBrowserUI()->CancelWaitDialog(); - - CleanupStack::PopAndDestroy(); //file - iFindFileEntryList->Reset(); - - _LIT(KMessage, "File list written to %S"); - TFileName noteMsg; - noteMsg.Format(KMessage, &allFilesPath); - - iEngine->FileBrowserUI()->ShowConfirmationNote(noteMsg, EFalse); // NoTimeout - } - else - { - _LIT(KMessage, "Failed writing to %S"); - TFileName noteMsg; - noteMsg.Format(KMessage, &allFilesPath); - - iEngine->FileBrowserUI()->ShowErrorNote(noteMsg, ETrue); // NoTimeout - } - } - -// -------------------------------------------------------------------------------------------- - -TInt CFileBrowserFileUtils::DoFindFiles(const TDesC& aFileName, const TDesC& aPath) - { - TFindFile fileFinder(iFs); - CDir* dir; - TInt err = fileFinder.FindWildByPath(aFileName, &aPath, dir); - - while (err == KErrNone && iAllowProcessing) - { - iEngine->FileBrowserUI()->ProcessEvents(); - for (TInt i=0; iCount(); i++) - { - TEntry entry = (*dir)[i]; - - // ignore any directory entries - if (!entry.IsDir() && entry.iName.Length() && aPath.Length()) - { - TParse parsedName; - parsedName.Set(entry.iName, &fileFinder.File(), NULL); - - if (parsedName.Drive().Length() && aPath.Length() && parsedName.Drive()[0] == aPath[0]) - { - TFileEntry fileEntry; - fileEntry.iPath = parsedName.DriveAndPath(); - fileEntry.iEntry = entry; - fileEntry.iDirEntries = KErrNotFound; - fileEntry.iIconId = EFixedIconEmpty; - - TRAP(err, iFindFileEntryList->AppendL(fileEntry)); - } - } - } - - delete dir; - dir = NULL; - err = fileFinder.FindWild(dir); - } - - return err; - } - -// -------------------------------------------------------------------------------------------- - -TInt CFileBrowserFileUtils::DoFindFilesRecursiveL(const TDesC& aFileName, const TDesC& aPath) - { - TInt err(KErrNone); - CDirScan* scan = CDirScan::NewLC(iFs); - scan->SetScanDataL(aPath, KEntryAttDir|KEntryAttMatchMask, ESortByName | EAscending | EDirsFirst); - CDir* dir = NULL; - - for(;;) - { - TRAP(err, scan->NextL(dir)); - if (!dir || (err != KErrNone)) - break; - - for (TInt i=0; iCount(); i++) - { - TEntry entry = (*dir)[i]; - - if (entry.IsDir()) - { - TFileName path(scan->FullPath()); - - if (path.Length()) - { - path.Append(entry.iName); - path.Append(_L("\\")); - DoFindFiles(aFileName, path); - } - } - } - delete(dir); - } - - CleanupStack::PopAndDestroy(scan); - return err; - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::ListOpenFilesL() - { - iFileEntryList->Reset(); - - CFileList* dir = NULL; - TOpenFileScan fileScan(iFs); - fileScan.NextL(dir); - - while (dir) - { - for (TInt i=0; iCount(); i++) - { - TEntry entry = (*dir)[i]; - TFileName fullPath; - - // TOpenFileScan does not return drive letters for the entries, so try to guess it - if (entry.iName.Length() > 2 && entry.iName[1] != ':') - { - for (TInt i=0; iCount(); i++) - { - TDriveEntry driveEntry = iDriveEntryList->At(i); - - TFileName guessPath; - guessPath.Append(driveEntry.iLetter); - guessPath.Append(_L(":")); - guessPath.Append(entry.iName); - - // check if the file exists - if (BaflUtils::FileExists(iFs, guessPath)) - { - // if it's on read only drive, then take it or check if it's really in use - TBool readOnlyDrive(ETrue); - BaflUtils::DiskIsReadOnly(iFs, guessPath, readOnlyDrive); - - if (readOnlyDrive || iFs.SetEntry(guessPath, entry.iModified, NULL, NULL) == KErrInUse) - { - fullPath = guessPath; - break; - } - } - } - } - else - { - fullPath = entry.iName; - } - - TParse nameParser; - if (fullPath.Length() && nameParser.SetNoWild(fullPath, NULL, NULL) == KErrNone) - { - entry.iName = nameParser.NameAndExt(); - - TFileEntry fileEntry; - fileEntry.iPath = nameParser.DriveAndPath(); - fileEntry.iEntry = entry; - fileEntry.iDirEntries = KErrNotFound; - fileEntry.iIconId = EFixedIconEmpty; - - iFileEntryList->AppendL(fileEntry); - } - } - - delete dir; - dir = NULL; - fileScan.NextL(dir); - } - - TInt operations = iFileEntryList->Count(); - - iListingMode = EOpenFiles; - // TODO - //iEngine->FileListContainer()->ListBox()->SetCurrentItemIndex(0); - RefreshViewL(); - - _LIT(KMessage, "%d open files found"); - TFileName noteMsg; - noteMsg.Format(KMessage, operations); - - iEngine->FileBrowserUI()->ShowInformationNote(noteMsg, _L("")); - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::ListMessageAttachmentsL(TInt aType) - { - iFileEntryList->Reset(); - - CMsvSession* session = CMsvSession::OpenSyncL(*this); - CleanupStack::PushL(session); - - CMsvEntry* context = NULL; - - if (aType == EFileBrowserCmdToolsMsgAttachmentsInbox) - context = session->GetEntryL(KMsvGlobalInBoxIndexEntryId); - else if (aType == EFileBrowserCmdToolsMsgAttachmentsDrafts) - context = session->GetEntryL(KMsvDraftEntryId); - else if (aType == EFileBrowserCmdToolsMsgAttachmentsSentItems) - context = session->GetEntryL(KMsvSentEntryId); - else if (aType == EFileBrowserCmdToolsMsgAttachmentsOutbox) - context = session->GetEntryL(KMsvGlobalOutBoxIndexEntryId); - else - User::Panic(_L("MsgAtt.Mode"), 100); - - CleanupStack::PushL(context); - - CDesCArray* attPaths = new(ELeave) CDesCArrayFlat(128); - CleanupStack::PushL(attPaths); - - // read attachment paths - ReadAttachmentPathsRecursiveL(session, context, attPaths); - - // create file entries of the paths - for (TInt i=0; iMdcaCount(); i++) - { - TFileEntry fileEntry; - TEntry entry; - TParse nameParser; - - if (attPaths->MdcaPoint(i).Length() && - nameParser.SetNoWild(attPaths->MdcaPoint(i), NULL, NULL) == KErrNone && - iFs.Entry(attPaths->MdcaPoint(i), entry) == KErrNone) - { - TFileEntry fileEntry; - fileEntry.iPath = nameParser.DriveAndPath(); - fileEntry.iEntry = entry; - fileEntry.iDirEntries = KErrNotFound; - fileEntry.iIconId = EFixedIconEmpty; - - iFileEntryList->AppendL(fileEntry); - } - } - - CleanupStack::PopAndDestroy(3); //session, context, attPaths - - TInt operations = iFileEntryList->Count(); - - if (aType == EFileBrowserCmdToolsMsgAttachmentsInbox) - iListingMode = EMsgAttachmentsInbox; - else if (aType == EFileBrowserCmdToolsMsgAttachmentsDrafts) - iListingMode = EMsgAttachmentsDrafts; - else if (aType == EFileBrowserCmdToolsMsgAttachmentsSentItems) - iListingMode = EMsgAttachmentsSentItems; - else if (aType == EFileBrowserCmdToolsMsgAttachmentsOutbox) - iListingMode = EMsgAttachmentsOutbox; - - // TODO - //iEngine->FileListContainer()->ListBox()->SetCurrentItemIndex(0); - RefreshViewL(); - - _LIT(KMessage, "%d files found"); - TFileName noteMsg; - noteMsg.Format(KMessage, operations); - - iEngine->FileBrowserUI()->ShowInformationNote(noteMsg, _L("")); - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::ReadAttachmentPathsRecursiveL(CMsvSession* aSession, CMsvEntry* aContext, CDesCArray* aAttPaths) - { - CMsvEntrySelection* entrySelection = aContext->ChildrenL(); - CleanupStack::PushL(entrySelection); - - for (TInt i=0; iCount(); i++) - { - CMsvEntry* entry = aSession->GetEntryL((*entrySelection)[i]); - CleanupStack::PushL(entry); - - CMsvStore* store = NULL; - TRAPD(err, store = entry->ReadStoreL()); - - if (err == KErrNone) - { - CleanupStack::PushL(store); - - for (TInt j=0; jAttachmentManagerL().AttachmentCount(); j++) - { - CMsvAttachment* attachment = store->AttachmentManagerL().GetAttachmentInfoL(j); - CleanupStack::PushL(attachment); - - aAttPaths->AppendL(attachment->FilePath()); - - CleanupStack::PopAndDestroy(); //attachment - } - CleanupStack::PopAndDestroy(); // store - } - - // recurse into children - if (entry->Count() > 0) - { - ReadAttachmentPathsRecursiveL(aSession, entry, aAttPaths); - } - - CleanupStack::PopAndDestroy(); // entry - } - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::WriteMsgStoreWalkL() - { - _LIT(KAllAppsFileName, "MsgStoreWalk.txt"); - TFileName allAppsPath = PathInfo::PhoneMemoryRootPath(); - allAppsPath.Append(KAllAppsFileName); - - if (iMsgStoreWalkFile.Replace(iFs, allAppsPath, EFileWrite) == KErrNone) - { - CMsvSession* session = CMsvSession::OpenSyncL(*this); - CleanupStack::PushL(session); - - CMsvEntry* context = session->GetEntryL(KMsvRootIndexEntryId); - CleanupStack::PushL(context); - - iMsgStoreWalkFile.Write(_L8("id service_id related_id type mtm date size error biotype mtmdata1 mtmdata2 mtmdata3 description details\r\n\r\n")); - - // write details about the root entry - DoWriteMessageEntryInfoL(context, iMsgStoreWalkFile, 0); - - // get and write info recursively - TInt level(1); - WriteMessageEntryInfoRecursiveL(session, context, iMsgStoreWalkFile, level); - - CleanupStack::PopAndDestroy(2); //session, context - - iMsgStoreWalkFile.Flush(); - iMsgStoreWalkFile.Close(); - - _LIT(KMessage, "Msg. store walk written to %S"); - TFileName noteMsg; - noteMsg.Format(KMessage, &allAppsPath); - - iEngine->FileBrowserUI()->ShowConfirmationNote(noteMsg, ETrue); // NoTimeout - } - else - { - _LIT(KMessage, "Failed writing to %S"); - TFileName noteMsg; - noteMsg.Format(KMessage, &allAppsPath); - - iEngine->FileBrowserUI()->ShowErrorNote(noteMsg, ETrue); // NoTimeout - } - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::WriteMessageEntryInfoRecursiveL(CMsvSession* aSession, CMsvEntry* aContext, RFile& aFile, TInt& aLevel) - { - CMsvEntrySelection* entrySelection = aContext->ChildrenL(); - CleanupStack::PushL(entrySelection); - - for (TInt i=0; iCount(); i++) - { - CMsvEntry* entry = aSession->GetEntryL((*entrySelection)[i]); - CleanupStack::PushL(entry); - - DoWriteMessageEntryInfoL(entry, aFile, aLevel); - - // recurse into children - if (entry->Count() > 0) - { - aLevel++; - WriteMessageEntryInfoRecursiveL(aSession, entry, aFile, aLevel); - aLevel--; - } - - CleanupStack::PopAndDestroy(); // entry - } - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::DoWriteMessageEntryInfoL(CMsvEntry* aContext, RFile& aFile, TInt aLevel) - { - TMsvEntry messageEntry = aContext->Entry(); - - for (TInt j=0; j desc; - desc.Copy(messageEntry.iDescription); - - TBuf8<256> details; - details.Copy(messageEntry.iDetails); - - _LIT8(KLine, "-> %d %d %d %d %d %Ld %d %d %d %d %d %d %S %S\r\n"); - TBuf8<1024> buf; - buf.Format(KLine, messageEntry.Id(), messageEntry.iServiceId, messageEntry.iRelatedId, messageEntry.iType.iUid, - messageEntry.iMtm.iUid, messageEntry.iDate.Int64(), messageEntry.iSize, messageEntry.iError, messageEntry.iBioType, - messageEntry.iMtmData1, messageEntry.iMtmData2, messageEntry.iMtmData3, &desc, &details); - - aFile.Write(buf); - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::HandleSessionEventL(TMsvSessionEvent /*aEvent*/, TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/) - { - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::FileEditorL(TInt aCurrentItemIndex, TInt /*aType*/) - { - // TODO - // just get current item - //TInt currentItemIndex = iEngine->QueryCurrentItemIndex(); - - if (iFileEntryList->Count() > aCurrentItemIndex && aCurrentItemIndex >= 0) - { - TFileEntry fileEntry = iFileEntryList->At(aCurrentItemIndex); - - // only valid for files - if (!fileEntry.iEntry.IsDir()) - { - TFileName fullPath = fileEntry.iPath; - fullPath.Append(fileEntry.iEntry.iName); - -// iEngine->FileListContainer()->SetNaviPaneTextL(fileEntry.iEntry.iName); -// -// TInt editorMode(0); -// -// if (aType == EFileBrowserCmdFileViewText) -// editorMode = EFileEditorViewAsText; -// else if (aType == EFileBrowserCmdFileViewHex) -// editorMode = EFileEditorViewAsHex; -// else if (aType == EFileBrowserCmdFileEditText) -// editorMode = EFileEditorEditAsText; -// else if (aType == EFileBrowserCmdFileEditHex) -// editorMode = EFileEditorEditAsHex; -// else -// User::Panic(_L("Inv.Ed.Mode"), 843); -// -// // launch dialog -// CFileBrowserFileEditorDlg* dlg = CFileBrowserFileEditorDlg::NewL(fullPath, editorMode); -// dlg->RunDlgLD(); -// -// iEngine->FileListContainer()->SetNaviPaneTextL(iCurrentPath); -// -// if (aType == EFileBrowserCmdFileEditText || aType == EFileBrowserCmdFileEditHex) -// { -// RefreshViewL(); -// } - } - } - } - -// -------------------------------------------------------------------------------------------- - -TBool CFileBrowserFileUtils::DriveSnapShotPossible() - { -// // TODO -// // check that E-drive is available -// TBool EDriveIsOK(EFalse); -// -// for (TInt i=0; iCount(); i++) -// { -// TDriveEntry driveEntry = iDriveEntryList->At(i); -// -// if (driveEntry.iNumber == EDriveE) -// { -// if (driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttLocked || driveEntry.iVolumeInfo.iDrive.iDriveAtt & KDriveAbsent) -// EDriveIsOK = EFalse; -// else -// EDriveIsOK = ETrue; -// } -// } -// -// if (!EDriveIsOK) -// return EFalse; -// -// // get current item -// TInt currentItemIndex = iEngine->QueryCurrentItemIndex(); -// -// if (iDriveEntryList->Count() > currentItemIndex && currentItemIndex >= 0) -// { -// TDriveEntry driveEntry = iDriveEntryList->At(currentItemIndex); -// -// // drive snapshot not possible when E-drive is highlighted, since that's where we are copying -// if (driveEntry.iNumber == EDriveE) -// return EFalse; -// else -// return ETrue; -// } - return EFalse; - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::DriveSnapShotL() - { -// if (iEngine->Settings().iBypassPlatformSecurity) -// { -// // get current item -// TInt currentItemIndex = iEngine->QueryCurrentItemIndex(); -// -// if (iDriveEntryList->Count() > currentItemIndex && currentItemIndex >= 0) -// { -// TDriveEntry driveEntry = iDriveEntryList->At(currentItemIndex); -// -// TChar sourceDriveLetter = driveEntry.iLetter; -// TChar targetDriveLetter = 'E'; // hardcoded drive letter, could be better if would be queried from the user -// -// // append to the command array -// AppendToCommandArrayL(EFileBrowserFileOpCommandDriveSnapShot, -// new(ELeave)CCommandParamsDriveSnapShot(sourceDriveLetter, targetDriveLetter) -// ); -// -// // execute the operation -// StartExecutingCommandsL(_L("Copying")); -// } -// } -// else -// { -// iEngine->FileBrowserUI()->ShowInformationNote(_L("Enable \"bypass platform security\" from the settings first"), _L("")); -// } - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::SetDrivePasswordL(TInt aIndex, - const TFileName &aOldPassword, - const TFileName &aNewPassword) - { - if (iDriveEntryList->Count() > aIndex && aIndex >= 0) - { - TMediaPassword oldPassword; - TMediaPassword newPassword; - - TDriveEntry driveEntry = iDriveEntryList->At(aIndex); - - ConvertCharsToPwd(aOldPassword, oldPassword); - ConvertCharsToPwd(aNewPassword, newPassword); - - // set the password, does not actually lock the drive - TInt err = iFs.LockDrive(driveEntry.iNumber, oldPassword, newPassword, ETrue); - - if (err == KErrNone) - { - iEngine->FileBrowserUI()->ShowConfirmationNote(_L("Password set")); - } - else if (err == KErrNotSupported) - { - iEngine->FileBrowserUI()->ShowErrorNote(_L("Not supported for this drive")); - } - else - { - CTextResolver* textResolver = CTextResolver::NewLC(*iEngine->EikonEnv()); - - iEngine->FileBrowserUI()->ShowErrorNote( - textResolver->ResolveErrorString(err, CTextResolver::ECtxNoCtxNoSeparator) ); - - CleanupStack::PopAndDestroy(); //textResolver - } - - RefreshViewL(); - } - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::UnlockDriveL(TInt aIndex, const TFileName &aOldPassword) - { - if (iDriveEntryList->Count() > aIndex && aIndex >= 0) - { - TDriveEntry driveEntry = iDriveEntryList->At(aIndex); - - TMediaPassword oldPassword; - ConvertCharsToPwd(aOldPassword, oldPassword); - - // unlock the drive - TInt err = iFs.UnlockDrive(driveEntry.iNumber, oldPassword, ETrue) == KErrNone; - - if (err == KErrNone) - { - iEngine->FileBrowserUI()->ShowConfirmationNote(_L("Drive unlocked")); - } - else if (err == KErrNotSupported) - { - iEngine->FileBrowserUI()->ShowErrorNote(_L("Not supported for this drive")); - } - else - { - CTextResolver* textResolver = CTextResolver::NewLC(*iEngine->EikonEnv()); - - iEngine->FileBrowserUI()->ShowErrorNote( textResolver->ResolveErrorString(err, CTextResolver::ECtxNoCtxNoSeparator) ); - - CleanupStack::PopAndDestroy(); //textResolver - } - - RefreshViewL(); - } - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::ClearDrivePasswordL(TInt aIndex, const TFileName &aOldPassword) - { - if (iDriveEntryList->Count() > aIndex && aIndex >= 0) - { - TDriveEntry driveEntry = iDriveEntryList->At(aIndex); - - TMediaPassword oldPassword; - - ConvertCharsToPwd(aOldPassword, oldPassword); - - // clear the password from the drive - TInt err = iFs.ClearPassword(driveEntry.iNumber, oldPassword); - - if (err == KErrNone) - { - iEngine->FileBrowserUI()->ShowConfirmationNote(_L("Password cleared")); - } - else if (err == KErrNotSupported) - { - iEngine->FileBrowserUI()->ShowErrorNote(_L("Not supported for this drive")); - } - else - { - CTextResolver* textResolver = CTextResolver::NewLC(*iEngine->EikonEnv()); - - iEngine->FileBrowserUI()->ShowErrorNote( - textResolver->ResolveErrorString(err, CTextResolver::ECtxNoCtxNoSeparator) ); - - CleanupStack::PopAndDestroy(); //textResolver - } - - RefreshViewL(); - } - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::EraseDrivePasswordL(TInt aIndex) - { - if (iDriveEntryList->Count() > aIndex && aIndex >= 0) - { - TDriveEntry driveEntry = iDriveEntryList->At(aIndex); - - // erase the password from the drive - TInt err(KErrNone); - err = iFs.ErasePassword(driveEntry.iNumber); - - if (err == KErrNone) - { - iEngine->FileBrowserUI()->ShowConfirmationNote(_L("Password erased")); - } - else if (err == KErrNotSupported) - { - iEngine->FileBrowserUI()->ShowErrorNote(_L("Not supported for this drive")); - } - else - { - iEngine->FileBrowserUI()->ShowErrorNote(_L("Cannot erase, you may have to format the drive first")); - } - - RefreshViewL(); - } - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::FormatDriveL(TInt aIndex, TBool aQuickFormat) - { - if (iDriveEntryList->Count() > aIndex && aIndex >= 0) - { - TDriveEntry driveEntry = iDriveEntryList->At(aIndex); - - TInt err(KErrNone); - TInt formatCount(0); - - TBuf<10> driveRoot; - driveRoot.Append(driveEntry.iLetter); - driveRoot.Append(_L(":")); - - TUint formatMode(0); - if (aQuickFormat) - formatMode = ESpecialFormat|EQuickFormat; - else - formatMode = ESpecialFormat|EFullFormat; - - // set as system application to prevent getting shut down events - iEngine->EikonEnv()->SetSystem(ETrue); - - // first close any open applications - CBaBackupSessionWrapper* BSWrapper = CBaBackupSessionWrapper::NewL(); - CleanupStack::PushL(BSWrapper); - - TBackupOperationAttributes atts(MBackupObserver::EReleaseLockNoAccess, MBackupOperationObserver::EStart); - BSWrapper->NotifyBackupOperationL(atts); - - CAsyncWaiter* waiter = CAsyncWaiter::NewLC(); - BSWrapper->CloseAll( MBackupObserver::EReleaseLockNoAccess, waiter->iStatus ); - waiter->StartAndWait(); - CleanupStack::PopAndDestroy(); //waiter - - // some delay to make sure all applications have been closed - User::After(1000000); - - // format the drive - RFormat format; - err = format.Open(iFs, driveRoot, formatMode, formatCount); - - // Forced format for locked card - if ( err == KErrLocked ) - { - // Erase password and try again - err = iFs.ErasePassword( driveEntry.iNumber ); - if ( !err ) - { - err = format.Open(iFs, driveRoot, formatMode, formatCount); - } - } - - if( err != KErrNone && err != KErrLocked ) - { -// CAknQueryDialog* lockQuery = CAknQueryDialog::NewL(); -// if ( lockQuery->ExecuteLD(R_GENERAL_CONFIRMATION_QUERY, _L("Memory card in use by other application. Proceed anyway?"))) - // TODO Dialog should be opened in UI part - if (iEngine->FileBrowserUI()->ShowConfirmationQuery(_L("Memory card in use by other application. Proceed anyway?"))) - { - // If format could not be started, someone is still keeping - // files open on media. Let's try to dismount file system, then - // remount with own extension embedded and try again. - - TFullName fsName; - err = iFs.FileSystemName( fsName, driveEntry.iNumber ); - - if ( err == KErrNone && fsName.Length() > 0 ) - { - // Prevent SysAp shutting down applications - RProperty::Set( - KPSUidCoreApplicationUIs, - KCoreAppUIsMmcRemovedWithoutEject, - ECoreAppUIsEjectCommandUsed ); - - TRequestStatus stat; - iFs.NotifyDismount( driveEntry.iNumber, stat, EFsDismountForceDismount ); - User::WaitForRequest( stat ); - - // Unfortunately, at the moment we have to wait until clients have received - // notification about card dismount. Otherwise at least causes problems with - // theme selected from card. In future clients should use new notify-API. - User::After( KForcedFormatTimeout ); - - // Let's set priority higher than normally. This is done to decrease the chance - // that someone reopens files on memory card after mandatory file system - // remounting hence preventing formatting again. - TThreadPriority priority( RThread().Priority() ); - RThread().SetPriority( EPriorityAbsoluteHigh ); - - // Mount file system back... - err = iFs.MountFileSystem( fsName, driveEntry.iNumber ); - err = format.Open(iFs, driveRoot, formatMode, formatCount); - RThread().SetPriority( priority ); - } - } - } - - - if (err == KErrNone) - { - // needs to be implemented with active objects - // CAknProgressDialog* dlg = new(ELeave) CAknProgressDialog(formatCount, 1, 1, NULL); - // dlg->SetTone(CAknNoteDialog::ENoTone); - // dlg->ExecuteLD(R_FORMAT_PROGRESS_NOTE); - - while (formatCount && err == KErrNone) - { - err = format.Next(formatCount); - } - } - - format.Close(); - - // restart closed applications - TBackupOperationAttributes atts2(MBackupObserver::ETakeLock, MBackupOperationObserver::EEnd); - BSWrapper->NotifyBackupOperationL(atts2); - BSWrapper->RestartAll(); - CleanupStack::PopAndDestroy(); //BSWrapper - - // system status not needed anymore - iEngine->EikonEnv()->SetSystem(EFalse); - - - if (err == KErrNone) - { - iEngine->FileBrowserUI()->ShowConfirmationNote(_L("Format succeeded")); - } - else if (err == KErrNotSupported) - { - iEngine->FileBrowserUI()->ShowErrorNote(_L("Not supported for this drive")); - } - else - { - CTextResolver* textResolver = CTextResolver::NewLC(*iEngine->EikonEnv()); - - iEngine->FileBrowserUI()->ShowErrorNote( - textResolver->ResolveErrorString(err, CTextResolver::ECtxNoCtxNoSeparator) ); - - CleanupStack::PopAndDestroy(); //textResolver - } - - RefreshViewL(); - } - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::EraseMBRL(TInt aIndex) - { - // TODO - #ifndef FILEBROWSER_LITE - if (iEngine->Settings().iBypassPlatformSecurity) - { - if (iDriveEntryList->Count() > aIndex && aIndex >= 0) - { - TDriveEntry driveEntry = iDriveEntryList->At(aIndex); - - TInt err(KErrNone); - - iEngine->FileBrowserUI()->ShowInformationNote(_L("Please wait, this may take 30 seconds"), _L("")); - - // set as system application to prevent getting shut down events - iEngine->EikonEnv()->SetSystem(ETrue); - - // first close any open applications - CBaBackupSessionWrapper* BSWrapper = CBaBackupSessionWrapper::NewL(); - CleanupStack::PushL(BSWrapper); - - TBackupOperationAttributes atts(MBackupObserver::EReleaseLockNoAccess, MBackupOperationObserver::EStart); - BSWrapper->NotifyBackupOperationL(atts); - - CAsyncWaiter* waiter = CAsyncWaiter::NewLC(); - BSWrapper->CloseAll( MBackupObserver::EReleaseLockNoAccess, waiter->iStatus ); - waiter->StartAndWait(); - CleanupStack::PopAndDestroy(); //waiter - - // some delay to make sure all applications have been closed - User::After(1000000); - - - // do the erase MBR operation - err = iFileOps->EraseMBR(driveEntry.iNumber); - - - // restart closed applications - TBackupOperationAttributes atts2(MBackupObserver::ETakeLock, MBackupOperationObserver::EEnd); - BSWrapper->NotifyBackupOperationL(atts2); - BSWrapper->RestartAll(); - CleanupStack::PopAndDestroy(); //BSWrapper - - // system status not needed anymore - iEngine->EikonEnv()->SetSystem(EFalse); - - - if (err == KErrNone) - { - iEngine->FileBrowserUI()->ShowConfirmationNote(_L("Erase MBR succeeded")); - } - else if (err == KErrNotSupported) - { - iEngine->FileBrowserUI()->ShowErrorNote(_L("Not supported for this drive")); - } - else - { - CTextResolver* textResolver = CTextResolver::NewLC(*iEngine->EikonEnv()); - - iEngine->FileBrowserUI()->ShowErrorNote( - textResolver->ResolveErrorString(err, CTextResolver::ECtxNoCtxNoSeparator) ); - - CleanupStack::PopAndDestroy(); //textResolver - } - - RefreshViewL(); - } - } - else - { - iEngine->FileBrowserUI()->ShowInformationNote(_L("Enable \"bypass platform security\" from the settings first"), _L("")); - } - #else - iEngine->FileBrowserUI()->ShowInformationNote(_L("Not supported in lite version"), _L("")); - #endif - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::PartitionDriveL(TInt aIndex, TBool aEraseMBR, TInt aAmountOfPartitions) - { - // TODO - #ifndef FILEBROWSER_LITE - if (iEngine->Settings().iBypassPlatformSecurity) - { - if (iDriveEntryList->Count() > aIndex && aIndex >= 0) - { - TDriveEntry driveEntry = iDriveEntryList->At(aIndex); - - TInt err(KErrNone); - - iEngine->FileBrowserUI()->ShowInformationNote(_L("Please wait, this may take 30 seconds"), _L("")); - - // set as system application to prevent getting shut down events - iEngine->EikonEnv()->SetSystem(ETrue); - - // first close any open applications - CBaBackupSessionWrapper* BSWrapper = CBaBackupSessionWrapper::NewL(); - CleanupStack::PushL(BSWrapper); - - TBackupOperationAttributes atts(MBackupObserver::EReleaseLockNoAccess, MBackupOperationObserver::EStart); - BSWrapper->NotifyBackupOperationL(atts); - - CAsyncWaiter* waiter = CAsyncWaiter::NewLC(); - BSWrapper->CloseAll( MBackupObserver::EReleaseLockNoAccess, waiter->iStatus ); - waiter->StartAndWait(); - CleanupStack::PopAndDestroy(); //waiter - - // some delay to make sure all applications have been closed - User::After(1000000); - - // do the erase operation - if (aEraseMBR) - { - err = iFileOps->EraseMBR(driveEntry.iNumber); - - if (err != KErrNone) - { - iEngine->FileBrowserUI()->ShowErrorNote(_L("Erase MBR failed")); - } - - User::After(500000); - } - - - // do the partition operation - err = iFileOps->PartitionDrive(driveEntry.iNumber, aAmountOfPartitions); - - - // restart closed applications - TBackupOperationAttributes atts2(MBackupObserver::ETakeLock, MBackupOperationObserver::EEnd); - BSWrapper->NotifyBackupOperationL(atts2); - BSWrapper->RestartAll(); - CleanupStack::PopAndDestroy(); //BSWrapper - - // system status not needed anymore - iEngine->EikonEnv()->SetSystem(EFalse); - - - if (err == KErrNone) - { - iEngine->FileBrowserUI()->ShowConfirmationNote(_L("Partition succeeded")); - } - else if (err == KErrNotSupported) - { - iEngine->FileBrowserUI()->ShowErrorNote(_L("Not supported for this drive")); - } - else - { - CTextResolver* textResolver = CTextResolver::NewLC(*iEngine->EikonEnv()); - - iEngine->FileBrowserUI()->ShowErrorNote( - textResolver->ResolveErrorString(err, CTextResolver::ECtxNoCtxNoSeparator) ); - - CleanupStack::PopAndDestroy(); //textResolver - } - - RefreshViewL(); - } - } - else - { - iEngine->FileBrowserUI()->ShowInformationNote(_L("Enable \"bypass platform security\" from the settings first"), _L("")); - } - #else - iEngine->FileBrowserUI()->ShowInformationNote(_L("Not supported in lite version"), _L("")); - #endif - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::CheckDiskL(TInt aIndex) - { - if (iDriveEntryList->Count() > aIndex && aIndex >= 0) - { - TDriveEntry driveEntry = iDriveEntryList->At(aIndex); - - TBuf<10> driveRoot; - driveRoot.Append(driveEntry.iLetter); - driveRoot.Append(_L(":")); - - // check disk - TInt err = iFs.CheckDisk(driveRoot); - - if (err == KErrNone) - { - iEngine->FileBrowserUI()->ShowConfirmationNote(_L("Integrity of the disk is ok")); - } - else if (err == KErrNotReady) - { - iEngine->FileBrowserUI()->ShowInformationNote(_L("Disk is empty"), _L("")); - } - else if (err == KErrNotSupported) - { - iEngine->FileBrowserUI()->ShowErrorNote(_L("Not supported for this drive")); - } - else - { - iEngine->FileBrowserUI()->ShowErrorNote(_L("Disk is corrupted")); - } - - RefreshViewL(); - } - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::ScanDriveL(TInt aIndex) - { - if (iDriveEntryList->Count() > aIndex && aIndex >= 0) - { - TDriveEntry driveEntry = iDriveEntryList->At(aIndex); - - TBuf<10> driveRoot; - driveRoot.Append(driveEntry.iLetter); - driveRoot.Append(_L(":")); - - // scan disk - TInt err = iFs.ScanDrive(driveRoot); - - if (err == KErrNone) - { - iEngine->FileBrowserUI()->ShowConfirmationNote(_L("Run succesfully")); - } - else if (err == KErrNotSupported) - { - iEngine->FileBrowserUI()->ShowErrorNote(_L("Not supported for this drive")); - } - else - { - CTextResolver* textResolver = CTextResolver::NewLC(*iEngine->EikonEnv()); - - iEngine->FileBrowserUI()->ShowErrorNote( - textResolver->ResolveErrorString(err, CTextResolver::ECtxNoCtxNoSeparator) ); - - CleanupStack::PopAndDestroy(); //textResolver - } - - RefreshViewL(); - } - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::GetDriveName(TInt aIndex, TFileName &aDriveName) - { - if (iDriveEntryList->Count() > aIndex && aIndex >= 0) - { - TDriveEntry driveEntry = iDriveEntryList->At(aIndex); - - // get existing drive name - iFs.GetDriveName(driveEntry.iNumber, aDriveName); - } - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::SetDriveNameL(TInt aIndex, const TFileName &aDriveName) - { - if (iDriveEntryList->Count() > aIndex && aIndex >= 0) - { - TDriveEntry driveEntry = iDriveEntryList->At(aIndex); - - // set drive name - TInt err = iFs.SetDriveName(driveEntry.iNumber, aDriveName); - - if (err == KErrNone) - { - iEngine->FileBrowserUI()->ShowConfirmationNote(_L("Name changed")); - } - else if (err == KErrNotSupported) - { - iEngine->FileBrowserUI()->ShowErrorNote(_L("Not supported for this drive")); - } - else - { - CTextResolver* textResolver = CTextResolver::NewLC(*iEngine->EikonEnv()); - - iEngine->FileBrowserUI()->ShowErrorNote( - textResolver->ResolveErrorString(err, CTextResolver::ECtxNoCtxNoSeparator) ); - - CleanupStack::PopAndDestroy(); //textResolver - } - - RefreshViewL(); - } - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::GetDriveVolumeLabel(TInt aIndex, TFileName &aVolumeLabel) - { - if (iDriveEntryList->Count() > aIndex && aIndex >= 0) - { - TDriveEntry driveEntry = iDriveEntryList->At(aIndex); - - // get existing volume label - aVolumeLabel.Copy(driveEntry.iVolumeInfo.iName); - } - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::SetDriveVolumeLabelL(TInt aIndex, const TFileName &aVolumeLabel) - { - if (iDriveEntryList->Count() > aIndex && aIndex >= 0) - { - TDriveEntry driveEntry = iDriveEntryList->At(aIndex); - - // set volume label - TInt err = iFs.SetVolumeLabel(aVolumeLabel, driveEntry.iNumber); - - if (err == KErrNone) - { - iEngine->FileBrowserUI()->ShowConfirmationNote(_L("Volume label changed")); - } - else if (err == KErrNotSupported) - { - iEngine->FileBrowserUI()->ShowErrorNote(_L("Not supported for this drive")); - } - else - { - CTextResolver* textResolver = CTextResolver::NewLC(*iEngine->EikonEnv()); - - iEngine->FileBrowserUI()->ShowErrorNote( - textResolver->ResolveErrorString(err, CTextResolver::ECtxNoCtxNoSeparator) ); - - CleanupStack::PopAndDestroy(); //textResolver - } - - RefreshViewL(); - } - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::EjectDriveL(TInt aIndex) - { - if (iDriveEntryList->Count() > aIndex && aIndex >= 0) - { - TDriveEntry driveEntry = iDriveEntryList->At(aIndex); - - TInt err(KErrNone); - - // get current filesystem name - TFileName fileSystemName; - err = iFs.FileSystemName(fileSystemName, driveEntry.iNumber); - - if (err == KErrNone) - { - // Prevent SysAp shutting down applications - RProperty::Set( - KPSUidCoreApplicationUIs, - KCoreAppUIsMmcRemovedWithoutEject, - ECoreAppUIsEjectCommandUsed ); - - // dismount the file system - err = iFs.DismountFileSystem(fileSystemName, driveEntry.iNumber); - - if (err == KErrNone) - { - // remount the file system - err = iFs.MountFileSystem(fileSystemName, driveEntry.iNumber); - - if (err == KErrInUse) - { - // try to remount after a while if locked - User::After(1000000); - err = iFs.MountFileSystem(fileSystemName, driveEntry.iNumber); - } - } - } - - if (err == KErrNone) - { - iEngine->FileBrowserUI()->ShowConfirmationNote(_L("Ejected succesfully")); - } - else if (err == KErrNotSupported) - { - iEngine->FileBrowserUI()->ShowErrorNote(_L("Not supported for this drive")); - } - else - { - CTextResolver* textResolver = CTextResolver::NewLC(*iEngine->EikonEnv()); - - iEngine->FileBrowserUI()->ShowErrorNote( - textResolver->ResolveErrorString(err, CTextResolver::ECtxNoCtxNoSeparator) ); - - CleanupStack::PopAndDestroy(); //textResolver - } - - RefreshViewL(); - } - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::DismountFileSystemL(TInt aIndex) - { - if (iDriveEntryList->Count() > aIndex && aIndex >= 0) - { - TDriveEntry driveEntry = iDriveEntryList->At(aIndex); - - TInt err(KErrNone); - - // get current filesystem name - TFileName fileSystemName; - err = iFs.FileSystemName(fileSystemName, driveEntry.iNumber); - - if (err == KErrNone) - { - // Prevent SysAp shutting down applications - RProperty::Set( - KPSUidCoreApplicationUIs, - KCoreAppUIsMmcRemovedWithoutEject, - ECoreAppUIsEjectCommandUsed ); - - // dismount the file system - err = iFs.DismountFileSystem(fileSystemName, driveEntry.iNumber); - } - - if (err == KErrNone) - { - iEngine->FileBrowserUI()->ShowConfirmationNote(_L("Dismounted succesfully")); - } - else if (err == KErrNotSupported) - { - iEngine->FileBrowserUI()->ShowErrorNote(_L("Not supported for this drive")); - } - else - { - CTextResolver* textResolver = CTextResolver::NewLC(*iEngine->EikonEnv()); - - iEngine->FileBrowserUI()->ShowErrorNote( - textResolver->ResolveErrorString(err, CTextResolver::ECtxNoCtxNoSeparator) ); - - CleanupStack::PopAndDestroy(); //textResolver - } - - RefreshViewL(); - } - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::ConvertCharsToPwd(const TDesC& aWord, TDes8& aConverted) const - { - aConverted.FillZ(aConverted.MaxLength()); - aConverted.Zero(); - - if (aWord.Length()) - { - aConverted.Copy( (TUint8*)(&aWord[0]), aWord.Size() ); - } - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::EditDataTypesL() - { - // TODO - /* - iEngine->FileListContainer()->SetScreenLayoutL(EDisplayModeNormal); - iEngine->FileListContainer()->SetNaviPaneTextL(KNullDesC); - - CFileBrowserDataTypesDlg* dlg = CFileBrowserDataTypesDlg::NewL(); - dlg->RunQueryLD(); - - iEngine->FileListContainer()->SetScreenLayoutL(iEngine->Settings().iDisplayMode); - iEngine->FileListContainer()->SetNaviPaneTextL(iCurrentPath); - */ - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::SecureBackupL(TInt aType) - { - TInt err(KErrNone); - TInt showStatus(EFalse); - - if (aType == EFileBrowserCmdToolsSecureBackupStartBackup || aType == EFileBrowserCmdToolsSecureBackupStartRestore) - { -// TInt queryIndexState(0); -// TInt queryIndexType(0); - -// CAknListQueryDialog* listQueryDlgState = new(ELeave) CAknListQueryDialog(&queryIndexState); -// if (listQueryDlgState->ExecuteLD(R_SECUREBACKUP_STATE_QUERY)) -// { -// -// CAknListQueryDialog* listQueryDlgType = new(ELeave) CAknListQueryDialog(&queryIndexType); -// if (listQueryDlgType->ExecuteLD(R_SECUREBACKUP_TYPE_QUERY)) -// { -// conn::TBURPartType partType = conn::EBURNormal; -// conn::TBackupIncType backupIncType = conn::ENoBackup; -// -// if (aType == EFileBrowserCmdToolsSecureBackupStartBackup) -// { -// if (queryIndexState == ESecureBackupStateFull) -// partType = conn::EBURBackupFull; -// else if (queryIndexState == ESecureBackupStatePartial) -// partType = conn::EBURBackupPartial; -// } -// else if (aType == EFileBrowserCmdToolsSecureBackupStartRestore) -// { -// if (queryIndexState == ESecureBackupStateFull) -// partType = conn::EBURRestoreFull; -// else if (queryIndexState == ESecureBackupStatePartial) -// partType = conn::EBURRestorePartial; -// } -// -// if (queryIndexType == ESecureBackupTypeBase) -// backupIncType = conn::EBackupBase; -// else if (queryIndexType == ESecureBackupTypeIncremental) -// backupIncType = conn::EBackupIncrement; -// -// // start secure backup -// err = iFileOps->ActivateSecureBackUp(partType, backupIncType); -// showStatus = ETrue; -// } -// } - } - - else if (aType == EFileBrowserCmdToolsSecureBackupStop) - { - err = iFileOps->DeActivateSecureBackUp(); - showStatus = ETrue; - } - - else - User::Panic(_L("Sec.br.mode"), 101); - - - if (showStatus) - { - if (err == KErrNone) - { - iEngine->FileBrowserUI()->ShowConfirmationNote(_L("Succeeded")); - } - else - { - CTextResolver* textResolver = CTextResolver::NewLC(*iEngine->EikonEnv()); - - iEngine->FileBrowserUI()->ShowErrorNote( - textResolver->ResolveErrorString(err, CTextResolver::ECtxNoCtxNoSeparator) ); - - CleanupStack::PopAndDestroy(); //textResolver - } - } - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFileUtils::OpenCommonFileActionQueryL(TInt aCurrentItemIndex) - { - // TODO - // just get current item -// TInt currentItemIndex = iEngine->QueryCurrentItemIndex(); - - if (iFileEntryList->Count() > aCurrentItemIndex && aCurrentItemIndex >= 0) - { -// TInt queryIndex(0); -// -// CAknListQueryDialog* listQueryDlg = new(ELeave) CAknListQueryDialog(&queryIndex); -// -// if (listQueryDlg->ExecuteLD(R_COMMON_FILE_ACTION_QUERY)) -// { -// if (queryIndex == ECommonFileActionViewAsTextHex) -// { -// TFileEntry fileEntry = iFileEntryList->At(aCurrentItemIndex); -// -// TFileName fullPath = fileEntry.iPath; -// fullPath.Append(fileEntry.iEntry.iName); -// -// TInt viewerType(EFileBrowserCmdFileViewHex); -// -// // check from mime type if it's text -// TDataType dataType; -// TUid appUid; -// if (iEngine->LsSession().AppForDocument(fullPath, appUid, dataType) == KErrNone) -// { -// TBuf<128> mimeTypeBuf; -// mimeTypeBuf.Copy(dataType.Des8()); -// if (mimeTypeBuf == KNullDesC) -// mimeTypeBuf.Copy(_L("N/A")); -// -// if (mimeTypeBuf.CompareF(_L("text/plain")) == 0) -// viewerType = EFileBrowserCmdFileViewText; -// } -// -// FileEditorL(viewerType); -// } -// -// else if (queryIndex == ECommonFileActionOpenWithApparc) -// { -// // TODO -// //OpenWithApparcL(); -// } -// -// else if (queryIndex == ECommonFileActionOpenWithDocHandlerEmbed) -// { -// // TODO -// //OpenWithDocHandlerL(ETrue); -// } -// -// else -// User::Panic(_L("Unk.Com.Act"), 221); -// } - } - } - -// -------------------------------------------------------------------------------------------- - -// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/engine/FBFileUtils.h --- a/filebrowser/engine/FBFileUtils.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,407 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef FILEBROWSER_FILEUTILS_H -#define FILEBROWSER_FILEUTILS_H - -// INCLUDES -#include -#include -#include -#include -#include -#include -#include -#include "FB.hrh" - -_LIT(KIRAppPath, "z:\\sys\\bin\\irapp.exe"); -_LIT(KBTAppPath, "z:\\sys\\bin\\btui.exe"); -_LIT(KUSBAppPath, "z:\\sys\\bin\\usbclasschangeui.exe"); -_LIT(KErrRdPath, "c:\\resource\\ErrRd"); -_LIT(KErrRdDir, "c:\\resource\\"); - - -// FORWARD DECLARATIONS -class CEngine; -class CFileBrowserFileOps; -class CDocumentHandler; -class CEikProgressInfo; -class CFBFileOpClient; -class CEikProgressInfo; -class CMessageDigest; - -// CLASS DECLARATIONS - -class TSearchAttributes - { -public: - TFileName iSearchDir; - TFileName iWildCards; - TFileName iTextInFile; - TUint iMinSize; - TUint iMaxSize; - TTime iMinDate; - TTime iMaxDate; - TBool iRecurse; - TBool iDefaultWildCard; - }; - -class TDriveEntry - { -public: - TChar iLetter; - TInt iNumber; - TVolumeInfo iVolumeInfo; - TBuf<64> iMediaTypeDesc; - TBuf<128> iAttributesDesc; - TInt iIconId; - }; - -class TFileEntry - { -public: - TFileName iFullName; - TFileName iPath; - TEntry iEntry; - TInt iDirEntries; - TInt iIconId; - }; - -class TAppIcon - { -public: - TInt iId; - TUid iUid; - }; - -typedef CArrayFixSeg CDriveEntryList; -typedef CArrayFixSeg CFileEntryList; -typedef CArrayFixSeg CAppIconList; - -class TSearchResults - { -public: - TInt iNumberOfFoundFiles; - //CFileEntryList iFoundFilesList; - }; - -class TOverwriteOptions - { -public: - TBool iDoFileOperations/*(ETrue)*/; - TInt iQueryIndex/*(0)*/; - TFileName iPostFix; - TInt iOverWriteFlags/* = CFileMan::EOverWrite*/; - }; - -class CCommandParamsBase : public CBase - { - }; - -class CCommandParamsAttribs : public CCommandParamsBase - { -public: - TFileEntry iSourceEntry; - TUint iSetMask; - TUint iClearMask; - TTime iTime; - TUint iSwitch; -public: - CCommandParamsAttribs(const TFileEntry& aSourceEntry, TUint aSetMask, TUint aClearMask, const TTime& aTime, TUint aSwitch) : iSourceEntry(aSourceEntry), iSetMask(aSetMask), iClearMask(aClearMask), iTime(aTime), iSwitch(aSwitch) {} - }; - -class CCommandParamsCopyOrMove : public CCommandParamsBase - { -public: - TFileEntry iSourceEntry; - TFileName iTargetPath; - TUint iSwitch; -public: - CCommandParamsCopyOrMove(const TFileEntry& aSourceEntry, const TDesC& aTargetPath, TUint aSwitch) : iSourceEntry(aSourceEntry), iTargetPath(aTargetPath), iSwitch(aSwitch) {} - }; - -class CCommandParamsRename : public CCommandParamsBase - { -public: - TFileEntry iSourceEntry; - TFileName iTargetPath; - TUint iSwitch; -public: - CCommandParamsRename(const TFileEntry& aSourceEntry, const TDesC& aTargetPath, TUint aSwitch) : iSourceEntry(aSourceEntry), iTargetPath(aTargetPath), iSwitch(aSwitch) {} - }; - -class CCommandParamsDelete : public CCommandParamsBase - { -public: - TFileEntry iSourceEntry; - TUint iSwitch; -public: - CCommandParamsDelete(const TFileEntry& aSourceEntry, TUint aSwitch) : iSourceEntry(aSourceEntry), iSwitch(aSwitch) {} - }; - -class CCommandParamsDriveSnapShot : public CCommandParamsBase - { -public: - TInt iSourceDriveLetter; - TInt iTargetDriveLetter; -public: - CCommandParamsDriveSnapShot(TChar aSourceDriveLetter, TChar aTargetDriveLetter) : iSourceDriveLetter(aSourceDriveLetter), iTargetDriveLetter(aTargetDriveLetter) {} - }; - -class TCommand - { -public: - TInt iCommandId; - CCommandParamsBase* iParameters; -public: - TCommand(TInt aCommandId, CCommandParamsBase* aParameters) : iCommandId(aCommandId), iParameters(aParameters) {} - }; - -typedef CArrayFixSeg CCommandArray; - - - -class CFileBrowserFileUtils : public CActive, public MMsvSessionObserver - { -private: - enum TState // active object states - { - EIdle = 0, // do nothing - }; - -// enum TClipBoardMode -// { -// EClipBoardModeCut = 0, -// EClipBoardModeCopy -// }; - -public: - static CFileBrowserFileUtils* NewL(CEngine* aEngine); - ~CFileBrowserFileUtils(); - -private: - CFileBrowserFileUtils(CEngine* aEngine); - void ConstructL(); - -private: // from CActive - void RunL(); - TInt RunError(TInt aError); - void DoCancel(); - -private: // from MMsvSessionObserver - void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3); - -public: //from MProgressDialogCallback - void DialogDismissedL(/*TInt aButtonId*/); - -public: // command handling - void StartExecutingCommandsL(const TDesC& aLabel); -private: // command handling - void ExecuteCommand(); - void CheckForMoreCommandsL(); - void AppendToCommandArrayL(TInt aCommand, CCommandParamsBase* aParameters); - TInt CommandArrayCount() const; - void ResetCommandArray(); - -private: // misc functionality - void GenerateDirectoryDataL(); - void GetDriveListL(); - void GetDirectoryListingL(); -// CAknIconArray* GenerateIconArrayL(TBool aGenerateNewBasicIconArray=EFalse); -// void AppendGulIconToIconArrayL(CAknIconArray* aIconArray, const TDesC& aIconFile, TInt aIconId, TInt aMaskId, const TAknsItemID aAknsItemId); - TInt AppIconIdForUid(TUid aUid); - TUid GetAppUid(TFileEntry aFileEntry); -// CDesCArray* GenerateItemTextArrayL(); -// TInt GetSelectedItemsOrCurrentItemL(CFileEntryList* aFileEntryList); - TInt SetSelectedItemsOrCurrentItemL(const CArrayFix* selectionIndexes, - CFileEntryList* aFileEntryList); - -// TBool IsDestinationEntriesExists(const CFileEntryList* aEntryList, const TDesC& aTargetDir); - void DoCopyToFolderL(CFileEntryList* aEntryList, const TDesC& aTargetDir, const TOverwriteOptions &aOverwriteOptions, TBool aDeleteSource); - TInt DoSearchFiles(const TDesC& aFileName, const TDesC& aPath); - TInt DoSearchFilesRecursiveL(const TDesC& aFileName, const TDesC& aPath); - TInt DoFindFiles(const TDesC& aFileName, const TDesC& aPath); - TInt DoFindFilesRecursiveL(const TDesC& aFileName, const TDesC& aPath); - void ReadAttachmentPathsRecursiveL(CMsvSession* aSession, CMsvEntry* aContext, CDesCArray* aAttPaths); - void WriteMessageEntryInfoRecursiveL(CMsvSession* aSession, CMsvEntry* aContext, RFile& aFile, TInt& aLevel); - void DoWriteMessageEntryInfoL(CMsvEntry* aContext, RFile& aFile, TInt aLevel); - void ConvertCharsToPwd(const TDesC& aWord, TDes8& aConverted) const; - HBufC8* MessageDigestInHexLC(CMessageDigest* aMD, RFile& aFile); - void OpenCommonFileActionQueryL(TInt aCurrentItemIndex); - -public: // public interfaces - TKeyResponse HandleOfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType); - void HandleSettingsChangeL(); - void SetSortModeL(TInt aSortMode); - void SetOrderModeL(TInt aOrderMode); - void RefreshViewL(); - TBool IsCurrentDriveReadOnly(); - TBool IsItemDirectory(TInt aCurrentItemIndex); - void MoveUpOneLevelL(); - void MoveDownToDirectoryL(TInt aIndex); - TInt ClipboardCutL(const CArrayFix* aSelectionIndices); - TInt ClipboardCopyL(const CArrayFix* aSelectionIndices); - void ClipboardPasteL(const TOverwriteOptions &aOverwriteOptions); - TInt SetCurrentSelection(const CArrayFix* aSelectionIndices); - void CopyToFolderL(TFileName aTargetDir, const TOverwriteOptions &aOverwriteOptions, TBool aMove=EFalse); - void DeleteL(); - TBool SelectionHasDirs(); - void TouchL(TBool aRecurse); - void RenameL(const TInt aIndex, const TFileName &newName); - void SetAttributesL(TUint &aSetAttMask, TUint &aClearAttMask, TBool &aRecurse); - void SearchL(); - void NewFileL(const TFileName &aNewFileName); - void NewDirectoryL(const TFileName &aNewDirectoryName); - void SendToL(); - void CompressL(); - void DecompressL(); - bool PropertiesL(TInt currentItemIndex, CDesCArray* entryLines, TFileName &titleText); - void OpenWithApparcL(TFileName aFileName); - void OpenWithDocHandlerL(TFileName aFileName, TBool aEmbed); - void OpenWithFileServiceL(TInt aCurrentItemIndex); - TBool FileExists(const TDesC& aPath); - TInt LaunchProgramL(const TDesC& aPath); - void MemoryInfoPopupL(); - void ShowFileCheckSumsL(TInt aCurrentItemIndex, TInt aType); - void SetErrRdL(TBool aEnable); -// void EnableAvkonIconCacheL(TBool aEnable); - void SimulateLeaveL(TInt aLeaveCode); - void SimulatePanicL(const TDesC& aPanicCategory, TInt aPanicCode); - void SimulateExceptionL(TInt aExceptionCode); - TUint32 GetDebugMask(); - void SetDebugMaskL(TUint32 aDbgMask); - void WriteAllAppsL(); - void WriteAllFilesL(); - void ListOpenFilesL(); - void ListMessageAttachmentsL(TInt aType); - void WriteMsgStoreWalkL(); - void FileEditorL(TInt aCurrentItemIndex, TInt aType); - void SetDrivePasswordL(TInt aIndex, const TFileName &aOldPassword, const TFileName &aNewPassword); - void UnlockDriveL(TInt aIndex, const TFileName &aOldPassword); - void ClearDrivePasswordL(TInt aIndex, const TFileName &aOldPassword); - void EraseDrivePasswordL(TInt aIndex); - void FormatDriveL(TInt aIndex, TBool aQuickFormat); - void CheckDiskL(TInt aIndex); - void ScanDriveL(TInt aIndex); - void SetDriveNameL(TInt aIndex, const TFileName &aDriveName); - void SetDriveVolumeLabelL(TInt aIndex, const TFileName &aVolumeLabel); - void EjectDriveL(TInt aIndex); - void DismountFileSystemL(TInt aIndex); - void EraseMBRL(TInt aIndex); - void PartitionDriveL(TInt aIndex, TBool aEraseMBR, TInt aAmountOfPartitions); - TBool DriveSnapShotPossible(); - void DriveSnapShotL(); - void EditDataTypesL(); - void SecureBackupL(TInt aType); - - TBool IsDestinationEntriesExists(const TDesC& aTargetDir); - TBool TargetExists(const TInt aIndex, const TFileName &newName); - void GetDriveName(TInt aIndex, TFileName &aDriveName); - void GetDriveVolumeLabel(TInt aIndex, TFileName &aVolumeLabel); - - CFileEntryList* FileEntries() const; - CDriveEntryList* DriveEntries() const; - -public: - inline TInt SortMode() { return iSortMode; } - inline TInt OrderMode() { return iOrderMode; } - inline CFileEntryList* ClipBoardList() { return iClipBoardList; } - inline CFileEntryList* CurrentSelectionList() { return iCurrentSelectionList; } - inline TBool IsDriveListViewActive() { return iCurrentPath==KNullDesC && iListingMode==ENormalEntries; } - inline TBool IsNormalModeActive() { return iListingMode==ENormalEntries; } - inline TListingMode ListingMode() { return iListingMode; } - inline TFileName CurrentPath() { return iCurrentPath; } - - inline TSearchAttributes GetSearchAttributes(){ return iSearchAttributes; }; - inline void ChangeAttributes(TSearchAttributes attributes) { iSearchAttributes = attributes; }; - inline TSearchResults SearchResults(){ return iFileSearchResults; }; - inline CFileEntryList* FoundFiles() { return iFileEntryList; }; - inline void SetAllowProcessing(TBool aAllowProcessing) { iAllowProcessing = aAllowProcessing; } - TClipBoardMode GetClipBoardMode() { return iClipBoardMode; } - -private: - TState iState; - CEngine* iEngine; - CFileBrowserFileOps* iFileOps; - - TBool isWaitDialog; - TBool isProgressDialog; - - //CEikProgressInfo* iProgressInfo; - CCommandArray* iCommandArray; - TInt iCurrentEntry; - TInt iSucceededOperations; - TInt iFailedOperations; - TInt iLastError; - RTimer iTimer; - RFs iFs; - TListingMode iListingMode; - CFileMan* iFileMan; - TInt iViewMode; - TFileName iCurrentPath; - TInt iSortMode; - TInt iOrderMode; -// TInt iClipboardMode; - CDesCArray* iClipboardPaths; - CDriveEntryList* iDriveEntryList; - CFileEntryList* iFileEntryList; - CFileEntryList* iFindFileEntryList; - CAppIconList* iAppIconList; - TClipBoardMode iClipBoardMode; - CFileEntryList* iClipBoardList; - CFileEntryList* iCurrentSelectionList; - TSearchAttributes iSearchAttributes; - CDocumentHandler* iDocHandler; - - RFile iMsgStoreWalkFile; - TInt iPrevFolderIndex; - TFileName iPrevFolderName; - RTz iTz; - TSearchResults iFileSearchResults; - CDesCArray* iTextArray; - TBool iAllowProcessing; - }; - - -// utility class for waiting for asychronous requests -class CAsyncWaiter : public CActive - { -public: - static CAsyncWaiter* NewL( TInt aPriority = EPriorityStandard ); - static CAsyncWaiter* NewLC( TInt aPriority = EPriorityStandard ); - ~CAsyncWaiter(); - - void StartAndWait(); - TInt Result() const; - -private: - CAsyncWaiter( TInt aPriority ); - - // from CActive - void RunL(); - void DoCancel(); - -private: - CActiveSchedulerWait iWait; - TInt iError; - }; - - -#endif - -// End of File - diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/engine/FBFolderSelector.cpp --- a/filebrowser/engine/FBFolderSelector.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,622 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include "FBFolderSelector.h" -#include "FBFileUtils.h" -#include "FB.hrh" -#include "FBStd.h" - -#if (!defined __SERIES60_30__ && !defined __SERIES60_31__) -#include -#endif // !defined __SERIES60_30__ && !defined __SERIES60_31__ - -// ===================================== MEMBER FUNCTIONS ===================================== - -CFileBrowserFolderSelector *CFileBrowserFolderSelector::NewL( - TDes& aReturnPath, - MFolderSelectorUI *aFolderSelectorUI) - { - CFileBrowserFolderSelector* self = new(ELeave) CFileBrowserFolderSelector(aReturnPath, - aFolderSelectorUI); - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(self); - return self; - } - -// -------------------------------------------------------------------------------------------- - -CFileBrowserFolderSelector::~CFileBrowserFolderSelector() - { - delete iFileEntryList; - delete iDriveEntryList; - - iFs.Close(); - - //iEikonEnv->InfoMsgCancel(); - } - -// -------------------------------------------------------------------------------------------- - -CFileBrowserFolderSelector::CFileBrowserFolderSelector(TDes& aReturnPath, MFolderSelectorUI *aFolderSelectorUI) : - iReturnPath(aReturnPath), - iFolderSelectorUI(aFolderSelectorUI) - { - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFolderSelector::ConstructL() - { - User::LeaveIfError( iFs.Connect() ); - iDriveEntryList = new(ELeave) CDriveEntryList(8); - iFileEntryList = new(ELeave) CFileEntryList(32); - iCurrentPath = KNullDesC; - - //iIsDragging = EFalse; - //EnableDragEvents(); - - // get only writeable drives - GetDriveListL(); - } - -// -------------------------------------------------------------------------------------------- - -/* -void CFileBrowserFolderSelector::HandlePointerEventL(const TPointerEvent &aPointerEvent) - { - // detect direction of dragging by comparing the start and finish points - - if (aPointerEvent.iType == TPointerEvent::EButton1Down) - { - iDragStartPoint = aPointerEvent.iPosition; - iIsDragging = EFalse; - } - else if (aPointerEvent.iType == TPointerEvent::EDrag) - { - iIsDragging = ETrue; - - return; - } - else if (aPointerEvent.iType == TPointerEvent::EButton1Up) - { - if (iIsDragging) - { - const TInt KDelta = iDragStartPoint.iX - aPointerEvent.iPosition.iX; - const TInt KThreshold = 30; - - if (KDelta < -KThreshold) // dragging to right - { - // "emulate" right key press - - TKeyEvent keyEvent; - keyEvent.iCode = EKeyRightArrow; - keyEvent.iModifiers = 0; - - TEventCode type = EEventKey; - - OfferKeyEventL(keyEvent, type); - - return; - } - else if (KDelta > KThreshold) // dragging to left - { - // "emulate" left key press - - TKeyEvent keyEvent; - keyEvent.iCode = EKeyLeftArrow; - keyEvent.iModifiers = 0; - - TEventCode type = EEventKey; - - OfferKeyEventL(keyEvent, type); - - return; - } - } - iIsDragging = EFalse; - } - else - { - iIsDragging = EFalse; - } - - CAknListQueryDialog::HandlePointerEventL(aPointerEvent); - } -*/ - -// -------------------------------------------------------------------------------------------- - -TKeyResponse CFileBrowserFolderSelector::OfferKeyEventL(const TKeyEvent& /*aKeyEvent*/, TEventCode /*aType*/) - { -// if(aType != EEventKey) -// return EKeyWasNotConsumed; - -// if (aKeyEvent.iCode == EKeyLeftArrow && !IsDriveListViewActive()) -// { -// MoveUpOneLevelL(); -// return EKeyWasConsumed; -// } -// else if (aKeyEvent.iCode == EKeyRightArrow && ((ListBox()->CurrentItemIndex() > 0 && !IsDriveListViewActive()) || IsDriveListViewActive())) -// { -// MoveDownToDirectoryL(); -// return EKeyWasConsumed; -// } -// else if (aKeyEvent.iCode == EKeyOK || aKeyEvent.iCode == EKeyEnter) -// { -// if (IsDriveListViewActive()) -// { -// MoveDownToDirectoryL(); -// return EKeyWasConsumed; -// } -// else if (ListBox()->CurrentItemIndex() == 0) -// { -// TryExitL(EAknSoftkeyOk); -// return EKeyWasConsumed; -// } -// else if (ListBox()->CurrentItemIndex() > 0) -// { -// MoveDownToDirectoryL(); -// return EKeyWasConsumed; -// } -// } -// -// TKeyResponse result = CAknDialog::OfferKeyEventL(aKeyEvent, aType); -// -// // update LSK label -// if (!IsDriveListViewActive()) -// { -// if (ListBox()->CurrentItemIndex() == 0) -// { -// ButtonGroupContainer().SetCommandL(0, EAknSoftkeyOk, iLSKActionText); -// ButtonGroupContainer().DrawNow(); -// } -// else -// { -// ButtonGroupContainer().SetCommandL(0, EAknSoftkeyOk, _L("Open dir")); -// ButtonGroupContainer().DrawNow(); -// } -// } -// -// return result; - return TKeyResponse(); - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFolderSelector::PreLayoutDynInitL() - { -// CAknListQueryDialog::PreLayoutDynInitL(); - -// static_cast(ListBox())->ItemDrawer()->ColumnData()->EnableMarqueeL(ETrue); - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFolderSelector::PostLayoutDynInitL() - { -// CAknListQueryDialog::PostLayoutDynInitL(); - - //w SetIconArrayL(static_cast*>(iIconArray)); - - RefreshViewL(); - } - -// -------------------------------------------------------------------------------------------- - -TBool CFileBrowserFolderSelector::OkToExitL(TInt /*aButtonId*/) - { -// if (aButtonId == GetLeftCBAShortKeyPress()) -// { -// if (IsDriveListViewActive()) -// { -// MoveDownToDirectoryL(); -// return EFalse; -// } -// else if (ListBox()->CurrentItemIndex() == 0) -// { -// // close the dialog -// iReturnPath = iCurrentPath; -// return ETrue; -// } -// else if (ListBox()->CurrentItemIndex() > 0) -// { -// MoveDownToDirectoryL(); -// return EFalse; -// } -// else -// return EFalse; -// } -// else if (aButtonId == GetRightCBAShortKeyPress()) -// { -// return ETrue; -// } -// else -// { -// return EFalse; -// } - return ETrue; - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFolderSelector::MoveUpOneLevelL() - { - if (iCurrentPath.Length() <= 3) - { - // move to drive list view is the current path is already short enough - iCurrentPath = KNullDesC; - } - else - { - // move one directory up - TInt marker(iCurrentPath.Length()); - - // find second last dir marker - for (TInt i=iCurrentPath.Length()-2; i>=0; i--) - { - if (iCurrentPath[i] == '\\') - { - marker = i; - break; - } - - } - iCurrentPath = iCurrentPath.LeftTPtr(marker+1); - } - - // update view - RefreshViewL(); - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFolderSelector::MoveDownToDirectoryL(TInt index) - { - if (index >= 0) - { - if (IsDriveListViewActive()) - { - // currently in a drive list view, move to root of selected drive - if (iDriveEntryList->Count() > index) - { - TDriveEntry driveEntry = iDriveEntryList->At(index); - - iCurrentPath.Append(driveEntry.iLetter); - iCurrentPath.Append(_L(":\\")); - } - } - else - { - // this needed because we have an extra item in the listbox - index--; - - // append the new directory - if (iFileEntryList->Count() > index) - { - TFileEntry fileEntry = iFileEntryList->At(index); - - if (fileEntry.iEntry.IsDir()) - { - iCurrentPath.Append(fileEntry.iEntry.iName); - iCurrentPath.Append(_L("\\")); - } - } - } - - // update view - RefreshViewL(); - } - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFolderSelector::RefreshViewL() - { - if (IsDriveListViewActive()) - { - GetDriveListL(); - } - else - { - GetFileListL(); - } - iFolderSelectorUI->InformFolderSelectionChanged(); - - // TODO -// if (iCurrentPath == KNullDesC) -// iEikonEnv->InfoMsgWithDuration(_L("<- up dir down dir ->"), TTimeIntervalMicroSeconds32(KMaxTInt)); -// else -// iEikonEnv->InfoMsgWithDuration(iCurrentPath, TTimeIntervalMicroSeconds32(KMaxTInt)); - -// SetItemTextArray(textArray); -// SetOwnershipType(ELbmOwnsItemArray); -// ListBox()->HandleItemAdditionL(); -// Layout(); -// ListBox()->SetCurrentItemIndex(0); -// DrawDeferred(); - } - -// -------------------------------------------------------------------------------------------- - -//TBool CFileBrowserFolderSelector::RunCopyDlgLD() -// { -// iLSKActionText.Copy(_L("Copy")); -// return ExecuteLD(1/*R_COPY_TO_FOLDER_SELECTION_QUERY*/); -// } - -//// -------------------------------------------------------------------------------------------- - -//TBool CFileBrowserFolderSelector::RunMoveDlgLD() -// { -// iLSKActionText.Copy(_L("Move")); -// return ExecuteLD(1/*R_MOVE_TO_FOLDER_SELECTION_QUERY*/); -// } - -//// -------------------------------------------------------------------------------------------- - -//TInt CAknQueryDialog::GetLeftCBAShortKeyPress() -// { -// return TInt16(0xffff & TInt16(ButtonGroupContainer().ButtonGroup()->CommandId(0))); -// } - -//// -------------------------------------------------------------------------------------------- - -//TInt CAknQueryDialog::GetRightCBAShortKeyPress() -// { -// return TInt16(0xffff & TInt16(ButtonGroupContainer().ButtonGroup()->CommandId(2))); -// } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFolderSelector::GetDriveListL() - { - TDriveList driveList; - - // get drive listing depending of the support for network drives - if (true/*TODO iEngine->Settings().iSupportNetworkDrives*/) - { - #ifndef __SERIES60_30__ - #ifndef __SERIES60_31__ - User::LeaveIfError(iFs.DriveList(driveList, KDriveAttAll)); - #endif - #else - User::LeaveIfError(iFs.DriveList(driveList)); - #endif - } - else - { - User::LeaveIfError(iFs.DriveList(driveList)); - } - - iDriveEntryList->Reset(); - - //TDriveEntry driveEntry; - for (TInt i=0; iCount(); -// } - - if (driveEntry.iVolumeInfo.iDrive.iMediaAtt != KMediaAttWriteProtected - && driveEntry.iVolumeInfo.iDrive.iMediaAtt != KMediaAttLocked - && driveEntry.iVolumeInfo.iDrive.iDriveAtt != KDriveAbsent) - { - iDriveEntryList->AppendL(driveEntry); - } - } - } - } - -void CFileBrowserFolderSelector::GetFileListL() - { - iFileEntryList->Reset(); - - CDir* dir = NULL; - if (iFs.GetDir(iCurrentPath, KEntryAttDir|KEntryAttMatchMask, ESortByName | EAscending | EDirsFirst, dir) == KErrNone) - { - CleanupStack::PushL(dir); - - for (TInt i=0; iCount(); i++) - { - TFileEntry fileEntry; - fileEntry.iPath = iCurrentPath; - fileEntry.iEntry = (*dir)[i]; - fileEntry.iDirEntries = KErrNotFound; - fileEntry.iIconId = EFixedIconEmpty; - - // check for directory entries - if (fileEntry.iEntry.IsDir()) - { - fileEntry.iIconId = EFixedIconFolder; - - TFileName subPath = fileEntry.iPath; - subPath.Append(fileEntry.iEntry.iName); - subPath.Append(_L("\\")); - - // check if any sub directories - CDir* subDir = NULL; - if (iFs.GetDir(subPath, KEntryAttDir|KEntryAttMatchMask, ESortNone | EDirsFirst, subDir) == KErrNone) - { - fileEntry.iDirEntries = subDir->Count(); - - for (TInt j=0; jCount(); j++) - { - TEntry entry = (*subDir)[j]; - - if (entry.IsDir()) - { - fileEntry.iIconId = EFixedIconFolderSub; - break; - } - } - - delete subDir; - } - iFileEntryList->AppendL(fileEntry); - } - } - - CleanupStack::PopAndDestroy(); //dir - } - } - -// -------------------------------------------------------------------------------------------- - -// End of File - diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/engine/FBFolderSelector.h --- a/filebrowser/engine/FBFolderSelector.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,93 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef FILEBROWSER_FILEDLGS_H -#define FILEBROWSER_FILEDLGS_H - -#include "FBFileUtils.h" - -#include -#include -#include -#include - -/** - * Interface to communicate UI with - */ -class MFolderSelectorUI -{ -public: - /** - * Shows info message with text -// * @param A aText text to be shown in message body. -// * @param A aTitle text to be shown in message title. - * @return None. - */ - virtual void InformFolderSelectionChanged() = 0; -}; - -/** - * Backend class for destination folder selection dialog - */ -class CFileBrowserFolderSelector - { -public: - static CFileBrowserFolderSelector *NewL(TDes& aReturnPath, MFolderSelectorUI *); - virtual ~CFileBrowserFolderSelector(); - - inline TFileName CurrentPath() const { return iCurrentPath; } - inline TBool IsDriveListViewActive() const { return iCurrentPath==KNullDesC; } - inline const CDriveEntryList *DriveEntryList() { return iDriveEntryList; } - inline const CFileEntryList *FileEntryList() {return iFileEntryList; } - - void MoveDownToDirectoryL(TInt index); - void MoveUpOneLevelL(); - -private: // Constructors - CFileBrowserFolderSelector(TDes& aReturnPath, MFolderSelectorUI *); - void ConstructL(); - -protected: // From CEikDialog - TKeyResponse OfferKeyEventL(const TKeyEvent &aKeyEvent, TEventCode aType); - void PreLayoutDynInitL(); - void PostLayoutDynInitL(); - TBool OkToExitL(TInt aButtonId); - -protected: // From CCoeControl - //void HandlePointerEventL(const TPointerEvent &aPointerEvent); - -private: // New methods - void RefreshViewL(); - - void GetDriveListL(); - void GetFileListL(); - -private: // Data - TInt iSelectedIndex; - TBuf<16> iLSKActionText; - TDes &iReturnPath; - RFs iFs; - CDriveEntryList *iDriveEntryList; - CFileEntryList *iFileEntryList; - TFileName iCurrentPath; - MFolderSelectorUI *iFolderSelectorUI; - }; - -#endif - -// End of File - diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/engine/FBStd.h --- a/filebrowser/engine/FBStd.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef FILEBROWSER_STD_H -#define FILEBROWSER_STD_H - -#include -#include -#include - -LOCAL_C inline TBool IsQHD(const TSize& aSize) { return ((aSize.iWidth==640 && aSize.iHeight==360) || (aSize.iWidth==360 && aSize.iHeight==640)); } - -#endif - -// End of File - diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/engine/FBTraces.h --- a/filebrowser/engine/FBTraces.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,102 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef FILEBROWSER_TRACES_H -#define FILEBROWSER_TRACES_H - -#include - - -// --------------------------------------------------------------------------- -// You can change these logging method values below! Recompile the application to take changes effect. - - // logging methods - // 0 = No logging - // 1 = Flogger - // 2 = RDebug - // 3 = Flogger and RDebug - - #ifndef _DEBUG - - // Logging method for UREL/release builds: - #define FILEBROWSER_LOGGING_METHOD 0 - - #else - - // Logging method for UDEB/debug builds: - #define FILEBROWSER_LOGGING_METHOD 2 - - #endif - - - -// --------------------------------------------------------------------------- -// Do not make any changes to lines below... - - #if FILEBROWSER_LOGGING_METHOD == 1 || FILEBROWSER_LOGGING_METHOD == 3 - - #include - _LIT(KLogFolder,"Launcher"); - _LIT(KLogFile,"Launcher_Trace.txt"); - - #endif - - #if FILEBROWSER_LOGGING_METHOD == 2 || FILEBROWSER_LOGGING_METHOD == 3 - - #include - - #endif - - - #if FILEBROWSER_LOGGING_METHOD == 0 - - #define LOGTEXT(AAA) - #define LOGSTRING(AAA) - #define LOGSTRING2(AAA,BBB) - #define LOGSTRING3(AAA,BBB,CCC) - #define LOGSTRING4(AAA,BBB,CCC,DDD) - - - #elif FILEBROWSER_LOGGING_METHOD == 1 - - #define LOGTEXT(AAA) RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend, AAA) - #define LOGSTRING(AAA) do { _LIT(tempLogDes,AAA); RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend,tempLogDes()); } while (0) - #define LOGSTRING2(AAA,BBB) do { _LIT(tempLogDes,AAA); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB); } while (0) - #define LOGSTRING3(AAA,BBB,CCC) do { _LIT(tempLogDes,AAA); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB,CCC); } while (0) - #define LOGSTRING4(AAA,BBB,CCC,DDD) do { _LIT(tempLogDes,AAA); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB,CCC,DDD); } while (0) - - #elif FILEBROWSER_LOGGING_METHOD == 2 - - #define LOGTEXT(AAA) RDebug::Print(AAA) - #define LOGSTRING(AAA) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes); } while (0) - #define LOGSTRING2(AAA,BBB) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB); } while (0) - #define LOGSTRING3(AAA,BBB,CCC) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC); } while (0) - #define LOGSTRING4(AAA,BBB,CCC,DDD) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC, DDD); } while (0) - - #elif FILEBROWSER_LOGGING_METHOD == 3 - - #define LOGTEXT(AAA) RDebug::Print(AAA); RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend, AAA) - #define LOGSTRING(AAA) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes); RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend,tempLogDes()); } while (0) - #define LOGSTRING2(AAA,BBB) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB); } while (0) - #define LOGSTRING3(AAA,BBB,CCC) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB,CCC); } while (0) - #define LOGSTRING4(AAA,BBB,CCC,DDD) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC, DDD); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB,CCC,DDD); } while (0) - - #endif - -// --------------------------------------------------------------------------- - -#endif diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/engine/engine.cpp --- a/filebrowser/engine/engine.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,427 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -// INCLUDE FILES - -#include "engine.h" - -//#include "FBApp.h" -#include "FB.hrh" -#include "FBFileUtils.h" -#include "FBStd.h" -//#include - -#include -#include -#include -#include -#include - -// CONSTANTS -// UID of the application -const TUid KUidFileBrowser = { 0x102828D6 }; - -const TInt KSettingsDrive = EDriveC; -_LIT(KSettingsFileName, "filebrowser_settings.ini"); - -// ===================================== MEMBER FUNCTIONS ===================================== - -CEngine* CEngine::NewL(MFileBrowserUI *aFileBrowserUI) - { - CEngine* self = new(ELeave) CEngine; - CleanupStack::PushL(self); - self->ConstructL(aFileBrowserUI); - CleanupStack::Pop(); - return self; - } - -// -------------------------------------------------------------------------------------------- - -CEngine::CEngine() - : iFileUtils(NULL) - { - } - -// -------------------------------------------------------------------------------------------- - -void CEngine::ConstructL(MFileBrowserUI *aFileBrowserUI) - { - iFileBrowserUI = aFileBrowserUI; - iEnv = CEikonEnv::Static(); - User::LeaveIfError(iLs.Connect()); - } - -// -------------------------------------------------------------------------------------------- - -CEngine::~CEngine() - { - if (iFileUtils != NULL) - delete iFileUtils; - - iLs.Close(); - } - -// --------------------------------------------------------------------------- - -void CEngine::ActivateEngineL() - { - TRAP_IGNORE( LoadSettingsL() ); - - iFileUtils = CFileBrowserFileUtils::NewL(this); - } - -// --------------------------------------------------------------------------- - -void CEngine::DeActivateEngineL() - { - } - -// --------------------------------------------------------------------------- - -void CEngine::LoadDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, TInt& aValue) - { - if (aDicFS->IsPresentL(aUid)) - { - RDictionaryReadStream in; - in.OpenLC(*aDicFS, aUid); - aValue = in.ReadInt16L(); - CleanupStack::PopAndDestroy(); // in - } - } - -// --------------------------------------------------------------------------- - -void CEngine::LoadDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, TDes& aValue) - { - if (aDicFS->IsPresentL(aUid)) - { - RDictionaryReadStream in; - in.OpenLC(*aDicFS, aUid); - TInt bufLength = in.ReadInt16L(); // get length of descriptor - in.ReadL(aValue, bufLength); // get the descriptor itself - CleanupStack::PopAndDestroy(); // in - } - } - -// --------------------------------------------------------------------------- - -void CEngine::SaveDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, const TInt& aValue) - { - RDictionaryWriteStream out; - out.AssignLC(*aDicFS, aUid); - out.WriteInt16L(aValue); - out.CommitL(); - CleanupStack::PopAndDestroy(1);// out - } - -// --------------------------------------------------------------------------- - -void CEngine::SaveDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, const TDes& aValue) - { - RDictionaryWriteStream out; - out.AssignLC(*aDicFS, aUid); - out.WriteInt16L(aValue.Length()); // write length of the descriptor - out.WriteL(aValue, aValue.Length()); // write the descriptor itself - out.CommitL(); - CleanupStack::PopAndDestroy(1);// out - } - -// -------------------------------------------------------------------------------------------- - -void CEngine::LoadSettingsL() - { - const TSize screenSize = iEnv->ScreenDevice()->SizeInPixels(); - - // set defaults - iSettings.iDisplayMode = EDisplayModeFullScreen; - iSettings.iFileViewMode = IsQHD(screenSize) ? EFileViewModeExtended : EFileViewModeSimple; - iSettings.iShowSubDirectoryInfo = EFalse; - iSettings.iShowAssociatedIcons = EFalse; - iSettings.iRememberLastPath = EFalse; - iSettings.iLastPath = KNullDesC; - iSettings.iRememberFolderSelection = ETrue; -//#if 0 // TODO -//#if(!defined __SERIES60_30__ && !defined __SERIES60_31__ && !defined __S60_32__) -// if ( AknLayoutUtils::PenEnabled() ) -// { -// iSettings.iEnableToolbar = ETrue; -// } -// else -// { -// iSettings.iEnableToolbar = EFalse; -// } -//#else -// iSettings.iEnableToolbar = EFalse; -//#endif -//#endif // TODO - - iSettings.iSupportNetworkDrives = EFalse; - iSettings.iBypassPlatformSecurity = EFalse; - iSettings.iRemoveFileLocks = ETrue; - iSettings.iIgnoreProtectionsAtts = ETrue; - iSettings.iRemoveROMWriteProrection = ETrue; - - // build specific defaults -#if(!defined __SERIES60_30__ && !defined __SERIES60_31__) - iSettings.iSupportNetworkDrives = ETrue; -#endif - - - // make sure that the private path of this app in c-drive exists - iEnv->FsSession().CreatePrivatePath( KSettingsDrive ); // c:\\private\\102828d6\\ - - // handle settings always in the private directory - if (iEnv->FsSession().SetSessionToPrivate( KSettingsDrive ) == KErrNone) - { - // open or create a dictionary file store - CDictionaryFileStore* settingsStore = CDictionaryFileStore::OpenLC(iEnv->FsSession(), KSettingsFileName, KUidFileBrowser); - - LoadDFSValueL(settingsStore, KFBSettingDisplayMode, iSettings.iDisplayMode); - LoadDFSValueL(settingsStore, KFBSettingFileViewMode, iSettings.iFileViewMode); - LoadDFSValueL(settingsStore, KFBSettingShowSubDirectoryInfo, iSettings.iShowSubDirectoryInfo); - LoadDFSValueL(settingsStore, KFBSettingShowAssociatedIcons, iSettings.iShowAssociatedIcons); - LoadDFSValueL(settingsStore, KFBSettingRememberLastPath, iSettings.iRememberLastPath); - LoadDFSValueL(settingsStore, KFBSettingLastPath, iSettings.iLastPath); - LoadDFSValueL(settingsStore, KFBSettingFolderSelection, iSettings.iRememberFolderSelection); - LoadDFSValueL(settingsStore, KFBSettingEnableToolbar, iSettings.iEnableToolbar); - - LoadDFSValueL(settingsStore, KFBSettingSupportNetworkDrives, iSettings.iSupportNetworkDrives); - LoadDFSValueL(settingsStore, KFBSettingBypassPlatformSecurity, iSettings.iBypassPlatformSecurity); - LoadDFSValueL(settingsStore, KFBSettingRemoveFileLocks, iSettings.iRemoveFileLocks); - LoadDFSValueL(settingsStore, KFBSettingIgnoreProtectionsAtts, iSettings.iIgnoreProtectionsAtts); - LoadDFSValueL(settingsStore, KFBSettingRemoveROMWriteProtection, iSettings.iRemoveROMWriteProrection); - - CleanupStack::PopAndDestroy(); // settingsStore - } - } - -// -------------------------------------------------------------------------------------------- - -void CEngine::SaveSettingsL(TBool aNotifyModules) - { - // handle settings always in c:\\private\\102828d6\\ - if (iEnv->FsSession().SetSessionToPrivate( KSettingsDrive ) == KErrNone) - { - // delete existing store to make sure that it is clean and not eg corrupted - if (BaflUtils::FileExists(iEnv->FsSession(), KSettingsFileName)) - { - iEnv->FsSession().Delete(KSettingsFileName); - } - - // create a dictionary file store - CDictionaryFileStore* settingsStore = CDictionaryFileStore::OpenLC(iEnv->FsSession(), KSettingsFileName, KUidFileBrowser); - - SaveDFSValueL(settingsStore, KFBSettingDisplayMode, iSettings.iDisplayMode); - SaveDFSValueL(settingsStore, KFBSettingFileViewMode, iSettings.iFileViewMode); - SaveDFSValueL(settingsStore, KFBSettingShowSubDirectoryInfo, iSettings.iShowSubDirectoryInfo); - SaveDFSValueL(settingsStore, KFBSettingShowAssociatedIcons, iSettings.iShowAssociatedIcons); - SaveDFSValueL(settingsStore, KFBSettingRememberLastPath, iSettings.iRememberLastPath); - SaveDFSValueL(settingsStore, KFBSettingLastPath, iSettings.iLastPath); - SaveDFSValueL(settingsStore, KFBSettingFolderSelection, iSettings.iRememberFolderSelection); - SaveDFSValueL(settingsStore, KFBSettingEnableToolbar, iSettings.iEnableToolbar); - - SaveDFSValueL(settingsStore, KFBSettingSupportNetworkDrives, iSettings.iSupportNetworkDrives); - SaveDFSValueL(settingsStore, KFBSettingBypassPlatformSecurity, iSettings.iBypassPlatformSecurity); - SaveDFSValueL(settingsStore, KFBSettingRemoveFileLocks, iSettings.iRemoveFileLocks); - SaveDFSValueL(settingsStore, KFBSettingIgnoreProtectionsAtts, iSettings.iIgnoreProtectionsAtts); - SaveDFSValueL(settingsStore, KFBSettingRemoveROMWriteProtection, iSettings.iRemoveROMWriteProrection); - - settingsStore->CommitL(); - CleanupStack::PopAndDestroy(); // settingsStore - } - - // update changes to modules - if (aNotifyModules) - { - //iScreenCapture->HandleSettingsChangeL(); - if (iFileUtils != NULL) - { - iFileUtils->HandleSettingsChangeL(); - } - //iFileListContainer->HandleSettingsChangeL(); - } - } - -// -------------------------------------------------------------------------------------------- - -TInt CEngine::LaunchSettingsDialogL() - { - TInt retValue = KErrNone; - // TODO: - // set to normal mode - //iFileListContainer->SetScreenLayoutL(EDisplayModeNormal); - //iFileListContainer->DeleteNaviPane(); - //iFileListContainer->HideToolbar(); - - // launch the dialog and save settings - //CFileBrowserSettingViewDlg* dlg = CFileBrowserSettingViewDlg::NewL(iSettings); - //TInt retValue = dlg->ExecuteLD(R_FILEBROWSER_SETTINGS_DIALOG); - //FileListContainer()->CreateEmptyNaviPaneLabelL(); - TRAP_IGNORE(SaveSettingsL()); - return retValue; - } - -// -------------------------------------------------------------------------------------------- -// -------------------------------------------------------------------------------------------- - -CAsyncWaiter* CAsyncWaiter::NewL(TInt aPriority) - { - CAsyncWaiter* self = new(ELeave) CAsyncWaiter(aPriority); - return self; - } - -CAsyncWaiter* CAsyncWaiter::NewLC(TInt aPriority) - { - CAsyncWaiter* self = new(ELeave) CAsyncWaiter(aPriority); - CleanupStack::PushL(self); - return self; - } - -CAsyncWaiter::CAsyncWaiter(TInt aPriority) : CActive(aPriority) - { - CActiveScheduler::Add(this); - } - -CAsyncWaiter::~CAsyncWaiter() - { - Cancel(); - } - -void CAsyncWaiter::StartAndWait() - { - iStatus = KRequestPending; - SetActive(); - iWait.Start(); - } - -TInt CAsyncWaiter::Result() const - { - return iError; - } - -void CAsyncWaiter::RunL() - { - iError = iStatus.Int(); - //CAknEnv::StopSchedulerWaitWithBusyMessage( iWait ); - iWait.AsyncStop(); - } - -void CAsyncWaiter::DoCancel() - { - iError = KErrCancel; - if( iStatus == KRequestPending ) - { - TRequestStatus* s=&iStatus; - User::RequestComplete( s, KErrCancel ); - } - - //CAknEnv::StopSchedulerWaitWithBusyMessage( iWait ); - iWait.AsyncStop(); - } - -// -------------------------------------------------------------------------------------------- - -void CEngine::OpenWithApparcL(TFileName aFileName) - { - if (iFileUtils != NULL) - { - iFileUtils->OpenWithApparcL(aFileName); - } - } - -// -------------------------------------------------------------------------------------------- - -void CEngine::OpenWithDocHandlerL(TFileName aFileName, TBool aEmbed) - { - if (iFileUtils != NULL) - { - iFileUtils->OpenWithDocHandlerL(aFileName, aEmbed); - } - } - -// -------------------------------------------------------------------------------------------- - -//TInt CEngine::QueryCurrentItemIndex() -// { -// return iFileBrowserUI->QueryCurrentItemIndex(); -// } - -// -------------------------------------------------------------------------------------------- - -TSearchAttributes CEngine::GetSearchAttributes() - { - if (iFileUtils != NULL) - { - return iFileUtils->GetSearchAttributes(); - } - else - { - return TSearchAttributes(); - } - } - -// -------------------------------------------------------------------------------------------- - -void CEngine::ChangeAttributes(TSearchAttributes attributes) - { - if (iFileUtils != NULL) - { - iFileUtils->ChangeAttributes(attributes); - } - } - -// -------------------------------------------------------------------------------------------- - -TSearchResults CEngine::SearchResults() - { - if (iFileUtils != NULL) - { - return iFileUtils->SearchResults(); - } - else - { - return TSearchResults(); - } - } - -// -------------------------------------------------------------------------------------------- - -CFileEntryList* CEngine::FoundFiles() - { - if (iFileUtils != NULL) - { - return iFileUtils->FoundFiles(); - } - else - { - return NULL; - } - } - -// -------------------------------------------------------------------------------------------- - -void CEngine::SearchL() - { - if (iFileUtils != NULL) - { - TRAP_IGNORE(iFileUtils->SearchL()); - } - } - -// -------------------------------------------------------------------------------------------- - -// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/engine/engine.h --- a/filebrowser/engine/engine.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,222 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef __ENGINE_H__ -#define __ENGINE_H__ - -// INCLUDES -#include -#include -#include - -#include "FBFileUtils.h" - -// setting keys (do not change uids of existing keys to maintain compatibility to older versions!) -const TUid KFBSettingDisplayMode = { 0x00 }; -const TUid KFBSettingFileViewMode = { 0x01 }; -const TUid KFBSettingShowSubDirectoryInfo = { 0x02 }; -const TUid KFBSettingShowAssociatedIcons = { 0x03 }; -const TUid KFBSettingRememberLastPath = { 0x04 }; -const TUid KFBSettingLastPath = { 0x05 }; - -const TUid KFBSettingSupportNetworkDrives = { 0x06 }; -const TUid KFBSettingBypassPlatformSecurity = { 0x07 }; -const TUid KFBSettingRemoveFileLocks = { 0x08 }; -const TUid KFBSettingIgnoreProtectionsAtts = { 0x09 }; -const TUid KFBSettingRemoveROMWriteProtection = { 0x0A }; - -const TUid KFBSettingFolderSelection = { 0x0B }; -const TUid KFBSettingEnableToolbar = { 0x0C }; - - -// FORWARD DECLARATIONS -class CFileBrowserFileListContainer; -class CFileBrowserScreenCapture; -class CFileBrowserFileUtils; -class CEikonEnv; -class CDictionaryFileStore; -class MFileBrowserUI; - -// CLASS DECLARATIONS - -class TFileBrowserSettings - { -public: - TInt iDisplayMode; - TInt iFileViewMode; - TBool iShowSubDirectoryInfo; - TBool iShowAssociatedIcons; - TBool iRememberLastPath; - TFileName iLastPath; - TBool iRememberFolderSelection; - TBool iEnableToolbar; - - TBool iSupportNetworkDrives; - TBool iBypassPlatformSecurity; - TBool iRemoveFileLocks; - TBool iIgnoreProtectionsAtts; - TBool iRemoveROMWriteProrection; - }; - -// INFERFACE FOR COMMUNICATION WITH UI - -class MFileBrowserUI -{ -public: -// /** -// * Method from getting current index -// * @return current index. -// */ -// virtual TInt QueryCurrentItemIndex() = 0; - - /** - * Shows info message with text - * @param A aText text to be shown in message body. - * @param A aTitle text to be shown in message title. - * @return None. - */ - virtual void ShowInformationNote(const TDesC &aDescText, const TDesC &aDescTitle) = 0; - - /** - * Shows error message with error text - * @param aText An error text to be shown in message. - * @return None. - */ - virtual void ShowErrorNote(const TDesC& aText, TBool aNoTimeout = EFalse) = 0; - - /** - * Shows confirmation message with text - * @param aText An text to be shown in message. - * @return None. - */ - virtual void ShowConfirmationNote(const TDesC& aText, TBool aNoTimeout = EFalse) = 0; - - /** - * Shows progress bar with text - * @param aText A text to be shown at top of the progress bar. - * @param aMinimum A minimum progress bar value. - * @param aMaximum A maximum progress bar value. - * @return None. - */ - virtual void ShowProgressDialog(const TDesC& aDescText, TInt aMinimum, TInt aMaximum ) = 0; - - /** - * Cancel progress dialog - * @return None. - */ - virtual void CancelProgressDialog() = 0; - - /** - * Set progress dialog value - * @param aValue A vaule to be shown at top of the progress dialog. - */ - virtual void SetProgressValue(TInt aValue) = 0; -// -// /** -// * Sets progress bar value -// * @param aValue A value between min and max value of the progress bar range -// * @return None. -// */ -// virtual void SetProgressBarValue(TInt aValue) = 0; -// -// /** -// * Hides progress bar -// * @return None. -// */ -// virtual void HideProgressBar() = 0; -// - /** - * Shows wait dialog with text - * @param aText A text to be shown at top of the wait bar. - * @return None. - */ - virtual void ShowWaitDialog(const TDesC& aText) = 0; - - /** - * Cancel wait dialog - * @return None. - */ - virtual void CancelWaitDialog() = 0; - - /** - * Processes all pending events to allow wait/progresa dialog to update itself - * @return None. - */ - virtual void ProcessEvents() = 0; - - /** - * Shows confirmation dialog - * @param aFileName String contaning file name and path - * @return ETrue if user pressed OK button, otherwise EFalse. - */ - virtual TBool ShowConfirmationQuery(const TDesC& aDescText) = 0; - - /** - * Notify wrapping model data has changed - */ - virtual void NotifyModelHasChanged() = 0; - -}; - -class CEngine : public CBase - { -public: - static CEngine* NewL(MFileBrowserUI *aFileBrowserUI); - ~CEngine(); - -private: - CEngine(); - void ConstructL(MFileBrowserUI *aFileBrowserUI); - void LoadSettingsL(); - void LoadDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, TInt& aValue); - void LoadDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, TDes& aValue); - void SaveDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, const TInt& aValue); - void SaveDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, const TDes& aValue); - -public: - void ActivateEngineL(); - void DeActivateEngineL(); - void SaveSettingsL(TBool aNotifyModules=ETrue); - TInt LaunchSettingsDialogL(); - inline TFileBrowserSettings& Settings() { return iSettings; } - inline CEikonEnv* EikonEnv() { return iEnv; } - inline RApaLsSession& LsSession() { return iLs; } - inline CFileBrowserScreenCapture* ScreenCapture() { return iScreenCapture; } - inline CFileBrowserFileUtils* FileUtils() { return iFileUtils; } - inline MFileBrowserUI* FileBrowserUI() { return iFileBrowserUI; } - - void OpenWithApparcL(TFileName aFileName); - void OpenWithDocHandlerL(TFileName aFileName, TBool aEmbed); -// TInt QueryCurrentItemIndex(); - TSearchAttributes GetSearchAttributes(); - void ChangeAttributes(TSearchAttributes attributes); - TSearchResults SearchResults(); - CFileEntryList* FoundFiles(); - void SearchL(); - -private: - MFileBrowserUI *iFileBrowserUI; - CFileBrowserScreenCapture *iScreenCapture; - CFileBrowserFileUtils *iFileUtils; - CEikonEnv* iEnv; - TFileBrowserSettings iSettings; - RApaLsSession iLs; - TBool iIsHashKeySelectionInUse; - }; - - -#endif // __ENGINE_H__ diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/filebrowser.pro --- a/filebrowser/filebrowser.pro Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -# -# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# This component and the accompanying materials are made available -# under the terms of "Eclipse Public License v1.0" -# which accompanies this distribution, and is available -# at the URL "http://www.eclipse.org/legal/epl-v10.html". -# -# Initial Contributors: -# Nokia Corporation - initial contribution. -# -# Contributors: -# -# Description: -# -# - -TEMPLATE = subdirs - -DEFINES += QT_NO_DEBUG_OUTPUT QT_NO_WARNING_OUTPUT QT_NO_DEBUG - -SUBDIRS = group \ - ui diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/fileopclient/BWINS/FileBrowserFileOpClientU.DEF --- a/filebrowser/fileopclient/BWINS/FileBrowserFileOpClientU.DEF Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -EXPORTS - ??1CFBFileOpClient@@UAE@XZ @ 1 NONAME ; CFBFileOpClient::~CFBFileOpClient(void) - ?Attribs@CFBFileOpClient@@QAEHABVTDesC16@@IIABVTTime@@I@Z @ 2 NONAME ; int CFBFileOpClient::Attribs(class TDesC16 const &, unsigned int, unsigned int, class TTime const &, unsigned int) - ?Copy@CFBFileOpClient@@QAEHABVTDesC16@@0I@Z @ 3 NONAME ; int CFBFileOpClient::Copy(class TDesC16 const &, class TDesC16 const &, unsigned int) - ?CreateEmptyFile@CFBFileOpClient@@QAEHABVTDesC16@@@Z @ 4 NONAME ; int CFBFileOpClient::CreateEmptyFile(class TDesC16 const &) - ?Delete@CFBFileOpClient@@QAEHABVTDesC16@@I@Z @ 5 NONAME ; int CFBFileOpClient::Delete(class TDesC16 const &, unsigned int) - ?EraseMBR@CFBFileOpClient@@QAEHI@Z @ 6 NONAME ; int CFBFileOpClient::EraseMBR(unsigned int) - ?MkDirAll@CFBFileOpClient@@QAEHABVTDesC16@@@Z @ 7 NONAME ; int CFBFileOpClient::MkDirAll(class TDesC16 const &) - ?NewL@CFBFileOpClient@@SAPAV1@XZ @ 8 NONAME ; class CFBFileOpClient * CFBFileOpClient::NewL(void) - ?PartitionDrive@CFBFileOpClient@@QAEHII@Z @ 9 NONAME ; int CFBFileOpClient::PartitionDrive(unsigned int, unsigned int) - ?Rename@CFBFileOpClient@@QAEHABVTDesC16@@0I@Z @ 10 NONAME ; int CFBFileOpClient::Rename(class TDesC16 const &, class TDesC16 const &, unsigned int) - ?RmDir@CFBFileOpClient@@QAEHABVTDesC16@@I@Z @ 11 NONAME ; int CFBFileOpClient::RmDir(class TDesC16 const &, unsigned int) - ?CancelOp@CFBFileOpClient@@QAEXXZ @ 12 NONAME ; void CFBFileOpClient::CancelOp(void) - diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/fileopclient/eabi/FileBrowserFileOpClientu.def --- a/filebrowser/fileopclient/eabi/FileBrowserFileOpClientu.def Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,20 +0,0 @@ -EXPORTS - _ZN15CFBFileOpClient14PartitionDriveEjj @ 1 NONAME - _ZN15CFBFileOpClient15CreateEmptyFileERK7TDesC16 @ 2 NONAME - _ZN15CFBFileOpClient4CopyERK7TDesC16S2_j @ 3 NONAME - _ZN15CFBFileOpClient4NewLEv @ 4 NONAME - _ZN15CFBFileOpClient5RmDirERK7TDesC16j @ 5 NONAME - _ZN15CFBFileOpClient6DeleteERK7TDesC16j @ 6 NONAME - _ZN15CFBFileOpClient6RenameERK7TDesC16S2_j @ 7 NONAME - _ZN15CFBFileOpClient7AttribsERK7TDesC16jjRK5TTimej @ 8 NONAME - _ZN15CFBFileOpClient8EraseMBREj @ 9 NONAME - _ZN15CFBFileOpClient8MkDirAllERK7TDesC16 @ 10 NONAME - _ZN15CFBFileOpClientD0Ev @ 11 NONAME - _ZN15CFBFileOpClientD1Ev @ 12 NONAME - _ZN15CFBFileOpClientD2Ev @ 13 NONAME - _ZTI15CFBFileOpClient @ 14 NONAME ; ## - _ZTV15CFBFileOpClient @ 15 NONAME ; ## - _ZN15CFBFileOpClient8CancelOpEv @ 16 NONAME - _ZTI18CAsyncWaiterClient @ 17 NONAME ; ## - _ZTV18CAsyncWaiterClient @ 18 NONAME ; ## - diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/fileopclient/group/FBFileOpClient.mmp --- a/filebrowser/fileopclient/group/FBFileOpClient.mmp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#include -#include - - -TARGET FileBrowserFileOpClient.dll -TARGETTYPE dll - -CAPABILITY CAP_GENERAL_DLL - -SMPSAFE - -UID 0x102828D7 -VENDORID VID_DEFAULT - - -USERINCLUDE ../inc -SOURCEPATH ../src -OS_LAYER_SYSTEMINCLUDE - - -SOURCE FBFileOpClient.cpp - -LIBRARY euser.lib diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/fileopclient/group/bld.inf --- a/filebrowser/fileopclient/group/bld.inf Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,20 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -PRJ_MMPFILES -FBFileOpClient.mmp diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/fileopclient/inc/FBFileOpClient.h --- a/filebrowser/fileopclient/inc/FBFileOpClient.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,108 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#ifndef __FBFILEOPCLIENT_H__ -#define __FBFILEOPCLIENT_H__ - -// INCLUDES -#include -#include -#include "FBFileOpClientServer.h" // TFileOpArgs - -// FORWARD DECLARATIONS - -// CLASS DECLARATIONS - -class RFBFileOpServerSession : public RSessionBase - { -public: - TInt Connect(); - - void Copy(const TDesC& aSourceFullName, const TDesC& aTargetFullName, TUint aSwitch, TRequestStatus& aStatus); - TInt Rename(const TDesC& anOld, const TDesC& aNew, TUint aSwitch); - TInt Attribs(const TDesC& aName, TUint aSetMask, TUint aClearMask, const TTime& aTime, TUint aSwitch); - void RmDir(const TDesC& aDirName, TUint aSwitch, TRequestStatus& aStatus); - void Delete(const TDesC& aName, TUint aSwitch, TRequestStatus& aStatus); - TInt MkDirAll(const TDesC& aPath); - TInt CreateEmptyFile(const TDesC& aName); - TInt EraseMBR(TUint aDriveNumber); - TInt PartitionDrive(TUint aDriveNumber, TUint aNumberOfPartitions); - TInt CancelOp(); - -private: - TVersion Version() const; - TPckgBuf iPckgBuf; - }; - - -class CFBFileOpClient : public CBase - { -public: - IMPORT_C static CFBFileOpClient* NewL(); - IMPORT_C ~CFBFileOpClient(); - IMPORT_C TInt Copy(const TDesC& aSourceFullName, const TDesC& aTargetFullName, TUint aSwitch); - IMPORT_C TInt Rename(const TDesC& anOld, const TDesC& aNew, TUint aSwitch); - IMPORT_C TInt Attribs(const TDesC& aName, TUint aSetMask, TUint aClearMask, const TTime& aTime, TUint aSwitch); - IMPORT_C TInt RmDir(const TDesC& aDirName, TUint aSwitch); - IMPORT_C TInt Delete(const TDesC& aName, TUint aSwitch); - IMPORT_C TInt MkDirAll(const TDesC& aPath); - IMPORT_C TInt CreateEmptyFile(const TDesC& aName); - IMPORT_C TInt EraseMBR(TUint aDriveNumber); - IMPORT_C TInt PartitionDrive(TUint aDriveNumber, TUint aNumberOfPartitions); - IMPORT_C void CancelOp(); - -private: - CFBFileOpClient(); - void ConstructL(); - - private : - RFBFileOpServerSession iFBFileOpServerSession; - }; - - -/** - * Similar class as CAsyncWaiter defined in FBUtils.h, except - * CAsyncWaiterClient uses iWait.AsyncStop() instead of - * CAknEnv::StopSchedulerWaitWithBusyMessage( iWait ) - * to stop the nested loop. This class can be utilized - * if CAknEnv is not running. - */ -class CAsyncWaiterClient : public CActive - { -public: - static CAsyncWaiterClient* NewL( TInt aPriority = EPriorityStandard ); - static CAsyncWaiterClient* NewLC( TInt aPriority = EPriorityStandard ); - ~CAsyncWaiterClient(); - - void StartAndWait(); - TInt Result() const; - -private: - CAsyncWaiterClient( TInt aPriority ); - - // from CActive - void RunL(); - void DoCancel(); - -private: - CActiveSchedulerWait iWait; - TInt iError; - }; - -#endif - diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/fileopclient/inc/FBFileOpClientServer.h --- a/filebrowser/fileopclient/inc/FBFileOpClientServer.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#ifndef __FBCLIENTSERVER_H__ -#define __FBCLIENTSERVER_H__ - -#include - -const TUint KCopyServMajorVersionNumber = 1; -const TUint KCopyServMinorVersionNumber = 0; -const TUint KCopyServBuildVersionNumber = 0; - -_LIT(KMyServerName, "FileBrowserFileOpServer"); -_LIT(KMyServerImg, "FileBrowserFileOpServer"); // EXE name -const TUid KServerUid3 = {0x102828D8}; - -enum TFileOpMessages - { - EFileOpCopy, - EFileOpRename, - EFileOpAttribs, - EFileOpRmDir, - EFileOpDelete, - EFileOpMkDirAll, - EFileOpCreateEmptyFile, - EFileOpEraseMBR, - EFileOpPartitionDrive, - EFileOpCancel - }; - -class TFileOpArgs - { -public: - TFileName iBuf1; - TFileName iBuf2; - TUint iUint1; - TUint iUint2; - TUint iUint3; - TTime iTime1; - }; - -#endif \ No newline at end of file diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/fileopclient/src/FBFileOpClient.cpp --- a/filebrowser/fileopclient/src/FBFileOpClient.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,481 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -// needed for client interface -#include "FBFileOpClient.h" - -const TUint KDefaultMessageSlots=4; - -// -------------------------------------------------------------------------------------------- - -static TInt StartServer() -// -// Start the server process. Simultaneous launching -// of two such processes should be detected when the second one attempts to -// create the server object, failing with KErrAlreadyExists. -// - { - const TUidType serverUid(KNullUid,KNullUid,KServerUid3); - RProcess server; - TInt r=server.Create(KMyServerImg,KNullDesC,serverUid); - if (r!=KErrNone) - return r; - TRequestStatus stat; - server.Rendezvous(stat); - if (stat!=KRequestPending) - server.Kill(0); // abort startup - else - server.Resume(); // logon OK - start the server - User::WaitForRequest(stat); // wait for start or death - // we can't use the 'exit reason' if the server panicked as this - // is the panic 'reason' and may be '0' which cannot be distinguished - // from KErrNone - r=(server.ExitType()==EExitPanic) ? KErrGeneral : stat.Int(); - server.Close(); - return r; - } - -// -------------------------------------------------------------------------------------------- - -TVersion RFBFileOpServerSession::Version(void) const - { - return(TVersion(KCopyServMajorVersionNumber,KCopyServMinorVersionNumber,KCopyServBuildVersionNumber)); - } - -// -------------------------------------------------------------------------------------------- - -TInt RFBFileOpServerSession::Connect() -// -// Connect to the server, attempting to start it if necessary -// - { - TInt retry=2; - for (;;) - { - TInt r=CreateSession(KMyServerName,Version(),KDefaultMessageSlots); - if (r!=KErrNotFound && r!=KErrServerTerminated) - return r; - if (--retry==0) - return r; - r=StartServer(); - if (r!=KErrNone && r!=KErrAlreadyExists) - return r; - } - } - -// -------------------------------------------------------------------------------------------- - -void RFBFileOpServerSession::Copy(const TDesC& aSourceFullName, const TDesC& aTargetFullName, TUint aSwitch, TRequestStatus& aStatus) - { - TFileOpArgs argsStruct = TFileOpArgs(); - argsStruct.iBuf1.Copy(aSourceFullName); - argsStruct.iBuf2.Copy(aTargetFullName); - argsStruct.iUint1 = aSwitch; - - iPckgBuf = argsStruct; - TIpcArgs args(&iPckgBuf); - SendReceive(EFileOpCopy, args, aStatus); - } - -// -------------------------------------------------------------------------------------------- - -TInt RFBFileOpServerSession::Rename(const TDesC& anOld, const TDesC& aNew, TUint aSwitch) - { - TFileOpArgs argsStruct = TFileOpArgs(); - argsStruct.iBuf1.Copy(anOld); - argsStruct.iBuf2.Copy(aNew); - argsStruct.iUint1 = aSwitch; - - TPckgBuf pckgBuf; - pckgBuf = argsStruct; - TIpcArgs args(&pckgBuf); - return SendReceive(EFileOpRename, args); - } - -// -------------------------------------------------------------------------------------------- - -TInt RFBFileOpServerSession::Attribs(const TDesC& aName, TUint aSetMask, TUint aClearMask, const TTime& aTime, TUint aSwitch) - { - TFileOpArgs argsStruct = TFileOpArgs(); - argsStruct.iBuf1.Copy(aName); - argsStruct.iUint1 = aSetMask; - argsStruct.iUint2 = aClearMask; - argsStruct.iTime1 = aTime; - argsStruct.iUint3 = aSwitch; - - TPckgBuf pckgBuf; - pckgBuf = argsStruct; - TIpcArgs args(&pckgBuf); - return SendReceive(EFileOpAttribs, args); - } - -// -------------------------------------------------------------------------------------------- - -void RFBFileOpServerSession::RmDir( const TDesC& aDirName, - TUint aSwitch, - TRequestStatus& aStatus ) - { - TFileOpArgs argsStruct = TFileOpArgs(); - argsStruct.iBuf1.Copy(aDirName); - argsStruct.iUint1 = aSwitch; - - iPckgBuf = argsStruct; - TIpcArgs args(&iPckgBuf); - SendReceive(EFileOpRmDir, args, aStatus); - } - -// -------------------------------------------------------------------------------------------- - -void RFBFileOpServerSession::Delete(const TDesC& aName, TUint aSwitch, TRequestStatus& aStatus) - { - TFileOpArgs argsStruct = TFileOpArgs(); - argsStruct.iBuf1.Copy(aName); - argsStruct.iUint1 = aSwitch; - - iPckgBuf = argsStruct; - TIpcArgs args(&iPckgBuf); - SendReceive(EFileOpDelete, args, aStatus); - } - -// -------------------------------------------------------------------------------------------- - -TInt RFBFileOpServerSession::MkDirAll(const TDesC& aPath) - { - TFileOpArgs argsStruct = TFileOpArgs(); - argsStruct.iBuf1.Copy(aPath); - - TPckgBuf pckgBuf; - pckgBuf = argsStruct; - TIpcArgs args(&pckgBuf); - return SendReceive(EFileOpMkDirAll, args); - } - -// -------------------------------------------------------------------------------------------- - -TInt RFBFileOpServerSession::CreateEmptyFile(const TDesC& aName) - { - TFileOpArgs argsStruct = TFileOpArgs(); - argsStruct.iBuf1.Copy(aName); - - TPckgBuf pckgBuf; - pckgBuf = argsStruct; - TIpcArgs args(&pckgBuf); - return SendReceive(EFileOpCreateEmptyFile, args); - } -// -------------------------------------------------------------------------------------------- - -TInt RFBFileOpServerSession::EraseMBR(TUint aDriveNumber) - { - TFileOpArgs argsStruct = TFileOpArgs(); - argsStruct.iUint1 = aDriveNumber; - - TPckgBuf pckgBuf; - pckgBuf = argsStruct; - TIpcArgs args(&pckgBuf); - return SendReceive(EFileOpEraseMBR, args); - } - -// -------------------------------------------------------------------------------------------- - -TInt RFBFileOpServerSession::PartitionDrive(TUint aDriveNumber, TUint aNumberOfPartitions) - { - TFileOpArgs argsStruct = TFileOpArgs(); - argsStruct.iUint1 = aDriveNumber; - argsStruct.iUint2 = aNumberOfPartitions; - - TPckgBuf pckgBuf; - pckgBuf = argsStruct; - TIpcArgs args(&pckgBuf); - return SendReceive(EFileOpPartitionDrive, args); - } - -// -------------------------------------------------------------------------------------------- - -TInt RFBFileOpServerSession::CancelOp() - { - TIpcArgs args( NULL ); - return SendReceive( EFileOpCancel, args ); - } - -// -------------------------------------------------------------------------------------------- -// -------------------------------------------------------------------------------------------- - -EXPORT_C CFBFileOpClient* CFBFileOpClient::NewL() - { - CFBFileOpClient* self = new(ELeave) CFBFileOpClient; - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(self); - return self; - } - -// -------------------------------------------------------------------------------------------- - -EXPORT_C CFBFileOpClient::~CFBFileOpClient() - { - iFBFileOpServerSession.Close(); - } - -// -------------------------------------------------------------------------------------------- - -CFBFileOpClient::CFBFileOpClient() - { - } - -// -------------------------------------------------------------------------------------------- - -void CFBFileOpClient::ConstructL() - { - User::LeaveIfError(iFBFileOpServerSession.Connect()); - } - -// -------------------------------------------------------------------------------------------- - -EXPORT_C TInt CFBFileOpClient::Copy( const TDesC& aSourceFullName, - const TDesC& aTargetFullName, - TUint aSwitch ) - { - CAsyncWaiterClient* waiter = CAsyncWaiterClient::NewLC(); - iFBFileOpServerSession.Copy( aSourceFullName, aTargetFullName, aSwitch, waiter->iStatus ); - waiter->StartAndWait(); - TInt err = waiter->Result(); - - if ( err == KErrServerTerminated ) - { - User::LeaveIfError( iFBFileOpServerSession.Connect() ); - iFBFileOpServerSession.Copy( aSourceFullName, aTargetFullName, aSwitch, waiter->iStatus ); - waiter->StartAndWait(); - err = waiter->Result(); - } - CleanupStack::PopAndDestroy( waiter ); - return err; - } - -// -------------------------------------------------------------------------------------------- - -EXPORT_C TInt CFBFileOpClient::Rename(const TDesC& anOld, const TDesC& aNew, TUint aSwitch) - { - TInt err = iFBFileOpServerSession.Rename(anOld, aNew, aSwitch); - - if (err == KErrServerTerminated) - { - User::LeaveIfError(iFBFileOpServerSession.Connect()); - err = iFBFileOpServerSession.Rename(anOld, aNew, aSwitch); - } - - return err; - } - -// -------------------------------------------------------------------------------------------- - -EXPORT_C TInt CFBFileOpClient::Attribs(const TDesC& aName, TUint aSetMask, TUint aClearMask, const TTime& aTime, TUint aSwitch) - { - TInt err = iFBFileOpServerSession.Attribs(aName, aSetMask, aClearMask, aTime, aSwitch); - - if (err == KErrServerTerminated) - { - User::LeaveIfError(iFBFileOpServerSession.Connect()); - err = iFBFileOpServerSession.Attribs(aName, aSetMask, aClearMask, aTime, aSwitch); - } - - return err; - } - -// -------------------------------------------------------------------------------------------- - -EXPORT_C TInt CFBFileOpClient::RmDir(const TDesC& aDirName, TUint aSwitch) - { - CAsyncWaiterClient* waiter = CAsyncWaiterClient::NewLC(); - iFBFileOpServerSession.RmDir( aDirName, aSwitch, waiter->iStatus ); - waiter->StartAndWait(); - TInt err = waiter->Result(); - - if ( err == KErrServerTerminated ) - { - User::LeaveIfError( iFBFileOpServerSession.Connect() ); - iFBFileOpServerSession.RmDir( aDirName, aSwitch, waiter->iStatus ); - waiter->StartAndWait(); - err = waiter->Result(); - } - CleanupStack::PopAndDestroy( waiter ); - return err; - } - -// -------------------------------------------------------------------------------------------- - -EXPORT_C TInt CFBFileOpClient::Delete(const TDesC& aName, TUint aSwitch) - { - CAsyncWaiterClient* waiter = CAsyncWaiterClient::NewLC(); - iFBFileOpServerSession.Delete(aName, aSwitch, waiter->iStatus ); - waiter->StartAndWait(); - TInt err = waiter->Result(); - - if ( err == KErrServerTerminated ) - { - User::LeaveIfError( iFBFileOpServerSession.Connect() ); - iFBFileOpServerSession.Delete(aName, aSwitch, waiter->iStatus ); - waiter->StartAndWait(); - err = waiter->Result(); - } - CleanupStack::PopAndDestroy( waiter ); - return err; - } - -// -------------------------------------------------------------------------------------------- - -EXPORT_C TInt CFBFileOpClient::MkDirAll(const TDesC& aPath) - { - TInt err = iFBFileOpServerSession.MkDirAll(aPath); - - if (err == KErrServerTerminated) - { - User::LeaveIfError(iFBFileOpServerSession.Connect()); - err = iFBFileOpServerSession.MkDirAll(aPath); - } - - return err; - } - -// -------------------------------------------------------------------------------------------- - -EXPORT_C TInt CFBFileOpClient::CreateEmptyFile(const TDesC& aName) - { - TInt err = iFBFileOpServerSession.CreateEmptyFile(aName); - - if (err == KErrServerTerminated) - { - User::LeaveIfError(iFBFileOpServerSession.Connect()); - err = iFBFileOpServerSession.CreateEmptyFile(aName); - } - - return err; - } - -// -------------------------------------------------------------------------------------------- - -EXPORT_C TInt CFBFileOpClient::EraseMBR(TUint aDriveNumber) - { - TInt err = iFBFileOpServerSession.EraseMBR(aDriveNumber); - - if (err == KErrServerTerminated) - { - User::LeaveIfError(iFBFileOpServerSession.Connect()); - err = iFBFileOpServerSession.EraseMBR(aDriveNumber); - } - - return err; - } - -// -------------------------------------------------------------------------------------------- - -EXPORT_C TInt CFBFileOpClient::PartitionDrive(TUint aDriveNumber, TUint aNumberOfPartitions) - { - TInt err = iFBFileOpServerSession.PartitionDrive(aDriveNumber, aNumberOfPartitions); - - if (err == KErrServerTerminated) - { - User::LeaveIfError(iFBFileOpServerSession.Connect()); - err = iFBFileOpServerSession.PartitionDrive(aDriveNumber, aNumberOfPartitions); - } - - return err; - } - -// -------------------------------------------------------------------------------------------- - -EXPORT_C void CFBFileOpClient::CancelOp() - { - TInt err = iFBFileOpServerSession.CancelOp(); - - if ( err == KErrServerTerminated ) - { - User::LeaveIfError( iFBFileOpServerSession.Connect() ); - err = iFBFileOpServerSession.CancelOp(); // Ignore return value this time - } - } - -// -------------------------------------------------------------------------------------------- -// -------------------------------------------------------------------------------------------- - -CAsyncWaiterClient* CAsyncWaiterClient::NewL( TInt aPriority ) - { - CAsyncWaiterClient* self = new(ELeave) CAsyncWaiterClient( aPriority ); - return self; - } - -// -------------------------------------------------------------------------------------------- - -CAsyncWaiterClient* CAsyncWaiterClient::NewLC( TInt aPriority ) - { - CAsyncWaiterClient* self = new (ELeave) CAsyncWaiterClient( aPriority ); - CleanupStack::PushL( self ); - return self; - } - -// -------------------------------------------------------------------------------------------- - -CAsyncWaiterClient::CAsyncWaiterClient( TInt aPriority ) : CActive( aPriority ) - { - CActiveScheduler::Add( this ); - } - -// -------------------------------------------------------------------------------------------- - -CAsyncWaiterClient::~CAsyncWaiterClient() - { - Cancel(); - } - -// -------------------------------------------------------------------------------------------- - -void CAsyncWaiterClient::StartAndWait() - { - SetActive(); - iWait.Start(); - } - -// -------------------------------------------------------------------------------------------- - -TInt CAsyncWaiterClient::Result() const - { - return iError; - } - -// -------------------------------------------------------------------------------------------- - -void CAsyncWaiterClient::RunL() - { - iError = iStatus.Int(); - iWait.AsyncStop(); - } - -// -------------------------------------------------------------------------------------------- - -void CAsyncWaiterClient::DoCancel() - { - iError = KErrCancel; - if( iStatus == KRequestPending ) - { - TRequestStatus* s = &iStatus; - User::RequestComplete( s, KErrCancel ); - } - iWait.AsyncStop(); - } - -// -------------------------------------------------------------------------------------------- - diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/fileopserver/group/FBFileOpServer.mmp --- a/filebrowser/fileopserver/group/FBFileOpServer.mmp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#include -#include - - -TARGET FileBrowserFileOpServer.exe -TARGETTYPE exe -UID 0 0x102828D8 -VENDORID VID_DEFAULT - -CAPABILITY CAP_FILE_SERVER - -SMPSAFE - -USERINCLUDE ../inc -USERINCLUDE ../../fileopclient/inc -OS_LAYER_SYSTEMINCLUDE -//SYSTEMINCLUDE /epoc32/include/kernel -SOURCEPATH ../src - - -SOURCE FBFileOpServer.cpp -SOURCE FBDrivePartitioner.cpp - -LIBRARY euser.lib -LIBRARY efsrv.lib -LIBRARY efile.lib diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/fileopserver/group/bld.inf --- a/filebrowser/fileopserver/group/bld.inf Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,20 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -PRJ_MMPFILES -FBFileOpServer.mmp diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/fileopserver/inc/FBDrivePartitioner.h --- a/filebrowser/fileopserver/inc/FBDrivePartitioner.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#ifndef __FBDRIVEPARTITIONER_H__ -#define __FBDRIVEPARTITIONER_H__ - -#include -#include - -class FBDrivePartioner - { -public: - static TInt FindLocalDriveNumber(RFs& aFs, TInt aDriveNumber, TInt& aLocalDriveNum); - static TInt EraseMBR(RFs& aFs, TInt aDriveNumber); - static TInt CreatePartitions(RFs& aFs, TInt aDriveNumber, TInt aPartCount); - static TInt FormatPartitions(RFs& aFs, TInt aDriveNumber, TInt aPartCount); - }; - - -#endif diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/fileopserver/inc/FBFileOpServer.h --- a/filebrowser/fileopserver/inc/FBFileOpServer.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,186 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#ifndef __FBFILEOPSERVER_H__ -#define __FBFILEOPSERVER_H__ - -#include -#include -#include "FBFileOpClientServer.h" - -// needed for creating server thread. -//const TUint KDefaultHeapSize=0x10000; - -// reasons for server panic -enum TMyPanic - { - EPanicBadDescriptor, - EPanicIllegalFunction - }; - -class CShutdown : public CTimer - { - enum {KMyShutdownDelay=0x200000}; // approx 2s - -public : - inline CShutdown(); - inline void ConstructL(); - inline void Start(); - -private : - void RunL(); - }; - -//********************************** -//CFBFileOpServer -//********************************** -/** -Our server class - an active object - and therefore derived ultimately from CActive. -It accepts requests from client threads and forwards -them to the client session to be dealt with. It also handles the creation -of the server-side client session. -*/ -class CFBFileOpServer : public CServer2 - { - -public : - static CServer2* NewLC(); - void AddSession(); - void DropSession(); - -protected : - -private : - CFBFileOpServer(); - void ConstructL(); - CSession2* NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const; - -public : - -private : - TInt iSessionCount; - CShutdown iShutdown; - - }; - -//********************************** -//CRequestObserver -//********************************** -/** -This class is for monitoring asynchronous request -and for completing related RMessage2 object. -*/ -class CRequestObserver : public CActive - { -public: - CRequestObserver( TInt aPriority ); - virtual ~CRequestObserver(); - - void StartWaiting( const RMessage2& aMsg ); - -private: - // from CActive - void RunL(); - void DoCancel(); - -private: - RMessage2 iMsg; - }; - - -//********************************** -//CFBFileOpServerSession -//********************************** -/** -This class represents a session with the server. -Functions are provided to respond appropriately to client messages. -*/ -class CFBFileOpServerSession : public CSession2, - public MFileManObserver - { - -public : - CFBFileOpServerSession(); - -private: // From MFileManObserver - - TControl NotifyFileManStarted(); - TControl NotifyFileManOperation(); - TControl NotifyFileManEnded(); - -protected : - // panic the client - void PanicClient(const RMessage2& aMessage,TInt aPanic) const; - -private : - ~CFBFileOpServerSession(); - inline CFBFileOpServer& Server(); - void CreateL(); - - //service requests - void ServiceL(const RMessage2& aMessage); - void DispatchMessageL(const RMessage2& aMessage, TBool& aComplete); - - void CopyL(const RMessage2& aMessage); - void RenameL(const RMessage2& aMessage); - void AttribsL(const RMessage2& aMessage); - void RmDirL(const RMessage2& aMessage, TBool& aComplete); - void DeleteL(const RMessage2& aMessage); - void MkDirAllL(const RMessage2& aMessage); - void CreateEmptyFileL(const RMessage2& aMessage); - void EraseMBRL(const RMessage2& aMessage); - void PartitionDriveL(const RMessage2& aMessage); - - void ServiceError(const RMessage2& aMessage, TInt aError); - - void CancelOp(); - -private : - RFs iFs; - RFile iFile; - CFileMan* iFileMan; - MFileManObserver::TControl iFileManObserverResult; - CRequestObserver* iReqObserver; - }; - - -//********************************** -//Inlines -//********************************** - -inline CShutdown::CShutdown() - :CTimer(-1) - {CActiveScheduler::Add(this);} - -inline void CShutdown::ConstructL() - {CTimer::ConstructL();} - -inline void CShutdown::Start() - {After(KMyShutdownDelay);} - -inline CFBFileOpServer::CFBFileOpServer() - :CServer2(0,ESharableSessions) - {} - -inline CFBFileOpServerSession::CFBFileOpServerSession() - {} - -inline CFBFileOpServer& CFBFileOpServerSession::Server() - {return *static_cast(const_cast(CSession2::Server()));} - -#endif diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/fileopserver/src/FBDrivePartitioner.cpp --- a/filebrowser/fileopserver/src/FBDrivePartitioner.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,454 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#include -#include -#include -#include - -#include "FBDrivePartitioner.h" - - -// copied from coreapplicationuisdomainpskeys.h -const TUid KPSUidCoreApplicationUIs = { 0x101F8767 }; -const TUint32 KCoreAppUIsMmcRemovedWithoutEject = 0x00000109; -enum TCoreAppUIsMmcRemovedWithoutEject - { - ECoreAppUIsEjectCommandUsedUninitialized = 0, - ECoreAppUIsEjectCommandNotUsed, - ECoreAppUIsEjectCommandUsed, - ECoreAppUIsEjectCommandUsedToDrive // Low 16-bits contain this value and high 16-bits TDriveNumber to eject - }; - - -// trace macros -#define TRACE(a) {_LIT( KMsg, a ); RDebug::Print(KMsg);} -#define TRACE1(a,b) {_LIT( KMsg, a ); RDebug::Print(KMsg,b);} -#define TRACE2(a,b,c) {_LIT( KMsg, a ); RDebug::Print(KMsg,b,c);} - - -// Set the partition alignment boundary -const TInt KPartitionAlignment = 0x1000; // 4kB -const TInt KMBRSize = 512; -const TInt KSectorSize = 512; -const TInt KMBRPartitionInfoOffset = 0x1BE; -const TInt KLargeFAT16Partition = 0x2000000; // 32MB -const TInt KPartitionEntrySize = 16; - -// Set for the iX86BootIndicator -//const TInt KPartitionBootable = 0x80; -const TInt KPartitionNonBootable = 0x0; - - -class TMBRPartition - { -public: - TUint8 iX86BootIndicator; - TUint8 iStartHead; - TUint8 iStartSector; - TUint8 iStartCylinder; - TUint8 iPartitionType; - TUint8 iEndHead; - TUint8 iEndSector; - TUint8 iEndCylinder; - TUint32 iFirstSector; - TUint32 iNumSectors; - }; - - -// -------------------------------------------------------------------------------------------- - -TInt FBDrivePartioner::FindLocalDriveNumber(RFs& aFs, TInt aDriveNumber, TInt& aLocalDriveNum) - { - TRACE1( "FBDrivePartitioner::FindLocalDriveNumber: start aDriveNumber=%d", aDriveNumber ); - - TInt err(KErrNone); - - TDriveInfo driveInfo; - err = aFs.Drive(driveInfo, aDriveNumber); - - TRACE1( "FBDrivePartitioner::FindLocalDriveNumber: get DriveInfo err=%d", err ); - - - TVolumeInfo vi; - err = aFs.Volume(vi, aDriveNumber); - - TRACE1( "FBDrivePartitioner::FindLocalDriveNumber: get VolumeInfo err=%d", err ); - - - TMediaSerialNumber serialNum; - err = aFs.GetMediaSerialNumber(serialNum, aDriveNumber); - - TRACE1( "FBDrivePartitioner::FindLocalDriveNumber: get MediaSerialNumber err=%d", err ); - - - TInt len = serialNum.Length(); - TInt n(0); - for (n=0; n buf; - for (TInt m=n; m hexBuf; - hexBuf.Format(_L("%02X "),serialNum[m]); - buf.Append(hexBuf); - } - buf.Append(_L("\n")); - } - - TBusLocalDrive drv; - TBool chg(EFalse); - aLocalDriveNum = -1; - for (n=0; n mbrBuf; - mbrBuf.Fill(0, mbrBuf.MaxLength()); - -/* - // write the next 16 sectors with the buffer. Usually you only write the first one, but this one should erase any following invalid sectors - for (TInt i=0; i<16; i++) - { - err = drv.Write(i*KMBRSize, KMBRSize, &mbrBuf, -1 , 0, 0x40000000); // RLocalDrive::ELocDrvWholeMedia==0x40000000 - TRACE2("FBDrivePartitioner::EraseMBR: sector %d, write returns %d", i+1, err); - } -*/ - - // erase the MBR - err = drv.Write(0, KMBRSize, &mbrBuf, -1 , 0, 0x40000000); // RLocalDrive::ELocDrvWholeMedia==0x40000000 - TRACE1("FBDrivePartitioner::EraseMBR: write returns %d", err); - - drv.Disconnect(); - - // force a remount, if this is the protected area, then it will have to be remounted - TRACE1( "FBDrivePartitioner::EraseMBR: Remounting drive number %d", aDriveNumber ); - TInt err2 = aFs.RemountDrive(aDriveNumber, NULL, 0); - TRACE1( "FBDrivePartitioner::EraseMBR: RemountDrive err2=%d", err2 ); - - TRACE1( "FBDrivePartitioner::EraseMBR: returns %d", err ); - return err; - } - -// -------------------------------------------------------------------------------------------- - -TInt FBDrivePartioner::CreatePartitions(RFs& aFs, TInt aDriveNumber, TInt aPartCount) - { - TRACE2( "FBDrivePartitioner::CreatePartitions: start aDriveNumber=%d aPartCount=%d", aDriveNumber, aPartCount ); - TInt err(KErrNone); - - TUint8 MBRPartitionInfo[ KPartitionEntrySize*KMBRMaxPrimaryPartitions ]; - - // Prevent SysAp shutting down applications - RProperty::Set( - KPSUidCoreApplicationUIs, - KCoreAppUIsMmcRemovedWithoutEject, - ECoreAppUIsEjectCommandUsed ); - - // Force the system to read the memory card erased MBR - err = aFs.RemountDrive( aDriveNumber ); - TRACE1( "FBDrivePartitioner::CreatePartitions: Remount result %d", err ); - - // Get the number of partitions from user - TUint8 partitionCount(aPartCount); - TBool change = EFalse; - TInt mcDriveNbr(2); - TLocalDriveCapsV4 dc; - TInt64 diskSpace(0); - -/* - err = FindLocalDriveNumber(aFs, aDriveNumber, mcDriveNbr); - - if (err != KErrNone) - { - TRACE1("FBDrivePartitioner::CreatePartitions: FindLocalDriveNumber err=%d returning", err); - return err; - } -*/ - - // Seek through the system drives to find memory card drive - for (TInt i = 0; i < KMaxLocalDrives; ++i) - { - RLocalDrive d; - change = EFalse; - err = d.Connect(i, change); - if (err == KErrNone) - { - TPckg capsPack(dc); - - if (d.Caps(capsPack) == KErrNone) - { - if (dc.iType == EMediaHardDisk) - { - mcDriveNbr = i; - diskSpace = dc.iSize; - TRACE1( "FBDrivePartitioner::CreatePartitions: found hard drive %d:", mcDriveNbr ); - } - } - d.Close(); - } - } - - // Connect to the local drive we found - RLocalDrive localDrive; - change = EFalse; - err = localDrive.Connect( mcDriveNbr, change ); - TRACE2( "FBDrivePartitioner::CreatePartitions: localDrive.Connect %d: %d", mcDriveNbr, err ); - TRACE1( "FBDrivePartitioner::CreatePartitions: diskSpace in sectors 0x%x, %d", diskSpace / KSectorSize ); - - // Let's read the MBR by using RLocalDrive - TUint8 data[KMBRSize]; - TPtr8 buf( &data[0], KMBRSize ); - err = localDrive.Read( 0, KMBRSize, buf ); - TRACE1( "FBDrivePartitioner::CreatePartitions: localDrive.Read %d", err ); - // Let's check the current drive layout here - memcpy( MBRPartitionInfo, &data[KMBRPartitionInfoOffset],(sizeof(TMBRPartition)<<2)); - TMBRPartition *partitionInfo = (TMBRPartition*) MBRPartitionInfo; - - // Clean the rest of the MBR buffer - buf.FillZ(); - - // Print out the partition info - for( TInt i = 0; i 0) - { - err = fmt.Next(count); - if (err != KErrNone) - { - TRACE1( "FBDrivePartitioner::FormatPartitions: Format error=%d", err ); - break; - } - } - fmt.Close(); - TRACE1( "FBDrivePartitioner::FormatPartitions: Format %S end", &name ); - } - - TRACE1("FBDrivePartitioner::FormatPartitions returns %d", err); - - return err; - } - -// -------------------------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/fileopserver/src/FBFileOpServer.cpp --- a/filebrowser/fileopserver/src/FBFileOpServer.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,474 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#include "FBFileOpServer.h" -#include "FBDrivePartitioner.h" - -#include -#include - -// -------------------------------------------------------------------------------------------- - -//*********************************** -//CFBFileOpServer - implementations -//*********************************** - -CServer2* CFBFileOpServer::NewLC() - { - CFBFileOpServer* self = new(ELeave) CFBFileOpServer; - CleanupStack::PushL(self); - self->ConstructL(); - return self; - } - -// -------------------------------------------------------------------------------------------- - -// -// 2nd phase construction - ensure the timer and server objects are running -// -void CFBFileOpServer::ConstructL() - { - StartL(KMyServerName); - iShutdown.ConstructL(); - // ensure that the server still exits even if the 1st client fails to connect - iShutdown.Start(); - } - -// -------------------------------------------------------------------------------------------- - -// -// Cretae a new client session. This should really check the version number. -// -CSession2* CFBFileOpServer::NewSessionL(const TVersion&,const RMessage2&) const - { - return new(ELeave) CFBFileOpServerSession(); - } - -// -------------------------------------------------------------------------------------------- - -// -// A new session is being created -// Cancel the shutdown timer if it was running -// -void CFBFileOpServer::AddSession() - { - ++iSessionCount; - iShutdown.Cancel(); - } - -// -------------------------------------------------------------------------------------------- - -// -// A session is being destroyed -// Start the shutdown timer if it is the last session. -// -void CFBFileOpServer::DropSession() - { - if (--iSessionCount==0) - iShutdown.Start(); - } - -// -------------------------------------------------------------------------------------------- - -CRequestObserver::CRequestObserver( TInt aPriority ) : CActive( aPriority ) - { - CActiveScheduler::Add( this ); - } - -CRequestObserver::~CRequestObserver() - { - Cancel(); - } - -void CRequestObserver::StartWaiting( const RMessage2& aMsg ) - { - iMsg = aMsg; - SetActive(); - } - -void CRequestObserver::RunL() - { - iMsg.Complete( iStatus.Int() ); - } - -void CRequestObserver::DoCancel() - { - iMsg.Complete( KErrCancel ); - } - -// -------------------------------------------------------------------------------------------- - -//*********************************** -//CFBFileOpServerSession - implementations -//*********************************** - -// -// 2nd phase construct for sessions - called by the CServer framework -// -void CFBFileOpServerSession::CreateL() - { - User::LeaveIfError(iFs.Connect()); - iFileMan = CFileMan::NewL( iFs, this ); - iReqObserver = new (ELeave) CRequestObserver( CActive::EPriorityStandard ); - Server().AddSession(); - } - -// -------------------------------------------------------------------------------------------- - -CFBFileOpServerSession::~CFBFileOpServerSession() - { - if (iFileMan) - { - delete iFileMan; - iFileMan = NULL; - } - iFs.Close(); - delete iReqObserver; - Server().DropSession(); - } - -// -------------------------------------------------------------------------------------------- - -/** -Services a client request. -*/ -void CFBFileOpServerSession::ServiceL(const RMessage2& aMessage) - { - TBool completeImmediately( ETrue ); - TRAPD( err,DispatchMessageL( aMessage, completeImmediately ) ); - if ( completeImmediately ) aMessage.Complete( err ); - } - -// -------------------------------------------------------------------------------------------- - -/** -Called by ServiceL() - -It tests the function code and then delegates to -the appropriate function. -*/ -void CFBFileOpServerSession::DispatchMessageL(const RMessage2& aMessage, TBool& aComplete) - { - switch (aMessage.Function()) - { - case EFileOpCopy: - CopyL(aMessage); - aComplete = EFalse; - return; - - case EFileOpRename: - RenameL(aMessage); - return; - - case EFileOpAttribs: - AttribsL(aMessage); - return; - - case EFileOpRmDir: - RmDirL(aMessage, aComplete); - return; - - case EFileOpDelete: - DeleteL(aMessage); - aComplete = EFalse; - return; - - case EFileOpMkDirAll: - MkDirAllL(aMessage); - return; - - case EFileOpCreateEmptyFile: - CreateEmptyFileL(aMessage); - return; - - case EFileOpEraseMBR: - EraseMBRL(aMessage); - return; - - case EFileOpPartitionDrive: - PartitionDriveL(aMessage); - return; - - case EFileOpCancel: - CancelOp(); - return; - - default: - PanicClient(aMessage, EPanicIllegalFunction); - return; - } - } - -// -------------------------------------------------------------------------------------------- - -void CFBFileOpServerSession::CopyL( const RMessage2& aMessage ) - { - __ASSERT_ALWAYS( iReqObserver && !iReqObserver->IsActive(), User::Leave( KErrServerBusy ) ); - TPckgBuf pckgBuf; - aMessage.ReadL( 0, pckgBuf, 0 ); - TFileOpArgs argsStruct = pckgBuf(); - - TInt err = iFileMan->Copy( argsStruct.iBuf1, argsStruct.iBuf2, argsStruct.iUint1, iReqObserver->iStatus ); - User::LeaveIfError( err ); - iFileManObserverResult = MFileManObserver::EContinue; - iReqObserver->StartWaiting( aMessage ); // start asynchronous waiting - } - -// -------------------------------------------------------------------------------------------- - -void CFBFileOpServerSession::RenameL(const RMessage2& aMessage) - { - TPckgBuf pckgBuf; - aMessage.ReadL(0, pckgBuf, 0); - TFileOpArgs argsStruct = pckgBuf(); - - iFileManObserverResult = MFileManObserver::EContinue; - User::LeaveIfError(iFileMan->Rename(argsStruct.iBuf1, argsStruct.iBuf2, argsStruct.iUint1)); - } - -// -------------------------------------------------------------------------------------------- - -void CFBFileOpServerSession::AttribsL(const RMessage2& aMessage) - { - TPckgBuf pckgBuf; - aMessage.ReadL(0, pckgBuf, 0); - TFileOpArgs argsStruct = pckgBuf(); - - iFileManObserverResult = MFileManObserver::EContinue; - User::LeaveIfError(iFileMan->Attribs(argsStruct.iBuf1, argsStruct.iUint1, argsStruct.iUint2, argsStruct.iTime1, argsStruct.iUint3)); - } - -// -------------------------------------------------------------------------------------------- - -void CFBFileOpServerSession::RmDirL( const RMessage2& aMessage, TBool& aComplete ) - { - TPckgBuf pckgBuf; - aMessage.ReadL( 0, pckgBuf, 0 ); - TFileOpArgs argsStruct = pckgBuf(); - - if ( argsStruct.iUint1 & CFileMan::ERecurse ) - { - __ASSERT_ALWAYS( iReqObserver && !iReqObserver->IsActive(), User::Leave( KErrServerBusy ) ); - User::LeaveIfError( iFileMan->RmDir( argsStruct.iBuf1, iReqObserver->iStatus ) ); - iFileManObserverResult = MFileManObserver::EContinue; - aComplete = EFalse; - iReqObserver->StartWaiting( aMessage ); // start asynchronous waiting - } - else - { - iFileManObserverResult = MFileManObserver::EContinue; - User::LeaveIfError( iFs.RmDir( argsStruct.iBuf1 ) ); - } - } - -// -------------------------------------------------------------------------------------------- - -void CFBFileOpServerSession::DeleteL( const RMessage2& aMessage ) - { - __ASSERT_ALWAYS( iReqObserver && !iReqObserver->IsActive(), User::Leave( KErrServerBusy ) ); - TPckgBuf pckgBuf; - aMessage.ReadL( 0, pckgBuf, 0 ); - TFileOpArgs argsStruct = pckgBuf(); - - User::LeaveIfError( iFileMan->Delete(argsStruct.iBuf1, argsStruct.iUint1, iReqObserver->iStatus ) ); - iFileManObserverResult = MFileManObserver::EContinue; - iReqObserver->StartWaiting( aMessage ); // start asynchronous waiting - } - -// -------------------------------------------------------------------------------------------- - -void CFBFileOpServerSession::MkDirAllL(const RMessage2& aMessage) - { - TPckgBuf pckgBuf; - aMessage.ReadL(0, pckgBuf, 0); - TFileOpArgs argsStruct = pckgBuf(); - - User::LeaveIfError(iFs.MkDirAll(argsStruct.iBuf1)); - } - -// -------------------------------------------------------------------------------------------- - -void CFBFileOpServerSession::CreateEmptyFileL(const RMessage2& aMessage) - { - TPckgBuf pckgBuf; - aMessage.ReadL(0, pckgBuf, 0); - TFileOpArgs argsStruct = pckgBuf(); - - TInt err(KErrNone); - RFile newFile; - err = newFile.Create(iFs, argsStruct.iBuf1, EFileShareExclusive); - if (err == KErrNone) - err = newFile.Flush(); - newFile.Close(); - - User::LeaveIfError(err); - } - -// -------------------------------------------------------------------------------------------- - -void CFBFileOpServerSession::EraseMBRL(const RMessage2& aMessage) - { - TPckgBuf pckgBuf; - aMessage.ReadL(0, pckgBuf, 0); - TFileOpArgs argsStruct = pckgBuf(); - - RFs fs; - CleanupClosePushL(fs); - User::LeaveIfError(fs.Connect()); - - User::LeaveIfError(FBDrivePartioner::EraseMBR(fs, argsStruct.iUint1)); - - CleanupStack::PopAndDestroy(); //fs - } - -// -------------------------------------------------------------------------------------------- - -void CFBFileOpServerSession::PartitionDriveL(const RMessage2& aMessage) - { - TPckgBuf pckgBuf; - aMessage.ReadL(0, pckgBuf, 0); - TFileOpArgs argsStruct = pckgBuf(); - - RFs fs; - CleanupClosePushL(fs); - User::LeaveIfError(fs.Connect()); - - FBDrivePartioner::CreatePartitions(fs, argsStruct.iUint1, argsStruct.iUint2); - User::LeaveIfError(FBDrivePartioner::FormatPartitions(fs, argsStruct.iUint1, argsStruct.iUint2)); - - CleanupStack::PopAndDestroy(); //fs - } - -// -------------------------------------------------------------------------------------------- - -// -// Panics the client -// -void CFBFileOpServerSession::PanicClient(const RMessage2& aMessage, TInt aPanic) const - { - _LIT(KTxtServer,"FBFileOpServer"); - aMessage.Panic(KTxtServer, aPanic); - } - -// -------------------------------------------------------------------------------------------- - -// -// Handle an error from CFBFileOpServerSession::ServiceL() -// A bad descriptor error implies a badly programmed client, so panic it; -// otherwise use the default handling (report the error to the client) -// -void CFBFileOpServerSession::ServiceError(const RMessage2& aMessage, TInt aError) - { - if (aError==KErrBadDescriptor) - PanicClient(aMessage,EPanicBadDescriptor); - CSession2::ServiceError(aMessage,aError); - } - -// -------------------------------------------------------------------------------------------- - -MFileManObserver::TControl CFBFileOpServerSession::NotifyFileManStarted() - { - return iFileManObserverResult; - } - -// -------------------------------------------------------------------------------------------- - -MFileManObserver::TControl CFBFileOpServerSession::NotifyFileManOperation() - { - return iFileManObserverResult; - } -// -------------------------------------------------------------------------------------------- - -MFileManObserver::TControl CFBFileOpServerSession::NotifyFileManEnded() - { - return iFileManObserverResult; - } - -// -------------------------------------------------------------------------------------------- - -void CFBFileOpServerSession::CancelOp() - { - iFileManObserverResult = MFileManObserver::ECancel; - iReqObserver->Cancel(); - } - -// -------------------------------------------------------------------------------------------- - -//********************************** -//Global functions -//********************************** - -// -// Initiate server exit when the timer expires -// -void CShutdown::RunL() - { - CActiveScheduler::Stop(); - } - -// -------------------------------------------------------------------------------------------- - -// -// Perform all server initialisation, in particular creation of the -// scheduler and server and then run the scheduler -// -static void RunServerL() - { - // naming the server thread after the server helps to debug panics - User::LeaveIfError(RThread::RenameMe(KMyServerName)); - // - // create and install the active scheduler we need - CActiveScheduler* s=new(ELeave) CActiveScheduler; - CleanupStack::PushL(s); - CActiveScheduler::Install(s); - // - // create the server (leave it on the cleanup stack) - CFBFileOpServer::NewLC(); - // - // Initialisation complete, now signal the client - RProcess::Rendezvous(KErrNone); - // - // Ready to run - CActiveScheduler::Start(); - // - // Cleanup the server and scheduler - CleanupStack::PopAndDestroy(2); - } - -// -------------------------------------------------------------------------------------------- - -// -// Server process entry-point -// -TInt E32Main() - { - __UHEAP_MARK; - // - CTrapCleanup* cleanup=CTrapCleanup::New(); - TInt r=KErrNoMemory; - if (cleanup) - { - TRAP(r,RunServerL()); - delete cleanup; - } - // - __UHEAP_MARKEND; - return r; - } - -// -------------------------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/group/ReleaseNotes_FileBrowser.txt --- a/filebrowser/group/ReleaseNotes_FileBrowser.txt Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,271 +0,0 @@ -=============================================================================== - -RELEASE NOTES - FILEBROWSER v5.2.0 -RELEASED 27th August 2010 - -SUPPORTS S60 3.0+ - -=============================================================================== - -Product Description: -==================== -The FileBrowser tool can be used to browse directory hierarchies and perform -file operations under the S60 environment. It also contains some smaller tools -and functionalities that help RnD development and verification. - -Main Features: -============== -- Showing a drive list -- Browsing through directory hierarchies -- Disk admin tools for generic disk operations -- Searching files with different parameters -- Full clipboard functionality -- Copying/moving files with the help of a separate dialog -- Creating new files and directories -- Showing properties of files, directories and disks -- Sending, deleting, renaming, touching, setting attributes, - compressing and uncompressing of files -- Recursive directory support -- Sorting and ordering file view -- Filtering entries with a search field -- Text and hex viewer for files -- A settings screen for altering different kind of settings -- Data type viewer/editor -- Ability to give TCB capability for file operations -- Showing message attachments from Symbian messaging store -- Touch UI toolbar (S60 5.x only) - -=============================================================================== - -What's New in v5.2.0 -==================== -- Error fixes -- Destination folder selection dialog - -=============================================================================== - -Installation Notes: -=================== -FileBrowser is typically preinstalled on ROM. If not, it can be added to the -ROM with the .iby file. Alternatively, the .sis file can be found under the sis- -directory, but the user need to sign it with their own developer certificate. -In Nokia R&D environment, you can use directly the R&D-signed .sis file under the -internal\sis directory. - -FileBrowser is provided as full and lite version. Lite version is aimed for -those who cannot sign with TCB capability. Lite version can be generated by -defining FILEBROWSER_LITE flag and then by recompiling the application and -regenerating the sis file. - -When signing with own developer certificate, the following capabilities are -needed in the lite version: - ReadDeviceData - WriteDeviceData - DiskAdmin - AllFiles - SwEvent - NetworkServices - LocalServices - ReadUserData - WriteUserData - Location - UserEnvironment - -The full version requires these addtional capabilities: - CommDD - PowerMgmt - MultimediaDD - DRM - TrustedUI - ProtServ - NetworkControl - SurroundingsDD - TCB - -When builing FileBrowser against S60 3.0 or 3.1, you may need to patch your SDK -environment first with some fixes. For more information, please refer to the -instructions under the "envpatcher" directory. - -=============================================================================== - -System Requirements: -==================== -Basic Requirements: -- Any S60 3.x device or emulator environment - -=============================================================================== - -Compatibility Issues: -===================== -N/A - -=============================================================================== - -Known Issues: -============= -N/A - -=============================================================================== - -Version History: -================ - -Version 5.1.1 - 26th June 2010 -==================== -- Error fixes -- File attributes - -Version 5.1.0 - 18th June 2010 -==================== -- Error fixes -- File filtering -- Usability improvements - -Version 5.0.1 - 21th May 2010 -==================== -- Error fixes -- All files to text file with file sizes -- Usability improvements - -Version 5.0.0 - 23th April 2010 ------------------------------ -- Orbit UI - -Version 4.5.2 - 10th December 2009 ------------------------------ -- Fix: UI layout problems fixed -- Fix: Filebrowser crashes with too long filenames - -Version 4.5.1 - 15th May 2009 ------------------------------ -- Fix: Refreshing display does not work well when starting FileBrowser -- Fix: Internal Mass storage drive is displayed as Memory Card - -Version 4.5.0 - 13th February 2009 ----------------------------------- -- Feature: Touch UI toolbar introduced with Navigate Up, Filter and Select - functionalities (S60 5.x only) -- Fix: Date and directory attributes don't work correctly with search - -Version 4.4.0 - 12th December 2008 ----------------------------------- -- Feature: "Remember last folder": File list view now remembers which folder - had the last focus before navigating deeper in a directory, and selects that - folder instead of the root of the directory when navigating back upwards. -- Fix: Execution of long file operations may cause WSERV 11 panic -- Fix: Allow formatting even if files are in use - -Version 4.3.3 - 8th August 2008 -------------------------------- -- Fix: Calculation of partition size with 64-bit values caused unwanted side - effects - -Version 4.3.2 - 5th May 2008 ------------------------------- -- Fix: Size of drive partitions should be calculated with 64-bit values - -Version 4.3.1 - 7th March 2008 ------------------------------- -- Fix: Crash when search field was active and changing file view mode - -Version 4.3.0 - 28th January 2008 ---------------------------------- -- Feature: Extended file view now displays also the directory/file time -- Feature: Text file viewer/editor supports also in UTF-8, UTF-16 little endian - and UTF-16 big endian formats -- Change: Opening with apparc is not anymore a default opening action but now - a list of another common actions appears -- Change: Font size in file list view has been adjusted to suit better in - currently used resolution -- Change: In first time start, extended view is activated in QHD resolution -- Change: Font size in file viewer and editor is now smaller so that more text - fits to the screen -- Change: Settings are now saved in dictionary store instead of cenreps -- Fix: Copy/move to folder functionality was broken -- Fix: Scroll bar did not work properly in text viewer when used via touch UI -- Fix: Last line of hex viewer was not warpped correctly -- Fix: Menu bars of file viewer and editor did not work properly -- Fix: Search should not return directories when searching a string -- Fix: Hash key selection should not be active in qwerty mode - -Version 4.2.0 - 14th January 2008 ---------------------------------- -- Feature: User mapped remote drives are visible in drive list view as normal - drive when setting is turned on -- Feature: Files can be edited in both text and hex modes -- Feature: Show checksums (message digests) on different algorithms for a file -- Feature: Error strings are now displayed for various operations instead of - generic error messages -- Feature: Disk can be ejected and dismounted via disk admin -- Change: Increased maximum heap usage to 32Mb to allow loading large files to - file editor -- Fix: Trying to create a directory which already exists did not return an - error -- Fix: In the file list view active item not visible when deleting last item in - the view -- Fix: Some file specific commands were visibile in menus also for directory - entries -- Fix: Utilizing secure backup leaked memory - -Version 4.1.0 - 17th December 2007 ----------------------------------- -- Feature: File operations are now started asynchronously with own recursion - handler which allows removing file locks and any protection attributes -- Feature: Status of each file operation can be monitored via RDebug -- Feature: Remove file locks via Secure Backup -- Feature: File operation functionality can be customized via the settings - dialog -- Feature: Multidrive support with erasing MBR and drive partition for drives - which support it -- Change: Remove screen capture support since the same functionality can be - done with the ScreenGrabber tool -- Fix: Forms were incorrectly constructed in search dialog and attribute editor - -Version 4.0.7 - 16th November 2007 --------------------------------- -- Feature: In the list view, left/right arrow keys can be simulated with drag to - left/right gestures -- Fix: Touch click in the listbox view -- Fix: Scroll bar in the hex/text viewer can be scrolled on a touch UI - -Version 4.0.6 - 9th October 2007 --------------------------------- -- Feature: Data type editor -- Fix: Layout in hex/text viewer in mirrored mode - -Version 4.0.5 - 27th August 2007 --------------------------------- -- Fix: Wrong functionality while moving a folder -- Change: Handle backup session while formatting a drive - -Version 4.0.4 - 23th May 2007 ------------------------------ -- Feature: Modify debug mask -- Feature: Simulate Symbian OS error types -- Feature: Enable/disable icon server cache - -Version 4.0.3 - 28th February 2007 ----------------------------------- -- Feature: Drive snapshot functionality under the main drive selection list - -Version 4.0.2 - 31st January 2007 ---------------------------------- -- Feature: Dump message store walk into a text file -- Change: Enhance hex/text viewer -- Fix: Enhance folder browsing speed in Z-drive - -Version 4.0.1 - 17th January 2007 ---------------------------------- -- Fix: Opening of search field -- Fix: Enabling extended errors if c:\resource directory does not already - exist - -=============================================================================== - -Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -All rights reserved. - -This component and the accompanying materials are made available -under the terms of "Eclipse Public License v1.0" -which accompanies this distribution, and is available -at the URL "http://www.eclipse.org/legal/epl-v10.html". diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/group/backup_registration.xml --- a/filebrowser/group/backup_registration.xml Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ - - - - - - - - diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/group/bld_generic.inf --- a/filebrowser/group/bld_generic.inf Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,48 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#include - -#ifndef FILEBROWSER_LITE - #include "../fileopserver/group/bld.inf" - #include "../fileopclient/group/bld.inf" -#endif - -PRJ_EXPORTS -../group/backup_registration.xml Z:/private/102828D6/backup_registration.xml -../rom/filebrowser.iby CORE_IBY_EXPORT_PATH(tools,filebrowser.iby) - - -PRJ_MMPFILES -#if defined(__SERIES60_30__) || defined(__SERIES60_31__) || defined(__S60_32__) - - #ifdef MARM - gnumakefile filebrowser_stub_sis.mk - #endif -#endif - -#if(!defined __SERIES60_30__ && !defined __SERIES60_31__ && !defined __S60_32__) - PRJ_EXTENSIONS - - #ifdef MARM - START EXTENSION app-services/buildstubsis - OPTION SRCDIR ../sis - OPTION SISNAME FileBrowser_stub - END - #endif -#endif diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/group/filebrowser_stub_sis.mk --- a/filebrowser/group/filebrowser_stub_sis.mk Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -# -# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# This component and the accompanying materials are made available -# under the terms of "Eclipse Public License v1.0" -# which accompanies this distribution, and is available -# at the URL "http://www.eclipse.org/legal/epl-v10.html". -# -# Initial Contributors: -# Nokia Corporation - initial contribution. -# -# Contributors: -# -# Description: -# - - -TARGETDIR=$(EPOCROOT)EPOC32\Data\Z\System\Install - -SISNAME=FileBrowser_stub -PKGNAME=FileBrowser_stub - -$(TARGETDIR) : - @perl -S emkdir.pl "$(TARGETDIR)" - -do_nothing : - rem do_nothing - -SISFILE=$(TARGETDIR)\$(SISNAME).sis - -$(SISFILE) : ..\sis\$(PKGNAME).pkg - makesis -s $? $@ - - - -MAKMAKE : do_nothing - -RESOURCE : do_nothing - -SAVESPACE : do_nothing - -BLD : do_nothing - -FREEZE : do_nothing - -LIB : do_nothing - -CLEANLIB : do_nothing - -FINAL : $(TARGETDIR) $(SISFILE) - -CLEAN : - @if exist $(SISFILE) erase $(SISFILE) - -RELEASABLES : - @echo $(SISFILE) diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/group/group.pro --- a/filebrowser/group/group.pro Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,19 +0,0 @@ -# -# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# This component and the accompanying materials are made available -# under the terms of "Eclipse Public License v1.0" -# which accompanies this distribution, and is available -# at the URL "http://www.eclipse.org/legal/epl-v10.html". -# -# Initial Contributors: -# Nokia Corporation - initial contribution. -# -# Contributors: -# -# Description: -# -# -TEMPLATE = subdirs - -BLD_INF_RULES.prj_platforms += "$${LITERAL_HASH}include \"bld_generic.inf\"" diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/icons/qgn_indi_tb_filebrowser_find.svg --- a/filebrowser/icons/qgn_indi_tb_filebrowser_find.svg Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/icons/qgn_indi_tb_filebrowser_folder_parent.svg --- a/filebrowser/icons/qgn_indi_tb_filebrowser_folder_parent.svg Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,372 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/icons/qgn_indi_tb_filebrowser_selection.svg --- a/filebrowser/icons/qgn_indi_tb_filebrowser_selection.svg Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ - - - - - - - - - - - - diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/icons/qgn_indi_tb_filebrowser_selection_active.svg --- a/filebrowser/icons/qgn_indi_tb_filebrowser_selection_active.svg Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/icons/qgn_menu_filebrowser.svg --- a/filebrowser/icons/qgn_menu_filebrowser.svg Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,454 +0,0 @@ - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/icons/qtg_indi_status_back.svg --- a/filebrowser/icons/qtg_indi_status_back.svg Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,17 +0,0 @@ - - - -]> - - - - - - diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/rom/filebrowser.iby --- a/filebrowser/rom/filebrowser.iby Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#ifndef __ORBITFILEBROWSER_IBY__ -#define __ORBITFILEBROWSER_IBY__ - -S60_APP_EXE(FileBrowser) -//S60_APP_AIF_ICONS(FileBrowser) -S60_APP_RESOURCE(FileBrowser) -SCALABLE_IMAGE(APP_BITMAP_DIR,APP_BITMAP_DIR,FileBrowser) - -//#ifdef S60_UPGRADABLE_APP_REG_RSC -// S60_UPGRADABLE_APP_REG_RSC(FileBrowser) -//#else -// S60_APP_AIF_RSC(FileBrowser) -//#endif -data=ZPRIVATE\10003a3f\import\APPS\FileBrowser_reg.RSC Private\10003a3f\import\Apps\FileBrowser_reg.rsc - -#ifndef FILEBROWSER_LITE -file=ABI_DIR\BUILD_DIR\FileBrowserFileOpServer.exe PROGRAMS_DIR\FileBrowserFileOpServer.exe -file=ABI_DIR\BUILD_DIR\FileBrowserFileOpClient.dll SHARED_LIB_DIR\FileBrowserFileOpClient.dll -#endif - -data=ZPRIVATE\102828D6\backup_registration.xml private\102828D6\backup_registration.xml -data=ZSYSTEM\Install\FileBrowser_stub.sis \system\install\FileBrowser_stub.sis - - -#endif // __ORBITFILEBROWSER_IBY__ diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/sis/FileBrowser_stub.pkg --- a/filebrowser/sis/FileBrowser_stub.pkg Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -; -; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -; All rights reserved. -; This component and the accompanying materials are made available -; under the terms of "Eclipse Public License v1.0" -; which accompanies this distribution, and is available -; at the URL "http://www.eclipse.org/legal/epl-v10.html". -; -; Initial Contributors: -; Nokia Corporation - initial contribution. -; -; Contributors: -; -; Description: -; - - -; Language - standard language definitions -&EN - -; Standard SIS file header -#{"FileBrowser"},(0x102828D6),1,0,0 - -; Non-localised vendor name -:"Nokia Corporation" - -; Localised vendor names -%{"Nokia Corporation"} - -; normal stuff: -""-"z:\sys\bin\FileBrowser.exe" -""-"z:\Resource\Apps\FileBrowser.mif" -""-"z:\Resource\Apps\FileBrowser.rsc" -""-"z:\private\10003a3f\import\apps\FileBrowser_reg.rsc" -""-"z:\private\102828D6\backup_registration.xml" - -""-"z:\sys\bin\FileBrowserFileOpServer.exe" -""-"z:\sys\bin\FileBrowserFileOpClient.dll" diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/ui/inc/enginewrapper.h --- a/filebrowser/ui/inc/enginewrapper.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,198 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef ENGINEWRAPPER_H -#define ENGINEWRAPPER_H - -#include "fbdriveentry.h" -#include "fbfileentry.h" -#include "filebrowsersettings.h" - -#include "engine.h" -#include "FBFileUtils.h" -#include "FB.hrh" - -#include -#include -#include - -class CEngine; -class SearchAttributes; -class SearchResults; -class FileBrowserView; -class HbProgressDialog; - -class QModelIndex; - -class OverwriteOptions -{ -public: - OverwriteOptions() : - doFileOperations(true), - queryIndex(0), - overWriteFlags(CFileMan::EOverWrite) - {} - - bool doFileOperations; - int queryIndex; - QString postFix; - int overWriteFlags; -}; - -/** - * class that is used for communicating between Symbian and Qt code. - */ -class EngineWrapper : public QObject, public MFileBrowserUI -{ - Q_OBJECT -public: - /** - * Constructor - */ - EngineWrapper(); - - /** - * Destructor - */ - ~EngineWrapper(); - - /** - * Initializes Engine Wrapper - * @return true if engine was started successfully - */ - bool init(); - -public: // from MFileBrowserUI - /* Functions that are called from engine: */ - void ShowInformationNote(const TDesC &aDescText, const TDesC &aDescTitle); - void ShowErrorNote(const TDesC& aDescText, TBool aNoTimeout = EFalse); - void ShowConfirmationNote(const TDesC& aDescText, TBool aNoTimeout = EFalse); - - void ShowProgressDialog(const TDesC& aDescText, TInt aMinimum, TInt aMaximum); - void CancelProgressDialog(); - void SetProgressValue(TInt aValue); - - void ShowWaitDialog(const TDesC& aText); - void CancelWaitDialog(); - void ProcessEvents(); - - TBool ShowConfirmationQuery(const TDesC& aDescText); - void NotifyModelHasChanged(); - -public: - /* Functions that are called from UI */ - bool searchFiles(); - SearchAttributes getFileSearchAttributes(); - int setFileSearchAttributes(SearchAttributes attributes); - SearchResults getSearchResults(); - - FileBrowserSettings &settings() { return mSettings; } - const FileBrowserSettings &settings() const { return mSettings; } - - void saveSettings(bool aNotifyModules = true); - - void startExecutingCommands(const QString &aCommandsExecutionMessage); - void refreshView(); - inline TListingMode listingMode() { return mEngine->FileUtils()->ListingMode(); } -// TBool IsCurrentDriveReadOnly(); -// TBool IsCurrentItemDirectory(); - void moveUpOneLevel(); - void moveDownToDirectory(const QModelIndex& index); - int clipboardCut(const QModelIndexList &aSelectionIndices); - int clipboardCopy(const QModelIndexList &aSelectionIndices); - void clipboardPaste(const OverwriteOptions &aOverwriteOptions); - void copyToFolder(const QString &aTargetDir, const OverwriteOptions &aOverwriteOptions, bool aMove); - void createNewFile(const QString &aNewFileName); - void createNewDirectory(const QString &aNewDirectoryName); - void deleteItems(const QModelIndexList& aSelectionIndices); - bool selectionHasDirs(); - void rename(const QModelIndex& aIndex, const QString aNewName); - void touch(bool aRecurse); - void properties(const QModelIndex &aCurrentItemIndex, QStringList &aPropertyList, QString &aTitleText); - void setAttributes(quint32 &, quint32 &, bool &); - - bool openAppArc(QString fileName); - bool openDocHandler(QString fileName, bool embeddedVal = false); - - bool isDriveListViewActive(); - bool isCurrentDriveReadOnly(); - bool isClipBoardListInUse(); - int itemCount() const; - FbDriveEntry getDriveEntry(const QModelIndex& aIndex) const; - FbFileEntry getFileEntry(const QModelIndex& aIndex) const; - - const CArrayFix *convertSelectionList(const QModelIndexList &aSelectionIndices); - void setCurrentSelection(const QModelIndexList &aSelectionIndices); - bool isDestinationEntriesExists(const QModelIndexList &aSelectionIndices, QString aTargetDir); - bool targetExists(const QModelIndex& aIndex, const QString aNewName); - QString currentPath() const; - TOverwriteOptions convertOverwriteOptions(const OverwriteOptions &aOverwriteOptions); - bool hasDrivePassword(const QModelIndex &aIndex); - bool isDriveRemovable(const QModelIndex &aIndex); - bool isDriveLocked(const QModelIndex &aIndex); - void GetDriveName(const QModelIndex &aIndex, QString &aDriveName); - void GetDriveVolumeLabel(const QModelIndex &aIndex, QString &aDriveName); - - void DiskAdminSetDrivePassword(const QModelIndex &aIndex, const QString &aOldPassword, const QString &aNewPassword); - void DiskAdminUnlockDrive(const QModelIndex &aIndex, const QString &aOldPassword); - void DiskAdminClearDrivePassword(const QModelIndex &aIndex, const QString &aOldPassword); - void DiskAdminEraseDrivePassword(const QModelIndex &aIndex); - void DiskAdminFormatDrive(const QModelIndex &aIndex, bool aQuickFormat); - void DiskAdminQuickFormatDrive(const QModelIndex &aIndex, bool aQuickFormat); - void DiskAdminCheckDisk(const QModelIndex &aIndex); - void DiskAdminScanDrive(const QModelIndex &aIndex); - void DiskAdminSetDriveName(const QModelIndex &aIndex, const QString &aDriveName); - void DiskAdminSetDriveVolumeLabel(const QModelIndex &aIndex, const QString &aVolumeLabel); - void DiskAdminEjectDrive(const QModelIndex &aIndex); - void DiskAdminDismountDrive(const QModelIndex &aIndex); - void DiskAdminEraseMBR(const QModelIndex &aIndex); - void DiskAdminPartitionDrive(const QModelIndex &aIndex, bool aEraseMBR, int aAmountOfPartitions); - - void ToolsSetErrRd(bool aEnable); - bool ErrRdFileExists(); - - void ToolsErrorSimulateLeave(int aLeaveCode); - void ToolsErrorSimulatePanic(QString aPanicCategory, int aPanicCode); - void ToolsErrorSimulateException(int aExceptionCode); - - quint32 getDebugMask(); - void toolsSetDebugMask(quint32 aDbgMask); - - void toolsWriteAllFiles(); - - void showFileCheckSums(const QModelIndex &aIndex, TFileBrowserCmdFileChecksums checksumType); - - TClipBoardMode getClipBoardMode() { return mEngine->FileUtils()->GetClipBoardMode(); } - -signals: - void fileSystemDataChanged(); - -private slots: - void progressDialogCancelled(); - void waitDialogCancelled(); - -private: - // FB engine - CEngine *mEngine; - // List of found files results for Ui - QStringList mFilesFound; - FileBrowserSettings mSettings; - HbProgressDialog *mProgressDialog; - HbProgressDialog *mWaitDialog; - }; - -#endif //ENGINEWRAPPER_H diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/ui/inc/fbattributesview.h --- a/filebrowser/ui/inc/fbattributesview.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,64 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef FBATTRIBUTESVIEW_H -#define FBATTRIBUTESVIEW_H - -#include - -class HbDataForm; -class HbDataFormModelItem; - -class FbAttributesView : public HbView -{ - Q_OBJECT - -public: - FbAttributesView(quint32 &, quint32 &, bool &); - virtual ~FbAttributesView(); - - quint32 &setAttributesMask() { return mSetAttributesMask; } - quint32 &clearAttributesMask() { return mClearAttributesMask; } - bool &recurse() { return mRecurse; } - -signals: - void finished(bool ok); - -public slots: - void accept(); - void reject(); - -private: - void initDataForm(); - void createToolbar(); - void loadSettings(); - void saveSettings(); - -private: - quint32 mSetAttributesMask; - quint32 mClearAttributesMask; - bool mRecurse; - - HbDataForm *mForm; - HbDataFormModelItem *mArchiveItem; - HbDataFormModelItem *mHiddenItem; - HbDataFormModelItem *mReadOnlyItem; - HbDataFormModelItem *mSystemItem; - HbDataFormModelItem *mRecurseItem; -}; - -#endif // FBATTRIBUTESVIEW_H diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/ui/inc/fbdriveentry.h --- a/filebrowser/ui/inc/fbdriveentry.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef FBDRIVEENTRY_H -#define FBDRIVEENTRY_H - -#include "FBFileUtils.h" -#include -#include - - -/** - * class that is used for communicating between Symbian and Qt code. - */ -class FbDriveEntry { - -public: - - /** - * Constructor - */ - FbDriveEntry(TDriveEntry aDriveEntry); - - /** - * Destructor - */ - ~FbDriveEntry(); - - /* Functions that are called from UI */ -public: - QChar driveLetter(); - int number(); - QString mediaTypeString(); - QString attributesString(); - int iconId(); - qint64 volumeInfoFree(); - qint64 volumeInfoSize(); - -private: - TDriveEntry mDriveEntry; - }; - -#endif //FBDRIVEENTRY_H diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/ui/inc/fbdrivelistviewitem.h --- a/filebrowser/ui/inc/fbdrivelistviewitem.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,65 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef FBDRIVELISTVIEWITEMS_H -#define FBDRIVELISTVIEWITEMS_H - -#include - -#include -#include - -class HbAbstractViewItem; -class HbLabel; -class HbCheckBox; -class HbWidget; - -class QGraphicsLinearLayout; -class QModelIndex; -class QGraphicsItem; - -class FbDriveListViewItem : public HbListViewItem -{ - Q_OBJECT - -public: - FbDriveListViewItem( QGraphicsItem *parent = 0 ); - ~FbDriveListViewItem(); - - virtual bool canSetModelIndex(const QModelIndex &index) const; - virtual HbAbstractViewItem *createItem(); - virtual void updateChildItems(); - -private slots: - void setCheckedState( int state ); - -private: - virtual void polish(HbStyleParameters& params); - -private: - void init(); - - QGraphicsLinearLayout *hLayout; - - HbLabel *mDiskNameLabel; - HbLabel *mSizeLabel; - HbLabel *mFreeLabel; - //HbCheckBox *mCheckBox; - HbLabel *mIconLabel; -}; - -#endif // FBDRIVELISTVIEWITEMS_H diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/ui/inc/fbdrivemodel.h --- a/filebrowser/ui/inc/fbdrivemodel.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef FBDRIVEMODELH_H_ -#define FBDRIVEMODELH_H_ - -#include "fbdriveentry.h" - -#include -#include - -// Forward declarations -class EngineWrapper; -class QModelIndex; -class QFileIconProvider; -class QObject; - -class FbDriveModel : public QAbstractListModel -{ - Q_OBJECT - -public: - explicit FbDriveModel(EngineWrapper *engineWrapper, QObject *parent = 0); - virtual ~FbDriveModel(); - - int rowCount(const QModelIndex &parent = QModelIndex()) const; - QVariant data(const QModelIndex &index, int role) const; - QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; - - FbDriveEntry driveEntry(const QModelIndex &index) const; - QString driveLetter( const QModelIndex &index ) const; - QString mediaTypeString(const QModelIndex &index) const; - -private: - EngineWrapper *mEngineWrapper; - QFileIconProvider *mFileIconProvider; -}; - - - -#endif /* FBDRIVEMODELH_H_ */ diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/ui/inc/fbdriveview.h --- a/filebrowser/ui/inc/fbdriveview.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,244 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef FBDRIVEVIEWH_H_ -#define FBDRIVEVIEWH_H_ - -#include "menuaction.h" -#include "enginewrapper.h" - -#include -#include - -#include - -// Forward declarations -class QFileInfo; -class QSignalMapper; -class QItemSelection; -class QString; -class QGraphicsLinearLayout; - -class HbListView; -class HbListWidget; -class HbToolBar; -class HbLabel; -class HbDialog; -class HbAbstractViewItem; -class HbMenu; -class HbSearchPanel; - -class EditorView; -class SearchView; -class SettingsView; -class EngineWrapper; -class FbDriveModel; -class FileBrowserSortFilterProxyModel; - -class FbDriveView : public HbView -{ - Q_OBJECT - -public: - explicit FbDriveView(); - virtual ~FbDriveView(); - void init(EngineWrapper *engineWrapper); - -public slots: - void refreshList(); - -private: - void openListDialog(const QStringList &items, const QString &titleText, QObject *receiver, const char *member); - - void openPropertyDialog(const QStringList &propertyList, const QString &title); - - QModelIndex currentItemIndex(); - void storeSelectedItemsOrCurrentItem(); - - // Menu related methods - void createMenu(); - void createFileMenu(); - void createEditMenu(); - void createViewMenu(); - void createToolsMenu(); - - void createSettingsMenuItem(); - void createAboutMenuItem(); - void createExitMenuItem(); - - void createContextMenu(); - void createFileContextMenu(); - void createEditContextMenu(); - void createViewContextMenu(); - void createDiskAdminContextMenu(); - -private slots: - // menu action slots - // file menu - void fileOpenDrive(); - void fileSearch(); - - void fileProperties(); - - void fileSetAttributes(); - - // edit menu - void editSnapShotToE(); - - // view menu - void viewRefresh(); - - // disk admin menu - void diskAdminSetDrivePassword(); - void diskAdminSetDrivePasswordNew(HbAction *); - void doDiskAdminSetDrivePassword(HbAction *); - - void diskAdminUnlockDrive(); - void doDiskAdminUnlockDrive(HbAction *); - - void diskAdminClearDrivePassword(); - void doDiskAdminClearDrivePassword(HbAction *); - - void diskAdminEraseDrivePassword(); - void doDiskAdminEraseDrivePassword(int); - - void diskAdminFormatDrive(); - void doDiskAdminFormatDrive(int); - - void diskAdminQuickFormatDrive(); - void doDiskAdminQuickFormatDrive(int); - - void diskAdminCheckDisk(); - - void diskAdminScanDrive(); - void doDiskAdminScanDrive(int); - - void diskAdminSetDriveName(); - void doDiskAdminSetDriveName(HbAction *); - - void diskAdminSetDriveVolumeLabel(); - void doDiskAdminSetDriveVolumeLabel(HbAction *); - - void diskAdminEjectDrive(); - void diskAdminDismountDrive(); - void doDiskAdminDismountDrive(int); - - void diskAdminEraseMBR(); - void doDiskAdminEraseMBR(int); - void doDiskAdminReallyEraseMBR(int); - void doDiskAdminNotRemovableReallyEraseMBR(int); - - void diskAdminPartitionDrive(); - void diskAdminPartitionDriveProceed(int); - void diskAdminPartitionDriveReallyProceed(int); - void diskAdminPartitionDriveIsNotRemovable(int); - void diskAdminPartitionDriveEraseMbr(int); - void diskAdminPartitionDriveGetCount(HbAction *); - - // tools menu - void toolsAllAppsToTextFile(); - void toolsAllFilesToTextFile(); -// void toolsAvkonIconCacheEnable(); -// void toolsAvkonIconCacheDisable(); - - void toolsDisableExtendedErrors(); - void toolsDumpMsgStoreWalk(); - void toolsEditDataTypes(); - void toolsEnableExtendedErrors(); - - void toolsErrorSimulateLeave(); - void doToolsErrorSimulateLeave(HbAction *); - - void toolsErrorSimulatePanic(); - void doToolsErrorSimulatePanicCode(HbAction *); - void doToolsErrorSimulatePanic(HbAction *); - - void toolsErrorSimulateException(); - void doToolsErrorSimulateException(HbAction *); - -// void toolsLocalConnectivityActivateInfrared(); -// void toolsLocalConnectivityLaunchBTUI(); -// void toolsLocalConnectivityLaunchUSBUI(); - void toolsMessageInbox(); - void toolsMessageDrafts(); - void toolsMessageSentItems(); - void toolsMessageOutbox(); - void toolsMemoryInfo(); - void toolsSecureBackStart(); - void toolsSecureBackRestore(); - void toolsSecureBackStop(); - void toolsSetDebugMaskQuestion(); - void toolsSetDebugMask(HbAction *); - void toolsShowOpenFilesHere(); - - // main menu items - void about(); - -signals: - void aboutToShowFileView(); - void aboutToShowSettingsView(); - void aboutToShowEditorView(const QString &, bool); - void aboutToShowSearchView(const QString &); - void aboutToSimulateLeave(int); - -private slots: - void updateOptionMenu(); - void updateContextMenu(); - void selectionChanged(const QItemSelection &, const QItemSelection &); - void activated(const QModelIndex& index); - - void onLongPressed(HbAbstractViewItem *, QPointF); - -private: - EngineWrapper *mEngineWrapper; - - HbListView *mListView; - HbLabel *mNaviPane; - - QGraphicsLinearLayout *mMainLayout; - - // file info contains all needed information of selected file from file model - QModelIndexList mClipboardIndexes; - QModelIndexList mSelectionIndexes; - - FbDriveModel *mFbDriveModel; - OptionMenuActions mOptionMenuActions; - ContextMenuActions mContextMenuActions; - HbMenu *mContextMenu; - - // flags - bool mLocationChanged; - // flag for removing source file after copied to target file - bool mRemoveFileAfterCopied; - bool mClipBoardInUse; - bool mFolderContentChanged; - QModelIndex mCurrentIndex; - - // temporarily storage - QString mOldPassword; - QString mPanicCategory; - QString mAbsoluteFilePath; - OverwriteOptions mOverwriteOptions; - QModelIndex mModelIndex; - QString mNewFileName; - bool mProceed; - bool mEraseMBR; -}; - - - -#endif /* FBDRIVEVIEWH_H_ */ diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/ui/inc/fbeditorview.h --- a/filebrowser/ui/inc/fbeditorview.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,70 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef FBEDITORVIEW_H -#define FBEDITORVIEW_H - -#include - -class HbTextEdit; -class HbAction; - -class FbEditorView : public HbView -{ - Q_OBJECT - -public: - FbEditorView(); - ~FbEditorView(); - void open(const QString& fileName, bool flagReadOnly); - -signals: - void finished(bool ok); - -private slots: - void backButtonClicked(); - void displayInText(); - void displayInHex(); - void updateMenu(); - - /* - void newFile(); - bool save(); - bool saveAs(); - void about(); - void documentWasModified(); - */ - - -private: - void loadFile(const QString &fileName); - void createMenu(); - - // editor - HbTextEdit *mTextEdit; - // if flag true, file is currently in hex format - bool mFileHex; - bool mFlagReadOnly; - QString mFileName; - QString mFileContent; - - HbAction* mToTextAction; - HbAction* mToHexAction; - HbAction* mExitAction; -}; - -#endif // FBEDITORVIEW_H diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/ui/inc/fbfileentry.h --- a/filebrowser/ui/inc/fbfileentry.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,72 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef FILEEENTRY_H -#define FILEEENTRY_H - -#include "FBFileUtils.h" -#include -#include -#include - -/** - * class that is used for communicating between Symbian and Qt code. - */ -class FbFileEntry -{ -public: - /** - * Constructor - */ - FbFileEntry(TFileEntry aFileEntry); - - /** - * Destructor - */ - ~FbFileEntry(); - - /* Functions that are called from UI */ -public: - QString fullName(); - QString path(); - - int attributes(); - QString attributesString(); - bool isArchive() { return mFileEntry.iEntry.IsArchive(); } - bool isHidden() { return mFileEntry.iEntry.IsHidden(); } - bool isReadOnly() { return mFileEntry.iEntry.IsReadOnly(); } - bool isSystem() { return mFileEntry.iEntry.IsSystem(); } - - int size(); - QString sizeString(); - -// QDateTime modified(); - QString modifiedString(); -// int Uid(int id); - bool isDir(); - QString name(); - - int dirEntries(); - QString dirEntriesString(); - - int iconId(); - -private: - TFileEntry mFileEntry; - }; - -#endif //FBFILEEENTRY_H diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/ui/inc/fbfilelistviewitem.h --- a/filebrowser/ui/inc/fbfilelistviewitem.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,65 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef FBFILELISTVIEWITEM_H -#define FBFILELISTVIEWITEM_H - -#include - -#include -#include - -class HbAbstractViewItem; -class HbLabel; -class HbCheckBox; -class HbWidget; - -class QGraphicsLinearLayout; -class QModelIndex; -class QGraphicsItem; - -class FbFileListViewItem : public HbListViewItem -{ - Q_OBJECT - -public: - FbFileListViewItem( QGraphicsItem *parent = 0 ); - ~FbFileListViewItem(); - - virtual bool canSetModelIndex(const QModelIndex &) const; - virtual HbAbstractViewItem *createItem(); - virtual void updateChildItems(); - -private slots: - void setCheckedState(int state); - -private: - virtual void polish(HbStyleParameters &); - -private: - void init(); - - QGraphicsLinearLayout *hLayout; - - HbLabel *mDiskNameLabel; - HbLabel *mSizeLabel; - HbLabel *mFreeLabel; - //HbCheckBox *mCheckBox; - HbLabel *mIconLabel; -}; - -#endif // FBFILELISTVIEWITEM_H diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/ui/inc/fbfilemodel.h --- a/filebrowser/ui/inc/fbfilemodel.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef FBFILEMODELH_H_ -#define FBFILEMODELH_H_ - -#include - -// Forward declarations -class EngineWrapper; -class QModelIndex; -class QFileIconProvider; - -class FbFileModel : public QAbstractListModel -{ - Q_OBJECT - -public: - explicit FbFileModel(EngineWrapper *engineWrapper, QObject *parent = 0); - virtual ~FbFileModel(); - - int rowCount(const QModelIndex &parent = QModelIndex()) const; - QVariant data(const QModelIndex &index, int role) const; - QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; - -private: - EngineWrapper *mEngineWrapper; - QFileIconProvider *mFileIconProvider; -}; - - - -#endif /* FBFILEMODELH_H_ */ diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/ui/inc/fbfileview.h --- a/filebrowser/ui/inc/fbfileview.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,256 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef FBFILEVIEWH_H_ -#define FBFILEVIEWH_H_ - -#include "menuaction.h" -#include "enginewrapper.h" - -#include -#include - -#include - -// Forward declarations -class QFileInfo; -class QSignalMapper; -class QItemSelection; -class QString; -class QGraphicsLinearLayout; - -class HbListView; -class HbListWidget; -class HbToolBar; -class HbLabel; -class HbDialog; -class HbAbstractViewItem; -class HbMenu; -class HbSearchPanel; - -class FbEditorView; -class SearchView; -class SettingsView; -class EngineWrapper; -class FbFileModel; -class FileBrowserSortFilterProxyModel; - -class FbFileView : public HbView -{ - Q_OBJECT - -public: - explicit FbFileView(); - virtual ~FbFileView(); - void init(EngineWrapper *engineWrapper); - -public slots: - void refreshList(); - -private: - void fileOverwriteDialog(); - void openListDialog(const QStringList &items, const QString &titleText, QObject *receiver, const char *member); - - void openPropertyDialog(const QStringList &propertyList, const QString &title); - - void storeSelectedItemsOrCurrentItem(); - QModelIndex currentItemIndex(); - - // Menu related methods - void createMenu(); - void createFileMenu(); - void createEditMenu(); - void createViewMenu(); - void createToolsMenu(); - - void createSelectionMenuItem(); - void createSettingsMenuItem(); - void createAboutMenuItem(); - void createExitMenuItem(); - - void createContextMenu(); - void createFileContextMenu(); - void createEditContextMenu(); - void createViewContextMenu(); - void createToolBar(); - -private slots: - // menu action slots - // file menu - void fileBackMoveUp(); - void fileOpenDirectory(); - void fileSearch(); - - void fileNewFile(); - void doFileNewFile(HbAction *); - - void fileNewDirectory(); - void doFileNewDirectory(HbAction *); - - void fileDelete(); - void doFileDelete(int); - - void fileRename(); - void doFileRename(HbAction *); - void doFileRenameFileExist(int); - - void fileTouch(); - void doFileTouch(int); - void fileProperties(); - - void fileChecksumsMD5(); - void fileChecksumsMD2(); - void fileChecksumsSHA1(); - void fileChecksums(TFileBrowserCmdFileChecksums checksumType); - - void fileSetAttributes(); - - // edit menu - void editSnapShotToE(); - void editCut(); - void editCopy(); - void editPaste(); - - void editCopyToFolder(); - void doEditCopyToFolder(int); - - void editMoveToFolder(); - void doEditMoveToFolder(int); - - void editSelect(); - void editUnselect(); - void editSelectAll(); - void editUnselectAll(); - - // view menu - void viewFilterEntries(); - void filterCriteriaChanged(const QString &); - void clearFilterCriteria(); - void viewRefresh(); - - // tools menu - void toolsAllAppsToTextFile(); - void toolsAllFilesToTextFile(); -// void toolsAvkonIconCacheEnable(); -// void toolsAvkonIconCacheDisable(); - - void toolsDisableExtendedErrors(); - void toolsDumpMsgStoreWalk(); - void toolsEditDataTypes(); - void toolsEnableExtendedErrors(); - - void toolsErrorSimulateLeave(); - void doToolsErrorSimulateLeave(HbAction *); - - void toolsErrorSimulatePanic(); - void doToolsErrorSimulatePanicCode(HbAction *); - void doToolsErrorSimulatePanic(HbAction *); - - void toolsErrorSimulateException(); - void doToolsErrorSimulateException(HbAction *); - -// void toolsLocalConnectivityActivateInfrared(); -// void toolsLocalConnectivityLaunchBTUI(); -// void toolsLocalConnectivityLaunchUSBUI(); - void toolsMessageInbox(); - void toolsMessageDrafts(); - void toolsMessageSentItems(); - void toolsMessageOutbox(); - void toolsMemoryInfo(); - void toolsSecureBackStart(); - void toolsSecureBackRestore(); - void toolsSecureBackStop(); - void toolsSetDebugMaskQuestion(); - void toolsSetDebugMask(HbAction *); - void toolsShowOpenFilesHere(); - - // main menu items - void selectionModeChanged(); - void about(); - -signals: - void aboutToShowDriveView(); - void aboutToShowSettingsView(); - void aboutToShowEditorView(const QString &, bool); - void aboutToShowSearchView(const QString &); - void aboutToShowAttributesView(const QString &, quint32 &, quint32 &, bool &); - void aboutToSimulateLeave(int); - -private slots: - void updateOptionMenu(); - void updateContextMenu(); - void selectionChanged(const QItemSelection &, const QItemSelection &); - void activated(const QModelIndex& index); - void activateSelectionMode(); - void deActivateSelectionMode(); - void onLongPressed(HbAbstractViewItem *, QPointF); - - void fileOpen(HbAction *); - void fileOverwrite(HbAction *); - void fileOverwritePostfix(HbAction *); - -private: - // Internal methods - void proceedFileRename(); - void proceedFileTouch(bool recurse); - -private: - EngineWrapper *mEngineWrapper; - - HbListView *mListView; - HbToolBar *mToolBar; - HbLabel *mNaviPane; - HbSearchPanel *mSearchPanel; - - QGraphicsLinearLayout *mMainLayout; - - // file info contains all needed information of selected file from file model - QModelIndexList mClipboardIndexes; - QModelIndexList mSelectionIndexes; - - FbFileModel *mFbFileModel; - FileBrowserSortFilterProxyModel *mSortFilterProxyModel; - OptionMenuActions mOptionMenuActions; - ContextMenuActions mContextMenuActions; - HbMenu *mContextMenu; - HbAction *mToolbarBackAction; - HbAction* mToolbarFilterAction; - HbAction *mToolbarPasteAction; - - // flags - bool mItemHighlighted; - bool mLocationChanged; - // flag for removing source file after copied to target file - bool mRemoveFileAfterCopied; - bool mClipBoardInUse; - bool mFolderContentChanged; - QModelIndex mCurrentIndex; - - // temporarily storage - QString mOldPassword; - QString mPanicCategory; - QString mAbsoluteFilePath; - OverwriteOptions mOverwriteOptions; - QModelIndex mModelIndex; - QString mNewFileName; - bool mProceed; - bool mEraseMBR; -}; - - - -#endif /* FBFILEVIEWH_H_ */ diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/ui/inc/fbfolderselectiondialog.h --- a/filebrowser/ui/inc/fbfolderselectiondialog.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,76 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef FBFOLDERSELECTIONDIALOG_H_ -#define FBFOLDERSELECTIONDIALOG_H_ - -#include - -// forward declarations -class FbFolderSelectorWrapper; -class HbListWidget; -class HbListWidgetItem; -class HbLabel; -class QFileIconProvider; - -class FbFolderSelectionDialog : public HbDialog -{ - Q_OBJECT - -public: - explicit FbFolderSelectionDialog(QGraphicsItem *parent = 0); - virtual ~FbFolderSelectionDialog(); - - QString selectedFolder(); - -private: - void init(); - void createHeading(); - void createList(); - void createToolBar(); - -private slots: - void activated(HbListWidgetItem *); - void refreshView(); - void moveUpPressed(); - -protected: - HbLabel *mTitle; - -private: - HbListWidget *mFolderList; - FbFolderSelectorWrapper *mFolderSelectorWrapper; - QFileIconProvider *mFileIconProvider; -}; - -class FbCopyToFolderSelectionDialog : public FbFolderSelectionDialog -{ - Q_OBJECT - -public: - explicit FbCopyToFolderSelectionDialog(QGraphicsItem *parent = 0); -}; - -class FbMoveToFolderSelectionDialog : public FbFolderSelectionDialog -{ - Q_OBJECT - -public: - explicit FbMoveToFolderSelectionDialog(QGraphicsItem *parent = 0); -}; - -#endif // FBFOLDERSELECTIONDIALOG_H_ diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/ui/inc/fbfolderselectorwrapper.h --- a/filebrowser/ui/inc/fbfolderselectorwrapper.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,71 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef FBFOLDERSELECTORWRAPPER_H_ -#define FBFOLDERSELECTORWRAPPER_H_ - -#include "fbdriveentry.h" -#include "fbfileentry.h" -#include "FBFolderSelector.h" - -#include -#include -#include - -class CEngine; -class SearchAttributes; -class SearchResults; -class FileBrowserView; -class HbProgressDialog; - -class QModelIndex; -class CFileBrowserFolderSelector; -class EngineWrapper; - - -/** - * class that is used for communicating between Symbian and Qt code. - */ -class FbFolderSelectorWrapper : public QObject, public MFolderSelectorUI -{ - Q_OBJECT -public: - FbFolderSelectorWrapper(); - ~FbFolderSelectorWrapper(); - - bool init(); - - QString currentPath() const; - bool isDriveListViewActive() const; - int itemCount() const; - FbDriveEntry getDriveEntry(const int aIndex) const; - FbFileEntry getFileEntry(const int aIndex) const; - - void moveDownToDirectory(int); - void moveUpOneLevel(); - -signals: - void FolderSelectionChanged(); - -public: // From MFolderSelectorUI - virtual void InformFolderSelectionChanged(); - -private: - CFileBrowserFolderSelector *mDestinationFolderSelector; -}; - -#endif // FBFOLDERSELECTORWRAPPER_H_ diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/ui/inc/fbmainwindow.h --- a/filebrowser/ui/inc/fbmainwindow.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef FBMAINWINDOW_H_ -#define FBMAINWINDOW_H_ - -#include - -class HbApplication; -class HbView; - -class EngineWrapper; -class FbDriveView; -class FbFileView; -class FbSettingsView; -class FbEditorView; -class FbSearchView; -class FbAttributesView; - -class FbMainWindow : public HbMainWindow -{ - Q_OBJECT - -public: - explicit FbMainWindow(QWidget *parent = 0); - virtual ~FbMainWindow(); - - void init(); - -private slots: - void openPreviousBrowserView(); - void openFileBrowserView(bool); - void openDriveView(); - void openFileView(); - void openSettingsView(); - void openEditorView(const QString &, bool); - void openSearchView(const QString &); - - void openAttributesView(const QString &, quint32 &, quint32 &, bool &); - void closeAttributesView(bool); - -private: - EngineWrapper *mEngineWrapper; - FbDriveView *mDriveView; - FbFileView *mFileView; - FbSettingsView *mSettingsView; - FbEditorView *mEditorView; - FbSearchView *mSearchView; - FbAttributesView *mAttributesView; - HbView *mPreviousView; -}; - -#endif /* FBMAINWINDOW_H_ */ diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/ui/inc/fbsearchview.h --- a/filebrowser/ui/inc/fbsearchview.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,106 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef FBSEARCHVIEW_H -#define FBSEARCHVIEW_H - -#include - -#include - -class QStringList; - -class EngineWrapper; -class HbDataForm; -class HbDataFormModelItem; -class HbProgressDialog; - -/** - * Settings class that is used for - */ -class SearchAttributes -{ -public: - QString mSearchDir; - QString mWildCards; - QString mTextInFile; - int mMinSize; - int mMaxSize; - QDate mMinDate; - QDate mMaxDate; - bool mRecurse; - bool mDefaultWildCard; -}; - -/** - * search results class. - */ -class SearchResults -{ -public: - int mNumberOfFoundFiles; - QStringList *mFoundFilesList; -}; - -class FbSearchView : public HbView -{ - Q_OBJECT - -public: - explicit FbSearchView(EngineWrapper &engineWrapper); - ~FbSearchView(); - void open(const QString &path); - -signals: - void finished(bool ok); - -private slots: - void accept(); - void reject(); - -private: - void initDataForm(); - void createToolbar(); - void loadAttributes(); - void readFormItems(); - - void startFileSearch(); - void fileSearchResults(); - -private: - /* EngineWrapper */ - EngineWrapper &mEngineWrapper; - - /* Search attributes */ - SearchAttributes mAttributes; - /* Search results */ - SearchResults mResults; - - HbDataForm *mForm; - HbDataFormModelItem *mSearchFileNameItem; - HbDataFormModelItem *mWildCardItem; - HbDataFormModelItem *mHasString; - HbDataFormModelItem *mRecurse; - HbDataFormModelItem *mMinSize; - HbDataFormModelItem *mMaxSize; - HbDataFormModelItem *mMinDate; - HbDataFormModelItem *mMaxDate; - QString mPath; - HbProgressDialog *mProgressDialog; -}; - -#endif // FBSEARCHVIEW_H diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/ui/inc/fbsettingsview.h --- a/filebrowser/ui/inc/fbsettingsview.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,79 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef FBSETTINGSVIEW_H -#define FBSETTINGSVIEW_H - -#include - -class HbDataForm; -class HbDataFormModelItem; -class EngineWrapper; -class FileBrowserSettings; - -class FbSettingsView : public HbView -{ - Q_OBJECT - -public: - FbSettingsView(EngineWrapper &engineWrapper); - virtual ~FbSettingsView(); - - void initDataForm(); -signals: - void finished(bool ok); - -public slots: -// void displayModeChanged(); -// void fileViewChanged(); -// void subDirectoryInfoChanged(); -// void associatedIconsChanged(); -// void rememberFolderOnExitChanged(); -// void rememberLastFolderChanged(); -// void showToolbarChanged(); - -// void toggleChange(QModelIndex, QModelIndex); - void accept(); - void reject(); - -private: - void createToolbar(); - void constructMenu(); - void loadSettings(const FileBrowserSettings &settings); - void saveSettings(FileBrowserSettings &settings); - -private: - EngineWrapper &mEngineWrapper; - - HbDataForm *mForm; - HbDataFormModelItem *mDisplayModeItem; - HbDataFormModelItem *mFileViewItem; - HbDataFormModelItem *mShowDirectoryInfoItem; - HbDataFormModelItem *mShowAssociatedIconsItem; - HbDataFormModelItem *mRememberFolderOnExitItem; - HbDataFormModelItem *mRememberLastFolderItem; - HbDataFormModelItem *mShowToolbarItem; - - HbDataFormModelItem *mSupportNetDrivesItem; //"Support net drives" - HbDataFormModelItem *mBypassPlatformSecurityItem; //"Bypass plat.security" - HbDataFormModelItem *mUnlockFilesViaSBItem; //"Unlock files via SB" - HbDataFormModelItem *mIgnoreProtectionAttributesItem; //"Ign. protection atts" - HbDataFormModelItem *mNoROAttributeCopyFromZItem; //"No RO-att copy from Z:" - -}; - -#endif // FBSETTINGSVIEW_H diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/ui/inc/filebrowsersettings.h --- a/filebrowser/ui/inc/filebrowsersettings.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,78 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef FILEBROWSERSETTINGS_H_ -#define FILEBROWSERSETTINGS_H_ - -#include "engine.h" -#include "enginewrapper.h" - -#include - -/** - * Settings class that is used for ui settings handling - */ -class FileBrowserSettings -{ -public: - FileBrowserSettings(TFileBrowserSettings *aSettings) : mSettings(aSettings) { } - ~FileBrowserSettings() { } - - int displayMode() const { return mSettings->iDisplayMode; } - void setDisplayMode(int displayMode) { mSettings->iDisplayMode = displayMode; } - - int fileViewMode() const { return mSettings->iFileViewMode; } - void setFileViewMode(int fileViewMode) { mSettings->iFileViewMode = fileViewMode; } - - bool showSubDirectoryInfo() const { return mSettings->iShowSubDirectoryInfo; } - void setShowSubDirectoryInfo(bool showSubDirectoryInfo) { mSettings->iShowSubDirectoryInfo = showSubDirectoryInfo; } - - bool showAssociatedIcons() const { return mSettings->iShowAssociatedIcons; } - void setShowAssociatedIcons(bool showAssociatedIcons) { mSettings->iShowAssociatedIcons = showAssociatedIcons; } - - bool rememberLastPath() const { return mSettings->iRememberLastPath; } - void setRememberLastPath(bool rememberLastPath) { mSettings->iRememberLastPath = rememberLastPath; } - - QString lastPath() const { return QString((QChar*)mSettings->iLastPath.Ptr(),mSettings->iLastPath.Length()); } - void lastPath(const QString& lastPath) { mSettings->iLastPath = lastPath.utf16(); } - - bool rememberFolderSelection() const { return mSettings->iRememberFolderSelection; } - void setRememberFolderSelection(bool rememberFolderSelection) { mSettings->iRememberFolderSelection = rememberFolderSelection; } - - bool enableToolbar() const { return mSettings->iEnableToolbar; } - void setEnableToolbar(bool enableToolbar) { mSettings->iEnableToolbar = enableToolbar; } - - bool supportNetworkDrives() const { return mSettings->iSupportNetworkDrives; } - void setSupportNetworkDrives(bool supportNetworkDrives) { mSettings->iSupportNetworkDrives = supportNetworkDrives; } - - bool bypassPlatformSecurity() const { return mSettings->iBypassPlatformSecurity; } - void setBypassPlatformSecurity(bool bypassPlatformSecurity) { mSettings->iBypassPlatformSecurity = bypassPlatformSecurity; } - - bool removeFileLocks() const { return mSettings->iRemoveFileLocks; } - void setRemoveFileLocks(bool removeFileLocks) { mSettings->iRemoveFileLocks = removeFileLocks; } - - bool ignoreProtectionsAttributes() const { return mSettings->iIgnoreProtectionsAtts; } - void setIgnoreProtectionsAttributes(bool ignoreProtectionsAttributes) { mSettings->iIgnoreProtectionsAtts = ignoreProtectionsAttributes; } - - bool removeROMWriteProrection() const { return mSettings->iRemoveROMWriteProrection; } - void setRemoveROMWriteProrection(bool removeROMWriteProrection) { mSettings->iRemoveROMWriteProrection = removeROMWriteProrection; } - -private: - TFileBrowserSettings *mSettings; -}; - -#endif /* FILEBROWSERSETTINGS_H_ */ diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/ui/inc/filebrowsersortfilterproxymodel.h --- a/filebrowser/ui/inc/filebrowsersortfilterproxymodel.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef FILEBROWSERSORTFILTERPROXYMODEL_H -#define FILEBROWSERSORTFILTERPROXYMODEL_H - -#include -#include - -class FileBrowserSortFilterProxyModel : public QSortFilterProxyModel -{ - Q_OBJECT - -public: - FileBrowserSortFilterProxyModel(QObject *parent = 0); - - QString filterCriteria() const { return mFilterCriteria; } - void setFilterCriteria(const QString &criteria); - -protected: - bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const; - -private: - QString mFilterCriteria; -}; - -#endif // FILEBROWSERSORTFILTERPROXYMODEL_H diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/ui/inc/menuaction.h --- a/filebrowser/ui/inc/menuaction.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,331 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef MENUACTION_H -#define MENUACTION_H - -class HbMenu; -class HbAction; - -class OptionMenuActions -{ -public: - OptionMenuActions() : - mFileMenu(0), - mFileBackMoveUp(0), - mFileOpenDrive(0), - mFileOpenDirectory(0), - mFileSearch(0), - mFileNewMenu(0), - mFileNewFile(0), - mFileNewDirectory(0), - mFileDelete(0), - mFileRename(0), - mFileTouch(0), - mFileProperties(0), - mFileChecksumsMenu(0), - mFileChecksumsMD5(0), - mFileChecksumsMD2(0), - mFileChecksumsSHA1(0), - mFileSetAttributes(0), - //Edit - - mEditMenu(0), - mEditSnapShotToE(0), - mEditCut(0), - mEditCopy(0), - mEditPaste(0), - mEditCopyToFolder(0), - mEditMoveToFolder(0), - mEditSelect(0), - mEditUnselect(0), - mEditSelectAll(0), - mEditUnselectAll(0), - // View - - mViewMenu(0), - mViewFilterEntries(0), - mViewRefresh(0), - // Disk admin - - mDiskAdminMenu(0), - mDiskAdminSetDrivePassword(0), - mDiskAdminUnlockDrive(0), - mDiskAdminClearDrivePassword(0), - mDiskAdminEraseDrivePassword(0), - mDiskAdminFormatDrive(0), - mDiskAdminQuickFormatDrive(0), - mDiskAdminCheckDisk(0), - mDiskAdminScanDrive(0), - mDiskAdminSetDriveName(0), - mDiskAdminSetDriveVolumeLabel(0), - mDiskAdminEjectDrive(0), - mDiskAdminDismountDrive(0), - mDiskAdminEraseMBR(0), - mDiskAdminPartitionDrive(0), - // Tools - - mToolsMenu(0), - mToolsAllAppsToTextFile(0), - mToolsAllFilesToTextFile(0), - mToolsAvkonIconCacheMenu(0), - mToolsAvkonIconCacheEnable(0), - mToolsAvkonIconCacheDisable(0), - mToolsDisableExtendedErrors(0), - mToolsDumpMsgStoreWalk(0), - mToolsEditDataTypes(0), - mToolsEnableExtendedErrors(0), - mToolsErrorSimulateMenu(0), - mToolsErrorSimulateLeave(0), - mToolsErrorSimulatePanic(0), - mToolsErrorSimulateException(0), - mToolsMessageAttachmentsMenu(0), - mToolsMessageInbox(0), - mToolsMessageDrafts(0), - mToolsMessageSentItems(0), - mToolsMessageOutbox(0), - mToolsLocalConnectivityMenu(0), - mToolsLocalConnectivityActivateInfrared(0), - mToolsLocalConnectivityLaunchBTUI(0), - mToolsLocalConnectivityLaunchUSBUI(0), - mToolsMemoryInfo(0), - mToolsSecureBackupMenu(0), - mToolsSecureBackStart(0), - mToolsSecureBackRestore(0), - mToolsSecureBackStop(0), - mToolsSetDebugMask(0), - mToolsShowOpenFilesHere(0), - mSelection(0), - mSetting(0), - mAbout(0), - mExit(0) - { - - } - - ~OptionMenuActions() { } -public: - //File menu operations - HbMenu *mFileMenu; - HbAction *mFileBackMoveUp; - HbAction *mFileOpenDrive; - HbAction *mFileOpenDirectory; - HbAction *mFileSearch; - HbMenu *mFileNewMenu; - HbAction *mFileNewFile; - HbAction *mFileNewDirectory; - HbAction *mFileDelete; - HbAction *mFileRename; - HbAction *mFileTouch; - HbAction *mFileProperties; - HbMenu *mFileChecksumsMenu; - HbAction *mFileChecksumsMD5; - HbAction *mFileChecksumsMD2; - HbAction *mFileChecksumsSHA1; - HbAction *mFileSetAttributes; - - //Edit - - HbMenu *mEditMenu; - HbAction *mEditSnapShotToE; - HbAction *mEditCut; - HbAction *mEditCopy; - HbAction *mEditPaste; - HbAction *mEditCopyToFolder; - HbAction *mEditMoveToFolder; - HbAction *mEditSelect; - HbAction *mEditUnselect; - HbAction *mEditSelectAll; - HbAction *mEditUnselectAll; - - // View - - HbMenu *mViewMenu; - HbAction *mViewFilterEntries; - HbAction *mViewRefresh; - - // Disk admin - - HbMenu *mDiskAdminMenu; - HbAction *mDiskAdminSetDrivePassword; - HbAction *mDiskAdminUnlockDrive; - HbAction *mDiskAdminClearDrivePassword; - HbAction *mDiskAdminEraseDrivePassword; - HbAction *mDiskAdminFormatDrive; - HbAction *mDiskAdminQuickFormatDrive; - HbAction *mDiskAdminCheckDisk; - HbAction *mDiskAdminScanDrive; - HbAction *mDiskAdminSetDriveName; - HbAction *mDiskAdminSetDriveVolumeLabel; - HbAction *mDiskAdminEjectDrive; - HbAction *mDiskAdminDismountDrive; - HbAction *mDiskAdminEraseMBR; - HbAction *mDiskAdminPartitionDrive; - - // Tools - - HbMenu *mToolsMenu; - HbAction *mToolsAllAppsToTextFile; - HbAction *mToolsAllFilesToTextFile; - - HbMenu *mToolsAvkonIconCacheMenu; - HbAction *mToolsAvkonIconCacheEnable; - HbAction *mToolsAvkonIconCacheDisable; - - HbAction *mToolsDisableExtendedErrors; - HbAction *mToolsDumpMsgStoreWalk; - HbAction *mToolsEditDataTypes; - - HbAction *mToolsEnableExtendedErrors; - - HbMenu *mToolsErrorSimulateMenu; - HbAction *mToolsErrorSimulateLeave; - HbAction *mToolsErrorSimulatePanic; - HbAction *mToolsErrorSimulateException; - - HbMenu *mToolsMessageAttachmentsMenu; - HbAction *mToolsMessageInbox; - HbAction *mToolsMessageDrafts; - HbAction *mToolsMessageSentItems; - HbAction *mToolsMessageOutbox; - - HbMenu *mToolsLocalConnectivityMenu; - HbAction *mToolsLocalConnectivityActivateInfrared; - HbAction *mToolsLocalConnectivityLaunchBTUI; - HbAction *mToolsLocalConnectivityLaunchUSBUI; - - HbAction *mToolsMemoryInfo; - - HbMenu *mToolsSecureBackupMenu; - HbAction *mToolsSecureBackStart; - HbAction *mToolsSecureBackRestore; - HbAction *mToolsSecureBackStop; - - HbAction *mToolsSetDebugMask; - HbAction *mToolsShowOpenFilesHere; - - HbAction *mSelection; - HbAction *mSetting; - HbAction *mAbout; - HbAction *mExit; -}; - - -class ContextMenuActions -{ -public: - ContextMenuActions() : - mOpenDirectory(0), - mSearch(0), - //File - - mFileMenu(0), - mFileBackMoveUp(0), - mFileOpenDrive(0), - mFileOpenDirectory(0), - mFileSearch(0), - mFileNewMenu(0), - mFileNewFile(0), - mFileNewDirectory(0), - mFileDelete(0), - mFileRename(0), - mFileTouch(0), - mFileProperties(0), - mFileChecksumsMenu(0), - mFileChecksumsMD5(0), - mFileChecksumsMD2(0), - mFileChecksumsSHA1(0), - mFileSetAttributes(0), - //Edit - - mEditMenu(0), -// mEditSnapShotToE(0), - mEditCut(0), - mEditCopy(0), - mEditPaste(0), - mEditCopyToFolder(0), - mEditMoveToFolder(0), - // View - -// mViewMenu(0), -// mViewFilterEntries(0), -// mViewRefresh(0), - // Disk admin - - mDiskAdminMenu(0), - mDiskAdminSetDrivePassword(0), - mDiskAdminUnlockDrive(0), - mDiskAdminClearDrivePassword(0), - mDiskAdminEraseDrivePassword(0), - mDiskAdminFormatDrive(0), - mDiskAdminQuickFormatDrive(0), - mDiskAdminCheckDisk(0), - mDiskAdminScanDrive(0), - mDiskAdminSetDriveName(0), - mDiskAdminSetDriveVolumeLabel(0), - mDiskAdminEjectDrive(0), - mDiskAdminDismountDrive(0), - mDiskAdminEraseMBR(0), - mDiskAdminPartitionDrive(0) - { - - } - - ~ContextMenuActions() { } -public: - HbAction *mOpenDirectory; - HbAction *mSearch; - //File menu operations - HbMenu *mFileMenu; - HbAction *mFileBackMoveUp; - HbAction *mFileOpenDrive; - HbAction *mFileOpenDirectory; - HbAction *mFileSearch; - HbMenu *mFileNewMenu; - HbAction *mFileNewFile; - HbAction *mFileNewDirectory; - HbAction *mFileDelete; - HbAction *mFileRename; - HbAction *mFileTouch; - HbAction *mFileProperties; - HbMenu *mFileChecksumsMenu; - HbAction *mFileChecksumsMD5; - HbAction *mFileChecksumsMD2; - HbAction *mFileChecksumsSHA1; - HbAction *mFileSetAttributes; - - //Edit - - HbMenu *mEditMenu; -// HbAction *mEditSnapShotToE; - HbAction *mEditCut; - HbAction *mEditCopy; - HbAction *mEditPaste; - HbAction *mEditCopyToFolder; - HbAction *mEditMoveToFolder; - -// // View - -// HbMenu *mViewMenu; -// HbAction *mViewFilterEntries; -// HbAction *mViewRefresh; - - // Disk admin - - HbMenu *mDiskAdminMenu; - HbAction *mDiskAdminSetDrivePassword; - HbAction *mDiskAdminUnlockDrive; - HbAction *mDiskAdminClearDrivePassword; - HbAction *mDiskAdminEraseDrivePassword; - HbAction *mDiskAdminFormatDrive; - HbAction *mDiskAdminQuickFormatDrive; - HbAction *mDiskAdminCheckDisk; - HbAction *mDiskAdminScanDrive; - HbAction *mDiskAdminSetDriveName; - HbAction *mDiskAdminSetDriveVolumeLabel; - HbAction *mDiskAdminEjectDrive; - HbAction *mDiskAdminDismountDrive; - HbAction *mDiskAdminEraseMBR; - HbAction *mDiskAdminPartitionDrive; -}; - -#endif // MENUACTION_H diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/ui/inc/notifications.h --- a/filebrowser/ui/inc/notifications.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef NOTIFICATIONS_H_ -#define NOTIFICATIONS_H_ - -#include - -class HbProgressDialog; - -class Notifications -{ -public: - static void showAboutNote(); - static void showMessageBox(HbMessageBox::MessageBoxType type, const QString &text, const QString &label, int timeout = HbPopup::NoTimeout); - static void showInformationNote(const QString &text, const QString &title = QString()); - static void showErrorNote(const QString &text, bool noTimeout = false); - static void showConfirmationNote(const QString &text, bool noTimeout = false); - static bool showConfirmationQuery(const QString &aText); -}; - -#endif // NOTIFICATIONS_H_ diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/ui/src/enginewrapper.cpp --- a/filebrowser/ui/src/enginewrapper.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,828 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include "enginewrapper.h" -#include "engine.h" -#include "FBFileUtils.h" -#include "notifications.h" -#include "fbfileview.h" -#include "fbsearchview.h" -#include "filebrowsersettings.h" -//#include "fbsettingsview.h" - -#include - -#include -#include -#include - -// --------------------------------------------------------------------------- - -EngineWrapper::EngineWrapper() - : mEngine(0), - mFilesFound(), - mSettings(0), - mProgressDialog(0), - mWaitDialog(0) -{ -} - -// --------------------------------------------------------------------------- - -EngineWrapper::~EngineWrapper() -{ - if(mEngine != NULL) { - TRAP_IGNORE(mEngine->DeActivateEngineL()); - delete mEngine; - } - if (mProgressDialog) - delete mProgressDialog; - - if (mWaitDialog) - delete mWaitDialog; -} - -// --------------------------------------------------------------------------- - -bool EngineWrapper::init() -{ - TRAPD(err, mEngine = CEngine::NewL(this)); - if (err != KErrNone) { - return false; - } else { - TRAP_IGNORE(mEngine->ActivateEngineL()); - mSettings = FileBrowserSettings(&mEngine->Settings()); - return true; - } -} - -// --------------------------------------------------------------------------- -// Functions that are called from UI -// --------------------------------------------------------------------------- -bool EngineWrapper::searchFiles() -{ - TRAPD(err, mEngine->SearchL() ); - if(err != KErrNone) { - return false; - } - else { - return true; - } -} - -// --------------------------------------------------------------------------- -SearchAttributes EngineWrapper::getFileSearchAttributes() -{ - TSearchAttributes tAttributes = mEngine->GetSearchAttributes(); - SearchAttributes attributes; - - // Convert TSearchAttributes to SearchAttributes - attributes.mSearchDir = QString((QChar*)tAttributes.iSearchDir.Ptr(),tAttributes.iSearchDir.Length()); - attributes.mWildCards = QString((QChar*)tAttributes.iWildCards.Ptr(),tAttributes.iWildCards.Length()); - attributes.mTextInFile = QString((QChar*)tAttributes.iTextInFile.Ptr(),tAttributes.iTextInFile.Length()); - attributes.mMinSize = tAttributes.iMinSize; - attributes.mMaxSize = tAttributes.iMaxSize; - attributes.mRecurse = tAttributes.iRecurse; - attributes.mDefaultWildCard = tAttributes.iDefaultWildCard; - - // TTime to QDate - TBuf<20> timeString; - _LIT(KDateString,"%D%M%Y%/0%1%/1%2%/2%3%/3"); - TRAP_IGNORE( tAttributes.iMinDate.FormatL(timeString, KDateString) ); - QString temp = QString::fromUtf16(timeString.Ptr(), timeString.Length()); - temp.replace(QChar('/'), QChar('-')); - attributes.mMinDate = QDate::fromString(temp, "dd-MM-yyyy"); - - - TRAP_IGNORE( tAttributes.iMaxDate.FormatL(timeString, KDateString) ); - temp = QString::fromUtf16(timeString.Ptr(), timeString.Length()); - temp.replace(QChar('/'), QChar('-')); - attributes.mMaxDate = QDate::fromString(temp, "dd-MM-yyyy"); - - return attributes; - -} - -// --------------------------------------------------------------------------- -int EngineWrapper::setFileSearchAttributes(SearchAttributes attributes) -{ - TSearchAttributes tAttributes; - // Convert SearchAttributes to TSearchAttributes - - //convert QString to TFilename: - tAttributes.iSearchDir = TFileName(attributes.mSearchDir.utf16()); - tAttributes.iWildCards = TFileName(attributes.mWildCards.utf16()); - tAttributes.iTextInFile = TFileName(attributes.mTextInFile.utf16()); - - tAttributes.iMinSize = attributes.mMinSize; - tAttributes.iMaxSize = attributes.mMaxSize; - tAttributes.iRecurse = attributes.mRecurse; - tAttributes.iDefaultWildCard = attributes.mDefaultWildCard; - - // QDate to TTime for both min- and max Date - QString temp = attributes.mMinDate.toString("yyyy-MM-dd"); - QStringList dateList = temp.split("-"); - int month = dateList[1].toInt() - 1; - int day = dateList[2].toInt() - 1; - temp = dateList[0]; - if (month == 0) { - temp.append("00"); - } - else { - temp.append(QString::number(month)); - } - if (day == 0) { - temp.append("00"); - } - else { - temp.append(QString::number(day)); - } - temp.append(":"); - - TBuf<24> dateString(temp.utf16()); - tAttributes.iMinDate.Set(dateString); - - temp = attributes.mMaxDate.toString("yyyy-MM-dd"); - dateList = temp.split("-"); - month = dateList[1].toInt() - 1; - day = dateList[2].toInt() - 1; - temp = dateList[0]; - if (month == 0) { - temp.append("00"); - } - else { - temp.append(QString::number(month)); - } - if (day == 0) { - temp.append("00"); - } - else { - temp.append(QString::number(day)); - } - temp.append(":"); - dateString.Copy(temp.utf16()); - tAttributes.iMaxDate.Set(dateString); - - mEngine->ChangeAttributes(tAttributes); - return KErrNone; -} - - -// --------------------------------------------------------------------------- -SearchResults EngineWrapper::getSearchResults() -{ - TSearchResults tResults = mEngine->SearchResults(); - SearchResults results; - results.mNumberOfFoundFiles = tResults.iNumberOfFoundFiles; - CFileEntryList* foundFilesResult = mEngine->FoundFiles(); - if (!mFilesFound.isEmpty()) { - mFilesFound.clear(); - } - // copy file names and convert them from TFileName format to QStringList items type - for (int i = 0; i < foundFilesResult->Count(); i++) { - mFilesFound.append( - QString((QChar*)foundFilesResult->At(i).iFullName.Ptr(), - foundFilesResult->At(i).iFullName.Length()) - ); - } - results.mFoundFilesList = &mFilesFound; - return results; -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::saveSettings(bool aNotifyModules) -{ - return mEngine->SaveSettingsL(aNotifyModules);; -} - -// --------------------------------------------------------------------------- - -bool EngineWrapper::isDriveListViewActive() -{ - // TODO check return value - if (mEngine->FileUtils() && mEngine->FileUtils()->IsDriveListViewActive()) { - return true; - } else { - return false; - } -} - -bool EngineWrapper::isCurrentDriveReadOnly() -{ - // TODO check return value - if (mEngine->FileUtils() && mEngine->FileUtils()->IsCurrentDriveReadOnly()) { - return true; - } else { - return false; - } -} - -bool EngineWrapper::isClipBoardListInUse() -{ - if (mEngine->FileUtils() && mEngine->FileUtils()->ClipBoardList() && mEngine->FileUtils()->ClipBoardList()->Count() != 0) - return true; - else - return false; -} - -// --------------------------------------------------------------------------- -void EngineWrapper::startExecutingCommands(const QString &aCommandsExecutionMessage) -{ - TPtrC commandsExecutionMessage(reinterpret_cast(aCommandsExecutionMessage.constData())); - TRAPD(err, mEngine->FileUtils()->StartExecutingCommandsL(commandsExecutionMessage) ); - Q_UNUSED(err); //TODO -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::refreshView() -{ - if (mEngine->FileUtils()) { - TRAPD(err, mEngine->FileUtils()->RefreshViewL() ); - Q_UNUSED(err); //TODO - } -} - -void EngineWrapper::moveUpOneLevel() -{ - if (mEngine->FileUtils()) { - TRAPD(err, mEngine->FileUtils()->MoveUpOneLevelL() ); - Q_UNUSED(err); //TODO - } -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::moveDownToDirectory(const QModelIndex& aIndex) -{ - if (mEngine->FileUtils()) { - TRAPD(err, mEngine->FileUtils()->MoveDownToDirectoryL(aIndex.row()) ); - Q_UNUSED(err); //TODO - } -} - -// --------------------------------------------------------------------------- - -int EngineWrapper::clipboardCut(const QModelIndexList& aSelectionIndices) -{ - TInt operations = 0; - const CArrayFix *selectionIndexes = convertSelectionList(aSelectionIndices); - if (mEngine->FileUtils()) { - TRAPD(err, operations = mEngine->FileUtils()->ClipboardCutL(selectionIndexes) ); - Q_UNUSED(err); //TODO - } - delete selectionIndexes; - return operations; -} - -// --------------------------------------------------------------------------- -int EngineWrapper::clipboardCopy(const QModelIndexList& aSelectionIndices) -{ - TInt operations = 0; - const CArrayFix *selectionIndexes = convertSelectionList(aSelectionIndices); - - if (mEngine->FileUtils()) { - TRAPD(err, operations = mEngine->FileUtils()->ClipboardCopyL(selectionIndexes)); - Q_UNUSED(err); //TODO - } - delete selectionIndexes; - return operations; -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::clipboardPaste(const OverwriteOptions &aOverwriteOptions) -{ - TOverwriteOptions tOverwriteOptions = convertOverwriteOptions(aOverwriteOptions); - if (mEngine->FileUtils()) { - TRAPD(err, mEngine->FileUtils()->ClipboardPasteL(tOverwriteOptions)); - Q_UNUSED(err); //TODO - } -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::copyToFolder(const QString &aTargetDir, const OverwriteOptions &aOverwriteOptions, bool aMove) -{ - TFileName targetDir = TFileName(aTargetDir.utf16()); - TOverwriteOptions tOverwriteOptions = convertOverwriteOptions(aOverwriteOptions); - - - TRAPD(err, mEngine->FileUtils()->CopyToFolderL(targetDir, tOverwriteOptions, aMove ? ETrue : EFalse) ); - Q_UNUSED(err); //TODO -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::createNewFile(const QString &aNewFileName) -{ - TFileName fileName = TFileName(aNewFileName.utf16()); - TRAPD(err, mEngine->FileUtils()->NewFileL(fileName) ); - Q_UNUSED(err); //TODO -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::createNewDirectory(const QString &aNewDirectoryName) -{ - TFileName newDirectoryName = TFileName(aNewDirectoryName.utf16()); - TRAPD(err, mEngine->FileUtils()->NewDirectoryL(newDirectoryName) ); - Q_UNUSED(err); //TODO -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::deleteItems(const QModelIndexList& aSelectionIndices) -{ - setCurrentSelection(aSelectionIndices); - TRAPD(err, mEngine->FileUtils()->DeleteL() ); - Q_UNUSED(err); //TODO -} - -// --------------------------------------------------------------------------- -bool EngineWrapper::selectionHasDirs() -{ - return mEngine->FileUtils()->SelectionHasDirs(); -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::rename(const QModelIndex& aIndex, const QString aNewName) -{ - if (mEngine->FileUtils()) { - const TFileName newName = TFileName(aNewName.utf16()); - TRAPD(err, mEngine->FileUtils()->RenameL(aIndex.row(), newName) ); - Q_UNUSED(err); //TODO - } -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::touch(bool aRecurse) -{ - if (mEngine->FileUtils()) { - TRAPD(err, mEngine->FileUtils()->TouchL(aRecurse) ); - Q_UNUSED(err); //TODO - } -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::properties(const QModelIndex &aCurrentItemIndex, QStringList &aPropertyList, QString &aTitleText) -{ - if (mEngine->FileUtils()) { - - // create an array for the items - CDesCArray* entryLines = new(ELeave) CDesCArrayFlat(16); -// CleanupStack::PushL(entryLines); - TFileName titleText; - - TRAPD(err, mEngine->FileUtils()->PropertiesL(aCurrentItemIndex.row(), entryLines, titleText)); - Q_UNUSED(err); //TODO - - aTitleText = QString::fromUtf16(titleText.Ptr(), titleText.Length()); - QString textItem; - for (TInt i = 0; i < entryLines->Count(); ++i) { - textItem = QString::fromUtf16((*entryLines)[i].Ptr(), (*entryLines)[i].Length()); - aPropertyList.append(textItem); - } -// CleanupStack::PopAndDestroy(); //entryLines - delete entryLines; - } -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::setAttributes(quint32 &setAttributesMask, quint32 &clearAttributesMask, bool &recurse) -{ - if (mEngine->FileUtils()) { - TBool tRecurse = recurse ? ETrue : EFalse; - TRAPD(err, mEngine->FileUtils()->SetAttributesL(setAttributesMask, clearAttributesMask, tRecurse)); - Q_UNUSED(err); //TODO - } -} - -// --------------------------------------------------------------------------- - -bool EngineWrapper::openAppArc(QString fileName) -{ - - //convert QString to TFilename: - fileName.replace("/", "\\"); - TFileName fileToOpen = TFileName(fileName.utf16()); - - TRAPD(err, mEngine->OpenWithApparcL(fileToOpen) ); - if(err != KErrNone) { - return false; - } else { - return true; - } -} - -// --------------------------------------------------------------------------- - -bool EngineWrapper::openDocHandler(QString fileName, bool embeddedVal) -{ - //convert QString to TFilename: - fileName.replace("/", "\\"); - TFileName fileToOpen = TFileName(fileName.utf16()); - - TRAPD(err, mEngine->OpenWithDocHandlerL(fileToOpen, embeddedVal) ); - if(err != KErrNone) { - return false; - } else { - return true; - } -} - -// --------------------------------------------------------------------------- - -int EngineWrapper::itemCount() const -{ - if (mEngine->FileUtils()->IsDriveListViewActive()) { - return mEngine->FileUtils()->DriveEntries()->Count(); - } else { - return mEngine->FileUtils()->FileEntries()->Count(); - } -} - -// --------------------------------------------------------------------------- - -FbDriveEntry EngineWrapper::getDriveEntry(const QModelIndex& aIndex) const -{ - TDriveEntry driveEntry; - if (mEngine->FileUtils()->DriveEntries()->Count() > aIndex.row() && aIndex.row() >= 0) { - driveEntry = mEngine->FileUtils()->DriveEntries()->At(aIndex.row()); - } - return FbDriveEntry(driveEntry); -} - -// --------------------------------------------------------------------------- - -FbFileEntry EngineWrapper::getFileEntry(const QModelIndex& aIndex) const -{ - TFileEntry fileEntry; - if (mEngine->FileUtils()->FileEntries()->Count() > aIndex.row() && aIndex.row() >= 0) { - fileEntry = mEngine->FileUtils()->FileEntries()->At(aIndex.row()); - } - return FbFileEntry(fileEntry); -} - -// --------------------------------------------------------------------------- - -const CArrayFix *EngineWrapper::convertSelectionList(const QModelIndexList &aSelectionIndices) -{ - CArrayFixFlat* selectionIndexes = 0; - TRAPD(err, selectionIndexes = new(ELeave)CArrayFixFlat(4)); - if (err != KErrNone) { - return 0; - } - - for (int i=0; i< aSelectionIndices.count(); ++i) { - TRAPD(err, selectionIndexes->AppendL(aSelectionIndices.at(i).row()) ); - Q_UNUSED(err); //TODO - } - return selectionIndexes; -} - - -// --------------------------------------------------------------------------- - -void EngineWrapper::setCurrentSelection(const QModelIndexList &aSelectionIndices) -{ - const CArrayFix *selectionIndexes = convertSelectionList(aSelectionIndices); - mEngine->FileUtils()->SetCurrentSelection(selectionIndexes); - delete selectionIndexes; -} - -// --------------------------------------------------------------------------- - -bool EngineWrapper::isDestinationEntriesExists(const QModelIndexList &aSelectionIndices, QString aTargetDir) -{ - TFileName targetDir = TFileName(aTargetDir.utf16()); - //setCurrentSelection(aSelectionIndices); - Q_UNUSED(aSelectionIndices); - - TBool someEntryExists = mEngine->FileUtils()->IsDestinationEntriesExists(targetDir); - return someEntryExists; -} - -// --------------------------------------------------------------------------- -bool EngineWrapper::targetExists(const QModelIndex& aIndex, const QString aNewName) -{ - const TFileName newName = TFileName(aNewName.utf16()); - return mEngine->FileUtils()->TargetExists(aIndex.row(), newName); -} - -// --------------------------------------------------------------------------- - -QString EngineWrapper::currentPath() const -{ - return QString::fromUtf16(mEngine->FileUtils()->CurrentPath().Ptr(), - mEngine->FileUtils()->CurrentPath().Length()); -} - -TOverwriteOptions EngineWrapper::convertOverwriteOptions(const OverwriteOptions &aOverwriteOptions) -{ - TOverwriteOptions tOverwriteOptions; - tOverwriteOptions.iDoFileOperations = aOverwriteOptions.doFileOperations; - tOverwriteOptions.iQueryIndex = aOverwriteOptions.queryIndex; - tOverwriteOptions.iPostFix = TFileName(aOverwriteOptions.postFix.utf16()); - tOverwriteOptions.iOverWriteFlags = aOverwriteOptions.overWriteFlags; - return tOverwriteOptions; -} - -bool EngineWrapper::hasDrivePassword(const QModelIndex &aIndex) -{ - bool hasPassword = false; - if (mEngine->FileUtils()->DriveEntries()->Count() > aIndex.row() && aIndex.row() >= 0) - { - TDriveEntry driveEntry = mEngine->FileUtils()->DriveEntries()->At(aIndex.row()); - hasPassword = driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttHasPassword; - } - return hasPassword; -} - -bool EngineWrapper::isDriveRemovable(const QModelIndex &aIndex) -{ - bool isRemovable = false; - if (mEngine->FileUtils()->DriveEntries()->Count() > aIndex.row() && aIndex.row() >= 0) - { - TDriveEntry driveEntry = mEngine->FileUtils()->DriveEntries()->At(aIndex.row()); - isRemovable = driveEntry.iVolumeInfo.iDrive.iDriveAtt & KDriveAttRemovable; - } - return isRemovable; -} - -bool EngineWrapper::isDriveLocked(const QModelIndex &aIndex) -{ - bool isRemovable = false; - if (mEngine->FileUtils()->DriveEntries()->Count() > aIndex.row() && aIndex.row() >= 0) - { - TDriveEntry driveEntry = mEngine->FileUtils()->DriveEntries()->At(aIndex.row()); - isRemovable = driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttLocked; - } - return isRemovable; -} - -void EngineWrapper::GetDriveName(const QModelIndex &aIndex, QString &aDriveName) -{ - TFileName driveName; - mEngine->FileUtils()->GetDriveName(aIndex.row(), driveName); - aDriveName = QString::fromUtf16(driveName.Ptr(), driveName.Length()); -} - - -void EngineWrapper::GetDriveVolumeLabel(const QModelIndex &aIndex, QString &aVolumeLabel) -{ - TFileName volumeLabel; - mEngine->FileUtils()->GetDriveName(aIndex.row(), volumeLabel); - aVolumeLabel = QString::fromUtf16(volumeLabel.Ptr(), volumeLabel.Length()); -} - -void EngineWrapper::DiskAdminSetDrivePassword(const QModelIndex &aIndex, - const QString &aOldPassword, - const QString &aNewPassword) -{ - TFileName oldPassword = TFileName(aOldPassword.utf16()); - TFileName newPassword = TFileName(aNewPassword.utf16()); - TRAP_IGNORE(mEngine->FileUtils()->SetDrivePasswordL(aIndex.row(), oldPassword, newPassword)); -} - -void EngineWrapper::DiskAdminUnlockDrive(const QModelIndex &aIndex, const QString &aOldPassword) -{ - TFileName oldPassword = TFileName(aOldPassword.utf16()); - TRAP_IGNORE(mEngine->FileUtils()->UnlockDriveL(aIndex.row(), oldPassword)); -} - -void EngineWrapper::DiskAdminClearDrivePassword(const QModelIndex &aIndex, const QString &aOldPassword) -{ - TFileName oldPassword = TFileName(aOldPassword.utf16()); - TRAP_IGNORE(mEngine->FileUtils()->ClearDrivePasswordL(aIndex.row(), oldPassword)); -} - -void EngineWrapper::DiskAdminEraseDrivePassword(const QModelIndex &aIndex) -{ - TRAP_IGNORE(mEngine->FileUtils()->EraseDrivePasswordL(aIndex.row())); -} - -void EngineWrapper::DiskAdminFormatDrive(const QModelIndex &aIndex, bool aQuickFormat) -{ - TRAP_IGNORE(mEngine->FileUtils()->FormatDriveL(aIndex.row(), aQuickFormat)); -} - -void EngineWrapper::DiskAdminQuickFormatDrive(const QModelIndex &aIndex, bool aQuickFormat) -{ - TRAP_IGNORE(mEngine->FileUtils()->FormatDriveL(aIndex.row(), aQuickFormat)); -} - -void EngineWrapper::DiskAdminCheckDisk(const QModelIndex &aIndex) -{ - TRAP_IGNORE(mEngine->FileUtils()->CheckDiskL(aIndex.row())); -} - -void EngineWrapper::DiskAdminScanDrive(const QModelIndex &aIndex) -{ - TRAP_IGNORE(mEngine->FileUtils()->ScanDriveL(aIndex.row())); -} - -void EngineWrapper::DiskAdminSetDriveName(const QModelIndex &aIndex, const QString &aDriveName) -{ - TFileName driveName = TFileName(aDriveName.utf16()); - TRAP_IGNORE(mEngine->FileUtils()->SetDriveNameL(aIndex.row(), driveName)); -} - -void EngineWrapper::DiskAdminSetDriveVolumeLabel(const QModelIndex &aIndex, const QString &aVolumeLabel) -{ - TFileName volumeLabel = TFileName(aVolumeLabel.utf16()); - TRAP_IGNORE(mEngine->FileUtils()->SetDriveNameL(aIndex.row(), volumeLabel)); -} - -void EngineWrapper::DiskAdminEjectDrive(const QModelIndex &aIndex) -{ - TRAP_IGNORE(mEngine->FileUtils()->EjectDriveL(aIndex.row())); -} - -void EngineWrapper::DiskAdminDismountDrive(const QModelIndex &aIndex) -{ - TRAP_IGNORE(mEngine->FileUtils()->DismountFileSystemL(aIndex.row())); -} - -void EngineWrapper::DiskAdminEraseMBR(const QModelIndex &aIndex) -{ - TRAP_IGNORE(mEngine->FileUtils()->EraseMBRL(aIndex.row())); -} - -void EngineWrapper::DiskAdminPartitionDrive(const QModelIndex &aIndex, bool aEraseMBR, int aAmountOfPartitions) -{ - TRAP_IGNORE(mEngine->FileUtils()->PartitionDriveL(aIndex.row(), aEraseMBR, aAmountOfPartitions)); -} - -void EngineWrapper::ToolsSetErrRd(bool aEnable) -{ - TRAP_IGNORE(mEngine->FileUtils()->SetErrRdL(aEnable)); -} - -bool EngineWrapper::ErrRdFileExists() -{ - return mEngine->FileUtils()->FileExists(KErrRdPath); -} - -void EngineWrapper::ToolsErrorSimulateLeave(int aLeaveCode) -{ - mEngine->FileUtils()->SimulateLeaveL(aLeaveCode); -} - -void EngineWrapper::ToolsErrorSimulatePanic(QString aPanicCategory, int aPanicCode) -{ - TBuf<128> panicCategory; - panicCategory.Copy(aPanicCategory.utf16()); - mEngine->FileUtils()->SimulatePanicL(panicCategory, aPanicCode); -} - -void EngineWrapper::ToolsErrorSimulateException(int aExceptionCode) -{ - mEngine->FileUtils()->SimulateExceptionL(aExceptionCode); -} - -quint32 EngineWrapper::getDebugMask() -{ - return mEngine->FileUtils()->GetDebugMask(); -} - -void EngineWrapper::toolsSetDebugMask(quint32 aDbgMask) -{ - mEngine->FileUtils()->SetDebugMaskL(aDbgMask); -} - -void EngineWrapper::toolsWriteAllFiles() -{ - mEngine->FileUtils()->WriteAllFilesL(); -} - -void EngineWrapper::showFileCheckSums(const QModelIndex &aIndex, TFileBrowserCmdFileChecksums checksumType) -{ - mEngine->FileUtils()->ShowFileCheckSumsL(aIndex.row(), checksumType); -} - -// --------------------------------------------------------------------------- -// Functions that are called from engine -// --------------------------------------------------------------------------- - -// --------------------------------------------------------------------------- - -void EngineWrapper::ShowErrorNote(const TDesC& aDescText, TBool aNoTimeout /*= EFalse*/) -{ - QString qText = QString::fromUtf16(aDescText.Ptr(), aDescText.Length()); - Notifications::showErrorNote(qText, aNoTimeout); -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::ShowInformationNote(const TDesC &aDescText, const TDesC &aDescTitle) -{ - QString qText = QString::fromUtf16(aDescText.Ptr(), aDescText.Length()); - QString qTitle = QString::fromUtf16(aDescTitle.Ptr(), aDescTitle.Length()); - Notifications::showInformationNote(qText, qTitle); -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::ShowConfirmationNote(const TDesC& aDescText, TBool aNoTimeout /*= EFalse*/) -{ - QString qText = QString::fromUtf16(aDescText.Ptr(), aDescText.Length()); - Notifications::showConfirmationNote(qText, aNoTimeout); -} - -void EngineWrapper::ShowProgressDialog(const TDesC& aDescText, TInt aMinimum, TInt aMaximum ) -{ - const QString qText = QString::fromUtf16(aDescText.Ptr(), aDescText.Length()); - if (!mProgressDialog) { - mProgressDialog = new HbProgressDialog(HbProgressDialog::WaitDialog); - QObject::connect(mProgressDialog, SIGNAL(cancelled()), this, SLOT(progressDialogCancelled())); - } - - mProgressDialog->setText(qText); - mProgressDialog->setMinimum(aMinimum); - mProgressDialog->setMaximum(aMaximum); - mEngine->FileUtils()->SetAllowProcessing(true); - mProgressDialog->show(); -} - -void EngineWrapper::CancelProgressDialog() -{ - if (mProgressDialog) { - QObject::disconnect(mProgressDialog, SIGNAL(cancelled()), this, SLOT(progressDialogCancelled())); - mProgressDialog->cancel(); - QObject::connect(mProgressDialog, SIGNAL(cancelled()), this, SLOT(progressDialogCancelled())); - } -} - -void EngineWrapper::SetProgressValue(TInt aValue) -{ - if (mProgressDialog) - mProgressDialog->setProgressValue(aValue); -} - -void EngineWrapper::progressDialogCancelled() -{ - mEngine->FileUtils()->DialogDismissedL(); -} - -void EngineWrapper::ShowWaitDialog(const TDesC& aDescText) -{ - const QString qText = QString::fromUtf16(aDescText.Ptr(), aDescText.Length()); - if (!mWaitDialog) { - mWaitDialog = new HbProgressDialog(HbProgressDialog::WaitDialog); - QObject::connect(mWaitDialog, SIGNAL(cancelled()), this, SLOT(waitDialogCancelled())); - } - - mWaitDialog->setText(qText); - mEngine->FileUtils()->SetAllowProcessing(true); - //mWaitDialog->setAttribute(Qt::WA_DeleteOnClose); - mWaitDialog->show(); -} - -void EngineWrapper::CancelWaitDialog() -{ - if (mWaitDialog) - mWaitDialog->cancel(); -} - -void EngineWrapper::waitDialogCancelled() -{ - mEngine->FileUtils()->SetAllowProcessing(false); -} - -void EngineWrapper::ProcessEvents() -{ - qApp->processEvents(); -} - -TBool EngineWrapper::ShowConfirmationQuery(const TDesC& aDescText) -{ - QString qText = QString::fromUtf16(aDescText.Ptr(), aDescText.Length()); - return Notifications::showConfirmationQuery(qText); -} - -void EngineWrapper::NotifyModelHasChanged() -{ - emit fileSystemDataChanged(); -} - -// --------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/ui/src/fbattributesview.cpp --- a/filebrowser/ui/src/fbattributesview.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,210 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include "fbattributesview.h" - -#include -#include -#include -#include -#include -#include - -#include - -#include - -const QStringList AttributesChoices = QStringList() << "Skip" << "On" << "Off"; -const QStringList RecurseChoices = QStringList() << "Recursive" << "Non-recursive"; -const QString acceptActionText = "OK"; -const QString rejectActionText = "Cancel"; -const int AttributeOn = 1; -const int AttributeOff = 2; -const int AttributeEnableRecursion = 0; -const int AttributeDisableRecursion = 1; - -FbAttributesView::FbAttributesView(quint32 &aSetAttMask, quint32 &aClearAttMask, bool &aRecurse) : - mSetAttributesMask(aSetAttMask), - mClearAttributesMask(aClearAttMask), - mRecurse(aRecurse), - mForm(0), - mArchiveItem(0), - mHiddenItem(0), - mReadOnlyItem(0), - mSystemItem(0), - mRecurseItem(0) -{ - setTitle("Set attributes"); - - // Override back navigation action - HbAction *leaveViewAction = new HbAction(Hb::BackNaviAction, this); - connect(leaveViewAction, SIGNAL(triggered()), this, SLOT(reject())); - setNavigationAction(leaveViewAction); - - initDataForm(); - createToolbar(); -} - -FbAttributesView::~FbAttributesView() -{ -} - -void FbAttributesView::initDataForm() -{ - mForm = new HbDataForm(this); - HbDataFormModel *model = new HbDataFormModel(); - - // Create Group for sequential image components - //mGroupSeguantialCapture = model->appendDataFormGroup(QString("Archive"), parent); - - mArchiveItem = new HbDataFormModelItem(HbDataFormModelItem::RadioButtonListItem); - mArchiveItem->setLabel("Archive"); - mArchiveItem->setContentWidgetData(QString("items"), AttributesChoices); - mArchiveItem->setContentWidgetData(QString("displayMode"), QString("embedded")); - - mHiddenItem = new HbDataFormModelItem(HbDataFormModelItem::RadioButtonListItem); - mHiddenItem->setLabel("Hidden"); - mHiddenItem->setContentWidgetData(QString("items"), AttributesChoices); - mHiddenItem->setContentWidgetData(QString("displayMode"), QString("embedded")); - - mReadOnlyItem = new HbDataFormModelItem(HbDataFormModelItem::RadioButtonListItem); - mReadOnlyItem->setLabel("Read only"); - mReadOnlyItem->setContentWidgetData(QString("items"), AttributesChoices); - mReadOnlyItem->setContentWidgetData(QString("displayMode"), QString("embedded")); - - mSystemItem = new HbDataFormModelItem(HbDataFormModelItem::RadioButtonListItem); - mSystemItem->setLabel("System"); - mSystemItem->setContentWidgetData(QString("items"), AttributesChoices); - mSystemItem->setContentWidgetData(QString("displayMode"), QString("embedded")); - - mRecurseItem = new HbDataFormModelItem(HbDataFormModelItem::RadioButtonListItem); - mRecurseItem->setLabel("Recurse"); - mRecurseItem->setContentWidgetData(QString("items"), RecurseChoices); - mRecurseItem->setContentWidgetData(QString("displayMode"), QString("embedded")); - - // load file search attribute values from FB engine: - loadSettings(); - - model->appendDataFormItem(mArchiveItem); - model->appendDataFormItem(mHiddenItem); - model->appendDataFormItem(mReadOnlyItem); - model->appendDataFormItem(mSystemItem); - model->appendDataFormItem(mRecurseItem); - - mForm->setModel(model); - - QGraphicsLinearLayout* layout = new QGraphicsLinearLayout(Qt::Vertical,this); - layout->addItem(mForm); - setLayout(layout); -} - -void FbAttributesView::createToolbar() -{ - HbToolBar *toolBar = new HbToolBar(this); - HbAction *acceptAction = new HbAction(acceptActionText); - connect(acceptAction, SIGNAL(triggered()), this, SLOT(accept())); - toolBar->addAction(acceptAction); - - HbAction *rejectAction = new HbAction(rejectActionText); - connect(rejectAction, SIGNAL(triggered()), this, SLOT(reject())); - toolBar->addAction(rejectAction); - - setToolBar(toolBar); -} - -/** - Set form item values from settings \a settings. - */ -void FbAttributesView::loadSettings() -{ - if (mSetAttributesMask & KEntryAttArchive) - mArchiveItem->setContentWidgetData(QString("selected"), AttributeOn); - else if (mClearAttributesMask & KEntryAttArchive) - mArchiveItem->setContentWidgetData(QString("selected"), AttributeOff); - - if (mSetAttributesMask & KEntryAttHidden) - mHiddenItem->setContentWidgetData(QString("selected"), AttributeOn); - else if (mClearAttributesMask & KEntryAttHidden) - mHiddenItem->setContentWidgetData(QString("selected"), AttributeOff); - - if (mSetAttributesMask & KEntryAttReadOnly) - mReadOnlyItem->setContentWidgetData(QString("selected"), AttributeOn); - else if (mClearAttributesMask & KEntryAttReadOnly) - mReadOnlyItem->setContentWidgetData(QString("selected"), AttributeOff); - - if (mSetAttributesMask & KEntryAttSystem) - mSystemItem->setContentWidgetData(QString("selected"), AttributeOn); - else if (mClearAttributesMask & KEntryAttSystem) - mSystemItem->setContentWidgetData(QString("selected"), AttributeOff); - - if (mRecurse) - mRecurseItem->setContentWidgetData(QString("selected"), AttributeEnableRecursion); - else - mRecurseItem->setContentWidgetData(QString("selected"), AttributeDisableRecursion); -} - -/** - Store form item data into \a settings - */ -void FbAttributesView::saveSettings() -{ - mSetAttributesMask = 0; - mClearAttributesMask = 0; - - int archive = mArchiveItem->contentWidgetData(QString("selected")).toInt(); - if (archive == AttributeOn) - mSetAttributesMask |= KEntryAttArchive; - else if (archive == AttributeOff) - mClearAttributesMask |= KEntryAttArchive; - - int hidden = mHiddenItem->contentWidgetData(QString("selected")).toInt(); - if (hidden == AttributeOn) - mSetAttributesMask |= KEntryAttHidden; - else if (hidden == AttributeOff) - mClearAttributesMask |= KEntryAttHidden; - - int readOnly = mReadOnlyItem->contentWidgetData(QString("selected")).toInt(); - if (readOnly == AttributeOn) - mSetAttributesMask |= KEntryAttReadOnly; - else if (readOnly == AttributeOff) - mClearAttributesMask |= KEntryAttReadOnly; - - int system = mSystemItem->contentWidgetData(QString("selected")).toInt(); - if (system == AttributeOn) - mSetAttributesMask |= KEntryAttSystem; - else if (system == AttributeOff) - mClearAttributesMask |= KEntryAttSystem; - - int recurse = mRecurseItem->contentWidgetData(QString("selected")).toInt(); - if (recurse == AttributeEnableRecursion) - mRecurse = ETrue; - else if (recurse == AttributeDisableRecursion) - mRecurse = EFalse; -} - -void FbAttributesView::accept() -{ - saveSettings(); - emit finished(true); -} - -void FbAttributesView::reject() -{ - emit finished(false); -} - -// End of file diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/ui/src/fbdriveentry.cpp --- a/filebrowser/ui/src/fbdriveentry.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,82 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include "fbdriveentry.h" - -// --------------------------------------------------------------------------- - -FbDriveEntry::FbDriveEntry(TDriveEntry aDriveEntry) -: mDriveEntry(aDriveEntry) -{ -} - -// --------------------------------------------------------------------------- - -FbDriveEntry::~FbDriveEntry() -{ -} - -// --------------------------------------------------------------------------- - -QChar FbDriveEntry::driveLetter() -{ - return QChar(TUint(mDriveEntry.iLetter)); -} - -// --------------------------------------------------------------------------- - -int FbDriveEntry::number() -{ - return mDriveEntry.iNumber; -} - -// --------------------------------------------------------------------------- - -QString FbDriveEntry::mediaTypeString() -{ - return QString::fromUtf16(mDriveEntry.iMediaTypeDesc.Ptr(), mDriveEntry.iMediaTypeDesc.Length()); -} - -// --------------------------------------------------------------------------- - -QString FbDriveEntry::attributesString() -{ - return QString::fromUtf16(mDriveEntry.iAttributesDesc.Ptr(), mDriveEntry.iAttributesDesc.Length()); -} - -// --------------------------------------------------------------------------- - -int FbDriveEntry::iconId() -{ - return mDriveEntry.iIconId; -} - -// --------------------------------------------------------------------------- - -qint64 FbDriveEntry::volumeInfoFree() -{ - return mDriveEntry.iVolumeInfo.iFree; -} - -// --------------------------------------------------------------------------- - -qint64 FbDriveEntry::volumeInfoSize() -{ - return mDriveEntry.iVolumeInfo.iSize; -} - -// --------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/ui/src/fbdrivelistviewitem.cpp --- a/filebrowser/ui/src/fbdrivelistviewitem.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,173 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include "fbdrivelistviewitem.h" -#include "fbdriveentry.h" -#include "fbdrivemodel.h" - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -FbDriveListViewItem::FbDriveListViewItem(QGraphicsItem *parent) : - HbListViewItem(parent), - hLayout(0), - mDiskNameLabel(0), - mSizeLabel(0), - mFreeLabel(0), - mIconLabel(0) -{ -} - -FbDriveListViewItem::~FbDriveListViewItem() -{ -} - -void FbDriveListViewItem::polish(HbStyleParameters& params) -{ - Q_UNUSED(params); -} - -bool FbDriveListViewItem::canSetModelIndex(const QModelIndex &index) const -{ - Q_UNUSED(index); - return true; -} - - -HbAbstractViewItem *FbDriveListViewItem::createItem() -{ - return new FbDriveListViewItem(*this); -} - -void FbDriveListViewItem::updateChildItems() -{ - if(!hLayout) { - init(); - } - - // Qt::DisplayRole -// QVariant displayRole = modelIndex().data(Qt::DisplayRole); -// QString diskName("default"); - QStringList stringList; -// if (displayRole.isValid()) { -// if (displayRole.canConvert()) { // EFileViewModeSimple -// stringList.append(displayRole.toString()); -// } else if (displayRole.canConvert()) { // EFileViewModeExtended -// stringList = displayRole.toStringList(); -// } -// if (stringList.count() > 0) -// diskName = stringList[0]; //modelIndex().data( Qt::UserRole ).toString(); -// -// mDiskNameLabel->setPlainText(diskName/*displayString*/); -// } -// if (stringList.count() > 1) -// mSizeLabel->setPlainText( stringList[1] ); - - - // Get the Drive Entry - const FbDriveModel* driveModel= qobject_cast(modelIndex().model()); - FbDriveEntry driveEntry = driveModel->driveEntry(modelIndex()); - - const QString SimpleDriveEntry("%1: <%2>"); - - QString diskName = SimpleDriveEntry.arg(driveEntry.driveLetter()).arg(driveEntry.mediaTypeString()); - mDiskNameLabel->setPlainText(diskName); - - const QString ExtendedDriveEntry("%1/%2 kB"); - QString diskSize = ExtendedDriveEntry.arg(QString::number(driveEntry.volumeInfoFree()/1024)) - .arg(QString::number(driveEntry.volumeInfoSize()/1024)); - mSizeLabel->setPlainText( diskSize ); - - //mFreeLabel->setPlainText( stringList[2] ); - - // mCheckBox->setCheckState( checkState() ); - - // Qt::DecorationRole - // QTBUG-11033 No Icon provided for QFileIconProvider::Desktop, Network, Drive on Symbian - QVariant decorationRole = modelIndex().data(Qt::DecorationRole); - if (decorationRole.isValid()) { - QIcon icon = qvariant_cast(decorationRole); - if( icon.isNull() ) { - QFileIconProvider fileIconProvider; - icon = fileIconProvider.icon(QFileIconProvider::File); - } - mIconLabel->setIcon(HbIcon(icon)); - } -} - -void FbDriveListViewItem::setCheckedState(int state) -{ - HbAbstractViewItem::setCheckState(static_cast(state)); -} - -void FbDriveListViewItem::init() -{ - hLayout = new QGraphicsLinearLayout(); - hLayout->setContentsMargins(0, 0, 0, 0); - - hLayout->setOrientation( Qt::Horizontal ); - hLayout->addItem(layout()); - - mIconLabel = new HbLabel(); - hLayout->addItem( mIconLabel ); - hLayout->setAlignment( mIconLabel, Qt::AlignTop ); - hLayout->setStretchFactor( mIconLabel, 0 ); - - QGraphicsLinearLayout *vLayout = new QGraphicsLinearLayout(); - //vLayout->setContentsMargins(0, 0, 0, 0); - vLayout->setOrientation( Qt::Vertical ); - - mDiskNameLabel = new HbLabel(); - HbFontSpec fontSpecPrimary(HbFontSpec::Primary); - //fontSpecPrimary.setTextHeight(18.0); - mDiskNameLabel->setFontSpec( fontSpecPrimary ); - vLayout->addItem( mDiskNameLabel ); - vLayout->setAlignment( mDiskNameLabel, Qt::AlignLeft ); - - mSizeLabel = new HbLabel(); - HbFontSpec fontSpecSecondary(HbFontSpec::Secondary); - //fontSpecSecondary.setTextHeight(18.0); - mSizeLabel->setFontSpec(fontSpecSecondary); - vLayout->addItem( mSizeLabel ); - vLayout->setAlignment(mSizeLabel, Qt::AlignLeft); - -// mFreeLabel = new HbLabel(); -// mFreeLabel->setFontSpec( HbFontSpec( HbFontSpec::Secondary ) ); -// vLayout->addItem( mFreeLabel ); -// vLayout->setAlignment( mFreeLabel, Qt::AlignLeft ); - - HbWidget *labelsWidget = new HbWidget(); - labelsWidget->setLayout(vLayout); - - hLayout->setAlignment( labelsWidget, Qt::AlignLeft ); - - hLayout->addItem( labelsWidget ); - hLayout->setStretchFactor( labelsWidget, 1 ); - - //this->setMaximumHeight( mDiskNameLabel->preferredHeight() ); - //setMaximumHeight( mIconLabel->preferredHeight() ); - - setLayout( hLayout ); -} diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/ui/src/fbdrivemodel.cpp --- a/filebrowser/ui/src/fbdrivemodel.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,139 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include "fbdrivemodel.h" -#include "enginewrapper.h" -#include "fbdriveentry.h" -#include "filebrowsersettings.h" -#include "FB.hrh" - -#include -#include - -/** - Constructs a file browser custom system model with the given \a engineWrapper and \a parent. - */ -FbDriveModel::FbDriveModel(EngineWrapper *engineWrapper, QObject *parent) : - QAbstractListModel(parent), - mEngineWrapper(engineWrapper), - mFileIconProvider(0) -{ - mFileIconProvider = new QFileIconProvider(); -} - -/** - Destroys this file browser custom system model. - */ -FbDriveModel::~FbDriveModel() -{ - if (mFileIconProvider) { - delete mFileIconProvider; - } -} - -/** - \reimp - */ -int FbDriveModel::rowCount(const QModelIndex &parent) const -{ - Q_UNUSED(parent); - return mEngineWrapper->itemCount(); -} - -/** - \reimp - */ -QVariant FbDriveModel::data(const QModelIndex &index, int role) const -{ - if (!index.isValid() || index.model() != this) - return QVariant(); - - switch (role) { - case Qt::EditRole: - case Qt::DisplayRole: { - QStringList listItem; - FbDriveEntry driveEntry(mEngineWrapper->getDriveEntry(index)); - if (mEngineWrapper->settings().fileViewMode() == EFileViewModeSimple) - { - const QString SimpleDriveEntry("%1: <%2>"); - listItem /*<< driveEntry.IconId() */ - << SimpleDriveEntry.arg(driveEntry.driveLetter()) - .arg(driveEntry.mediaTypeString()); - } else if (mEngineWrapper->settings().fileViewMode() == EFileViewModeExtended) { - const QString SimpleDriveEntry("%1: <%2>"); - const QString ExtendedDriveEntry("%1/%2 kB"); - listItem /*<< driveEntry.IconId()*/ - << SimpleDriveEntry.arg(driveEntry.driveLetter()) - .arg(driveEntry.mediaTypeString()) - << ExtendedDriveEntry.arg(QString::number(driveEntry.volumeInfoFree()/1024)) - .arg(QString::number(driveEntry.volumeInfoSize()/1024)); - - } - return listItem; - } - case Qt::DecorationRole: { - if (mEngineWrapper) { - QIcon icon; - //TODO Drive ico has to be provided, for some reason it is not visible - icon = mFileIconProvider->icon(QFileIconProvider::Drive); - return QVariant(icon); - } - } - } - return QVariant(); -} - -/** - \reimp - */ -QVariant FbDriveModel::headerData(int section, Qt::Orientation orientation, int role) const -{ - Q_UNUSED(section); - Q_UNUSED(orientation); - Q_UNUSED(role); - - // TODO, implement or remove - return QVariant(); -} - - -FbDriveEntry FbDriveModel::driveEntry(const QModelIndex &index) const -{ - return mEngineWrapper->getDriveEntry(index); -} - -QString FbDriveModel::driveLetter(const QModelIndex &index) const -{ - QString diskLetter; - if (index.row() >= 0 && index.row() < mEngineWrapper->itemCount()) { - FbDriveEntry driveEntry(mEngineWrapper->getDriveEntry(index)); - diskLetter = driveEntry.driveLetter(); - } - return diskLetter; -} - -QString FbDriveModel::mediaTypeString(const QModelIndex &index) const -{ - QString mediaTypeString; - if (index.row() >= 0 && index.row() < mEngineWrapper->itemCount()) { - FbDriveEntry driveEntry(mEngineWrapper->getDriveEntry(index)); - mediaTypeString = driveEntry.mediaTypeString(); - } - return mediaTypeString; -} - -// --------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/ui/src/fbdriveview.cpp --- a/filebrowser/ui/src/fbdriveview.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1337 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include "fbdriveview.h" -#include "fbsettingsview.h" -#include "fbeditorview.h" -#include "fbsearchview.h" -#include "enginewrapper.h" -#include "notifications.h" - -#include "fbdrivemodel.h" -#include "filebrowsersortfilterproxymodel.h" -#include "fbdrivelistviewitem.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -//TODO check if needed to do this way -#include - -// --------------------------------------------------------------------------- - -FbDriveView::FbDriveView() : - mEngineWrapper(0), - mListView(0), - mNaviPane(0), - mMainLayout(0), - mFbDriveModel(0), - mOptionMenuActions(), - mContextMenuActions(), - mContextMenu(0), - mLocationChanged(false), - mRemoveFileAfterCopied(false), -// mClipBoardInUse(false), - mFolderContentChanged(false), - mCurrentIndex(), - mOldPassword(), - mPanicCategory(), - mAbsoluteFilePath(), - mOverwriteOptions(), - mModelIndex(), - mNewFileName(), - mProceed(false), - mEraseMBR(false) -{ - setTitle("File Browser"); - - createMenu(); - createContextMenu(); -} - -// --------------------------------------------------------------------------- - -void FbDriveView::init(EngineWrapper *engineWrapper) -{ - mEngineWrapper = engineWrapper; - - mListView = new HbListView(this); - mListView->listItemPrototype()->setStretchingStyle(HbListViewItem::StretchLandscape); - - mListView->setItemPrototype(new FbDriveListViewItem(mListView)); - - mFbDriveModel = new FbDriveModel(mEngineWrapper); - if (!mListView->model()) { - mEngineWrapper->refreshView(); - mListView->setModel(mFbDriveModel); - } - - //mListView->setRootIndex(mFileSystemModel->index(startPath)); - //mListView->setRootIndex(model->index()); - -// mListView->setScrollingStyle(HbScrollArea::PanWithFollowOn); - - connect(mListView, SIGNAL(activated(QModelIndex)), this, SLOT(activated(QModelIndex))); - connect(mListView, SIGNAL(longPressed(HbAbstractViewItem*,QPointF)), - this, SLOT(onLongPressed(HbAbstractViewItem*, QPointF))); - - mNaviPane = new HbLabel(this); - mNaviPane->setPlainText(QString(" ")); // TODO get from settings or default - //mNaviPane->setPlainText(QString(mEngineWrapper->currentPath())); - HbFontSpec fontSpec(HbFontSpec::PrimarySmall); - mNaviPane->setFontSpec(fontSpec); - - // Create layout and add list view and naviPane into layout: - mMainLayout = new QGraphicsLinearLayout(Qt::Vertical); - mMainLayout->addItem(mNaviPane); - mMainLayout->addItem(mListView); - setLayout(mMainLayout); -} - -// --------------------------------------------------------------------------- - -FbDriveView::~FbDriveView() -{ -// if (mEngineWrapper) { -// delete mEngineWrapper; -// } - if (mContextMenu) { - mContextMenu->deleteLater(); - } - - delete mFbDriveModel; - delete mListView; -} - -/** - Initial setup for options menu. - Dynamic menu update during the runtime is performed by updateOptionMenu() which - to menu's aboutToShow() signal. - */ -void FbDriveView::createMenu() -{ - createFileMenu(); - createEditMenu(); - createViewMenu(); - createToolsMenu(); - - createSettingsMenuItem(); - createAboutMenuItem(); - createExitMenuItem(); - - // menu dynamic update - connect(menu(), SIGNAL(aboutToShow()), this, SLOT(updateOptionMenu())); -} - -/** - Initial setup for File submenu - */ -void FbDriveView::createFileMenu() -{ - mOptionMenuActions.mFileMenu = menu()->addMenu("File"); - - mOptionMenuActions.mFileSearch = mOptionMenuActions.mFileMenu->addAction("Search...", this, SLOT(fileSearch())); - //mOptionMenuActions.mFileSearch->setVisible(false); - - //mOptionMenuActions.mFileNewMenu = mOptionMenuActions.mFileMenu->addMenu("New"); - - mOptionMenuActions.mFileSetAttributes = mOptionMenuActions.mFileMenu->addAction("Set attributes...", this, SLOT(fileSetAttributes())); - mOptionMenuActions.mFileSetAttributes->setVisible(false); -} - -/** - Initial setup for Edit submenu - */ -void FbDriveView::createEditMenu() -{ - mOptionMenuActions.mEditMenu = menu()->addMenu("Edit"); - - mOptionMenuActions.mEditSnapShotToE = mOptionMenuActions.mEditMenu->addAction("Snap shot to E:", this, SLOT(editSnapShotToE())); - mOptionMenuActions.mEditSnapShotToE->setVisible(false); -} - -/** - Initial setup for View submenu - */ -void FbDriveView::createViewMenu() -{ - mOptionMenuActions.mViewMenu = menu()->addMenu("View"); - //mOptionMenuActions.mViewMenu->menuAction()->setVisible(false); - - //mOptionMenuActions.mViewFilterEntries = mOptionMenuActions.mViewMenu->addAction("Filter entries", this, SLOT(viewFilterEntries())); - mOptionMenuActions.mViewRefresh = mOptionMenuActions.mViewMenu->addAction("Refresh", this, SLOT(viewRefresh())); -} - -/** - Initial setup for Tools submenu - */ -void FbDriveView::createToolsMenu() -{ - mOptionMenuActions.mToolsMenu = menu()->addMenu("Tools"); - - mOptionMenuActions.mToolsAllAppsToTextFile = mOptionMenuActions.mToolsMenu->addAction("All apps to a text file", this, SLOT(toolsAllAppsToTextFile())); - mOptionMenuActions.mToolsAllAppsToTextFile->setVisible(false); - mOptionMenuActions.mToolsAllFilesToTextFile = mOptionMenuActions.mToolsMenu->addAction("All files to a text file", this, SLOT(toolsAllFilesToTextFile())); - //mOptionMenuActions.mToolsAllFilesToTextFile->setVisible(false); - -// mOptionMenuActions.mToolsAvkonIconCacheMenu = mOptionMenuActions.mToolsMenu->addMenu("Avkon icon cache"); -// mOptionMenuActions.mToolsAvkonIconCacheMenu->menuAction()->setVisible(false); -// mOptionMenuActions.mToolsAvkonIconCacheEnable = mOptionMenuActions.mToolsAvkonIconCacheMenu->addAction("Enable", this, SLOT(toolsAvkonIconCacheEnable())); -// mOptionMenuActions.mToolsAvkonIconCacheDisable = mOptionMenuActions.mToolsAvkonIconCacheMenu->addAction("Clear and disable", this, SLOT(toolsAvkonIconCacheDisable())); - - mOptionMenuActions.mToolsDisableExtendedErrors = mOptionMenuActions.mToolsMenu->addAction("Disable extended errors", this, SLOT(toolsDisableExtendedErrors())); - mOptionMenuActions.mToolsDumpMsgStoreWalk = mOptionMenuActions.mToolsMenu->addAction("Dump msg. store walk", this, SLOT(toolsDumpMsgStoreWalk())); - mOptionMenuActions.mToolsDumpMsgStoreWalk->setVisible(false); - mOptionMenuActions.mToolsEditDataTypes = mOptionMenuActions.mToolsMenu->addAction("Edit data types", this, SLOT(toolsEditDataTypes())); - mOptionMenuActions.mToolsEditDataTypes->setVisible(false); - mOptionMenuActions.mToolsEnableExtendedErrors = mOptionMenuActions.mToolsMenu->addAction("Enable extended errors", this, SLOT(toolsEnableExtendedErrors())); - - mOptionMenuActions.mToolsErrorSimulateMenu = mOptionMenuActions.mToolsMenu->addMenu("Error simulate"); - mOptionMenuActions.mToolsErrorSimulateLeave = mOptionMenuActions.mToolsErrorSimulateMenu->addAction("Leave", this, SLOT(toolsErrorSimulateLeave())); - mOptionMenuActions.mToolsErrorSimulatePanic = mOptionMenuActions.mToolsErrorSimulateMenu->addAction("Panic", this, SLOT(toolsErrorSimulatePanic())); - mOptionMenuActions.mToolsErrorSimulatePanic->setVisible(false); - mOptionMenuActions.mToolsErrorSimulateException = mOptionMenuActions.mToolsErrorSimulateMenu->addAction("Exception", this, SLOT(toolsErrorSimulateException())); - -// mOptionMenuActions.mLocalConnectivityMenu = mOptionMenuActions.mToolsMenu->addMenu("Local connectivity"); -// mOptionMenuActions.mToolsLocalConnectivityActivateInfrared = mOptionMenuActions.mLocalConnectivityMenu->addAction("Activate infrared", this, SLOT(toolsLocalConnectivityActivateInfrared())); -// mOptionMenuActions.mToolsLocalConnectivityLaunchBTUI = mOptionMenuActions.mLocalConnectivityMenu->addAction("Launch BT UI", this, SLOT(toolsLocalConnectivityLaunchBTUI())); -// mOptionMenuActions.mToolsLocalConnectivityLaunchUSBUI = mOptionMenuActions.mLocalConnectivityMenu->addAction("Launch USB UI", this, SLOT(toolsLocalConnectivityLaunchUSBUI())); - - mOptionMenuActions.mToolsMessageAttachmentsMenu = mOptionMenuActions.mToolsMenu->addMenu("Message attachments"); - mOptionMenuActions.mToolsMessageAttachmentsMenu->menuAction()->setVisible(false); - mOptionMenuActions.mToolsMessageInbox = mOptionMenuActions.mToolsMessageAttachmentsMenu->addAction("Inbox", this, SLOT(toolsMessageInbox())); - mOptionMenuActions.mToolsMessageDrafts = mOptionMenuActions.mToolsMessageAttachmentsMenu->addAction("Drafts", this, SLOT(toolsMessageDrafts())); - mOptionMenuActions.mToolsMessageSentItems = mOptionMenuActions.mToolsMessageAttachmentsMenu->addAction("Sent items", this, SLOT(toolsMessageSentItems())); - mOptionMenuActions.mToolsMessageOutbox = mOptionMenuActions.mToolsMessageAttachmentsMenu->addAction("Outbox", this, SLOT(toolsMessageOutbox())); - - mOptionMenuActions.mToolsMemoryInfo = mOptionMenuActions.mToolsMenu->addAction("Memory info", this, SLOT(toolsMemoryInfo())); - mOptionMenuActions.mToolsMemoryInfo->setVisible(false); - - mOptionMenuActions.mToolsSecureBackupMenu = mOptionMenuActions.mToolsMenu->addMenu("Secure backup"); - mOptionMenuActions.mToolsSecureBackupMenu->menuAction()->setVisible(false); - mOptionMenuActions.mToolsSecureBackStart = mOptionMenuActions.mToolsSecureBackupMenu->addAction("Start backup", this, SLOT(toolsSecureBackStart())); - mOptionMenuActions.mToolsSecureBackRestore = mOptionMenuActions.mToolsSecureBackupMenu->addAction("Start restore", this, SLOT(toolsSecureBackRestore())); - mOptionMenuActions.mToolsSecureBackStop = mOptionMenuActions.mToolsSecureBackupMenu->addAction("Stop", this, SLOT(toolsSecureBackStop())); - - mOptionMenuActions.mToolsSetDebugMask = mOptionMenuActions.mToolsMenu->addAction("Set debug mask", this, SLOT(toolsSetDebugMaskQuestion())); - mOptionMenuActions.mToolsShowOpenFilesHere = mOptionMenuActions.mToolsMenu->addAction("Show open files here", this, SLOT(toolsShowOpenFilesHere())); - mOptionMenuActions.mToolsShowOpenFilesHere->setVisible(false); -} - -/** - Creates Setting menu item in option menu - */ -void FbDriveView::createSettingsMenuItem() -{ - mOptionMenuActions.mSetting = menu()->addAction("Settings..."); - connect(mOptionMenuActions.mSetting, SIGNAL(triggered()), this, SIGNAL(aboutToShowSettingsView())); -} - - -/** - Creates About menu item in option menu - */ -void FbDriveView::createAboutMenuItem() -{ - // about note - mOptionMenuActions.mAbout = menu()->addAction("About"); - connect(mOptionMenuActions.mAbout, SIGNAL(triggered()), this, SLOT(about())); -} - -/** - Creates Exit menu item in option menu - */ -void FbDriveView::createExitMenuItem() -{ - // application exit - mOptionMenuActions.mExit = menu()->addAction("Exit"); - connect(mOptionMenuActions.mExit, SIGNAL(triggered()), qApp, SLOT(quit())); -} - -/** - update menu: disk admin available only in device root view. edit available only in folder view - when file or folder content exist in current folder, or clipboard has copied item. - file and view menus updated every time regarding the folder content. - tools, settings, about, exit always available. - If there's remove and add operations at same time, always remove first - to keep to the correct menu items order. - */ -void FbDriveView::updateOptionMenu() -{ - bool isFileItemListEmpty = mFbDriveModel->rowCount() == 0; -// bool isDriveListViewActive = true; //mEngineWrapper->isDriveListViewActive(); - bool isNormalModeActive = true; //iModel->FileUtils()->IsNormalModeActive(); -// bool isCurrentDriveReadOnly = mEngineWrapper->isCurrentDriveReadOnly(); //iModel->FileUtils()->IsCurrentDriveReadOnly(); -// bool isCurrentItemDirectory = mEngineWrapper->getFileEntry(currentItemIndex()).isDir(); - // bool currentSelected = true; //iContainer->ListBox()->View()->ItemIsSelected(iContainer->ListBox()->View()->CurrentItemIndex()); -// bool isAllSelected = mListView->selectionModel()->selection().count() == mFbDriveModel->rowCount(); - //bool isNoneSelected = mListView->selectionModel()->selection().count() != 0; -// bool hasSelectedItems = mListView->selectionModel()->selection().count() != 0; - //bool isSelectionMode = mOptionMenuActions.mSelection && mOptionMenuActions.mSelection->isChecked(); - bool isClipBoardEmpty = !mEngineWrapper->isClipBoardListInUse(); - bool showSnapShot = false; //iModel->FileUtils()->DriveSnapShotPossible(); - - bool showEditMenu(true); - if (!showSnapShot || isFileItemListEmpty && isClipBoardEmpty) - showEditMenu = false; - else - showEditMenu = true; - - mOptionMenuActions.mEditMenu->menuAction()->setVisible(showEditMenu); - - //aMenuPane->SetItemDimmed(EFileBrowserCmdFileOpen, isFileItemListEmpty || isDriveListViewActive || isCurrentItemDirectory); - - //aMenuPane->SetItemDimmed(EFileBrowserCmdFileView, isFileItemListEmpty || !hasSelectedItems || isCurrentItemDirectory || isDriveListViewActive); - //aMenuPane->SetItemDimmed(EFileBrowserCmdFileEdit, isFileItemListEmpty || !hasSelectedItems || isCurrentItemDirectory || isDriveListViewActive); - //aMenuPane->SetItemDimmed(EFileBrowserCmdFileSendTo, isFileItemListEmpty || driveListActive || isCurrentItemDirectory); - - // TODO mOptionMenuActions.mFileCompress->setVisible(!(isCurrentDriveReadOnly || isFileItemListEmpty || !hasSelectedItems || isCurrentItemDirectory || isDriveListViewActive)); - // TODO mOptionMenuActions.mFileDecompress->setVisible(!(isCurrentDriveReadOnly || isFileItemListEmpty || !hasSelectedItems || isCurrentItemDirectory || isDriveListViewActive)); - - // TODO mOptionMenuActions.mEditSnapShotToE->setVisible(isDriveListViewActive); - - // TODO mOptionMenuActions.mViewSort->setVisible(!(!isNormalModeActive || isDriveListViewActive || isFileItemListEmpty)); - // TODO mOptionMenuActions.mViewOrder->setVisible(!(!isNormalModeActive || isDriveListViewActive || isFileItemListEmpty)); - mOptionMenuActions.mViewRefresh->setVisible(isNormalModeActive); - //mOptionMenuActions.mViewFilterEntries->setVisible(!isFileItemListEmpty); - - // TODO R_FILEBROWSER_VIEW_SORT_SUBMENU - // aMenuPane->SetItemButtonState(iModel->FileUtils()->SortMode(), EEikMenuItemSymbolOn); - - // TODO R_FILEBROWSER_VIEW_ORDER_SUBMENU - // aMenuPane->SetItemButtonState(iModel->FileUtils()->OrderMode(), EEikMenuItemSymbolOn); - - // aResourceId == R_FILEBROWSER_TOOLS_SUBMENU - bool noExtendedErrorsAllowed = mEngineWrapper->ErrRdFileExists(); - mOptionMenuActions.mToolsDisableExtendedErrors->setVisible(noExtendedErrorsAllowed); - mOptionMenuActions.mToolsEnableExtendedErrors->setVisible(!noExtendedErrorsAllowed); - -// bool infraRedAllowed = mEngineWrapper->FileExists(KIRAppPath); -// bool bluetoothAllowed = mEngineWrapper->FileExists(KBTAppPath); -// bool usbAllowed = mEngineWrapper->FileExists(KUSBAppPath); -// -// bool noLocalCon = !infraRedAllowed && !bluetoothAllowed && !usbAllowed; -// mOptionMenuActions.mToolsLocalConnectivityMenu->menuAction()->setVisible(!noLocalCon); -// -// mOptionMenuActions.mToolsLocalConnectivityActivateInfrared->setVisible(infraRedAllowed); -// mOptionMenuActions.mToolsLocalConnectivityLaunchBTUI->setVisible(bluetoothAllowed); -// mOptionMenuActions.mToolsLocalConnectivityLaunchUSBUI->setVisible(usbAllowed); -} - -void FbDriveView::createContextMenu() -{ - mContextMenu = new HbMenu(); - connect(mContextMenu, SIGNAL(aboutToShow()), this, SLOT(updateContextMenu())); - - createFileContextMenu(); - createEditContextMenu(); - createViewContextMenu(); - createDiskAdminContextMenu(); -} - - -void FbDriveView::createFileContextMenu() -{ - //mContextMenuActions.mFileMenu = mContextMenu->addMenu("File"); - - //mContextMenuActions.mFileOpenDrive = mContextMenuActions.mFileMenu->addAction("Open drive (->)", this, SLOT(fileOpenDrive())); -// mContextMenuActions.mFileSearch = mContextMenuActions.mFileMenu->addAction("Search...", this, SLOT(fileSearch())); - //mContextMenuActions.mFileSearch->setVisible(false); - - //mContextMenuActions.mFileProperties = mContextMenuActions.mFileMenu->addAction("Properties", this, SLOT(fileProperties())); - mContextMenuActions.mFileProperties = mContextMenu->addAction("Properties", this, SLOT(fileProperties())); - mContextMenuActions.mFileSearch = mContextMenu->addAction("Search...", this, SLOT(fileSearch())); - -// mContextMenuActions.mFileSetAttributes = mContextMenuActions.mFileMenu->addAction("Set attributes...", this, SLOT(fileSetAttributes())); -// mContextMenuActions.mFileSetAttributes->setVisible(false); -} - -void FbDriveView::createEditContextMenu() -{ -// mContextMenuActions.mEditMenu = mContextMenu->addMenu("Edit"); - - //mContextMenuActions.mEditSnapShotToE = mContextMenuActions.mEditMenu->addAction("Snap shot to E:", this, SLOT(editSnapShotToE())); -// mContextMenuActions.mEditSnapShotToE->setVisible(false); -// mContextMenuActions.mEditCut = mContextMenuActions.mEditMenu->addAction("Cut", this, SLOT(editCut())); -// mContextMenuActions.mEditCopy = mContextMenuActions.mEditMenu->addAction("Copy", this, SLOT(editCopy())); -// mContextMenuActions.mEditPaste = mContextMenuActions.mEditMenu->addAction("Paste", this, SLOT(editPaste())); -// mContextMenuActions.mEditCopyToFolder = mContextMenuActions.mEditMenu->addAction("Copy to folder...", this, SLOT(editCopyToFolder())); -// mContextMenuActions.mEditMoveToFolder = mContextMenuActions.mEditMenu->addAction("Move to folder...", this, SLOT(editMoveToFolder())); -} - -void FbDriveView::createViewContextMenu() -{ - -} - -/** - Initial setup for Disk Admin submenu - */ -void FbDriveView::createDiskAdminContextMenu() -{ - mContextMenuActions.mDiskAdminMenu = mContextMenu->addMenu("Disk admin"); - //mContextMenuActions.mDiskAdminMenu->menuAction()->setVisible(false); - - mContextMenuActions.mDiskAdminSetDrivePassword = mContextMenuActions.mDiskAdminMenu->addAction("Set drive password", this, SLOT(diskAdminSetDrivePassword())); - mContextMenuActions.mDiskAdminUnlockDrive = mContextMenuActions.mDiskAdminMenu->addAction("Unlock drive", this, SLOT(diskAdminUnlockDrive())); - mContextMenuActions.mDiskAdminClearDrivePassword = mContextMenuActions.mDiskAdminMenu->addAction("Clear drive password", this, SLOT(diskAdminClearDrivePassword())); - mContextMenuActions.mDiskAdminEraseDrivePassword = mContextMenuActions.mDiskAdminMenu->addAction("Erase drive password", this, SLOT(diskAdminEraseDrivePassword())); - - mContextMenuActions.mDiskAdminFormatDrive = mContextMenuActions.mDiskAdminMenu->addAction("Format drive", this, SLOT(diskAdminFormatDrive())); - mContextMenuActions.mDiskAdminFormatDrive->setVisible(false); - mContextMenuActions.mDiskAdminQuickFormatDrive = mContextMenuActions.mDiskAdminMenu->addAction("Quick format drive", this, SLOT(diskAdminQuickFormatDrive())); - mContextMenuActions.mDiskAdminQuickFormatDrive->setVisible(false); - - mContextMenuActions.mDiskAdminCheckDisk = mContextMenuActions.mDiskAdminMenu->addAction("Check disk", this, SLOT(diskAdminCheckDisk())); - mContextMenuActions.mDiskAdminScanDrive = mContextMenuActions.mDiskAdminMenu->addAction("Scan drive", this, SLOT(diskAdminScanDrive())); - mContextMenuActions.mDiskAdminSetDriveName = mContextMenuActions.mDiskAdminMenu->addAction("Set drive name", this, SLOT(diskAdminSetDriveName())); - mContextMenuActions.mDiskAdminSetDriveVolumeLabel = mContextMenuActions.mDiskAdminMenu->addAction("Set drive volume label", this, SLOT(diskAdminSetDriveVolumeLabel())); - mContextMenuActions.mDiskAdminEjectDrive = mContextMenuActions.mDiskAdminMenu->addAction("Eject drive", this, SLOT(diskAdminEjectDrive())); - mContextMenuActions.mDiskAdminDismountDrive = mContextMenuActions.mDiskAdminMenu->addAction("Dismount drive", this, SLOT(diskAdminDismountDrive())); - mContextMenuActions.mDiskAdminEraseMBR = mContextMenuActions.mDiskAdminMenu->addAction("Erase MBR", this, SLOT(diskAdminEraseMBR())); - mContextMenuActions.mDiskAdminPartitionDrive = mContextMenuActions.mDiskAdminMenu->addAction("Partition drive", this, SLOT(diskAdminPartitionDrive())); -} - -void FbDriveView::updateContextMenu() -{ - bool isFileItemListEmpty = mFbDriveModel->rowCount() == 0; - mContextMenuActions.mFileProperties->setVisible(!isFileItemListEmpty); -} - -// --------------------------------------------------------------------------- - -void FbDriveView::onLongPressed(HbAbstractViewItem *listViewItem, QPointF coords) -{ - mCurrentIndex = listViewItem->modelIndex(); - - mContextMenu->setPreferredPos(coords); - mContextMenu->show(); -} - -/** - Refresh FileBrowser view - */ -void FbDriveView::refreshList() -{ - mEngineWrapper->refreshView(); - mListView->reset(); - - TListingMode listingMode = mEngineWrapper->listingMode(); - if (listingMode == ENormalEntries) - mNaviPane->setPlainText(QString(mEngineWrapper->currentPath())); - else if (listingMode == ESearchResults) - mNaviPane->setPlainText(QString(tr("Search results"))); - else if (listingMode == EOpenFiles) - mNaviPane->setPlainText(QString(tr("Open files"))); - else if (listingMode == EMsgAttachmentsInbox) - mNaviPane->setPlainText(QString(tr("Attachments in Inbox"))); - else if (listingMode == EMsgAttachmentsDrafts) - mNaviPane->setPlainText(QString(tr("Attachments in Drafts"))); - else if (listingMode == EMsgAttachmentsSentItems) - mNaviPane->setPlainText(QString(tr("Attachments in Sent Items"))); - else if (listingMode == EMsgAttachmentsOutbox) - mNaviPane->setPlainText(QString(tr("Attachments in Outbox"))); -} - -// --------------------------------------------------------------------------- -/** - Show a list dialog - \param List aList of item to select item from. - \param Title text titleText of a dialog heading widget - \return None - */ -void FbDriveView::openListDialog(const QStringList& items, const QString &titleText, QObject* receiver, const char* member) -{ - // Create a list and some simple content for it - HbSelectionDialog *dlg = new HbSelectionDialog(); - dlg->setAttribute(Qt::WA_DeleteOnClose); - // Set items to be popup's content - dlg->setStringItems(items); - dlg->setSelectionMode(HbAbstractItemView::SingleSelection); - - HbLabel *title = new HbLabel(dlg); - title->setPlainText(titleText); - dlg->setHeadingWidget(title); - - // Launch popup and handle the user response: - dlg->open(receiver, member); -} - -// --------------------------------------------------------------------------- - -void FbDriveView::openPropertyDialog(const QStringList& propertyList, const QString& title) -{ - HbDialog *dialog = new HbDialog(); - dialog->setDismissPolicy(HbPopup::TapOutside); - dialog->setTimeout(HbPopup::NoTimeout); - - HbLabel *titleWidget = new HbLabel(); - titleWidget->setPlainText(title); - dialog->setHeadingWidget(titleWidget); - - // Create a list and some simple content for it - HbListWidget *list = new HbListWidget(); - QString str; - foreach (str, propertyList) { - list->addItem(str); - } - - // Connect list item activation signal to close the popup - connect(list, SIGNAL(activated(HbListWidgetItem*)), dialog, SLOT(close())); - - HbAction *cancelAction = new HbAction("Close"); - dialog->setPrimaryAction(cancelAction); - - // Set listwidget to be popup's content - dialog->setContentWidget(list); - // Launch popup and handle the user response: - dialog->open(); -} - -void FbDriveView::storeSelectedItemsOrCurrentItem() -{ - QItemSelectionModel *selectionIndexes = mListView->selectionModel(); - - // by default use selected items - if (selectionIndexes) { - if (selectionIndexes->hasSelection()) { - mSelectionIndexes = mListView->selectionModel()->selectedIndexes(); - } else { // or if none selected, use the current item index - mSelectionIndexes.clear(); - mSelectionIndexes.append(mCurrentIndex); -// QModelIndex currentIndex = currentItemIndex(); -// if (mFbDriveModel->rowCount(currentItemIndex) > currentItemIndex && currentItemIndex >= 0) -// { -// modelIndexList.append(currentIndex); -// } - } - } -// mClipBoardInUse = true; -} - -// --------------------------------------------------------------------------- - -QModelIndex FbDriveView::currentItemIndex() -{ - return mCurrentIndex;//mListView->selectionModel()->currentIndex(); -} - -// --------------------------------------------------------------------------- -// operations in File Menu -// --------------------------------------------------------------------------- - -void FbDriveView::fileOpenDrive() -{ - // TODO make a separate function to be called from here and fileOpenDirectory() - mLocationChanged = true; - // get selected drive or directory from list view model and open it: - //if (mListView->selectionModel()->hasSelection()) { -// if (mListView->selectionModel()->selection().count() != 0) { -// QModelIndex currentIndex = currentItemIndex(); - mEngineWrapper->moveDownToDirectory(mCurrentIndex); - mListView->setRootIndex(mCurrentIndex); - refreshList(); -// } else { -// Notifications::showErrorNote("not selected item!"); -// } -} - -void FbDriveView::fileSearch() -{ - QString searchPath; - HbAction *contextrMenuAction = static_cast(sender()); - if (contextrMenuAction - && contextrMenuAction->text().compare(QString("Search..."), Qt::CaseInsensitive) == 0 - && contextrMenuAction == mContextMenuActions.mFileSearch) { - FbDriveEntry driveEntry(mEngineWrapper->getDriveEntry(currentItemIndex())); - searchPath = driveEntry.driveLetter() + QString(":\\"); - } else { - searchPath = mEngineWrapper->currentPath(); - } - emit aboutToShowSearchView(searchPath); -} - -/** - Show file properties - */ -void FbDriveView::fileProperties() -{ - QModelIndex currentIndex = currentItemIndex(); - QStringList propertyList; - QString titleText; - mEngineWrapper->properties(currentIndex, propertyList, titleText); - openPropertyDialog(propertyList, titleText); -} - -void FbDriveView::fileSetAttributes() -{ - -} - -// edit menu -void FbDriveView::editSnapShotToE() -{ - -} - -// --------------------------------------------------------------------------- -// view menu -// --------------------------------------------------------------------------- - -/** - Refresh view - */ -void FbDriveView::viewRefresh() -{ - refreshList(); -} - -// --------------------------------------------------------------------------- -// disk admin menu -// --------------------------------------------------------------------------- - -/** - Open old password for the selected drive dialog. - */ -void FbDriveView::diskAdminSetDrivePassword() -{ - QModelIndex currentIndex = currentItemIndex(); - // check if the drive has a password - if (mEngineWrapper->hasDrivePassword(currentIndex)) { - QString heading = QString("Existing password"); - HbInputDialog::queryText(heading, this, SLOT(diskAdminSetDrivePasswordNew(HbAction*)), QString(), scene()); - } else { - QString heading = QString("New password"); - HbInputDialog::queryText(heading, this, SLOT(doDiskAdminSetDrivePassword(HbAction*)), mOldPassword, scene()); - } -} - -/** - Open new password for the selected drive dialog. - */ -void FbDriveView::diskAdminSetDrivePasswordNew(HbAction *action) -{ - HbInputDialog *dlg = static_cast(sender()); - if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { - mOldPassword = dlg->value().toString(); - QString heading = QString("New password"); - HbInputDialog::queryText(heading, this, SLOT(doDiskAdminSetDrivePassword(HbAction*)), mOldPassword, scene()); - } -} - -/** - Set password for the selected drive. - */ -void FbDriveView::doDiskAdminSetDrivePassword(HbAction *action) -{ - HbInputDialog *dlg = static_cast(sender()); - if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { - QString newPassword = dlg->value().toString(); - QModelIndex currentIndex = currentItemIndex(); - mEngineWrapper->DiskAdminSetDrivePassword(currentIndex, mOldPassword, newPassword); - refreshList(); - mOldPassword = QString(); - newPassword = QString(); - } -} - -/** - Open Unlock the selected drive dialog. - */ -void FbDriveView::diskAdminUnlockDrive() -{ - QModelIndex currentIndex = currentItemIndex(); - // check if the drive is locked - if (mEngineWrapper->isDriveLocked(currentIndex)) { - QString heading = QString("Existing password"); - HbInputDialog::queryText(heading, this, SLOT(doDiskAdminUnlockDrive(HbAction*)), QString(), scene()); - } else { - Notifications::showInformationNote(QString("This drive is not locked")); - } -} - -/** - Unlock the selected drive. - */ -void FbDriveView::doDiskAdminUnlockDrive(HbAction *action) -{ - HbInputDialog *dlg = static_cast(sender()); - if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { - QString oldPassword = dlg->value().toString(); - QModelIndex currentIndex = currentItemIndex(); - mEngineWrapper->DiskAdminUnlockDrive(currentIndex, oldPassword); - refreshList(); - } -} - -/** - Open clear password of the selected drive dialog. - */ -void FbDriveView::diskAdminClearDrivePassword() -{ - QModelIndex currentIndex = currentItemIndex(); - // check if the drive has a password - if (mEngineWrapper->hasDrivePassword(currentIndex)) { - QString heading = QString("Existing password"); - HbInputDialog::queryText(heading, this, SLOT(doDiskAdminClearDrivePassword(HbAction*)), QString(), scene()); - } else { - Notifications::showInformationNote(QString("This drive has no password")); - } -} - -/** - Clear password of the selected drive. - */ -void FbDriveView::doDiskAdminClearDrivePassword(HbAction *action) -{ - HbInputDialog *dlg = static_cast(sender()); - if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { - QString oldPassword = dlg->value().toString(); - QModelIndex currentIndex = currentItemIndex(); - mEngineWrapper->DiskAdminClearDrivePassword(currentIndex, oldPassword); - refreshList(); - } -} - - -/** - Question for erase password of the selected drive - */ -void FbDriveView::diskAdminEraseDrivePassword() -{ - // check if the drive has a password - QModelIndex currentIndex = currentItemIndex(); - if (mEngineWrapper->hasDrivePassword(currentIndex)) { - HbMessageBox::question(QString("Are you sure? All data can be lost!"), - this, - SLOT(doDiskAdminEraseDrivePassword(int)), - HbMessageBox::Yes | HbMessageBox::No); - } else { - Notifications::showInformationNote(QString("This drive has no password")); - } -} - -/** - Erase password of the selected drive - */ -void FbDriveView::doDiskAdminEraseDrivePassword(int action) -{ - if (action == HbMessageBox::Yes) { - QModelIndex currentIndex = currentItemIndex(); - mEngineWrapper->DiskAdminEraseDrivePassword(currentIndex); - refreshList(); - } -} - -/** - Performs format on the selected drive - */ -void FbDriveView::diskAdminFormatDrive() -{ - HbMessageBox::question(QString("Are you sure? All data will be lost!"), - this, - SLOT(doDiskAdminFormatDrive(int)), - HbMessageBox::Yes | HbMessageBox::No); -} - -/** - Performs format on the selected drive - */ -void FbDriveView::doDiskAdminFormatDrive(int action) -{ - if (action == HbMessageBox::Yes) { - QModelIndex currentIndex = currentItemIndex(); - mEngineWrapper->DiskAdminFormatDrive(currentIndex, false); - } -} - -/** - Performs quick format on the selected drive - */ -void FbDriveView::diskAdminQuickFormatDrive() -{ - HbMessageBox::question(QString("Are you sure? All data will be lost!"), - this, - SLOT(doDiskAdminQuickFormatDrive(int)), - HbMessageBox::Yes | HbMessageBox::No); -} - -/** - Performs quick format on the selected drive - */ -void FbDriveView::doDiskAdminQuickFormatDrive(int action) -{ - if (action == HbMessageBox::Yes) { - QModelIndex currentIndex = currentItemIndex(); - mEngineWrapper->DiskAdminFormatDrive(currentIndex, true); - } -} - -/** - Checks the disk integrity on the selected drive - */ -void FbDriveView::diskAdminCheckDisk() -{ - QModelIndex currentIndex = currentItemIndex(); - mEngineWrapper->DiskAdminCheckDisk(currentIndex); -} - -/** - Checks the selected drive for errors and corrects them - */ -void FbDriveView::diskAdminScanDrive() -{ - HbMessageBox::question(QString("This finds errors on disk and corrects them. Proceed?"), - this, - SLOT(doDiskAdminScanDrive(int)), - HbMessageBox::Yes | HbMessageBox::No); -} - -/** - Checks the selected drive for errors and corrects them - */ -void FbDriveView::doDiskAdminScanDrive(int action) -{ - if (action == HbMessageBox::Yes) { - QModelIndex currentIndex = currentItemIndex(); - mEngineWrapper->DiskAdminScanDrive(currentIndex); - refreshList(); - } -} - -/** - Open drive name dialog - */ -void FbDriveView::diskAdminSetDriveName() -{ - QString driveName; - - // get existing drive name - QModelIndex currentIndex = currentItemIndex(); - mEngineWrapper->GetDriveName(currentIndex, driveName); - - QString heading = QString("New name"); - HbInputDialog::queryText(heading, this, SLOT(doDiskAdminSetDriveName(HbAction*)), driveName, scene()); -} - -/** - Set drive name. - */ -void FbDriveView::doDiskAdminSetDriveName(HbAction *action) -{ - HbInputDialog *dlg = static_cast(sender()); - if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { - QString driveName = dlg->value().toString(); - - QModelIndex currentIndex = currentItemIndex(); - mEngineWrapper->DiskAdminSetDriveName(currentIndex, driveName); - - refreshList(); - } -} - -/** - Open drive volume label dialog - */ -void FbDriveView::diskAdminSetDriveVolumeLabel() -{ - QString volumeLabel; - - // get existing drive name - QModelIndex currentIndex = currentItemIndex(); - mEngineWrapper->GetDriveVolumeLabel(currentIndex, volumeLabel); - - QString heading = QString("New volume label"); - HbInputDialog::queryText(heading, this, SLOT(doDiskAdminSetDriveVolumeLabel(HbAction*)), volumeLabel, scene()); -} - -/** - Set drive volume label. - */ -void FbDriveView::doDiskAdminSetDriveVolumeLabel(HbAction *action) -{ - HbInputDialog *dlg = static_cast(sender()); - if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { - QString volumeLabel = dlg->value().toString(); - - QModelIndex currentIndex = currentItemIndex(); - mEngineWrapper->DiskAdminSetDriveVolumeLabel(currentIndex, volumeLabel); - - refreshList(); - } -} - -/** - Eject the selected drive - */ -void FbDriveView::diskAdminEjectDrive() -{ - QModelIndex currentIndex = currentItemIndex(); - mEngineWrapper->DiskAdminEjectDrive(currentIndex); - refreshList(); -} - -/** - Dismount the selected drive - */ -void FbDriveView::diskAdminDismountDrive() -{ - HbMessageBox::question(QString("Are you sure you know what are you doing?"), - this, - SLOT(doDiskAdminDismountDrive(int)), - HbMessageBox::Yes | HbMessageBox::No); -} - -void FbDriveView::doDiskAdminDismountDrive(int action) -{ - if (action == HbMessageBox::Yes) { - QModelIndex currentIndex = currentItemIndex(); - mEngineWrapper->DiskAdminDismountDrive(currentIndex); - refreshList(); - } -} - -/** - Erase Master Boot Record of the selected drive - */ -void FbDriveView::diskAdminEraseMBR() -{ - // TODO What to do with FB LITE macros? - HbMessageBox::question(QString("Are you sure? Your media driver must support this!"), - this, - SLOT(doDiskAdminEraseMBR(int)), - HbMessageBox::Yes | HbMessageBox::No); -} - -void FbDriveView::doDiskAdminEraseMBR(int action) -{ - // TODO What to do with FB LITE macros? - if (action == HbMessageBox::Yes) { - HbMessageBox::question(QString("Are you really sure you know what are you doing ?!?"), - this, - SLOT(doDiskAdminReallyEraseMBR(int)), - HbMessageBox::Yes | HbMessageBox::No); - } -} - -void FbDriveView::doDiskAdminReallyEraseMBR(int action) -{ - if (action == HbMessageBox::Yes) { - QModelIndex currentIndex = currentItemIndex(); - // warn if the selected drive is not detected as removable - if (mEngineWrapper->isDriveRemovable(currentIndex)) { - mEngineWrapper->DiskAdminEraseMBR(currentIndex); - refreshList(); - } else { - HbMessageBox::question(QString("Selected drive is not removable, really continue?"), - this, - SLOT(doDiskAdminNotRemovableReallyEraseMBR(int)), - HbMessageBox::Yes | HbMessageBox::No); - } - } -} - -void FbDriveView::doDiskAdminNotRemovableReallyEraseMBR(int action) -{ - if (action == HbMessageBox::Yes) { - QModelIndex currentIndex = currentItemIndex(); - mEngineWrapper->DiskAdminEraseMBR(currentIndex); - refreshList(); - } - -} - -/** - Partition the selected drive - */ -void FbDriveView::diskAdminPartitionDrive() -{ - HbMessageBox::question(QString("Are you sure? Your media driver must support this!"), - this, - SLOT(diskAdminPartitionDriveProceed(int)), - HbMessageBox::Yes | HbMessageBox::No); -} - -/** - Partition the selected drive if user is sure - */ -void FbDriveView::diskAdminPartitionDriveProceed(int action) -{ - if (action == HbMessageBox::Yes) { - HbMessageBox::question(QString("Are you really sure you know what are you doing ?!?"), - this, - SLOT(diskAdminPartitionDriveReallyProceed(int)), - HbMessageBox::Yes | HbMessageBox::No); - } -} - -/** - Partition the selected drive if user is really sure - */ -void FbDriveView::diskAdminPartitionDriveReallyProceed(int action) -{ - if (action == HbMessageBox::Yes) { - QModelIndex currentIndex = currentItemIndex(); - mEraseMBR = false; - // warn if the selected drive is not detected as removable - mProceed = false; - if (mEngineWrapper->isDriveRemovable(currentIndex)) { - mProceed = true; - } else { - HbMessageBox::question(QString("Selected drive is not removable, really continue?"), - this, - SLOT(diskAdminPartitionDriveIsNotRemovable(int)), - HbMessageBox::Yes | HbMessageBox::No); - } - - if (mProceed) { - // query if erase mbr - mEraseMBR = false; - - HbMessageBox::question(QString("Erase MBR first (normally needed)?"), - this, - SLOT(diskAdminPartitionDriveEraseMbr(int)), - HbMessageBox::Yes | HbMessageBox::No); - - // TODO use HbListDialog - QStringList list; - list << "1" << "2" << "3" << "4"; - openListDialog(list, QString("Partitions?"), this, SLOT(diskAdminPartitionDriveGetCount(HbAction*))); - } - } -} - -/** - Store result of user query about proceeding when drive is not removable. - */ -void FbDriveView::diskAdminPartitionDriveIsNotRemovable(int action) -{ - if (action == HbMessageBox::Yes) { - mProceed = true; - } else { - mProceed = false; - } -} - -/** - Store result of user query about erase MBR - */ -void FbDriveView::diskAdminPartitionDriveEraseMbr(int action) -{ - if (action == HbMessageBox::Yes) { - mEraseMBR = true; - } -} - -/** - Partition the selected drive - */ -void FbDriveView::diskAdminPartitionDriveGetCount(HbAction* action) -{ - HbSelectionDialog *dlg = static_cast(sender()); - if(!action && dlg && dlg->selectedItems().count()){ - int selectionIndex = dlg->selectedItems().at(0).toInt(); - QModelIndex currentIndex = currentItemIndex(); - int amountOfPartitions = selectionIndex + 1; - mEngineWrapper->DiskAdminPartitionDrive(currentIndex, mEraseMBR, amountOfPartitions); - refreshList(); - } -} - -// --------------------------------------------------------------------------- -// tools menu -// --------------------------------------------------------------------------- -void FbDriveView::toolsAllAppsToTextFile() -{ - -} - -/** - Write all files to text file - */ -void FbDriveView::toolsAllFilesToTextFile() -{ - mEngineWrapper->toolsWriteAllFiles(); -} - -//void FbDriveView::toolsAvkonIconCacheEnable() -//{ -// -//} -//void FbDriveView::toolsAvkonIconCacheDisable() -//{ -// -//} - -/** - Disable extended errors - */ -void FbDriveView::toolsDisableExtendedErrors() -{ - mEngineWrapper->ToolsSetErrRd(false); -} - -void FbDriveView::toolsDumpMsgStoreWalk() -{ - -} -void FbDriveView::toolsEditDataTypes() -{ - -} - -/** - Enable extended errors - */ -void FbDriveView::toolsEnableExtendedErrors() -{ - mEngineWrapper->ToolsSetErrRd(true); -} - -/** - Open simulate leave dialog - */ -void FbDriveView::toolsErrorSimulateLeave() -{ - int leaveCode = -6; - QString heading = QString("Leave code"); - HbInputDialog::queryText(heading, this, SLOT(doToolsErrorSimulateLeave(HbAction*)), QString::number(leaveCode), scene()); -} - - -/** - Simulate leave. - */ -void FbDriveView::doToolsErrorSimulateLeave(HbAction *action) -{ - HbInputDialog *dlg = static_cast(sender()); - if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { - bool ok; - int leaveCode = dlg->value().toString().toInt(&ok); - if (leaveCode != 0 || ok) { - mEngineWrapper->ToolsErrorSimulateLeave(leaveCode); - } - } -} - -/** - Open simulate panic dialog. - */ -void FbDriveView::toolsErrorSimulatePanic() -{ - mPanicCategory = QString ("Test Category"); - QString heading = QString("Panic category"); - HbInputDialog::queryText(heading, this, SLOT(doToolsErrorSimulatePanicCode(HbAction*)), mPanicCategory, scene()); -} - -/** - Simulate panic. - */ -void FbDriveView::doToolsErrorSimulatePanicCode(HbAction *action) -{ - HbInputDialog *dlg = static_cast(sender()); - if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { - mPanicCategory = dlg->value().toString(); - int panicCode(555); - QString heading = QString("Panic code"); - HbInputDialog::queryInt(heading, this, SLOT(doToolsErrorSimulatePanic(HbAction*)), panicCode, scene()); - } -} - -/** - Simulate panic. - */ -void FbDriveView::doToolsErrorSimulatePanic(HbAction *action) -{ - HbInputDialog *dlg = static_cast(sender()); - if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { - bool ok; - int panicCode = dlg->value().toInt(&ok); - if (panicCode != 0 || ok) { - mEngineWrapper->ToolsErrorSimulatePanic(mPanicCategory, panicCode); - } - } -} - -/** - Open simulate exception dialog. - */ -void FbDriveView::toolsErrorSimulateException() -{ - int exceptionCode = 0; - QString heading = QString("Exception code"); - HbInputDialog::queryInt(heading, this, SLOT(doToolsErrorSimulateException(HbAction*)), exceptionCode, scene()); -} - -/** - Simulate exception. - */ -void FbDriveView::doToolsErrorSimulateException(HbAction *action) -{ - HbInputDialog *dlg = static_cast(sender()); - if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { - bool ok; - int exceptionCode = dlg->value().toInt(&ok); - if (exceptionCode != 0 || ok) { - mEngineWrapper->ToolsErrorSimulateException(exceptionCode); - } - } -} - -// void FbDriveView::toolsLocalConnectivityActivateInfrared() -//{ -// -//} -// void FbDriveView::toolsLocalConnectivityLaunchBTUI() -//{ -// -//} -// void FbDriveView::toolsLocalConnectivityLaunchUSBUI() -//{ -// -//} -void FbDriveView::toolsMessageInbox() -{ - -} -void FbDriveView::toolsMessageDrafts() -{ - -} -void FbDriveView::toolsMessageSentItems() -{ - -} -void FbDriveView::toolsMessageOutbox() -{ - -} -void FbDriveView::toolsMemoryInfo() -{ - -} -void FbDriveView::toolsSecureBackStart() -{ - -} -void FbDriveView::toolsSecureBackRestore() -{ - -} -void FbDriveView::toolsSecureBackStop() -{ - -} - -/** - Open debug mask dialog - */ -void FbDriveView::toolsSetDebugMaskQuestion() -{ - quint32 dbgMask = mEngineWrapper->getDebugMask(); - QString dbgMaskText = QString("0x").append(QString::number(dbgMask, 16)); - QString heading = QString("Kernel debug mask in hex format"); - HbInputDialog::queryText(heading, this, SLOT(toolsSetDebugMask(HbAction*)), dbgMaskText, scene()); -} - -/** - Set debug mask - */ -void FbDriveView::toolsSetDebugMask(HbAction *action) -{ - HbInputDialog *dlg = static_cast(sender()); - if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { - QString dbgMaskText = dlg->value().toString(); - if (dbgMaskText.length() > 2 && dbgMaskText[0]=='0' && dbgMaskText[1]=='x') { - bool ok; - quint32 dbgMask = dbgMaskText.toUInt(&ok, 16); - if (dbgMask != 0 || ok) { - mEngineWrapper->toolsSetDebugMask(dbgMask); - Notifications::showConfirmationNote(QString("Changed")); - } else { - Notifications::showErrorNote(QString("Cannot convert value")); - } - } else { - Notifications::showErrorNote(QString("Not in hex format")); - } - } -} - -void FbDriveView::toolsShowOpenFilesHere() -{ - -} - -// --------------------------------------------------------------------------- -// main menu items -// --------------------------------------------------------------------------- - -/** - Show about note - */ -void FbDriveView::about() -{ - Notifications::showAboutNote(); -} - -// --------------------------------------------------------------------------- -// End of operations -// --------------------------------------------------------------------------- - -// --------------------------------------------------------------------------- - -/** - Item is selected from list when selection mode is activated from menu - */ -void FbDriveView::selectionChanged(const QItemSelection &/*selected*/, const QItemSelection &/*deselected*/) -{ - //QItemSelectionModel *selectionModel = mListView->selectionModel(); -} - -/** - An item is clicked from navigation item list. Navigation item list contains - drive-, folder- or file items. Opens selected drive, folder or file popup menu - */ -void FbDriveView::activated(const QModelIndex& index) -{ - if (mFbDriveModel) { -// if (mEngineWrapper->isDriveListViewActive()) { - mEngineWrapper->moveDownToDirectory(index); - //emit aboutToShowFileView(QString(mEngineWrapper->currentPath())); - emit aboutToShowFileView(); - //refreshList(); -// } - } -} - -// --------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/ui/src/fbeditorview.cpp --- a/filebrowser/ui/src/fbeditorview.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,144 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include "fbeditorview.h" - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -FbEditorView::FbEditorView() : - mTextEdit(0), - mFileHex(false), - mFlagReadOnly(), - mFileName(), - mFileContent(), - mToTextAction(0), - mToHexAction(0), - mExitAction(0) -{ - // Override back navigation action - HbAction *backNaviAction = new HbAction(Hb::BackNaviAction, this); - connect(backNaviAction, SIGNAL(triggered()), this, SLOT(backButtonClicked())); - setNavigationAction(backNaviAction); - - createMenu(); - - // text editor -// mTextEdit = new QTextEdit(); -// QGraphicsLinearLayout *editorLayout = new QGraphicsLinearLayout(Qt::Vertical); -// QGraphicsProxyWidget *editorWidget = new QGraphicsProxyWidget(); -// editorWidget->setWidget(mTextEdit); -// editorLayout->addItem(editorWidget); -// setLayout(editorLayout); - - mTextEdit = new HbTextEdit(); - mTextEdit->setAlignment(Qt::AlignTop); - QGraphicsLinearLayout *editorLayout = new QGraphicsLinearLayout(Qt::Vertical, this); - editorLayout->addItem(mTextEdit); - setLayout(editorLayout); -} - -FbEditorView::~FbEditorView() -{ -// delete mTextEdit; -// delete mToTextAction; -// delete mToHexAction; -// delete mExitAction; -} - -void FbEditorView::open(const QString& fileName, bool flagReadOnly) -{ - mFlagReadOnly = flagReadOnly; - - if (!fileName.isEmpty()) { - mTextEdit->setReadOnly(mFlagReadOnly); - loadFile(fileName); - } - else { - // not valid file name - } -} - -void FbEditorView::loadFile(const QString &fileName) -{ - mFileName = fileName; - QFile file(fileName); - QFileInfo baseName(fileName); - setTitle(baseName.fileName()); - - if (!file.open(QFile::ReadOnly | QFile::Text)) { - // note: cannot be opened. readonly or not text - return; - } - QTextStream in(&file); - in.setAutoDetectUnicode(false); - - mFileContent = in.readAll(); - file.close(); - displayInText(); -} - -void FbEditorView::displayInText() -{ - mFileHex = false; - QByteArray asciiContent = mFileContent.toAscii(); - mTextEdit->setPlainText(QString(asciiContent)); -} - -void FbEditorView::displayInHex() -{ - QByteArray asciiContent = mFileContent.toAscii().toHex(); - QString textInHex = QString(asciiContent); - mTextEdit->setPlainText(textInHex); - mFileHex = true; -} - -void FbEditorView::createMenu() -{ - mToTextAction = menu()->addAction("View as text"); - connect(mToTextAction, SIGNAL(triggered()), this, SLOT(displayInText())); - mToHexAction = menu()->addAction("View as hex"); - connect(mToHexAction, SIGNAL(triggered()), this, SLOT(displayInHex())); -// mExitAction = menu()->addAction("Exit"); -// connect(mExitAction, SIGNAL(triggered()), this, SLOT(backButtonClicked())); - - // update the menus before showing it: - connect(menu(), SIGNAL(aboutToShow()), this, SLOT(updateMenu())); -} - -void FbEditorView::updateMenu() -{ - mToTextAction->setVisible(mFileHex); - mToHexAction->setVisible(!mFileHex); -} - -void FbEditorView::backButtonClicked() -{ - emit finished(false); -} - diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/ui/src/fbfileentry.cpp --- a/filebrowser/ui/src/fbfileentry.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,209 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include "fbfileentry.h" - -#include - -// --------------------------------------------------------------------------- - -FbFileEntry::FbFileEntry(TFileEntry aFileEntry) -: mFileEntry(aFileEntry) -{ -} - -// --------------------------------------------------------------------------- - -FbFileEntry::~FbFileEntry() -{ -} - -// --------------------------------------------------------------------------- - -QString FbFileEntry::fullName() -{ - return QString::fromUtf16(mFileEntry.iFullName.Ptr(), mFileEntry.iFullName.Length()); -} - -// --------------------------------------------------------------------------- - -QString FbFileEntry::path() -{ - return QString::fromUtf16(mFileEntry.iPath.Ptr(), mFileEntry.iPath.Length()); -} - -// --------------------------------------------------------------------------- - -int FbFileEntry::attributes() -{ - return mFileEntry.iEntry.iAtt; -} - -QString FbFileEntry::attributesString() -{ - QString attributesString; - if (mFileEntry.iEntry.IsArchive()) { - attributesString.append("A"); - } else { - attributesString.append("-"); - } - if (mFileEntry.iEntry.IsHidden()) { - attributesString.append("H"); - } else { - attributesString.append("-"); - } - if (mFileEntry.iEntry.IsReadOnly()) { - attributesString.append("R"); - } else { - attributesString.append("-"); - } - if (mFileEntry.iEntry.IsSystem()) { - attributesString.append("S"); - } else { - attributesString.append("-"); - } - - return attributesString; -} - -// --------------------------------------------------------------------------- - -int FbFileEntry::size() -{ - return mFileEntry.iEntry.iSize; -} - -// --------------------------------------------------------------------------- - -QString FbFileEntry::sizeString() -{ - QString sizeString; - if (size() < 1024) { - sizeString.append(QString::number(size())); - sizeString.append(" B"); - } else if (size() < 1024*1024) { - qreal sizeKB = static_cast(size() / 1024); - sizeString.append( QString::number(sizeKB, 'f',1)); - sizeString.append(" kB"); - } else { - qreal sizeMB = static_cast(size() / (1024*1024)); - sizeString.append( QString::number(sizeMB, 'f',1)); - sizeString.append(" MB"); - } - return sizeString; -} - -// --------------------------------------------------------------------------- - -//QDateTime FbFileEntry::modified() -//{ -// QDateTime modified; -// TTime time1Jan1970UTC = TTime(_L("19700101:000000.000000")); -// TTimeIntervalSeconds intervalSeconds; -// -// TTime entryModified = mFileEntry.iEntry.iModified; -// -// TInt err = /*mFileEntry.iEntry.iModified*/ entryModified.SecondsFrom(time1Jan1970UTC, intervalSeconds); -// if (err == KErrNone) { -// quint32 secsSince1Jan1970UTC = intervalSeconds.Int(); -// modified = QDateTime::fromTime_t(secsSince1Jan1970UTC); -// qDebug() << "QDateTime:: " << modified.toString(); -// modified.setTimeSpec(Qt::LocalTime); -// qDebug() << "QDateTime:: " << modified.toString() << modified.toLocalTime().toString(); -// } -// return modified; -//} - -// --------------------------------------------------------------------------- - -QString FbFileEntry::modifiedString() -{ - // TODO use HbExtendedLocale to convert date and time -// QDateTime modifiedInLocalTime = modified();//.toLocalTime(); -// HbExtendedLocale locale = HbExtendedLocale::system(); -// QString date = locale.format(modifiedInLocalTime.date(), r_qtn_date_usual); -// QString time = locale.format(modifiedInLocalTime.time(), r_qtn_time_usual); -// -// return date + " " + time; - QString modifiedString; - TTime entryModified = mFileEntry.iEntry.iModified; - RTz Tz; - TInt err = Tz.Connect(); - if ( err == KErrNone && Tz.ConvertToLocalTime( entryModified ) == KErrNone ) - { - entryModified = mFileEntry.iEntry.iModified; - TBuf<128> extraData; - _LIT(KCurrentDate,"%D%M%*Y%/0%1%/1%2%/2%3%/3 %-B%:0%J%:1%T%:2%S%:3%+B"); - entryModified.FormatL(extraData, KCurrentDate); - modifiedString = QString::fromUtf16(extraData.Ptr(), extraData.Length()); - } - Tz.Close(); - - return modifiedString; -} - -// --------------------------------------------------------------------------- - -//int FbFileEntry::Uid(int id) -//{ -// return id;//mFileEntry.iEntry.iType[id]; -//} - -// --------------------------------------------------------------------------- - -bool FbFileEntry::isDir() -{ - return mFileEntry.iEntry.IsDir(); -} - -// --------------------------------------------------------------------------- - - -QString FbFileEntry::name() -{ - return QString::fromUtf16(mFileEntry.iEntry.iName.Ptr(), mFileEntry.iEntry.iName.Length()); -} - -// --------------------------------------------------------------------------- - -int FbFileEntry::dirEntries() -{ - return mFileEntry.iDirEntries; -} - -// --------------------------------------------------------------------------- - -QString FbFileEntry::dirEntriesString() -{ - QString dirEntriesString; - dirEntriesString.append(QString::number(dirEntries())); - if (dirEntries() == 1) { - dirEntriesString.append(" entry"); - } else { - dirEntriesString.append(" entries"); - } - return dirEntriesString; -} - -// --------------------------------------------------------------------------- - -int FbFileEntry::iconId() -{ - return mFileEntry.iIconId; -} - -// --------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/ui/src/fbfilelistviewitem.cpp --- a/filebrowser/ui/src/fbfilelistviewitem.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,160 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include "fbfilelistviewitem.h" - -#include -#include -#include -#include -#include - -#include -#include -#include - -FbFileListViewItem::FbFileListViewItem(QGraphicsItem *parent) : - HbListViewItem(parent), - hLayout(0), - mDiskNameLabel(0), - mSizeLabel(0), - mFreeLabel(0), - mIconLabel(0) -{ -} - -FbFileListViewItem::~FbFileListViewItem() -{ -} - -void FbFileListViewItem::polish(HbStyleParameters ¶ms) -{ - Q_UNUSED(params); -} - -bool FbFileListViewItem::canSetModelIndex(const QModelIndex &index) const -{ - Q_UNUSED(index); - return true; -} - - -HbAbstractViewItem *FbFileListViewItem::createItem() -{ - return new FbFileListViewItem(*this); -} - -void FbFileListViewItem::updateChildItems() -{ - if(!hLayout) { - init(); - } - - // Qt::DisplayRole - QVariant displayRole = modelIndex().data(Qt::DisplayRole); - QString diskName("default"); - QStringList stringList; - if (displayRole.isValid()) { - if (displayRole.canConvert()) { // EFileViewModeSimple - stringList.append(displayRole.toString()); - } else if (displayRole.canConvert()) { // EFileViewModeExtended - stringList = displayRole.toStringList(); - } - if (stringList.count() > 0) - diskName = stringList[0]; //modelIndex().data( Qt::UserRole ).toString(); - - mDiskNameLabel->setPlainText(diskName/*displayString*/); - } - -// mSizeLabel->setPlainText( hbTrId ( "Size: " ) /*+ FmUtils::formatStorageSize( driverInfo.size() )*/ ); -// mFreeLabel->setPlainText( hbTrId ( "Free: " ) /*+ FmUtils::formatStorageSize( driverInfo.freeSize() )*/ ); - if (stringList.count() > 1) - mSizeLabel->setPlainText( stringList[1] ); - - //mStorageSizeDiagram->setFreeSizePercentage(); - //mFreeLabel->setPlainText( stringList[2] ); - - // mCheckBox->setCheckState( checkState() ); - - // Qt::DecorationRole - QVariant decorationRole = modelIndex().data(Qt::DecorationRole); - if (decorationRole.isValid()) { - QIcon icon = qvariant_cast(decorationRole); -// if( icon.isNull() ) { -// QFileIconProvider fileIconProvider; -// icon = fileIconProvider.icon(QFileIconProvider::Drive); -// } - mIconLabel->setIcon(HbIcon(icon)); - } -} - -void FbFileListViewItem::setCheckedState(int state) -{ - HbAbstractViewItem::setCheckState(static_cast(state)); -} - -void FbFileListViewItem::init() -{ - hLayout = new QGraphicsLinearLayout(); - - hLayout->setOrientation( Qt::Horizontal ); - hLayout->addItem(layout()); - - mIconLabel = new HbLabel(); - hLayout->addItem( mIconLabel ); - hLayout->setAlignment( mIconLabel, Qt::AlignTop ); - hLayout->setStretchFactor( mIconLabel, 0 ); - -// mStorageSizeDiagram = new FbDriveStorageSizeDiagram(this); -// hLayout->addItem( mStorageSizeDiagram ); -// hLayout->setAlignment( mIconLabel, Qt::AlignTop ); -// hLayout->setStretchFactor( mStorageSizeDiagram, 0 ); - - QGraphicsLinearLayout *vLayout = new QGraphicsLinearLayout(); - vLayout->setOrientation( Qt::Vertical ); - - mDiskNameLabel = new HbLabel(); - //HbFontSpec fontSpecPrimary(HbFontSpec::Primary); - //fontSpecPrimary.setTextHeight(18.0); - //mDiskNameLabel->setFontSpec( fontSpecPrimary ); - vLayout->addItem( mDiskNameLabel ); - vLayout->setAlignment( mDiskNameLabel, Qt::AlignLeft ); - - mSizeLabel = new HbLabel(); - //HbFontSpec fontSpecSecondary(HbFontSpec::Secondary); - //fontSpecSecondary.setTextHeight(18.0); - //mSizeLabel->setFontSpec(fontSpecSecondary); - vLayout->addItem( mSizeLabel ); - vLayout->setAlignment(mSizeLabel, Qt::AlignLeft); - -// mFreeLabel = new HbLabel(); -// mFreeLabel->setFontSpec( HbFontSpec( HbFontSpec::Secondary ) ); -// vLayout->addItem( mFreeLabel ); -// vLayout->setAlignment( mFreeLabel, Qt::AlignLeft ); - - HbWidget *labelsWidget = new HbWidget(); - labelsWidget->setLayout(vLayout); - - hLayout->setAlignment( labelsWidget, Qt::AlignLeft ); - - hLayout->addItem( labelsWidget ); - hLayout->setStretchFactor( labelsWidget, 1 ); - -// this->setMaximumHeight(80); - - setLayout( hLayout ); -} diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/ui/src/fbfilemodel.cpp --- a/filebrowser/ui/src/fbfilemodel.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,120 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include "fbfilemodel.h" -#include "enginewrapper.h" -#include "fbfileentry.h" -#include "filebrowsersettings.h" -#include "FB.hrh" - -#include -#include - -/** - Constructs a file browser custom system model with the given \a engineWrapper and \a parent. - */ -FbFileModel::FbFileModel(EngineWrapper *engineWrapper, QObject *parent) : - QAbstractListModel(parent), - mEngineWrapper(engineWrapper), - mFileIconProvider(0) -{ - mFileIconProvider = new QFileIconProvider(); -} - -/** - Destroys this file browser custom system model. - */ -FbFileModel::~FbFileModel() -{ - if (mFileIconProvider) { - delete mFileIconProvider; - } -} - -/** - \reimp - */ -int FbFileModel::rowCount(const QModelIndex &parent) const -{ - Q_UNUSED(parent); - return mEngineWrapper->itemCount(); -} - -/** - \reimp - */ -QVariant FbFileModel::data(const QModelIndex &index, int role) const -{ - if (!index.isValid() || index.model() != this) - return QVariant(); - - switch (role) { - case Qt::EditRole: - case Qt::DisplayRole: { - QStringList listItem; - FbFileEntry fileEntry(mEngineWrapper->getFileEntry(index)); - if (mEngineWrapper->settings().fileViewMode() == EFileViewModeSimple) - { - listItem /*<< fileEntry.IconId()*/ - << fileEntry.name(); - } else if (mEngineWrapper->settings().fileViewMode() == EFileViewModeExtended) { - QString extraData; - extraData.append(fileEntry.modifiedString()); - if (fileEntry.isDir() && fileEntry.dirEntries() >= 0) { - extraData.append(" - "); - extraData.append(fileEntry.dirEntriesString()); - } else if (!fileEntry.isDir()) { - extraData.append(" - "); - extraData.append(fileEntry.sizeString()); - } - listItem /*<< fileEntry.IconId()*/ - << fileEntry.name() << extraData << fileEntry.attributesString(); - } - return listItem; - } - case Qt::DecorationRole: { - if (mEngineWrapper) { - QIcon icon; - FbFileEntry fileEntry(mEngineWrapper->getFileEntry(index)); - if (fileEntry.isDir()) { - icon = mFileIconProvider->icon(QFileIconProvider::Folder); - } else { - icon = mFileIconProvider->icon(QFileIconProvider::File); - } -// } - return QVariant(icon); - } - } - } - - return QVariant(); -} - -/** - \reimp - */ -QVariant FbFileModel::headerData(int section, Qt::Orientation orientation, int role) const -{ - Q_UNUSED(section) - Q_UNUSED(orientation) - Q_UNUSED(role) - - // TODO, implement or remove - return QVariant(); -} - -// --------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/ui/src/fbfileview.cpp --- a/filebrowser/ui/src/fbfileview.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1598 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include "fbfileview.h" -#include "fbsettingsview.h" -#include "fbeditorview.h" -#include "fbsearchview.h" -#include "enginewrapper.h" -#include "notifications.h" -#include "fbfolderselectiondialog.h" -#include "fbfilemodel.h" -#include "filebrowsersortfilterproxymodel.h" -//#include "fbfilelistviewitem.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -//TODO check if needed to do this way -#include - -// --------------------------------------------------------------------------- - -FbFileView::FbFileView() : - mEngineWrapper(0), - mListView(0), - mToolBar(0), - mNaviPane(0), - mSearchPanel(0), - mMainLayout(0), - mFbFileModel(0), - mSortFilterProxyModel(0), - mOptionMenuActions(), - mContextMenuActions(), - mContextMenu(0), - mToolbarBackAction(0), - mToolbarFilterAction(0), - mToolbarPasteAction(0), - mItemHighlighted(false), - mLocationChanged(false), - mRemoveFileAfterCopied(false), -// mClipBoardInUse(false), - mFolderContentChanged(false), - mCurrentIndex(), - mOldPassword(), - mPanicCategory(), - mAbsoluteFilePath(), - mOverwriteOptions(), - mModelIndex(), - mNewFileName(), - mProceed(false), - mEraseMBR(false) -{ - setTitle("File Browser"); - - createMenu(); - createContextMenu(); - createToolBar(); -} - -// --------------------------------------------------------------------------- - -void FbFileView::init(EngineWrapper *engineWrapper) -{ - mEngineWrapper = engineWrapper; - - mListView = new HbListView(this); - mListView->listItemPrototype()->setStretchingStyle(HbListViewItem::StretchLandscape); - -// mListView->setItemPrototype(new FbDiskListViewItem(mListView)); - - mFbFileModel = new FbFileModel(mEngineWrapper); - if (!mListView->model()) { - - mEngineWrapper->refreshView(); - - mSortFilterProxyModel = new FileBrowserSortFilterProxyModel(this); - mSortFilterProxyModel->setSourceModel(mFbFileModel); - mSortFilterProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive); - mSearchPanel->setPlaceholderText(QString("Type filter criteria")); - - mListView->setModel(mSortFilterProxyModel); - } - - //mListView->setRootIndex(mFileSystemModel->index(startPath)); - //mListView->setRootIndex(model->index()); - - //setItemVisible(Hb::ToolBarItem, !mEngineWrapper->isDriveListViewActive()); -// mListView->setScrollingStyle(HbScrollArea::PanWithFollowOn); - - connect(mListView, SIGNAL(activated(QModelIndex)), this, SLOT(activated(QModelIndex))); - connect(mListView, SIGNAL(longPressed(HbAbstractViewItem*,QPointF)), - this, SLOT(onLongPressed(HbAbstractViewItem*, QPointF))); - connect(mEngineWrapper, SIGNAL(fileSystemDataChanged()), this, SLOT(refreshList())); - - mNaviPane = new HbLabel(this); - mNaviPane->setPlainText(QString(" ")); // TODO get from settings or default - //mNaviPane->setPlainText(QString(mEngineWrapper->currentPath())); - HbFontSpec fontSpec(HbFontSpec::PrimarySmall); - mNaviPane->setFontSpec(fontSpec); - - // Create layout and add list view and toolbar into layout: - mMainLayout = new QGraphicsLinearLayout(Qt::Vertical); - mMainLayout->addItem(mNaviPane); - mMainLayout->addItem(mListView); - setLayout(mMainLayout); -} - -// --------------------------------------------------------------------------- - -FbFileView::~FbFileView() -{ -// if (mEngineWrapper) { -// delete mEngineWrapper; -// } - if (mContextMenu) { - mContextMenu->deleteLater(); - } - - delete mSortFilterProxyModel; - delete mFbFileModel; - delete mListView; - delete mToolBar; -} - -/** - Initial setup for options menu. - Dynamic menu update during the runtime is performed by updateOptionMenu() which - to menu's aboutToShow() signal. - */ -void FbFileView::createMenu() -{ - createFileMenu(); - createEditMenu(); - createViewMenu(); - createToolsMenu(); - - createSelectionMenuItem(); - createSettingsMenuItem(); - createAboutMenuItem(); - createExitMenuItem(); - - // menu dynamic update - connect(menu(), SIGNAL(aboutToShow()), this, SLOT(updateOptionMenu())); -} - -/** - Initial setup for File submenu - */ -void FbFileView::createFileMenu() -{ - mOptionMenuActions.mFileMenu = menu()->addMenu("File"); - - mOptionMenuActions.mFileBackMoveUp = mOptionMenuActions.mFileMenu->addAction("Back/Move up", this, SLOT(fileBackMoveUp())); - mOptionMenuActions.mFileSearch = mOptionMenuActions.mFileMenu->addAction("Search...", this, SLOT(fileSearch())); - - mOptionMenuActions.mFileNewMenu = mOptionMenuActions.mFileMenu->addMenu("New"); - mOptionMenuActions.mFileNewFile = mOptionMenuActions.mFileNewMenu->addAction("File", this, SLOT(fileNewFile())); - mOptionMenuActions.mFileNewDirectory = mOptionMenuActions.mFileNewMenu->addAction("Directory", this, SLOT(fileNewDirectory())); - - mOptionMenuActions.mFileDelete = mOptionMenuActions.mFileMenu->addAction("Delete", this, SLOT(fileDelete())); - mOptionMenuActions.mFileRename = mOptionMenuActions.mFileMenu->addAction("Rename", this, SLOT(fileRename())); - mOptionMenuActions.mFileTouch = mOptionMenuActions.mFileMenu->addAction("Touch", this, SLOT(fileTouch())); - - mOptionMenuActions.mFileSetAttributes = mOptionMenuActions.mFileMenu->addAction("Set attributes...", this, SLOT(fileSetAttributes())); -} - -/** - Initial setup for Edit submenu - */ -void FbFileView::createEditMenu() -{ - mOptionMenuActions.mEditMenu = menu()->addMenu("Edit"); - - mOptionMenuActions.mEditSnapShotToE = mOptionMenuActions.mEditMenu->addAction("Snap shot to E:", this, SLOT(editSnapShotToE())); - mOptionMenuActions.mEditSnapShotToE->setVisible(false); - mOptionMenuActions.mEditCut = mOptionMenuActions.mEditMenu->addAction("Cut", this, SLOT(editCut())); - mOptionMenuActions.mEditCopy = mOptionMenuActions.mEditMenu->addAction("Copy", this, SLOT(editCopy())); - mOptionMenuActions.mEditPaste = mOptionMenuActions.mEditMenu->addAction("Paste", this, SLOT(editPaste())); - - mOptionMenuActions.mEditCopyToFolder = mOptionMenuActions.mEditMenu->addAction("Copy to folder...", this, SLOT(editCopyToFolder())); - mOptionMenuActions.mEditMoveToFolder = mOptionMenuActions.mEditMenu->addAction("Move to folder...", this, SLOT(editMoveToFolder())); - - mOptionMenuActions.mEditSelect = mOptionMenuActions.mEditMenu->addAction("Select", this, SLOT(editSelect())); - mOptionMenuActions.mEditUnselect = mOptionMenuActions.mEditMenu->addAction("Unselect", this, SLOT(editUnselect())); - mOptionMenuActions.mEditSelectAll = mOptionMenuActions.mEditMenu->addAction("Select all", this, SLOT(editSelectAll())); - mOptionMenuActions.mEditUnselectAll = mOptionMenuActions.mEditMenu->addAction("Unselect all", this, SLOT(editUnselectAll())); -} - -/** - Initial setup for View submenu - */ -void FbFileView::createViewMenu() -{ - mOptionMenuActions.mViewMenu = menu()->addMenu("View"); - //mOptionMenuActions.mViewMenu->menuAction()->setVisible(false); - - mOptionMenuActions.mViewFilterEntries = mOptionMenuActions.mViewMenu->addAction("Filter entries", this, SLOT(viewFilterEntries())); - mOptionMenuActions.mViewRefresh = mOptionMenuActions.mViewMenu->addAction("Refresh", this, SLOT(viewRefresh())); -} - -/** - Initial setup for Tools submenu - */ -void FbFileView::createToolsMenu() -{ - mOptionMenuActions.mToolsMenu = menu()->addMenu("Tools"); - - mOptionMenuActions.mToolsAllAppsToTextFile = mOptionMenuActions.mToolsMenu->addAction("All apps to a text file", this, SLOT(toolsAllAppsToTextFile())); - mOptionMenuActions.mToolsAllAppsToTextFile->setVisible(false); - mOptionMenuActions.mToolsAllFilesToTextFile = mOptionMenuActions.mToolsMenu->addAction("All files to a text file", this, SLOT(toolsAllFilesToTextFile())); - //mOptionMenuActions.mToolsAllFilesToTextFile->setVisible(false); - -// mOptionMenuActions.mToolsAvkonIconCacheMenu = mOptionMenuActions.mToolsMenu->addMenu("Avkon icon cache"); -// mOptionMenuActions.mToolsAvkonIconCacheMenu->menuAction()->setVisible(false); -// mOptionMenuActions.mToolsAvkonIconCacheEnable = mOptionMenuActions.mToolsAvkonIconCacheMenu->addAction("Enable", this, SLOT(toolsAvkonIconCacheEnable())); -// mOptionMenuActions.mToolsAvkonIconCacheDisable = mOptionMenuActions.mToolsAvkonIconCacheMenu->addAction("Clear and disable", this, SLOT(toolsAvkonIconCacheDisable())); - - mOptionMenuActions.mToolsDisableExtendedErrors = mOptionMenuActions.mToolsMenu->addAction("Disable extended errors", this, SLOT(toolsDisableExtendedErrors())); - mOptionMenuActions.mToolsDumpMsgStoreWalk = mOptionMenuActions.mToolsMenu->addAction("Dump msg. store walk", this, SLOT(toolsDumpMsgStoreWalk())); - mOptionMenuActions.mToolsDumpMsgStoreWalk->setVisible(false); - mOptionMenuActions.mToolsEditDataTypes = mOptionMenuActions.mToolsMenu->addAction("Edit data types", this, SLOT(toolsEditDataTypes())); - mOptionMenuActions.mToolsEditDataTypes->setVisible(false); - mOptionMenuActions.mToolsEnableExtendedErrors = mOptionMenuActions.mToolsMenu->addAction("Enable extended errors", this, SLOT(toolsEnableExtendedErrors())); - - mOptionMenuActions.mToolsErrorSimulateMenu = mOptionMenuActions.mToolsMenu->addMenu("Error simulate"); - mOptionMenuActions.mToolsErrorSimulateLeave = mOptionMenuActions.mToolsErrorSimulateMenu->addAction("Leave", this, SLOT(toolsErrorSimulateLeave())); - mOptionMenuActions.mToolsErrorSimulatePanic = mOptionMenuActions.mToolsErrorSimulateMenu->addAction("Panic", this, SLOT(toolsErrorSimulatePanic())); - mOptionMenuActions.mToolsErrorSimulatePanic->setVisible(false); - mOptionMenuActions.mToolsErrorSimulateException = mOptionMenuActions.mToolsErrorSimulateMenu->addAction("Exception", this, SLOT(toolsErrorSimulateException())); - -// mOptionMenuActions.mLocalConnectivityMenu = mOptionMenuActions.mToolsMenu->addMenu("Local connectivity"); -// mOptionMenuActions.mToolsLocalConnectivityActivateInfrared = mOptionMenuActions.mLocalConnectivityMenu->addAction("Activate infrared", this, SLOT(toolsLocalConnectivityActivateInfrared())); -// mOptionMenuActions.mToolsLocalConnectivityLaunchBTUI = mOptionMenuActions.mLocalConnectivityMenu->addAction("Launch BT UI", this, SLOT(toolsLocalConnectivityLaunchBTUI())); -// mOptionMenuActions.mToolsLocalConnectivityLaunchUSBUI = mOptionMenuActions.mLocalConnectivityMenu->addAction("Launch USB UI", this, SLOT(toolsLocalConnectivityLaunchUSBUI())); - - mOptionMenuActions.mToolsMessageAttachmentsMenu = mOptionMenuActions.mToolsMenu->addMenu("Message attachments"); - mOptionMenuActions.mToolsMessageAttachmentsMenu->menuAction()->setVisible(false); - mOptionMenuActions.mToolsMessageInbox = mOptionMenuActions.mToolsMessageAttachmentsMenu->addAction("Inbox", this, SLOT(toolsMessageInbox())); - mOptionMenuActions.mToolsMessageDrafts = mOptionMenuActions.mToolsMessageAttachmentsMenu->addAction("Drafts", this, SLOT(toolsMessageDrafts())); - mOptionMenuActions.mToolsMessageSentItems = mOptionMenuActions.mToolsMessageAttachmentsMenu->addAction("Sent items", this, SLOT(toolsMessageSentItems())); - mOptionMenuActions.mToolsMessageOutbox = mOptionMenuActions.mToolsMessageAttachmentsMenu->addAction("Outbox", this, SLOT(toolsMessageOutbox())); - - mOptionMenuActions.mToolsMemoryInfo = mOptionMenuActions.mToolsMenu->addAction("Memory info", this, SLOT(toolsMemoryInfo())); - mOptionMenuActions.mToolsMemoryInfo->setVisible(false); - - mOptionMenuActions.mToolsSecureBackupMenu = mOptionMenuActions.mToolsMenu->addMenu("Secure backup"); - mOptionMenuActions.mToolsSecureBackupMenu->menuAction()->setVisible(false); - mOptionMenuActions.mToolsSecureBackStart = mOptionMenuActions.mToolsSecureBackupMenu->addAction("Start backup", this, SLOT(toolsSecureBackStart())); - mOptionMenuActions.mToolsSecureBackRestore = mOptionMenuActions.mToolsSecureBackupMenu->addAction("Start restore", this, SLOT(toolsSecureBackRestore())); - mOptionMenuActions.mToolsSecureBackStop = mOptionMenuActions.mToolsSecureBackupMenu->addAction("Stop", this, SLOT(toolsSecureBackStop())); - - mOptionMenuActions.mToolsSetDebugMask = mOptionMenuActions.mToolsMenu->addAction("Set debug mask", this, SLOT(toolsSetDebugMaskQuestion())); - mOptionMenuActions.mToolsShowOpenFilesHere = mOptionMenuActions.mToolsMenu->addAction("Show open files here", this, SLOT(toolsShowOpenFilesHere())); - mOptionMenuActions.mToolsShowOpenFilesHere->setVisible(false); -} - -/** - Creates Selection mode menu item in option menu - */ -void FbFileView::createSelectionMenuItem() -{ - if (!mOptionMenuActions.mSelection) { - mOptionMenuActions.mSelection = menu()->addAction("Selection mode"); - mOptionMenuActions.mSelection->setToolTip("Selection mode"); - mOptionMenuActions.mSelection->setCheckable(true); - connect(mOptionMenuActions.mSelection, SIGNAL(triggered()), this, SLOT(selectionModeChanged())); - } -} - -/** - Creates Setting menu item in option menu - */ -void FbFileView::createSettingsMenuItem() -{ - mOptionMenuActions.mSetting = menu()->addAction("Settings..."); - connect(mOptionMenuActions.mSetting, SIGNAL(triggered()), this, SIGNAL(aboutToShowSettingsView())); -} - - -/** - Creates About menu item in option menu - */ -void FbFileView::createAboutMenuItem() -{ - // about note - mOptionMenuActions.mAbout = menu()->addAction("About"); - connect(mOptionMenuActions.mAbout, SIGNAL(triggered()), this, SLOT(about())); -} - -/** - Creates Exit menu item in option menu - */ -void FbFileView::createExitMenuItem() -{ - // application exit - mOptionMenuActions.mExit = menu()->addAction("Exit"); - connect(mOptionMenuActions.mExit, SIGNAL(triggered()), qApp, SLOT(quit())); -} - -/** - update menu: disk admin available only in device root view. edit available only in folder view - when file or folder content exist in current folder, or clipboard has copied item. - file and view menus updated every time regarding the folder content. - tools, settings, about, exit always available. - If there's remove and add operations at same time, always remove first - to keep to the correct menu items order. - */ -void FbFileView::updateOptionMenu() -{ - bool isFileItemListEmpty = mFbFileModel->rowCount() == 0; - bool isNormalModeActive = true; //iModel->FileUtils()->IsNormalModeActive(); - bool isCurrentDriveReadOnly = mEngineWrapper->isCurrentDriveReadOnly(); //iModel->FileUtils()->IsCurrentDriveReadOnly(); - // bool isCurrentItemDirectory = mEngineWrapper->getFileEntry(currentItemIndex()).isDir(); - // bool currentSelected = true; //iContainer->ListBox()->View()->ItemIsSelected(iContainer->ListBox()->View()->CurrentItemIndex()); - bool isAllSelected = mListView->selectionModel()->selection().count() == mFbFileModel->rowCount(); - //bool isNoneSelected = mListView->selectionModel()->selection().count() != 0; - bool hasSelectedItems = mListView->selectionModel()->selection().count() != 0; - bool isSelectionMode = mOptionMenuActions.mSelection && mOptionMenuActions.mSelection->isChecked(); - bool isClipBoardEmpty = !mEngineWrapper->isClipBoardListInUse(); - //bool showSnapShot = false; //iModel->FileUtils()->DriveSnapShotPossible(); - - bool showEditMenu(true); - if (isFileItemListEmpty && isClipBoardEmpty) - showEditMenu = false; - else - showEditMenu = true; - - mOptionMenuActions.mEditMenu->menuAction()->setVisible(showEditMenu); - - //mOptionMenuActions.mFileBackMoveUp->setVisible( !isDriveListViewActive); - - //aMenuPane->SetItemDimmed(EFileBrowserCmdFileView, isFileItemListEmpty || !hasSelectedItems || isCurrentItemDirectory); - //aMenuPane->SetItemDimmed(EFileBrowserCmdFileEdit, isFileItemListEmpty || !hasSelectedItems || isCurrentItemDirectory); - //aMenuPane->SetItemDimmed(EFileBrowserCmdFileSendTo, isFileItemListEmpty || driveListActive || isCurrentItemDirectory); - - mOptionMenuActions.mFileNewMenu->menuAction()->setVisible(!isCurrentDriveReadOnly); - mOptionMenuActions.mFileDelete->setVisible(!isFileItemListEmpty && !isCurrentDriveReadOnly && hasSelectedItems/*isSelectionMode*/); - mOptionMenuActions.mFileRename->setVisible(!isFileItemListEmpty && !isCurrentDriveReadOnly && hasSelectedItems /*&& !isSelectionMode*/); - mOptionMenuActions.mFileTouch->setVisible(!isFileItemListEmpty && !isCurrentDriveReadOnly && hasSelectedItems); - - mOptionMenuActions.mFileSetAttributes->setVisible(!isFileItemListEmpty && !isCurrentDriveReadOnly && hasSelectedItems); - // TODO mOptionMenuActions.mFileCompress->setVisible(!(isCurrentDriveReadOnly || isFileItemListEmpty || !hasSelectedItems || isCurrentItemDirectory)); - // TODO mOptionMenuActions.mFileDecompress->setVisible(!(isCurrentDriveReadOnly || isFileItemListEmpty || !hasSelectedItems || isCurrentItemDirectory)); - - mOptionMenuActions.mEditMenu->menuAction()->setVisible( (!isSelectionMode && !isClipBoardEmpty && !isCurrentDriveReadOnly) - || (isSelectionMode)); - mOptionMenuActions.mEditCut->setVisible(!isFileItemListEmpty && !isCurrentDriveReadOnly && isSelectionMode && hasSelectedItems); - mOptionMenuActions.mEditCopy->setVisible(!isFileItemListEmpty && isSelectionMode && hasSelectedItems); - mOptionMenuActions.mEditPaste->setVisible(!isClipBoardEmpty && !isCurrentDriveReadOnly); - mOptionMenuActions.mEditCopyToFolder->setVisible(!isFileItemListEmpty && isSelectionMode && hasSelectedItems); - mOptionMenuActions.mEditMoveToFolder->setVisible(!isFileItemListEmpty && !isCurrentDriveReadOnly && isSelectionMode && hasSelectedItems); - - mOptionMenuActions.mEditSelect->setVisible(false/*!currentSelected && !isFileItemListEmpty*/); - mOptionMenuActions.mEditUnselect->setVisible(false/*currentSelected && !isFileItemListEmpty*/); - mOptionMenuActions.mEditSelectAll->setVisible(!isFileItemListEmpty && isSelectionMode && !isAllSelected); - mOptionMenuActions.mEditUnselectAll->setVisible(!isFileItemListEmpty && hasSelectedItems); - - // TODO mOptionMenuActions.mViewSort->setVisible(!(!isNormalModeActive || isFileItemListEmpty)); - // TODO mOptionMenuActions.mViewOrder->setVisible(!(!isNormalModeActive || isFileItemListEmpty)); - mOptionMenuActions.mViewRefresh->setVisible(isNormalModeActive); - mOptionMenuActions.mViewFilterEntries->setVisible(!isFileItemListEmpty); - - // TODO R_FILEBROWSER_VIEW_SORT_SUBMENU - // aMenuPane->SetItemButtonState(iModel->FileUtils()->SortMode(), EEikMenuItemSymbolOn); - - // TODO R_FILEBROWSER_VIEW_ORDER_SUBMENU - // aMenuPane->SetItemButtonState(iModel->FileUtils()->OrderMode(), EEikMenuItemSymbolOn); - - // aResourceId == R_FILEBROWSER_TOOLS_SUBMENU - bool noExtendedErrorsAllowed = mEngineWrapper->ErrRdFileExists(); - mOptionMenuActions.mToolsDisableExtendedErrors->setVisible(noExtendedErrorsAllowed); - mOptionMenuActions.mToolsEnableExtendedErrors->setVisible(!noExtendedErrorsAllowed); - -// bool infraRedAllowed = mEngineWrapper->FileExists(KIRAppPath); -// bool bluetoothAllowed = mEngineWrapper->FileExists(KBTAppPath); -// bool usbAllowed = mEngineWrapper->FileExists(KUSBAppPath); -// -// bool noLocalCon = !infraRedAllowed && !bluetoothAllowed && !usbAllowed; -// mOptionMenuActions.mToolsLocalConnectivityMenu->menuAction()->setVisible(!noLocalCon); -// -// mOptionMenuActions.mToolsLocalConnectivityActivateInfrared->setVisible(infraRedAllowed); -// mOptionMenuActions.mToolsLocalConnectivityLaunchBTUI->setVisible(bluetoothAllowed); -// mOptionMenuActions.mToolsLocalConnectivityLaunchUSBUI->setVisible(usbAllowed); -} - -void FbFileView::createContextMenu() -{ - mContextMenu = new HbMenu(); - connect(mContextMenu, SIGNAL(aboutToShow()), this, SLOT(updateContextMenu())); - - createFileContextMenu(); - createEditContextMenu(); - createViewContextMenu(); -} - - -void FbFileView::createFileContextMenu() -{ - mContextMenuActions.mFileMenu = mContextMenu->addMenu("File"); - - //mContextMenuActions.mFileBackMoveUp = mContextMenuActions.mFileMenu->addAction("Back/Move up (<-)", this, SLOT(fileBackMoveUp())); -// mContextMenuActions.mFileOpenDirectory = mContextMenuActions.mFileMenu->addAction("Open directory (->)", this, SLOT(fileOpenDirectory())); - mContextMenuActions.mFileOpenDirectory = mContextMenu->addAction("Open directory (->)", this, SLOT(fileOpenDirectory())); - mContextMenuActions.mSearch = mContextMenu->addAction("Search...", this, SLOT(fileSearch())); - mContextMenuActions.mFileSearch = mContextMenuActions.mFileMenu->addAction("Search...", this, SLOT(fileSearch())); - - mContextMenuActions.mFileDelete = mContextMenuActions.mFileMenu->addAction("Delete", this, SLOT(fileDelete())); - mContextMenuActions.mFileRename = mContextMenuActions.mFileMenu->addAction("Rename", this, SLOT(fileRename())); - mContextMenuActions.mFileTouch = mContextMenuActions.mFileMenu->addAction("Touch", this, SLOT(fileTouch())); - mContextMenuActions.mFileProperties = mContextMenuActions.mFileMenu->addAction("Properties", this, SLOT(fileProperties())); - - mContextMenuActions.mFileChecksumsMenu = mContextMenuActions.mFileMenu->addMenu("Checksums"); - mContextMenuActions.mFileChecksumsMD5 = mContextMenuActions.mFileChecksumsMenu->addAction("MD5", this, SLOT(fileChecksumsMD5())); - mContextMenuActions.mFileChecksumsMD2 = mContextMenuActions.mFileChecksumsMenu->addAction("MD2", this, SLOT(fileChecksumsMD2())); - mContextMenuActions.mFileChecksumsSHA1 = mContextMenuActions.mFileChecksumsMenu->addAction("SHA-1", this, SLOT(fileChecksumsSHA1())); - - mContextMenuActions.mFileSetAttributes = mContextMenuActions.mFileMenu->addAction("Set attributes...", this, SLOT(fileSetAttributes())); -} - -void FbFileView::createEditContextMenu() -{ - mContextMenuActions.mEditMenu = mContextMenu->addMenu("Edit"); - - //mContextMenuActions.mEditSnapShotToE = mContextMenuActions.mEditMenu->addAction("Snap shot to E:", this, SLOT(editSnapShotToE())); -// mContextMenuActions.mEditSnapShotToE->setVisible(false); - mContextMenuActions.mEditCut = mContextMenuActions.mEditMenu->addAction("Cut", this, SLOT(editCut())); - mContextMenuActions.mEditCopy = mContextMenuActions.mEditMenu->addAction("Copy", this, SLOT(editCopy())); - mContextMenuActions.mEditPaste = mContextMenuActions.mEditMenu->addAction("Paste", this, SLOT(editPaste())); - - mContextMenuActions.mEditCopyToFolder = mContextMenuActions.mEditMenu->addAction("Copy to folder...", this, SLOT(editCopyToFolder())); - mContextMenuActions.mEditMoveToFolder = mContextMenuActions.mEditMenu->addAction("Move to folder...", this, SLOT(editMoveToFolder())); -} - -void FbFileView::createViewContextMenu() -{ - -} - -void FbFileView::updateContextMenu() -{ - bool isFileItemListEmpty = mFbFileModel->rowCount() == 0; -// bool isNormalModeActive = true; //iModel->FileUtils()->IsNormalModeActive(); - bool isCurrentDriveReadOnly = mEngineWrapper->isCurrentDriveReadOnly(); - bool isCurrentItemDirectory = mEngineWrapper->getFileEntry(currentItemIndex()).isDir(); - bool hasSelectedItems = mListView->selectionModel()->selection().count() != 0; - bool isSelectionMode = mOptionMenuActions.mSelection && mOptionMenuActions.mSelection->isChecked(); - bool isClipBoardEmpty = !mEngineWrapper->isClipBoardListInUse(); - - mContextMenuActions.mFileOpenDirectory->setVisible(!isFileItemListEmpty && isCurrentItemDirectory && isSelectionMode); - mContextMenuActions.mSearch->setVisible(!isFileItemListEmpty && isSelectionMode && isCurrentItemDirectory); - mContextMenuActions.mFileSearch->setVisible(!isFileItemListEmpty && !isSelectionMode && isCurrentItemDirectory); - // File submenu - //mContextMenuActions.mFileBackMoveUp->setVisible(); - mContextMenuActions.mFileMenu->menuAction()->setVisible(!isSelectionMode); - - mContextMenuActions.mFileDelete->setVisible(!isFileItemListEmpty && !isCurrentDriveReadOnly); - mContextMenuActions.mFileRename->setVisible(!isFileItemListEmpty && !isCurrentDriveReadOnly && !isSelectionMode); - mContextMenuActions.mFileTouch->setVisible(!isFileItemListEmpty && !isCurrentDriveReadOnly); - mContextMenuActions.mFileProperties->setVisible(!isFileItemListEmpty && !isSelectionMode); - - mContextMenuActions.mFileChecksumsMenu->menuAction()->setVisible(!isFileItemListEmpty && !isSelectionMode && !isCurrentItemDirectory); - - // Edit submenu - mContextMenuActions.mEditMenu->menuAction()->setVisible(!isSelectionMode); - mContextMenuActions.mEditCut->setVisible(!(isCurrentDriveReadOnly || isFileItemListEmpty)); - mContextMenuActions.mEditCopy->setVisible(!(isFileItemListEmpty)); - mContextMenuActions.mEditPaste->setVisible(!isClipBoardEmpty && !isCurrentDriveReadOnly); - mContextMenuActions.mEditCopyToFolder->setVisible(!isFileItemListEmpty); - mContextMenuActions.mEditMoveToFolder->setVisible(!(isCurrentDriveReadOnly || isFileItemListEmpty)); -} - -// --------------------------------------------------------------------------- - -void FbFileView::onLongPressed(HbAbstractViewItem *listViewItem, QPointF coords) -{ - QModelIndex proxyIndex = listViewItem->modelIndex(); - //map to source model - mCurrentIndex = mSortFilterProxyModel->mapToSource(proxyIndex); - - mContextMenu->setPreferredPos(coords); - mContextMenu->show(); -} - -/** - Create a file browser tool bar - */ -void FbFileView::createToolBar() -{ - mToolBar = toolBar(); - - mToolbarBackAction = new HbAction(mToolBar); - mToolbarBackAction->setToolTip("Back"); - mToolbarBackAction->setIcon(HbIcon(QString(":/qgn_indi_tb_filebrowser_folder_parent.svg"))); - connect(mToolbarBackAction, SIGNAL(triggered()), this, SLOT(fileBackMoveUp())); - mToolBar->addAction(mToolbarBackAction); - - // Find button and its extension - HbToolBarExtension* filterExtension = new HbToolBarExtension(); - // Set search panel widget - mSearchPanel = new HbSearchPanel(filterExtension); - mSearchPanel->setMinimumWidth( 360 ); // TODO should be based on layout, screen width - connect(mSearchPanel, SIGNAL(criteriaChanged(const QString &)), this, SLOT(filterCriteriaChanged(const QString &))); - connect(mSearchPanel, SIGNAL(exitClicked()), filterExtension, SLOT(close())); - connect(mSearchPanel, SIGNAL(exitClicked()), this, SLOT(clearFilterCriteria())); - filterExtension->setContentWidget(mSearchPanel); - - mToolbarFilterAction = mToolBar->addExtension(filterExtension); - mToolbarFilterAction->setToolTip("Filter"); - mToolbarFilterAction->setIcon(HbIcon(QString(":/qgn_indi_tb_filebrowser_find.svg"))); - //connect(mToolbarFilterAction, SIGNAL(triggered()), this, SLOT(viewFilterEntries())); - - if (mOptionMenuActions.mSelection) { - // TODO Selection mode icon to be added - //mOptionMenuActions.mSelection->setIcon(HbIcon(QString(":/qgn_indi_tb_filebrowser_selection_active.svg"))); - mToolBar->addAction(mOptionMenuActions.mSelection); - } - - mToolbarPasteAction = new HbAction(mToolBar); - mToolbarPasteAction->setText("Paste"); - mToolbarPasteAction->setToolTip("Paste"); - // TODO Paste icon to be added - //mToolbarPasteAction->setIcon(HbIcon(QString(":/qgn_indi_tb_filebrowser_folder_parent.svg"))); - connect(mToolbarPasteAction, SIGNAL(triggered()), this, SLOT(editPaste())); - mToolBar->addAction(mToolbarPasteAction); - mToolbarPasteAction->setEnabled(false); -} - -/** - Refresh FileBrowser view - */ -void FbFileView::refreshList() -{ - editUnselectAll(); - mEngineWrapper->refreshView(); - mSearchPanel->setCriteria(QString("")); - mListView->reset(); - - if (mListView->model() && mListView->model()->rowCount() > 0) { - QModelIndex firstIndex = mListView->model()->index(0, 0); - mListView->scrollTo(firstIndex); - } - - mToolbarPasteAction->setEnabled(mEngineWrapper->isClipBoardListInUse()); - - TListingMode listingMode = mEngineWrapper->listingMode(); - if (listingMode == ENormalEntries) - mNaviPane->setPlainText(QString(mEngineWrapper->currentPath())); - else if (listingMode == ESearchResults) - mNaviPane->setPlainText(QString(tr("Search results"))); - else if (listingMode == EOpenFiles) - mNaviPane->setPlainText(QString(tr("Open files"))); - else if (listingMode == EMsgAttachmentsInbox) - mNaviPane->setPlainText(QString(tr("Attachments in Inbox"))); - else if (listingMode == EMsgAttachmentsDrafts) - mNaviPane->setPlainText(QString(tr("Attachments in Drafts"))); - else if (listingMode == EMsgAttachmentsSentItems) - mNaviPane->setPlainText(QString(tr("Attachments in Sent Items"))); - else if (listingMode == EMsgAttachmentsOutbox) - mNaviPane->setPlainText(QString(tr("Attachments in Outbox"))); -} - -// --------------------------------------------------------------------------- - -void FbFileView::fileOpen(HbAction *action) -{ -// Q_UNUSED(action); - HbSelectionDialog *dlg = static_cast(sender()); - if(!action && dlg && dlg->selectedItems().count()){ - int selectionIndex = dlg->selectedItems().at(0).toInt(); - - if (selectionIndex == 0) { - // open editor view - emit aboutToShowEditorView(mAbsoluteFilePath, true); - } else if (selectionIndex == 1) { - // AppArc - mEngineWrapper->openAppArc(mAbsoluteFilePath); - } else { - // DocHandler - mEngineWrapper->openDocHandler(mAbsoluteFilePath, true); - } - } -} - -/** - Open overwrite dialog - */ -void FbFileView::fileOverwriteDialog() -{ - mOverwriteOptions = OverwriteOptions(); - // open user-dialog to select: view as text/hex, open w/AppArc or open w/DocH. embed - QStringList list; - list << QString("Overwrite all") - << QString("Skip all existing") - << QString("Gen. unique filenames") - << QString("Query postfix"); - openListDialog(list, QString("Overwrite?"), this, SLOT(fileOverwrite(HbAction *))); -} - -/** - File overwrite - */ -void FbFileView::fileOverwrite(HbAction *action) -{ - HbSelectionDialog *dlg = static_cast(sender()); - if(!action && dlg && dlg->selectedItems().count()) { - mOverwriteOptions.queryIndex = dlg->selectedItems().at(0).toInt(); - if (mOverwriteOptions.queryIndex == EFileActionQueryPostFix) { - QString heading = QString("Postfix"); - HbInputDialog::queryText(heading, this, SLOT(fileOverwritePostfix(HbAction *)), QString(), scene()); - } else if (mOverwriteOptions.queryIndex == EFileActionSkipAllExisting) { - mOverwriteOptions.overWriteFlags = 0; - } - } else { - mOverwriteOptions.doFileOperations = false; - } -} - -/** - File overwrite postfix query dialog - */ -void FbFileView::fileOverwritePostfix(HbAction *action) -{ - HbInputDialog *dlg = static_cast(sender()); - if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { - mOverwriteOptions.postFix = dlg->value().toString(); - } else { - mOverwriteOptions.doFileOperations = false; - } -} - -// --------------------------------------------------------------------------- -/** - Show a list dialog - \param List aList of item to select item from. - \param Title text titleText of a dialog heading widget - \return None - */ -void FbFileView::openListDialog(const QStringList& items, const QString &titleText, QObject* receiver, const char* member) -{ - // Create a list and some simple content for it - HbSelectionDialog *dlg = new HbSelectionDialog(); - dlg->setAttribute(Qt::WA_DeleteOnClose); - // Set items to be popup's content - dlg->setStringItems(items); - dlg->setSelectionMode(HbAbstractItemView::SingleSelection); - - HbLabel *title = new HbLabel(dlg); - title->setPlainText(titleText); - dlg->setHeadingWidget(title); - - // Launch popup and handle the user response: - dlg->open(receiver, member); -} - -// --------------------------------------------------------------------------- - -void FbFileView::openPropertyDialog(const QStringList& propertyList, const QString& title) -{ - HbDialog *dialog = new HbDialog(); - dialog->setDismissPolicy(HbPopup::TapOutside); - dialog->setTimeout(HbPopup::NoTimeout); - - HbLabel *titleWidget = new HbLabel(); - titleWidget->setPlainText(title); - dialog->setHeadingWidget(titleWidget); - - // Create a list and some simple content for it - HbListWidget *list = new HbListWidget(); - QString str; - foreach (str, propertyList) { - list->addItem(str); - } - - // Connect list item activation signal to close the popup - connect(list, SIGNAL(activated(HbListWidgetItem*)), dialog, SLOT(close())); - - HbAction *cancelAction = new HbAction("Close"); - dialog->setPrimaryAction(cancelAction); - - // Set listwidget to be popup's content - dialog->setContentWidget(list); - // Launch popup and handle the user response: - dialog->open(); -} - -/** - Stores selection or current index mapped to source model - */ -void FbFileView::storeSelectedItemsOrCurrentItem() -{ - QItemSelectionModel *selectionIndexes = mListView->selectionModel(); - - // by default use selected items - if (selectionIndexes) { - bool isSelectionMode = mOptionMenuActions.mSelection && mOptionMenuActions.mSelection->isChecked(); - if (isSelectionMode) { - if (selectionIndexes->hasSelection()) { - QItemSelection proxyItemSelection = mListView->selectionModel()->selection(); - QItemSelection itemSelection = mSortFilterProxyModel->mapSelectionToSource(proxyItemSelection); - mSelectionIndexes = itemSelection.indexes(); - } else { // or if none selected, clear selection - mSelectionIndexes.clear(); - } - } else { // or if none selected, use the current item index - mSelectionIndexes.clear(); - QModelIndex currentIndex = currentItemIndex(); //alreade mapped to source model - mSelectionIndexes.append(currentIndex); - } - } -} - -// --------------------------------------------------------------------------- - -QModelIndex FbFileView::currentItemIndex() -{ - return mCurrentIndex; -} - -// --------------------------------------------------------------------------- -// operations in File Menu -// --------------------------------------------------------------------------- - -/** - Move back/up in folder browsing history - */ -void FbFileView::fileBackMoveUp() -{ - mLocationChanged = true; - mEngineWrapper->moveUpOneLevel(); - //mListView->setRootIndex(currentItemIndex()); - refreshList(); - if (mEngineWrapper->isDriveListViewActive()) { - emit aboutToShowDriveView(); - } -} - -void FbFileView::fileOpenDirectory() -{ - mLocationChanged = true; - // get selected drive or directory from list view model and open it: - //if (mListView->selectionModel()->hasSelection()) { -// if (mListView->selectionModel()->selection().count() != 0) { -// QModelIndex currentIndex = currentItemIndex(); - mEngineWrapper->moveDownToDirectory(currentItemIndex()); -// mListView->setRootIndex(currentItemIndex()); - refreshList(); -// } else { -// Notifications::showErrorNote("not selected item!"); -// } -} - -void FbFileView::fileSearch() -{ - QString searchPath; - HbAction *contextrMenuAction = static_cast(sender()); - if (contextrMenuAction - && (contextrMenuAction == mContextMenuActions.mSearch - || contextrMenuAction == mContextMenuActions.mFileSearch) - && mEngineWrapper->getFileEntry(currentItemIndex()).isDir()) { - searchPath = mEngineWrapper->currentPath() - + mEngineWrapper->getFileEntry(currentItemIndex()).name() - + QString("\\"); - } else { - searchPath = mEngineWrapper->currentPath(); - } - - emit aboutToShowSearchView(searchPath); -} - -/** - Open new file dialog - */ -void FbFileView::fileNewFile() -{ - QString heading = QString("Enter filename"); - HbInputDialog::queryText(heading, this, SLOT(doFileNewFile(HbAction*)), QString(), scene()); -} - -/** - Create a new file in current directory with a name queried from user - */ -void FbFileView::doFileNewFile(HbAction *action) -{ - HbInputDialog *dlg = static_cast(sender()); - if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { - QString newFileName = dlg->value().toString(); - mEngineWrapper->createNewFile(newFileName); - refreshList(); - } -} - -/** - Open new directory dialog - */ -void FbFileView::fileNewDirectory() -{ - QString heading = QString("Enter directory name"); - HbInputDialog::queryText(heading, this, SLOT(doFileNewDirectory(HbAction*)), QString(), scene()); -} - -/** - Create a new directory in current directory with a name queried from user - */ -void FbFileView::doFileNewDirectory(HbAction *action) -{ - HbInputDialog *dlg = static_cast(sender()); - if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { - QString newDirectoryName = dlg->value().toString(); - mEngineWrapper->createNewDirectory(newDirectoryName); - refreshList(); - } -} - -/** - Question for Delete actually selected files - */ -void FbFileView::fileDelete() -{ - storeSelectedItemsOrCurrentItem(); - const QString messageFormat = "Delete %1 entries?"; - QString message = messageFormat.arg(mSelectionIndexes.count()); - HbMessageBox::question(message, this, SLOT(doFileDelete(int)), HbMessageBox::Yes | HbMessageBox::No); -} - -/** - Delete actually selected files - */ -void FbFileView::doFileDelete(int action) -{ - if (action == HbMessageBox::Yes) { - mEngineWrapper->deleteItems(mSelectionIndexes); - mEngineWrapper->startExecutingCommands(QString("Deleting")); - } -} - -/** - Open rename dialog for actually selected files - */ -void FbFileView::fileRename() -{ - storeSelectedItemsOrCurrentItem(); - mEngineWrapper->setCurrentSelection(mSelectionIndexes); - - for (int i(0), ie(mSelectionIndexes.count()); i < ie; ++i ) { - mProceed = (i == ie-1); // if the last item - mModelIndex = mSelectionIndexes.at(i); - FbFileEntry entry = mEngineWrapper->getFileEntry(mModelIndex); - - QString heading = QString("Enter new name"); - HbInputDialog::queryText(heading, this, SLOT(doFileRename(HbAction*)), entry.name(), scene()); - } -} - -/** - Rename actually selected files - */ -void FbFileView::doFileRename(HbAction *action) -{ - HbInputDialog *dlg = static_cast(sender()); - if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { - mNewFileName = dlg->value().toString(); - - if (mEngineWrapper->targetExists(mModelIndex, mNewFileName)) { - const QString messageTemplate = QString("%1 already exists, overwrite?"); - QString message = messageTemplate.arg(mNewFileName); - HbMessageBox::question(message, this, SLOT(doFileRenameFileExist(int)), HbMessageBox::Yes | HbMessageBox::No); - } else { - proceedFileRename(); - } - } -} - -/** - Rename actually selected files - */ -void FbFileView::doFileRenameFileExist(int action) -{ - if (action == HbMessageBox::Yes) { - proceedFileRename(); - } -} - - -void FbFileView::proceedFileRename() -{ - mEngineWrapper->rename(mModelIndex, mNewFileName); - if (mProceed) { - mEngineWrapper->startExecutingCommands(QString("Renaming")); - refreshList(); - } -} - -/** - Touch actually selected files - */ -void FbFileView::fileTouch() -{ - storeSelectedItemsOrCurrentItem(); - mEngineWrapper->setCurrentSelection(mSelectionIndexes); - - if (mEngineWrapper->selectionHasDirs()) { - const QString message = "Recurse touch for all selected dirs?"; - HbMessageBox::question(message, this, SLOT(doFileTouch(int)), HbMessageBox::Yes | HbMessageBox::No); - } else { - proceedFileTouch(false); - } -} - -/** - Touch actually selected files - */ -void FbFileView::doFileTouch(int action) -{ - bool recurse = false; - if (action == HbMessageBox::Yes) { - recurse = true; - } - proceedFileTouch(recurse); -} - -void FbFileView::proceedFileTouch(bool recurse) -{ - mEngineWrapper->touch(recurse); - mEngineWrapper->startExecutingCommands(QString("Touching")); - refreshList(); -} - -void FbFileView::fileChecksumsMD5() -{ - fileChecksums(EFileChecksumsMD5); -} - -void FbFileView::fileChecksumsMD2() -{ - fileChecksums(EFileChecksumsMD2); -} - -void FbFileView::fileChecksumsSHA1() -{ - fileChecksums(EFileChecksumsSHA1); -} - -void FbFileView::fileChecksums(TFileBrowserCmdFileChecksums checksumType) -{ - mEngineWrapper->showFileCheckSums(currentItemIndex(), checksumType); -} - -/** - Show file properties - */ -void FbFileView::fileProperties() -{ - QModelIndex currentIndex = currentItemIndex(); - QStringList propertyList; - QString titleText; - mEngineWrapper->properties(currentIndex, propertyList, titleText); - openPropertyDialog(propertyList, titleText); -} - -void FbFileView::fileSetAttributes() -{ - storeSelectedItemsOrCurrentItem(); - mEngineWrapper->setCurrentSelection(mSelectionIndexes); - - QString attributesViewTitle("Multiple entries"); - - quint32 setAttributesMask(0); - quint32 clearAttributesMask(0); - bool recurse(false); - - // set default masks if only one file selected - if (mSelectionIndexes.count() == 1) - { - mModelIndex = mSelectionIndexes.at(0); - FbFileEntry fileEntry = mEngineWrapper->getFileEntry(mModelIndex); - - attributesViewTitle = fileEntry.name(); - - if (fileEntry.isArchive()) - setAttributesMask |= KEntryAttArchive; - else - clearAttributesMask |= KEntryAttArchive; - - if (fileEntry.isHidden()) - setAttributesMask |= KEntryAttHidden; - else - clearAttributesMask |= KEntryAttHidden; - - if (fileEntry.isReadOnly()) - setAttributesMask |= KEntryAttReadOnly; - else - clearAttributesMask |= KEntryAttReadOnly; - - if (fileEntry.isSystem()) - setAttributesMask |= KEntryAttSystem; - else - clearAttributesMask |= KEntryAttSystem; - } - - emit aboutToShowAttributesView(attributesViewTitle, setAttributesMask, clearAttributesMask, recurse); -} - -// edit menu -void FbFileView::editSnapShotToE() -{ - -} - -/** - Set selected files into clipboard. - Selected item will be removed after paste operation. - */ -void FbFileView::editCut() -{ - storeSelectedItemsOrCurrentItem(); - - // Store indices to clipboard - mClipboardIndexes.clear(); - for (int i = 0; i < mSelectionIndexes.size(); ++i) { - mClipboardIndexes.append(mSelectionIndexes.at(i)); - } - - mEngineWrapper->clipboardCut(mClipboardIndexes); - mEngineWrapper->setCurrentSelection(mClipboardIndexes); - - int operations = mClipboardIndexes.count(); - const QString message = QString ("%1 entries cut to clipboard"); - QString noteMsg = message.arg(operations); - - mToolbarPasteAction->setEnabled(true); - Notifications::showInformationNote(noteMsg); -} - -/** - Set selected files into clipboard. - Selected item will not be removed after paste operation. - */ -void FbFileView::editCopy() -{ - storeSelectedItemsOrCurrentItem(); - - // Store indices to clipboard - mClipboardIndexes.clear(); - for (int i = 0; i < mSelectionIndexes.size(); ++i) { - mClipboardIndexes.append(mSelectionIndexes.at(i)); - } - - mEngineWrapper->clipboardCopy(mClipboardIndexes); - mEngineWrapper->setCurrentSelection(mClipboardIndexes); - - int operations = mClipboardIndexes.count(); - - const QString message = QString ("%1 entries copied to clipboard"); - QString noteMsg = message.arg(operations); - - mToolbarPasteAction->setEnabled(true); - Notifications::showInformationNote(noteMsg); -} - -/** - Moves or copies file selection stored in clipboard to a actual directory. - Removing files depend on previous operation, i.e. Cut or Copy - */ -void FbFileView::editPaste() -{ - bool someEntryExists(false); - - someEntryExists = mEngineWrapper->isDestinationEntriesExists(mClipboardIndexes, mEngineWrapper->currentPath()); - if (someEntryExists) { - fileOverwriteDialog(); - } - - mEngineWrapper->clipboardPaste(mOverwriteOptions); - mEngineWrapper->startExecutingCommands(mEngineWrapper->getClipBoardMode() == EClipBoardModeCut ? - QString("Moving") : QString("Copying") ); -} - -/** - Open copy to folder new filename dialog - */ -void FbFileView::editCopyToFolder() -{ - QString heading = QString("Enter new name"); - FbCopyToFolderSelectionDialog *folderSelectionDialog = new FbCopyToFolderSelectionDialog(); - folderSelectionDialog->open(this, SLOT(doEditCopyToFolder(int))); -} - -/** - Copies current file selection to a queried directory. - */ -void FbFileView::doEditCopyToFolder(int action) -{ - FbCopyToFolderSelectionDialog *dlg = qobject_cast(sender()); - if (dlg && action == HbDialog::Accepted) { - QString targetDir = dlg->selectedFolder(); - - bool someEntryExists(false); - - // TODO Set entry items here - storeSelectedItemsOrCurrentItem(); - mEngineWrapper->setCurrentSelection(mSelectionIndexes); - - someEntryExists = mEngineWrapper->isDestinationEntriesExists(mSelectionIndexes, targetDir); - if (someEntryExists) { - fileOverwriteDialog(); - } - mEngineWrapper->copyToFolder(targetDir, mOverwriteOptions, false); - mEngineWrapper->startExecutingCommands(QString("Copying")); - } -} - -/** - Open move to folder new filename dialog. - */ -void FbFileView::editMoveToFolder() -{ - QString heading = QString("Enter new name"); - FbMoveToFolderSelectionDialog *folderSelectionDialog = new FbMoveToFolderSelectionDialog(); - folderSelectionDialog->open(this, SLOT(doEditMoveToFolder(int))); -} - -/** - Moves current file selection to a queried directory. - */ -void FbFileView::doEditMoveToFolder(int action) -{ - FbMoveToFolderSelectionDialog *dlg = qobject_cast(sender()); - if (dlg && action == HbDialog::Accepted) { - QString targetDir = dlg->selectedFolder(); - - bool someEntryExists(false); - - // TODO Set entry items here - storeSelectedItemsOrCurrentItem(); - mEngineWrapper->setCurrentSelection(mSelectionIndexes); - - someEntryExists = mEngineWrapper->isDestinationEntriesExists(mSelectionIndexes, targetDir); - if (someEntryExists) { - fileOverwriteDialog(); - } - mEngineWrapper->copyToFolder(targetDir, mOverwriteOptions, true); - mEngineWrapper->startExecutingCommands(QString("Moving")); - } -} - -/** - Select current file - */ -void FbFileView::editSelect() -{ - QItemSelectionModel *selectionModel = mListView->selectionModel(); - if (selectionModel) { - selectionModel->select(selectionModel->currentIndex(), QItemSelectionModel::SelectCurrent); - selectionModel->select(selectionModel->currentIndex(), QItemSelectionModel::Select); - refreshList(); - } -} - -/** - Unselect current file - */ -void FbFileView::editUnselect() -{ - QItemSelectionModel *selectionModel = mListView->selectionModel(); - if (selectionModel) { - selectionModel->select(selectionModel->currentIndex(), QItemSelectionModel::Deselect); -// itemHighlighted(selectionModel->currentIndex()); - } -} - -/** - Select all files - */ -void FbFileView::editSelectAll() -{ - QItemSelectionModel *selectionModel = mListView->selectionModel(); - if (selectionModel) { - - //if (mFileBrowserModel->rowCount() > 0) { - if (mListView->model() && mListView->model()->rowCount() > 0) { - QModelIndex firstIndex = mListView->model()->index(0, 0); - QModelIndex lastIndex = mListView->model()->index( (mListView->model()->rowCount() - 1), 0); - - QItemSelection itemSelection(firstIndex, lastIndex); - selectionModel->select(itemSelection, QItemSelectionModel::SelectCurrent); - } - } -} - -/** - Unselect all files - */ -void FbFileView::editUnselectAll() -{ - QItemSelectionModel *selectionModel = mListView->selectionModel(); - if (selectionModel) { - selectionModel->clearSelection(); - } -} - -// --------------------------------------------------------------------------- -// view menu -// --------------------------------------------------------------------------- -void FbFileView::viewFilterEntries() -{ - if (mToolBar && mToolBar->actions().count() > 1 && mToolBar->actions().at(1)) { - if (mToolbarFilterAction && mToolbarFilterAction->toolBarExtension()) { - HbToolBarExtension *tbeFilter = mToolbarFilterAction->toolBarExtension(); - tbeFilter->open(); - } - } -} - -/** - Set filter criteria to proxy model - */ -void FbFileView::filterCriteriaChanged(const QString &criteria) -{ - mSortFilterProxyModel->setFilterCriteria(criteria); -} - -/** - Set filter criteria to proxy model - */ -void FbFileView::clearFilterCriteria() -{ - mSearchPanel->setCriteria(QString("")); -} - -/** - Refresh view - */ -void FbFileView::viewRefresh() -{ - refreshList(); -} - -// --------------------------------------------------------------------------- -// tools menu -// --------------------------------------------------------------------------- -void FbFileView::toolsAllAppsToTextFile() -{ - -} - -/** - Write all files to text file - */ -void FbFileView::toolsAllFilesToTextFile() -{ - mEngineWrapper->toolsWriteAllFiles(); -} - -//void FbFileView::toolsAvkonIconCacheEnable() -//{ -// -//} -//void FbFileView::toolsAvkonIconCacheDisable() -//{ -// -//} - -/** - Disable extended errors - */ -void FbFileView::toolsDisableExtendedErrors() -{ - mEngineWrapper->ToolsSetErrRd(false); -} - -void FbFileView::toolsDumpMsgStoreWalk() -{ - -} -void FbFileView::toolsEditDataTypes() -{ - -} - -/** - Enable extended errors - */ -void FbFileView::toolsEnableExtendedErrors() -{ - mEngineWrapper->ToolsSetErrRd(true); -} - -/** - Open simulate leave dialog - */ -void FbFileView::toolsErrorSimulateLeave() -{ - int leaveCode = -6; - QString heading = QString("Leave code"); - //HbInputDialog::queryInt(heading, this, SLOT(doToolsErrorSimulateLeave(HbAction*)), leaveCode, scene()); - HbInputDialog::queryText(heading, this, SLOT(doToolsErrorSimulateLeave(HbAction*)), QString::number(leaveCode), scene()); -} - - -/** - Simulate leave. - */ -void FbFileView::doToolsErrorSimulateLeave(HbAction *action) -{ - HbInputDialog *dlg = static_cast(sender()); - if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { - bool ok; - int leaveCode = dlg->value().toString().toInt(&ok); - if (leaveCode != 0 || ok) { - mEngineWrapper->ToolsErrorSimulateLeave(leaveCode); - } - } -} - -/** - Open simulate panic dialog. - */ -void FbFileView::toolsErrorSimulatePanic() -{ - mPanicCategory = QString ("Test Category"); - QString heading = QString("Panic category"); - HbInputDialog::queryText(heading, this, SLOT(doToolsErrorSimulatePanicCode(HbAction*)), mPanicCategory, scene()); -} - -/** - Simulate panic. - */ -void FbFileView::doToolsErrorSimulatePanicCode(HbAction *action) -{ - HbInputDialog *dlg = static_cast(sender()); - if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { - mPanicCategory = dlg->value().toString(); - int panicCode(555); - QString heading = QString("Panic code"); - HbInputDialog::queryInt(heading, this, SLOT(doToolsErrorSimulatePanic(HbAction*)), panicCode, scene()); - } -} - -/** - Simulate panic. - */ -void FbFileView::doToolsErrorSimulatePanic(HbAction *action) -{ - HbInputDialog *dlg = static_cast(sender()); - if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { - bool ok; - int panicCode = dlg->value().toInt(&ok); - if (panicCode != 0 || ok) { - mEngineWrapper->ToolsErrorSimulatePanic(mPanicCategory, panicCode); - } - } -} - -/** - Open simulate exception dialog. - */ -void FbFileView::toolsErrorSimulateException() -{ - int exceptionCode = 0; - QString heading = QString("Exception code"); - HbInputDialog::queryInt(heading, this, SLOT(doToolsErrorSimulateException(HbAction*)), exceptionCode, scene()); -} - -/** - Simulate exception. - */ -void FbFileView::doToolsErrorSimulateException(HbAction *action) -{ - HbInputDialog *dlg = static_cast(sender()); - if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { - bool ok; - int exceptionCode = dlg->value().toInt(&ok); - if (exceptionCode != 0 || ok) { - mEngineWrapper->ToolsErrorSimulateException(exceptionCode); - } - } -} - -// void FbFileView::toolsLocalConnectivityActivateInfrared() -//{ -// -//} -// void FbFileView::toolsLocalConnectivityLaunchBTUI() -//{ -// -//} -// void FbFileView::toolsLocalConnectivityLaunchUSBUI() -//{ -// -//} -void FbFileView::toolsMessageInbox() -{ - -} -void FbFileView::toolsMessageDrafts() -{ - -} -void FbFileView::toolsMessageSentItems() -{ - -} -void FbFileView::toolsMessageOutbox() -{ - -} -void FbFileView::toolsMemoryInfo() -{ - -} -void FbFileView::toolsSecureBackStart() -{ - -} -void FbFileView::toolsSecureBackRestore() -{ - -} -void FbFileView::toolsSecureBackStop() -{ - -} - -/** - Open debug mask dialog - */ -void FbFileView::toolsSetDebugMaskQuestion() -{ - quint32 dbgMask = mEngineWrapper->getDebugMask(); - QString dbgMaskText = QString("0x").append(QString::number(dbgMask, 16)); - QString heading = QString("Kernel debug mask in hex format"); - HbInputDialog::queryText(heading, this, SLOT(toolsSetDebugMask(HbAction*)), dbgMaskText, scene()); -} - -/** - Set debug mask - */ -void FbFileView::toolsSetDebugMask(HbAction *action) -{ - HbInputDialog *dlg = static_cast(sender()); - if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { - QString dbgMaskText = dlg->value().toString(); - if (dbgMaskText.length() > 2 && dbgMaskText[0]=='0' && dbgMaskText[1]=='x') { - bool ok; - quint32 dbgMask = dbgMaskText.toUInt(&ok, 16); - if (dbgMask != 0 || ok) { - mEngineWrapper->toolsSetDebugMask(dbgMask); - Notifications::showConfirmationNote(QString("Changed")); - } else { - Notifications::showErrorNote(QString("Cannot convert value")); - } - } else { - Notifications::showErrorNote(QString("Not in hex format")); - } - } -} - -void FbFileView::toolsShowOpenFilesHere() -{ - -} - -// --------------------------------------------------------------------------- -// main menu items -// --------------------------------------------------------------------------- -void FbFileView::selectionModeChanged() -{ - if (mOptionMenuActions.mSelection->isChecked()) { - activateSelectionMode(); - } else { - deActivateSelectionMode(); - } -} - -/** - Show about note - */ -void FbFileView::about() -{ - Notifications::showAboutNote(); -} - -// --------------------------------------------------------------------------- -// End of operations -// --------------------------------------------------------------------------- - -// --------------------------------------------------------------------------- - -/** - Item is selected from list when selection mode is activated from menu - */ -void FbFileView::selectionChanged(const QItemSelection &/*selected*/, const QItemSelection &/*deselected*/) -{ - //QItemSelectionModel *selectionModel = mListView->selectionModel(); - //itemHighlighted(selectionModel->currentIndex()); -} - -/** - An item is clicked from navigation item list. Navigation item list contains - drive-, folder- or file items. Opens selected drive, folder or file popup menu - */ -void FbFileView::activated(const QModelIndex& index) -{ - if (mFbFileModel) { - //map to source model - QModelIndex activatedIndex = mSortFilterProxyModel->mapToSource(index); - - if (mEngineWrapper->getFileEntry(activatedIndex).isDir()) { - // populate new content of changed navigation view. - // mLocationChanged = true; - // mDirectory = filePath; - mEngineWrapper->moveDownToDirectory(activatedIndex); - refreshList(); - } else { // file item - // mSelectedFilePath = filePath; - FbFileEntry fileEntry = mEngineWrapper->getFileEntry(activatedIndex); - mAbsoluteFilePath = fileEntry.path() + fileEntry.name(); - - // open user-dialog to select: view as text/hex, open w/AppArc or open w/DocH. embed - QStringList list; - list << QString("View as text/hex") << QString("Open w/ AppArc") << QString("Open w/ DocH. embed"); - openListDialog(list, QString("Open file"), this, SLOT(fileOpen(HbAction *))); - } - } -} - -// --------------------------------------------------------------------------- - -void FbFileView::activateSelectionMode() -{ - QString path; - disconnect(mListView, SIGNAL(activated(QModelIndex)), this, SLOT(activated(QModelIndex))); - mListView->setSelectionMode(HbListView::MultiSelection); - -// QModelIndex index = mFileSystemModel->index(path,0); -// mListView->selectionModel()->setCurrentIndex(index, QItemSelectionModel::SelectCurrent); -// mListView->selectionModel()->select(index, QItemSelectionModel::Select); -// //mListView->setHighlightMode(HbItemHighlight::HighlightAlwaysVisible); -// mListView->setFocus(); // TODO use focus in - if (mListView->selectionModel()) { - connect(mListView->selectionModel(), - SIGNAL(selectionChanged(QItemSelection, QItemSelection)), - this, - SLOT(selectionChanged(QItemSelection, QItemSelection))); -// // flag to indicate that selection mode changed, "edit" sub-menu update needed -// mFolderContentChanged = true; - } -} - -// --------------------------------------------------------------------------- - -void FbFileView::deActivateSelectionMode() -{ - disconnect(mListView->selectionModel(), - SIGNAL(selectionChanged(QItemSelection, QItemSelection)), - this, - SLOT(selectionChanged(QItemSelection, QItemSelection))); - mListView->setSelectionMode(HbListView::NoSelection); - connect(mListView, SIGNAL(activated(QModelIndex)), this, SLOT(activated(QModelIndex))); - editUnselectAll(); - // flag to indicate that selection mode changed, "edit" sub-menu update needed - mFolderContentChanged = true; -} - -// --------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/ui/src/fbfolderselectiondialog.cpp --- a/filebrowser/ui/src/fbfolderselectiondialog.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,188 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include "fbfolderselectiondialog.h" -#include "fbfolderselectorwrapper.h" - -#include -#include -#include -#include -#include - -#include -#include -#include - -FbFolderSelectionDialog::FbFolderSelectionDialog(QGraphicsItem *parent) : - HbDialog(parent), - mTitle(0), - mFolderList(0), - mFolderSelectorWrapper(0), - mFileIconProvider(0) -{ - init(); -} - -FbFolderSelectionDialog::~FbFolderSelectionDialog() -{ - if (mFileIconProvider) - delete mFileIconProvider; -} - -QString FbFolderSelectionDialog::selectedFolder() -{ - return mFolderSelectorWrapper->currentPath(); -} - -void FbFolderSelectionDialog::init() -{ - setAttribute(Qt::WA_DeleteOnClose); - - mFileIconProvider = new QFileIconProvider(); - - createHeading(); - createList(); - createToolBar(); -} - -void FbFolderSelectionDialog::createHeading() -{ - HbWidget *headingWidget = new HbWidget(this); - QGraphicsLinearLayout *headingLayout = new QGraphicsLinearLayout(Qt::Horizontal, headingWidget); - headingWidget->setLayout(headingLayout); - - mTitle = new HbLabel(this); - mTitle->setElideMode(Qt::ElideRight); - - HbPushButton *upButton = new HbPushButton(this); - upButton->setIcon(HbIcon(QString(":/qtg_indi_status_back.svg"))); - connect(upButton, SIGNAL(pressed()), - this, SLOT(moveUpPressed())); - - headingLayout->addItem(mTitle); - headingLayout->addItem(upButton); - headingLayout->setAlignment(upButton, Qt::AlignRight); - - setHeadingWidget(headingWidget); -} - -void FbFolderSelectionDialog::createList() -{ - mFolderList = new HbListWidget(this); - mFolderSelectorWrapper = new FbFolderSelectorWrapper(); - mFolderSelectorWrapper->init(); - - refreshView(); - - setContentWidget(mFolderList); - connect(mFolderList, SIGNAL(activated(HbListWidgetItem *)), - this, SLOT(activated(HbListWidgetItem *))); - - connect(mFolderSelectorWrapper, SIGNAL(FolderSelectionChanged()), - this, SLOT(refreshView())); -} - -void FbFolderSelectionDialog::createToolBar() -{ - HbAction *rejectAction = new HbAction(QString("Cancel"), this); - addAction(rejectAction); -} - -void FbFolderSelectionDialog::refreshView() -{ - mFolderList->clear(); - QIcon icon; - if (mFolderSelectorWrapper->isDriveListViewActive()) - { - const QString KSimpleDriveEntry("%d\t%c: <%S>\t\t"); - //TODO icon = mFileIconProvider->icon(QFileIconProvider::Drive); - icon = mFileIconProvider->icon(QFileIconProvider::File); - - for (TInt i=0; iitemCount(); i++) { - FbDriveEntry driveEntry = mFolderSelectorWrapper->getDriveEntry(i); - - const QString SimpleDriveEntry("%1: <%2>"); - QString diskName = SimpleDriveEntry.arg(driveEntry.driveLetter()).arg(driveEntry.mediaTypeString()); - - mFolderList->addItem(icon, diskName); - } - } else { - const QString SimpleFileEntry("%1"); - icon = mFileIconProvider->icon(QFileIconProvider::Folder); - - // append current folder item - QString currentAbsolutePath = mFolderSelectorWrapper->currentPath().left(mFolderSelectorWrapper->currentPath().length()-1); - QFileInfo fileInfo(currentAbsolutePath); - QString currentFolderName = fileInfo.fileName(); - if (currentFolderName.isEmpty()) { - currentFolderName = QString("[root level]"); - } - - QString currentDirTextEntry = SimpleFileEntry.arg(currentFolderName); ///*<< fileEntry.IconId()*/ - mFolderList->addItem(icon, currentDirTextEntry); - - for (TInt i=0; iitemCount(); i++) { - FbFileEntry fileEntry = mFolderSelectorWrapper->getFileEntry(i); - - QString fileName = SimpleFileEntry.arg(fileEntry.name()); ///*<< fileEntry.IconId()*/ - - mFolderList->addItem(icon, fileName); - } - } -} - -void FbFolderSelectionDialog::activated(HbListWidgetItem * item) -{ - int row = mFolderList->row(item); - if (mFolderSelectorWrapper->isDriveListViewActive()) { - mFolderSelectorWrapper->moveDownToDirectory(row); - } else if (row == 0) { - if (this->actions().count() > 0) { - accept(); - } - } else if (row > 0) { - mFolderSelectorWrapper->moveDownToDirectory(row); - } -} - -void FbFolderSelectionDialog::moveUpPressed() -{ - mFolderSelectorWrapper->moveUpOneLevel(); -} - -// --------------------------------------------------------------------------- - -FbCopyToFolderSelectionDialog::FbCopyToFolderSelectionDialog(QGraphicsItem *parent) : - FbFolderSelectionDialog(parent) -{ - if (headingWidget()) { - mTitle->setPlainText(QString("Copy To")); - } -} - -// --------------------------------------------------------------------------- - -FbMoveToFolderSelectionDialog::FbMoveToFolderSelectionDialog(QGraphicsItem *parent) : - FbFolderSelectionDialog(parent) -{ - if (headingWidget()) { - mTitle->setPlainText(QString("Move To")); - } -} - -// End of file diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/ui/src/fbfolderselectorwrapper.cpp --- a/filebrowser/ui/src/fbfolderselectorwrapper.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,134 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include "fbfolderselectorwrapper.h" -#include "FBFolderSelector.h" - -#include - -// --------------------------------------------------------------------------- - -/** - * Constructor - */ -FbFolderSelectorWrapper::FbFolderSelectorWrapper() - : mDestinationFolderSelector(0) -{ -} - -/** - * Destructor - */ -FbFolderSelectorWrapper::~FbFolderSelectorWrapper() -{ - if (mDestinationFolderSelector) - delete mDestinationFolderSelector; -} - -/** - * Initializes Engine Wrapper - * @return true if engine was started successfully - */ -bool FbFolderSelectorWrapper::init() -{ - TFileName destinationFolder; - - TRAPD(err, mDestinationFolderSelector = CFileBrowserFolderSelector::NewL(destinationFolder, this)); - if (err != KErrNone) { - return false; - } else { - //TRAP_IGNORE(mEngine->ActivateEngineL()); - //mSettings = FileBrowserSettings(&mEngine->Settings()); - return true; - } -} - -/** - * Return current path - */ -QString FbFolderSelectorWrapper::currentPath() const -{ - return QString::fromUtf16(mDestinationFolderSelector->CurrentPath().Ptr(), - mDestinationFolderSelector->CurrentPath().Length()); -} - -/** - * Return whether drive list view is active - */ -bool FbFolderSelectorWrapper::isDriveListViewActive() const -{ - return mDestinationFolderSelector->IsDriveListViewActive(); -} - -/** - * Returns number of either drives or files depending on current view - */ -int FbFolderSelectorWrapper::itemCount() const -{ - if (isDriveListViewActive()) { - return mDestinationFolderSelector->DriveEntryList()->Count(); - } else { - return mDestinationFolderSelector->FileEntryList()->Count(); - } -} - -/** - * Returns drive entry for given \a index - */ -FbDriveEntry FbFolderSelectorWrapper::getDriveEntry(const int index) const -{ - TDriveEntry driveEntry; - if (mDestinationFolderSelector->DriveEntryList()->Count() > index && index >= 0) { - driveEntry = mDestinationFolderSelector->DriveEntryList()->At(index); - } - return FbDriveEntry(driveEntry); -} - -/** - * Returns file entry for given \a index - */ -FbFileEntry FbFolderSelectorWrapper::getFileEntry(const int index) const -{ - TFileEntry fileEntry; - if (mDestinationFolderSelector->FileEntryList()->Count() > index && index >= 0) { - fileEntry = mDestinationFolderSelector->FileEntryList()->At(index); - } - return FbFileEntry(fileEntry); -} - -/** - * Move down to selected item by \a index - */ -void FbFolderSelectorWrapper::moveDownToDirectory(int index) -{ - mDestinationFolderSelector->MoveDownToDirectoryL(index); -} - -/** - * Move up from folder - */ -void FbFolderSelectorWrapper::moveUpOneLevel() -{ - mDestinationFolderSelector->MoveUpOneLevelL(); -} - -void FbFolderSelectorWrapper::InformFolderSelectionChanged() -{ - emit FolderSelectionChanged(); -} - -// --------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/ui/src/fbmainwindow.cpp --- a/filebrowser/ui/src/fbmainwindow.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,178 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ -#include -#include - -#include "fbmainwindow.h" -#include "enginewrapper.h" -#include "fbfileview.h" -#include "fbdriveview.h" -#include "fbsettingsview.h" -#include "fbeditorview.h" -#include "fbsearchview.h" -#include "fbattributesview.h" - -FbMainWindow::FbMainWindow(QWidget *parent) - : HbMainWindow(parent), - mEngineWrapper(0), - mDriveView(0), - mFileView(0), - mSettingsView(0), - mEditorView(0), - mSearchView(0), - mAttributesView(0), - mPreviousView(0) -{ -} - -FbMainWindow::~FbMainWindow () -{ - if (mEngineWrapper) { - delete mEngineWrapper; - } -} - -void FbMainWindow::init() -{ - // Create Engine Wrapper and initialize it - mEngineWrapper = new EngineWrapper(); - int error = mEngineWrapper->init(); - Q_ASSERT_X(error == 1, "FileBrowser", "Engine initialization failed"); - - // Create drive view - mDriveView = new FbDriveView(); - connect(mDriveView, SIGNAL(aboutToShowSettingsView()), this, SLOT(openSettingsView())); - connect(mDriveView, SIGNAL(aboutToShowFileView()), this, SLOT(openFileView())); - mDriveView->init(mEngineWrapper); - addView(mDriveView); - - // Create file view - mFileView = new FbFileView(); - connect(mFileView, SIGNAL(aboutToShowSettingsView()), this, SLOT(openSettingsView())); - connect(mFileView, SIGNAL(aboutToShowDriveView()), this, SLOT(openDriveView())); - mFileView->init(mEngineWrapper); - addView(mFileView); - - // Create settings view - mSettingsView = new FbSettingsView(*mEngineWrapper); - connect(mSettingsView, SIGNAL(finished(bool)), this, SLOT(openPreviousBrowserView())); - addView(mSettingsView); - - // Create editor view - mEditorView = new FbEditorView(); - connect(mFileView, SIGNAL(aboutToShowEditorView(const QString &, bool)), this, SLOT(openEditorView(const QString &, bool))); - connect(mEditorView, SIGNAL(finished(bool)), this, SLOT(openFileView())); - addView(mEditorView); - - // Create Search view - mSearchView = new FbSearchView(*mEngineWrapper); - connect(mDriveView, SIGNAL(aboutToShowSearchView(QString)), this, SLOT(openSearchView(QString))); - connect(mFileView, SIGNAL(aboutToShowSearchView(QString)), this, SLOT(openSearchView(QString))); - connect(mSearchView, SIGNAL(finished(bool)), this, SLOT(openFileBrowserView(bool))); - addView(mSearchView); - - connect(mFileView, SIGNAL(aboutToShowAttributesView(const QString &, quint32 &, quint32 &, bool &)), - this, SLOT(openAttributesView(const QString &, quint32 &, quint32 &, bool &))); - - // Show ApplicationView at startup - setCurrentView(mDriveView); - mPreviousView = mDriveView; - - // Show HbMainWindow - show(); -} - - -void FbMainWindow::openPreviousBrowserView() -{ - mDriveView->refreshList(); - mFileView->refreshList(); - setCurrentView(mPreviousView); -} - -void FbMainWindow::openFileBrowserView(bool accepted) -{ - mDriveView->refreshList(); - mFileView->refreshList(); - if (accepted) { - setCurrentView(mFileView); - } else { - setCurrentView(mPreviousView); - } -} - -void FbMainWindow::openDriveView() -{ - mDriveView->refreshList(); - setCurrentView(mDriveView); - mPreviousView = mDriveView; -} - -void FbMainWindow::openFileView() -{ - mDriveView->refreshList(); -// mFileView->setCurrentpath(path); - mFileView->refreshList(); - setCurrentView(mFileView); - mPreviousView = mFileView; -} - -void FbMainWindow::openSettingsView() -{ - mSettingsView->initDataForm(); - setCurrentView(mSettingsView); -} - -void FbMainWindow::openEditorView(const QString &fileName, bool flagReadOnly) -{ - mEditorView->open(fileName, flagReadOnly); - setCurrentView(mEditorView); -} - -void FbMainWindow::openSearchView(const QString &path) -{ - mSearchView->open(path); - setCurrentView(mSearchView); -} - -void FbMainWindow::openAttributesView(const QString &attributesViewTitle, - quint32 &setAttributesMask, - quint32 &clearAttributesMask, - bool &recurse) -{ - if (!mAttributesView) { - // Create attributes view - mAttributesView = new FbAttributesView(setAttributesMask, clearAttributesMask, recurse); - connect(mAttributesView, SIGNAL(finished(bool)), this, SLOT(closeAttributesView(bool))); - mAttributesView->setTitle(attributesViewTitle); - addView(mAttributesView); - setCurrentView(mAttributesView); - } -} - -void FbMainWindow::closeAttributesView(bool accepted) -{ - if (accepted) { - mEngineWrapper->setAttributes(mAttributesView->setAttributesMask(), mAttributesView->clearAttributesMask(), mAttributesView->recurse()); - } - openFileView(); - removeView(mAttributesView); - mAttributesView->deleteLater(); - mAttributesView = 0; -} - -// End of file diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/ui/src/fbsearchview.cpp --- a/filebrowser/ui/src/fbsearchview.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,213 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include "fbsearchview.h" -#include "enginewrapper.h" -#include "notifications.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -const QStringList RECURSEMODES = (QStringList() << "Non-recursive" << "Recursive"); -const QString acceptActionText = "Search"; -const QString rejectActionText = "Cancel"; - - -FbSearchView::FbSearchView(EngineWrapper &engineWrapper) - : mEngineWrapper(engineWrapper), - mAttributes(), - mResults(), - mForm(0), - mSearchFileNameItem(0), - mWildCardItem(0), - mHasString(0), - mRecurse(0), - mMinSize(0), - mMaxSize(0), - mMinDate(0), - mMaxDate(0), - mPath(), - mProgressDialog(0) -{ - // Set title and add this view to main window - setTitle("Search"); - - // Override back navigation action - HbAction *leaveViewAction = new HbAction(Hb::BackNaviAction, this); - connect(leaveViewAction, SIGNAL(triggered()), this, SLOT(reject())); - setNavigationAction(leaveViewAction); - - initDataForm(); - createToolbar(); -} - -FbSearchView::~FbSearchView() -{ -} - -void FbSearchView::initDataForm() { - mForm = new HbDataForm(/*HbFormView::ModeEdit,*/ this); - HbDataFormModel *model = new HbDataFormModel(); - - mSearchFileNameItem = new HbDataFormModelItem(HbDataFormModelItem::TextItem); - mSearchFileNameItem->setLabel("Search dir: "); - - mWildCardItem = new HbDataFormModelItem(HbDataFormModelItem::TextItem); - mWildCardItem->setLabel("Wildcards: "); - - mHasString = new HbDataFormModelItem(HbDataFormModelItem::TextItem); - mHasString->setLabel("Has string: "); - - mRecurse = new HbDataFormModelItem(HbDataFormModelItem::ComboBoxItem); - mRecurse->setLabel("Recurse: "); - mRecurse->setContentWidgetData("items", RECURSEMODES); - - mMinSize = new HbDataFormModelItem(HbDataFormModelItem::TextItem); - mMinSize->setLabel("Min size: "); - - mMaxSize = new HbDataFormModelItem(HbDataFormModelItem::TextItem); - mMaxSize->setLabel("Max size: "); - - mMinDate = new HbDataFormModelItem(HbDataFormModelItem::TextItem); - mMinDate->setLabel("Min date: "); - mMinDate->setContentWidgetData("text", "01/01/1980"); - - mMaxDate = new HbDataFormModelItem(HbDataFormModelItem::TextItem); - mMaxDate->setLabel("Max date: "); - mMaxDate->setContentWidgetData("text", "31/12/2060"); - - model->appendDataFormItem(mSearchFileNameItem); - model->appendDataFormItem(mWildCardItem); - model->appendDataFormItem(mHasString); - model->appendDataFormItem(mRecurse); - model->appendDataFormItem(mMinSize); - model->appendDataFormItem(mMaxSize); - model->appendDataFormItem(mMinDate); - model->appendDataFormItem(mMaxDate); - mForm->setModel(model); - - QGraphicsLinearLayout* layout = new QGraphicsLinearLayout(Qt::Vertical,this); - layout->addItem(mForm); - setLayout(layout); -} - -void FbSearchView::createToolbar() -{ - HbToolBar *toolBar = new HbToolBar(this); - HbAction *acceptAction = new HbAction(acceptActionText); - connect(acceptAction, SIGNAL(triggered()), this, SLOT(accept())); - toolBar->addAction(acceptAction); - - HbAction *rejectAction = new HbAction(rejectActionText); - connect(rejectAction, SIGNAL(triggered()), this, SLOT(reject())); - toolBar->addAction(rejectAction); - - setToolBar(toolBar); -} - -void FbSearchView::loadAttributes() -{ - // get settings from engine; - mAttributes = mEngineWrapper.getFileSearchAttributes(); - - // set data: - mSearchFileNameItem->setContentWidgetData("text", mPath); -// mSearchFileNameItem->setContentWidgetData("text", mAttributes.mSearchDir); - if (!mAttributes.mDefaultWildCard) { - mWildCardItem->setContentWidgetData("text", mAttributes.mWildCards); - } - mHasString->setContentWidgetData("text", mAttributes.mTextInFile); - - mRecurse->setContentWidgetData("selected", mAttributes.mRecurse); - - mMinSize->setContentWidgetData("text", mAttributes.mMinSize); - mMaxSize->setContentWidgetData("text", mAttributes.mMaxSize); - - mMinDate->setContentWidgetData("text", mAttributes.mMinDate); - mMaxDate->setContentWidgetData("text", mAttributes.mMaxDate); -} - -/** - * Reads form items and saves values of them into member variable mAttributes - */ -void FbSearchView::readFormItems() -{ - mAttributes.mSearchDir = mSearchFileNameItem->contentWidgetData("text").toString(); - - mAttributes.mDefaultWildCard = false; - QString wildCard = mWildCardItem->contentWidgetData("text").toString(); - if (wildCard.trimmed().isEmpty()) { - wildCard = QString("*"); - mAttributes.mDefaultWildCard = true; - } - mAttributes.mWildCards = wildCard; - mAttributes.mTextInFile = mHasString->contentWidgetData("text").toString(); - mAttributes.mMinSize = mMinSize->contentWidgetData("text").toInt(); - mAttributes.mMaxSize = mMaxSize->contentWidgetData("text").toInt(); - mAttributes.mMinDate = mMinDate->contentWidgetData("text").toDate(); - mAttributes.mMaxDate = mMaxDate->contentWidgetData("text").toDate(); - mAttributes.mRecurse = mRecurse->contentWidgetData("selected").toBool(); -} - -void FbSearchView::open(const QString &path) -{ - mPath = path; - // load file search attribute values from FB engine: - loadAttributes(); -} - -void FbSearchView::startFileSearch() -{ - // save form data values and set them as search attributes into FB engine. - readFormItems(); - mEngineWrapper.setFileSearchAttributes(mAttributes); - - bool err = mEngineWrapper.searchFiles(); - - // show results of file search: - mResults = mEngineWrapper.getSearchResults(); - fileSearchResults(); -} - -void FbSearchView::fileSearchResults() -{ - QString noteMsg("%1 entries found"); - Notifications::showInformationNote(noteMsg.arg(mEngineWrapper.itemCount()), QString("")); -} - -void FbSearchView::accept() -{ - startFileSearch(); - emit finished(true); -} - -void FbSearchView::reject() -{ - emit finished(false); -} diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/ui/src/fbsettingsview.cpp --- a/filebrowser/ui/src/fbsettingsview.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,243 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include "fbsettingsview.h" -#include "enginewrapper.h" -#include "filebrowsersettings.h" - -#include -#include -#include -#include -#include -#include - -#include - -const QStringList DisplayModeModes = (QStringList() << "Full screen" << "Normal"); -const QStringList FileViewModes = (QStringList() << "Simple" << "Extended"); -const QStringList Modes = (QStringList() << "Yes" << "No"); -const QString YesText = QString("Yes"); -const QString NoText = QString("No"); -const QString acceptActionText = "OK"; -const QString rejectActionText = "Cancel"; - -FbSettingsView::FbSettingsView(EngineWrapper &engineWrapper) : - mEngineWrapper(engineWrapper), - mForm(0), - mDisplayModeItem(0), - mFileViewItem(0), - mShowDirectoryInfoItem(0), - mShowAssociatedIconsItem(0), - mRememberFolderOnExitItem(0), - mRememberLastFolderItem(0), - mShowToolbarItem(0), - mSupportNetDrivesItem(0), - mBypassPlatformSecurityItem(0), - mUnlockFilesViaSBItem(0), - mIgnoreProtectionAttributesItem(0), - mNoROAttributeCopyFromZItem(0) -{ - setTitle("Settings"); - - // Override back navigation action - HbAction *leaveViewAction = new HbAction(Hb::BackNaviAction, this); - connect(leaveViewAction, SIGNAL(triggered()), this, SLOT(reject())); - setNavigationAction(leaveViewAction); - - initDataForm(); - createToolbar(); -} - -FbSettingsView::~FbSettingsView() -{ -} - -void FbSettingsView::initDataForm() -{ - mForm = new HbDataForm(this); - HbDataFormModel *model = new HbDataFormModel(); - -// connect(model, SIGNAL(dataChanged(QModelIndex, QModelIndex)), -// this, SLOT(toggleChange(QModelIndex, QModelIndex))); - - - // TODO to be done -// mDisplayModeItem = new HbDataFormModelItem(HbDataFormModelItem::ComboBoxItem); -// mDisplayModeItem->setLabel("Display mode: "); -// mDisplayModeItem->setContentWidgetData("items", DisplayModeModes); -// -// mFileViewItem = new HbDataFormModelItem(HbDataFormModelItem::ComboBoxItem); -// mFileViewItem->setLabel("File view: "); -// mFileViewItem->setContentWidgetData("items", FileViewModes); -// -// mShowDirectoryInfoItem = new HbDataFormModelItem(HbDataFormModelItem::ToggleValueItem); -// mShowDirectoryInfoItem->setLabel("Show directory info: "); -// mShowDirectoryInfoItem->setContentWidgetData(QString("text"), YesText); -// mShowDirectoryInfoItem->setContentWidgetData(QString("additionalText"), NoText); -// -// mShowAssociatedIconsItem = new HbDataFormModelItem(HbDataFormModelItem::ToggleValueItem); -// mShowAssociatedIconsItem->setLabel("Show associated icons: "); -// mShowAssociatedIconsItem->setContentWidgetData(QString("text"), YesText); -// mShowAssociatedIconsItem->setContentWidgetData(QString("additionalText"), NoText); -// -// mRememberFolderOnExitItem = new HbDataFormModelItem(HbDataFormModelItem::ToggleValueItem); -// mRememberFolderOnExitItem->setLabel("Remember folder on exit: "); -// mRememberFolderOnExitItem->setContentWidgetData(QString("text"), YesText); -// mRememberFolderOnExitItem->setContentWidgetData(QString("additionalText"), NoText); -// -// mRememberLastFolderItem = new HbDataFormModelItem(HbDataFormModelItem::ToggleValueItem); -// mRememberLastFolderItem->setLabel("Remember last folder: "); -// mRememberLastFolderItem->setContentWidgetData(QString("text"), YesText); -// mRememberLastFolderItem->setContentWidgetData(QString("additionalText"), NoText); -// -// mShowToolbarItem = new HbDataFormModelItem(HbDataFormModelItem::ToggleValueItem); -// mShowToolbarItem->setLabel("Show toolbar: "); -// mShowToolbarItem->setContentWidgetData(QString("text"), YesText); -// mShowToolbarItem->setContentWidgetData(QString("additionalText"), NoText); - - mSupportNetDrivesItem = new HbDataFormModelItem(HbDataFormModelItem::ToggleValueItem); - mSupportNetDrivesItem->setLabel("Support net drives: "); - mSupportNetDrivesItem->setContentWidgetData(QString("text"), YesText); - mSupportNetDrivesItem->setContentWidgetData(QString("additionalText"), NoText); - - mBypassPlatformSecurityItem = new HbDataFormModelItem(HbDataFormModelItem::ToggleValueItem); - mBypassPlatformSecurityItem->setLabel("Bypass plat.security: "); - mBypassPlatformSecurityItem->setContentWidgetData(QString("text"), YesText); - mBypassPlatformSecurityItem->setContentWidgetData(QString("additionalText"), NoText); - - mUnlockFilesViaSBItem = new HbDataFormModelItem(HbDataFormModelItem::ToggleValueItem); - mUnlockFilesViaSBItem->setLabel("Unlock files via SB: "); - mUnlockFilesViaSBItem->setContentWidgetData(QString("text"), YesText); - mUnlockFilesViaSBItem->setContentWidgetData(QString("additionalText"), NoText); - - mIgnoreProtectionAttributesItem = new HbDataFormModelItem(HbDataFormModelItem::ToggleValueItem); - mIgnoreProtectionAttributesItem->setLabel("Ign. protection atts: "); - mIgnoreProtectionAttributesItem->setContentWidgetData(QString("text"), YesText); - mIgnoreProtectionAttributesItem->setContentWidgetData(QString("additionalText"), NoText); - - mNoROAttributeCopyFromZItem = new HbDataFormModelItem(HbDataFormModelItem::ToggleValueItem); - mNoROAttributeCopyFromZItem->setLabel("No RO-att copy from Z: "); - mNoROAttributeCopyFromZItem->setContentWidgetData(QString("text"), YesText); - mNoROAttributeCopyFromZItem->setContentWidgetData(QString("additionalText"), NoText); - - // load file search attribute values from FB engine: - loadSettings(mEngineWrapper.settings()); - -// model->appendDataFormItem(mDisplayModeItem); -// model->appendDataFormItem(mFileViewItem); -// model->appendDataFormItem(mShowDirectoryInfoItem); -// model->appendDataFormItem(mShowAssociatedIconsItem); -// model->appendDataFormItem(mRememberFolderOnExitItem); -// model->appendDataFormItem(mRememberLastFolderItem); -// model->appendDataFormItem(mShowToolbarItem); - - model->appendDataFormItem(mSupportNetDrivesItem); - model->appendDataFormItem(mBypassPlatformSecurityItem); - model->appendDataFormItem(mUnlockFilesViaSBItem); - model->appendDataFormItem(mIgnoreProtectionAttributesItem); - model->appendDataFormItem(mNoROAttributeCopyFromZItem); - - mForm->setModel(model); - - QGraphicsLinearLayout* layout = new QGraphicsLinearLayout(Qt::Vertical,this); - layout->addItem(mForm); - setLayout(layout); -} - -void FbSettingsView::createToolbar() -{ - HbToolBar *toolBar = new HbToolBar(this); - HbAction *acceptAction = new HbAction(acceptActionText); - connect(acceptAction, SIGNAL(triggered()), this, SLOT(accept())); - toolBar->addAction(acceptAction); - - HbAction *rejectAction = new HbAction(rejectActionText); - connect(rejectAction, SIGNAL(triggered()), this, SLOT(reject())); - toolBar->addAction(rejectAction); - - setToolBar(toolBar); -} - -/** - Set form item values from settings \a settings. - */ -void FbSettingsView::loadSettings(const FileBrowserSettings &settings) -{ -// mDisplayModeItem->setContentWidgetData("text", settings.displayMode()); -// mFileViewItem->setContentWidgetData("text", settings.fileViewMode()); -// mShowDirectoryInfoItem->setContentWidgetData("text", settings.showSubDirectoryInfo()); -// mShowAssociatedIconsItem->setContentWidgetData("text", settings.showAssociatedIcons()); -// mRememberFolderOnExitItem->setContentWidgetData("text", settings.rememberFolderSelection()); -// mRememberLastFolderItem->setContentWidgetData("text", settings.rememberLastPath()); -// mShowToolbarItem->setContentWidgetData("text", settings.enableToolbar()); - - mSupportNetDrivesItem->setContentWidgetData("text", settings.supportNetworkDrives() ? YesText : NoText); - mSupportNetDrivesItem->setContentWidgetData("additionalText", !settings.supportNetworkDrives() ? YesText : NoText); - - mBypassPlatformSecurityItem->setContentWidgetData("text", settings.bypassPlatformSecurity() ? YesText : NoText); - mBypassPlatformSecurityItem->setContentWidgetData("additionalText", !settings.bypassPlatformSecurity() ? YesText : NoText); - - mUnlockFilesViaSBItem->setContentWidgetData("text", settings.removeFileLocks() ? YesText : NoText); - mUnlockFilesViaSBItem->setContentWidgetData("additionalText", !settings.removeFileLocks() ? YesText : NoText); - - mIgnoreProtectionAttributesItem->setContentWidgetData("text", settings.ignoreProtectionsAttributes() ? YesText : NoText); - mIgnoreProtectionAttributesItem->setContentWidgetData("additionalText", !settings.ignoreProtectionsAttributes() ? YesText : NoText); - - mNoROAttributeCopyFromZItem->setContentWidgetData("text", settings.removeROMWriteProrection() ? YesText : NoText); - mNoROAttributeCopyFromZItem->setContentWidgetData("additionalText", !settings.removeROMWriteProrection() ? YesText : NoText); -} - -/** - Store form item data into \a settings - */ -void FbSettingsView::saveSettings(FileBrowserSettings &settings) -{ -// settings.setDisplayMode(mDisplayModeItem->contentWidgetData("text").toInt()); -// settings.setFileViewMode(mFileViewItem->contentWidgetData("text").toInt()); -// settings.setShowSubDirectoryInfo(mShowDirectoryInfoItem->contentWidgetData("text").toBool()); -// settings.setShowAssociatedIcons(mShowAssociatedIconsItem->contentWidgetData("text").toBool()); -// settings.setRememberLastPath(mRememberFolderOnExitItem->contentWidgetData("text").toBool()); -// //settings.setLastPath(mRememberLastFolderItem->contentWidgetData("text").toString()); -// settings.setRememberFolderSelection(mRememberLastFolderItem->contentWidgetData("text").toBool()); -// settings.setEnableToolbar(mShowToolbarItem->contentWidgetData("text").toBool()); - - settings.setSupportNetworkDrives(mSupportNetDrivesItem->contentWidgetData("text").toString() == YesText); - settings.setBypassPlatformSecurity(mBypassPlatformSecurityItem->contentWidgetData("text").toString() == YesText); - settings.setRemoveFileLocks(mUnlockFilesViaSBItem->contentWidgetData("text").toString() == YesText); - settings.setIgnoreProtectionsAttributes(mIgnoreProtectionAttributesItem->contentWidgetData("text").toString() == YesText); - settings.setRemoveROMWriteProrection(mNoROAttributeCopyFromZItem->contentWidgetData("text").toString() == YesText); -} - -void FbSettingsView::constructMenu() -{ - -} - -void FbSettingsView::accept() -{ - saveSettings(mEngineWrapper.settings()); - mEngineWrapper.saveSettings(); - emit finished(true); -} - -void FbSettingsView::reject() -{ - emit finished(false); -} - -// End of file diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/ui/src/filebrowser.cpp --- a/filebrowser/ui/src/filebrowser.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include -#include - -#include "fbmainwindow.h" - - -int main(int argc, char *argv[]) -{ - HbApplication app(argc, argv); - FbMainWindow window; - window.init(); - int result = app.exec(); - - return result; -} diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/ui/src/filebrowsersortfilterproxymodel.cpp --- a/filebrowser/ui/src/filebrowsersortfilterproxymodel.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,62 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include "filebrowsersortfilterproxymodel.h" - -#include -#include - -FileBrowserSortFilterProxyModel::FileBrowserSortFilterProxyModel(QObject *parent) - : QSortFilterProxyModel(parent) -{ -} - -bool FileBrowserSortFilterProxyModel::filterAcceptsRow(int sourceRow, - const QModelIndex &sourceParent) const -{ - QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent); - - QVariant displayRole = index.data(Qt::DisplayRole); - QStringList stringList; - if (displayRole.isValid()) { - if (displayRole.canConvert()) { - stringList.append(displayRole.toString()); - } else if (displayRole.canConvert()) { - stringList = displayRole.toStringList(); - } - QString itemName = stringList.at(0); - //QString criteria = filterRegExp().pattern(); - QString criteria = filterCriteria(); - if (!criteria.isEmpty()) { - bool contains = itemName.contains(criteria, Qt::CaseInsensitive); - return contains; - } else { - //invalidateFilter(); - return true; - } - } - return true; -} - -void FileBrowserSortFilterProxyModel::setFilterCriteria(const QString &criteria) -{ - mFilterCriteria = criteria; - invalidate(); -} - - -// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/ui/src/notifications.cpp --- a/filebrowser/ui/src/notifications.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,79 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ -#include "notifications.h" - -#include -#include -#include - -// --------------------------------------------------------------------------- - -void Notifications::showMessageBox(HbMessageBox::MessageBoxType type, const QString &text, const QString &label, int timeout) -{ - HbMessageBox *messageBox = new HbMessageBox(type); - messageBox->setText(text); - if (label.length()) { - HbLabel *header = new HbLabel(label, messageBox); - messageBox->setHeadingWidget(header); - } - messageBox->setAttribute(Qt::WA_DeleteOnClose); - messageBox->setTimeout(timeout); - messageBox->open(); -} - -void Notifications::showAboutNote() -{ - showMessageBox(HbMessageBox::MessageTypeInformation, - "Version 5.1.1 - 26th July 2010. Copyright © 2010 Nokia Corporation" - "and/or its subsidiary(-ies). All rights reserved." - "Licensed under Eclipse Public License v1.0.", - "About File Browser" - ); -} - -// --------------------------------------------------------------------------- - -void Notifications::showInformationNote(const QString &text, const QString &title) -{ - showMessageBox(HbMessageBox::MessageTypeInformation, text, title, 3000); -} - -// --------------------------------------------------------------------------- - -void Notifications::showErrorNote(const QString &text, bool noTimeout) -{ - showMessageBox(HbMessageBox::MessageTypeWarning, text, "", - noTimeout ? HbPopup::NoTimeout : 3000 /*HbPopup::StandardTimeout*/); -} - -// --------------------------------------------------------------------------- - -void Notifications::showConfirmationNote(const QString &text, bool noTimeout) -{ - showMessageBox(HbMessageBox::MessageTypeInformation, text, "", - noTimeout ? HbPopup::NoTimeout : 3000 /*HbPopup::ConfirmationNoteTimeout*/); -} - -// --------------------------------------------------------------------------- - -bool Notifications::showConfirmationQuery(const QString &aText) -{ - Q_UNUSED(aText); - return false; //HbMessageBox::question(aText); -} - -// --------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/ui/ui.pro --- a/filebrowser/ui/ui.pro Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,126 +0,0 @@ -# -# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# This component and the accompanying materials are made available -# under the terms of "Eclipse Public License v1.0" -# which accompanies this distribution, and is available -# at the URL "http://www.eclipse.org/legal/epl-v10.html". -# -# Initial Contributors: -# Nokia Corporation - initial contribution. -# -# Contributors: -# -# Description: -# -# -TEMPLATE = app -TARGET = FileBrowser -DEPENDPATH += . -INCLUDEPATH += ./inc -load(hb.prf) -symbian:CONFIG -= symbian_i18n - -HEADERS += ./inc/menuaction.h \ - ./inc/enginewrapper.h \ - ./inc/fbmainwindow.h \ - ./inc/fbdrivelistviewitem.h \ - ./inc/fbdrivemodel.h \ - ./inc/fbdriveentry.h \ - ./inc/fbdriveview.h \ - ./inc/fbfilelistviewitem.h \ - ./inc/fbfilemodel.h \ - ./inc/fbfileentry.h \ - ./inc/fbfileview.h \ - ./inc/filebrowsersortfilterproxymodel.h \ - ./inc/filebrowsersettings.h \ - ./inc/fbsettingsview.h \ - ./inc/fbeditorview.h \ - ./inc/fbsearchview.h \ - ./inc/fbattributesview.h \ - ./inc/fbfolderselectiondialog.h \ - ./inc/fbfolderselectorwrapper.h \ - ./inc/notifications.h -SOURCES += ./src/filebrowser.cpp \ - ./src/enginewrapper.cpp \ - ./src/fbmainwindow.cpp \ - ./src/fbdrivelistviewitem.cpp \ - ./src/fbdrivemodel.cpp \ - ./src/fbdriveentry.cpp \ - ./src/fbdriveview.cpp \ - ./src/fbfilelistviewitem.cpp \ - ./src/fbfilemodel.cpp \ - ./src/fbfileentry.cpp \ - ./src/fbfileview.cpp \ - ./src/filebrowsersortfilterproxymodel.cpp \ - ./src/fbsettingsview.cpp \ - ./src/fbeditorview.cpp \ - ./src/fbsearchview.cpp \ - ./src/fbattributesview.cpp \ - ./src/fbfolderselectiondialog.cpp \ - ./src/fbfolderselectorwrapper.cpp \ - ./src/notifications.cpp -RESOURCES += ./ui.qrc - -symbian { - INCLUDEPATH += ../ - LIBS += -leikcore \ - -lcommonengine \ - -ltzclient \ - -lapmime \ - -lcommonui \ - -leuser \ - -lapparc \ - -lcone \ - -lws32 \ - -lfbscli \ - -lImageConversion \ - -lPlatformEnv \ - -lapgrfx \ - -lefsrv \ - -lbafl \ - -lCentralRepository \ - -lmediaclientaudio \ - -lestor \ - -lgdi \ - -legul \ - -lsendui \ - -lmsgs \ - -lezlib \ - -lcdlengine \ - -lremconcoreapi \ - -lremconinterfacebase \ - -lsbeclient \ - -lhash \ - -letext \ - -lcharconv \ - #ifndef FILEBROWSER_LITE - -lfilebrowserfileopclient - #endif" - - INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE - - HEADERS += ../engine/engine.h \ - ../engine/FBFileUtils.h \ - ../engine/FBFileOps.h \ - ../engine/FB.hrh \ - ../engine/FBStd.h \ - ../engine/FBTraces.h \ - ../engine/FBFolderSelector.h \ - #ifndef FILEBROWSER_LITE - ../fileopclient/inc/FBFileOpClient.h - #endif - SOURCES += ../engine/engine.cpp \ - ../engine/FBFileUtils.cpp \ - ../engine/FBFileOps.cpp \ - ../engine/FBFolderSelector.cpp - RSS_RULES += "group_name = \"RnD Tools\";" - TARGET.CAPABILITY = NetworkServices LocalServices CAP_APPLICATION AllFiles DiskAdmin - TARGET.UID3 = 0xE85157B0 - TARGET.VID = 0x101FB657 // Nokia - TARGET.EPOCHEAPSIZE = 0x20000 0x4000000 // Min 128Kb, Max 64Mb - ICON = ../icons/qgn_menu_filebrowser.svg -} else { - error("Only Symbian supported!") -} - diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/ui/ui.qrc --- a/filebrowser/ui/ui.qrc Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ - - - ../icons/qgn_indi_tb_filebrowser_folder_parent.svg - ../icons/qgn_indi_tb_filebrowser_find.svg - ../icons/qgn_indi_tb_filebrowser_selection_active.svg - ../icons/qtg_indi_status_back.svg - - diff -r 819e59dfc032 -r 2d9cac8919d3 launcher/ReleaseNotes_Launcher.txt --- a/launcher/ReleaseNotes_Launcher.txt Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,135 +0,0 @@ -=============================================================================== - -RELEASE NOTES - LAUNCHER v4.0.1 -RELEASED 21st May 2010 - -SUPPORTS S60 3.0+ - -=============================================================================== - -Product Description: -==================== -Launcher is a testing utility application aimed to help test the launching of -applications installed in the system, both on user side disk drives and on -ROM. Launcher tests if an application can be launched and then, if the launch -has failed, reports the possible reason for the failure. It is a very useful -application when checking the build as the user can instantly see if the -applications work. Launcher can also be used when testing binary -compatibility issues because it can reveal any DLL files missing from the -device. - -Main Features: -============== -- Show a list of installed applications in all drives -- Launch selected applications and read their statuses from threads -- In case of a failure, report thread's exit type, reason and category -- Show missing DLL files required by the binary to be launched -- Show problems on the UI and print all cases to a log file -- Generate a list of DLLs in the device to a file -- Analyse binary compatibility of system DLLs comparing them to a user - given reference data. Report any binary compatibility issues or missing - DLL files. - -=============================================================================== - -What's New in v4.0.1 -==================== -- Feature: Orbit UI improvements -- Fix: Launching DLL analysis not starting - -=============================================================================== - -Installation Notes: -=================== -Launcher is typically preinstalled on ROM. If not, it can be added to the -ROM with the .iby file. Alternatively, a .sis file can be found under the sis- -directory, but the user needs to sign it with their own developer certificate. -In Nokia R&D environment, you can use directly the R&D-signed .sis file under the -internal\sis directory. - -When signing with own developer certificate, the following capabilities are -needed: - PowerMgmt - ReadDeviceData - WriteDeviceData - AllFiles - ReadUserData - WriteUserData - -When building Launcher against S60 3.0 or 3.1, you may need to patch your SDK -environment first with some fixes. For more information, please refer to the -instructions under the "envpatcher" directory. - -=============================================================================== - -System Requirements: -==================== -Basic Requirements: -- Any S60 3.x device or emulator environment - -=============================================================================== - -Compatibility Issues: -===================== -N/A - -=============================================================================== - -Known Issues: -============= - -Fails in a test despite the application is working correctly ------------------------------------------------------------- -- Some application may exit immediately after a launch. This can be - normal behavior and should be checked manually. Such application is, for example, - irapp.exe. - -Binary compatibility check support ----------------------------------- -- Currently, only uncompressed and deflate compressed ELF binaries are - supported. This means that for example WINSCW is not supported. - -=============================================================================== - -Version History: -================ -3.7.0 - 29th May 2009 -- Feature: Binary compatiblity check for DLLs, which checks UID1, UID2, UID3, SID -and capability values of system DLLs against an XML-formatted input file. -- Fix: Launcher panics when comparing a large DLL list against system DLLs. -- Fix: Launcher panics when application launching is cancelled. - -Version 3.6.3 - 14th March 2008 -------------------------------- -- Change: Removed unnecessary capabilities - -Version 3.6.2 - 6th November 2007 --------------------------------- -- Fix: Applications can be selected/unselected on a touch UI -- Fix: Scroll bar in the output view can be scrolled on a touch UI - -Version 3.6.1 - 9th October 2007 --------------------------------- -- Fix: Layout in out tab in mirrored mode -- Fix: Codescanner high warnings - -Version 3.6.0 - 25th January 2007 ---------------------------------- -- Fix: Re-fix problems when reading import section from binaries -- Fix: Output screen for larger resolutions -- Fix: Stopping of launching - -Version 3.5.0 - 4th December 2006 ---------------------------------- -- Fix: Problems when reading import section from binaries -- Change: Marquee used for items in the application list view - -=============================================================================== - -Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -All rights reserved. - -This component and the accompanying materials are made available -under the terms of "Eclipse Public License v1.0" -which accompanies this distribution, and is available -at the URL "http://www.eclipse.org/legal/epl-v10.html". diff -r 819e59dfc032 -r 2d9cac8919d3 launcher/engine/inc/e32image.h --- a/launcher/engine/inc/e32image.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,84 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - - -#ifndef __LAUNCHERE32IMAGE_H__ -#define __LAUNCHERE32IMAGE_H__ - -#include -#include -#include -#include - -class E32ImageHeader; -class E32ImportSection; -class E32RelocSection; -class CEikonEnv; - - -NONSHARABLE_CLASS(E32ImageReader) : public CBase, public TProcessCreateInfo - { -public: - static E32ImageReader* NewLC(); - ~E32ImageReader(); - -public: - CDesCArray* ListOfDLLsL(const TDesC& aFullPathToE32Image); - -private: - E32ImageReader(); - void ConstructL(); - TInt LoadData(); - static TUint8* MemoryMove(TAny* aDestination, const TAny* aSource, TInt aNumberofBytes); - TInt LoadFile(TUint32 aCompression); - TInt LoadFileNoCompress(); - void LoadFileInflateL(); - TInt Read(TText8* aDest, TInt aSize); - TInt Read(TInt aPos, TText8* aDest, TInt aSize); - TInt ReadImportData(); - -private: - CEikonEnv* iEnv; - -public: - E32ImageHeader* iHeader; - E32ImportSection* iImportSection; - E32RelocSection* iCodeRelocSection; - E32RelocSection* iDataRelocSection; - TUint32* iImportData; - TUint8* iRestOfFileData; - TUint32 iRestOfFileSize; - TUint32 iConversionOffset; - RFile iFile; - TUint32 iCodeDelta; - TUint32 iDataDelta; - TUint32 iExportDirLoad; - TBool isDll; - TBool iAlreadyLoaded; - TAny* iCloseCodeSeg; - TInt iCurrentImportCount; - TInt iNextImportPos; - TUint32* iCurrentImportList; - TUint8 iCurrentImportListSorted; - TUint8 iExportDirLoadAllocated; - TUint8 iPadding1; - TUint8 iPadding2; - }; - -#endif // __LAUNCHERE32IMAGE_H__ diff -r 819e59dfc032 -r 2d9cac8919d3 launcher/engine/inc/e32imageheaders.h --- a/launcher/engine/inc/e32imageheaders.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,540 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#ifndef __LAUNCHERE32IMAGEHEADERS_H__ -#define __LAUNCHERE32IMAGEHEADERS_H__ - -#include - -// from e32Huffman.h - -/** @file - @internalTechnology -*/ - -/** Bit output stream. - Good for writing bit streams for packed, compressed or huffman data algorithms. - - This class must be derived from and OverflowL() reimplemented if the bitstream data - cannot be generated into a single memory buffer. -*/ -class TBitOutput - { -public: - IMPORT_C TBitOutput(); - IMPORT_C TBitOutput(TUint8* aBuf,TInt aSize); - inline void Set(TUint8* aBuf,TInt aSize); - inline const TUint8* Ptr() const; - inline TInt BufferedBits() const; -// - IMPORT_C void WriteL(TUint aValue, TInt aLength); - IMPORT_C void HuffmanL(TUint aHuffCode); - IMPORT_C void PadL(TUint aPadding); -private: - void DoWriteL(TUint aBits, TInt aSize); - virtual void OverflowL(); -private: - TUint iCode; // code in production - TInt iBits; - TUint8* iPtr; - TUint8* iEnd; - }; - -/** Set the memory buffer to use for output - - Data will be written to this buffer until it is full, at which point OverflowL() will - be called. This should handle the data and then can Set() again to reset the buffer - for further output. - - @param aBuf The buffer for output - @param aSize The size of the buffer in bytes -*/ -inline void TBitOutput::Set(TUint8* aBuf,TInt aSize) - {iPtr=aBuf;iEnd=aBuf+aSize;} - -/** Get the current write position in the output buffer - - In conjunction with the address of the buffer, which should be known to the - caller, this describes the data in the bitstream. -*/ -inline const TUint8* TBitOutput::Ptr() const - {return iPtr;} - -/** Get the number of bits that are buffered - - This reports the number of bits that have not yet been written into the - output buffer. It will always lie in the range 0..7. Use PadL() to - pad the data out to the next byte and write it to the buffer. -*/ -inline TInt TBitOutput::BufferedBits() const - {return iBits+8;} - -/** Bit input stream. Good for reading bit streams for packed, compressed or huffman - data algorithms. -*/ -class TBitInput - { -public: - IMPORT_C TBitInput(); - IMPORT_C TBitInput(const TUint8* aPtr, TInt aLength, TInt aOffset=0); - IMPORT_C void Set(const TUint8* aPtr, TInt aLength, TInt aOffset=0); -// - IMPORT_C TUint ReadL(); - IMPORT_C TUint ReadL(TInt aSize); - IMPORT_C TUint HuffmanL(const TUint32* aTree); -private: - virtual void UnderflowL(); -private: - TInt iCount; - TUint iBits; - TInt iRemain; - const TUint32* iPtr; - }; - - -/** Huffman code toolkit. - - This class builds a huffman encoding from a frequency table and builds - a decoding tree from a code-lengths table - - The encoding generated is based on the rule that given two symbols s1 and s2, with - code length l1 and l2, and huffman codes h1 and h2: - - if l1= KImageHdrFmt_J) - return iCompressionType; - return 0; - } - inline TUint32 ModuleVersion() const - { - if ((iFlags & KImageHdrFmtMask) >= KImageHdrFmt_V) - return iModuleVersion; - return 0x00000000u; - } - inline TInt TotalSize() const; - inline TInt UncompressedFileSize() const; - inline TUint HeaderFormat() const - { return HdrFmtFromFlags(iFlags); } - inline TUint EntryPointFormat() const - { return EptFromFlags(iFlags); } - inline TUint ImportFormat() const - { return ImpFmtFromFlags(iFlags); } - inline TUint ABI() const - { return ABIFromFlags(iFlags); } - inline void GetSecurityInfo(SSecurityInfo& aInfo) const; - inline TCpu CpuIdentifier() const; - inline TProcessPriority ProcessPriority() const; - inline TUint32 ExceptionDescriptor() const; - TInt IntegrityCheck(TInt aFileSize); - static TInt New(E32ImageHeader*& aHdr, RFile& aFile); -public: - TUint32 iUid1; - TUint32 iUid2; - TUint32 iUid3; - TUint32 iUidChecksum; - TUint iSignature; // 'EPOC' - TUint32 iHeaderCrc; // CRC-32 of entire header - TUint32 iModuleVersion; // Version number for this executable (used in link resolution) - TUint32 iCompressionType; // Type of compression used (UID or 0 for none) - TVersion iToolsVersion; // Version of PETRAN/ELFTRAN which generated this file - TUint32 iTimeLo; - TUint32 iTimeHi; - TUint iFlags; // 0 = exe, 1 = dll, 2 = fixed address exe - TInt iCodeSize; // size of code, import address table, constant data and export dir - TInt iDataSize; // size of initialised data - TInt iHeapSizeMin; - TInt iHeapSizeMax; - TInt iStackSize; - TInt iBssSize; - TUint iEntryPoint; // offset into code of entry point - TUint iCodeBase; // where the code is linked for - TUint iDataBase; // where the data is linked for - TInt iDllRefTableCount; // filling this in enables E32ROM to leave space for it - TUint iExportDirOffset; // offset into the file of the export address table - TInt iExportDirCount; - TInt iTextSize; // size of just the text section, also doubles as the offset for the iat w.r.t. the code section - TUint iCodeOffset; // file offset to code section, also doubles as header size - TUint iDataOffset; // file offset to data section - TUint iImportOffset; // file offset to import section - TUint iCodeRelocOffset; // relocations for code and const - TUint iDataRelocOffset; // relocations for data - TUint16 iProcessPriority; // executables priority - TUint16 iCpuIdentifier; // 0x1000 = X86, 0x2000 = ARM - }; - -class E32ImageHeaderComp : public E32ImageHeader - { -public: - TUint32 iUncompressedSize; // Uncompressed size of file - // For J format this is file size - sizeof(E32ImageHeader) - // and this is included as part of the compressed data :-( - // For other formats this is file size - total header size - }; - -class E32ImageHeaderV : public E32ImageHeaderComp - { -public: - SSecurityInfo iS; - - // Use iSpare1 as offset to Exception Descriptor - TUint32 iExceptionDescriptor; // Offset in bytes from start of code section to Exception Descriptor, bit 0 set if valid - TUint32 iSpare2; - TUint16 iExportDescSize; // size of bitmap section - TUint8 iExportDescType; // type of description of holes in export table - TUint8 iExportDesc[1]; // description of holes in export table - extend - }; - -// export description type -const TUint KImageHdr_ExpD_NoHoles =0x00; // no holes, all exports present -const TUint KImageHdr_ExpD_FullBitmap =0x01; // full bitmap present -const TUint KImageHdr_ExpD_SparseBitmap8 =0x02; // sparse bitmap present, granularity 8 -const TUint KImageHdr_ExpD_Xip =0xff; // XIP file - - -inline TInt E32ImageHeader::TotalSize() const - { - if (HeaderFormat() == KImageHdrFmt_J && iCompressionType != 0) - return sizeof(E32ImageHeaderComp); - return iCodeOffset; - } - -inline TInt E32ImageHeader::UncompressedFileSize() const - { - TUint hdrfmt = HeaderFormat(); - if (hdrfmt == KImageHdrFmt_Original || iCompressionType == 0) - return -1; // not compressed - else if (hdrfmt == KImageHdrFmt_J) - return ((E32ImageHeaderComp*)this)->iUncompressedSize + sizeof(E32ImageHeader); - else - return ((E32ImageHeaderComp*)this)->iUncompressedSize + iCodeOffset; - } - -extern const SSecurityInfo KDefaultSecurityInfo; -inline void E32ImageHeader::GetSecurityInfo(SSecurityInfo& aInfo) const - { - if (HeaderFormat() >= KImageHdrFmt_V) - aInfo = ((E32ImageHeaderV*)this)->iS; - else - aInfo = KDefaultSecurityInfo; - } - -inline TCpu E32ImageHeader::CpuIdentifier() const - { - if (HeaderFormat() >= KImageHdrFmt_V) - return (TCpu)iCpuIdentifier; - return (TCpu)iHeaderCrc; - } - -inline TProcessPriority E32ImageHeader::ProcessPriority() const - { - if (HeaderFormat() >= KImageHdrFmt_V) - return (TProcessPriority)iProcessPriority; - return *(const TProcessPriority*)&iProcessPriority; - } - -inline TUint32 E32ImageHeader::ExceptionDescriptor() const - { - if (HeaderFormat() >= KImageHdrFmt_V) - { - TUint32 xd = ((E32ImageHeaderV*)this)->iExceptionDescriptor; - if ((xd & 1) && (xd != 0xffffffffu)) - return (xd & ~1); - } - return 0; - } - -class E32ImportBlock - { -public: - inline const E32ImportBlock* NextBlock(TUint aImpFmt) const; - inline TInt Size(TUint aImpFmt) const; - inline const TUint* Imports() const; // import list if present -public: - TUint32 iOffsetOfDllName; // offset of name of dll importing from - TInt iNumberOfImports; // no of imports from this dll -// TUint iImport[iNumberOfImports]; // list of imported ordinals, omitted in PE2 import format - }; - -inline TInt E32ImportBlock::Size(TUint aImpFmt) const - { - TInt r = sizeof(E32ImportBlock); - if (aImpFmt!=KImageImpFmt_PE2) - r += iNumberOfImports * sizeof(TUint); - return r; - } - -inline const E32ImportBlock* E32ImportBlock::NextBlock(TUint aImpFmt) const - { - const E32ImportBlock* next = this + 1; - if (aImpFmt!=KImageImpFmt_PE2) - next = (const E32ImportBlock*)( (TUint8*)next + iNumberOfImports * sizeof(TUint) ); - return next; - } - -inline const TUint* E32ImportBlock::Imports() const - { - return (const TUint*)(this + 1); - } - -class E32ImportSection - { -public: - TInt iSize; // size of this section -// E32ImportBlock[iDllRefTableCount]; - }; - -class E32RelocSection - { -public: - TInt iSize; // size of this relocation section - TInt iNumberOfRelocs; // number of relocations in this section - }; - - -typedef TUint8* (*TMemoryMoveFunction)(TAny* aTrg,const TAny* aSrc,TInt aLength); - -const TInt KDeflateLengthMag=8; -const TInt KDeflateDistanceMag=12; -const TInt KDeflateMinLength=3; -const TInt KDeflateMaxLength=KDeflateMinLength-1 + (1< - -typedef TBuf8<8> TDllIdValue; - -class CLauncherDLLElement : public CBase - { -public: - - enum TDifference - { - EDifference_UID1, // UID1 is different - EDifference_UID2, // UID1 is different - EDifference_UID3, // UID1 is different - EDifference_SID, // SID is different - EDifference_Capability // Capabilities are different - }; - - virtual ~CLauncherDLLElement(); - static CLauncherDLLElement* NewL(); - static CLauncherDLLElement* NewLC(); - - /* - * Compares DLL elements. - * @return ETrue if differencies exist, EFalse otherwise. - * @param aReferenceElement Reference DLL-element for comparison - * @param aDifferenceList Differencies are added to this list. - */ - TBool CompareL(const CLauncherDLLElement& aReferenceElement, RArray& aDifferenceList) const; - - /* - * Returns DLL name - * @return DLL name - */ - TFileName Name() const; - /* - * Sets DLL name - * @param aName DLL name - */ - void SetNameL(const TFileName& aName); - - /* - * Returns DLL UID1 - * @return UID1 object - */ - TUid UID1() const; - - /* - * Sets DLL UID1 - * @param aUID1 UID1 object - */ - void SetUID1L(TUid aUID1); - - /* - * Returns DLL UID2 - * @return UID2 object - */ - TUid UID2() const; - - /* - * Sets DLL UID2 - * @param aUID2 UID2 object - */ - void SetUID2L(TUid aUID2); - - /* - * Returns DLL UID3 - * @return UID3 object - */ - TUid UID3() const; - - /* - * Sets DLL UID3 - * @param aUID3 UID3 object - */ - void SetUID3L(TUid aUID3); - - /* - * Returns DLL SID - * @return SID object - */ - TUid SID() const; - - /* - * Sets DLL SID - * @param aSID SID object - */ - void SetSIDL(TUid aSID); - - /* - * Returns DLL capability - * @return capability value - */ - TUint32 Capability() const; - - /* - * Sets DLL capability - * @param aCapability capability value - */ - void SetCapabilityL(TUint32 aCapability); - -protected: - CLauncherDLLElement(); - virtual void ConstructL(); - -private: - TFileName iName; - TUid iUID1; - TUid iUID2; - TUid iUID3; - TUid iSID; - TUint32 iCapability; - }; - -#endif /* LAUNCHERDLLELEMENT_H_ */ diff -r 819e59dfc032 -r 2d9cac8919d3 launcher/engine/inc/launcherdllparser.h --- a/launcher/engine/inc/launcherdllparser.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,62 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef LAUNCHERDLLPARSER_H_ -#define LAUNCHERDLLPARSER_H_ - -#include -#include -#include "launcherdllelement.h" - -#define UID1_OFFSET 0x00 -#define UID2_OFFSET 0x04 -#define UID3_OFFSET 0x08 -#define SID_OFFSET_ROM 0x44 -#define SID_OFFSET_ROFS 0x80 -#define CAPABILITY_OFFSET_ROM 0x4c -#define CAPABILITY_OFFSET_ROFS 0x88 - -class CLauncherDLLParser : public CBase - { -public: - - virtual ~CLauncherDLLParser(); - static CLauncherDLLParser* NewL(); - static CLauncherDLLParser* NewLC(); - - /** - * Reads data from the given DLL-file and sets parsed data to given object. - * @param aFileSession Reference to an open file session - * @param aFile Reference to the DLL file object - * @param aElement Reference to the element, which will contain the parsed data - */ - void ParseL( RFs& aFileSession, RFile& aFile, CLauncherDLLElement& aElement ); - -private: - - CLauncherDLLParser(); - void ConstructL(); - - /** - * Reads 32-bit unsigned integer from the given file. - * @return 32-bit unsigned integer value. - * @param aFile File handle. - */ - TUint32 ReadUint32L( RFile& aFile ); - }; - -#endif /* LAUNCHERDLLPARSER_H_ */ diff -r 819e59dfc032 -r 2d9cac8919d3 launcher/engine/inc/launcherengine.h --- a/launcher/engine/inc/launcherengine.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,274 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef LAUNCHERENGINE_H -#define LAUNCHERENGINE_H - -#include -#include -#include -#include -#include - -#include "launcherparserobserver.h" - -// CONSTANTS -// None - -// MACROS -// None - -// DATA TYPES -// None - -// FUNCTION PROTOTYPES -// None - -// FORWARD DECLARATIONS -class CEikonEnv; -class CAppThreadChecker; -class CAppRunningChecker; -class CLauncherXMLParser; -class CLauncherDLLParser; - - -// INFERFACE FOR COMMUNICATION WITH UI - -class MLauncherUI -{ -public: - /** - * Method for writing text to output window. - * @param aText A text to be written. - * @return None. - */ - virtual void PrintText(const TDesC& aText) = 0; - - /** - * Shows info message with text - * @param aText An text to be shown in message. - * @return None. - */ - virtual void ShowInfoMessage(const TDesC& aText) = 0; - - /** - * Shows error message with error text - * @param aText An error text to be shown in message. - * @return None. - */ - virtual void ShowErrorMessage(const TDesC& aText) = 0; - - /** - * Shows progress bar with text - * @param aText A text to be shown at top of the progress bar. - * @param aMinimum A minimum progress bar value. - * @param aMaximum A maximum progress bar value. - * @return None. - */ - virtual void ShowProgressBar(const TDesC& aText, TInt aMinimum, TInt aMaximum ) = 0; - - /** - * Sets progress bar value - * @param aValue A value between min and max value of the progress bar range - * @return None. - */ - virtual void SetProgressBarValue(TInt aValue) = 0; - - /** - * Hides progress bar - * @return None. - */ - virtual void HideProgressBar() = 0; - - /** - * Shows wait dialog with text - * @param aText A text to be shown at top of the wait bar. - * @return None. - */ - virtual void ShowWaitDialog(const TDesC& aText) = 0; - - /** - * Hides wait dialog - * @return None. - */ - virtual void HideWaitDialog() = 0; - - /** - * Changes focus to output view - * @return None. - */ - virtual void ChangeFocusToOutputView() = 0; - -}; - -// CLASS DECLARATION - -class CLauncherEngine: public CActive, public MLauncherParserObserver -{ - -public: - static CLauncherEngine* NewL(MLauncherUI *aLauncherUI); - ~CLauncherEngine(); - CDesCArray* ListOfAllAppsL(); - void StartAppLaunchingL(const CArrayFix* aSelectedApps, TBool aAutoClose); - void CheckIfAppIsRunningL(); - void CheckWhyThreadDiedL(); - void StopLaunchingL(); - TBool LogFileExists(); - TBool BCLogFileExists(); - - TInt DeleteLogFile(); - TInt DeleteBCLogFile(); - - void AnalyseDLLsL( const TDesC& aFileName ); - - void ElementParsedL(const CLauncherDLLElement& aDllElement); - void DocumentParsedL(TInt aErrorCode); - void ParsingProgressedL(TInt aBytes); - TInt ReadLineFromFileL(RFile& aFile, TDes& aReadBuf); - - const TDesC& RequiredDllsFilePath() const { return iRequiredDllsFilePath; }; - - void CancelBCAnalysis(); - -private: - CLauncherEngine(); - void ConstructL(MLauncherUI *aLauncherUI); - - void RunL(); - void DoCancel(); - - TInt FindFiles(const TDesC& aFileName, const TDesC& aPath); - void IssueLaunch(); - void WriteInitialStuffToTheLogL(const TDesC& aOwnData, RFile& aFile); - void CheckForMoreAppsL(); - void LaunchApplicationL(); - void DoLaunchApplicationL(); - CDesCArray* DependencyCheckForE32ImageL(); - - /** - * Performs binary compatibility analysis based on reference data given - * in XML-file. - */ - void DoBCAnalysisL(); - - /** - * Compares given DLL list to system DLLs - */ - void DoCompareDLLListsL(); - -private: - - MLauncherUI *iLauncherUI; - - RTimer iTimer; - CEikonEnv* iEnv; - RApaLsSession iLs; - RWsSession iWs; - HBufC8* iLogWriteBuf; - RFile iLogFile; - RFile iBCLogFile; - TFileName iLogFilePath; - TFileName iBCLogFilePath; - TFileName iSystemDllsFilePath; - TFileName iRequiredDllsFilePath; - - CDesCArray* iAppsArray; - CDesCArray* iAllAppsArray; - CDesCArray* iSystemDllArray; -// CDesCArray* iRequiredDllArray; - - TBool iLaunchingIsActive; - TBool iDLLAnalysisIsActive; - TBool iSkipHiddenAndEmbedOnly; - TBool iAutoClose; - TInt iAppLaunchCounter; - TInt iFailedCases; - TInt iOkCases; - TInt iSkippedCases; - TInt iTotalNumberOfCases; - - TUid iCurrentAppUid; - TThreadId iCurrentAppThreadId; - TBuf<128> iCurrentAppNameAndExt; - RThread iCurrentAppThread; -// - CAppThreadChecker* iAppThreadChecker; - CAppRunningChecker* iAppRunningChecker; - - CLauncherXMLParser* iXMLParser; - CLauncherDLLParser* iDLLParser; - CLauncherDLLElement* iDLLElement; - - TInt iFoundBCIssues; - HBufC* iBCIssuesBigBuffer; - - -public: - inline TBool SkipHiddenAndEmbedOnly() { return iSkipHiddenAndEmbedOnly; }; - inline void SetSkipHiddenAndEmbedOnly(TBool aSkip) { iSkipHiddenAndEmbedOnly = aSkip; }; - inline const TDesC& LogFilePath() { return iLogFilePath; } - inline const TDesC& BCLogFilePath() { return iBCLogFilePath; } - inline const TDesC& SystemDllsFilePath() { return iSystemDllsFilePath; } -}; - - - -class CAppRunningChecker : public CActive - { -public: - static CAppRunningChecker* NewL(CLauncherEngine* aLauncherEngine); - ~CAppRunningChecker(); - - void StartTesting(); - -private: - CAppRunningChecker(); - void ConstructL(CLauncherEngine* aLauncherEngine); - - void RunL(); - void DoCancel(); - -private: - RTimer iTimer; - CEikonEnv* iEnv; - CLauncherEngine* iLauncherEngine; - }; - -class CAppThreadChecker : public CActive - { -public: - static CAppThreadChecker* NewL(CLauncherEngine* aLauncherEngine); - ~CAppThreadChecker(); - - void ActivateChecking(); - void CheckIfAppIsRunningL(); - -private: - CAppThreadChecker(); - void ConstructL(CLauncherEngine* aLauncherEngine); - - void RunL(); - void DoCancel(); - -private: - CEikonEnv* iEnv; - CLauncherEngine* iLauncherEngine; - }; - - -#endif //LAUNCHERENGINE_H diff -r 819e59dfc032 -r 2d9cac8919d3 launcher/engine/inc/launcherparserobserver.h --- a/launcher/engine/inc/launcherparserobserver.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef LAUNCHERPARSEROBSERVER_H_ -#define LAUNCHERPARSEROBSERVER_H_ - -class CLauncherDLLElement; - -class MLauncherParserObserver -{ -public: - - /** - * This method is called when parser has parsed next DLL element - * @param aDllElement Parsed DLL element. - */ - virtual void ElementParsedL(const CLauncherDLLElement& aDllElement) = 0; - - /** - * This method is called when the parsing is completed. If parsing was - * stopped due to an error, an error code is given in parameter. - * @param aErrorCode KErrNone if document was parsed successfully. - */ - virtual void DocumentParsedL(TInt aErrorCode) = 0; - - /** - * Parser calls this function during parsing to indicate the amount of - * bytes parsed from the given file. - * @param aBytes Amount of data (in bytes) parsed. Amount is incremental. - */ - virtual void ParsingProgressedL(TInt aBytes) = 0; - -}; - -#endif /* LAUNCHERPARSEROBSERVER_H_ */ diff -r 819e59dfc032 -r 2d9cac8919d3 launcher/engine/inc/launchertraces.h --- a/launcher/engine/inc/launchertraces.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,103 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef __LAUNCHER_TRACES_H__ -#define __LAUNCHER_TRACES_H__ - -#include - - -// --------------------------------------------------------------------------- -// You change these logging method values below! Recompile the application to take changes effect. - - // logging methods - // 0 = No logging - // 1 = Flogger - // 2 = RDebug - // 3 = Flogger and RDebug - - #ifndef _DEBUG - - // Logging method for UREL builds: - #define LAUNCHER_LOGGING_METHOD 2 - - #else - - // Logging method for UDEB builds: - #define LAUNCHER_LOGGING_METHOD 0 - - #endif - - - -// --------------------------------------------------------------------------- -// Do not make any changes to lines below... - - #if LAUNCHER_LOGGING_METHOD == 1 || LAUNCHER_LOGGING_METHOD == 3 - - #include - _LIT(KLogFolder,"Launcher"); - _LIT(KLogFile,"Launcher_Trace.txt"); - - #endif - - #if LAUNCHER_LOGGING_METHOD == 2 || LAUNCHER_LOGGING_METHOD == 3 - - #include - - #endif - - - #if LAUNCHER_LOGGING_METHOD == 0 - - #define LOGTEXT(AAA) - #define LOGSTRING(AAA) - #define LOGSTRING2(AAA,BBB) - #define LOGSTRING3(AAA,BBB,CCC) - #define LOGSTRING4(AAA,BBB,CCC,DDD) - - - #elif LAUNCHER_LOGGING_METHOD == 1 - - #define LOGTEXT(AAA) RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend, AAA) - #define LOGSTRING(AAA) do { _LIT(tempLogDes,AAA); RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend,tempLogDes()); } while (0) - #define LOGSTRING2(AAA,BBB) do { _LIT(tempLogDes,AAA); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB); } while (0) - #define LOGSTRING3(AAA,BBB,CCC) do { _LIT(tempLogDes,AAA); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB,CCC); } while (0) - #define LOGSTRING4(AAA,BBB,CCC,DDD) do { _LIT(tempLogDes,AAA); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB,CCC,DDD); } while (0) - - #elif LAUNCHER_LOGGING_METHOD == 2 - - #define LOGTEXT(AAA) RDebug::Print(AAA) - #define LOGSTRING(AAA) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes); } while (0) - #define LOGSTRING2(AAA,BBB) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB); } while (0) - #define LOGSTRING3(AAA,BBB,CCC) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC); } while (0) - #define LOGSTRING4(AAA,BBB,CCC,DDD) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC, DDD); } while (0) - - #elif LAUNCHER_LOGGING_METHOD == 3 - - #define LOGTEXT(AAA) RDebug::Print(AAA); RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend, AAA) - #define LOGSTRING(AAA) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes); RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend,tempLogDes()); } while (0) - #define LOGSTRING2(AAA,BBB) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB); } while (0) - #define LOGSTRING3(AAA,BBB,CCC) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB,CCC); } while (0) - #define LOGSTRING4(AAA,BBB,CCC,DDD) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC, DDD); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB,CCC,DDD); } while (0) - - #endif - -// --------------------------------------------------------------------------- - -#endif // __LAUNCHER_TRACES_H__ - diff -r 819e59dfc032 -r 2d9cac8919d3 launcher/engine/inc/launcherxmlparser.h --- a/launcher/engine/inc/launcherxmlparser.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,114 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef LAUNCHERXMLPARSER_H_ -#define LAUNCHERXMLPARSER_H_ - -#include -#include -#include -#include "launcherdllelement.h" -#include "launcherparserobserver.h" - -using namespace Xml; - -const TUint KXMLBufferSize = 1024; - -class CLauncherDLLElement; - -/** - * Parses DLL data from the given XML-file - */ -class CLauncherXMLParser : public CActive, public MContentHandler -{ -public: - - virtual ~CLauncherXMLParser(); - static CLauncherXMLParser* NewL(RFs& aFs); - static CLauncherXMLParser* NewLC(RFs& aFs); - - /** - * Parses the given XML-file and notifies the observer. - * @param aFilePath XML-file's path - * @param aObserver Pointer to the observer instance. - */ - void ParseL(const TDesC& aFilePath, MLauncherParserObserver* aObserver); - -protected: - - // from CActive - void DoCancel(); - void RunL(); - -private: - - CLauncherXMLParser(RFs& aFs); - void ConstructL(); - - /** - * Tells whether the current XML element is a sub-element of the 'dll'-element. - * @return ETrue if the current XML-element is sub-element of the 'dll'-element. - */ - TBool IsDataElement(); - - /** - * Deletes current data buffer and zeroes the pointer. - */ - void ClearXMLDataBuffer(); - - /** - * Converts 8-bit descriptor to 32-bit unsigned integer - * @return Converted 32-bit unsigned integer value. - * @param aStr 8-bit descriptor to be converted. - */ - TUint32 ConvertDes8ToUint32L(const TDesC8& aStr); - -public: - // From MContentHandler: - void OnStartDocumentL(const RDocumentParameters &aDocParam, TInt aErrorCode); - void OnEndDocumentL(TInt aErrorCode); - void OnStartElementL( const RTagInfo& aElement, - const RAttributeArray& aAttributes, - TInt aErrorCode); - void OnEndElementL(const RTagInfo& aElement, TInt aErrorCode); - void OnContentL(const TDesC8& aBytes, TInt aErrorCode); - void OnStartPrefixMappingL( const RString& aPrefix, - const RString& aUri, - TInt aErrorCode); - void OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode); - void OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt aErrorCode); - void OnSkippedEntityL(const RString& aName, TInt aErrorCode); - void OnProcessingInstructionL( const TDesC8& aTarget, - const TDesC8& aData, - TInt aErrorCode); - void OnError(TInt aErrorCode); - TAny* GetExtendedInterface(const TInt32 aUid); - -private: - CParser* iParser; // XML parser - RFs& iFileSession; - RFile iFile; // XML file - TBuf8 iXMLDataBuffer; - MLauncherParserObserver* iObserver; - CLauncherDLLElement* iCurrentDllElement; - TBuf8 iCurrentContent; - TBuf8 iCurrentElementName; - TBool iIgnoreError; - TInt iParsedBytes; -}; - -#endif /* LAUNCHERXMLPARSER_H_ */ diff -r 819e59dfc032 -r 2d9cac8919d3 launcher/engine/src/e32image.cpp --- a/launcher/engine/src/e32image.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,846 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - -#include "e32image.h" -#include "e32imageheaders.h" -#include "launchertraces.h" - - -const TInt KMaxHeaderSize = sizeof(E32ImageHeaderV) + 65536/8; - -SCapabilitySet AllCapabilities; -SCapabilitySet DisabledCapabilities; - -// --------------------------------------------------------------------------- - -E32ImageReader* E32ImageReader::NewLC() - { - E32ImageReader* self = new(ELeave) E32ImageReader; - CleanupStack::PushL(self); - self->ConstructL(); - return self; - } - -// --------------------------------------------------------------------------- - -E32ImageReader::E32ImageReader() - { - } - -// --------------------------------------------------------------------------- - -void E32ImageReader::ConstructL() - { - LOGSTRING("Launcher: E32ImageReader::ConstructL"); - - iEnv = CEikonEnv::Static(); - } - -// --------------------------------------------------------------------------- - -CDesCArray* E32ImageReader::ListOfDLLsL(const TDesC& aFullPathToE32Image) - { - LOGSTRING("Launcher: E32ImageReader::ListOfDLLsL"); - - // open the file for reading - User::LeaveIfError( iFile.Open(iEnv->FsSession(), aFullPathToE32Image, EFileRead) ); - CleanupClosePushL(iFile); - - // get local copies of capability sets - TCapabilitySet caps; - caps.SetAllSupported(); - AllCapabilities=*(SCapabilitySet*)∩︀ - caps.SetDisabled(); - DisabledCapabilities=*(SCapabilitySet*)∩︀ - - // read the header of the image - User::LeaveIfError( E32ImageHeader::New(iHeader, iFile) ); - - // set stuff - iHeapSizeMin = iHeader->iHeapSizeMin; - iHeapSizeMax = iHeader->iHeapSizeMax; - iStackSize = iHeader->iStackSize; - iPriority = iHeader->ProcessPriority(); - iDepCount = iHeader->iDllRefTableCount; - iExportDirCount = iHeader->iExportDirCount; - iExportDir = iHeader->iExportDirOffset-iHeader->iCodeOffset; - iTextSize = iHeader->iTextSize; - iCodeSize = iHeader->iCodeSize; - iDataSize = iHeader->iDataSize; - iBssSize = iHeader->iBssSize; - iTotalDataSize = iDataSize+iBssSize; - iFileEntryPoint = iHeader->iEntryPoint; - iEntryPtVeneer = 0; - iExceptionDescriptor = iHeader->ExceptionDescriptor(); - if (iHeader->iExportDirOffset) - iExportDirLoad=iExportDir; - - // allocate data for the code area - iCodeLoadAddress = (TUint32)User::Alloc(iCodeSize); - - // load data from the binary - User::LeaveIfError( LoadData() ); - - // create an array for the dll names from the import list - CDesCArray* dllArray = new(ELeave) CDesCArrayFlat(100); - CleanupStack::PushL(dllArray); - - // get the dll names from the import section - E32ImportSection* importSection = (E32ImportSection *)iImportData; - E32ImportBlock* block; - if(importSection) - block = (E32ImportBlock*)(importSection+1); - else - block = NULL; - iNextImportPos = 0; - - // loop through all import data blocks - for (TInt i=0; iiOffsetOfDllName); - TBuf8 rootname; - if (dllname.Length() > KMaxKernelName) - User::Leave( KErrNotSupported ); - - // parse the filename - TFileNameInfo fni; - User::LeaveIfError( fni.Set(dllname, TFileNameInfo::EAllowUid) ); - fni.GetName(rootname, TFileNameInfo::EIncludeBaseExt); - - // append the name to the dll name array - TFileName dllName16; - dllName16.Copy(rootname); - dllArray->AppendL(dllName16); - - // get the next block - TUint impfmt = iHeader->ImportFormat(); - block = (E32ImportBlock*)block->NextBlock(impfmt); - } - - CleanupStack::Pop(); //dllArray - CleanupStack::PopAndDestroy(); //iFile - - // free memory - delete iHeader; - iHeader = NULL; - delete iImportSection; - iImportSection = NULL; - delete iCodeRelocSection; - iCodeRelocSection = NULL; - delete iDataRelocSection; - iDataRelocSection = NULL; - - User::Free((TAny*)iCodeLoadAddress); - User::Free(iRestOfFileData); - User::Free(iCurrentImportList); - if (iExportDirLoadAllocated) - User::Free((TAny*)iExportDirLoad); - - return dllArray; - } - -// --------------------------------------------------------------------------- - -E32ImageReader::~E32ImageReader() - { - LOGSTRING("Launcher: E32ImageReader::~E32ImageReader"); - } - - -// --------------------------------------------------------------------------- - -TInt FileRead(RFile& aFile, TUint8* aDest, TInt aSize) - { - TPtr8 p(aDest,aSize,aSize); - return aFile.Read(p,aSize); - } - -// --------------------------------------------------------------------------- - -TInt E32ImageHeader::New(E32ImageHeader*& aHdr, RFile& aFile) - { - LOGSTRING("Launcher: E32ImageHeader::New"); - - E32ImageHeader* h = NULL; - TInt hdrsz = 0; - TInt filesize; - TInt r = aFile.Size(filesize); - if (r!=KErrNone) - return r; - E32ImageHeader bh; - r = FileRead(aFile, (TUint8*)&bh, sizeof(E32ImageHeader)); - if (r==KErrNone) - { - hdrsz = bh.TotalSize(); - if ( (TUint(hdrsz) > TUint(KMaxHeaderSize)) || (TUint(hdrsz) < TUint(sizeof(bh))) ) - return KErrCorrupt; - } - h = (E32ImageHeader*)User::Alloc(hdrsz); - if (!h) - return KErrNoMemory; - wordmove(h, &bh, sizeof(E32ImageHeader)); - if (hdrsz > (TInt)sizeof(E32ImageHeader)) - r = FileRead(aFile, (TUint8*)(h + 1), hdrsz - sizeof(E32ImageHeader)); - if (r==KErrNone) - r = h->IntegrityCheck(filesize); - if (r==KErrNone) - { - if (h->HeaderFormat() >= KImageHdrFmt_V) - { - // Overide capabilities in image - for(TInt i=0; iiS.iCaps[i] |= DisabledCapabilities[i]; - ((E32ImageHeaderV*)h)->iS.iCaps[i] &= AllCapabilities[i]; - } - } - aHdr = h; - } - else - { - delete h; - aHdr = NULL; - } - return r; - } - -// --------------------------------------------------------------------------- - -TInt E32ImageHeader::IntegrityCheck(TInt aFileSize) - { - LOGSTRING("Launcher: E32ImageHeader::IntegrityCheck"); - - TInt hdrsz = TotalSize(); - TUint hdrfmt = HeaderFormat(); - TUidType uids = *(const TUidType*)&iUid1; - E32ImageHeaderV* v = NULL; - TCheckedUid chkuid(uids); - const TUint32* pChkUid = (const TUint32*)&chkuid; - - if (pChkUid[3] != iUidChecksum) - return KErrCorrupt; - - if (hdrfmt == KImageHdrFmt_V) - { - TUint32 supplied_crc = iHeaderCrc; - iHeaderCrc = KImageCrcInitialiser; - TUint32 crc = 0; - Mem::Crc32(crc, this, hdrsz); - iHeaderCrc = supplied_crc; - if (crc != supplied_crc) - return KErrCorrupt; - v = (E32ImageHeaderV*)this; - TUint total_eds = v->iExportDescSize + sizeof(v->iExportDescSize) + sizeof(v->iExportDescType); - total_eds = (total_eds + 3) &~ 3; - if (total_eds + (TUint)_FOFF(E32ImageHeaderV, iExportDescSize) != (TUint)hdrsz) - return KErrCorrupt; - if (TUint(v->iExportDescType) > KImageHdr_ExpD_SparseBitmap8) - return KErrNotSupported; - } - else if (hdrfmt >= KImageHdrFmt_V) - return KErrNotSupported; - - TCpu cpu = CpuIdentifier(); - TUint abi = ABI(); - TUint impfmt = ImportFormat(); - TUint compression = CompressionType(); - - TUint uncompressed_size = compression ? UncompressedFileSize() : (TUint)aFileSize; - - if (iSignature != 0x434f5045) // 'EPOC' - return KErrCorrupt; - if (iCodeSize<0) - return KErrCorrupt; - if (iDataSize<0) - return KErrCorrupt; - if (iHeapSizeMin<0) - return KErrCorrupt; - if (iHeapSizeMax= uncompressed_size) - return KErrCorrupt; - if (TUint(iExportDirCount)>65535) - return KErrCorrupt; - if (iTextSize<0) - return KErrCorrupt; - if (iCodeSize= uncompressed_size) - return KErrCorrupt; - if (iDataOffset >= uncompressed_size) - return KErrCorrupt; - if (iImportOffset >= uncompressed_size) - return KErrCorrupt; - if (iCodeRelocOffset >= uncompressed_size) - return KErrCorrupt; - if (iDataRelocOffset >= uncompressed_size) - return KErrCorrupt; - if (TUint(iCodeSize+iDataSize) > uncompressed_size) - return KErrCorrupt; - - if (abi>KImageABI_EABI) - return KErrNotSupported; - if (impfmt>KImageImpFmt_PE2) - return KErrNotSupported; - if (iUid1 != (TUint32)KExecutableImageUidValue && iUid1 != (TUint32)KDynamicLibraryUidValue) - return KErrNotSupported; - TUint32 mv = ModuleVersion(); - if (mv >= 0x80000000u || (mv & 0x0000ffffu) > 0x8000u) - return KErrNotSupported; - - return KErrNone; - } -// --------------------------------------------------------------------------- - -TInt E32ImageReader::LoadData() - { - LOGSTRING("Launcher: E32ImageReader::LoadData"); - - TInt remainder; - iFile.Size(remainder); - - remainder -= iHeader->TotalSize(); - TUint32 compression = iHeader->CompressionType(); - if (compression != KMyFormatNotCompressed) - { - remainder = iHeader->UncompressedFileSize() - iHeader->iCodeOffset; - } - - remainder -= iHeader->iCodeSize; - - if (remainder > 0) - { - iRestOfFileData = (TUint8*)User::Alloc(remainder); - if (iRestOfFileData) - iRestOfFileSize=remainder; - else - return KErrNoMemory; - } - - iConversionOffset = iHeader->iCodeOffset + iHeader->iCodeSize; - - TInt r = LoadFile(compression); - if (r !=KErrNone) - return r; - - - TUint8* source=NULL; - if (iHeader->iImportOffset) - { - TUint bufferOffset=iHeader->iImportOffset-iConversionOffset; - - if(bufferOffset>iRestOfFileSize || bufferOffset+sizeof(E32ImportSection)>iRestOfFileSize) - return KErrCorrupt; - - source=iRestOfFileData+bufferOffset; - - iImportSection = new E32ImportSection; - - if (iImportSection) - Mem::Move((TText8*)iImportSection, source, sizeof(E32ImportSection)); - else - return KErrNoMemory; - } - - iCodeDelta = iCodeRunAddress-iHeader->iCodeBase; - iDataDelta = iDataRunAddress-iHeader->iDataBase; - - if (r==KErrNone) - r = ReadImportData(); - - return r; - } - -// --------------------------------------------------------------------------- - -TUint8* E32ImageReader::MemoryMove(TAny* aDestination, const TAny* aSource, TInt aNumberofBytes) - { - return Mem::Move(aDestination, aSource, aNumberofBytes); - } - -// --------------------------------------------------------------------------- - -GLDEF_C TInt svRelocateExports(TAny* aPtr) - { - E32ImageReader* pI=(E32ImageReader*)aPtr; - TUint32* destExport=(TUint32*)pI->iExportDirLoad; - TInt i=pI->iExportDirCount; - TUint32 codeBase=pI->iCodeRunAddress; - while (i-->0) - *destExport+++=codeBase; - return 0; - } - -// --------------------------------------------------------------------------- - -TInt E32ImageReader::LoadFile(TUint32 aCompression) - { - LOGSTRING("Launcher: E32ImageReader::LoadFile"); - - TInt r(KErrNone); - - if (aCompression == KMyFormatNotCompressed) - r=LoadFileNoCompress(); - - else if (aCompression == KMyUidCompressionDeflate) - { - TRAP(r, LoadFileInflateL()); - } - - else - r = KErrNotSupported; - - return r; - } - -// --------------------------------------------------------------------------- - -TInt E32ImageReader::LoadFileNoCompress() - { - LOGSTRING("Launcher: E32ImageReader::LoadFileNoCompress"); - - TInt r(KErrNone); - - if (iHeader->iCodeSize) - { - r = Read(iHeader->iCodeOffset, (TText8*)iCodeLoadAddress, iCodeSize); - } - - if (r != KErrNone) - { - return r; - } - - if (iRestOfFileSize) - { - r = Read(iConversionOffset, (TText8*)iRestOfFileData, iRestOfFileSize); - } - - return r; - } - -// --------------------------------------------------------------------------- - -void FileCleanup(TAny* aPtr) - { - TFileInput* f=(TFileInput*)aPtr; - f->Cancel(); - delete f; - } - -// --------------------------------------------------------------------------- - -void E32ImageReader::LoadFileInflateL() - { - LOGSTRING("Launcher: E32ImageReader::LoadFileInflateL"); - - TInt pos = iHeader->TotalSize(); - User::LeaveIfError(iFile.Seek(ESeekStart,pos)); - - TFileInput* file = new (ELeave) TFileInput(iFile); - CleanupStack::PushL(TCleanupItem(&FileCleanup,file)); - CInflater* inflater = CInflater::NewLC(*file); - - if (iHeader->iCodeSize) - { - TInt count = inflater->ReadL((TUint8*)iCodeLoadAddress, iCodeSize, &MemoryMove); - - if(count!=iCodeSize) - User::Leave(KErrCorrupt); - } - - if (iRestOfFileSize) - { - TUint32 count = inflater->ReadL(iRestOfFileData, iRestOfFileSize, &Mem::Move); - - if(count!=iRestOfFileSize) - User::Leave(KErrCorrupt); - } - - CleanupStack::PopAndDestroy(2,file); - } - -// --------------------------------------------------------------------------- - -TInt E32ImageReader::Read(TText8* aDest, TInt aSize) - { - TPtr8 p(aDest,aSize,aSize); - return iFile.Read(p,aSize); - } - -// --------------------------------------------------------------------------- - -TInt E32ImageReader::Read(TInt aPos, TText8* aDest, TInt aSize) - { - TPtr8 p(aDest,aSize,aSize); - if (aPos<0) - return KErrCorrupt; - return iFile.Read(aPos,p,aSize); - } - -// --------------------------------------------------------------------------- - -TInt E32ImageReader::ReadImportData() - { - LOGSTRING("Launcher: E32ImageReader::ReadImportData"); - - if (!iHeader->iImportOffset) - return KErrNone; - - TUint32 bufferOffset = iHeader->iImportOffset-iConversionOffset; - - if(bufferOffset>iRestOfFileSize || bufferOffset+iImportSection->iSize>iRestOfFileSize) - return KErrCorrupt; - - iImportData = (TUint32*)(iRestOfFileData+bufferOffset); - - E32ImportSection* s = (E32ImportSection*)iImportData; - E32ImportBlock* b = (E32ImportBlock*)(s + 1); - TUint impfmt = iHeader->ImportFormat(); - TInt i; - TInt n = 0; - - for (i=0; iiNumberOfImports > n) - n = b->iNumberOfImports; - b = (E32ImportBlock*)b->NextBlock(impfmt); - } - - iCurrentImportList = (TUint32*)User::Alloc(n * sizeof(TUint32)); - - if (!iCurrentImportList) - return KErrNoMemory; - - return KErrNone; - } - -// --------------------------------------------------------------------------- - -inline CInflater::CInflater(TBitInput& aInput) - :iBits(&aInput),iEncoding(0),iOut(0) - {} - -// --------------------------------------------------------------------------- - -void CInflater::ConstructL() - { - iEncoding=new(ELeave) TEncoding; - InitL(); - iLen=0; - iOut=new(ELeave) TUint8[KDeflateMaxDistance]; - iAvail=iLimit=iOut; - } - -// --------------------------------------------------------------------------- - -CInflater* CInflater::NewLC(TBitInput& aInput) - { - CInflater* self=new(ELeave) CInflater(aInput); - CleanupStack::PushL(self); - self->ConstructL(); - return self; - } - -// --------------------------------------------------------------------------- - -CInflater::~CInflater() - { - delete iEncoding; - delete [] iOut; - } - -// --------------------------------------------------------------------------- - -TInt CInflater::ReadL(TUint8* aBuffer,TInt aLength, TMemoryMoveFunction aMemMovefn) - { - TInt tfr=0; - for (;;) - { - TInt len=Min(aLength,iLimit-iAvail); - if (len && aBuffer) - { - aMemMovefn(aBuffer,iAvail,len); - aBuffer+=len; - } - aLength-=len; - iAvail+=len; - tfr+=len; - if (aLength==0) - return tfr; - len=InflateL(); - if (len==0) - return tfr; - iAvail=iOut; - iLimit=iAvail+len; - } - } - -// --------------------------------------------------------------------------- - -TInt CInflater::SkipL(TInt aLength) - { - return ReadL(0,aLength,Mem::Move); - } - -// --------------------------------------------------------------------------- - -void CInflater::InitL() - { - Huffman::InternalizeL(*iBits,iEncoding->iLitLen,KDeflationCodes); - - if (!Huffman::IsValid(iEncoding->iLitLen,TEncoding::ELitLens) || - !Huffman::IsValid(iEncoding->iDistance,TEncoding::EDistances)) - User::Leave(KErrCorrupt); - - Huffman::Decoding(iEncoding->iLitLen,TEncoding::ELitLens,iEncoding->iLitLen); - Huffman::Decoding(iEncoding->iDistance,TEncoding::EDistances,iEncoding->iDistance,KDeflateDistCodeBase); - } - -// --------------------------------------------------------------------------- - -TInt CInflater::InflateL() - { - TUint8* out=iOut; - TUint8* const end=out+KDeflateMaxDistance; - const TUint32* tree=iEncoding->iLitLen; - if (iLen<0) // EOF - return 0; - if (iLen>0) - goto useHistory; - - while (outHuffmanL(tree)-TEncoding::ELiterals; - if (val<0) - { - *out++=TUint8(val); - continue; - } - if (val==TEncoding::EEos-TEncoding::ELiterals) - { - iLen=-1; - break; - } - - TInt code=val&0xff; - if (code>=8) - { - TInt xtra=(code>>2)-1; - code-=xtra<<2; - code<<=xtra; - code|=iBits->ReadL(xtra); - } - if (valiDistance; - continue; - } - - iRptr=out-(code+1); - if (iRptr+KDeflateMaxDistanceiLitLen; - }; - - return out-iOut; - } - -// --------------------------------------------------------------------------- - -TFileInput::TFileInput(RFile& aFile) - :iFile(aFile),iReadBuf(iBuf1),iPtr(iBuf1,KBufSize) - { - aFile.Read(iPtr,iStat); - } - -// --------------------------------------------------------------------------- - -void TFileInput::Cancel() - { - if (iReadBuf) - User::WaitForRequest(iStat); - } - -// --------------------------------------------------------------------------- - -void TFileInput::UnderflowL() - { - TUint8* b=iReadBuf; - ASSERT(b!=NULL); - User::WaitForRequest(iStat); - iReadBuf=0; - User::LeaveIfError(iStat.Int()); - if(iPtr.Length()==0) - User::Leave(KErrCorrupt); - Set(b,iPtr.Length()*8); - - b = b==iBuf1 ? iBuf2 : iBuf1; - iPtr.Set(b,0,KBufSize); - iFile.Read(iPtr,iStat); - iReadBuf=b; - } - -// --------------------------------------------------------------------------- - -TFileNameInfo::TFileNameInfo() - { - memclr(this, sizeof(TFileNameInfo)); - } - -// --------------------------------------------------------------------------- - -TInt TFileNameInfo::Set(const TDesC8& aFileName, TUint aFlags) - { - iUid = 0; - iVersion = 0; - iPathPos = 0; - iName = aFileName.Ptr(); - iLen = aFileName.Length(); - iExtPos = aFileName.LocateReverse('.'); - if (iExtPos<0) - iExtPos = iLen; - TInt osq = aFileName.LocateReverse('['); - TInt csq = aFileName.LocateReverse(']'); - if (!(aFlags & EAllowUid) && (osq>=0 || csq>=0)) - { - return KErrBadName; - } - if (osq>=iExtPos || csq>=iExtPos) - { - return KErrBadName; - } - TInt p = iExtPos; - if ((aFlags & EAllowUid) && p>=10 && iName[p-1]==']' && iName[p-10]=='[') - { - TPtrC8 uidstr(iName + p - 9, 8); - TLex8 uidlex(uidstr); - TUint32 uid = 0; - TInt r = uidlex.Val(uid, EHex); - if (r==KErrNone && uidlex.Eos()) - iUid = uid, p -= 10; - } - iUidPos = p; - TInt ob = aFileName.LocateReverse('{'); - TInt cb = aFileName.LocateReverse('}'); - if (ob>=iUidPos || cb>=iUidPos) - { - return KErrBadName; - } - if (ob>=0 && cb>=0 && p-1==cb) - { - TPtrC8 p8(iName, p); - TInt d = p8.LocateReverse('.'); - TPtrC8 verstr(iName+ob+1, p-ob-2); - TLex8 verlex(verstr); - if (ob==p-10 && dob && p-1>d && (aFlags & EAllowDecimalVersion)) - { - TUint32 maj = 0; - TUint32 min = 0; - TInt r = verlex.Val(maj, EDecimal); - TUint c = (TUint)verlex.Get(); - TInt r2 = verlex.Val(min, EDecimal); - if (r==KErrNone && c=='.' && r2==KErrNone && verlex.Eos() && maj<32768 && min<32768) - iVersion = (maj << 16) | min, p = ob; - } - } - iVerPos = p; - if (iLen>=2 && iName[1]==':') - { - TUint c = iName[0]; - if (c!='?' || !(aFlags & EAllowPlaceholder)) - { - c |= 0x20; - if (c<'a' || c>'z') - { - return KErrBadName; - } - } - iPathPos = 2; - } - TPtrC8 pathp(iName+iPathPos, iVerPos-iPathPos); - if (pathp.Locate('[')>=0 || pathp.Locate(']')>=0 || pathp.Locate('{')>=0 || pathp.Locate('}')>=0 || pathp.Locate(':')>=0) - { - return KErrBadName; - } - iBasePos = pathp.LocateReverse('\\') + 1 + iPathPos; - - return KErrNone; - } - -// --------------------------------------------------------------------------- - -void TFileNameInfo::GetName(TDes8& aName, TUint aFlags) const - { - if (aFlags & EIncludeDrive) - aName.Append(Drive()); - if (aFlags & EIncludePath) - { - if (PathLen() && iName[iPathPos]!='\\') - aName.Append('\\'); - aName.Append(Path()); - } - if (aFlags & EIncludeBase) - aName.Append(Base()); - if ((aFlags & EForceVer) || ((aFlags & EIncludeVer) && VerLen()) ) - { - aName.Append('{'); - aName.AppendNumFixedWidth(iVersion, EHex, 8); - aName.Append('}'); - } - if ((aFlags & EForceUid) || ((aFlags & EIncludeUid) && UidLen()) ) - { - aName.Append('['); - aName.AppendNumFixedWidth(iUid, EHex, 8); - aName.Append(']'); - } - if (aFlags & EIncludeExt) - aName.Append(Ext()); - } - -// --------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 launcher/engine/src/launcherdllelement.cpp --- a/launcher/engine/src/launcherdllelement.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,191 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include "launcherdllelement.h" -#include "launchertraces.h" - -// --------------------------------------------------------------------------- - -CLauncherDLLElement::~CLauncherDLLElement() - { - LOGSTRING("Launcher: CLauncherDLLElement::~CLauncherDLLElement"); - } - -// --------------------------------------------------------------------------- - -CLauncherDLLElement::CLauncherDLLElement() - { - } - -// --------------------------------------------------------------------------- - -CLauncherDLLElement* CLauncherDLLElement::NewL() - { - LOGSTRING("Launcher: CLauncherDLLElement::NewL"); - CLauncherDLLElement* self = CLauncherDLLElement::NewLC(); - CleanupStack::Pop(); - return self; - } - -// --------------------------------------------------------------------------- - -CLauncherDLLElement* CLauncherDLLElement::NewLC() - { - LOGSTRING("Launcher: CLauncherDLLElement::NewLC"); - CLauncherDLLElement* self = new (ELeave) CLauncherDLLElement; - CleanupStack::PushL(self); - self->ConstructL(); - return self; - } - -// --------------------------------------------------------------------------- - -void CLauncherDLLElement::ConstructL() - { - - } - -// --------------------------------------------------------------------------- - -TBool CLauncherDLLElement::CompareL(const CLauncherDLLElement& aReferenceElement, RArray& aDifferenceList) const - { - LOGSTRING2("Launcher: CLauncherDLLElement::CompareL - DLLName: %S", &iName); - if( iName != aReferenceElement.Name()) - { - LOGSTRING("Launcher: CLauncherDLLElement::CompareL: ERROR - DLL names don't match."); - User::Leave(KErrArgument); - } - - TBool diff = EFalse; - - if( iUID1 != aReferenceElement.UID1()) - { - diff = ETrue; - aDifferenceList.AppendL(this->EDifference_UID1); - LOGSTRING3("Launcher: CLauncherDLLElement::CompareL - UID1s differs: %x vs. %x", iUID1, aReferenceElement.UID1()); - } - if( iUID2!= aReferenceElement.UID2()) - { - diff = ETrue; - aDifferenceList.AppendL(this->EDifference_UID2); - LOGSTRING3("Launcher: CLauncherDLLElement::CompareL - UID2s differs: %x vs. %x", iUID2, aReferenceElement.UID2()); - } - if( iUID3 != aReferenceElement.UID3()) - { - diff = ETrue; - aDifferenceList.AppendL(this->EDifference_UID3); - LOGSTRING3("Launcher: CLauncherDLLElement::CompareL - UID3s differs: %x vs. %x", iUID3, aReferenceElement.UID3()); - } - if( iSID != aReferenceElement.SID()) - { - diff = ETrue; - aDifferenceList.AppendL(this->EDifference_SID); - LOGSTRING3("Launcher: CLauncherDLLElement::CompareL - SIDs differs: %x vs. %x", iSID, aReferenceElement.SID()); - } - if( iCapability != aReferenceElement.Capability()) - { - diff = ETrue; - aDifferenceList.AppendL(this->EDifference_Capability); - LOGSTRING3("Launcher: CLauncherDLLElement::CompareL - Capabilities differs: %x vs. %x", iCapability, aReferenceElement.Capability()); - } - - return diff; - } - -// --------------------------------------------------------------------------- - -TFileName CLauncherDLLElement::Name() const - { - return iName; - } - -// --------------------------------------------------------------------------- - -void CLauncherDLLElement::SetNameL(const TFileName& aName) - { - iName.Copy(aName); - } - -// --------------------------------------------------------------------------- - -TUid CLauncherDLLElement::UID1() const - { - return iUID1; - } - -// --------------------------------------------------------------------------- - -void CLauncherDLLElement::SetUID1L(TUid aUID1) - { - iUID1.iUid = aUID1.iUid; - } - -// --------------------------------------------------------------------------- - -TUid CLauncherDLLElement::UID2() const - { - return iUID2; - } - -// --------------------------------------------------------------------------- - -void CLauncherDLLElement::SetUID2L(TUid aUID2) - { - iUID2 = aUID2; - } - -// --------------------------------------------------------------------------- - -TUid CLauncherDLLElement::UID3() const - { - return iUID3; - } - -// --------------------------------------------------------------------------- - -void CLauncherDLLElement::SetUID3L(TUid aUID3) - { - iUID3 = aUID3; - } - -// --------------------------------------------------------------------------- - -TUid CLauncherDLLElement::SID() const - { - return iSID; - } - -// --------------------------------------------------------------------------- - -void CLauncherDLLElement::SetSIDL(TUid aSID) - { - iSID = aSID; - } - -// --------------------------------------------------------------------------- - -TUint32 CLauncherDLLElement::Capability() const - { - return iCapability; - } - -// --------------------------------------------------------------------------- - -void CLauncherDLLElement::SetCapabilityL(TUint32 aCapability) - { - iCapability = aCapability; - } diff -r 819e59dfc032 -r 2d9cac8919d3 launcher/engine/src/launcherdllparser.cpp --- a/launcher/engine/src/launcherdllparser.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,133 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include "launcherdllparser.h" -#include "launchertraces.h" - -// --------------------------------------------------------------------------- - -CLauncherDLLParser::~CLauncherDLLParser() - { - LOGSTRING("Launcher: CLauncherDLLParser::~CLauncherDLLParser"); - } - -// --------------------------------------------------------------------------- - -CLauncherDLLParser::CLauncherDLLParser() - { - LOGSTRING("Launcher: CLauncherDLLParser::CLauncherDLLParser"); - } - -// --------------------------------------------------------------------------- - -CLauncherDLLParser* CLauncherDLLParser::NewL() - { - LOGSTRING("Launcher: CLauncherDLLParser::NewL"); - CLauncherDLLParser* self = CLauncherDLLParser::NewLC(); - CleanupStack::Pop(); - return self; - } - -// --------------------------------------------------------------------------- - -CLauncherDLLParser* CLauncherDLLParser::NewLC() - { - LOGSTRING("Launcher: CLauncherDLLParser::NewLC"); - CLauncherDLLParser* self = new (ELeave) CLauncherDLLParser; - CleanupStack::PushL(self); - self->ConstructL(); - return self; - } - -// --------------------------------------------------------------------------- - -void CLauncherDLLParser::ConstructL() - { - - } - -// --------------------------------------------------------------------------- - -void CLauncherDLLParser::ParseL( RFs& aFileSession, RFile& aFile, CLauncherDLLElement& aElement ) - { - TFileName dllName; - TFileName fullName; - TUid tmpUID; - TInt offset = 0; - - aFile.Name(dllName); - aFile.FullName(fullName); - aElement.SetNameL(dllName); - - TBool isFileInRom = aFileSession.IsFileInRom(fullName) != 0; - - /** - * Read UID1 - */ - offset = UID1_OFFSET; - aFile.Seek(ESeekStart, offset); // Set file position - tmpUID.iUid = ReadUint32L(aFile); - aElement.SetUID1L(tmpUID); - - /** - * Read UID2 - */ - offset = UID2_OFFSET; - aFile.Seek(ESeekStart, offset); // Set file position - tmpUID.iUid = ReadUint32L(aFile); - aElement.SetUID2L(tmpUID); - - /** - * Read UID3 - */ - offset = UID3_OFFSET; - aFile.Seek(ESeekStart, offset); // Set file position - tmpUID.iUid = ReadUint32L(aFile); - aElement.SetUID3L(tmpUID); - - /** - * Read SID - */ - if( isFileInRom ) - offset = SID_OFFSET_ROM; - else - offset = SID_OFFSET_ROFS; - aFile.Seek(ESeekStart, offset); // Set file position - tmpUID.iUid = ReadUint32L(aFile); - aElement.SetSIDL(tmpUID); - - /** - * Read Capability - */ - if( isFileInRom ) - offset = CAPABILITY_OFFSET_ROM; - else - offset = CAPABILITY_OFFSET_ROFS; - aFile.Seek(ESeekStart, offset); // Set file position - TUint32 tmpVal = ReadUint32L(aFile); - aElement.SetCapabilityL(tmpVal); - } - -// --------------------------------------------------------------------------- - -TUint32 CLauncherDLLParser::ReadUint32L( RFile& aFile ) - { - TBuf8<4> tempBuf; - User::LeaveIfError(aFile.Read(tempBuf, 4)); - const TUint8* ptr = tempBuf.Ptr(); - return TUint32(ptr[0] | (ptr[1]<<8) | (ptr[2]<<16) | (ptr[3]<<24)); - } diff -r 819e59dfc032 -r 2d9cac8919d3 launcher/engine/src/launcherengine.cpp --- a/launcher/engine/src/launcherengine.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1665 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include -#include -#include -#include -#include - -#include "launchertraces.h" -#include "e32image.h" -#include "launcherxmlparser.h" -#include "launcherdllparser.h" -#include "launcherengine.h" - -_LIT(KLogFileName, "LauncherLog.txt"); -_LIT(KBCLogFileName, "LauncherBCLog.txt"); -_LIT(KSystemDllsFileName, "SystemDlls.txt"); -_LIT(KRequiredDllsFileName, "RequiredDlls.xml"); -_LIT(KDotXML,".xml"); -_LIT(KDotLauncherXML,".launcherxml"); - -_LIT(KFileSeparator, "\t"); -_LIT(KFileNewLine, "\r\n"); - -_LIT(KNewLine, "\n"); - -const TInt KMaxAppsArraySize=250; -const TInt KMaxDllArraySize=5000; -const TInt KLauncherLogBufferSize = 4096; - -// After this many issues, issues are buffered and printed -// in the end of analysis -const TInt KBigBufferUsageThreshold=10; - -// Buffer allocation unit -const TInt KBigBufferAllocBytes=1024; - -// --------------------------------------------------------------------------- - -CLauncherEngine* CLauncherEngine::NewL(MLauncherUI *aLauncherUI) - { - CLauncherEngine* self = new(ELeave) CLauncherEngine; - CleanupStack::PushL(self); - self->ConstructL(aLauncherUI); - CleanupStack::Pop(); - return self; - } - -// --------------------------------------------------------------------------- - -CLauncherEngine::CLauncherEngine() : CActive(EActivePriorityIpcEventsHigh) - { - } - -// --------------------------------------------------------------------------- - -template -void AppendLogBufferL(const TDesC& aText, T*& aBuf, TInt aIncreaseStep = KLauncherLogBufferSize) - { - if( aBuf == 0 ) - { - aBuf = T::NewL(aIncreaseStep); - } - - TInt currentMaxLength = aBuf->Des().MaxLength(); - if( aBuf->Des().Length() + aText.Length() > currentMaxLength ) - { - TInt increaseSize = Max(aText.Length(), aIncreaseStep); - aBuf = aBuf->ReAllocL(aBuf->Des().MaxLength() + increaseSize ); - } - aBuf->Des().Append(aText); - } - -// --------------------------------------------------------------------------- - -void CLauncherEngine::ConstructL(MLauncherUI *aLauncherUI) - { - LOGSTRING("Launcher: CLauncherEngine::ConstructL"); - - User::LeaveIfNull( aLauncherUI ); - - iLauncherUI = aLauncherUI; - - - iEnv = CEikonEnv::Static(); - iLaunchingIsActive = EFalse; - iDLLAnalysisIsActive = EFalse; - iSkipHiddenAndEmbedOnly = ETrue; - - User::LeaveIfError(iTimer.CreateLocal()); - - User::LeaveIfError(iLs.Connect()); - User::LeaveIfError(iWs.Connect()); - - iAppThreadChecker = CAppThreadChecker::NewL(this); - iAppRunningChecker = CAppRunningChecker::NewL(this); - - iAllAppsArray = new(ELeave) CDesCArrayFlat(KMaxAppsArraySize); - iAppsArray = new(ELeave) CDesCArrayFlat(KMaxAppsArraySize); - iSystemDllArray = new(ELeave) CDesCArrayFlat(KMaxDllArraySize); - - iLogWriteBuf = HBufC8::NewL(KLauncherLogBufferSize); - - iLogFilePath = PathInfo::PhoneMemoryRootPath(); - iLogFilePath.Append( KLogFileName ); - - iBCLogFilePath = PathInfo::PhoneMemoryRootPath(); - iBCLogFilePath.Append( KBCLogFileName ); - - iSystemDllsFilePath = PathInfo::PhoneMemoryRootPath(); - iSystemDllsFilePath.Append( KSystemDllsFileName ); - - iRequiredDllsFilePath = PathInfo::PhoneMemoryRootPath(); - iRequiredDllsFilePath.Append( KRequiredDllsFileName ); - - iDLLParser = CLauncherDLLParser::NewL(); - - CActiveScheduler::Add(this); - } - -// --------------------------------------------------------------------------- - -CLauncherEngine::~CLauncherEngine() - { - LOGSTRING("Launcher: CLauncherEngine::~CLauncherEngine"); - - Cancel(); - - // close the log - iLogFile.Close(); - iBCLogFile.Close(); - if (iLogWriteBuf) - delete iLogWriteBuf; - - if (iAppRunningChecker) - delete iAppRunningChecker; - - if (iAppThreadChecker) - delete iAppThreadChecker; - - if (iSystemDllArray) - { - iSystemDllArray->Reset(); - delete iSystemDllArray; - } - - if (iAppsArray) - { - iAppsArray->Reset(); - delete iAppsArray; - } - - - if (iAllAppsArray) - { - iAllAppsArray->Reset(); - delete iAllAppsArray; - } - - delete iXMLParser; - // delete iDLLParser; - //delete iDLLElement; - delete iBCIssuesBigBuffer; - - iWs.Close(); - iLs.Close(); - iTimer.Close(); - } - -// --------------------------------------------------------------------------- - -void CLauncherEngine::DoCancel() - { - LOGSTRING("Launcher: CLauncherEngine::DoCancel"); - - if( iXMLParser ) - { - iXMLParser->Cancel(); - } - iTimer.Cancel(); - - } - -// --------------------------------------------------------------------------- - -void CLauncherEngine::RunL() - { - - LOGSTRING("Launcher: CLauncherEngine::RunL"); - TInt err = iStatus.Int(); - User::LeaveIfError(err); - - // write full app path to the log file - WriteInitialStuffToTheLogL(iAppsArray->MdcaPoint(iAppLaunchCounter), iLogFile); - - // get the uid of the current app - iCurrentAppUid = KNullUid; - TApaAppInfo appInfo; - iLs.GetAllApps(); - while (iLs.GetNextApp(appInfo) == KErrNone) - { - if (appInfo.iFullName.CompareF( iAppsArray->MdcaPoint(iAppLaunchCounter) ) == 0) - { - iCurrentAppUid = appInfo.iUid; - break; - } - } - - if (iCurrentAppUid == KNullUid) - { - iLogWriteBuf->Des().Append(_L("[WARN: App has no UID] ")); - } - - // parse the filename - TParse nameParser; - nameParser.SetNoWild(iAppsArray->MdcaPoint(iAppLaunchCounter), NULL, NULL); - iCurrentAppNameAndExt.Copy(nameParser.Drive()); - iCurrentAppNameAndExt.Append(nameParser.NameAndExt()); - - // do not try to launch these apps - if (iAppsArray->MdcaPoint(iAppLaunchCounter).FindF(_L("\\Launcher.")) != KErrNotFound - || iAppsArray->MdcaPoint(iAppLaunchCounter).FindF(_L("\\Phone.")) != KErrNotFound - || iAppsArray->MdcaPoint(iAppLaunchCounter).FindF(_L("\\Startup.")) != KErrNotFound - || iAppsArray->MdcaPoint(iAppLaunchCounter).FindF(_L("\\SplashScreen.")) != KErrNotFound - || iAppsArray->MdcaPoint(iAppLaunchCounter).FindF(_L("\\eshell.")) != KErrNotFound) - { - - iLauncherUI->PrintText(iCurrentAppNameAndExt); - iLauncherUI->PrintText(_L(": SKIPPED automatically\n")); - - iLogWriteBuf->Des().Append(_L("[SKIPPED automatically] ")); - iLogWriteBuf->Des().Append(KFileNewLine); - iLogFile.Write(iLogWriteBuf->Des()); - - iSkippedCases++; - CheckForMoreAppsL(); - } - - else - { - - // dependency check not needed if the app is in the ROM/ROFS, because they'll be checked automatically - // when the rom image is built - - if (iCurrentAppNameAndExt[0] != 'Z' && iCurrentAppNameAndExt[0] != 'z') - { - - if (iCurrentAppNameAndExt[2] == '[') // this is quite likely a Java application, no dependency test needed - { - iLogWriteBuf->Des().Append(_L("[Dependency check not done] ")); - } - else - { // otherwise check depencies - - #ifdef __WINS__ - - // emulator not supported - - #else - - // ELF binaries - - CDesCArray* missingDllArray = NULL; - - TRAPD(err, missingDllArray = DependencyCheckForE32ImageL()); - - // some error happened while processing the E32 image - if (err != KErrNone) - { - - iLauncherUI->PrintText(iCurrentAppNameAndExt); - iLauncherUI->PrintText(_L(": unable to read import table!\n")); - - iLogWriteBuf->Des().Append(_L("[Unable to read import table!] ")); - } - - // print missing dependencies - else if (err==KErrNone && missingDllArray) - { - if (missingDllArray->MdcaCount() > 0) - { - iLauncherUI->PrintText(iCurrentAppNameAndExt); - iLauncherUI->PrintText(_L(": missing dependencies: ")); - - iLogWriteBuf->Des().Append(_L("[Missing dependencies: ")); - - for (TInt k=0; kMdcaCount(); k++) - { - iLauncherUI->PrintText(missingDllArray->MdcaPoint(k)); - iLauncherUI->PrintText(_L(" ")); - - iLogWriteBuf->Des().Append(missingDllArray->MdcaPoint(k)); - iLogWriteBuf->Des().Append(_L(" ")); - } - - iLauncherUI->PrintText(_L("\n")); - - iLogWriteBuf->Des().Append(_L("] ")); - } - } - - if (missingDllArray) - delete missingDllArray; - - #endif - - } // if '[' - } // if 'Z' - - - - // check if the app is already running - TApaTaskList taskList(iWs); - TApaTask thisTask = taskList.FindApp(iCurrentAppUid); - if (thisTask.Exists()) - { - iLogWriteBuf->Des().Append(_L(" [OK: App already running]")); - iLogWriteBuf->Des().Append(KFileNewLine); - iLogFile.Write(iLogWriteBuf->Des()); - - iOkCases++; - CheckForMoreAppsL(); - } - - else - { - // check the program's capabilities - TApaAppCapabilityBuf buf; - iLs.GetAppCapability(buf, iCurrentAppUid); - TApaAppCapability cap = buf(); - - // if it's embeddable only, don't launch if setting is enabled - if (cap.iEmbeddability == TApaAppCapability::EEmbeddableOnly && SkipHiddenAndEmbedOnly()) - { - - iLauncherUI->PrintText(iCurrentAppNameAndExt); - iLauncherUI->PrintText(_L(": SKIPPED: embeddable only\n")); - - iLogWriteBuf->Des().Append(_L("[SKIPPED: embeddable only] ")); - iLogWriteBuf->Des().Append(KFileNewLine); - iLogFile.Write(iLogWriteBuf->Des()); - - iSkippedCases++; - CheckForMoreAppsL(); - } - - // if it's hidden, don't launch if setting is enabled - else if (cap.iAppIsHidden && SkipHiddenAndEmbedOnly()) - { - - iLauncherUI->PrintText(iCurrentAppNameAndExt); - iLauncherUI->PrintText(_L(": SKIPPED: hidden\n")); - - iLogWriteBuf->Des().Append(_L("[SKIPPED: hidden] ")); - iLogWriteBuf->Des().Append(KFileNewLine); - iLogFile.Write(iLogWriteBuf->Des()); - - iSkippedCases++; - CheckForMoreAppsL(); - } - - // otherwise do the normal launch test - else - { - LaunchApplicationL(); - } - - } //if (thisTask.Exists()) - - } //if (iAppsArray->MdcaPoint(iAppLaunchCounter).FindF - - } - -// --------------------------------------------------------------------------- - -CDesCArray* CLauncherEngine::ListOfAllAppsL() - { - LOGSTRING("Launcher: CLauncherEngine::ListOfAllAppsL"); - - // find all DLLs from the system - iSystemDllArray->Reset(); - TRAP_IGNORE( FindFiles(_L("*.dll"), _L("\\sys\\bin\\")) ); - - // write the list of DLLs to a file - RFile dllFile; - if (dllFile.Replace(iEnv->FsSession(), iSystemDllsFilePath, EFileWrite) == KErrNone) - { - TBuf8 dllName; - - for (TInt i=0; iMdcaCount(); i++) - { - dllName.Copy( iSystemDllArray->MdcaPoint(i) ); - dllName.Append( KFileNewLine ); - - dllFile.Write( dllName ); - } - - dllFile.Close(); - } - - // reset the apps list - iAllAppsArray->Reset(); - - // search all apps - TApaAppInfo appInfo; - iLs.GetAllApps(); - - while (iLs.GetNextApp(appInfo) == KErrNone) - { - iAllAppsArray->AppendL(appInfo.iFullName); - } - - - // remove launcher.app / launcher.exe from the list - for (TInt i=0; iMdcaCount(); i++) - { - if (iAllAppsArray->MdcaPoint(i).FindF(_L("\\Launcher.")) != KErrNotFound) - { - iAllAppsArray->Delete(i); - iAllAppsArray->Compress(); - break; - } - } - - // sort the elements - iAllAppsArray->Sort(); - - return iAllAppsArray; - } - -// --------------------------------------------------------------------------- - -TInt CLauncherEngine::FindFiles(const TDesC& aFileName, const TDesC& aPath) - { - TFindFile fileFinder(iEnv->FsSession()); - CDir* fileList; - TInt err = fileFinder.FindWildByDir(aFileName, aPath, fileList); - - while (err == KErrNone) - { - for (TInt i=0; iCount(); i++) - { - TParse fullentry; - fullentry.Set((*fileList)[i].iName, &fileFinder.File(), NULL); - - TRAP(err, iSystemDllArray->AppendL(fullentry.NameAndExt())); - } - - delete fileList; - err = fileFinder.FindWild(fileList); - } - return err; - } - -// --------------------------------------------------------------------------- - - -void CLauncherEngine::StartAppLaunchingL(const CArrayFix* aSelectedApps, TBool aAutoClose) - { - LOGSTRING("Launcher: CLauncherEngine::StartAppLaunchingL"); - - // check that we have something to launch - if (aSelectedApps->Count() <= 0) - { - _LIT(message, "Nothing selected"); - iLauncherUI->ShowErrorMessage(message); - } - else - { - // update the list of applications to be tested - iAppsArray->Reset(); - - TInt ref(0); - TKeyArrayFix key(0, ECmpTUint16); - TInt index(0); - - for (TInt i=0; iMdcaCount(); i++) - { - ref = i; - - // if the application is selected, append it to the apps array - if (aSelectedApps->Find(ref, key, index) == 0) - { - iAppsArray->AppendL(iAllAppsArray->MdcaPoint(i)); - } - } - - - // to make sure that our algorithm works correctly - if (iAppsArray->MdcaCount() != aSelectedApps->Count()) - { - _LIT(message, "Something went wrong..."); - iLauncherUI->ShowErrorMessage(message); - } - - - // init - Cancel(); - iLaunchingIsActive = ETrue; - iAutoClose = aAutoClose; - iAppLaunchCounter = 0; - iFailedCases = 0; - iOkCases = 0; - iSkippedCases = 0; - iTotalNumberOfCases = iAppsArray->MdcaCount(); - iCurrentAppUid = KNullUid; - - // open the log file for writing - if (iLogFile.Open(iEnv->FsSession(), iLogFilePath, EFileWrite) != KErrNone) - { - iEnv->FsSession().MkDirAll(iLogFilePath); - iLogFile.Replace(iEnv->FsSession(), iLogFilePath, EFileWrite); - } - else - { - // file opens correctly, seek to the end - TInt fileSize=0; - iLogFile.Size(fileSize); - iLogFile.Seek(ESeekCurrent, fileSize); - } - - // change focus to output view!! - iLauncherUI->ChangeFocusToOutputView(); - - //text to log - iLauncherUI->PrintText(_L("New test started.\n")); - - // start the first launch! - IssueLaunch(); - - } - } - -// --------------------------------------------------------------------------- - -void CLauncherEngine::IssueLaunch() - { - LOGSTRING("Launcher: CLauncherEngine::IssueLaunch"); - - __ASSERT_ALWAYS(!IsActive(), User::Panic(_L("Timing error?"), 100)); - - // this should keep the backlight on - User::ResetInactivityTime(); - - iDLLAnalysisIsActive = EFalse; - // some delay - iTimer.After(iStatus, 1000000); - SetActive(); - } - -// --------------------------------------------------------------------------- - -// --------------------------------------------------------------------------- - -void CLauncherEngine::WriteInitialStuffToTheLogL(const TDesC& aOwnData, RFile& aFile) - { - LOGSTRING("Launcher: CLauncherEngine::WriteInitialStuffToTheLog"); - - TTime time; - time.HomeTime(); - TBuf<32> currentTime; - TBuf<32> currentDate; - - // current date - _LIT(KCurrentDate,"%D%M%Y%/0%1%/1%2%/2%3%/3"); - time.FormatL(currentDate, KCurrentDate); - iLogWriteBuf->Des().Copy(currentDate); - AppendLogBufferL(KFileSeparator(), iLogWriteBuf); - - // current time - _LIT(KCurrentTime,"%-B%:0%J%:1%T%:2%S%:3%+B"); - time.FormatL(currentTime, KCurrentTime); - AppendLogBufferL(currentTime, iLogWriteBuf); - AppendLogBufferL(KFileSeparator(), iLogWriteBuf); - - // available RAM memory - TMemoryInfoV1Buf memory; - UserHal::MemoryInfo(memory); - iLogWriteBuf->Des().AppendNum(memory().iFreeRamInBytes); - AppendLogBufferL(KFileSeparator(), iLogWriteBuf); - - // own data, eg. application name - AppendLogBufferL(aOwnData, iLogWriteBuf); - AppendLogBufferL(KFileSeparator(), iLogWriteBuf); - AppendLogBufferL(KFileNewLine(), iLogWriteBuf); - - // write the buffer to the file - aFile.Write(iLogWriteBuf->Des()); - - // clear the buffer - iLogWriteBuf->Des().Copy(_L("")); - } - -// --------------------------------------------------------------------------- - - -void CLauncherEngine::CheckForMoreAppsL() - { - LOGSTRING("Launcher: CLauncherEngine::CheckForMoreAppsL"); - - // make sure the launcher app is in the foreground - TApaTaskList taskList(iWs); - TUid launcherAppUid; - launcherAppUid.iUid = 0x101FB74F; - TApaTask launcherTask = taskList.FindApp(launcherAppUid); - launcherTask.BringToForeground(); - - - // check if we have more test to be executed - if ( iAppLaunchCounter >= iTotalNumberOfCases-1 ) - { - - // all done, show stats - TBuf<200> message; - message.Append( _L("Done: ") ); - message.AppendNum( iOkCases ); - message.Append( _L(" ok, ") ); - message.AppendNum( iFailedCases ); - message.Append( _L(" failed, ") ); - message.AppendNum( iSkippedCases ); - message.Append( _L(" skipped.") ); - - // print the message to the output screen - iLauncherUI->PrintText(message); - iLauncherUI->PrintText(_L("\n\n")); - - //write same stuff to the log - WriteInitialStuffToTheLogL(message, iLogFile); - iLogWriteBuf->Des().Copy(KFileNewLine); - iLogWriteBuf->Des().Append(KFileNewLine); - iLogFile.Write(iLogWriteBuf->Des()); - - // close the log - iLogFile.Close(); - - iLaunchingIsActive = EFalse; - - // all apps launched - _LIT(KAllDoneMessage, "All apps launched"); - iLauncherUI->ShowInfoMessage(KAllDoneMessage); - } - else - { - // more apps to be launched, maintain requests - iAppLaunchCounter++; - IssueLaunch(); - } - - } - -// --------------------------------------------------------------------------- - -void CLauncherEngine::LaunchApplicationL() - { - LOGSTRING("Launcher: CLauncherEngine::LaunchApplication"); - LOGSTRING3("Launcher: Trying to launch %S, UID: %d", &iCurrentAppNameAndExt, iCurrentAppUid.iUid); - - TRAPD(err, DoLaunchApplicationL()); - - if (err!=KErrNone) - { - iLogWriteBuf->Des().Append(_L("[FAIL: Cannot launch the app] ")); - - iLauncherUI->PrintText(iCurrentAppNameAndExt); - iLauncherUI->PrintText(_L(": cannot launch\n")); - - // write the buffer to the log - iLogWriteBuf->Des().Append(KFileNewLine); - iLogFile.Write(iLogWriteBuf->Des()); - - // this application isn't even launchable, go to next one - iFailedCases++; - CheckForMoreAppsL(); - } - - } -// --------------------------------------------------------------------------- - - -void CLauncherEngine::DoLaunchApplicationL() - { - LOGSTRING("Launcher: CLauncherEngine::DoLaunchApplicationL"); - - // create a new handle - RThread newThreadHandle; - iCurrentAppThread = newThreadHandle; - - - // Find the task with uid3 - TApaTaskList tasklist(iWs); - TApaTask task=tasklist.FindApp(iCurrentAppUid); - - if (task.Exists()) - // Task exists, bring it to foreground - { - task.BringToForeground(); - } - else - // Task doesn't exist, launch a new instance of an application - { - TApaAppInfo appInfo; - User::LeaveIfError(iLs.GetAppInfo(appInfo, iCurrentAppUid)); - TApaAppCapabilityBuf capBuf; - User::LeaveIfError(iLs.GetAppCapability(capBuf, iCurrentAppUid)); - TApaAppCapability& caps = capBuf(); - - CApaCommandLine* cmdLine=CApaCommandLine::NewLC(); - cmdLine->SetExecutableNameL(appInfo.iFullName); - - if ( caps.iLaunchInBackground ) - // Apps capability defines that the app is launched in background - { - cmdLine->SetCommandL(EApaCommandBackground); - } - else - { - cmdLine->SetCommandL(EApaCommandRun); - } - - // start the app - User::LeaveIfError(iLs.StartApp(*cmdLine, iCurrentAppThreadId)); - - // activate thread checker active object - iAppThreadChecker->ActivateChecking(); - - // now open a handle to the thread and register death notifier - TInt err = iCurrentAppThread.Open(iCurrentAppThreadId); - if (err == KErrNone) - iCurrentAppThread.Logon(iAppThreadChecker->iStatus); - else - { - iCurrentAppThread.Close(); - TRequestStatus* status = &iAppThreadChecker->iStatus; - User::RequestComplete(status, KErrNone); - iAppThreadChecker->Cancel(); - User::Leave(err); - } - - CleanupStack::PopAndDestroy(); // cmdLine - } - - // the application is now running, start a check to see if it's still alive - iAppRunningChecker->StartTesting(); - - } - -// --------------------------------------------------------------------------- - -void CLauncherEngine::CheckIfAppIsRunningL() - { - LOGSTRING("Launcher: CLauncherEngine::CheckIfAppIsRunningL"); - - // cancel the death notifier since it isn't needed anymore - if( iCurrentAppThread.Handle() != 0 ) - { - iCurrentAppThread.LogonCancel(iAppThreadChecker->iStatus); - } - - // cancel checkers - iAppThreadChecker->Cancel(); - iAppRunningChecker->Cancel(); - - - - // check from the window server if the app is running - TApaTaskList taskList(iWs); - TApaTask thisTask = taskList.FindApp(iCurrentAppUid); - - if( !thisTask.Exists() ) // application not running -> FAIL - { - // check from the thread why it quit - CheckWhyThreadDiedL(); - - // --> CheckForMoreApps() and all the other stuff called from CheckWhyThreadDied() ! - - } - else - { - // app is running! - iOkCases++; - - // close handle to the thread - iCurrentAppThread.Close(); - - - iLogWriteBuf->Des().Append(_L(" [OK]")); - iLogWriteBuf->Des().Append(KFileNewLine); - iLogFile.Write(iLogWriteBuf->Des()); - - - // close the running application if needed - if (iAutoClose) - { - // since the application is still open, let's close it - thisTask.EndTask(); - //User::After(1000); - //thisTask.SendSystemEvent(EApaSystemEventShutdown); - //thisTask.KillTask(); - //User::After(1000); - } - - // this app is done now, move to the next one! - CheckForMoreAppsL(); - - } - } - -// --------------------------------------------------------------------------- - -void CLauncherEngine::CheckWhyThreadDiedL() - { - LOGSTRING("Launcher: CLauncherEngine::CheckWhyThreadDiedL"); - - // cancel the death notifier since it isn't needed anymore - if( iCurrentAppThread.Handle() != 0 ) - { - iCurrentAppThread.LogonCancel(iAppThreadChecker->iStatus); - } - - // make sure all checkers are cancelled - iAppRunningChecker->Cancel(); - iAppThreadChecker->Cancel(); - - TBuf<256> outputText; - outputText.Append(_L("App.Closed. ")); - - - if (iCurrentAppThread.ExitType() == EExitKill) - { - outputText.Append(_L("\"EExitKill\"")); - } - else if (iCurrentAppThread.ExitType() == EExitTerminate) - { - outputText.Append(_L("\"EExitTerminate\"")); - } - else if (iCurrentAppThread.ExitType() == EExitPanic) - { - outputText.Append(_L("\"EExitPanic\"")); - } - else if (iCurrentAppThread.ExitType() == EExitPending) - { - outputText.Append(_L("\"EExitPending\"")); - } - else // unknown reason - { - outputText.Append(_L("\"Exit_Unknown_Reason\"")); - } - - outputText.Append(_L(" code:")); - TInt exitReason = iCurrentAppThread.ExitReason(); - outputText.AppendNum(exitReason); - outputText.Append(_L(" \"")); - - TPtrC exitCategory = iCurrentAppThread.ExitCategory(); - outputText.Append(exitCategory); - - outputText.Append(_L("\"")); - - - // print to screen - iLauncherUI->PrintText(iCurrentAppNameAndExt); - iLauncherUI->PrintText(_L(": ")); - iLauncherUI->PrintText(outputText); - iLauncherUI->PrintText(_L("\n")); - - // write to the log also - iLogWriteBuf->Des().Append(_L(" [FAIL: ")); - iLogWriteBuf->Des().Append(outputText); - iLogWriteBuf->Des().Append(_L("]")); - iLogWriteBuf->Des().Append(KFileNewLine); - - iLogFile.Write(iLogWriteBuf->Des()); - - // close handle to the thread - //iCurrentAppThread.Close(); <-- not safe the close the handle because of the "App.Closed" dialog - // somehow takes ownership of the thread or something - - // nothing to do anymore, move to the next app - iFailedCases++; - CheckForMoreAppsL(); - } - -// --------------------------------------------------------------------------- -// --------------------------------------------------------------------------- - -CDesCArray* CLauncherEngine::DependencyCheckForE32ImageL() - { - LOGSTRING("Launcher: CLauncherEngine::DependencyCheckForE32ImageL"); - - // create an empty array for the missing dll names - CDesCArray* missingDllArray = new(ELeave) CDesCArrayFlat(100); - CleanupStack::PushL(missingDllArray); - - // get a list of DLLs from the E32 image file - E32ImageReader* reader = E32ImageReader::NewLC(); - CDesCArray* dllArray = reader->ListOfDLLsL( iAppsArray->MdcaPoint(iAppLaunchCounter) ); - CleanupStack::PopAndDestroy(); // reader - CleanupStack::PushL(dllArray); - - // compare system DLL and image DLL arrays - TInt pos(0); - for (TInt j=0; jMdcaCount(); j++) - { - if (iSystemDllArray->Find(dllArray->MdcaPoint(j), pos, ECmpFolded) != 0) - { - // DLL not found, append the name to the list of missing DLLs - missingDllArray->AppendL(dllArray->MdcaPoint(j)); - } - } - - CleanupStack::PopAndDestroy(); // dllArray - CleanupStack::Pop(); // missingDllArray - - LOGSTRING("Launcher: CLauncherEngine::DependencyCheckForE32ImageL returns"); - - return missingDllArray; - } - -// --------------------------------------------------------------------------- - -TInt CLauncherEngine::DeleteLogFile() - { - LOGSTRING("Launcher: CLauncherEngine::DeleteLogFile"); - return BaflUtils::DeleteFile(iEnv->FsSession(), iLogFilePath); - } - -// --------------------------------------------------------------------------- - -void CLauncherEngine::StopLaunchingL() - { - LOGSTRING("Launcher: CLauncherEngine::StopLaunchingL"); - if(iLaunchingIsActive) - { - //write to the log - WriteInitialStuffToTheLogL(_L("Cancelled by the user !!! "), iLogFile); - iLogWriteBuf->Des().Copy(KFileNewLine); - iLogWriteBuf->Des().Append(KFileNewLine); - iLogFile.Write(iLogWriteBuf->Des()); - - // close the log - iLogFile.Close(); - - // print to the screen - iLauncherUI->PrintText(_L("Launching cancelled.\n\n")); - - // cancel all active objects - if( iCurrentAppThread.Handle() != 0 ) - { - iCurrentAppThread.LogonCancel(iAppThreadChecker->iStatus); - } - Cancel(); - iAppRunningChecker->Cancel(); - iAppThreadChecker->Cancel(); - - iLaunchingIsActive = EFalse; - - _LIT(KMessage, "Launching cancelled"); - iLauncherUI->ShowInfoMessage(KMessage); - - } - } - -// --------------------------------------------------------------------------- - -TBool CLauncherEngine::LogFileExists() - { - LOGSTRING("Launcher: CLauncherEngine::LogFileExists"); - return BaflUtils::FileExists(iEnv->FsSession(), iLogFilePath); - } - -// --------------------------------------------------------------------------- - -TInt CLauncherEngine::DeleteBCLogFile() - { - LOGSTRING("Launcher: CLauncherEngine::DeleteBCLogFile"); - return BaflUtils::DeleteFile(iEnv->FsSession(), iBCLogFilePath); - } - - -// --------------------------------------------------------------------------- - -TBool CLauncherEngine::BCLogFileExists() - { - LOGSTRING("Launcher: CLauncherEngine::BCLogFileExists"); - return BaflUtils::FileExists(iEnv->FsSession(), iBCLogFilePath); - } - -// --------------------------------------------------------------------------- -void CLauncherEngine::AnalyseDLLsL( const TDesC& aFileName ) - { - LOGSTRING("Launcher: CLauncherEngine::AnalyseDLLsL"); - _LIT(KStartSeparator, "******************************"); - _LIT(KStartingAnalysis, "Starting BC Analysis for DLLs."); - _LIT(KInputFileSelected, "Input file selected: "); - - // Reset found issues counter and buffer - iFoundBCIssues = 0; - delete iBCIssuesBigBuffer; - iBCIssuesBigBuffer = 0; - - // Reset log writing buffer: - iLogWriteBuf->Des().Zero(); - - if( IsActive() ) - { - Cancel(); - } - - iRequiredDllsFilePath = aFileName; - - if( BaflUtils::FileExists(iEnv->FsSession(), iRequiredDllsFilePath) == EFalse ) - { - LOGSTRING2("Launcher: CLauncherEngine::AnalyseDLLsL - can't find input file: %S", &iRequiredDllsFilePath); - User::Leave( KErrNotFound ); - } - - // open the log file for writing - if (iBCLogFile.Open(iEnv->FsSession(), iBCLogFilePath, EFileWrite) != KErrNone) - { - iEnv->FsSession().MkDirAll(iLogFilePath); - User::LeaveIfError( iBCLogFile.Replace(iEnv->FsSession(), iBCLogFilePath, EFileWrite) ); - } - else - { - // file opens correctly, seek to the end - TInt fileSize=0; - iBCLogFile.Size(fileSize); - iBCLogFile.Seek(ESeekCurrent, fileSize); - } - - AppendLogBufferL(KFileNewLine(), iLogWriteBuf); - AppendLogBufferL(KStartSeparator(), iLogWriteBuf); - AppendLogBufferL(KFileNewLine(), iLogWriteBuf); - iBCLogFile.Write(iLogWriteBuf->Des()); - iLogWriteBuf->Des().Zero(); - - // Resolve file type. Should we use XML parsing or just compare DLL list - TBool xmlParsing = - KDotXML().Compare(iRequiredDllsFilePath.Right(KDotXML().Length())) == 0 || - KDotLauncherXML().Compare(iRequiredDllsFilePath.Right(KDotLauncherXML().Length())) == 0; - - // Log analysis starting time and selected input file: - WriteInitialStuffToTheLogL(KStartingAnalysis, iBCLogFile); - AppendLogBufferL(KInputFileSelected(), iLogWriteBuf); - AppendLogBufferL(iRequiredDllsFilePath, iLogWriteBuf); - AppendLogBufferL(KFileNewLine(), iLogWriteBuf); - iBCLogFile.Write(iLogWriteBuf->Des()); - iLogWriteBuf->Des().Zero(); - - if( xmlParsing ) - { - iLauncherUI->ChangeFocusToOutputView(); - DoBCAnalysisL(); - } - else - { - DoCompareDLLListsL(); - } - } - -// --------------------------------------------------------------------------- - -void CLauncherEngine::DoBCAnalysisL() - { - LOGSTRING("Launcher: CLauncherEngine::DoBCAnalysisL"); - if( iXMLParser == 0 ) - { - iXMLParser = CLauncherXMLParser::NewL(iEnv->FsSession()); - } - - TEntry entry; - User::LeaveIfError(iEnv->FsSession().Entry(iRequiredDllsFilePath, entry)); - TInt fileSize = entry.iSize; - - _LIT(KAnalysing,"Analysing DLLs"); - iLauncherUI->ShowProgressBar(KAnalysing, 0, fileSize); - iDLLAnalysisIsActive = ETrue; - - iXMLParser->ParseL(iRequiredDllsFilePath, this); - } - -// --------------------------------------------------------------------------- - -void CLauncherEngine::CancelBCAnalysis() - { - LOGSTRING("Launcher: CLauncherEngine::CancelBCAnalysis"); - if( iXMLParser ) - { - iXMLParser->Cancel(); - } - iLauncherUI->PrintText(_L("\nAnalysis cancelled.\n\n")); - WriteInitialStuffToTheLogL(_L("Analysis cancelled by user"), iBCLogFile); - iLogWriteBuf->Des().Zero(); - iBCLogFile.Close(); - } - -// --------------------------------------------------------------------------- - -void CLauncherEngine::DoCompareDLLListsL() - { - LOGSTRING("Launcher: CLauncherEngine::DoCompareDLLListsL"); - - RFile file; - CleanupClosePushL(file); - - // Show progress bar - _LIT(KAnalysing,"Analysing DLLs"); - iLauncherUI->ShowWaitDialog(KAnalysing); - - if(file.Open(iEnv->FsSession(), iRequiredDllsFilePath, EFileRead) != KErrNone) - { - // Hide wait dialog - iLauncherUI->HideWaitDialog(); - - iLauncherUI->ChangeFocusToOutputView(); - - TBuf<200> msg; - - - msg.Format(_L("Unable to open %S for reading!\n\n"), &iRequiredDllsFilePath); - iLauncherUI->PrintText( msg ); - } - else - { - - CDesCArray* requiredDllArray = new(ELeave) CDesCArrayFlat(KMaxDllArraySize); - CleanupStack::PushL(requiredDllArray); - - // read all lines the text file - TFileName dllName; - TInt i(0); - while( ReadLineFromFileL(file, dllName) == KErrNone && i 1) - requiredDllArray->AppendL(dllName); - - i++; - } - - if (requiredDllArray->MdcaCount() == 0) - { - // Hide wait dialog - iLauncherUI->HideWaitDialog(); - - iLauncherUI->ChangeFocusToOutputView(); - - TBuf<200> msg; - msg.Format(_L("File %S is empty!\n\n"), &iRequiredDllsFilePath); - iLauncherUI->PrintText( msg ); - } - else - { - // compare the arrays and print any missing items - CDesCArray* missingDllArray = new(ELeave) CDesCArrayFlat(KMaxDllArraySize); - CleanupStack::PushL(missingDllArray); - - TInt pos(0); - for (TInt j=0; jMdcaCount(); j++) - { - if (iSystemDllArray->Find(requiredDllArray->MdcaPoint(j), pos, ECmpFolded) != 0) - { - // DLL not found, append the name to the list of missing DLLs - missingDllArray->AppendL(requiredDllArray->MdcaPoint(j)); - } - } - - - if (missingDllArray->MdcaCount() == 0) - { - _LIT(KMessage, "No missing files found"); - AppendLogBufferL(KMessage(), iLogWriteBuf); - iLauncherUI->ShowInfoMessage(KMessage); - } - else - { - iLauncherUI->ChangeFocusToOutputView(); - _LIT(KMissingFiles, "Missing files:\n"); - - //iLauncherUI->PrintText( KMissingFiles ); - AppendLogBufferL(KMissingFiles(), iBCIssuesBigBuffer, KBigBufferAllocBytes); - - AppendLogBufferL(KMissingFiles(), iLogWriteBuf); - - for (TInt i=0; iMdcaCount(); i++) - { - //iLauncherUI->PrintText( missingDllArray->MdcaPoint(i) ); - AppendLogBufferL(missingDllArray->MdcaPoint(i), iBCIssuesBigBuffer, KBigBufferAllocBytes); - //iLauncherUI->PrintText( _L("\n") ); - AppendLogBufferL(KNewLine(), iBCIssuesBigBuffer, KBigBufferAllocBytes); - - AppendLogBufferL(missingDllArray->MdcaPoint(i), iLogWriteBuf); - AppendLogBufferL(KFileNewLine(), iLogWriteBuf); - } - AppendLogBufferL(KNewLine(), iBCIssuesBigBuffer, KBigBufferAllocBytes); - iLauncherUI->PrintText( iBCIssuesBigBuffer->Des() ); - } - - // Hide wait dialog - iLauncherUI->HideWaitDialog(); - - CleanupStack::PopAndDestroy(); // missingDllArray - } - - CleanupStack::PopAndDestroy(); // requiredDllArray - } - - CleanupStack::PopAndDestroy(); //file - iBCLogFile.Write(iLogWriteBuf->Des()); - iLogWriteBuf->Des().Zero(); - iBCLogFile.Close(); - } - -// --------------------------------------------------------------------------- - -void CLauncherEngine::ParsingProgressedL(TInt aBytes) - { - LOGSTRING2("Launcher: CLauncherEngine::ParsingProgressedL - Bytes: %d", aBytes); - iLauncherUI->SetProgressBarValue(aBytes); - } - -// --------------------------------------------------------------------------- - - -void CLauncherEngine::ElementParsedL(const CLauncherDLLElement& aDllElement) - { - LOGSTRING("Launcher: CLauncherEngine::ElementParsedL"); - User::ResetInactivityTime(); - - _LIT(KIndent, " "); - _LIT(KIssuesFound, "Binary compatibility issues found:"); - _LIT(KDLLMissing,"DLL is missing"); - _LIT(KUID1Changed,"UID1 changed"); - _LIT(KUID2Changed,"UID2 changed"); - _LIT(KUID3Changed,"UID3 changed"); - _LIT(KSIDChanged,"SID changed"); - _LIT(KCapabilityChanged,"Capability changed"); - - if( iDLLElement == 0 ) - { - iDLLElement = CLauncherDLLElement::NewL(); - } - - TFindFile fileFinder(iEnv->FsSession()); - _LIT(KDLLPath, "\\sys\\bin\\"); - TInt err = fileFinder.FindByPath(aDllElement.Name(), &KDLLPath); - - TBuf<256> issueStr; - - if( err == KErrNotFound ) - { - if( iFoundBCIssues++ == 0 ) - { - iLauncherUI->PrintText( KIssuesFound ); - iLauncherUI->PrintText( KNewLine ); - AppendLogBufferL(KFileNewLine(), iLogWriteBuf); - AppendLogBufferL(KIssuesFound(), iLogWriteBuf); - AppendLogBufferL(KFileNewLine(), iLogWriteBuf); - } - issueStr.Copy(aDllElement.Name()); - issueStr.Append(KNewLine); - issueStr.Append(KIndent); - issueStr.Append(KDLLMissing); - issueStr.Append(KNewLine); - - AppendLogBufferL(issueStr, iLogWriteBuf); - - TFileName dllName = aDllElement.Name(); - LOGSTRING2("Launcher: DLL not found: %S", &dllName); - if( iFoundBCIssues > KBigBufferUsageThreshold ) - { - if( iBCIssuesBigBuffer == 0) - { - iBCIssuesBigBuffer = HBufC::NewL(KBigBufferAllocBytes); - } - TInt maxSize = iBCIssuesBigBuffer->Des().Length() + issueStr.Length(); - if( maxSize >= iBCIssuesBigBuffer->Des().MaxLength()) - { - iBCIssuesBigBuffer = iBCIssuesBigBuffer->ReAllocL(maxSize + KBigBufferAllocBytes ); - } - TPtr ptr(iBCIssuesBigBuffer->Des()); - ptr += issueStr; - } - else - { - iLauncherUI->PrintText( issueStr); - } - } - else if( err == KErrNone) - { - // File is found, so let's try to open it: - RFile dllFile; - CleanupClosePushL(dllFile); - if( dllFile.Open(iEnv->FsSession(), fileFinder.File(), EFileRead) == KErrNone ) - { - // Parse DLL: - iDLLParser->ParseL(iEnv->FsSession(), dllFile, *iDLLElement); - CleanupStack::PopAndDestroy(); // dllFile - RArray diffs; - CleanupClosePushL(diffs); - - // Compare DLLs: - if( iDLLElement->CompareL(aDllElement, diffs)) - { - if( iFoundBCIssues++ == 0 ) - { - iLauncherUI->PrintText( KIssuesFound ); - iLauncherUI->PrintText( KNewLine ); - AppendLogBufferL(KFileNewLine(), iLogWriteBuf); - AppendLogBufferL(KIssuesFound(), iLogWriteBuf); - AppendLogBufferL(KFileNewLine(), iLogWriteBuf); - } - // Differencies found: - for( TInt i = 0; i < diffs.Count(); ++i ) - { - // Print DLL name: - if( i == 0 ) - { - issueStr.Copy(aDllElement.Name()); - issueStr.Append(KNewLine); - } - - // Print differencies: - issueStr.Append(KIndent); - switch(diffs[i]) - { - case CLauncherDLLElement::EDifference_UID1: - issueStr.Append(KUID1Changed); - break; - case CLauncherDLLElement::EDifference_UID2: - issueStr.Append( KUID2Changed ); - break; - case CLauncherDLLElement::EDifference_UID3: - issueStr.Append( KUID3Changed ); - break; - case CLauncherDLLElement::EDifference_SID: - issueStr.Append( KSIDChanged ); - break; - case CLauncherDLLElement::EDifference_Capability: - issueStr.Append( KCapabilityChanged ); - break; - } - issueStr.Append( KNewLine ); - } - AppendLogBufferL(issueStr, iLogWriteBuf); - if( iFoundBCIssues > KBigBufferUsageThreshold ) - { - // To improve performance, don't print issues to output anymore. - // Instead, store the issues in buffer and print them when analysis is done. - if( iBCIssuesBigBuffer == 0) - { - iBCIssuesBigBuffer = HBufC::NewL(KBigBufferAllocBytes); - } - TInt maxSize = iBCIssuesBigBuffer->Des().Length() + issueStr.Length(); - if( maxSize >= iBCIssuesBigBuffer->Des().MaxLength()) - { - TInt increaseSize = Max(issueStr.Length(), KBigBufferAllocBytes); - iBCIssuesBigBuffer = iBCIssuesBigBuffer->ReAllocL(maxSize + increaseSize ); - } - TPtr ptr(iBCIssuesBigBuffer->Des()); - ptr += issueStr; - } - else - { - iLauncherUI->PrintText( issueStr); - } - } - CleanupStack::Pop(); // diffs - diffs.Close(); - } - else - { - CleanupStack::PopAndDestroy(); // dllFile - } - } - } - -// --------------------------------------------------------------------------- -void CLauncherEngine::DocumentParsedL(TInt aErrorCode) - { - LOGSTRING2("Launcher: CLauncherEngine::DocumentParsedL (Error code: %d)", aErrorCode); - - iDLLAnalysisIsActive = EFalse; - _LIT(KParseError, "Parse error: "); - _LIT(KNoIssues, "No binary compatibility issues found"); - - if( IsActive() ) - { - Cancel(); - } - - //hide progress bar - iLauncherUI->HideProgressBar(); - - if( aErrorCode != KErrNone ) - { - TBuf<16> errorCodeString; - errorCodeString.AppendNum(aErrorCode); - iLauncherUI->PrintText( KNewLine ); - iLauncherUI->PrintText( KParseError ); - iLauncherUI->PrintText( errorCodeString ); - iLauncherUI->PrintText( KNewLine ); - AppendLogBufferL(KFileNewLine(), iLogWriteBuf); - AppendLogBufferL(KParseError(), iLogWriteBuf); - AppendLogBufferL(errorCodeString, iLogWriteBuf); - AppendLogBufferL(KFileNewLine(), iLogWriteBuf); - } - else if(iFoundBCIssues == 0) - { - iLauncherUI->PrintText( KNoIssues ); - iLauncherUI->PrintText( KNewLine ); - AppendLogBufferL(KFileNewLine(), iLogWriteBuf); - AppendLogBufferL(KNoIssues(), iLogWriteBuf); - AppendLogBufferL(KFileNewLine(), iLogWriteBuf); - } - else if( iBCIssuesBigBuffer && iBCIssuesBigBuffer->Des().Length() > 0 ) - { - iLauncherUI->PrintText(iBCIssuesBigBuffer->Des()); - delete iBCIssuesBigBuffer; - iBCIssuesBigBuffer = 0; - } - if( iLogWriteBuf->Length() > 0 && iBCLogFile.SubSessionHandle() != 0) - { - iBCLogFile.Write(iLogWriteBuf->Des()); - } - WriteInitialStuffToTheLogL(_L("Analysis ready"), iBCLogFile); - iLogWriteBuf->Des().Zero(); - iBCLogFile.Close(); - } - -// --------------------------------------------------------------------------- - -TInt CLauncherEngine::ReadLineFromFileL(RFile& aFile, TDes& aReadBuf) - { - LOGSTRING("Launcher: CLauncherEngine::ReadLineFromFile"); - - _LIT8(KImcvCRLF, "\r\n"); - TInt err(KErrNone); - - HBufC8* tempLine = HBufC8::NewLC(1000); - TPtr8 buffer = tempLine->Des(); - - // clear the target buffer - aReadBuf.Zero(); - - // get the current file position - TInt filePos(0); - aFile.Seek(ESeekCurrent, filePos); - - // read the buffer - err = aFile.Read(buffer); - - // check if it's the end of file - TInt s = buffer.Length(); - if (s == 0) - err = KErrEof; - - if (err == KErrNone) - { - // copy to the lfcr and then set the file pointer to the point after that - TInt pos = buffer.Find(KImcvCRLF); - if (pos != -1) - { - TFileName tempBuf; - buffer.SetLength(pos); - tempBuf.Copy(buffer); - aReadBuf.Justify(tempBuf, pos, ELeft, ' '); - filePos += (pos+2); - - // set the file pointer back to after the lfcr - aFile.Seek(ESeekStart, filePos); - } - - // else fill the whole buffer - else - { - aReadBuf.Copy(buffer); - } - } - - CleanupStack::PopAndDestroy(); // tempLine - return err; - } - - -// --------------------------------------------------------------------------- -// --------------------------------------------------------------------------- - - -////////////////////////////////////////////////////////////////////////////////////// - -// --------------------------------------------------------------------------- - -CAppThreadChecker* CAppThreadChecker::NewL(CLauncherEngine* aLauncherEngine) - { - LOGSTRING("Launcher: CAppThreadChecker::NewL"); - - CAppThreadChecker* self = new(ELeave) CAppThreadChecker; - CleanupStack::PushL(self); - self->ConstructL(aLauncherEngine); - CleanupStack::Pop(); - return self; - } - -// --------------------------------------------------------------------------- - -CAppThreadChecker::CAppThreadChecker() : CActive(EActivePriorityIpcEventsHigh) - { - } - -// --------------------------------------------------------------------------- - -void CAppThreadChecker::ConstructL(CLauncherEngine* aLauncherEngine) - { - LOGSTRING("Launcher: CAppThreadChecker::ConstructL"); - - iEnv = CEikonEnv::Static(); - - iLauncherEngine = aLauncherEngine; - - CActiveScheduler::Add(this); - } - -// --------------------------------------------------------------------------- - -CAppThreadChecker::~CAppThreadChecker() - { - LOGSTRING("Launcher: CAppThreadChecker::~CAppThreadChecker"); - - Cancel(); - } - -// --------------------------------------------------------------------------- - -void CAppThreadChecker::ActivateChecking() - { - LOGSTRING("Launcher: CAppThreadChecker::ActivateChecking"); - - __ASSERT_ALWAYS(!IsActive(), User::Panic(_L("Thread Checker"), 300)); - - SetActive(); - } - -// --------------------------------------------------------------------------- - -void CAppThreadChecker::RunL() - { - LOGSTRING("Launcher: CAppThreadChecker::RunL"); - - // check the state of the thread - iLauncherEngine->CheckWhyThreadDiedL(); - } - -// --------------------------------------------------------------------------- - -void CAppThreadChecker::DoCancel() - { - LOGSTRING("Launcher: CAppThreadChecker::DoCancel"); - } - -// --------------------------------------------------------------------------- - - - -// --------------------------------------------------------------------------- - -////////////////////////////////////////////////////////////////////////////////////// - -// --------------------------------------------------------------------------- - -CAppRunningChecker* CAppRunningChecker::NewL(CLauncherEngine* aLauncherEngine) - { - LOGSTRING("Launcher: CAppRunningChecker::NewL"); - - CAppRunningChecker* self = new(ELeave) CAppRunningChecker; - CleanupStack::PushL(self); - self->ConstructL(aLauncherEngine); - CleanupStack::Pop(); - return self; - } - -// --------------------------------------------------------------------------- - -CAppRunningChecker::CAppRunningChecker() : CActive(EActivePriorityIpcEventsHigh) - { - } - -// --------------------------------------------------------------------------- - -void CAppRunningChecker::ConstructL(CLauncherEngine* aLauncherEngine) - { - LOGSTRING("Launcher: CAppRunningChecker::ConstructL"); - - iEnv = CEikonEnv::Static(); - User::LeaveIfError(iTimer.CreateLocal()); - - iLauncherEngine = aLauncherEngine; - - CActiveScheduler::Add(this); - } - -// --------------------------------------------------------------------------- - -CAppRunningChecker::~CAppRunningChecker() - { - LOGSTRING("Launcher: CAppRunningChecker::~CAppRunningChecker"); - - Cancel(); - - iTimer.Close(); - } - -// --------------------------------------------------------------------------- - -void CAppRunningChecker::StartTesting() - { - LOGSTRING("Launcher: CAppRunningChecker::StartTesting"); - - __ASSERT_ALWAYS(!IsActive(), User::Panic(_L("Running Checker"), 200)); - - // async delay of seven seconds - iTimer.After(iStatus, 7000000); - SetActive(); - } - -// --------------------------------------------------------------------------- - -void CAppRunningChecker::RunL() - { - LOGSTRING("Launcher: CAppRunningChecker::RunL"); - - // check if the application is running - iLauncherEngine->CheckIfAppIsRunningL(); - } - -// --------------------------------------------------------------------------- - -void CAppRunningChecker::DoCancel() - { - LOGSTRING("Launcher: CAppRunningChecker::DoCancel"); - iTimer.Cancel(); - } - -// --------------------------------------------------------------------------- - - - -////////////////////////////////////////////////////////////////////////////////////// - diff -r 819e59dfc032 -r 2d9cac8919d3 launcher/engine/src/launcherxmlparser.cpp --- a/launcher/engine/src/launcherxmlparser.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,430 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include -#include -#include "launcherxmlparser.h" -#include "launchertraces.h" - -_LIT8(KXmlMimeType, "text/xml"); - -/** - * XML element names - */ -_LIT8(KDll, "dll"); -_LIT8(KDllName, "dllname"); -_LIT8(KUID1, "uid1"); -_LIT8(KUID2, "uid2"); -_LIT8(KUID3, "uid3"); -_LIT8(KSID, "sid"); -_LIT8(KCapability, "capability"); - -// --------------------------------------------------------------------------- - -CLauncherXMLParser::CLauncherXMLParser(RFs& aFs) -: -CActive( EPriorityIdle ), -iParser(0), -iFileSession(aFs), -iParsedBytes(0) - { - CActiveScheduler::Add( this ); - } - -// --------------------------------------------------------------------------- - -void CLauncherXMLParser::ConstructL() - { - LOGSTRING("Launcher: CLauncherXMLParser::ConstructL"); - } - -// --------------------------------------------------------------------------- - -CLauncherXMLParser* CLauncherXMLParser::NewL(RFs& aFs) - { - LOGSTRING("Launcher: CLauncherXMLParser::NewL"); - CLauncherXMLParser* self = CLauncherXMLParser::NewLC(aFs); - CleanupStack::Pop(); - return self; - } - -// --------------------------------------------------------------------------- - -CLauncherXMLParser* CLauncherXMLParser::NewLC(RFs& aFs) - { - LOGSTRING("Launcher: CLauncherXMLParser::NewLC"); - CLauncherXMLParser* self = new (ELeave) CLauncherXMLParser(aFs); - CleanupStack::PushL(self); - self->ConstructL(); - return self; - } - -// --------------------------------------------------------------------------- - -CLauncherXMLParser::~CLauncherXMLParser() - { - LOGSTRING("Launcher: CLauncherXMLParser::~CLauncherXMLParser"); - Cancel(); - delete iParser; - delete iCurrentDllElement; - } - -// --------------------------------------------------------------------------- - -void CLauncherXMLParser::ClearXMLDataBuffer() - { - iXMLDataBuffer.Zero(); - } - -// --------------------------------------------------------------------------- - -void CLauncherXMLParser::DoCancel() - { - LOGSTRING("Launcher: CLauncherXMLParser::DoCancel"); - iIgnoreError = ETrue; - if( iParser ) - { - TRAP_IGNORE(iParser->ParseEndL()); - } - iFile.Close(); - ClearXMLDataBuffer(); - } - -// --------------------------------------------------------------------------- -// Gives current buffer content to parser for processing. Then reads -// next part of the file in the buffer and waits for next scheduled run. - -void CLauncherXMLParser::RunL() - { - TInt err = iStatus.Int(); - LOGSTRING2("Launcher: CLauncherXMLParser::RunL - iStatus: %d", err); - if( err != KErrNone ) - { - iObserver->DocumentParsedL(err); // Observer should cancel parsing - iFile.Close(); - ClearXMLDataBuffer(); - } - else - { - iParsedBytes += iXMLDataBuffer.Length(); - iObserver->ParsingProgressedL(iParsedBytes); - // Check if the end of the file is reached: - if( iXMLDataBuffer.Length() > 0) - { - // Parse the data in buffer - LOGSTRING("Launcher: CLauncherXMLParser::RunL: Starting XML parsing"); - if( iParser ) - { - iParser->ParseL( iXMLDataBuffer ); - } - else - { - LOGSTRING("CLauncherXMLParser::RunL - Error: NULL parser"); - User::Leave(KErrGeneral); - } - // Read new data from XML file to buffer: - iFile.Read( iXMLDataBuffer, KXMLBufferSize, iStatus ); - SetActive(); - } - else - { - // End of the file reached. Stop parsing and close the file: - LOGSTRING("Launcher: CLauncherXMLParser::RunL: Data parsed. Stopping"); - if( iParser ) - { - iParser->ParseEndL(); - } - iFile.Close(); - ClearXMLDataBuffer(); - } - } - } - -// --------------------------------------------------------------------------- - -void CLauncherXMLParser::ParseL(const TDesC& aFilePath, MLauncherParserObserver* aObserver) - { - LOGSTRING2("Launcher: CLauncherXMLParser::ParseL: %S", &aFilePath); - iIgnoreError = EFalse; - iParsedBytes = 0; - if ( IsActive() ) - { - Cancel(); - } - - if( aObserver == 0 ) - { - LOGSTRING("Launcher: CLauncherXMLParser::ParseL: Error: Observer is a NULL pointer."); - User::Leave(KErrArgument); - } - - // Open the XML-file - TInt err = iFile.Open( iFileSession, aFilePath, EFileRead ); - User::LeaveIfError( err ); - - // Create and start XML-parser: - delete iParser; - iParser = 0; - iParser = CParser::NewL(KXmlMimeType, *this); - - // Set observer: - iObserver = aObserver; - - // Initialize the buffer and read first part of the XML-file: - ClearXMLDataBuffer(); - iFile.Read( iXMLDataBuffer, KXMLBufferSize, iStatus ); - SetActive(); - iParser->ParseBeginL(); // Reset the parser to xml-filetype - } - -// --------------------------------------------------------------------------- - -void CLauncherXMLParser::OnStartDocumentL(const Xml::RDocumentParameters& /*aDocParam*/, TInt aErrorCode) - { - LOGSTRING2("Launcher: CLauncherXMLParser::OnStartDocumentL (Error code: %d)", aErrorCode); - if( aErrorCode != KErrNone ) - { - iObserver->DocumentParsedL(aErrorCode); - } - } - -// --------------------------------------------------------------------------- - -void CLauncherXMLParser::OnEndDocumentL(TInt aErrorCode) - { - LOGSTRING2("Launcher: CLauncherXMLParser::OnEndDocumentL (Error code: %d)", aErrorCode); - iObserver->DocumentParsedL(aErrorCode); - } - -// --------------------------------------------------------------------------- - -void CLauncherXMLParser::OnStartPrefixMappingL( const RString& /*aPrefix*/, - const RString& /*aUri*/, - TInt aErrorCode) - { - LOGSTRING2("Launcher: CLauncherXMLParser::OnStartPrefixMappingL (Error code: %d)", aErrorCode); - if( aErrorCode != KErrNone ) - { - iObserver->DocumentParsedL(aErrorCode); - } - } - -// --------------------------------------------------------------------------- - -void CLauncherXMLParser::OnEndPrefixMappingL(const RString& /*aPrefix*/, TInt aErrorCode) - { - LOGSTRING2("Launcer: CLauncherXMLParser::OnEndPrefixMappingL (Error code: %d)", aErrorCode); - if( aErrorCode != KErrNone ) - { - iObserver->DocumentParsedL(aErrorCode); - } - } - -// --------------------------------------------------------------------------- - -void CLauncherXMLParser::OnIgnorableWhiteSpaceL(const TDesC8& /*aBytes*/, TInt aErrorCode) - { - LOGSTRING2("Launcher: CLauncherXMLParser::OnIgnorableWhiteSpaceL (Error code: %d)", aErrorCode); - if( aErrorCode != KErrNone ) - { - iObserver->DocumentParsedL(aErrorCode); - } - } - -// --------------------------------------------------------------------------- - -void CLauncherXMLParser::OnSkippedEntityL(const RString& /*aName*/, TInt aErrorCode) - { - LOGSTRING2("Launcher: CLauncherXMLParser::OnSkippedEntityL (Error code: %d)", aErrorCode); - if( aErrorCode != KErrNone ) - { - iObserver->DocumentParsedL(aErrorCode); - } - } - -// --------------------------------------------------------------------------- - -void CLauncherXMLParser::OnProcessingInstructionL( const TDesC8& /*aTarget*/, - const TDesC8& /*aData*/, - TInt aErrorCode) - { - LOGSTRING2("Launcher: CLauncherXMLParser::OnProcessingInstructionL (Error code: %d)", aErrorCode); - if( aErrorCode != KErrNone ) - { - iObserver->DocumentParsedL(aErrorCode); - } - } - -// --------------------------------------------------------------------------- - -void CLauncherXMLParser::OnError(TInt aErrorCode) - { - LOGSTRING2("Launcher: CLauncherXMLParser::OnError: %d", aErrorCode); - if( iIgnoreError == EFalse ) - { - TRAP_IGNORE(iObserver->DocumentParsedL(aErrorCode)); - } - } - -// --------------------------------------------------------------------------- - -TAny* CLauncherXMLParser::GetExtendedInterface(const TInt32 aUid) - { - (void)aUid; - LOGSTRING2("Launcher: CLauncherXMLParser::GetExtendedInterface (UID: %d)", aUid); - return 0; - } - -// --------------------------------------------------------------------------- - -void CLauncherXMLParser::OnStartElementL( const RTagInfo& aElement, - const RAttributeArray& /*aAttributes*/, - TInt aErrorCode) - { - LOGSTRING2("Launcher: CLauncherXMLParser::OnStartElementL (Error code: %d)", aErrorCode); - if( aErrorCode != KErrNone ) - { - iObserver->DocumentParsedL(aErrorCode); - } - else - { - // Save XML-element name: - iCurrentElementName = aElement.LocalName().DesC(); - - // If this is 'dll'-element, initialize new DLL element instance: - if( iCurrentDllElement == 0 && iCurrentElementName == KDll ) - { - iCurrentDllElement = CLauncherDLLElement::NewL(); - } - // Clear contents buffer: - iCurrentContent.Zero(); - } - } - -// --------------------------------------------------------------------------- - -void CLauncherXMLParser::OnEndElementL(const RTagInfo& aElement, TInt aErrorCode) - { - LOGSTRING2("Launcher: CLauncherXMLParser::OnEndElementL (Error code: %d)", aErrorCode); - if( aErrorCode != KErrNone ) - { - iObserver->DocumentParsedL(aErrorCode); - } - else - { - // Save XML-element's name: - iCurrentElementName = aElement.LocalName().DesC(); - TUid tmpUID; - - if( IsDataElement() ) - { - // Check that we have a pointer to parent DLL element - if( iCurrentDllElement == 0 ) - { - LOGSTRING("Launcher: CLauncherXMLParser: Error in parsing xml (parent DLL element missing)."); - User::Leave(KErrGeneral); - } - // DLL name - if( iCurrentElementName == KDllName ) - { - TFileName dllName; - dllName.Copy(iCurrentContent); - iCurrentDllElement->SetNameL(dllName); - } - // UID1 - else if( iCurrentElementName == KUID1 ) - { - tmpUID.iUid = ConvertDes8ToUint32L(iCurrentContent); - iCurrentDllElement->SetUID1L(tmpUID); - } - // UID2 - else if( iCurrentElementName == KUID2 ) - { - tmpUID.iUid = ConvertDes8ToUint32L(iCurrentContent); - iCurrentDllElement->SetUID2L(tmpUID); - } - // UID3 - else if( iCurrentElementName == KUID3 ) - { - tmpUID.iUid = ConvertDes8ToUint32L(iCurrentContent); - iCurrentDllElement->SetUID3L(tmpUID); - } - // SID - else if( iCurrentElementName == KSID ) - { - tmpUID.iUid = ConvertDes8ToUint32L(iCurrentContent); - iCurrentDllElement->SetSIDL(tmpUID); - } - // Capability - else if( iCurrentElementName == KCapability ) - { - iCurrentDllElement->SetCapabilityL(ConvertDes8ToUint32L(iCurrentContent)); - } - } - else if( iCurrentElementName == KDll ) - { - // DLL element parsed, give current DLL object to observer: - iObserver->ElementParsedL(*iCurrentDllElement); - } - } - } - -// --------------------------------------------------------------------------- - -TBool CLauncherXMLParser::IsDataElement() - { - if( iCurrentElementName == KDllName || - iCurrentElementName == KUID1 || - iCurrentElementName == KUID2 || - iCurrentElementName == KUID3 || - iCurrentElementName == KSID || - iCurrentElementName == KCapability ) - { - return ETrue; - } - return EFalse; - } - -// --------------------------------------------------------------------------- -// Reads content of an xml-element. - -void CLauncherXMLParser::OnContentL(const TDesC8& aBytes, TInt aErrorCode) - { - LOGSTRING2("Launcher: CLauncherXMLParser::OnContentL (Error code: %d)", aErrorCode); - if( aErrorCode != KErrNone ) - { - iObserver->DocumentParsedL(aErrorCode); - } - else if( iCurrentElementName.Length() == 0) - { - LOGSTRING("Launcher: CLauncherXMLParser: Error in parsing xml (element name missing)."); - User::Leave(KErrGeneral); - } - iCurrentContent.Append(aBytes); - } - -// --------------------------------------------------------------------------- - -TUint32 CLauncherXMLParser::ConvertDes8ToUint32L(const TDesC8& aStr) - { - LOGSTRING("Launcher: CLauncherXMLParser::ConvertDes8ToUintL"); - TUint32 uintVal = 0; - TLex8 lex(aStr); - TInt errorCode=lex.Val(uintVal, EHex); - User::LeaveIfError(errorCode); - return uintVal; - } diff -r 819e59dfc032 -r 2d9cac8919d3 launcher/icons/check.svg --- a/launcher/icons/check.svg Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,90 +0,0 @@ - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - diff -r 819e59dfc032 -r 2d9cac8919d3 launcher/icons/qgn_menu_launcher.svg --- a/launcher/icons/qgn_menu_launcher.svg Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,113 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r 819e59dfc032 -r 2d9cac8919d3 launcher/inc/applicationview.h --- a/launcher/inc/applicationview.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,140 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef APPLICATIONVIEW_H -#define APPLICATIONVIEW_H - -#include - -class HbAction; -class HbDocumentLoader; -class HbListWidget; -class CommonActions; -class EngineWrapper; - -class ApplicationView : public HbView -{ - Q_OBJECT - -public: - - /** - * Constructor - */ - ApplicationView(); - - /** - * Destructor - */ - ~ApplicationView(); - - /** - * Created Application View - */ - static ApplicationView* create(HbDocumentLoader &loader, - CommonActions *commonActions, - EngineWrapper *engine); - - /** - * Setter for engine - */ - void setEngine(EngineWrapper *engine); - -private slots: - - - /** - * Refreshed application list - */ - void refreshAppList(); - - /** - * Launches selected applications - */ - void launchSelectedApplications(); - - /** - * Launches and closes selected applications - */ - void launchAndCloseSelectedApplications(); - - /** - * Selects all list items - */ - void selectAllItems(); - - /** - * unselects all items - */ - void unselectAllItems(); - - /** - * Changes launch options so that hidden applications are skipped - */ - void launchOptionsSkipHidden(); - - /** - * Changes launch options so that hidden applications are not skipped - */ - void launchOptionsDontSkipHidden(); - - /** - * Opens output view - */ - void openOutputView(); - - -private: - - /** - * Initializes view - */ - void init(HbDocumentLoader &loader, CommonActions *commonActions); - - /** - * connects signals and slots - */ - void connectSignalsAndSlots(); - - /** - * Loads all UI items from xml file - */ - void loadItemsFromXml(HbDocumentLoader &loader); - -private slots: - - -private: - EngineWrapper *mEngine; - - //UI components: - HbListWidget *mApplicationList; - - //Actions: - HbAction *mActionRefresh; - HbAction *mActionLaunchApps; - HbAction *mActionLaunchAndCloseApps; - HbAction *mActionSkipHidden; - HbAction *mActionDontSkipHidden; - HbAction *mActionSelectAll; - HbAction *mActionUnselectAll; - HbAction *mActionOpenOutputView; - - -}; - -#endif // APPLICATIONVIEW_H diff -r 819e59dfc032 -r 2d9cac8919d3 launcher/inc/commonActions.h --- a/launcher/inc/commonActions.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,106 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#ifndef COMMONACTIONS_H -#define COMMONACTIONS_H - -#include - -class EngineWrapper; -class HbAction; -class HbMenu; -class HbApplication; - -class CommonActions : public QObject -{ - Q_OBJECT -public: - - /** - * Constructor - */ - CommonActions(EngineWrapper *engine, HbApplication *application); - - /** - * Destructor - */ - ~CommonActions(); - - /** - * Adds all actions to menu that is given as parameter - */ - void addActionsToMenu(HbMenu *menu); - -public slots: - - /** - * Shows about box - */ - void showAbout(); - - /** - * Stops launching applications - */ - void stopLaunch(); - - /** - * Sends DLL info - */ - void sendDllInfo(); - - /** - * Compares DLL infos - */ - void compareDllInfo(); - - /** - * Sends log - */ - void sendLog(); - - /** - * Deletes log - */ - void deleteLog(); - - /** - * Exits launcher - */ - void exit(); - -private: - void connectSignalsAndSlots(); - -private: - EngineWrapper *mEngine; - - HbApplication *mApplication; - - //Actions: - - HbAction *mActionStopLaunch; - HbAction *mActionSendDllInfo; - HbAction *mActionCompareDllInfo; - HbAction *mActionSendLog; - HbAction *mActionDeleteLog; - HbAction *mActionAbout; - HbAction *mActionExit; - -}; - -#endif //COMMONACTIONS_H diff -r 819e59dfc032 -r 2d9cac8919d3 launcher/inc/enginewrapper.h --- a/launcher/inc/enginewrapper.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,170 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef ENGINEWRAPPER_H -#define ENGINEWRAPPER_H - -#include -#include -#include -#include - -#include "launcherengine.h" - -class HbProgressDialog; -class HbDeviceProgressDialog; -class HbAction; - -class LauncherMainWindow; - - -class EngineWrapper : public QObject, public MLauncherUI -{ - Q_OBJECT - -public: - - /** - * Constructor - */ - EngineWrapper(LauncherMainWindow* mainWindow); - - /** - * Destructor - */ - ~EngineWrapper(); - - /** - * Initializes Engine Wrapper - * @return true if engine was started successfully - */ - bool init(); - -public: - // functions that are called from UI - - /** - * Fetches list of applications from engine - */ - bool listOfAllApps(QStringList &allAppsQStringList); - - /** - * Starts launching applications that are given as parameter - */ - bool startAppLaunching(const QModelIndexList &list, bool autoClose); - - /** - * Sets engine to skip hidden applications when launching - */ - void setSkipHiddenAndEmbedOnly(bool skip); - - /** - * Stops launching applications - */ - bool stopLaunching(); - - /** - * Sends log - */ - bool sendLog(); - - /** - * Deletes log - */ - bool deleteLog(); - - /** - * Compares dll - */ - void compareDlls(); - - /** - * Sends list of dlls - */ - bool sendListOfDlls(); - -public: - // From MLauncherUIEngine - // functions that are called from Engine - - /** - * Shows error message with error text - */ - virtual void ShowErrorMessage(const TDesC& aText); - - /** - * Shows information message with info text - */ - virtual void ShowInfoMessage(const TDesC& aText); - - /** - * Shows progress bar with text - */ - virtual void ShowProgressBar(const TDesC& aText, TInt aMinimum = 0, TInt aMaximum = 0 ); - - /** - * Sets progress bar value - */ - virtual void SetProgressBarValue(TInt aValue); - - /** - * Hides progress bar - */ - virtual void HideProgressBar(); - - /** - * Shows wait dialog with text - */ - virtual void ShowWaitDialog(const TDesC& aText); - - /** - * Hides wait dialog - */ - virtual void HideWaitDialog(); - - /** - * Changes focus to output view - */ - virtual void ChangeFocusToOutputView(); - - /** - * Prints text to output views log - */ - virtual void PrintText(const TDesC& aText); - -public slots: - void doCompareDlls(HbAction*); - void CancelDllBCanalysis(); - -private: - - /** - * Allocate CArrayFix and copy QList to it - */ - CArrayFix* QModelIndexListToCArrayFixL(const QModelIndexList& qlist); - -private: - CLauncherEngine *mEngine; - LauncherMainWindow *mMainWindow; - HbProgressDialog* mProgressDialog; - HbDeviceProgressDialog* mWaitDialog; -}; - - - - -#endif //ENGINEWRAPPER_H diff -r 819e59dfc032 -r 2d9cac8919d3 launcher/inc/launchermainwindow.h --- a/launcher/inc/launchermainwindow.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,54 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#ifndef LauncherMainWindow_H_ -#define LauncherMainWindow_H_ - -#include -#include - -class HbApplication; -class ApplicationView; -class OutputView; -class EngineWrapper; -class CommonActions; - -class LauncherMainWindow : public HbMainWindow - { -public: - - LauncherMainWindow ( QWidget *parent = 0 ); - virtual ~LauncherMainWindow (); - - int init( HbApplication &app ); - - void openApplicationView(); - void openOutputView(); - /** - * Prints text into output - */ - void printText(const QString &text); - -private: //data - EngineWrapper* mEngineWrapper; - ApplicationView* mApplicationView; - OutputView* mOutputView; - CommonActions* mCommonActions; - }; - -#endif /* LauncherMainWindow_H_ */ diff -r 819e59dfc032 -r 2d9cac8919d3 launcher/inc/notifications.h --- a/launcher/inc/notifications.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,64 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef NOTIFICATIONS_H_ -#define NOTIFICATIONS_H_ - -#include -#include - - -class Notifications - { -public: - - /** - * shows message box of the specified type with text and label - */ - static void showMessageBox( - HbMessageBox::MessageBoxType type, - const QString &text, - const QString &label, - int timeout = HbPopup::NoTimeout - ); - - /** - * shows about box - */ - static void about(); - - /** - * shows information type message box - */ - static void showInformationNote(const QString &text); - - /** - * shows warning type message box - */ - static void showErrorNote(const QString &text); - - /** - * shows progressbar - */ - static HbDeviceProgressDialog* showWaitDialog(const QString &text); - - - }; - - - -#endif // NOTIFICATIONS_H_ diff -r 819e59dfc032 -r 2d9cac8919d3 launcher/inc/outputview.h --- a/launcher/inc/outputview.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,94 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef OUTPUTVIEW_H -#define OUTPUTVIEW_H - -#include - -class HbDocumentLoader; -class HbAction; -class HbTextEdit; -class CommonActions; - -class OutputView : public HbView -{ - Q_OBJECT - -public: - /** - * Constructor - */ - OutputView(); - - /** - * Destructor - */ - ~OutputView(); - - /** - * Creates output view and adds it into main window - */ - static OutputView* create(HbDocumentLoader &loader, CommonActions *commonActions); - - /** - * Prints text into output - */ - void printText(const QString &text); - -private slots: - - /** - * Clears output - */ - void clearOutput(); - - /** - * Opens application view - */ - void openApplicationView(); - -private: - - /** - * Initializes view - */ - void init(HbDocumentLoader &loader, CommonActions *commonActions); - - /** - * Loads all output view's ui components from xml-file - */ - void loadItemsFromXml(HbDocumentLoader &loader); - - /** - * connects signals and slots to each other - */ - void connectSignalsAndSlots(); - - -private: - - // Actions - HbAction *mActionClear; - HbAction *mActionOpenApplicationView; - - HbTextEdit *mTextOutput; - -}; - -#endif // OUTPUTVIEW - diff -r 819e59dfc032 -r 2d9cac8919d3 launcher/launcher.pro --- a/launcher/launcher.pro Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,64 +0,0 @@ -TEMPLATE = app -TARGET = Launcher -load(hb.prf) -symbian:CONFIG -= symbian_i18n -DEPENDPATH += src -DEPENDPATH += inc -INCLUDEPATH += inc - -HEADERS += launchermainwindow.h applicationview.h enginewrapper.h notifications.h outputview.h commonActions.h -SOURCES += main.cpp launchermainwindow.cpp applicationview.cpp enginewrapper.cpp notifications.cpp outputview.cpp commonActions.cpp -RESOURCES += launcher.qrc - -symbian: { - - BLD_INF_RULES.prj_exports += "./rom/Launcher.iby CORE_IBY_EXPORT_PATH(tools,Launcher.iby)" - BLD_INF_RULES.prj_exports += "./rom/backup_registration.xml Z:/private/101fb74f/backup_registration.xml" - - launcher_stub_sis_mk = \ - "$${LITERAL_HASH}if defined(__SERIES60_30__) || defined(__SERIES60_31__) || defined(__S60_32__)" \ - " $${LITERAL_HASH}ifdef MARM" \ - " gnumakefile .sis/launcher_stub_sis.mk" \ - " $${LITERAL_HASH}endif" \ - "$${LITERAL_HASH}endif" - BLD_INF_RULES.prj_mmpfiles += launcher_stub_sis_mk - - launcher_buildstubsis_extension = \ - "$${LITERAL_HASH}if(!defined __SERIES60_30__ && !defined __SERIES60_31__ && !defined __S60_32__)" \ - " $${LITERAL_HASH}ifdef MARM" \ - " START EXTENSION app-services/buildstubsis" \ - " OPTION SRCDIR sis" \ - " OPTION SISNAME Launcher_stub" \ - " END" \ - " $${LITERAL_HASH}endif" \ - "$${LITERAL_HASH}endif" - BLD_INF_RULES.prj_extensions += launcher_buildstubsis_extension - - INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE - - DEPENDPATH += engine/inc - DEPENDPATH += engine/src - INCLUDEPATH += engine/inc - - HEADERS += launcherengine.h launchertraces.h e32image.h e32imageheaders.h launcherxmlparser.h launcherdllelement.h launcherparserobserver.h launcherdllparser.h - SOURCES += launcherengine.cpp e32image.cpp launcherxmlparser.cpp launcherdllelement.cpp launcherdllparser.cpp - - RSS_RULES += "group_name = \"RnD Tools\""; - - LIBS += -lapgrfx -lPlatformEnv -lxqutils -lxmlframework -lbafl -lshareui -lws32 -lapparc -lefsrv -lcone - - - TARGET.CAPABILITY = ReadUserData ReadDeviceData WriteUserData WriteDeviceData PowerMgmt AllFiles - - TARGET.UID2 = 0x100039CE - TARGET.UID3 = 0x101FB74F - TARGET.SID = 0x101FB74F - TARGET.VID = 0x101FB657 // Nokia - - TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 // Min 128Kb, Max 32Mb - - ICON = ./icons/qgn_menu_launcher.svg - -} else { - error("Only Symbian supported!") -} diff -r 819e59dfc032 -r 2d9cac8919d3 launcher/launcher.qrc --- a/launcher/launcher.qrc Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,9 +0,0 @@ - - - src/applicationview.xml - src/outputview.xml - - - icons/qgn_menu_launcher.svg - - diff -r 819e59dfc032 -r 2d9cac8919d3 launcher/rom/Launcher.iby --- a/launcher/rom/Launcher.iby Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#ifndef __LAUNCHER_IBY__ -#define __LAUNCHER_IBY__ - -S60_APP_EXE(Launcher) -S60_APP_RESOURCE(Launcher) -SCALABLE_IMAGE(APP_BITMAP_DIR,APP_BITMAP_DIR,Launcher) -data=ZPRIVATE\10003a3f\import\APPS\Launcher_reg.RSC Private\10003a3f\import\Apps\Launcher_reg.rsc - -//#ifdef S60_UPGRADABLE_APP_REG_RSC -// S60_UPGRADABLE_APP_REG_RSC(Launcher) -//#else -// S60_APP_AIF_RSC(Launcher) -//#endif - -data=ZPRIVATE\101FB74F\backup_registration.xml private\101FB74F\backup_registration.xml -data=ZSYSTEM\Install\Launcher_stub.sis \system\install\Launcher_stub.sis - -#endif diff -r 819e59dfc032 -r 2d9cac8919d3 launcher/rom/backup_registration.xml --- a/launcher/rom/backup_registration.xml Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ - - - - - - - - diff -r 819e59dfc032 -r 2d9cac8919d3 launcher/sis/Launcher_S60-5x.pkg --- a/launcher/sis/Launcher_S60-5x.pkg Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ -; -; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -; All rights reserved. -; This component and the accompanying materials are made available -; under the terms of "Eclipse Public License v1.0" -; which accompanies this distribution, and is available -; at the URL "http://www.eclipse.org/legal/epl-v10.html". -; -; Initial Contributors: -; Nokia Corporation - initial contribution. -; -; Contributors: -; -; Description: -; - -; Language - standard language definitions -&EN - -; Standard SIS file header -#{"Launcher"},(0x101FB74F),4,0,0,TYPE=SA - -;Supports S60 v 5.0 -[0x1028315F], 0, 0, 0, {"S60ProductID"} - -;Supports S60 v 5.1 -[0x10283160], 0, 0, 0, {"S60ProductID"} - -;Supports S60 v 5.2 -[0x20022E6D], 0, 0, 0, {"S60ProductID"} - -; Non-localised vendor name -:"Nokia Corporation" - -; Localised vendor names -%{"Nokia Corporation"} - -; normal stuff: -"\epoc32\release\armv5\urel\launcher.exe"-"!:\sys\bin\launcher.exe" -"\epoc32\data\z\resource\apps\launcher.mif"-"!:\resource\apps\launcher.mif" -"\epoc32\data\z\resource\apps\launcher.rsc"-"!:\resource\apps\launcher.rsc" -"\epoc32\data\z\private\10003a3f\import\apps\launcher_reg.rsc"-"!:\private\10003a3f\import\apps\launcher_reg.rsc" -"..\group\backup_registration.xml"-"!:\private\101fb74f\backup_registration.xml" diff -r 819e59dfc032 -r 2d9cac8919d3 launcher/sis/Launcher_stub.pkg --- a/launcher/sis/Launcher_stub.pkg Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -; -; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -; All rights reserved. -; This component and the accompanying materials are made available -; under the terms of "Eclipse Public License v1.0" -; which accompanies this distribution, and is available -; at the URL "http://www.eclipse.org/legal/epl-v10.html". -; -; Initial Contributors: -; Nokia Corporation - initial contribution. -; -; Contributors: -; -; Description: -; - -; Language - standard language definitions -&EN - -; Standard SIS file header -#{"Launcher"},(0x101FB74F),4,0,0 - -; Non-localised vendor name -:"Nokia Corporation" - -; Localised vendor names -%{"Nokia Corporation"} - -; normal stuff: -""-"z:\sys\bin\Launcher.exe" -""-"z:\Resource\Apps\Launcher.mif" -""-"z:\Resource\Apps\Launcher.rsc" -""-"z:\private\10003a3f\import\apps\Launcher_reg.rsc" -""-"z:\private\101FB74F\backup_registration.xml" \ No newline at end of file diff -r 819e59dfc032 -r 2d9cac8919d3 launcher/sis/launcher_stub_sis.mk --- a/launcher/sis/launcher_stub_sis.mk Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -# -# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# This component and the accompanying materials are made available -# under the terms of "Eclipse Public License v1.0" -# which accompanies this distribution, and is available -# at the URL "http://www.eclipse.org/legal/epl-v10.html". -# -# Initial Contributors: -# Nokia Corporation - initial contribution. -# -# Contributors: -# -# Description: -# - - -TARGETDIR=$(EPOCROOT)EPOC32\Data\Z\System\Install - -SISNAME=Launcher_stub -PKGNAME=Launcher_stub - -$(TARGETDIR) : - @perl -S emkdir.pl "$(TARGETDIR)" - -do_nothing : - rem do_nothing - -SISFILE=$(TARGETDIR)\$(SISNAME).sis - -$(SISFILE) : .\$(PKGNAME).pkg - makesis -s $? $@ - - - -MAKMAKE : do_nothing - -RESOURCE : do_nothing - -SAVESPACE : do_nothing - -BLD : do_nothing - -FREEZE : do_nothing - -LIB : do_nothing - -CLEANLIB : do_nothing - -FINAL : $(TARGETDIR) $(SISFILE) - -CLEAN : - @if exist $(SISFILE) erase $(SISFILE) - -RELEASABLES : - @echo $(SISFILE) diff -r 819e59dfc032 -r 2d9cac8919d3 launcher/src/applicationview.cpp --- a/launcher/src/applicationview.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,299 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include -#include -#include -#include -#include -#include - -#include "applicationview.h" -#include "launchermainwindow.h" -#include "enginewrapper.h" -#include "notifications.h" -#include "commonActions.h" -#include "outputview.h" - - - - -// xml definition of view -const char *APPLICATIONVIEW_XML = ":/xml/applicationview.xml"; - -// name of the application view object in the xml file. -const char *APPLICATIONVIEW = "applicationview"; -const char *LISTVIEW = "applicationList"; -const char *ACTIONREFRESH = "actionRefresh"; -const char *ACTIONLAUNCHAPPS = "actionLaunchApps"; -const char *ACTIONLAUNCHANDCLOSEAPPS = "actionLaunchAppsAndClose"; -const char *ACTIONSELECT = "actionSelectAll"; -const char *ACTIONUNSELECT = "actionUnselectAll"; -const char *ACTIONOPENOUTPUTVIEW = "actionOpenOutputView"; -const char *ACTIONSKIPHIDDEN = "actionSkipHidden"; -const char *ACTIONDONTSKIPHIDDEN = "actionDontSkipHidden"; - -// --------------------------------------------------------------------------- - -ApplicationView* ApplicationView::create(HbDocumentLoader &loader, CommonActions *commonActions, EngineWrapper *engine) -{ - - // Load xml-file - bool ok = false; - qDebug("QTLauncher::load xml"); - loader.load(APPLICATIONVIEW_XML, &ok); - - // Load Application View: - QGraphicsWidget *widget = loader.findWidget(APPLICATIONVIEW); - Q_ASSERT_X(ok && (widget != 0), "Launcher", "Invalid launcher.xml file"); - ApplicationView *applicationView = qobject_cast(widget); - - // Set enginewrappers pointer to applicationview and initialize it - applicationView->setEngine(engine); - applicationView->init(loader, commonActions); - - return applicationView; -} - -// --------------------------------------------------------------------------- - -ApplicationView::ApplicationView() - : mEngine(0), - mActionRefresh(0), - mActionLaunchApps(0), - mActionLaunchAndCloseApps(0), - mActionSkipHidden(0), - mActionDontSkipHidden(0), - mActionSelectAll(0), - mActionUnselectAll(0), - mActionOpenOutputView(0) -{ -} - -// --------------------------------------------------------------------------- - -void ApplicationView::setEngine(EngineWrapper *engine) -{ - mEngine = engine; -} - -// --------------------------------------------------------------------------- - -ApplicationView::~ApplicationView() -{ - if(mActionRefresh) - mActionRefresh->deleteLater(); - if(mActionLaunchApps) - mActionLaunchApps->deleteLater(); - if(mActionLaunchAndCloseApps) - mActionLaunchAndCloseApps->deleteLater(); - if(mActionSkipHidden) - mActionSkipHidden->deleteLater(); - if(mActionDontSkipHidden) - mActionDontSkipHidden->deleteLater(); - if(mActionSelectAll) - mActionSelectAll->deleteLater(); - if(mActionUnselectAll) - mActionUnselectAll->deleteLater(); - if(mActionOpenOutputView) - mActionOpenOutputView->deleteLater(); -} - -// --------------------------------------------------------------------------- - -void ApplicationView::init(HbDocumentLoader &loader, CommonActions *commonActions) -{ - // Load items from xml file - loadItemsFromXml(loader); - - // Set actions checkable and select "Skip hidden & embed" - mActionSkipHidden->setCheckable(true); - mActionSkipHidden->setChecked(true); - mActionDontSkipHidden->setCheckable(true); - - commonActions->addActionsToMenu(menu()); - - // Set list widget settings - mApplicationList->setClampingStyle(HbScrollArea::BounceBackClamping); - mApplicationList->setSelectionMode(HbAbstractItemView::MultiSelection); - - // Refresh application list - refreshAppList(); - - // Connect signals and slots - connectSignalsAndSlots(); - -} - -// --------------------------------------------------------------------------- - -void ApplicationView::refreshAppList() -{ - // Clear list - - mApplicationList->clear(); - QStringList apps; - - // show wait dialog - QObject *dialog = static_cast(Notifications::showWaitDialog("Initializing")); - - // Get application list from engine - if(!mEngine->listOfAllApps(apps)) { - Notifications::showErrorNote("Unable to refresh list"); - } - - // Format values to list widget - int i = 0; - while(i < apps.size()) { - mApplicationList->addItem(/*HbIcon(":/gfx/check.svg"),*/apps.at(i)); - i++; - } - mApplicationList->selectAll(); - - // remove the wait dialog - delete dialog; -} - -// --------------------------------------------------------------------------- - -void ApplicationView::connectSignalsAndSlots() -{ - // Actions - connect(mActionRefresh, SIGNAL(triggered()), this, SLOT(refreshAppList())); - connect(mActionLaunchApps, SIGNAL(triggered()), this, SLOT(launchSelectedApplications())); - connect(mActionLaunchAndCloseApps, SIGNAL(triggered()), this, SLOT(launchAndCloseSelectedApplications())); - connect(mActionSelectAll, SIGNAL(triggered()), this, SLOT(selectAllItems())); - connect(mActionUnselectAll, SIGNAL(triggered()), this, SLOT(unselectAllItems())); - connect(mActionSkipHidden, SIGNAL(triggered()), this, SLOT(launchOptionsSkipHidden())); - connect(mActionDontSkipHidden, SIGNAL(triggered()), this, SLOT(launchOptionsDontSkipHidden())); - connect(mActionOpenOutputView, SIGNAL(triggered()), this, SLOT(openOutputView())); -} - -// --------------------------------------------------------------------------- - - -void ApplicationView::loadItemsFromXml(HbDocumentLoader &loader) -{ - - // List widget: - QGraphicsWidget *widget = loader.findWidget(LISTVIEW); - Q_ASSERT_X((widget != 0), "Launcher", "Invalid launcher.xml file"); - mApplicationList = qobject_cast(widget); - - /* ACTIONS: */ - //refresh - QObject *object= loader.findObject(ACTIONREFRESH); - Q_ASSERT_X((object != 0), "Launcher", "Invalid launcher.xml file"); - mActionRefresh = qobject_cast(object); - - // launch applications - object= loader.findObject(ACTIONLAUNCHAPPS); - Q_ASSERT_X((object != 0), "Launcher", "Invalid launcher.xml file"); - mActionLaunchApps = qobject_cast(object); - - // launch and close - object= loader.findObject(ACTIONLAUNCHANDCLOSEAPPS); - Q_ASSERT_X((object != 0), "Launcher", "Invalid launcher.xml file"); - mActionLaunchAndCloseApps = qobject_cast(object); - - // select all applications - object= loader.findObject(ACTIONSELECT); - Q_ASSERT_X((object != 0), "Launcher", "Invalid launcher.xml file"); - mActionSelectAll = qobject_cast(object); - - // unselect all applications - object= loader.findObject(ACTIONUNSELECT); - Q_ASSERT_X((object != 0), "Launcher", "Invalid launcher.xml file"); - mActionUnselectAll = qobject_cast(object); - - // open output view - object= loader.findObject(ACTIONOPENOUTPUTVIEW); - Q_ASSERT_X((object != 0), "Launcher", "Invalid launcher.xml file"); - mActionOpenOutputView = qobject_cast(object); - - // skip hidden - object= loader.findObject(ACTIONSKIPHIDDEN); - Q_ASSERT_X((object != 0), "Launcher", "Invalid launcher.xml file"); - mActionSkipHidden = qobject_cast(object); - - // do not skip hidden - object= loader.findObject(ACTIONDONTSKIPHIDDEN); - Q_ASSERT_X((object != 0), "Launcher", "Invalid launcher.xml file"); - mActionDontSkipHidden = qobject_cast(object); - -} - -// --------------------------------------------------------------------------- - -void ApplicationView::launchSelectedApplications() -{ - QModelIndexList list = mApplicationList->selectionModel()->selectedIndexes(); - mEngine->startAppLaunching(list, false); -} - -// --------------------------------------------------------------------------- - -void ApplicationView::launchAndCloseSelectedApplications() -{ - QModelIndexList list = mApplicationList->selectionModel()->selectedIndexes(); - mEngine->startAppLaunching(list, true); -} - -// --------------------------------------------------------------------------- - -void ApplicationView::selectAllItems() -{ - mApplicationList->selectAll(); -} - -// --------------------------------------------------------------------------- - -void ApplicationView::unselectAllItems() -{ - mApplicationList->clearSelection(); -} -// --------------------------------------------------------------------------- - -void ApplicationView::launchOptionsSkipHidden() -{ - mActionSkipHidden->setChecked(true); - mActionDontSkipHidden->setChecked(false); - mEngine->setSkipHiddenAndEmbedOnly(true); -} - -// --------------------------------------------------------------------------- - -void ApplicationView::launchOptionsDontSkipHidden() -{ - mActionSkipHidden->setChecked(false); - mActionDontSkipHidden->setChecked(true); - mEngine->setSkipHiddenAndEmbedOnly(false); -} - -// --------------------------------------------------------------------------- - -void ApplicationView::openOutputView() -{ - qDebug("OpenOutputView"); - LauncherMainWindow *pMainWindow = static_cast< LauncherMainWindow * >( mainWindow() ); - if( pMainWindow ) - { - pMainWindow->openOutputView(); - } -} - -// --------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 launcher/src/applicationview.xml --- a/launcher/src/applicationview.xml Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,74 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r 819e59dfc032 -r 2d9cac8919d3 launcher/src/commonActions.cpp --- a/launcher/src/commonActions.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,143 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include -#include - -#include "hbaction.h" -#include "hbmenu.h" -#include "commonActions.h" -#include "notifications.h" -#include "enginewrapper.h" - -// --------------------------------------------------------------------------- - -CommonActions::CommonActions(EngineWrapper *engine, HbApplication *application) - : mEngine(engine), mApplication(application) -{ - - - mActionStopLaunch = new HbAction("Stop launch", this); - mActionSendLog = new HbAction("Send log", this); - mActionDeleteLog = new HbAction("Delete log", this); - mActionSendDllInfo = new HbAction("Send list of DLLs", this); - mActionCompareDllInfo = new HbAction("Dll BC analysis", this); - mActionAbout = new HbAction("About", this); - mActionExit = new HbAction("Exit", this); - - - connectSignalsAndSlots(); -} - -// --------------------------------------------------------------------------- - -CommonActions::~CommonActions() -{ -} - -// --------------------------------------------------------------------------- - -void CommonActions::showAbout() -{ - Notifications::about(); -} - -// --------------------------------------------------------------------------- - -void CommonActions::exit() -{ - mApplication->exit(); -} - -// --------------------------------------------------------------------------- - -void CommonActions::sendDllInfo() -{ - if (!mEngine->sendListOfDlls()) { - Notifications::showErrorNote("Unable to send list"); - } - -} - -// --------------------------------------------------------------------------- - -void CommonActions::compareDllInfo() -{ - mEngine->compareDlls(); -} - -// --------------------------------------------------------------------------- - -void CommonActions::sendLog() -{ - if (!mEngine->sendLog()) { - Notifications::showErrorNote("Unable to send log"); - } -} - -// --------------------------------------------------------------------------- - -void CommonActions::deleteLog() -{ - if (mEngine->deleteLog()) { - QString text = "Log file(s) deleted"; - Notifications::showInformationNote(text); - } - else { - QString text = "Unable to delete"; - Notifications::showErrorNote(text); - } -} - -// --------------------------------------------------------------------------- - -void CommonActions::stopLaunch() -{ - if (!mEngine->stopLaunching()) { - Notifications::showErrorNote("Unable to stop launching"); - } -} - -// --------------------------------------------------------------------------- - -void CommonActions::addActionsToMenu(HbMenu *menu) -{ - menu->addAction(mActionStopLaunch); - menu->addAction(mActionSendLog); - menu->addAction(mActionDeleteLog); - HbMenu *menuDllInfo = menu->addMenu("Dll Info"); - menuDllInfo->addAction(mActionSendDllInfo); - menuDllInfo->addAction(mActionCompareDllInfo); - menu->addAction(mActionAbout); - menu->addAction(mActionExit); -} - -// --------------------------------------------------------------------------- - -void CommonActions::connectSignalsAndSlots() -{ - connect(mActionStopLaunch, SIGNAL(triggered()), this, SLOT(stopLaunch())); - connect(mActionSendDllInfo, SIGNAL(triggered()), this, SLOT(sendDllInfo())); - connect(mActionCompareDllInfo, SIGNAL(triggered()), this, SLOT(compareDllInfo())); - connect(mActionSendLog, SIGNAL(triggered()), this, SLOT(sendLog())); - connect(mActionDeleteLog, SIGNAL(triggered()), this, SLOT(deleteLog())); - connect(mActionAbout, SIGNAL(triggered()), this, SLOT(showAbout())); - connect(mActionExit, SIGNAL(triggered()), this, SLOT( exit() ) ); -} - - -// --------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 launcher/src/enginewrapper.cpp --- a/launcher/src/enginewrapper.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,355 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "launchermainwindow.h" -#include "notifications.h" -#include "enginewrapper.h" - -// --------------------------------------------------------------------------- - -EngineWrapper::EngineWrapper(LauncherMainWindow* mainWindow) -: mEngine(0), - mMainWindow(mainWindow), - mProgressDialog(0), - mWaitDialog(0) -{ -} - -// --------------------------------------------------------------------------- - -EngineWrapper::~EngineWrapper() -{ - if (mEngine != NULL) { - delete mEngine; - mEngine = NULL; - } - if (mProgressDialog != NULL) { - delete mProgressDialog; - mProgressDialog = NULL; - } - if (mWaitDialog != NULL) { - delete mWaitDialog; - mWaitDialog = NULL; - } -} - -// --------------------------------------------------------------------------- - -bool EngineWrapper::init() -{ - - // construct engine - TRAPD(error, mEngine = CLauncherEngine::NewL(this)); - if (error != KErrNone) { - return false; - } - - return true; - -} - -// --------------------------------------------------------------------------- - -bool EngineWrapper::listOfAllApps(QStringList &allAppsQStringList){ - - // Get application CDesCArray list from engine - CDesCArray* allAppsCDescArray = 0; - TRAPD(error, allAppsCDescArray = mEngine->ListOfAllAppsL()); - if(error != KErrNone) { - return false; - } - - //convert CDesCArray to QStringList - for (int i = 0; i < allAppsCDescArray->Count(); i++) { - allAppsQStringList.append(QString::fromUtf16( - allAppsCDescArray->MdcaPoint(i).Ptr(), - allAppsCDescArray->MdcaPoint(i).Length())); - } - return true; -} - -// --------------------------------------------------------------------------- -bool EngineWrapper::startAppLaunching(const QModelIndexList &qList, bool autoClose) -{ - - // check if used has not selected any files - if (qList.size() == 0) { - Notifications::showErrorNote("Nothing selected"); - return false; - } - - bool retval(true); - CArrayFix* pArrayFix = NULL; - try{ - // Create CArrayFix for application numbers that are launched and Qlist into CArrayFix - QT_TRAP_THROWING( pArrayFix = QModelIndexListToCArrayFixL(qList) ); - - // Start launching applications - QT_TRAP_THROWING(mEngine->StartAppLaunchingL(pArrayFix, autoClose ? ETrue : EFalse)); - } - catch (const std::exception &e){ - qDebug() << "EngineWrapper::startAppLaunching - exception: " << e.what(); - retval = false; - } - - if(pArrayFix) - delete pArrayFix; - - return retval; -} - -// --------------------------------------------------------------------------- - -bool EngineWrapper::stopLaunching() -{ - TRAPD(error, mEngine->StopLaunchingL()); - if (error != KErrNone) { - return false; - } - else { - return true; - } -} - -// --------------------------------------------------------------------------- - -bool EngineWrapper::sendLog() -{ - ShareUi dialog; - QList fileList; - - if( mEngine->LogFileExists() ) - { - const TDesC& logFilePath = mEngine->LogFilePath(); - fileList.append( QString::fromUtf16( logFilePath.Ptr(), logFilePath.Length() ) ); - } - if( mEngine->BCLogFileExists() ) - { - const TDesC& BCLogFilePath = mEngine->BCLogFilePath(); - fileList.append( QString::fromUtf16( BCLogFilePath.Ptr(), BCLogFilePath.Length() ) ); - } - - if( !fileList.empty()){ - dialog.init(fileList,true); - return true; - } - else{ - return false; - } - -} - -// --------------------------------------------------------------------------- - -bool EngineWrapper::deleteLog() -{ - // if log file exists delete it. - if (mEngine->LogFileExists()) { - if (mEngine->DeleteLogFile() != KErrNone) { - return false; - } - } - - //if BC log file exists, delete it. - if (mEngine->BCLogFileExists()) { - if (mEngine->DeleteBCLogFile() != KErrNone) { - return false; - } - } - - return true; - -} - -// --------------------------------------------------------------------------- - -bool EngineWrapper::sendListOfDlls() -{ - const TDesC& systemDllsFilePath = mEngine->SystemDllsFilePath(); - - if ( BaflUtils::FileExists( CEikonEnv::Static()->FsSession(), systemDllsFilePath) ){ - ShareUi dialog; - QList fileList; - fileList.append( QString::fromUtf16( systemDllsFilePath.Ptr(), systemDllsFilePath.Length() ) ); - dialog.init(fileList,true); - return true; - } - else{ - Notifications::showErrorNote("DLL list does not exist"); - return false; - } -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::doCompareDlls(HbAction* action) - { - HbInputDialog *dlg = static_cast(sender()); - if( action && !action->text().compare("ok", Qt::CaseInsensitive) ) - { - TFileName fileName( dlg->value().toString().utf16() ); - TRAPD(error, mEngine->AnalyseDLLsL( fileName ) ); - if( error != KErrNone ) - { - HideWaitDialog(); - HideProgressBar(); - Notifications::showErrorNote( QString("Error in analyse: %1").arg( error ) ); - } - } - } - -// --------------------------------------------------------------------------- - -void EngineWrapper::compareDlls() -{ - const TDesC& requiredDllsFileName = mEngine->RequiredDllsFilePath(); - QString fileName = QString::fromUtf16( requiredDllsFileName.Ptr(), requiredDllsFileName.Length() ); - HbInputDialog::getText( "Select input file for BC analysis:", this, SLOT(doCompareDlls(HbAction*)), fileName ); -} - -// --------------------------------------------------------------------------- -void EngineWrapper::ShowProgressBar(const TDesC& descText, TInt minimum, TInt maximum) -{ - QString qStringText = XQConversions::s60DescToQString(descText); - - if(mProgressDialog){ - delete mProgressDialog; - mProgressDialog = NULL; - } - mProgressDialog = new HbProgressDialog( HbProgressDialog::ProgressDialog ); - - if( maximum > 0 ) - mProgressDialog->setRange(minimum, maximum); - //iProgressDialog->setAutoClose(true); - mProgressDialog->setText(qStringText); - connect(mProgressDialog, SIGNAL(cancelled()), this, SLOT(CancelDllBCanalysis())); - mProgressDialog->show(); -} - -// --------------------------------------------------------------------------- -void EngineWrapper::SetProgressBarValue(TInt value) -{ - if (mProgressDialog && value > 0 ){ - mProgressDialog->setProgressValue(value); - } -} - -// --------------------------------------------------------------------------- -void EngineWrapper::HideProgressBar() -{ - if (mProgressDialog != NULL) { - disconnect(mProgressDialog, SIGNAL(cancelled), this, SLOT(CancelDllBCanalysis())); - delete mProgressDialog; - mProgressDialog = NULL; - } -} - -// --------------------------------------------------------------------------- -void EngineWrapper::CancelDllBCanalysis() -{ - mEngine->CancelBCAnalysis(); -} - -// --------------------------------------------------------------------------- -void EngineWrapper::ShowWaitDialog(const TDesC& descText) -{ - QString qStringText = XQConversions::s60DescToQString(descText); - - if(mWaitDialog){ - delete mWaitDialog; - mWaitDialog = NULL; - } - mWaitDialog = Notifications::showWaitDialog(qStringText); -} - -// --------------------------------------------------------------------------- -void EngineWrapper::HideWaitDialog() -{ - if (mWaitDialog != NULL) { - delete mWaitDialog; - mWaitDialog = NULL; - } -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::setSkipHiddenAndEmbedOnly(bool skip) -{ - if(skip) { - mEngine->SetSkipHiddenAndEmbedOnly(ETrue); - } - else { - mEngine->SetSkipHiddenAndEmbedOnly(EFalse); - } -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::ChangeFocusToOutputView() -{ - mMainWindow->openOutputView(); -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::PrintText(const TDesC& descText) -{ - - // Convert the descriptor to QString - QString qStringText = XQConversions::s60DescToQString(descText); - mMainWindow->printText(qStringText); -} - -// --------------------------------------------------------------------------- - -CArrayFix* EngineWrapper::QModelIndexListToCArrayFixL(const QModelIndexList& qlist) -{ - CArrayFix* pArrayFix = new (ELeave) CArrayFixFlat( qlist.size() ); - CleanupStack::PushL(pArrayFix); - for (int j = 0; j < qlist.size(); j++) { - pArrayFix->AppendL(qlist.at(j).row()); - } - CleanupStack::Pop(pArrayFix); - return pArrayFix; -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::ShowErrorMessage(const TDesC& descText) -{ - QString qStringText = XQConversions::s60DescToQString(descText); - Notifications::showErrorNote(qStringText); -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::ShowInfoMessage(const TDesC& descText) -{ - QString qStringText = XQConversions::s60DescToQString(descText); - Notifications::showInformationNote(qStringText); -} - -// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 launcher/src/launchermainwindow.cpp --- a/launcher/src/launchermainwindow.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,121 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#include -#include -#include - -#include "enginewrapper.h" -#include "commonActions.h" -#include "applicationview.h" -#include "outputview.h" -#include "launchermainwindow.h" - -// Here we create custom document loader to be able to use custom views in XML. -class LauncherDocumentLoader : public HbDocumentLoader -{ -public: - virtual QObject *createObject(const QString& type, const QString &name); -}; - -QObject *LauncherDocumentLoader::createObject(const QString& type, const QString &name) -{ - // Application view - if (type == ApplicationView::staticMetaObject.className()) { - QObject *object = new ApplicationView; - object->setObjectName(name); - return object; - } - - // Output view - else if (type == OutputView::staticMetaObject.className()) { - QObject *object = new OutputView; - object->setObjectName(name); - return object; - } - - return HbDocumentLoader::createObject(type, name); -} - - -LauncherMainWindow::LauncherMainWindow( QWidget *parent ) : HbMainWindow( parent ) - ,mEngineWrapper(0) - ,mApplicationView(0) - ,mOutputView(0) - ,mCommonActions(0) - { - } - -LauncherMainWindow::~LauncherMainWindow () - { - if(mCommonActions) - delete mCommonActions; - if(mEngineWrapper) - delete mEngineWrapper; - } - -int LauncherMainWindow::init( HbApplication &app ) - { - - // Create Engine Wrapper and initialize it - mEngineWrapper = new EngineWrapper(this); - if (!mEngineWrapper->init()) { - return EXIT_FAILURE; - } - - // Create common actions class for actions that are used in all views of Launcher - mCommonActions = new CommonActions(mEngineWrapper, &app); - - // Create document loader - LauncherDocumentLoader loader; - - // Create application view - mApplicationView = ApplicationView::create(loader, mCommonActions, mEngineWrapper); - // Add view to main window - addView(mApplicationView); - - loader.reset(); - - // Create output view - mOutputView = OutputView::create(loader, mCommonActions); - // Add view to main window - addView(mOutputView); - - // Show ApplicationView at startup - setCurrentView(mApplicationView); - - // Show HbMainWindow - show(); - - return 0;// no errors - } - -void LauncherMainWindow::openApplicationView() - { - setCurrentView(mApplicationView); - } - -void LauncherMainWindow::openOutputView() - { - setCurrentView(mOutputView); - } - -void LauncherMainWindow::printText(const QString &text) - { - mOutputView->printText(text); - } diff -r 819e59dfc032 -r 2d9cac8919d3 launcher/src/main.cpp --- a/launcher/src/main.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include -#include - - -int main(int argc, char *argv[]) -{ - - // Create application, main window. - HbApplication app(argc, argv); - // Create main window - LauncherMainWindow mainWindow; - // init main window - int error = mainWindow.init(app); - if(error) - return error; - // enter event loop - return app.exec(); -} - diff -r 819e59dfc032 -r 2d9cac8919d3 launcher/src/notifications.cpp --- a/launcher/src/notifications.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,88 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#include -#include -#include - - -#include "notifications.h" - -// --------------------------------------------------------------------------- - -void Notifications::showMessageBox(HbMessageBox::MessageBoxType type, const QString &text, const QString &label, int timeout ) -{ - HbMessageBox *messageBox = new HbMessageBox(type); - messageBox->setText(text); - if(label.length()) - { - HbLabel *header = new HbLabel(label, messageBox); - messageBox->setHeadingWidget(header); - } - messageBox->setAttribute(Qt::WA_DeleteOnClose); - messageBox->setTimeout(timeout); - messageBox->open(); -} - -// --------------------------------------------------------------------------- - -void Notifications::about() -{ - Notifications::showMessageBox( - HbMessageBox::MessageTypeInformation, - "Version 4.0.1 - 21st May 2010. Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. Licensed under Eclipse Public License v1.0.", - "About Launcher" - ); -} - -// --------------------------------------------------------------------------- - -HbDeviceProgressDialog* Notifications::showWaitDialog(const QString &text) -{ - HbDeviceProgressDialog *note = new HbDeviceProgressDialog( HbProgressDialog::WaitDialog ); - note->setText( text ); - note->setAction(0); - note->show(); - return note; -} - -// --------------------------------------------------------------------------- - -void Notifications::showInformationNote(const QString &text) -{ - Notifications::showMessageBox( - HbMessageBox::MessageTypeInformation, - text, - "", // no label - 3000 - ); -} - -// --------------------------------------------------------------------------- - -void Notifications::showErrorNote(const QString &text) -{ - Notifications::showMessageBox( - HbMessageBox::MessageTypeWarning, - text, - "", // no label - 3000 - ); -} - -// --------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 launcher/src/outputview.cpp --- a/launcher/src/outputview.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,159 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include -#include -#include -#include -#include - -#include "enginewrapper.h" -#include "commonActions.h" -#include "outputview.h" - -// xml definition of view -const char *OUTPUTVIEW_XML = ":/xml/outputview.xml"; - -// name of the output view object in the xml file. -const char *OUTPUTVIEW = "outputview"; -const char *ACTIONCLEAR = "actionClearWindow"; -const char *TEXTOUTPUT = "textEdit"; -const char *ACTIONOPENAPPLICATIONVIEW = "actionOpenApplicationView"; - -// --------------------------------------------------------------------------- - - -OutputView::OutputView(): - mActionClear(0), - mActionOpenApplicationView(0), - mTextOutput(0) -{ - -} - -// --------------------------------------------------------------------------- - -OutputView::~OutputView() -{ - if(mActionClear) - mActionClear->deleteLater(); - if(mActionOpenApplicationView) - mActionOpenApplicationView->deleteLater(); -} - - -// --------------------------------------------------------------------------- - -OutputView* OutputView::create(HbDocumentLoader &loader, - CommonActions *commonActions) -{ - // Load application view from xml-file - bool ok = false; - loader.load(OUTPUTVIEW_XML, &ok); - - // Output View: - QGraphicsWidget *widget = loader.findWidget(OUTPUTVIEW); - Q_ASSERT_X(ok && (widget != 0), "Launcher", "Invalid launcher.xml file"); - OutputView *outputView = qobject_cast(widget); - - // initialize view - outputView->init(loader, commonActions); - - return outputView; -} - -// --------------------------------------------------------------------------- - - -void OutputView::loadItemsFromXml(HbDocumentLoader &loader) -{ - - // List widget: - QGraphicsWidget *widget = loader.findWidget(TEXTOUTPUT); - Q_ASSERT_X((widget != 0), "Launcher", "Invalid launcher.xml file"); - mTextOutput = qobject_cast(widget); - - // clear action: - QObject *object= loader.findObject(ACTIONCLEAR); - Q_ASSERT_X((object != 0), "Launcher", "Invalid launcher.xml file"); - mActionClear = qobject_cast(object); - - // open output view - object= loader.findObject(ACTIONOPENAPPLICATIONVIEW); - Q_ASSERT_X((object != 0), "Launcher", "Invalid launcher.xml file"); - mActionOpenApplicationView = qobject_cast(object); - -} - -// --------------------------------------------------------------------------- - - -void OutputView::init(HbDocumentLoader &loader, CommonActions *commonActions) -{ - loadItemsFromXml(loader); - connectSignalsAndSlots(); - - // set text edit components settings - mTextOutput->setPlainText("Ready.\n\n"); - mTextOutput->setReadOnly(true); - mTextOutput->setCursorVisibility( Hb::TextCursorHidden ); - mTextOutput->setAttribute(Qt::WA_InputMethodEnabled, false); - - // add actions to menu - commonActions->addActionsToMenu(menu()); - -} - -// --------------------------------------------------------------------------- - -void OutputView::connectSignalsAndSlots() -{ - // Clear action - connect(mActionClear, SIGNAL(triggered()), this, SLOT(clearOutput())); - connect(mActionOpenApplicationView, SIGNAL(triggered()), this, SLOT(openApplicationView())); -} - -// --------------------------------------------------------------------------- - -void OutputView::clearOutput() -{ - mTextOutput->setPlainText(""); -} - -// --------------------------------------------------------------------------- - -void OutputView::printText(const QString &text) -{ - QString newText = mTextOutput->toPlainText() + text; - mTextOutput->setPlainText(newText); - mTextOutput->setCursorPosition(newText.length()-1); -} - -// --------------------------------------------------------------------------- - -void OutputView::openApplicationView() -{ - qDebug("openApplicationView"); - LauncherMainWindow *pMainWindow = static_cast< LauncherMainWindow * >( mainWindow() ); - if( pMainWindow ) - { - pMainWindow->openApplicationView(); - } -} - -// --------------------------------------------------------------------------- - diff -r 819e59dfc032 -r 2d9cac8919d3 launcher/src/outputview.xml --- a/launcher/src/outputview.xml Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/engine/inc/loadgen.hrh --- a/loadgen/engine/inc/loadgen.hrh Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,190 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#ifndef LOADGEN_HRH -#define LOADGEN_HRH - -enum TLoadGenCommandIds - { - ELoadGenCmdNewLoad, - ELoadGenCmdNewLoadCPULoad, - ELoadGenCmdNewLoadEatMemory, - ELoadGenCmdNewLoadPhoneCall, - ELoadGenCmdNewLoadNetConn, - ELoadGenCmdNewLoadKeyPress, - ELoadGenCmdNewLoadMessages, - ELoadGenCmdNewLoadApplications, - ELoadGenCmdNewLoadPhotoCaptures, - ELoadGenCmdNewLoadBluetooth, - ELoadGenCmdNewLoadPointerEvent, - ELoadGenStopAll, - ELoadGenSuspendAll, - ELoadGenResumeAll, - - ELoadGenCmdLaunchPerfMon, - ELoadGenCmdAbout, - - ELoadGenCmdSettingsChange, - ELoadGenCmdSettingsExit, - ELoadGenCmdSettingsBack, - - ELoadGenSettingItemList - }; - -enum TEditorFormItemIds - { - ELoadGenCPULoadQueryPriority = 1000, - ELoadGenCPULoadQueryMode, - ELoadGenCPULoadQueryType, - ELoadGenCPULoadQueryLength, - ELoadGenCPULoadQueryIdle, - ELoadGenCPULoadQueryVariance, - ELoadGenCPULoadQueryCpu, - - ELoadGenMemoryEatQueryPriority, - ELoadGenMemoryEatQuerySource, - ELoadGenMemoryEatQueryType, - ELoadGenMemoryEatQueryBuffer, - ELoadGenMemoryEatQueryIdle, - ELoadGenMemoryEatQueryAmount, - ELoadGenMemoryEatQueryRandomMin, - ELoadGenMemoryEatQueryRandomMax, - ELoadGenMemoryEatQueryVariance, - - ELoadGenPhoneCallQueryPriority, - ELoadGenPhoneCallQueryDestination, - ELoadGenPhoneCallQueryLength, - ELoadGenPhoneCallQueryIdle, - ELoadGenPhoneCallQueryVariance, - - ELoadGenNetConnQueryPriority, - ELoadGenNetConnQueryDestination, - ELoadGenNetConnQueryIdle, - ELoadGenNetConnQueryVariance, - - ELoadGenKeyPressQueryPriority, - ELoadGenKeyPressQueryHeartBeat, - ELoadGenKeyPressQueryVariance, - - ELoadGenMessagesQueryPriority, - ELoadGenMessagesQueryType, // Message type - ELoadGenMessagesQueryDestination, // Phone number - ELoadGenMessagesQueryAmount, // Messages - ELoadGenMessagesQueryLength, // Message length - ELoadGenMessagesQueryMessage, // Message - ELoadGenMessagesQueryIdle, // idle period - ELoadGenMessagesQueryVariance, - - ELoadGenApplicationsQueryPriority, - ELoadGenApplicationsLaunchingInterval, - ELoadGenApplicationsKeyPressQueryHeartBeat, - ELoadGenApplicationsMaxOpen, - ELoadGenApplicationsKeyPressType, - ELoadGenApplicationsQueryVariance, - - ELoadGenPhotoCaptureQueryPriority, - ELoadGenPhotoCaptureQueryDevice, - ELoadGenPhotoCaptureQueryIdle, - ELoadGenPhotoCaptureQueryVariance, - - ELoadGenBluetoothQueryPriority, - ELoadGenBluetoothQueryIdle, - ELoadGenBluetoothQueryVariance, - - ELoadGenPointerEventQueryPriority, - ELoadGenPointerEventQueryHeartBeat, - ELoadGenPointerEventQueryVariance - }; - -enum TItemActionMenuTypes - { - EItemActionMenuTypeStop = 0, - EItemActionMenuTypeSuspendResume, - EItemActionMenuTypeEdit - }; - -enum TThreadPriorityTypes - { - EThreadPriorityTypeMuchLess = 0, - EThreadPriorityTypeLess, - EThreadPriorityTypeNormal, - EThreadPriorityTypeMore, - EThreadPriorityTypeMuchMore, - EThreadPriorityTypeRealTime, - EThreadPriorityTypeAbsoluteVeryLow, - EThreadPriorityTypeAbsoluteLow, - EThreadPriorityTypeAbsoluteBackground, - EThreadPriorityTypeAbsoluteForeground, - EThreadPriorityTypeAbsoluteHigh - }; - -enum TCpuLoadMode - { - ECpuLoadModeYielding = 0, - ECpuLoadModeBlocking - }; - -enum TCpuLoadTypes - { - ECpuLoadTypeContinuous = 0, - ECpuLoadTypePeriodic - }; - -enum TMemoryEatTypes - { - EMemoryEatTypeMemoryToEat = 0, - EMemoryEatTypeMemoryToBeLeft, - EMemoryEatTypeWavy - }; - -enum TMemoryEatSourceTypes - { - EMemoryEatSourceTypeRAM = 0, - EMemoryEatSourceTypeDriveC, - EMemoryEatSourceTypeDriveD, - EMemoryEatSourceTypeDriveE, - EMemoryEatSourceTypeDriveF, - EMemoryEatSourceTypeDriveG, - EMemoryEatSourceTypeDriveH, - EMemoryEatSourceTypeDriveI, - EMemoryEatSourceTypeDriveJ, - EMemoryEatSourceTypeDriveK, - EMemoryEatSourceTypeDriveL, - EMemoryEatSourceTypeDriveM, - EMemoryEatSourceTypeDriveN - }; - -enum TMessageTypes - { - EMessageTypeSMS = 0, - EMessageTypeMMS - }; - -enum TApplicationsKeyPressTypes - { - EApplicationsKeyPressTypeNone = 0, - EApplicationsKeyPressTypeArrows - }; - -enum TApplicationsEventTypes - { - EApplicationsCloseApplication = 0, - EApplicationsLaunchApplication - }; - -#endif // LOADGEN_HRH diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/engine/inc/loadgen_applications.h --- a/loadgen/engine/inc/loadgen_applications.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,197 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - -#ifndef LOADGEN_APPLICATIONS_H -#define LOADGEN_APPLICATIONS_H - -// INCLUDES -#include -#include -#include - -#include "loadgen_loadbase.h" -#include "loadgen_loadattributes.h" - - -// FORWARD DECLARATIONS -class CLauncherEngine; - -// CLASS DECLARATIONS - -class CAppLauncher : public CLoadBase - { -public: - static CAppLauncher* NewL( TApplicationsAttributes& aAttributes, - TInt aReferenceNumber ); - virtual ~CAppLauncher(); - -private: // Constructors - CAppLauncher( TApplicationsAttributes& aAttributes, - TInt aReferenceNumber ); - void ConstructL(); - -public: // New methods - virtual void Resume(); - virtual void Suspend(); - virtual void SetPriority(); - virtual void Close(); - virtual TPtrC Description(); - inline TApplicationsAttributes& Attributes() { return iAttributes; } - inline void SetAttributes(const TApplicationsAttributes& aAttributes) { iAttributes = aAttributes; } - - -public: // New static methods - static TInt ThreadFunction( TAny* aThreadArg ); - -private: // New static methods - static void GenerateLoad( TApplicationsAttributes& aAttributes ); - -private: // Data - TApplicationsAttributes iAttributes; - RThread iThread; - }; - -// Class to start launching applications in given period - -// CLASS DECLARATIONS -class CAppLauncherManager : public CActive - { -public: - static CAppLauncherManager* NewL( TApplicationsAttributes& aAttributes ); - ~CAppLauncherManager(); - -private: - CAppLauncherManager( TApplicationsAttributes& aAttributes ); - void ConstructL(); - -private: - void RunL(); - void DoCancel(); - -private: - static TInt PeriodicTimerCallBack( TAny* aAny ); - void SimulateEventL(); - -public: - inline CPeriodic* PeriodicTimer() { return iPeriodicTimer; } - -private: - TApplicationsAttributes& iAttributes; - CPeriodic* iPeriodicTimer; - RWsSession iWsSession; - CLauncherEngine* iLauncherEngine; - TInt iAppEventType; - }; - -// A class where applicationg launching and ending is implemented -#include -#include - -// FORWARD DECLARATIONS -class CAppKeyPressManager; - -// CLASS DECLARATIONS -class CLauncherEngine : public CBase - { -public: - static CLauncherEngine* NewL( TApplicationsAttributes& aAttributes ); - ~CLauncherEngine(); - -public: - void StartAppLaunchingL(); - void StopApplication( TBool aRandomApplication ); - - -private: - CLauncherEngine( TApplicationsAttributes& aAttributes ); - void ConstructL(); - TBool LaunchApplicationL(); - void DoLaunchApplicationL(); - -public: - inline TInt AppLaunchCounter() { return iAppLaunchCounter; } - -private: - RTimer iTimer; - RApaLsSession iLs; - RWsSession iWs; - TInt iAppLaunchCounter; - TUid iCurrentAppUid; - TThreadId iCurrentAppThreadId; - TBuf<128> iCurrentAppNameAndExt; - RThread iCurrentAppThread; - TInt iParallelApplicationsCounter; - TApplicationsAttributes& iAttributes; - - CAppKeyPressManager* iAppKeyPressManager; - }; - - -// A class where key presses can be added to application -#include -// FORWARD DECLARATIONS -class CApplicationKeyPresses; -// CLASS DECLARATIONS -class CAppKeyPressManager : public CBase - { -public: - static CAppKeyPressManager* NewL( TApplicationsAttributes& aAttributes ); - ~CAppKeyPressManager(); - void AddNewApplicationUidToKeyEventsL( TUid aUid ); - TUid KillApplication( TBool aRandomApplication ); - -private: - CAppKeyPressManager( TApplicationsAttributes& aAttributes ); - void ConstructL(); - -private: - RPointerArray iKeyPresses; - TApplicationsAttributes& iAttributes; - }; - -// A class which sends key press events to application -// CLASS DECLARATIONS -class CApplicationKeyPresses : public CBase - { -public: - static CApplicationKeyPresses* NewL( TUid aUid, - TApplicationsAttributes& aAttributes ); - ~CApplicationKeyPresses(); - -private: - CApplicationKeyPresses( TUid aUid, TApplicationsAttributes& aAttributes ); - void ConstructL(); - -private: - static TInt PeriodicTimerCallBack( TAny* aAny ); - void SimulateKeyEvent(); - -public: - inline CPeriodic* PeriodicTimer() { return iPeriodicTimer; } - -private: - TUid iUid; - TApplicationsAttributes& iAttributes; - CPeriodic* iPeriodicTimer; - RWsSession iWsSession; -public: - inline TUid ApplicationUid() { return iUid; }; - }; - -#endif // LOADGEN_APPLICATIONS diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/engine/inc/loadgen_bluetooth.h --- a/loadgen/engine/inc/loadgen_bluetooth.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,108 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - -#ifndef LOADGEN_BLUETOOTH_H -#define LOADGEN_BLUETOOTH_H - -// INCLUDES -#include -#include -#include -#include "loadgen_loadbase.h" -#include "loadgen_loadattributes.h" -#include -#include - -// FORWARD DECLARATIONS - -// CLASS DECLARATIONS - -class CBluetooth : public CLoadBase - { -public: - static CBluetooth* NewL(TBluetoothAttributes& aAttributes, TInt aReferenceNumber); - virtual ~CBluetooth(); - -private: // Constructors - CBluetooth(TBluetoothAttributes& aAttributes, TInt aReferenceNumber); - void ConstructL(); - -public: // New methods - virtual void Resume(); - virtual void Suspend(); - virtual void SetPriority(); - virtual void Close(); - virtual TPtrC Description(); - inline TBluetoothAttributes& Attributes() { return iAttributes; } - inline void SetAttributes(const TBluetoothAttributes& aAttributes) { iAttributes = aAttributes; } - -public: // New static methods - static TInt ThreadFunction(TAny* aThreadArg); - -private: // New static methods - static void GenerateLoad(TBluetoothAttributes& aAttributes); - void InitializeBluetoothL(); - TBool SetBTPowerState(TBool aState); - -private: // Data - - TBluetoothAttributes iAttributes; - RThread iThread; - }; - - - - -class CBTManager : public CActive//, public MBTPowerManagerObserver - { - public: - - static CBTManager* NewL(TBluetoothAttributes& aAttrs); - virtual ~CBTManager(); - - private: - - CBTManager( TBluetoothAttributes& aAttrs); - void ConstructL(); - TInt StartBTDeviceDiscovery(); - - private: - - static TInt PeriodicTimerCallBack(TAny* aAny); - public: - - /** - * From CActive: - */ - void RunL(); - void DoCancel(); - - private: - - CPeriodic* iPeriodicTimer; - TBluetoothAttributes& iAttributes; - CRepository* iBTPowerStateCRepo; - RSocketServ iSocketServerHnd; - RHostResolver iHostResolver; - TNameEntry iBTNameEntry; - }; - - -#endif - diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/engine/inc/loadgen_cpuload.h --- a/loadgen/engine/inc/loadgen_cpuload.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,69 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - -#ifndef LOADGEN_CPULOAD_H -#define LOADGEN_CPULOAD_H - -// INCLUDES -#include -#include - -#include "loadgen_loadbase.h" -#include "loadgen_loadattributes.h" - - -// FORWARD DECLARATIONS - - - -// CLASS DECLARATIONS - -class CCPULoad : public CLoadBase - { -public: - static CCPULoad* NewL(TCPULoadAttributes& aAttributes, TInt aReferenceNumber); - virtual ~CCPULoad(); - -private: // Constructors - CCPULoad(TCPULoadAttributes& aAttributes, TInt aReferenceNumber); - void ConstructL(); - -public: // New methods - virtual void Resume(); - virtual void Suspend(); - virtual void SetPriority(); - virtual void Close(); - virtual TPtrC Description(); - inline TCPULoadAttributes& Attributes() { return iAttributes; } - inline void SetAttributes(const TCPULoadAttributes& aAttributes) { iAttributes = aAttributes; } - -public: // New static methods - static TInt ThreadFunction(TAny* aThreadArg); - -private: // New static methods - static void GenerateLoad(TCPULoadAttributes& aAttributes); - static void DoHeaveStuff(TInt aMode); - -private: // Data - TCPULoadAttributes iAttributes; - RThread iThread; - }; - - -#endif diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/engine/inc/loadgen_httpreceiver.h --- a/loadgen/engine/inc/loadgen_httpreceiver.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,183 +0,0 @@ - - -#ifndef CHTTPReceiver_H -#define CHTTPReceiver_H - -#include -#include -#include -#include -#include - -// CONSTANTS -// None. - -// MACROS -#ifdef _DEBUG -#define TRACE( text ) RDebug::Printf( text ); -#define TRACE2( text, arg ) RDebug::Printf( text, arg ); -#else -#define TRACE( text ) -#define TRACE2( text, arg ) -#endif - -// DATA TYPES -// None. - -// FUNCTION PROTOTYPES -// None. - -// FORWARD DECLARATIONS -// None. - -class MHTTPRecvObserver - { - public: - - /** - * Callback for HTTP response received. - * @param aStatus Status code. - * @return None. - */ - virtual void HTTPFileReceived( TInt aStatus ) = 0; - }; - -// CLASS DECLARATION - -class CHTTPReceiver - : public CBase, - public MHTTPTransactionCallback - { - public: // Constructors and destructor - - /** - * Two-phased constructor. - */ - static CHTTPReceiver* NewL( MHTTPRecvObserver& aObserver ); - - /** - * Two-phased constructor. - */ - static CHTTPReceiver* NewLC( MHTTPRecvObserver& aObserver ); - - /** - * Destructor. - */ - virtual ~CHTTPReceiver(); - - /** - * Cancels the current HTTP transaction. - */ - void CancelTransaction(); - - /** - * Opens a connection to destination aUri and sends data using HTTP GET. - * Callbacks via MHTTPRecvObserver::HTTPFileReceived - * Leaves with KErrNotReady If network is not available - * @param aUri Destination URL, if http scheme not specified, prepends scheme. - */ - void SendHTTPGetL( const TDesC8& aUri ); - - protected: // Constructors and destructor - - /** - * C++ default constructor. - */ - CHTTPReceiver( MHTTPRecvObserver& aObserver ); - - /** - * Symbian 2nd phase constructor. - */ - void ConstructL(); - - /** - * Sets HTTP header fields. - * @param aHeaders HTTP headers. - * @param aHdrField Header field to set. - * @param aHdrValue Header field value. - */ - void SetHeaderL(RHTTPHeaders aHeaders, TInt aHdrField, - const TDesC8& aHdrValue); - - //From MHTTPTransactionCallback - /** - * Called by HTTP framework when HTTP events occur. - * @param aTransaction The transaction that the event has occurred on. - * @param aEvent The event that has occurred. - */ - void MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent& aEvent); - - /** - * Called when RunL leaves from a transaction event. - * @param aError The leave code that RunL left with. - * @param aTransaction The transaction that was being processed. - * @param aEvent The event that was being processed. - * @return KErrNone. - */ - TInt MHFRunError( TInt aError, - RHTTPTransaction aTransaction, - const THTTPEvent& aEvent); - - /** - * Starts HTTP connection. - */ - void SetupConnectionL(); - - /** - * Utility:Checks for http uri scheme and prepends if not exists to the url - * @param aUri UriParser. - * @param aURL URL to check for. - * @return None - */ - void CheckForHTTPSchemeL(TUriParser8& aUri, const TDesC8& aURL); - - /** - * Utility: finish receiving, call calback HTTPFileReceived() - * @param aError to be signaled - * @return None - */ - void Finalize(); - - private: - - // Request uri, might need to prepend http scheme. - HBufC8* iUrl; - - // RSocketServ object. - RSocketServ iSocketServ; - - // RConnection object. - RConnection iConnection; - - // HTTP session. - RHTTPSession iSession; - - // HTTP transaction used for request. - RHTTPTransaction iTransaction; - - // Observer to notify. - MHTTPRecvObserver& iObserver; - - // ETrue if transaction in progress. - TBool iRunning; - - // ETrue if connection set up done. - TBool iConnectionSetupDone; - - // Response Status - TInt iResponseStatus; - -#ifdef _DEBUG - // Http response body written to file - RFile iResponseFile; - - // RFs to be used for writing to iResponseFile - RFs iFs; -#endif - -}; - -#endif - -// CHTTPReceiver_H -// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/engine/inc/loadgen_keypress.h --- a/loadgen/engine/inc/loadgen_keypress.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,95 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#ifndef LOADGEN_KEYPRESS_H -#define LOADGEN_KEYPRESS_H - -// INCLUDES -#include -#include -#include - -#include "loadgen_loadbase.h" -#include "loadgen_loadattributes.h" - - -// FORWARD DECLARATIONS - - - -// CLASS DECLARATIONS - -class CKeyPress : public CLoadBase - { -public: - static CKeyPress* NewL(TKeyPressAttributes& aAttributes, TInt aReferenceNumber); - virtual ~CKeyPress(); - -private: // Constructors - CKeyPress(TKeyPressAttributes& aAttributes, TInt aReferenceNumber); - void ConstructL(); - -public: // New methods - virtual void Resume(); - virtual void Suspend(); - virtual void SetPriority(); - virtual void Close(); - virtual TPtrC Description(); - inline TKeyPressAttributes& Attributes() { return iAttributes; } - inline void SetAttributes(const TKeyPressAttributes& aAttributes) { iAttributes = aAttributes; } - -public: // New static methods - static TInt ThreadFunction(TAny* aThreadArg); - -private: // New static methods - static void GenerateLoad(TKeyPressAttributes& aAttributes); - -private: // Data - TKeyPressAttributes iAttributes; - RThread iThread; - }; - - -class CKeyPressManager : public CActive - { -public: - static CKeyPressManager* NewL(TKeyPressAttributes& aAttributes); - ~CKeyPressManager(); - -private: - CKeyPressManager(TKeyPressAttributes& aAttributes); - void ConstructL(); - -private: - void RunL(); - void DoCancel(); - -private: - static TInt PeriodicTimerCallBack(TAny* aAny); - void SimulateKeyEvent(); - -public: - inline CPeriodic* PeriodicTimer() { return iPeriodicTimer; } - -private: - TKeyPressAttributes& iAttributes; - CPeriodic* iPeriodicTimer; - RWsSession iWsSession; - }; - -#endif diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/engine/inc/loadgen_loadattributes.h --- a/loadgen/engine/inc/loadgen_loadattributes.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,167 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#ifndef LOADGEN_LOADATTRIBUTES_H -#define LOADGEN_LOADATTRIBUTES_H - -// INCLUDES -#include -#include -#include // CDesCArray - -const TInt KCPUSelection_FreeScheduling = -1; -const TInt KCPUSelection_AllCPUs = 999; - -// FORWARD DECLARATIONS - - -// CLASS DECLARATIONS -class TCPULoadAttributes - { -public: - TUint iId; - TUint iPriority; - TUint iMode; - TUint iType; - TUint iLength; - TUint iIdle; - TUint iRandomVariance; - // iCpu defines in which CPU the load thread should be executed in - // (in SMP environments). 0 = CPU0, 1 = CPU1 etc. Negative value means - // that CPU is undefined. When CPU is undefined, Scheduler can schedule - // the load thread freely to any CPU as it pleases. - TInt iCpu; - // Defines how many CPUs the running system has. - TUint iCpuCount; - }; - -class TMemoryEatAttributes - { -public: - TUint iId; - TUint iPriority; - TUint iSource; - TUint iType; - TUint iBuffer; - TUint iIdle; - TInt64 iAmount; - TInt64 iRandomMin; - TInt64 iRandomMax; - TBuf<64> iAmountDes; - TBuf<64> iRandomMinDes; - TBuf<64> iRandomMaxDes; - TUint iRandomVariance; - TRequestStatus* iDeathStatus; - }; - -class TPhoneCallAttributes - { -public: - TUint iId; - TUint iPriority; - TBuf<128> iDestination; - TUint iLength; - TUint iIdle; - TUint iRandomVariance; - TRequestStatus* iDeathStatus; - }; - -class TNetConnAttributes - { -public: - TUint iId; - TUint iPriority; - TBuf<128> iDestination; - TUint iIdle; - TUint iRandomVariance; - TRequestStatus* iDeathStatus; - }; - -class TKeyPressAttributes - { -public: - TUint iId; - TUint iPriority; - TUint iHeartBeat; - TUint iRandomVariance; - TRequestStatus* iDeathStatus; - }; - -class TPointerEventAttributes - { -public: - TUint iId; - TUint iPriority; - TUint iHeartBeat; - TUint iRandomVariance; - TRequestStatus* iDeathStatus; - }; - -class TMessageAttributes - { -public: - TUint iId; - TInt iMessageType; - TBuf<128> iDestination; - TUint iPriority; - TUint iAmount; - TInt iLength; - TUint iIdle; - TUint iRandomVariance; - TRequestStatus* iDeathStatus; - }; - -class TApplicationsAttributes - { -public: - TUint iId; - TUint iPriority; - TUint iLaunchingInterval; - TUint iKeyPressType; - TUint iMaxOpen; - TUint iHeartBeat; - TUint iRandomVariance; - CDesCArray* iAppsArray; - TRequestStatus* iDeathStatus; - }; - - -class TPhotoCaptureAttributes - { -public: - TUint iId; - TInt iPriority; - TInt iCameraCount; - TInt iCamera; - TUint iIdle; - TUint iRandomVariance; - TRequestStatus* iDeathStatus; - }; - -class TBluetoothAttributes - { -public: - TUint iId; - TInt iPriority; - TUint iIdle; - TUint iRandomVariance; - TRequestStatus* iDeathStatus; - TBool iBluetoothSupported; - }; - -#endif diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/engine/inc/loadgen_loadbase.h --- a/loadgen/engine/inc/loadgen_loadbase.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,66 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#ifndef LOADGEN_LOADBASE_H -#define LOADGEN_LOADBASE_H - -// INCLUDES -#include -#include - -#include "loadgen_loadbase.h" - - -// FORWARD DECLARATIONS - - - -// CLASS DECLARATIONS - -class CLoadBase : public CBase - { -public: - enum TLoadState - { - ELoadStateInvalid = -1, - ELoadStateConstructed, - ELoadStateRunning, - ELoadStateSuspended, - ELoadStateClosed - }; - -protected: // Constructors - CLoadBase(); - void ConstructL(); - -public: // New methods - virtual void Resume(); - virtual void Suspend(); - virtual void SetPriority(); - virtual void Close(); - virtual TPtrC Description(); - inline TInt State() { return iState; } - inline TInt Type() { return iType; } - -protected: // Data - TInt iState; - TInt iType; - }; - - -#endif diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/engine/inc/loadgen_memoryeat.h --- a/loadgen/engine/inc/loadgen_memoryeat.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,108 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#ifndef LOADGEN_MEMORYEAT_H -#define LOADGEN_MEMORYEAT_H - -// INCLUDES -#include -#include -#include -#include - -#include "loadgen_loadbase.h" -#include "loadgen_loadattributes.h" - - -// FORWARD DECLARATIONS - - - -// CLASS DECLARATIONS - -class CMemoryEat : public CLoadBase - { -public: - static CMemoryEat* NewL(TMemoryEatAttributes& aAttributes, TInt aReferenceNumber); - virtual ~CMemoryEat(); - -private: // Constructors - CMemoryEat(TMemoryEatAttributes& aAttributes, TInt aReferenceNumber); - void ConstructL(); - -public: // New methods - virtual void Resume(); - virtual void Suspend(); - virtual void SetPriority(); - virtual void Close(); - virtual TPtrC Description(); - inline TMemoryEatAttributes& Attributes() { return iAttributes; } - inline void SetAttributes(const TMemoryEatAttributes& aAttributes) { iAttributes = aAttributes; } - -public: // New static methods - static TInt ThreadFunction(TAny* aThreadArg); -private: - static void GenerateLoad(TMemoryEatAttributes& aAttributes); - -private: // Data - TMemoryEatAttributes iAttributes; - RThread iThread; - }; - - -class CMemoryEatManager : public CActive - { -public: - static CMemoryEatManager* NewL(TMemoryEatAttributes& aAttributes); - ~CMemoryEatManager(); - -private: - CMemoryEatManager(TMemoryEatAttributes& aAttributes); - void ConstructL(); - -private: - void RunL(); - void DoCancel(); - -private: - static TInt PeriodicTimerCallBack(TAny* aAny); - void InitMemoryEatL(); - void DestroyMemoryEat(); - void EatMemoryL(); - void DoEatMemoryL( TInt64 aNewSize ); - void HandleEatMemoryL( TInt64 aNewSize ); - void AllocMemoryL( TInt64 aNewSize ); - void FreeMemoryL( TInt64 aNewSize ); - TInt64 ReadFreeMemory(); - - -public: - inline CPeriodic* PeriodicTimer() { return iPeriodicTimer; } - -private: - TMemoryEatAttributes& iAttributes; - CPeriodic* iPeriodicTimer; - RChunk iEatChunk; - RFile iEatFile; - RFs iFs; - TBool iWavyEatMoreMemory; - TInt iFilesCounter; - }; - - -#endif diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/engine/inc/loadgen_messages.h --- a/loadgen/engine/inc/loadgen_messages.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,422 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#ifndef LOADGEN_MESSAGES_H -#define LOADGEN_MESSAGES_H - -// INCLUDES -#include -#include - -#include "loadgen_loadbase.h" -#include "loadgen_loadattributes.h" - - -// FORWARD DECLARATIONS -class CSmsHandler; -class CMmsHandler; - -const TInt EMaxMessageLength = 512; - -// CLASS DECLARATIONS - -class CMessages : public CLoadBase - { -public: - static CMessages* NewL( TMessageAttributes& aAttributes, TInt aReferenceNumber ); - virtual ~CMessages(); - -private: // Constructors - CMessages( TMessageAttributes& aAttributes, TInt aReferenceNumber ); - void ConstructL(); - -public: // New methods - virtual void Resume(); - virtual void Suspend(); - virtual void SetPriority(); - virtual void Close(); - virtual TPtrC Description(); - inline TMessageAttributes& Attributes() { return iAttributes; } - inline void SetAttributes(const TMessageAttributes& aAttributes) { iAttributes = aAttributes; } - -public: // New static methods - static TInt ThreadFunction( TAny* aThreadArg ); - -private: // New static methods - static void GenerateLoad( TMessageAttributes& aAttributes ); - -private: // Data - TMessageAttributes iAttributes; - RThread iThread; - - }; - - -class CMessageManager : public CActive - { -private: - enum TState - { - EStateIdle = 0, - EStateSend, - EStateSending - }; -public: - static CMessageManager* NewL( TMessageAttributes& aAttributes ); - virtual ~CMessageManager(); - - -private: - CMessageManager( TMessageAttributes& aAttributes ); - void ConstructL(); - -private: - void RunL(); - void DoCancel(); - -private: - static TInt PeriodicTimerCallBack( TAny* aAny ); - void HandleMessageSending(); - void DoDial(); - void DoHangup(); - void CreateMessage(); - -public: - inline CPeriodic* PeriodicTimer() { return iPeriodicTimer; } - void HandleStatus( TInt aErr ); - -private: - TMessageAttributes& iAttributes; - CPeriodic* iPeriodicTimer; - TInt iState; - CSmsHandler* iSmsHandler; - CMmsHandler* iMmsHandler; - TInt iMessageCounter; - HBufC* iMessage; - }; - -// INCLUDES -#include -#include -#include -#include -// CONSTANTS -const TInt KBfrLength = 20; -const TInt KTelephoneNumberMaxLength = 100; - -// FORWARD DECLARATIONS -class CSmsAppUi; -class CClientMtmRegistry; -class CSmsClientMtm; - -// CLASS DECLARATION -/** -* CSmsHandler application engine class. -* Takes care of sending and receiveing SMS messages using the SMS client MTM. -* Interacts with the application UI class. -*/ -class CSmsHandler : public CActive, public MMsvSessionObserver - { - public: // Constructors and destructor - - /** - * NewL. - * Two-phased constructor. - * @param aSmsAppUi Pointer to AppUi instance. - * @return Pointer to the created instance of CSmsHandler. - */ - static CSmsHandler* NewL( CMessageManager& aManager ); - - /** - * NewLC. - * Two-phased constructor. - * @param aSmsAppUi Pointer to AppUi instance. - * @return Pointer to the created instance of CSmsHandler. - */ - static CSmsHandler* NewLC( CMessageManager& aManager ); - - /** - * ~CSmsHandler - * Destructor. - */ - virtual ~CSmsHandler(); - - public: // New functions - /** - * SendL. - * Starts the process of creating and sending an SMS message. - * @param aRecipientNumber The number of the recipent. - * @param aMessageText The message text. - * @return ETrue if successful, EFalse if not. - */ - TBool SendL( const TDesC& aRecipientNumber, - const TDesC& aMessageText ); - - public: // Functions from base classes - - /** - * From MMsvSessionObserver, HandleSessionEventL. - * Handles notifications of events from the Message Server. - * @param aEvent The event that has taken place - * @param aArg1 Event type-specific argument value - * @param aArg2 Event type-specific argument value - * @param aArg3 Event type-specific argument value - */ - void HandleSessionEventL( TMsvSessionEvent aEvent, TAny* aArg1, - TAny* aArg2, TAny* aArg3 ); - - protected: // Functions from base classes - - /** - * From CActive, DoCancel. - * Cancels any outstanding requests. - */ - void DoCancel(); - - /** - * From CActive, RunL. - * Handles an active object’s request completion event. - */ - void RunL(); - - private: // Constructors - - /** - * CSmsHandler. - * C++ default constructor. - * @param aSmsAppUi Pointer to AppUi instance. - */ - CSmsHandler( CMessageManager& aManager ); - - /** - * ConstructL. - * 2nd phase constructor. - */ - void ConstructL(); - - private: // New functions - - /** - * AccessMtmL. - * Access the MTM Registry and create an SMS specific Client MTM instance. - */ - void AccessMtmL(); - - /** - * CreateMsgL. - * Create an SMS message. - * @return ETrue if successful, EFalse is unsuccessful. - */ - TBool CreateMsgL(); - - /** - * ScheduleL. - * Schedule an SMS message for sending. - */ - void ScheduleL(); - - /** - * ValidateL. - * Validate an SMS message. - * @return ETrue if successful, EFalse is unsuccessful. - */ - TBool ValidateL(); - - private: // Enumeration - - /** - * TState, enumeration for the state of the handler, used by RunL(). - */ - enum TState - { - EWaitingForMoving = 1, - EWaitingForScheduling - }; - - private: // Data - - /** - * iState, the state of the handler. - */ - TState iState; - - /** - * iSession, the contact database. - * Owned by CSmsHandler object. - */ - CMsvSession* iSession; - - /** - * iMtmRegistry, client MTM registry. - * Owned by CSmsHandler object. - */ - CClientMtmRegistry* iMtmRegistry; - - /** - * iSmsMtm, SMS specific Client MTM. - * Owned by CSmsHandler object. - */ - CSmsClientMtm* iSmsMtm; - - /** - * iOperation, the current message server operation. - * Owned by CSmsHandler object. - */ - CMsvOperation* iOperation; - - /** - * iRecipientNumber, telephone number of the recipient. - */ - TBuf iRecipientNumber; - - /** - * iMessageText, SMS message text. - */ - TBuf iMessageText; - - - /** - * iSmsAppUi, application UI - * Not owned by CSmsHandler object. - */ - CSmsAppUi* iSmsAppUi; - - /** - * iMtmUiRegistry, User Interface MTM Registry. - * Owned by CSmsHandler object. - */ - CMtmUiRegistry* iMtmUiRegistry; - - CMessageManager& iManager; - - }; - - -// INCLUDES -#include // for MMsvSessionObserver -#include // for CMmsClientMtm -#include - -// Forward declarations -class CClientMtmRegistry; -class CMsvSession; - -// -// Container class to draw text on screen -// -class CMmsHandler : public CBase, public MMsvSessionObserver - { -public: // Constructors and destructor - - /** - * NewL. - * Two-phased constructor. - * @param aSmsAppUi Pointer to AppUi instance. - * @return Pointer to the created instance of CSmsHandler. - */ - static CMmsHandler* NewL( CMessageManager& aManager ); - - /** - * NewLC. - * Two-phased constructor. - * @param aSmsAppUi Pointer to AppUi instance. - * @return Pointer to the created instance of CSmsHandler. - */ - static CMmsHandler* NewLC( CMessageManager& aManager ); - - /** - * ~CSmsHandler - * Destructor. - */ - virtual ~CMmsHandler(); - -private: // Constructors - - /** - * CSmsHandler. - * C++ default constructor. - * @param aSmsAppUi Pointer to AppUi instance. - */ - CMmsHandler( CMessageManager& aManager ); - - /** - * ConstructL. - * 2nd phase constructor. - */ - void ConstructL(); - -public: // New functions - - /* - * Creates client MTM registry when session is ready for use. - * This completes model construction and is called after 'server - * ready' event is received after async opening of CMsvSession. - */ - void CompleteConstructL(); - - /* - * CMmsHandler::CreateNewMessageL() - * Creates a new message server entry and set up default values. - * In case the attachment file does not found method return EFalse - * otherwise ETrue. - * There are differenses how to add attachment file between 2nd and 3rd edition. - */ - TBool CreateMsgL(); - - /** - * Send the message. - * Return values: ETrue or EFalse - */ - TBool SendMessageL(); - - /** - * SendL. - * Starts the process of creating and sending an SMS message. - * @param aRecipientNumber The number of the recipent. - * @param aMessageText The message text. - * @return ETrue if successful, EFalse if not. - */ - TBool SendL( const TDesC& aRecipientNumber, - const TDesC& aMessageText ); - -private: - // from MMsvSessionObserver - void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3); - - void SetMessageBodyL(); - -private: - - CMsvSession* iSession; // Client session on the message server - CMmsClientMtm* iMmsMtm; // Message Type Module (MMS) - CClientMtmRegistry* iMtmReg; // Mtm client registry for creating new mtms - - /** - * iRecipientNumber, telephone number of the recipient. - */ - TBuf iRecipientNumber; - - /** - * iMessageText, SMS message text. - */ - TBuf iMessageText; - - CMessageManager& iManager; - - }; -#endif // LOADGEN_MESSAGES_H diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/engine/inc/loadgen_netconn.h --- a/loadgen/engine/inc/loadgen_netconn.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,97 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#ifndef LOADGEN_NETCONN_H -#define LOADGEN_NETCONN_H - -// INCLUDES -#include -#include -#include "loadgen_httpreceiver.h" - -#include "loadgen_loadbase.h" -#include "loadgen_loadattributes.h" - - -// FORWARD DECLARATIONS -class CNetConnManager; - - -// CLASS DECLARATIONS - -class CNetConn : public CLoadBase - { -public: - static CNetConn* NewL(TNetConnAttributes& aAttributes, TInt aReferenceNumber); - virtual ~CNetConn(); - -private: // Constructors - CNetConn(TNetConnAttributes& aAttributes, TInt aReferenceNumber); - void ConstructL(); - -public: // New methods - virtual void Resume(); - virtual void Suspend(); - virtual void SetPriority(); - virtual void Close(); - virtual TPtrC Description(); - inline TNetConnAttributes& Attributes() { return iAttributes; } - inline void SetAttributes(const TNetConnAttributes& aAttributes) { iAttributes = aAttributes; } - -public: // New static methods - static TInt ThreadFunction(TAny* aThreadArg); - -private: // New static methods - static void GenerateLoad(TNetConnAttributes& aAttributes); - -private: // Data - TNetConnAttributes iAttributes; - RThread iThread; - }; - - -class CNetConnManager : public CActive, public MHTTPRecvObserver - { -public: - static CNetConnManager* NewL(TNetConnAttributes& aAttributes); - ~CNetConnManager(); - -private: - CNetConnManager(TNetConnAttributes& aAttributes); - void ConstructL(); - -private: - void RunL(); - void DoCancel(); - -private: - static TInt PeriodicTimerCallBack(TAny* aAny); - void StartDownloadL(); - -private: // MHTTPRecvObserver - void HTTPFileReceived( TInt aStatus ); -public: - inline CPeriodic* PeriodicTimer() { return iPeriodicTimer; } - -private: - TNetConnAttributes& iAttributes; - CPeriodic* iPeriodicTimer; - CHTTPReceiver* iHTTPReceiver; - }; - -#endif diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/engine/inc/loadgen_phonecall.h --- a/loadgen/engine/inc/loadgen_phonecall.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,135 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#ifndef LOADGEN_PHONECALL_H -#define LOADGEN_PHONECALL_H - -// INCLUDES -#include -#include -#include - - -#include "loadgen_loadbase.h" -#include "loadgen_loadattributes.h" - - -// FORWARD DECLARATIONS -class CPhoneCallManager; -class CDialer; - - -// CLASS DECLARATIONS - -class CPhoneCall : public CLoadBase - { -public: - static CPhoneCall* NewL(TPhoneCallAttributes& aAttributes, TInt aReferenceNumber); - virtual ~CPhoneCall(); - -private: // Constructors - CPhoneCall(TPhoneCallAttributes& aAttributes, TInt aReferenceNumber); - void ConstructL(); - -public: // New methods - virtual void Resume(); - virtual void Suspend(); - virtual void SetPriority(); - virtual void Close(); - virtual TPtrC Description(); - inline TPhoneCallAttributes& Attributes() { return iAttributes; } - inline void SetAttributes(const TPhoneCallAttributes& aAttributes) { iAttributes = aAttributes; } - -public: // New static methods - static TInt ThreadFunction(TAny* aThreadArg); - -private: // New static methods - static void GenerateLoad(TPhoneCallAttributes& aAttributes); - -private: // Data - TPhoneCallAttributes iAttributes; - RThread iThread; - }; - - - -class CPhoneCallManager : public CActive - { -private: - enum TState - { - EStateIdle = 0, - EStateCall - }; -public: - static CPhoneCallManager* NewL(TPhoneCallAttributes& aAttributes); - ~CPhoneCallManager(); - -private: - CPhoneCallManager(TPhoneCallAttributes& aAttributes); - void ConstructL(); - -private: - void RunL(); - void DoCancel(); - -private: - static TInt PeriodicTimerCallBack(TAny* aAny); - void HandleCalls(); - void DoDial(); - void DoHangup(); - -public: - inline CPeriodic* PeriodicTimer() { return iPeriodicTimer; } - void HandleStatus(TInt aErr); - -private: - TPhoneCallAttributes& iAttributes; - CDialer* iDialer; - CPeriodic* iPeriodicTimer; - TInt iState; - }; - - -class CDialer : public CActive - { -public: - static CDialer* NewL(CPhoneCallManager& aManager); - ~CDialer(); - -private: - CDialer(CPhoneCallManager& aManager); - void ConstructL(); - -private: - void RunL(); - void DoCancel(); - -public: - void Dial(const TDesC& aDestination); - void Hangup(); - -private: - CPhoneCallManager& iManager; - CTelephony* iTelephony; - CTelephony::TCallId iCallId; - CTelephony::TCallParamsV1 iCallParams; - CTelephony::TCallParamsV1Pckg iCallParamsPckg; - }; - -#endif diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/engine/inc/loadgen_photocapture.h --- a/loadgen/engine/inc/loadgen_photocapture.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,140 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#ifndef LOADGEN_PHOTOCAPTURE_H -#define LOADGEN_PHOTOCAPTURE_H - -// INCLUDES -#include -#include -#include // CCamera, MCameraObserver - -#include "loadgen_loadbase.h" -#include "loadgen_loadattributes.h" - - -// FORWARD DECLARATIONS -class CCameraManager; - - -// CLASS DECLARATIONS - -class CPhotoCapture : public CLoadBase - { -public: - static CPhotoCapture* NewL(TPhotoCaptureAttributes& aAttributes, TInt aReferenceNumber); - virtual ~CPhotoCapture(); - -private: // Constructors - CPhotoCapture(TPhotoCaptureAttributes& aAttributes, TInt aReferenceNumber); - void ConstructL(); - -public: // New methods - virtual void Resume(); - virtual void Suspend(); - virtual void SetPriority(); - virtual void Close(); - virtual TPtrC Description(); - inline TPhotoCaptureAttributes& Attributes() { return iAttributes; } - inline void SetAttributes(const TPhotoCaptureAttributes& aAttributes) { iAttributes = aAttributes; } - - -public: // New static methods - static TInt ThreadFunction(TAny* aThreadArg); - //static void SetImagesReady(TInt aImages); - //static TInt ImagesReady(); - -private: // New static methods - static void GenerateLoad(TPhotoCaptureAttributes& aAttributes); - static void DoHeaveStuff(TInt aMode); - -private: // Data - TPhotoCaptureAttributes iAttributes; - RThread iThread; - //static TInt iImagesReady; - }; - - - - -class CCameraManager : public CActive, public MCameraObserver - { - public: - - static CCameraManager* NewL(TPhotoCaptureAttributes& aAttrs); - virtual ~CCameraManager(); - - private: - - CCameraManager(TPhotoCaptureAttributes& aAttrs); - void ConstructL(); - - private: - /** - * From MCameraObserver: - */ - virtual void ReserveComplete(TInt aError); - virtual void PowerOnComplete(TInt aError); - virtual void ViewFinderFrameReady(CFbsBitmap& aFrame); - virtual void ImageReady(CFbsBitmap* aBitmap, - HBufC8* aData, TInt aError); - virtual void FrameBufferReady(MFrameBuffer* aFrameBuffer, - TInt aError); - - static TInt PeriodicTimerCallBack(TAny* aAny); - public: - - /** - * Reserves the camera. - */ - void ReserveCameraL(); - - /** - * Takes a picture. - */ - void CapturePhotoL(); - - TInt NumberOfPictures(); - - /** - * From CActive: - */ - void RunL(); - void DoCancel(); - - private: - - enum TState - { - ENotReady, - ECameraReserved, - EIdle, - ECapture - }; - - CPeriodic* iPeriodicTimer; - TPhotoCaptureAttributes& iAttributes; - CCamera* iCamera; - TState iState; - TInt iNumOfPics; - TCameraInfo iCameraInfo; - TInt iCurrentCamera; - }; - - -#endif diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/engine/inc/loadgen_pointerevent.h --- a/loadgen/engine/inc/loadgen_pointerevent.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,95 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#ifndef LOADGEN_POINTEREVENT_H -#define LOADGEN_POINTEREVENT_H - -// INCLUDES -#include -#include -#include -#include -#include "loadgen_loadbase.h" -#include "loadgen_loadattributes.h" - - -// FORWARD DECLARATIONS - - - -// CLASS DECLARATIONS - -class CPointerEvent : public CLoadBase - { -public: - static CPointerEvent* NewL(TPointerEventAttributes& aAttributes, TInt aReferenceNumber); - virtual ~CPointerEvent(); - -private: // Constructors - CPointerEvent(TPointerEventAttributes& aAttributes, TInt aReferenceNumber); - void ConstructL(); - -public: // New methods - virtual void Resume(); - virtual void Suspend(); - virtual void SetPriority(); - virtual void Close(); - virtual TPtrC Description(); - inline TPointerEventAttributes& Attributes() { return iAttributes; } - inline void SetAttributes(const TPointerEventAttributes& aAttributes) { iAttributes = aAttributes; } - -public: // New static methods - static TInt ThreadFunction(TAny* aThreadArg); - -private: // New static methods - static void GenerateLoad(TPointerEventAttributes& aAttributes); - -private: // Data - TPointerEventAttributes iAttributes; - RThread iThread; - }; - - -class CPointerEventManager : public CActive - { -public: - static CPointerEventManager* NewL(TPointerEventAttributes& aAttributes); - ~CPointerEventManager(); - -private: - CPointerEventManager(TPointerEventAttributes& aAttributes); - void ConstructL(); - -private: - void RunL(); - void DoCancel(); - -private: - static TInt PeriodicTimerCallBack(TAny* aAny); - void SimulatePointerEvent(); - -public: - inline CPeriodic* PeriodicTimer() { return iPeriodicTimer; } - -private: - TPointerEventAttributes& iAttributes; - CPeriodic* iPeriodicTimer; - //RWsSession iWsSession; - }; - -#endif diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/engine/inc/loadgen_std.h --- a/loadgen/engine/inc/loadgen_std.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,27 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#ifndef LOADGEN_STD_H -#define LOADGEN_STD_H - - - -#endif - -// End of File - diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/engine/inc/loadgen_traces.h --- a/loadgen/engine/inc/loadgen_traces.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,106 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - - -#ifndef __LOADGEN_TRACES_H__ -#define __LOADGEN_TRACES_H__ - -#include - - -// --------------------------------------------------------------------------- -// You change these logging method values below! Recompile the application to take changes effect. - - // logging methods - // 0 = No logging - // 1 = Flogger - // 2 = RDebug - // 3 = Flogger and RDebug - - #ifndef _DEBUG - - // Logging method for UREL builds: - #define LOADGEN_LOGGING_METHOD 3 - - #else - - // Logging method for UDEB builds: - #define LOADGEN_LOGGING_METHOD 3 - - #endif - - - -// --------------------------------------------------------------------------- -// Do not make any changes to lines below... - - #if LOADGEN_LOGGING_METHOD == 1 || LOADGEN_LOGGING_METHOD == 3 - - #include - _LIT(KLogFolder,"loadgen"); - _LIT(KLogFile,"loadgen_trace.txt"); - - #endif - - #if LOADGEN_LOGGING_METHOD == 2 || LOADGEN_LOGGING_METHOD == 3 - - #include - - #endif - - - #if LOADGEN_LOGGING_METHOD == 0 - - #define LOGTEXT(AAA) - #define LOGSTRING(AAA) - #define LOGSTRING2(AAA,BBB) - #define LOGSTRING3(AAA,BBB,CCC) - #define LOGSTRING4(AAA,BBB,CCC,DDD) - - - #elif LOADGEN_LOGGING_METHOD == 1 - - #define LOGTEXT(AAA) RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend, AAA) - #define LOGSTRING(AAA) do { _LIT(tempLogDes,AAA); RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend,tempLogDes()); } while (0) - #define LOGSTRING2(AAA,BBB) do { _LIT(tempLogDes,AAA); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB); } while (0) - #define LOGSTRING3(AAA,BBB,CCC) do { _LIT(tempLogDes,AAA); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB,CCC); } while (0) - #define LOGSTRING4(AAA,BBB,CCC,DDD) do { _LIT(tempLogDes,AAA); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB,CCC,DDD); } while (0) - - #elif LOADGEN_LOGGING_METHOD == 2 - - #define LOGTEXT(AAA) RDebug::Print(AAA) - #define LOGSTRING(AAA) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes); } while (0) - #define LOGSTRING2(AAA,BBB) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB); } while (0) - #define LOGSTRING3(AAA,BBB,CCC) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC); } while (0) - #define LOGSTRING4(AAA,BBB,CCC,DDD) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC, DDD); } while (0) - - #elif LOADGEN_LOGGING_METHOD == 3 - - #define LOGTEXT(AAA) RDebug::Print(AAA); RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend, AAA) - #define LOGSTRING(AAA) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes); RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend,tempLogDes()); } while (0) - #define LOGSTRING2(AAA,BBB) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB); } while (0) - #define LOGSTRING3(AAA,BBB,CCC) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB,CCC); } while (0) - #define LOGSTRING4(AAA,BBB,CCC,DDD) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC, DDD); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB,CCC,DDD); } while (0) - - #endif - -// --------------------------------------------------------------------------- - -#endif // __LOADGEN_TRACES_H__ - diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/engine/inc/loadgen_utils.h --- a/loadgen/engine/inc/loadgen_utils.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#ifndef LOADGEN_UTILS_H -#define LOADGEN_UTILS_H - -// INCLUDES -#include -#include - -const TUint KHalFunction_EKernelHalNumLogicalCpus = 16; //EKernelHalNumLogicalCpus -const TUint KHalFunction_EKernelHalLockThreadToCpu = 19; //EKernelHalLockThreadToCpu - -class CLoadGenUtils { - -public: - static TThreadPriority SettingItemToThreadPriority(TInt aIndex); - static void SettingItemToThreadDescription(TInt aIndex, TDes& aBuf); - static void SettingItemToSourceDescription(TInt aIndex, TDes& aBuf); - static TInt MilliSecondsToMicroSeconds(TInt aMilliSeconds, TInt aRandomVariance=0); - static TInt RandomNumber(TInt aMin, TInt aMax); - static TSize ScreenSize(); - -private: - /* Desctructor pure Virtual -> static class cannot be instantiated or inherited */ - virtual ~CLoadGenUtils()=0; - static TInt64 iRandomNumberSeed; - -}; - -#endif \ No newline at end of file diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/engine/src/loadgen_applications.cpp --- a/loadgen/engine/src/loadgen_applications.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,683 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -// INCLUDE FILES -#include "loadgen_applications.h" -#include "loadgen_utils.h" -#include "loadgen.hrh" -#include - -#include -#include "loadgen_traces.h" - -_LIT(KThreadName, "Applications %d"); - -const TInt KDefaultStartDelay = 500; -const TInt KThreadNameLength = 64; -const TInt KDescriptorBufSize = 256; -const TInt KPriorityBufSize = 16; -const TInt KScanCodeStart = 32; - -// ===================================== MEMBER FUNCTIONS ===================================== - -CAppLauncher* CAppLauncher::NewL( TApplicationsAttributes& aAttributes, TInt aReferenceNumber ) - { - CAppLauncher* self = new(ELeave) CAppLauncher( aAttributes, aReferenceNumber ); - CleanupStack::PushL( self ); - self->ConstructL(); - CleanupStack::Pop( self ); - return self; - } - -// -------------------------------------------------------------------------------------------- - -CAppLauncher::~CAppLauncher() - { - Close(); - } - -// -------------------------------------------------------------------------------------------- - -CAppLauncher::CAppLauncher( - TApplicationsAttributes& aAttributes, TInt aReferenceNumber ) : - iAttributes( aAttributes ) - { - iAttributes.iId = aReferenceNumber; - } - -// -------------------------------------------------------------------------------------------- - -void CAppLauncher::ConstructL() - { - CLoadBase::ConstructL(); - - iType = ELoadGenCmdNewLoadApplications; - - TBuf threadName; - threadName.Format( KThreadName, iAttributes.iId ); - - // create a thread - User::LeaveIfError( iThread.Create( threadName, ThreadFunction, - KDefaultStackSize*2, KMinHeapSize, - KKilo * KMinHeapSize, (TAny*) &iAttributes ) ); - - // set priority of the thread - SetPriority(); - } - -// -------------------------------------------------------------------------------------------- - -TInt CAppLauncher::ThreadFunction( TAny* aThreadArg ) - { - CTrapCleanup* pC = CTrapCleanup::New(); - CActiveScheduler* pS = new CActiveScheduler; - CActiveScheduler::Install( pS ); - - // start generating load, pass pointer to arguments - GenerateLoad( *( ( TApplicationsAttributes* ) aThreadArg ) ); - - delete pS; - delete pC; - - return KErrNone; - } - -// -------------------------------------------------------------------------------------------- - -void CAppLauncher::GenerateLoad( TApplicationsAttributes& aAttributes ) - { - CAppLauncherManager* appLauncherManager = NULL; - TRAPD( err, appLauncherManager = CAppLauncherManager::NewL( aAttributes ) ); - if ( err == KErrNone ) - { - CActiveScheduler::Start(); - } - delete appLauncherManager; - } - -// -------------------------------------------------------------------------------------------- - -void CAppLauncher::Resume() - { - CLoadBase::Resume(); - - iThread.Resume(); - } - -// -------------------------------------------------------------------------------------------- - -void CAppLauncher::Suspend() - { - CLoadBase::Suspend(); - - iThread.Suspend(); - } - -// -------------------------------------------------------------------------------------------- - -void CAppLauncher::SetPriority() - { - CLoadBase::SetPriority(); - - iThread.SetPriority( CLoadGenUtils::SettingItemToThreadPriority( iAttributes.iPriority ) ); - } - -// -------------------------------------------------------------------------------------------- - -void CAppLauncher::Close() - { - CLoadBase::Close(); - - if ( iThread.ExitReason() == 0 ) // check if the thread is still alive - { - // signal the thread that it needs to close - iThread.RequestComplete( iAttributes.iDeathStatus, KErrCancel ); - - // wait the thread to die - TRequestStatus waiter; - iThread.Logon( waiter ); - User::WaitForRequest( waiter ); - iThread.Close(); - } - } - -// -------------------------------------------------------------------------------------------- - -TPtrC CAppLauncher::Description() - { - TBuf buf; - TBuf prioBuf; - CLoadGenUtils::SettingItemToThreadDescription( iAttributes.iPriority, prioBuf ); - - _LIT(KAppLauncherEntry, "[%d] Appls prio=%S max apps=%d heartbeat=%dms random=%d%%"); - buf.Format( KAppLauncherEntry, iAttributes.iId, &prioBuf, iAttributes.iMaxOpen, - iAttributes.iHeartBeat, iAttributes.iRandomVariance ); - - return TPtrC( buf ); - } - -// -------------------------------------------------------------------------------------------- -// -------------------------------------------------------------------------------------------- - -CAppLauncherManager* CAppLauncherManager::NewL( TApplicationsAttributes& aAttributes ) - { - CAppLauncherManager* self = new(ELeave) CAppLauncherManager(aAttributes); - CleanupStack::PushL( self ); - self->ConstructL(); - CleanupStack::Pop( self ); - return self; - } - -// -------------------------------------------------------------------------------------------- - -CAppLauncherManager::CAppLauncherManager( TApplicationsAttributes& aAttributes ) : - CActive( EPriorityStandard ), iAttributes( aAttributes ) - { - iAppEventType = EApplicationsLaunchApplication; - } - -// -------------------------------------------------------------------------------------------- - -CAppLauncherManager::~CAppLauncherManager() - { - if ( iPeriodicTimer ) - { - iPeriodicTimer->Cancel(); - delete iPeriodicTimer; - } - delete iLauncherEngine; - Cancel(); - - iWsSession.Close(); - } - -// -------------------------------------------------------------------------------------------- - -void CAppLauncherManager::ConstructL() - { - CActiveScheduler::Add( this ); - - // create instance to application launcher - iLauncherEngine = CLauncherEngine::NewL( iAttributes ); - - // set the status as pending - iStatus = KRequestPending; - SetActive(); - - // set the death status pointer point to the request status of this ao - iAttributes.iDeathStatus = &iStatus; - - // init - User::LeaveIfError( iWsSession.Connect() ); - - // start timer - iPeriodicTimer = CPeriodic::NewL( CActive::EPriorityStandard ); - iPeriodicTimer->Start( KDefaultStartDelay, - CLoadGenUtils::MilliSecondsToMicroSeconds( - iAttributes.iLaunchingInterval, iAttributes.iRandomVariance ), - TCallBack( PeriodicTimerCallBack, this ) ); - } - -// -------------------------------------------------------------------------------------------- - -void CAppLauncherManager::RunL() - { - // request status has completed by the main thread meaning that we need to stop now - CActiveScheduler::Stop(); - } - -// -------------------------------------------------------------------------------------------- - -void CAppLauncherManager::DoCancel() - { - } - -// -------------------------------------------------------------------------------------------- - -TInt CAppLauncherManager::PeriodicTimerCallBack( TAny* aAny ) - { - CAppLauncherManager* self = static_cast( aAny ); - - TRAPD( err, self->SimulateEventL() ); - if ( KErrNone != err ) - { - return err; - } - return KErrNone; - } - -// -------------------------------------------------------------------------------------------- - -void CAppLauncherManager::SimulateEventL() - { - // Randomly start new applications. - // After maximum applications launched stop one application. - // And after that start launching again. - if ( iAppEventType == EApplicationsLaunchApplication && - iAttributes.iMaxOpen == iLauncherEngine->AppLaunchCounter() ) - { - iAppEventType = EApplicationsCloseApplication; - } - if ( iAppEventType == EApplicationsCloseApplication && - iAttributes.iMaxOpen -1 == iLauncherEngine->AppLaunchCounter() ) - { - iAppEventType = EApplicationsLaunchApplication; - } - - // Launch or stop - if ( iAppEventType == EApplicationsLaunchApplication ) - { - iLauncherEngine->StartAppLaunchingL(); - } - else - { - iLauncherEngine->StopApplication( ETrue ); - } - } - -// -------------------------------------------------------------------------------------------- - -#include -#include -#include -#include -#include -#include -#include - -// --------------------------------------------------------------------------- - -CLauncherEngine* CLauncherEngine::NewL( TApplicationsAttributes& aAttributes ) - { - CLauncherEngine* self = new(ELeave) CLauncherEngine( aAttributes ); - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop( self ); - return self; - } - -// --------------------------------------------------------------------------- - -CLauncherEngine::CLauncherEngine( TApplicationsAttributes& aAttributes ) : - iAttributes( aAttributes ) - { - } - -// --------------------------------------------------------------------------- - -void CLauncherEngine::ConstructL() - { - LOGSTRING("LoadGen: CLauncherEngine::ConstructL"); - iAppKeyPressManager = CAppKeyPressManager::NewL( iAttributes ); - iAppLaunchCounter = 0; - User::LeaveIfError( iTimer.CreateLocal() ); - - User::LeaveIfError( iLs.Connect() ); - User::LeaveIfError( iWs.Connect() ); - - } - -// --------------------------------------------------------------------------- - -CLauncherEngine::~CLauncherEngine() - { - LOGSTRING("LoadGen: CLauncherEngine::~CLauncherEngine"); - StopApplication( EFalse ); - iWs.Close(); - iLs.Close(); - iTimer.Close(); - delete iAppKeyPressManager; - } - -// --------------------------------------------------------------------------- - -void CLauncherEngine::StartAppLaunchingL() - { - LOGSTRING("LoadGen: CLauncherEngine::StartAppLaunchingL"); - if ( iAppLaunchCounter == iAttributes.iMaxOpen ) - { - return; - } - - // start launching - TBool launched( EFalse ); - while ( !launched ) - { - launched = LaunchApplicationL(); - } - } - -// --------------------------------------------------------------------------- - -TBool CLauncherEngine::LaunchApplicationL() - { - LOGSTRING("LoadGen: CLauncherEngine::LaunchApplicationL"); - TBool result( EFalse ); - // get the uid of the current app - iCurrentAppUid = KNullUid; - TApaAppInfo appInfo; - - // get application list size - TInt appsListSize = iAttributes.iAppsArray->MdcaCount(); - // get random application number in the list - TInt appTolaunch = CLoadGenUtils::RandomNumber( 0, appsListSize - 1 ); - // get file name of the application to be launched - TFileName launchFileName = iAttributes.iAppsArray->MdcaPoint( appTolaunch ); - iLs.GetAllApps(); - while ( iLs.GetNextApp( appInfo ) == KErrNone ) - { - // get file name in current appInfo - TFileName appFileName = appInfo.iFullName; - // get AppUid - if ( appFileName.CompareF( launchFileName ) == 0 ) - { - iCurrentAppUid = appInfo.iUid; - break; - } - } - - if ( iCurrentAppUid != KNullUid ) - { - // parse the filename - TParse nameParser; - nameParser.SetNoWild( iAttributes.iAppsArray->MdcaPoint( appTolaunch ), NULL, NULL ); - iCurrentAppNameAndExt.Copy( nameParser.Drive() ); - iCurrentAppNameAndExt.Append( nameParser.NameAndExt() ); - - // do not try to launch these apps - if ( iCurrentAppUid != KNullUid && - iAttributes.iAppsArray->MdcaPoint( appTolaunch).FindF(_L("\\loadgen.")) == KErrNotFound && - iAttributes.iAppsArray->MdcaPoint( appTolaunch ).FindF( _L("\\Phone." ) ) == KErrNotFound && - iAttributes.iAppsArray->MdcaPoint( appTolaunch).FindF( _L("\\Startup.") ) == KErrNotFound && - iAttributes.iAppsArray->MdcaPoint( appTolaunch ).FindF( _L("\\SplashScreen.") ) == KErrNotFound && - iAttributes.iAppsArray->MdcaPoint( appTolaunch ).FindF( _L("\\cameraapp.") ) == KErrNotFound && - iAttributes.iAppsArray->MdcaPoint( appTolaunch ).FindF( _L("\\eshell.") ) == KErrNotFound && - iAttributes.iAppsArray->MdcaPoint( appTolaunch ).FindF( _L("\\ConnTest.") ) == KErrNotFound && - iAttributes.iAppsArray->MdcaPoint( appTolaunch ).FindF( _L("\\Launcher.") ) == KErrNotFound && - -#ifdef __WINS__ - iAttributes.iAppsArray->MdcaPoint( appTolaunch ).FindF( _L("\\DebugAgent.") ) == KErrNotFound && - iAttributes.iAppsArray->MdcaPoint( appTolaunch ).FindF( _L("\\redirect.") ) == KErrNotFound && -#endif - iAttributes.iAppsArray->MdcaPoint( appTolaunch ).FindF( _L("\\VoiceRecorder.") ) == KErrNotFound ) - { - - // check if the app is already running - TApaTaskList taskList( iWs ); - TApaTask thisTask = taskList.FindApp( iCurrentAppUid ); - if ( !thisTask.Exists( )) - { - // check the program's capabilities - TApaAppCapabilityBuf buf; - iLs.GetAppCapability( buf, iCurrentAppUid ); - TApaAppCapability cap = buf(); - - // if it's embeddable only, don't launch if setting is enabled - // if it's hidden, don't launch if setting is enabled - if ( cap.iEmbeddability != TApaAppCapability::EEmbeddableOnly && - !cap.iAppIsHidden ) - { - LOGSTRING2("launchFileName = %S", &launchFileName); - - DoLaunchApplicationL(); - result = ETrue; - } - } - } - } - return result; - } - - -// --------------------------------------------------------------------------- - -void CLauncherEngine::DoLaunchApplicationL() - { - LOGSTRING("LoadGen: CLauncherEngine::DoLaunchApplicationL"); - - // Find the task with uid3 - TApaTaskList tasklist( iWs ); - TApaTask task=tasklist.FindApp( iCurrentAppUid ); - - if ( !task.Exists() ) - // Task doesn't exist, launch a new instance of an application - { - TApaAppInfo appInfo; - User::LeaveIfError( iLs.GetAppInfo( appInfo, iCurrentAppUid ) ); - - CApaCommandLine* cmdLine=CApaCommandLine::NewLC(); - cmdLine->SetExecutableNameL( appInfo.iFullName ); - - // app is launched in background - cmdLine->SetCommandL( EApaCommandBackground ); - - // start the app - User::LeaveIfError( iLs.StartApp( *cmdLine ) ); - iAppKeyPressManager->AddNewApplicationUidToKeyEventsL( iCurrentAppUid ); - iAppLaunchCounter++; - - CleanupStack::PopAndDestroy( cmdLine ); - } - } - -// --------------------------------------------------------------------------- - -void CLauncherEngine::StopApplication( TBool aRandomApplication ) - { - LOGSTRING("LoadGen: CLauncherEngine::StopApplication"); - - // remove key pressing instance - TUid appToDelete = iAppKeyPressManager->KillApplication( aRandomApplication ); - if ( appToDelete != KNullUid ) - { - TApaTaskList taskList( iWs ); - TApaTask thisTask = taskList.FindApp( appToDelete ); - - if ( thisTask.Exists() ) - { - // since the application is still open, let's close it - thisTask.EndTask(); - } - iAppLaunchCounter--; - } - - // return if only one application requested - if ( aRandomApplication ) - { - return; - } - - // remove all launched applications because load is requested to be closed - while ( appToDelete != KNullUid ) - { - appToDelete = iAppKeyPressManager->KillApplication( aRandomApplication ); - - if ( appToDelete != KNullUid ) - { - TApaTaskList taskList( iWs ); - TApaTask thisTask = taskList.FindApp( appToDelete ); - - if ( thisTask.Exists() ) - { - // since the application is still open, let's close it - thisTask.EndTask(); - } - iAppLaunchCounter--; - } - } - } - -// -------------------------------------------------------------------------------------------- -// -------------------------------------------------------------------------------------------- - -CAppKeyPressManager* CAppKeyPressManager::NewL( TApplicationsAttributes& aAttributes ) - { - LOGSTRING("LoadGen: CAppKeyPressManager::NewL"); - CAppKeyPressManager* self = new(ELeave) CAppKeyPressManager( aAttributes ); - CleanupStack::PushL( self ); - self->ConstructL(); - CleanupStack::Pop( self ); - return self; - } - -// -------------------------------------------------------------------------------------------- - -CAppKeyPressManager::CAppKeyPressManager( TApplicationsAttributes& aAttributes ) : - iAttributes( aAttributes ) - { - LOGSTRING("LoadGen: CAppKeyPressManager::CAppKeyPressManager"); - } - -// -------------------------------------------------------------------------------------------- - -CAppKeyPressManager::~CAppKeyPressManager() - { - LOGSTRING("LoadGen: CAppKeyPressManager::~CAppKeyPressManager"); - if ( iKeyPresses.Count() != 0 ) - { - iKeyPresses.ResetAndDestroy(); - } - - iKeyPresses.Close(); - } - -// -------------------------------------------------------------------------------------------- - -void CAppKeyPressManager::ConstructL() - { - LOGSTRING("LoadGen: CAppKeyPressManager::ConstructL"); - } - - -// -------------------------------------------------------------------------------------------- -void CAppKeyPressManager::AddNewApplicationUidToKeyEventsL( TUid aUid ) - { - LOGSTRING("LoadGen: CAppKeyPressManager::AddNewApplicationUidToKeyEventsL"); - CApplicationKeyPresses* applicationKP = CApplicationKeyPresses::NewL( aUid, - iAttributes ); - CleanupStack::PushL( applicationKP ); - User::LeaveIfError( iKeyPresses.Append( applicationKP ) ); - CleanupStack::Pop( applicationKP ); - } - -// -------------------------------------------------------------------------------------------- -TUid CAppKeyPressManager::KillApplication( TBool aRandomApplication ) - { - TUid applicationUid = KNullUid; - TInt appToDelete = iKeyPresses.Count() - 1 ; - // remove the newest application if not random - if ( aRandomApplication ) - { - appToDelete = CLoadGenUtils::RandomNumber( 0, iKeyPresses.Count() - 1 ); - } - if ( iKeyPresses.Count() ) - { - // get random application and delete it - - applicationUid = iKeyPresses[appToDelete]->ApplicationUid(); - delete iKeyPresses[appToDelete]; - iKeyPresses.Remove( appToDelete ); - } - return applicationUid; - } -// -------------------------------------------------------------------------------------------- -// -------------------------------------------------------------------------------------------- - -CApplicationKeyPresses* CApplicationKeyPresses::NewL( TUid aUid, TApplicationsAttributes& - aAttributes ) - { - LOGSTRING("LoadGen: CApplicationKeyPresses::NewL"); - CApplicationKeyPresses* self = new(ELeave) CApplicationKeyPresses( aUid, aAttributes ); - CleanupStack::PushL( self ); - self->ConstructL(); - CleanupStack::Pop( self ); - return self; - } - -// -------------------------------------------------------------------------------------------- - -CApplicationKeyPresses::CApplicationKeyPresses( TUid aUid, - TApplicationsAttributes& aAttributes ) : - iUid( aUid ), iAttributes( aAttributes ) - { - LOGSTRING("LoadGen: CApplicationKeyPresses::CApplicationKeyPresses"); - } - -// -------------------------------------------------------------------------------------------- - -CApplicationKeyPresses::~CApplicationKeyPresses() - { - LOGSTRING("LoadGen: CApplicationKeyPresses::~CApplicationKeyPresses"); - if ( iPeriodicTimer ) - { - iPeriodicTimer->Cancel(); - delete iPeriodicTimer; - } - - iWsSession.Close(); - } - -// -------------------------------------------------------------------------------------------- - -void CApplicationKeyPresses::ConstructL() - { - LOGSTRING("LoadGen: CApplicationKeyPresses::ConstructL"); - // init - User::LeaveIfError( iWsSession.Connect() ); - - // start timer - iPeriodicTimer = CPeriodic::NewL( CActive::EPriorityStandard ); - if ( iAttributes.iKeyPressType ) - { - iPeriodicTimer->Start( KDefaultStartDelay, - CLoadGenUtils::MilliSecondsToMicroSeconds( - iAttributes.iHeartBeat, - iAttributes.iRandomVariance ), - TCallBack( PeriodicTimerCallBack, this ) ); - } - } - -// -------------------------------------------------------------------------------------------- - -TInt CApplicationKeyPresses::PeriodicTimerCallBack( TAny* aAny ) - { - CApplicationKeyPresses* self = static_cast( aAny ); - self->SimulateKeyEvent(); - return KErrNone; - } - -// -------------------------------------------------------------------------------------------- - -void CApplicationKeyPresses::SimulateKeyEvent() - { - LOGSTRING("LoadGen: CApplicationKeyPresses::SimulateKeyEvent"); - // for arrow key events - - TInt wgId(0); - CApaWindowGroupName::FindByAppUid( iUid, iWsSession, wgId ); - // generate a random arrow key event - TWsEvent event; - event.SetType( EEventKey ); - event.Key()->iCode = CLoadGenUtils::RandomNumber( EKeyLeftArrow, EKeyDownArrow ); - event.Key()->iScanCode = event.Key()->iCode - KScanCodeStart; - event.Key()->iModifiers = 0; - event.Key()->iRepeats = 0; - iWsSession.SendEventToWindowGroup( wgId, event ); - } - -// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/engine/src/loadgen_bluetooth.cpp --- a/loadgen/engine/src/loadgen_bluetooth.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,339 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -// INCLUDE FILES -#include "loadgen_bluetooth.h" -#include "loadgen_utils.h" -#include "loadgen.hrh" -#include "loadgen_traces.h" -#include -#include -#include -#include -#include -#include -#include -#include - -_LIT(KThreadName, "Bluetooth %d"); -_LIT(KBTLinkManagerStr, "BTLinkManager"); - -const TInt KDefaultStart = 50; -const TInt KDefaultPeriod = 5000000; - -// ===================================== MEMBER FUNCTIONS ===================================== - -CBluetooth* CBluetooth::NewL(TBluetoothAttributes& aAttributes, TInt aReferenceNumber) - { - CBluetooth* self = new(ELeave) CBluetooth(aAttributes, aReferenceNumber); - CleanupStack::PushL(self); - TRAPD(err, self->ConstructL()); - if( err != KErrNone ) - { - User::Leave(err); - } - CleanupStack::Pop(self); - return self; - } - -// -------------------------------------------------------------------------------------------- - -CBluetooth::~CBluetooth() - { - Close(); - } - -// -------------------------------------------------------------------------------------------- - -CBluetooth::CBluetooth(TBluetoothAttributes& aAttributes, TInt aReferenceNumber) : iAttributes(aAttributes) - { - iAttributes.iId = aReferenceNumber; - } - -// -------------------------------------------------------------------------------------------- - -void CBluetooth::ConstructL() - { - CLoadBase::ConstructL(); - - iType = ELoadGenCmdNewLoadBluetooth; - - InitializeBluetoothL(); - - TBuf<64> threadName; - threadName.Format(KThreadName, iAttributes.iId); - - // create a thread - User::LeaveIfError(iThread.Create(threadName, ThreadFunction, KDefaultStackSize*2, KMinHeapSize, 1024*KMinHeapSize, (TAny*) &iAttributes )); - - // set priority of the thread - SetPriority(); - iState = ELoadStateConstructed; - } - -// -------------------------------------------------------------------------------------------- - -TInt CBluetooth::ThreadFunction(TAny* aThreadArg) - { - TInt err = KErrNone; - - CTrapCleanup* pC = CTrapCleanup::New(); - CActiveScheduler* pS = new CActiveScheduler; - CActiveScheduler::Install(pS); - - // start generating load, pass pointer to arguments - GenerateLoad(*((TBluetoothAttributes*) aThreadArg)); - - delete pS; - delete pC; - - return err; - } - -// -------------------------------------------------------------------------------------------- - -void CBluetooth::GenerateLoad(TBluetoothAttributes& aAttributes) - { - CBTManager* btManager = 0; - TRAPD(err, btManager = CBTManager::NewL(aAttributes)); - if (err == KErrNone) CActiveScheduler::Start(); - delete btManager; - } - -// -------------------------------------------------------------------------------------------- - -void CBluetooth::Resume() - { - CLoadBase::Resume(); - iThread.Resume(); - } - -// -------------------------------------------------------------------------------------------- - -void CBluetooth::Suspend() - { - CLoadBase::Suspend(); - iThread.Suspend(); - } - -// -------------------------------------------------------------------------------------------- - -void CBluetooth::SetPriority() - { - CLoadBase::SetPriority(); - iThread.SetPriority(CLoadGenUtils::SettingItemToThreadPriority(iAttributes.iPriority)); - } - -// -------------------------------------------------------------------------------------------- - -void CBluetooth::Close() - { - LOGSTRING2("LoadGen: CBluetooth::~CBluetooth() - State: %d", iState); - if( iState != ELoadStateInvalid ) - { - CLoadBase::Close(); - // kill the thread immediately - iThread.Kill(0); - iThread.Close(); - } - } - -// -------------------------------------------------------------------------------------------- -TPtrC CBluetooth::Description() - { - TBuf<256> buf; - TBuf<16> prioBuf; - CLoadGenUtils::SettingItemToThreadDescription(iAttributes.iPriority, prioBuf); - - _LIT(KBluetoothEntry, "[%d] Bluetooth prio=%S idle=%dms random=%d%%"); - buf.Format(KBluetoothEntry, iAttributes.iId, &prioBuf, iAttributes.iIdle, iAttributes.iRandomVariance); - - return TPtrC(buf); - } - -// -------------------------------------------------------------------------------------------- -void CBluetooth::InitializeBluetoothL() - { - // Create central repository for checking and setting bluetooth power state - CRepository* btPowerStateCRepo = CRepository::NewL(KCRUidBluetoothPowerState); - - // Check if the BT is already turned on: - TInt btPowerState = 0; - btPowerStateCRepo->Get(KBTPowerState, btPowerState); - delete btPowerStateCRepo; - btPowerStateCRepo = 0; - - if(btPowerState == EBTPowerOff) - { - // Switch bt power on: - if (SetBTPowerState(ETrue) == EFalse) - { - LOGSTRING("LoadGen: Bluetooth could not be switched on"); - User::Leave(KErrNotReady); - } - } - } - -// -------------------------------------------------------------------------------------------- -TBool CBluetooth::SetBTPowerState(TBool aState) - { - // Ask user to turn on the bluetooth device: - RNotifier btPowerNotifier; - TInt errCode = btPowerNotifier.Connect(); - - TBool retVal = errCode == KErrNone; - - if( errCode == KErrNone ) - { - TPckgBuf powerRequest(aState); - TPckgBuf powerReply(EFalse); - TRequestStatus powerRequestStatus; - btPowerNotifier.StartNotifierAndGetResponse(powerRequestStatus, - KPowerModeSettingNotifierUid, - powerRequest, - powerReply); - User::WaitForRequest(powerRequestStatus); - btPowerNotifier.CancelNotifier(KPowerModeSettingNotifierUid); - btPowerNotifier.Close(); - if( powerReply() == EFalse ) - { - LOGSTRING("LoadGen: Bluetooth activating cancelled."); - } - retVal = powerReply(); - } - - return retVal; - } - -// -------------------------------------------------------------------------------------------- -CBTManager* CBTManager::NewL( TBluetoothAttributes& aAttrs) - { - CBTManager* self = new (ELeave) CBTManager( aAttrs); - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(self); - return self; - } - -// -------------------------------------------------------------------------------------------- -CBTManager::~CBTManager() - { - if (iPeriodicTimer) - { - iPeriodicTimer->Cancel(); - delete iPeriodicTimer; - } - iHostResolver.Close(); - Cancel(); - } - -// -------------------------------------------------------------------------------------------- -CBTManager::CBTManager( TBluetoothAttributes& aAttrs) -: -CActive(EPriorityStandard), -iAttributes(aAttrs) - { - } - -// -------------------------------------------------------------------------------------------- -void CBTManager::ConstructL() - { - // Socket server session initiation: - User::LeaveIfError(iSocketServerHnd.Connect()); - - CActiveScheduler::Add(this); - // set the status as pending - iStatus = KRequestPending; - SetActive(); - - // set the death status pointer point to the request status of this ao - iAttributes.iDeathStatus = &iStatus; - - // start timer - iPeriodicTimer = CPeriodic::NewL(CActive::EPriorityStandard); - iPeriodicTimer->Start(KDefaultStart, KDefaultPeriod, TCallBack(PeriodicTimerCallBack, this)); - } - -// -------------------------------------------------------------------------------------------- -void CBTManager::DoCancel() - { - LOGSTRING("LoadGen: CBTManager::DoCancel()"); - } - -// -------------------------------------------------------------------------------------------- -void CBTManager::RunL() - { - // request status has completed by the main thread meaning that we need to stop now - CActiveScheduler::Stop(); - } - -// -------------------------------------------------------------------------------------------- -TInt CBTManager::StartBTDeviceDiscovery() - { - TInt retVal = KErrNone; - RThread myThread; - - // Initialize host resolver - iHostResolver.Close(); - TProtocolDesc protocolInfo; - retVal = iSocketServerHnd.FindProtocol(KBTLinkManagerStr(), protocolInfo); - if( retVal == KErrNone ) - { - retVal = iHostResolver.Open(iSocketServerHnd, protocolInfo.iAddrFamily, protocolInfo.iProtocol); - } - - if( retVal == KErrNone ) - { - TInquirySockAddr socketAddress; - socketAddress.SetIAC( KGIAC ); - socketAddress.SetAction(KHostResInquiry|KHostResName|KHostResIgnoreCache); - retVal = iHostResolver.GetByAddress(socketAddress, iBTNameEntry); - // Loop all discovered devices: - while( retVal == KErrNone ) - { - LOGSTRING3("LoadGen: Thread %S found device: %S", &(myThread.Name()), &(iBTNameEntry().iName) ); - // Get next device - retVal = iHostResolver.Next(iBTNameEntry); - } - } - - // KErrEof is returned when no more devices to loop - if( retVal == KErrEof ) - { - retVal = KErrNone; - } - - iPeriodicTimer->Start( CLoadGenUtils::MilliSecondsToMicroSeconds( iAttributes.iIdle, - iAttributes.iRandomVariance ), KDefaultPeriod, - TCallBack( PeriodicTimerCallBack, this ) ); - - return retVal; - } - -// -------------------------------------------------------------------------------------------- - -TInt CBTManager::PeriodicTimerCallBack(TAny* aAny) - { - CBTManager* self = static_cast( aAny ); - self->iPeriodicTimer->Cancel(); - // Perform device discovery: - self->StartBTDeviceDiscovery(); - return KErrNone; - } - -// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/engine/src/loadgen_cpuload.cpp --- a/loadgen/engine/src/loadgen_cpuload.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,270 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -// INCLUDE FILES -#include "loadgen_cpuload.h" -#include "loadgen_utils.h" -#include "loadgen.hrh" -#include -#include -#include -#include -#include - -_LIT(KThreadName, "CPULoad %d"); - -// ===================================== MEMBER FUNCTIONS ===================================== - -CCPULoad* CCPULoad::NewL(TCPULoadAttributes& aAttributes, TInt aReferenceNumber) - { - CCPULoad* self = new(ELeave) CCPULoad(aAttributes, aReferenceNumber); - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(self); - return self; - } - -// -------------------------------------------------------------------------------------------- - -CCPULoad::~CCPULoad() - { - Close(); - } - -// -------------------------------------------------------------------------------------------- - -CCPULoad::CCPULoad(TCPULoadAttributes& aAttributes, TInt aReferenceNumber) : iAttributes(aAttributes) - { - iAttributes.iId = aReferenceNumber; - } - -// -------------------------------------------------------------------------------------------- - -void CCPULoad::ConstructL() - { - CLoadBase::ConstructL(); - - iType = ELoadGenCmdNewLoadCPULoad; - - TBuf<64> threadName; - threadName.Format(KThreadName, iAttributes.iId); - - // create a thread - User::LeaveIfError(iThread.Create(threadName, ThreadFunction, KDefaultStackSize*2, KMinHeapSize, 1024*KMinHeapSize, (TAny*) &iAttributes )); - - // set priority of the thread - SetPriority(); - } - -// -------------------------------------------------------------------------------------------- - -TInt CCPULoad::ThreadFunction(TAny* aThreadArg) - { - TCPULoadAttributes* threadArg = (TCPULoadAttributes*)aThreadArg; - TInt err = KErrNone; - - // if a cpu is defined, tie this thread to the given cpu (SMP environment) - if (threadArg->iCpu >= 0 && threadArg->iCpu != KCPUSelection_AllCPUs ) - { - UserSvr::HalFunction(EHalGroupKernel, KHalFunction_EKernelHalLockThreadToCpu, (TAny*) threadArg->iCpu, 0); - } - - CTrapCleanup* pC = CTrapCleanup::New(); - CActiveScheduler* pS = new CActiveScheduler; - CActiveScheduler::Install(pS); - - // start generating load, pass pointer to arguments - GenerateLoad(*((TCPULoadAttributes*) aThreadArg)); - - delete pS; - delete pC; - - return err; - } - -// -------------------------------------------------------------------------------------------- - -void CCPULoad::GenerateLoad(TCPULoadAttributes& aAttributes) - { - for (;;) - { - if (aAttributes.iType == ECpuLoadTypeContinuous) - { - // do constantly heave stuff - DoHeaveStuff(aAttributes.iMode); - } - - else if (aAttributes.iType == ECpuLoadTypePeriodic) - { - // do periodically heave stuff - TTime startTime; - startTime.HomeTime(); // get start time - - TTime currentTime; - TTimeIntervalMicroSeconds interval; - TInt processPeriod; - #ifdef QT_SUPPORT - - #else - processPeriod = CLoadGenUtils::MilliSecondsToMicroSeconds(aAttributes.iLength, aAttributes.iRandomVariance); - #endif - do - { - // do heave stuff - DoHeaveStuff(aAttributes.iMode); - - currentTime.HomeTime(); - interval = currentTime.MicroSecondsFrom(startTime); - } - while (interval.Int64() < processPeriod); - - - // now wait - User::After( CLoadGenUtils::MilliSecondsToMicroSeconds(aAttributes.iIdle, aAttributes.iRandomVariance) ); - } - - else - { - User::Panic(_L("Unk.type"), 888); - } - } - } - -// -------------------------------------------------------------------------------------------- - -void CCPULoad::DoHeaveStuff(TInt aMode) - { - TTime now; - now.HomeTime(); - TInt64 seed = now.Int64(); - - TReal random = Math::FRand(seed); - - TReal target(10); - TReal source(10); - - target += random; - - Math::Cos(target, source); - - source = source / 1.0382873; - source -= 32.24343; - source += 132.24343; - source *= random; - - // yield trick - if (aMode == ECpuLoadModeYielding) - { - // sleep randomly - if (User::TickCount() % 50 == 0) - User::AfterHighRes(1); - } - } - -// -------------------------------------------------------------------------------------------- - -void CCPULoad::Resume() - { - CLoadBase::Resume(); - - iThread.Resume(); - } - -// -------------------------------------------------------------------------------------------- - -void CCPULoad::Suspend() - { - CLoadBase::Suspend(); - - iThread.Suspend(); - } - -// -------------------------------------------------------------------------------------------- - -void CCPULoad::SetPriority() - { - CLoadBase::SetPriority(); - - iThread.SetPriority(CLoadGenUtils::SettingItemToThreadPriority(iAttributes.iPriority)); - } - -// -------------------------------------------------------------------------------------------- - -void CCPULoad::Close() - { - CLoadBase::Close(); - - // kill the thread immediately - iThread.Kill(0); - - iThread.Close(); - } - -// -------------------------------------------------------------------------------------------- - -TPtrC CCPULoad::Description() - { - TBuf<256> buf; - TBuf<16> prioBuf; - CLoadGenUtils::SettingItemToThreadDescription(iAttributes.iPriority, prioBuf); - - if (iAttributes.iType == ECpuLoadTypeContinuous) - { - if (iAttributes.iMode == ECpuLoadModeYielding) - { - _LIT(KCPULoadEntryContinuous, "[%d] CPULoad prio=%S mode=yielding type=cont"); - buf.Format(KCPULoadEntryContinuous, iAttributes.iId, &prioBuf); - } - else if (iAttributes.iMode == ECpuLoadModeBlocking) - { - _LIT(KCPULoadEntryContinuous, "[%d] CPULoad prio=%S mode=blocking type=cont"); - buf.Format(KCPULoadEntryContinuous, iAttributes.iId, &prioBuf); - } - } - - else if (iAttributes.iType == ECpuLoadTypePeriodic) - { - if (iAttributes.iMode == ECpuLoadModeYielding) - { - _LIT(KCPULoadEntryPeriodic, "[%d] CPULoad prio=%S mode=yielding type=period peak=%dms idle=%dms random=%d%%"); - buf.Format(KCPULoadEntryPeriodic, iAttributes.iId, &prioBuf, iAttributes.iLength, iAttributes.iIdle, iAttributes.iRandomVariance); - } - else if (iAttributes.iMode == ECpuLoadModeBlocking) - { - _LIT(KCPULoadEntryPeriodic, "[%d] CPULoad prio=%S mode=blocking type=period peak=%dms idle=%dms random=%d%%"); - buf.Format(KCPULoadEntryPeriodic, iAttributes.iId, &prioBuf, iAttributes.iLength, iAttributes.iIdle, iAttributes.iRandomVariance); - } - } - - // if we are running a load in a specific cpu, add the "name" of the - // cpu to the description. (SMP environment) - if (iAttributes.iCpu >= 0 && iAttributes.iCpu != KCPUSelection_AllCPUs) - { - TBuf<15> cpu; - _LIT(KCPU, " CPU%d"); - cpu.Format(KCPU, iAttributes.iCpu); - buf.Append(cpu); - } - - return TPtrC(buf); - } - -// -------------------------------------------------------------------------------------------- - - -// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/engine/src/loadgen_httpreceiver.cpp --- a/loadgen/engine/src/loadgen_httpreceiver.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,353 +0,0 @@ - -#include -#include -#include "loadgen_httpreceiver.h" - -// CONSTANTS -_LIT8( KHttpScheme, "http" ); -_LIT8( KSchemeAddon, "://" ); -// This client accepts all content types. -_LIT8(KAccept, "*/*"); - -CHTTPReceiver* CHTTPReceiver::NewL( MHTTPRecvObserver& aObserver ) - { - CHTTPReceiver* self = CHTTPReceiver::NewLC( aObserver ); - CleanupStack::Pop( self ); - return self; - } - -CHTTPReceiver* CHTTPReceiver::NewLC( MHTTPRecvObserver& aObserver ) - { - CHTTPReceiver* self = new (ELeave)CHTTPReceiver( aObserver ); - CleanupStack::PushL( self ); - self->ConstructL(); - return self; - } - -CHTTPReceiver::CHTTPReceiver( MHTTPRecvObserver& aObserver ) : - iObserver(aObserver), iRunning(EFalse), iConnectionSetupDone(EFalse) - { - } - -void CHTTPReceiver::ConstructL() - { -#ifdef _DEBUG - User::LeaveIfError( iFs.Connect() ); -#endif - } - -CHTTPReceiver::~CHTTPReceiver() - { - TRACE( "Entry: CHTTPReceiver::~CHTTPReceiver" ); - - CancelTransaction(); - - TRAP_IGNORE( iSession.DisconnectL() ); - iSession.Close(); - iConnection.Stop(); - iConnection.Close(); - iSocketServ.Close(); - - TRACE( "Entry: CHTTPReceiver::~CHTTPReceiver - delete iUrl" ); - delete iUrl; - -#ifdef _DEBUG - iFs.Close(); -#endif - TRACE( "Exit: CHTTPReceiver::~CHTTPReceiver" ); - } - -void CHTTPReceiver::CancelTransaction() - { - if ( !iRunning) - return; - - TRACE( "Entry: CHTTPReceiver::CancelTransaction" ); - - if ( iRunning) - { - iTransaction.Close(); - iRunning = EFalse; - } - - TRACE( "Exit: CHTTPReceiver::CancelTransaction" ); - } - -// ---------------------------------------------------------------------------- -// CHTTPReceiver::SendHTTPGetL() -// -// Start a new HTTP GET transaction. -// ---------------------------------------------------------------------------- -void CHTTPReceiver::SendHTTPGetL( const TDesC8& aURL ) - { - TRACE( "Entry: CHTTPReceiver::SendHTTPGetL" ); - - iResponseStatus = KErrGeneral; - -#ifdef _DEBUG - iResponseFile.Replace( iFs, _L("C:\\Data\\loadgen.htm"), EFileWrite ); -#endif - - SetupConnectionL(); - - // Parse string to URI (as defined in RFC2396) - TUriParser8 uri; - - CheckForHTTPSchemeL(uri, aURL); - - RStringF method = iSession.StringPool().StringF(HTTP::EGET, RHTTPSession::GetTable()); - CleanupClosePushL( method ); - - iTransaction = iSession.OpenTransactionL(uri, *this, method); - - // Set headers for request: accepted content type - RHTTPHeaders hdr = iTransaction.Request().GetHeaderCollection(); - SetHeaderL(hdr, HTTP::EAccept, KAccept); - - iTransaction.SubmitL(); - - iRunning = ETrue; - CleanupStack::PopAndDestroy(); - TRACE( "Exit: CHTTPReceiver::SendHTTPGetL" ); - return; - } - -void CHTTPReceiver::CheckForHTTPSchemeL(TUriParser8& aUri, const TDesC8& aURL) - { - if( iUrl ) - { - delete iUrl; - iUrl = NULL; - } - - iUrl = aURL.AllocL(); - aUri.Parse( *iUrl ); - - TPtrC8 scheme( aUri.Extract (EUriScheme) ); - - // unsupported or no scheme in url. - // Insert 'http://' to the beginning of it. - if ( scheme != KHttpScheme ) - { - HBufC8* tempBuf = HBufC8::NewL( KHttpScheme().Length() + KSchemeAddon().Length() + aURL.Length() ); - CleanupStack::PushL( tempBuf ); - tempBuf->Des().Append( KHttpScheme ); - tempBuf->Des().Append( KSchemeAddon ); - tempBuf->Des().Append( aURL ); - - if( iUrl ) - { - delete iUrl; - iUrl = NULL; - } - iUrl = tempBuf; - aUri.Parse( *iUrl ); - CleanupStack::PopAndDestroy( tempBuf ); - } - } - -// Used to set header value to HTTP request -void CHTTPReceiver::SetHeaderL (RHTTPHeaders aHeaders, TInt aHdrField, const TDesC8& aHdrValue) - { - RStringF valStr = iSession.StringPool().OpenFStringL (aHdrValue); - CleanupClosePushL (valStr); - THTTPHdrVal val(valStr); - aHeaders.SetFieldL (iSession.StringPool().StringF (aHdrField, RHTTPSession::GetTable ()), val); - CleanupStack::PopAndDestroy (); // valStr - } - -// Inherited from MHTTPTransactionCallback -// Called by framework to pass transaction events. -// ---------------------------------------------------------------------------- -void CHTTPReceiver::MHFRunL( RHTTPTransaction aTransaction, const THTTPEvent& aEvent ) - { - TRACE( "Entry: CHTTPReceiver::MHFRunL" ); - TRACE2( "Entry: CHTTPReceiver::MHFRunL <%d>", aEvent.iStatus ); - - // state check - if ( !iRunning ) - { - TRACE( "Exit1: CHTTPReceiver::MHFRunL: recv in wrong state" ); - return; - } - - switch ( aEvent.iStatus ) - { - case THTTPEvent::EGotResponseHeaders: - { - TRACE( "Entry: CHTTPReceiver::MHFRunL EGotResponseHeaders" ); - // Get HTTP status code from header (e.g. 200) - RHTTPResponse resp = aTransaction.Response(); - iResponseStatus = resp.StatusCode(); - } - break; - - case THTTPEvent::EGotResponseBodyData: - { - // Get the body data supplier - TRACE( "Entry: CHTTPReceiver::MHFRunL EGotResponseBodyData" ); - MHTTPDataSupplier* body = aTransaction.Response().Body (); - TPtrC8 dataChunk; - body->GetNextDataPart ( dataChunk ); -#ifdef _DEBUG - if ( dataChunk.Length() ) - { - iResponseFile.Write( dataChunk ); - } -#endif - body->ReleaseData (); - } - break; - - case THTTPEvent::EResponseComplete: - { - // Indicates that header & body of response is completely received. - // Notify Observer - TRACE( "Entry: CHTTPReceiver::MHFRunL EResponseComplete" ); - } - break; - - case THTTPEvent::ESucceeded: - { - // Transaction can be closed now. It's not needed anymore. - TRACE( "Entry: CHTTPReceiver::MHFRunL ESucceeded" ); - Finalize(); - } - break; - - case THTTPEvent::EFailed: - { - TRACE( "Entry: CHTTPReceiver::MHFRunL EFailed" ); - iResponseStatus = KErrGeneral; - Finalize(); - } - break; - - default: - TRACE( "Entry: CHTTPReceiver::MHFRunL EDefault" ); - break; - } - } - -// Called by framework when *leave* occurs in handling of transaction event. -// These errors must be handled, or otherwise HTTP-CORE 6 panic is thrown. -// ---------------------------------------------------------------------------- -TInt CHTTPReceiver::MHFRunError ( TInt aError, RHTTPTransaction /*aTransaction*/, const THTTPEvent& /*aEvent*/ ) - { - TRACE( "Entry: CHTTPReceiver::MHFRunError" ); - iResponseStatus = aError; - Finalize(); - - TRACE( "Exit: CHTTPReceiver::MHFRunError" ); - return KErrNone; - } - -void CHTTPReceiver::SetupConnectionL () - { - TRACE( "Entry: CHTTPReceiver::StartConnectionL" ); - - // check if conncetion is already open - if ( iRunning ) - { - return; - } - - if ( iConnectionSetupDone ) - { - return; - } - - iConnectionSetupDone = ETrue; - - // open HTTP session - iSession.OpenL(); - - // open socket server - TInt result = iSocketServ.Connect(); - if ( result == KErrNone) - { - // open connection - result = iConnection.Open(iSocketServ); - if ( result == KErrNone) - { - // set overrides - TCommDbConnPref pref; - pref.SetDialogPreference (ECommDbDialogPrefPrompt); - //pref.SetDirection (ECommDbConnectionDirectionOutgoing); - //pref.SetIapId (accessPoint); - - // start with overrides - result = iConnection.Start(pref); - - if ( result == KErrNone) - { - // get connection info from iSession - RHTTPConnectionInfo connInfo = iSession.ConnectionInfo (); - RStringPool pool = iSession.StringPool (); - - // set socket server - connInfo.SetPropertyL (pool.StringF (HTTP::EHttpSocketServ, - RHTTPSession::GetTable () ), - THTTPHdrVal( iSocketServ.Handle () ) ); - - // attach to connection - TInt connectionPtr= REINTERPRET_CAST( TInt, - &iConnection ); - - connInfo.SetPropertyL (pool.StringF ( - HTTP::EHttpSocketConnection, - RHTTPSession::GetTable () ), - THTTPHdrVal (connectionPtr) ); - -#if defined(__WINSCW__) || defined(__WINS__) // if Emulator - _LIT8(KProxyAddr, "192.168.0.252:4040"); - TBufC8<30> proxyAddr(KProxyAddr); - - RStringF prxAddr = iSession.StringPool().OpenFStringL (proxyAddr); - CleanupClosePushL (prxAddr); - THTTPHdrVal prxUsage(iSession.StringPool().StringF (HTTP::EUseProxy, - RHTTPSession::GetTable ())); - iSession.ConnectionInfo().SetPropertyL (iSession.StringPool().StringF (HTTP::EProxyUsage, - RHTTPSession::GetTable ()), prxUsage); - iSession.ConnectionInfo().SetPropertyL (iSession.StringPool().StringF (HTTP::EProxyAddress, - RHTTPSession::GetTable ()), prxAddr); - CleanupStack::PopAndDestroy (); // prxAddr -#endif - - } - else - { - TRACE2( "CHTTPReceiver:: connection start: <%d>", result ); - } - } - else - { - TRACE2( "CHTTPReceiver:: connection open: <%d>", result ); - } - } - else - { - TRACE2( "CHTTPReceiver:: connection to socket server: <%d>", result ); - } - - User::LeaveIfError( result ); - - TRACE( "Exit: CHTTPReceiver::StartConnectionL" ); - } - -// ---------------------------------------------------------------------------- -// CHTTPReceiver::Finalize -// -// ---------------------------------------------------------------------------- -// -void CHTTPReceiver::Finalize() - { - TRACE( "Exit: CHTTPReceiver::Finalize" ); -#ifdef _DEBUG - iResponseFile.Close(); -#endif - iTransaction.Close(); - iRunning = EFalse; - iObserver.HTTPFileReceived( iResponseStatus ); - TRACE( "Exit: CHTTPReceiver::Finalize" ); - } diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/engine/src/loadgen_keypress.cpp --- a/loadgen/engine/src/loadgen_keypress.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,257 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -// INCLUDE FILES -#include "loadgen_keypress.h" -#include "loadgen_utils.h" -#include "loadgen.hrh" -#include - -#include - -_LIT(KThreadName, "KeyPress %d"); - -const TInt KDefaultStart = 50; -const TInt KDefaultPeriod = 5000000; - -// ===================================== MEMBER FUNCTIONS ===================================== - -CKeyPress* CKeyPress::NewL(TKeyPressAttributes& aAttributes, TInt aReferenceNumber) - { - CKeyPress* self = new(ELeave) CKeyPress(aAttributes, aReferenceNumber); - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(self); - return self; - } - -// -------------------------------------------------------------------------------------------- - -CKeyPress::~CKeyPress() - { - Close(); - } - -// -------------------------------------------------------------------------------------------- - -CKeyPress::CKeyPress(TKeyPressAttributes& aAttributes, TInt aReferenceNumber) : iAttributes(aAttributes) - { - iAttributes.iId = aReferenceNumber; - } - -// -------------------------------------------------------------------------------------------- - -void CKeyPress::ConstructL() - { - CLoadBase::ConstructL(); - - iType = ELoadGenCmdNewLoadKeyPress; - - TBuf<64> threadName; - threadName.Format(KThreadName, iAttributes.iId); - - // create a thread - User::LeaveIfError(iThread.Create(threadName, ThreadFunction, KDefaultStackSize*2, KMinHeapSize, 1024*KMinHeapSize, (TAny*) &iAttributes )); - - // set priority of the thread - SetPriority(); - } - -// -------------------------------------------------------------------------------------------- - -TInt CKeyPress::ThreadFunction(TAny* aThreadArg) - { - CTrapCleanup* pC = CTrapCleanup::New(); - CActiveScheduler* pS = new CActiveScheduler; - CActiveScheduler::Install(pS); - - // start generating load, pass pointer to arguments - GenerateLoad(*((TKeyPressAttributes*) aThreadArg)); - - delete pS; - delete pC; - - return KErrNone; - } - -// -------------------------------------------------------------------------------------------- - -void CKeyPress::GenerateLoad(TKeyPressAttributes& aAttributes) - { - CKeyPressManager* keyPressManager = NULL; - TRAPD(err, keyPressManager = CKeyPressManager::NewL(aAttributes)); - if (err == KErrNone) CActiveScheduler::Start(); - delete keyPressManager; - } - -// -------------------------------------------------------------------------------------------- - -void CKeyPress::Resume() - { - CLoadBase::Resume(); - - iThread.Resume(); - } - -// -------------------------------------------------------------------------------------------- - -void CKeyPress::Suspend() - { - CLoadBase::Suspend(); - - iThread.Suspend(); - } - -// -------------------------------------------------------------------------------------------- - -void CKeyPress::SetPriority() - { - CLoadBase::SetPriority(); - - iThread.SetPriority(CLoadGenUtils::SettingItemToThreadPriority(iAttributes.iPriority)); - } - -// -------------------------------------------------------------------------------------------- - -void CKeyPress::Close() - { - CLoadBase::Close(); - - if (iThread.ExitReason() == 0) // check if the thread is still alive - { - // signal the thread that it needs to close - iThread.RequestComplete(iAttributes.iDeathStatus, KErrCancel); - - // wait the thread to die - TRequestStatus waiter; - iThread.Logon(waiter); - User::WaitForRequest(waiter); - iThread.Close(); - } - } - -// -------------------------------------------------------------------------------------------- - -TPtrC CKeyPress::Description() - { - TBuf<256> buf; - TBuf<16> prioBuf; - CLoadGenUtils::SettingItemToThreadDescription(iAttributes.iPriority, prioBuf); - - _LIT(KKeyPressEntry, "[%d] KeyPress prio=%S heartbeat=%dms random=%d%%"); - buf.Format(KKeyPressEntry, iAttributes.iId, &prioBuf, iAttributes.iHeartBeat, iAttributes.iRandomVariance); - - return TPtrC(buf); - } - -// -------------------------------------------------------------------------------------------- -// -------------------------------------------------------------------------------------------- - -CKeyPressManager* CKeyPressManager::NewL(TKeyPressAttributes& aAttributes) - { - CKeyPressManager* self = new(ELeave) CKeyPressManager(aAttributes); - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(); - return self; - } - -// -------------------------------------------------------------------------------------------- - -CKeyPressManager::CKeyPressManager(TKeyPressAttributes& aAttributes) : - CActive(EPriorityStandard), iAttributes(aAttributes) - { - } - -// -------------------------------------------------------------------------------------------- - -CKeyPressManager::~CKeyPressManager() - { - Cancel(); - - iWsSession.Close(); - } - -// -------------------------------------------------------------------------------------------- - -void CKeyPressManager::ConstructL() - { - CActiveScheduler::Add(this); - - // set the status as pending - iStatus = KRequestPending; - SetActive(); - - // set the death status pointer point to the request status of this ao - iAttributes.iDeathStatus = &iStatus; - - // init - User::LeaveIfError( iWsSession.Connect() ); - - // start timer - iPeriodicTimer = CPeriodic::NewL(CActive::EPriorityStandard); - iPeriodicTimer->Start(KDefaultStart, KDefaultPeriod, TCallBack(PeriodicTimerCallBack, this)); - } - -// -------------------------------------------------------------------------------------------- - -void CKeyPressManager::RunL() - { - // request status has completed by the main thread meaning that we need to stop now - CActiveScheduler::Stop(); - } - -// -------------------------------------------------------------------------------------------- - -void CKeyPressManager::DoCancel() - { - } - -// -------------------------------------------------------------------------------------------- - -TInt CKeyPressManager::PeriodicTimerCallBack(TAny* aAny) - { - CKeyPressManager* self = static_cast( aAny ); - - self->iPeriodicTimer->Cancel(); - self->SimulateKeyEvent(); - - return KErrNone; - } - -// -------------------------------------------------------------------------------------------- - -void CKeyPressManager::SimulateKeyEvent() - { - // generate a random key event from a to z - TKeyEvent keyEvent; - keyEvent.iCode = CLoadGenUtils::RandomNumber('a','z'); - keyEvent.iScanCode = keyEvent.iCode - 32; - keyEvent.iModifiers = 0; - keyEvent.iRepeats = 0; - - iWsSession.SimulateKeyEvent(keyEvent); - iWsSession.Flush(); - - // call timer - iPeriodicTimer->Start(CLoadGenUtils::MilliSecondsToMicroSeconds(iAttributes.iHeartBeat, iAttributes.iRandomVariance), KDefaultPeriod, TCallBack(PeriodicTimerCallBack, this)); - } - -// -------------------------------------------------------------------------------------------- - -// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/engine/src/loadgen_loadbase.cpp --- a/loadgen/engine/src/loadgen_loadbase.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,72 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -// INCLUDE FILES -#include "loadgen_loadbase.h" -#include "loadgen.hrh" - -// ===================================== MEMBER FUNCTIONS ===================================== - -CLoadBase::CLoadBase() - { - } - -// -------------------------------------------------------------------------------------------- - -void CLoadBase::ConstructL() - { - iState = ELoadStateInvalid; - } - -// -------------------------------------------------------------------------------------------- - -void CLoadBase::Resume() - { - iState = ELoadStateRunning; - } - -// -------------------------------------------------------------------------------------------- - -void CLoadBase::Suspend() - { - iState = ELoadStateSuspended; - } - -// -------------------------------------------------------------------------------------------- - -void CLoadBase::SetPriority() - { - } - -// -------------------------------------------------------------------------------------------- - -void CLoadBase::Close() - { - iState = ELoadStateClosed; - } - -// -------------------------------------------------------------------------------------------- - -TPtrC CLoadBase::Description() - { - return TPtrC(KNullDesC); - } - -// -------------------------------------------------------------------------------------------- - -// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/engine/src/loadgen_memoryeat.cpp --- a/loadgen/engine/src/loadgen_memoryeat.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,603 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -// INCLUDE FILES -#include "loadgen_memoryeat.h" -#include "loadgen_utils.h" -#include "loadgen.hrh" -#include "loadgen_traces.h" -#include - -#include - -_LIT(KThreadName, "MemEat %d"); -_LIT(KChunkName, "LoadGen %d"); -_LIT(KFilePath, "%c:\\system\\temp\\LoadGen-%d_%d.$$$"); - -// currently can only handle 2GB -const TInt64 KMaxEatSize = 2147483647; - -const TInt KDefaultStart = 50; -const TInt KDefaultPeriod = 5000000; - -// ===================================== MEMBER FUNCTIONS ===================================== - -CMemoryEat* CMemoryEat::NewL(TMemoryEatAttributes& aAttributes, TInt aReferenceNumber) - { - CMemoryEat* self = new(ELeave) CMemoryEat(aAttributes, aReferenceNumber); - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(self); - return self; - } - -// -------------------------------------------------------------------------------------------- - -CMemoryEat::~CMemoryEat() - { - Close(); - } - -// -------------------------------------------------------------------------------------------- - -CMemoryEat::CMemoryEat(TMemoryEatAttributes& aAttributes, TInt aReferenceNumber) : iAttributes(aAttributes) - { - iAttributes.iId = aReferenceNumber; - } - -// -------------------------------------------------------------------------------------------- - -void CMemoryEat::ConstructL() - { - CLoadBase::ConstructL(); - - iType = ELoadGenCmdNewLoadEatMemory; - - TBuf<64> threadName; - threadName.Format(KThreadName, iAttributes.iId); - - // create a thread - User::LeaveIfError(iThread.Create(threadName, ThreadFunction, KDefaultStackSize*2, KMinHeapSize, 32*1024*KMinHeapSize, (TAny*) &iAttributes )); - - // set priority of the thread - SetPriority(); - } - -// -------------------------------------------------------------------------------------------- - -TInt CMemoryEat::ThreadFunction(TAny* aThreadArg) - { - CTrapCleanup* pC = CTrapCleanup::New(); - CActiveScheduler* pS = new CActiveScheduler; - CActiveScheduler::Install(pS); - - // start memory eat, pass pointer to arguments - GenerateLoad(*((TMemoryEatAttributes*) aThreadArg)); - - delete pS; - delete pC; - - return KErrNone; - } - -// -------------------------------------------------------------------------------------------- - -void CMemoryEat::GenerateLoad(TMemoryEatAttributes& aAttributes) - { - CMemoryEatManager* memoryEatManager = NULL; - TRAPD(err, memoryEatManager = CMemoryEatManager::NewL(aAttributes)); - if (err == KErrNone) CActiveScheduler::Start(); - delete memoryEatManager; - } - -// -------------------------------------------------------------------------------------------- - -void CMemoryEat::Resume() - { - CLoadBase::Resume(); - - iThread.Resume(); - } - -// -------------------------------------------------------------------------------------------- - -void CMemoryEat::Suspend() - { - CLoadBase::Suspend(); - - iThread.Suspend(); - } - -// -------------------------------------------------------------------------------------------- - -void CMemoryEat::SetPriority() - { - CLoadBase::SetPriority(); - - iThread.SetPriority(CLoadGenUtils::SettingItemToThreadPriority(iAttributes.iPriority)); - } - -// -------------------------------------------------------------------------------------------- - -void CMemoryEat::Close() - { - CLoadBase::Close(); - - if (iThread.ExitReason() == 0) // check if the thread is still alive - { - // signal the thread that it needs to close - iThread.RequestComplete(iAttributes.iDeathStatus, KErrCancel); - - // wait the thread to die - TRequestStatus waiter; - iThread.Logon(waiter); - User::WaitForRequest(waiter); - iThread.Close(); - } - } - -// -------------------------------------------------------------------------------------------- - -TPtrC CMemoryEat::Description() - { - TBuf<256> buf; - TBuf<16> prioBuf; - CLoadGenUtils::SettingItemToThreadDescription(iAttributes.iPriority, prioBuf); - TBuf<16> srcBuf; - CLoadGenUtils::SettingItemToSourceDescription(iAttributes.iSource, srcBuf); - - if (iAttributes.iType == EMemoryEatTypeMemoryToEat) - { - _LIT(KMemoryEatEntryMemoryToEat, "[%d] MemEat src=%S prio=%S type=MemToEat amount=%LDB buf=%dB idle=%dms"); - - buf.Format(KMemoryEatEntryMemoryToEat, iAttributes.iId, &srcBuf, &prioBuf, iAttributes.iAmount, iAttributes.iBuffer, iAttributes.iIdle); - } - else if (iAttributes.iType == EMemoryEatTypeMemoryToBeLeft) - { - _LIT(KMemoryEatEntryMemoryToBeLeft, "[%d] MemEat src=%S prio=%S type=MemToBeLeft amount=%LDB buf=%dB idle=%dms"); - - buf.Format(KMemoryEatEntryMemoryToBeLeft, iAttributes.iId, &srcBuf, &prioBuf, iAttributes.iAmount, iAttributes.iBuffer, iAttributes.iIdle); - } - - else if (iAttributes.iType == EMemoryEatTypeWavy) - { - _LIT(KMemoryEatEntryRandom, "[%d] MemEat src=%S prio=%S type=Random min=%LDB max=%LDB buf=%dB idle=%dms"); - - buf.Format(KMemoryEatEntryRandom, iAttributes.iId, &srcBuf, &prioBuf, iAttributes.iRandomMin, iAttributes.iRandomMax, iAttributes.iBuffer, iAttributes.iIdle); - } - - return TPtrC(buf); - } - -// -------------------------------------------------------------------------------------------- -// -------------------------------------------------------------------------------------------- - -CMemoryEatManager* CMemoryEatManager::NewL(TMemoryEatAttributes& aAttributes) - { - CMemoryEatManager* self = new(ELeave) CMemoryEatManager(aAttributes); - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(); - return self; - } - -// -------------------------------------------------------------------------------------------- - -CMemoryEatManager::CMemoryEatManager(TMemoryEatAttributes& aAttributes) : - CActive(EPriorityStandard), iAttributes(aAttributes) - { - } - -// -------------------------------------------------------------------------------------------- - -CMemoryEatManager::~CMemoryEatManager() - { - Cancel(); - DestroyMemoryEat(); - } - -// -------------------------------------------------------------------------------------------- - -void CMemoryEatManager::ConstructL() - { - CActiveScheduler::Add(this); - - // set the status as pending - iStatus = KRequestPending; - SetActive(); - - // set the death status pointer point to the request status of this ao - iAttributes.iDeathStatus = &iStatus; - - // init - InitMemoryEatL(); - - // start timer - iPeriodicTimer = CPeriodic::NewL(CActive::EPriorityStandard); - iPeriodicTimer->Start(KDefaultStart, KDefaultPeriod, TCallBack(PeriodicTimerCallBack, this)); - } - -// -------------------------------------------------------------------------------------------- - -void CMemoryEatManager::RunL() - { - // request status has completed by the main thread meaning that we need to stop now - CActiveScheduler::Stop(); - } - -// -------------------------------------------------------------------------------------------- - -void CMemoryEatManager::DoCancel() - { - } - -// -------------------------------------------------------------------------------------------- - -TInt CMemoryEatManager::PeriodicTimerCallBack(TAny* aAny) - { - TInt result = KErrNone; - CMemoryEatManager* self = static_cast( aAny ); - - self->iPeriodicTimer->Cancel(); - TRAP( result, self->EatMemoryL() ); - - return result; - } - -// -------------------------------------------------------------------------------------------- - -void CMemoryEatManager::InitMemoryEatL() - { - // create a chunk for RAM - if (iAttributes.iSource == EMemoryEatSourceTypeRAM) - { - TBuf<64> chunkName; - chunkName.Format(KChunkName, iAttributes.iId); - - // set max size of the chunk to be size of the RAM memory - TMemoryInfoV1Buf ramMemory; - UserHal::MemoryInfo(ramMemory); - - User::LeaveIfError( iEatChunk.CreateGlobal(chunkName, 0, ramMemory().iMaxFreeRamInBytes-1, EOwnerThread) ); - } - - // create a temporary file to disk - else - { - // connect to RFs - User::LeaveIfError( iFs.Connect() ); - - iFilesCounter = 0; - - TFileName eatFileName; - eatFileName.Format( KFilePath, 'B'+iAttributes.iSource, iAttributes.iId, 1 ); - - iFs.MkDirAll( eatFileName ); - User::LeaveIfError( iEatFile.Replace( iFs, eatFileName, EFileWrite ) ); - iFilesCounter++; - } - - iWavyEatMoreMemory = ETrue; - } - -// -------------------------------------------------------------------------------------------- - -void CMemoryEatManager::DestroyMemoryEat() - { - if (iAttributes.iSource == EMemoryEatSourceTypeRAM) - { - iEatChunk.Adjust(0); - iEatChunk.Close(); - } - else - { - // close current file - - iEatFile.Flush(); - iEatFile.Close(); - - // delete created files - for ( TInt k = 1; k <= iFilesCounter; k++ ) - { - TFileName eatFileName; - eatFileName.Format( KFilePath, 'B'+iAttributes.iSource, iAttributes.iId, k ); - iFs.Delete( eatFileName ); - } - iFs.Close(); - } - } - -// -------------------------------------------------------------------------------------------- - -void CMemoryEatManager::EatMemoryL() - { - // get current sizes - TInt64 eatSizeNow(0); - TInt sizeNow(0); - TInt64 freeSystemMemory(0); - - if (iAttributes.iSource == EMemoryEatSourceTypeRAM) - { - eatSizeNow = iEatChunk.Size(); // get current chunk size - } - else - { - User::LeaveIfError( iEatFile.Size( sizeNow ) ); - if ( iFilesCounter > 1) - { - eatSizeNow += sizeNow + ( ( iFilesCounter - 1 ) * KMaxEatSize ); - } - else - { - eatSizeNow = sizeNow ; - } - } - LOGSTRING2("Loadgen:EatMemoryL eatSizeNow = %d", eatSizeNow ); - - freeSystemMemory = ReadFreeMemory(); - - // eat until specific amount of memory at most amount of buffer at a time - if (iAttributes.iType == EMemoryEatTypeMemoryToEat) - { - // grow partial buffer to match exact amount - if ( ( iAttributes.iAmount - eatSizeNow >= 0 && - iAttributes.iAmount - eatSizeNow < iAttributes.iBuffer ) ) - { - DoEatMemoryL( eatSizeNow + ( iAttributes.iAmount - eatSizeNow ) ); - } - - // grow full buffer - else if ( eatSizeNow < iAttributes.iAmount ) - { - DoEatMemoryL( eatSizeNow + iAttributes.iBuffer ); - } - // shrink partial buffer to match exact amount - else if (eatSizeNow - iAttributes.iAmount >= 0 && eatSizeNow - iAttributes.iAmount < iAttributes.iBuffer) - { - DoEatMemoryL(eatSizeNow - (eatSizeNow - iAttributes.iAmount)); - } - - // shrink full buffer - else if (eatSizeNow > iAttributes.iAmount) - { - DoEatMemoryL(eatSizeNow - iAttributes.iBuffer); - } - } - - - // eat until specific amount of free memory has been reached at most amount of buffer at a time - else if (iAttributes.iType == EMemoryEatTypeMemoryToBeLeft) - { - // grow partial buffer to match exact amount - if (freeSystemMemory - iAttributes.iAmount >= 0 && freeSystemMemory - iAttributes.iAmount < iAttributes.iBuffer) - { - DoEatMemoryL(eatSizeNow + (freeSystemMemory - iAttributes.iAmount)); - } - - // grow full buffer - else if (freeSystemMemory > iAttributes.iAmount) - { - DoEatMemoryL(eatSizeNow + iAttributes.iBuffer); - } - - // shrink partial buffer to match exact amount - if (iAttributes.iAmount - freeSystemMemory >= 0 && iAttributes.iAmount - freeSystemMemory < iAttributes.iBuffer) - { - DoEatMemoryL(eatSizeNow - (iAttributes.iAmount - freeSystemMemory)); - } - - // shrink full buffer - else if (freeSystemMemory < iAttributes.iAmount) - { - DoEatMemoryL(eatSizeNow - iAttributes.iBuffer); - } - } - - // wavy memory eat - else if (iAttributes.iType == EMemoryEatTypeWavy) - { - // grow to max value if not under it - if (freeSystemMemory > iAttributes.iRandomMax) - { - DoEatMemoryL(eatSizeNow + (freeSystemMemory - iAttributes.iRandomMax) + iAttributes.iBuffer); - iWavyEatMoreMemory = ETrue; // change direction - } - - // shrink to min value if not below it - else if (freeSystemMemory < iAttributes.iRandomMin) - { - DoEatMemoryL(eatSizeNow - (iAttributes.iRandomMin - freeSystemMemory) - iAttributes.iBuffer); - iWavyEatMoreMemory = EFalse; // change direction - } - - // grow or shrink - else - { - if (iWavyEatMoreMemory) - { - // grow partial buffer to match exact amount - if (freeSystemMemory - iAttributes.iRandomMin >= 0 && freeSystemMemory - iAttributes.iRandomMin < iAttributes.iBuffer) - { - DoEatMemoryL(eatSizeNow + (freeSystemMemory - iAttributes.iRandomMin)); - iWavyEatMoreMemory = EFalse; // change direction since limit reached - } - - // grow full buffer - else - { - DoEatMemoryL(eatSizeNow + iAttributes.iBuffer); - } - } - - else // shrink - { - // shrink partial buffer to match exact amount - if (iAttributes.iRandomMax - freeSystemMemory >= 0 && iAttributes.iRandomMax - freeSystemMemory < iAttributes.iBuffer) - { - DoEatMemoryL(eatSizeNow - (iAttributes.iRandomMax - freeSystemMemory)); - iWavyEatMoreMemory = ETrue; // change direction since limit reached - } - - // shrink full buffer - else - { - DoEatMemoryL(eatSizeNow - iAttributes.iBuffer); - } - } - } - } - - - // call timer - iPeriodicTimer->Start(CLoadGenUtils::MilliSecondsToMicroSeconds(iAttributes.iIdle, iAttributes.iRandomVariance), KDefaultPeriod, TCallBack(PeriodicTimerCallBack, this)); - } - -// -------------------------------------------------------------------------------------------- - -void CMemoryEatManager::DoEatMemoryL( TInt64 aNewSize ) - { - // check that new size is in valid range - if (aNewSize < 0) - { - aNewSize = 0; - } - LOGSTRING2("Loadgen::DoEatMemoryL aNewSize = %ld", aNewSize ); - // set new size - if (iAttributes.iSource == EMemoryEatSourceTypeRAM) - { - TInt err = iEatChunk.Adjust( aNewSize ); - } - else - { - HandleEatMemoryL( aNewSize ); - } - } - -// -------------------------------------------------------------------------------------------- - -void CMemoryEatManager::HandleEatMemoryL( TInt64 aNewSize ) - { - // current size = open file size + full files sizes - TInt currentFileSize = 0; - User::LeaveIfError( iEatFile.Size( currentFileSize ) ); - TInt64 currentSize = currentFileSize + ( ( iFilesCounter - 1 ) * KMaxEatSize ); - - if ( aNewSize > currentSize ) // increasing - { - AllocMemoryL( aNewSize ); - } - else if ( aNewSize < currentSize )//decreasing - { - FreeMemoryL( aNewSize ); - } - } - -// -------------------------------------------------------------------------------------------- -void CMemoryEatManager::AllocMemoryL( TInt64 aNewSize ) - { - LOGSTRING("Loadgen: CMemoryEatManager::AllocMemoryL =>"); - // size of the file that remains open - TInt64 sizeLeft = aNewSize % KMaxEatSize; - // amount of the files that is needed - TInt64 filesNeeded = aNewSize / KMaxEatSize; - if ( sizeLeft > 0 ) - { - filesNeeded++; - } - - if ( filesNeeded > iFilesCounter ) - { - // update current file size to 2 GB - User::LeaveIfError( iEatFile.SetSize( KMaxEatSize ) ); - // close current file - iEatFile.Flush(); - iEatFile.Close(); - - // open new file - TFileName eatFileName; - eatFileName.Format( KFilePath, 'B'+iAttributes.iSource, iAttributes.iId, ++iFilesCounter ); - - iFs.MkDirAll( eatFileName ); - User::LeaveIfError( iEatFile.Replace( iFs, eatFileName, EFileWrite ) ); - - } - User::LeaveIfError( iEatFile.SetSize( sizeLeft ) ); - LOGSTRING("Loadgen: CMemoryEatManager::AllocMemoryL <="); - } - -// -------------------------------------------------------------------------------------------- -void CMemoryEatManager::FreeMemoryL( TInt64 aNewSize ) - { - LOGSTRING("Loadgen: CMemoryEatManager::FreeMemoryL =>"); - // size of the file that remains open - TInt sizeLeft = aNewSize % KMaxEatSize; - - LOGSTRING2("Loadgen: sizeLeft = %d ", sizeLeft ); - // amount of the files that is needed - TInt filesNeeded = aNewSize / KMaxEatSize; - - if ( filesNeeded == 0 ) - { - filesNeeded = 1; - } - - if ( iFilesCounter > 1 && filesNeeded < iFilesCounter ) - { - TFileName eatFileName; - - // close current open file - iEatFile.Flush(); - iEatFile.Close(); - // remove file - eatFileName.Format( KFilePath, 'B'+iAttributes.iSource, iAttributes.iId, iFilesCounter-- ); - iFs.Delete( eatFileName ); - - // remove files not needed - while ( iFilesCounter > filesNeeded ) - { - eatFileName.Format( KFilePath, 'B'+iAttributes.iSource, iAttributes.iId, iFilesCounter-- ); - iFs.Delete( eatFileName ); - } - - // open new file - eatFileName.Format( KFilePath, 'B'+iAttributes.iSource, iAttributes.iId, iFilesCounter ); - User::LeaveIfError( iEatFile.Open( iFs, eatFileName, EFileWrite ) ); - } - User::LeaveIfError( iEatFile.SetSize( sizeLeft ) ); - LOGSTRING("Loadgen: CMemoryEatManager::FreeMemoryL <="); - } - -// -------------------------------------------------------------------------------------------- -TInt64 CMemoryEatManager::ReadFreeMemory() - { - if ( iAttributes.iSource == EMemoryEatSourceTypeRAM ) - { - TMemoryInfoV1Buf ramMemory; - UserHal::MemoryInfo( ramMemory ); // get available RAM - return (TInt64)ramMemory().iFreeRamInBytes; - } - else - { - TVolumeInfo volumeInfo; - iFs.Volume( volumeInfo, iAttributes.iSource + 1 ); // get available disk - return volumeInfo.iFree; - } - } -// -------------------------------------------------------------------------------------------- - -// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/engine/src/loadgen_messages.cpp --- a/loadgen/engine/src/loadgen_messages.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,990 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -// INCLUDE FILES -#include "loadgen_messages.h" -#include "loadgen_utils.h" -#include "loadgen.hrh" -#include -#include - -_LIT(KThreadName, "Messages %d"); -_LIT(KMessageSMS, "A test message from LoadGen S60 RnD tool. "); -_LIT( KMessageSMSType, "SMS" ); -_LIT( KMessageMMSType, "MMS" ); - -const TInt KTestMessageLength = 42; -const TInt KDefaultStart = 50; -const TInt KDefaultPeriod = 5000000; - -// ===================================== MEMBER FUNCTIONS ===================================== - -CMessages* CMessages::NewL( TMessageAttributes& aAttributes, TInt aReferenceNumber ) - { - CMessages* self = new(ELeave) CMessages( aAttributes, aReferenceNumber ); - CleanupStack::PushL( self ); - self->ConstructL(); - CleanupStack::Pop( self ); - return self; - } - -// -------------------------------------------------------------------------------------------- - -CMessages::~CMessages() - { - Close(); - } - -// -------------------------------------------------------------------------------------------- - -CMessages::CMessages( TMessageAttributes& aAttributes, - TInt aReferenceNumber ) - : iAttributes( aAttributes ) - { - iAttributes.iId = aReferenceNumber; - } - -// -------------------------------------------------------------------------------------------- - -void CMessages::ConstructL() - { - CLoadBase::ConstructL(); - - iType = ELoadGenCmdNewLoadMessages; - - TBuf<64> threadName; - threadName.Format( KThreadName, iAttributes.iId ); - - // create a thread - User::LeaveIfError( iThread.Create( threadName, - ThreadFunction, - KDefaultStackSize * 2, - KMinHeapSize, - 1024 * KMinHeapSize, - (TAny*) &iAttributes ) ); - - // set priority of the thread - SetPriority(); - } - -// -------------------------------------------------------------------------------------------- - -TInt CMessages::ThreadFunction(TAny* aThreadArg) - { - CTrapCleanup* pC = CTrapCleanup::New(); - CActiveScheduler* pS = new CActiveScheduler; - CActiveScheduler::Install( pS ); - - // start generating load, pass pointer to arguments - GenerateLoad( *( ( TMessageAttributes* ) aThreadArg ) ); - - delete pS; - delete pC; - - return KErrNone; - } - -// -------------------------------------------------------------------------------------------- - -void CMessages::GenerateLoad( TMessageAttributes& aAttributes ) - { - CMessageManager* messagesManager = NULL; - TRAPD( err, messagesManager = CMessageManager::NewL( aAttributes ) ); - - if ( err == KErrNone ) - { - CActiveScheduler::Start(); - } - delete messagesManager; - } - -// -------------------------------------------------------------------------------------------- - -void CMessages::Resume() - { - CLoadBase::Resume(); - - iThread.Resume(); - } - -// -------------------------------------------------------------------------------------------- - -void CMessages::Suspend() - { - CLoadBase::Suspend(); - - iThread.Suspend(); - } - -// -------------------------------------------------------------------------------------------- - -void CMessages::SetPriority() - { - CLoadBase::SetPriority(); - - iThread.SetPriority( CLoadGenUtils::SettingItemToThreadPriority( iAttributes.iPriority ) ); - } - -// -------------------------------------------------------------------------------------------- - -void CMessages::Close() - { - CLoadBase::Close(); - - if ( iThread.ExitReason() == 0 ) // check if the thread is still alive - { - // signal the thread that it needs to close - iThread.RequestComplete( iAttributes.iDeathStatus, KErrCancel ); - - // wait the thread to die - TRequestStatus waiter; - iThread.Logon( waiter ); - User::WaitForRequest( waiter ); - iThread.Close(); - } - } - -// -------------------------------------------------------------------------------------------- - -TPtrC CMessages::Description() - { - TBuf<256> buf; - TBuf<16> prioBuf; - TBuf<3> typeBuf; - CLoadGenUtils::SettingItemToThreadDescription( iAttributes.iPriority, prioBuf ); - if ( iAttributes.iMessageType == EMessageTypeSMS ) - { - typeBuf.Copy( KMessageSMSType ); - } - else - { - typeBuf.Copy( KMessageMMSType ); - } - _LIT(KMessagesEntry, "[%d] Type=%S prio=%S dest=%S idle=%dms random=%d%%"); - buf.Format( KMessagesEntry, iAttributes.iId, &typeBuf, &prioBuf, &iAttributes.iDestination, - iAttributes.iIdle, iAttributes.iRandomVariance ); - - return TPtrC( buf ); - } -// -------------------------------------------------------------------------------------------- - -CMessageManager* CMessageManager::NewL( TMessageAttributes& aAttributes ) - { - CMessageManager* self = new(ELeave) CMessageManager( aAttributes ); - CleanupStack::PushL( self ); - self->ConstructL(); - CleanupStack::Pop( self ); - return self; - } - -// -------------------------------------------------------------------------------------------- -CMessageManager::CMessageManager( TMessageAttributes& aAttributes ) : - CActive( EPriorityStandard ), iAttributes( aAttributes ), iState( EStateIdle ) - { - iMessageCounter = 0; - } - -// -------------------------------------------------------------------------------------------- - -CMessageManager::~CMessageManager() - { - Cancel(); - delete iMessage; - if ( iPeriodicTimer ) - { - iPeriodicTimer->Cancel(); - delete iPeriodicTimer; - } - if ( iAttributes.iMessageType == EMessageTypeSMS && iSmsHandler ) - { - delete iSmsHandler; - } - else if ( iMmsHandler ) - { - delete iMmsHandler; - } - } - -// -------------------------------------------------------------------------------------------- - -void CMessageManager::ConstructL() - { - CActiveScheduler::Add( this ); - - // set the status as pending - iStatus = KRequestPending; - SetActive(); - - // set the death status pointer point to the request status of this ao - iAttributes.iDeathStatus = &iStatus; - if ( iAttributes.iAmount > 0 ) - { - iState = EStateSend; - } - iMessage = HBufC::NewL( iAttributes.iLength ); - CreateMessage(); - - // init SMS sender ao - if ( iAttributes.iMessageType == EMessageTypeSMS ) - { - iSmsHandler = CSmsHandler::NewL( *this ); - } - else - { - iMmsHandler = CMmsHandler::NewL( *this ); - } - // start timer - iPeriodicTimer = CPeriodic::NewL( CActive::EPriorityStandard ); - iPeriodicTimer->Start( KDefaultStart, KDefaultPeriod, - TCallBack( PeriodicTimerCallBack, this ) ); - } - -// -------------------------------------------------------------------------------------------- - -void CMessageManager::RunL() - { - // request status has completed by the main thread meaning that we need to stop now - CActiveScheduler::Stop(); - } - -// -------------------------------------------------------------------------------------------- - -void CMessageManager::DoCancel() - { - } - -// -------------------------------------------------------------------------------------------- - -TInt CMessageManager::PeriodicTimerCallBack(TAny* aAny) - { - CMessageManager* self = static_cast( aAny ); - - self->iPeriodicTimer->Cancel(); - self->HandleMessageSending(); - - return KErrNone; - } - -// -------------------------------------------------------------------------------------------- - -void CMessageManager::CreateMessage() - { - // Message body - TBuf mToYou( KMessageSMS ); - TPtr ptr = iMessage->Des(); - - // Take as many characters as user requested to create the message - for ( TInt j = 0; j < iAttributes.iLength; j++ ) - { - for ( TInt k = 0; k < KTestMessageLength; k++ ) - { - ptr.Append( mToYou[k] ); - j++; - if ( j == iAttributes.iLength ) - { - break; - } - } - } - } - - -// -------------------------------------------------------------------------------------------- - -void CMessageManager::HandleMessageSending() - { - if ( iState == EStateSend && iAttributes.iDestination.Length() <= KTelephoneNumberMaxLength ) - { - TBool err( KErrNone ); - - // make a new call - iState = EStateSending; - - iMessageCounter++; - if ( iAttributes.iMessageType == EMessageTypeSMS ) - { - TRAP( err, iSmsHandler->SendL( iAttributes.iDestination, *iMessage ) ); - if ( !err ) - { - iState = EStateIdle; - iPeriodicTimer->Start( CLoadGenUtils::MilliSecondsToMicroSeconds( iAttributes.iIdle, - iAttributes.iRandomVariance ), KDefaultPeriod, - TCallBack( PeriodicTimerCallBack, this ) ); - - } - } - else - { - TRAP( err, iMmsHandler->SendL( iAttributes.iDestination, *iMessage ) ); - if ( err ) - { - HandleStatus( EStateIdle ); - } - } - } - else - { - iState = EStateIdle; - iPeriodicTimer->Start( CLoadGenUtils::MilliSecondsToMicroSeconds( iAttributes.iIdle, - iAttributes.iRandomVariance ), KDefaultPeriod, - TCallBack( PeriodicTimerCallBack, this ) ); - - } - } - -// -------------------------------------------------------------------------------------------- - -void CMessageManager::HandleStatus( TInt /*aErr*/ ) - { - // timer after wait - if ( iMessageCounter < iAttributes.iAmount ) - { - iState = EStateSend; - iPeriodicTimer->Cancel(); - iPeriodicTimer->Start( CLoadGenUtils::MilliSecondsToMicroSeconds( iAttributes.iIdle, - iAttributes.iRandomVariance ), KDefaultPeriod, - TCallBack( PeriodicTimerCallBack, this ) ); - } - } - -// -------------------------------------------------------------------------------------------- -// -------------------------------------------------------------------------------------------- -// INCLUDE FILES -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "smutset.h" -#include "smuthdr.h" - - - -// ============================ MEMBER FUNCTIONS =============================== -// ----------------------------------------------------------------------------- -// CSmsHandler::CSmsHandler() -// C++ default constructor can NOT contain any code, that might leave. -// ----------------------------------------------------------------------------- -// -CSmsHandler::CSmsHandler( CMessageManager& aManager ) - : CActive( CActive::EPriorityStandard ), iManager( aManager ) - { - CActiveScheduler::Add( this ); - } - -// ----------------------------------------------------------------------------- -// CSmsHandler::ConstructL() -// Symbian 2nd phase constructor can leave. -// ----------------------------------------------------------------------------- -// -void CSmsHandler::ConstructL() - { - // Session to message server is opened asynchronously. - iSession = CMsvSession::OpenAsyncL( *this ); - - } - -// ----------------------------------------------------------------------------- -// CSmsHandler::NewL() -// Two-phased constructor. -// ----------------------------------------------------------------------------- -// -CSmsHandler* CSmsHandler::NewL( CMessageManager& aManager ) - { - CSmsHandler* self = NewLC( aManager ); - CleanupStack::Pop( self ); - return self; - } - -// ----------------------------------------------------------------------------- -// CSmsHandler::NewLC() -// Two-phased constructor. -// ----------------------------------------------------------------------------- -// -CSmsHandler* CSmsHandler::NewLC( CMessageManager& aManager ) - { - CSmsHandler* self = new ( ELeave ) CSmsHandler( aManager ); - CleanupStack::PushL( self ); - self->ConstructL(); - return self; - } - -// ---------------------------------------------------------- -// CSmsHandler::~CSmsHandler() -// Destructor. -// ---------------------------------------------------------- -// -CSmsHandler::~CSmsHandler() - { - Cancel(); // cancel any outstanding request - - delete iOperation; - delete iMtmUiRegistry; - delete iSmsMtm; - delete iMtmRegistry; - delete iSession; // session must be deleted last - } - -// ----------------------------------------------------------------------------- -// CSmsHandler::DoCancel() -// Cancels a request. -// ----------------------------------------------------------------------------- -// -void CSmsHandler::DoCancel() - { - if ( iOperation ) - { - iOperation->Cancel(); - } - } - -// ----------------------------------------------------------------------------- -// CSmsHandler::RunL() -// Handles request completion events. -// ----------------------------------------------------------------------------- -// -void CSmsHandler::RunL() - { - User::LeaveIfError( iStatus != KErrNone ); - - // Determine the current operations progress. - // ProgressL returns an 8 bit descriptor. - TBufC8 progress( iOperation->ProgressL() ); - _LIT8( KCompare, "KErrNone" ); - User::LeaveIfError( !progress.Compare( KCompare ) ); - - // The pointer to the current CMsvOperation object is no longer needed. - delete iOperation; - iOperation = NULL; - - // Determine which request has finished. - switch ( iState ) - { - case EWaitingForMoving: - // Once a message is moved to Outbox it is scheduled for sending. - ScheduleL(); - break; - - case EWaitingForScheduling: - { - TMsvEntry entry( iSmsMtm->Entry().Entry() ); - TInt state( entry.SendingState() ); - - if ( state == KMsvSendStateWaiting || state == KMsvSendStateScheduled) - { - // notify the observer that status has changed - iManager.HandleStatus( iStatus.Int() ); - } - break; - } - - default: - break; - } - } - -// ----------------------------------------------------------------------------- -// CSmsHandler::HandleSessionEventL() -// Handles notifications of events from the Message Server. -// ----------------------------------------------------------------------------- -// -void CSmsHandler::HandleSessionEventL( TMsvSessionEvent aEvent, - TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/) - { - switch ( aEvent ) - { - // Session to server established - case EMsvServerReady: - { - TMsvId serviceId( KUidMsgTypeSMS.iUid ); // SMS service id - - // Determine if the event was succesful. - // ServiceProgress inserts TBuf8 value in progress. - TBuf8 progress; - iSession->ServiceProgress( serviceId, progress ); - _LIT8( KCompare, "KErrNone" ); - - if ( progress.Compare( KCompare ) ) - { - // Check that MtmRegistry has not already been accessed. - if ( !iMtmRegistry ) - { - AccessMtmL(); - } - } - break; - } - - // All other events are ignored. - default: - break; - } - } - -// ----------------------------------------------------------------------------- -// CSmsHandler::AccessMtmL() -// Access the MTM Registry and create a SMS specific Client MTM instance. -// ----------------------------------------------------------------------------- -// -void CSmsHandler::AccessMtmL() - { - // Create an MTM Registry object. - iMtmRegistry = CClientMtmRegistry::NewL( *iSession ); - - // Create an SMS Client MTM object. - iSmsMtm = STATIC_CAST( CSmsClientMtm*, iMtmRegistry->NewMtmL( KUidMsgTypeSMS ) ); - } - -// ----------------------------------------------------------------------------- -// CSmsHandler::SendL() -// Starts the process of creating and sending an SMS message. -// ----------------------------------------------------------------------------- -// -TBool CSmsHandler::SendL( const TDesC& aRecipientNumber, - const TDesC& aMessageText ) - { - iRecipientNumber = aRecipientNumber; - iMessageText = aMessageText; - - if ( CreateMsgL() ) - { - return ETrue; - } - - return EFalse; - } - -// ----------------------------------------------------------------------------- -// CSmsHandler::CreateMsgL() -// Create an SMS message. -// ----------------------------------------------------------------------------- -// -TBool CSmsHandler::CreateMsgL() - { - if(!iSmsMtm) - { - return EFalse; - } - // Current entry is the Draft folder. - iSmsMtm->SwitchCurrentEntryL( KMsvDraftEntryId ); - - // Create a new SMS message entry as a child of the current context. - iSmsMtm->CreateMessageL( KUidMsgTypeSMS.iUid ); - - CMsvEntry& serverEntry = iSmsMtm->Entry(); - TMsvEntry entry( serverEntry.Entry() ); - - CRichText& body = iSmsMtm->Body(); // the body of the message - body.Reset(); - // Insert the message text gotten as input from user. - body.InsertL( 0, iMessageText ); - - // Message will be sent immediately. - entry.SetSendingState( KMsvSendStateWaiting ); - - entry.iDate.UniversalTime(); // insert current time //Solution for HomeTime() - - // Set the SMS message settings for the message. - CSmsHeader& header = iSmsMtm->SmsHeader(); - CSmsSettings* settings = CSmsSettings::NewL(); - CleanupStack::PushL( settings ); - - settings->CopyL( iSmsMtm->ServiceSettings() ); // restore settings - settings->SetDelivery( ESmsDeliveryImmediately ); // to be delivered immediately - settings->SetDeliveryReport(ETrue); - header.SetSmsSettingsL( *settings ); // new settings - - // Let's check if there is a service center address. - if ( header.Message().ServiceCenterAddress().Length() == 0 ) - { - // No, there isn't. We assume there is at least one service center - // number set and use the default service center number. - CSmsSettings* serviceSettings = &( iSmsMtm->ServiceSettings() ); - - // Check if number of service center addresses in the list is null. - - //Changed for 3rd Edition specially - if ( !serviceSettings->ServiceCenterCount() ) - { - CleanupStack::PopAndDestroy( settings ); - return EFalse; // quit creating the message - } - - else - { - //Changed for 3rd Edition specially - CSmsNumber* smsCenter= CSmsNumber::NewL(); - CleanupStack::PushL(smsCenter); - smsCenter->SetAddressL((serviceSettings->GetServiceCenter( - serviceSettings->DefaultServiceCenter())).Address()); - header.Message().SetServiceCenterAddressL( smsCenter->Address() ); - CleanupStack::PopAndDestroy(smsCenter); - } - } - - CleanupStack::PopAndDestroy( settings ); - - // Recipient number is displayed also as the recipient alias. - entry.iDetails.Set( iRecipientNumber ); - // Add addressee. - iSmsMtm->AddAddresseeL( iRecipientNumber, entry.iDetails ); - - // Validate message. - if ( !ValidateL() ) - { - return EFalse; - } - - entry.SetVisible( ETrue ); // set message as visible - entry.SetInPreparation( EFalse ); // set together with the visibility flag - serverEntry.ChangeL( entry ); // commit changes - iSmsMtm->SaveMessageL(); // save message - - TMsvSelectionOrdering selection; - CMsvEntry* parentEntry = CMsvEntry::NewL( iSmsMtm->Session(), KMsvDraftEntryId, selection ); - CleanupStack::PushL( parentEntry ); - - // Move message to Outbox. - iOperation =parentEntry->MoveL( entry.Id(), KMsvGlobalOutBoxIndexEntryId, iStatus ); - - CleanupStack::PopAndDestroy( parentEntry ); - - iState = EWaitingForMoving; - SetActive(); - - return ETrue; - } - -// ----------------------------------------------------------------------------- -// CSmsHandler::ValidateL() -// Validate an SMS message. -// ----------------------------------------------------------------------------- -// -TBool CSmsHandler::ValidateL() - { - if( !iSmsMtm ) - { - return EFalse; - } - // Empty part list to hold the result. - TMsvPartList result( KMsvMessagePartNone ); - - // Validate message body. - result = iSmsMtm->ValidateMessage( KMsvMessagePartBody ); - - if ( result != KMsvMessagePartNone ) - { - return EFalse; - } - - // Validate recipient. - result = iSmsMtm->ValidateMessage( KMsvMessagePartRecipient ); - - if ( result != KMsvMessagePartNone ) - { - return EFalse; - } - - return ETrue; - } - -// ----------------------------------------------------------------------------- -// CSmsHandler::ScheduleL() -// Schedule an SMS message for sending. -// ----------------------------------------------------------------------------- -// -void CSmsHandler::ScheduleL() - { - if( !iSmsMtm ) - { - return; - } - CMsvEntrySelection* selection = new ( ELeave ) CMsvEntrySelection; - CleanupStack::PushL( selection ); - selection->AppendL( iSmsMtm->Entry().EntryId() ); // add message to selection - - // Add entry to task scheduler. - TBuf8<1> dummyParams; // dummy parameters needed for InvokeAsyncFunctionL - iOperation = iSmsMtm->InvokeAsyncFunctionL( ESmsMtmCommandScheduleCopy, - *selection, dummyParams, iStatus ); - - CleanupStack::PopAndDestroy( selection ); - - iState = EWaitingForScheduling; - SetActive(); - } - -// -------------------------------------------------------------------------------------------- -// -------------------------------------------------------------------------------------------- - - - -// INCLUDE FILES -#include // for CClientMtmRegistry -#include // for Message type IDs -#include // for CMmsClientMtm -#include // for CAknTextQueryDialog -#include -#include // Check the file exist - -#include //Attachemt mimeheader -#include //Attachment manager - -// ----------------------------------------------------------------------------- -// CMmsHandler::CSmsHandler() -// C++ default constructor can NOT contain any code, that might leave. -// ----------------------------------------------------------------------------- -// -CMmsHandler::CMmsHandler( CMessageManager& aManager ) : iManager( aManager ) - { - } - -// ----------------------------------------------------------------------------- -// CMmsHandler::ConstructL() -// Symbian 2nd phase constructor can leave. -// ----------------------------------------------------------------------------- -// -void CMmsHandler::ConstructL() - { - // Session to message server is opened asynchronously. - iSession = CMsvSession::OpenAsyncL( *this ); - - } - -// ----------------------------------------------------------------------------- -// CMmsHandler::NewL() -// Two-phased constructor. -// ----------------------------------------------------------------------------- -// -CMmsHandler* CMmsHandler::NewL( CMessageManager& aManager ) - { - CMmsHandler* self = NewLC( aManager ); - CleanupStack::Pop( self ); - return self; - } - -// ----------------------------------------------------------------------------- -// CMmsHandler::NewLC() -// Two-phased constructor. -// ----------------------------------------------------------------------------- -// -CMmsHandler* CMmsHandler::NewLC( CMessageManager& aManager ) - { - CMmsHandler* self = new ( ELeave ) CMmsHandler( aManager ); - CleanupStack::PushL( self ); - self->ConstructL(); - return self; - } - -// ---------------------------------------------------------- -// CMmsHandler::~CSmsHandler() -// Destructor. -// ---------------------------------------------------------- -// -CMmsHandler::~CMmsHandler() - { - delete iMmsMtm; - delete iMtmReg; - delete iSession; // session must be deleted last (and constructed first) - } - -/* ------------------------------------------------------------------------------ - CMmsHandler::CompleteConstructL() - Creates client MTM registry when session is ready for use. - This completes model construction and is called after 'server - ready' event is received after async opening of CMsvSession. ------------------------------------------------------------------------------ -*/ -void CMmsHandler::CompleteConstructL() - { - // We get a MtmClientRegistry from our session - // this registry is used to instantiate new mtms. - iMtmReg = CClientMtmRegistry::NewL( *iSession ); - iMmsMtm = (CMmsClientMtm*)iMtmReg->NewMtmL( KUidMsgTypeMultimedia ); - } - -/* ------------------------------------------------------------------------------ - CMmsHandler::HandleSessionEventL() - - Receives session events from observer and calls event handling functions. - Note that if additional session event handlers are defined - in the session, they are called before this function (as this is the - main session observer). - The type of event is indicated by the value of aEvent. The - interpretation of the TAny arguments depends on this type. ------------------------------------------------------------------------------ -*/ -void CMmsHandler::HandleSessionEventL(TMsvSessionEvent aEvent, - TAny* /*aArg1*/, - TAny* /*aArg2*/, - TAny* /*aArg3*/) - { - switch ( aEvent ) - { - // This event tells us that the session has been opened - case EMsvServerReady: - { - CompleteConstructL(); // Construct the mtm registry & MMS mtm - break; - } - default: - { - break; - } - } - } - - -// ----------------------------------------------------------------------------- -// CSmsHandler::SendL() -// Starts the process of creating and sending an SMS message. -// ----------------------------------------------------------------------------- -// -TBool CMmsHandler::SendL( const TDesC& aRecipientNumber, - const TDesC& aMessageText ) - { - TInt result( EFalse ); - - iRecipientNumber = aRecipientNumber; - iMessageText = aMessageText; - - if ( CreateMsgL() ) - { - if ( SendMessageL() ) - { - result = ETrue; - } - } - - return result; - } - -/* ------------------------------------------------------------------------------ - CMmsHandler::CreateMsgL() - Creates a new message server entry and set up default values. - In case the attachment file does not found method return EFalse - otherwise ETrue. - There are differenses how to add attachment file between 2nd and 3rd edition. ------------------------------------------------------------------------------ -*/ -TBool CMmsHandler::CreateMsgL() - { - - // - CMsvEntry accesses and acts upon a particular Message Server entry. - // - NewL() does not create a new entry, but simply a new object to access an existing entry. - // - It takes in as parameters the client's message server session, - // ID of the entry to access and initial sorting order of the children of the entry. - CMsvEntry* entry = CMsvEntry::NewL( *iSession, - KMsvGlobalOutBoxIndexEntryId, - TMsvSelectionOrdering() ); - CleanupStack::PushL( entry ); - - // Set context to the parent folder (Outbox) - iMmsMtm->SwitchCurrentEntryL( entry->EntryId() ); - - // Create new message in the parent folder (Outbox) and set it as the current context. - iMmsMtm->CreateMessageL( iMmsMtm->DefaultServiceL() ); - - CleanupStack::PopAndDestroy( entry ); - - // Setting recipients - // use this to add the "To" recipients. - iMmsMtm->AddAddresseeL( iRecipientNumber ); - - //Setting message subject - _LIT(KMessageSubject, "MMS Message"); - iMmsMtm->SetSubjectL( KMessageSubject ); - - // add message text - SetMessageBodyL(); - - TMsvEntry ent = iMmsMtm->Entry().Entry(); - // Set InPreparation to false - ent.SetInPreparation( EFalse ); - ent.SetVisible( ETrue ); // mark as visible, after this the message can be seen in Outbox and, after sending, in Sent folder. - - iMmsMtm->Entry().ChangeL( ent ); // Commit changes - - //Save the changes - iMmsMtm->SaveMessageL(); - - return ETrue; - } - -//--------------------------------------------------------------------------------- -void CMmsHandler::SetMessageBodyL() - { - _LIT (KFilenameText, "msg.txt"); - CMsvStore* store = iMmsMtm->Entry().EditStoreL(); - CleanupStack::PushL( store ); - - TMsvAttachmentId attachmentId = KMsvNullIndexEntryId; - - iMmsMtm->CreateTextAttachmentL ( *store, - attachmentId, - iMessageText, - KFilenameText ); - - store->CommitL(); - - CleanupStack::PopAndDestroy( store ); - } - -/* ------------------------------------------------------------------------------ - CMmsHandler::SendMessageL() - Sends the message. - Return values: ETrue or EFalse ------------------------------------------------------------------------------ -*/ -TBool CMmsHandler::SendMessageL() - { - - // Start sending the message via the Server MTM to the MMS server - CMsvOperationWait* wait = CMsvOperationWait::NewLC(); - wait->iStatus = KRequestPending; - CMsvOperation* op = NULL; - op = iMmsMtm->SendL( wait->iStatus ); - wait->Start(); - CleanupStack::PushL( op ); - CActiveScheduler::Start(); - - // The following is to ignore the completion of other active objects. It is not - // needed if the app has a command absorbing control. - while( wait->iStatus == KRequestPending ) - { - CActiveScheduler::Start(); - } - - iManager.HandleStatus( wait->iStatus.Int() ); - CleanupStack::PopAndDestroy(2); // op, wait - - return ETrue; - } -// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/engine/src/loadgen_netconn.cpp --- a/loadgen/engine/src/loadgen_netconn.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,271 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -// INCLUDE FILES -#include "loadgen_netconn.h" -#include "loadgen_utils.h" -#include "loadgen.hrh" -#include - -#include -#include - -_LIT(KThreadName, "NetConn %d"); - -const TInt KDefaultStart = 50; -const TInt KDefaultPeriod = 5000000; - -// ===================================== MEMBER FUNCTIONS ===================================== - -CNetConn* CNetConn::NewL(TNetConnAttributes& aAttributes, TInt aReferenceNumber) - { - CNetConn* self = new(ELeave) CNetConn(aAttributes, aReferenceNumber); - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(self); - return self; - } - -// -------------------------------------------------------------------------------------------- - -CNetConn::~CNetConn() - { - Close(); - } - -// -------------------------------------------------------------------------------------------- - -CNetConn::CNetConn(TNetConnAttributes& aAttributes, TInt aReferenceNumber) : iAttributes(aAttributes) - { - iAttributes.iId = aReferenceNumber; - } - -// -------------------------------------------------------------------------------------------- - -void CNetConn::ConstructL() - { - CLoadBase::ConstructL(); - - iType = ELoadGenCmdNewLoadNetConn; - - TBuf<64> threadName; - threadName.Format(KThreadName, iAttributes.iId); - - // create a thread - User::LeaveIfError(iThread.Create(threadName, ThreadFunction, KDefaultStackSize*2, 1024*KMinHeapSize, 16*1024*KMinHeapSize, (TAny*) &iAttributes )); - - // set priority of the thread - SetPriority(); - } - -// -------------------------------------------------------------------------------------------- - -TInt CNetConn::ThreadFunction(TAny* aThreadArg) - { - CTrapCleanup* pC = CTrapCleanup::New(); - CActiveScheduler* pS = new CActiveScheduler; - CActiveScheduler::Install(pS); - - // start generating load, pass pointer to arguments - GenerateLoad(*((TNetConnAttributes*) aThreadArg)); - - delete pS; - delete pC; - - return KErrNone; - } - -// -------------------------------------------------------------------------------------------- - -void CNetConn::GenerateLoad(TNetConnAttributes& aAttributes) - { - CNetConnManager* netConnManager = NULL; - TRAPD(err, netConnManager = CNetConnManager::NewL(aAttributes)); - if (err == KErrNone) CActiveScheduler::Start(); - delete netConnManager; - } - -// -------------------------------------------------------------------------------------------- - -void CNetConn::Resume() - { - CLoadBase::Resume(); - - iThread.Resume(); - } - -// -------------------------------------------------------------------------------------------- - -void CNetConn::Suspend() - { - CLoadBase::Suspend(); - - iThread.Suspend(); - } - -// -------------------------------------------------------------------------------------------- - -void CNetConn::SetPriority() - { - CLoadBase::SetPriority(); - - iThread.SetPriority(CLoadGenUtils::SettingItemToThreadPriority(iAttributes.iPriority)); - } - -// -------------------------------------------------------------------------------------------- - -void CNetConn::Close() - { - CLoadBase::Close(); - - if (iThread.ExitReason() == 0) // check if the thread is still alive - { - // signal the thread that it needs to close - iThread.RequestComplete(iAttributes.iDeathStatus, KErrCancel); - - // wait the thread to die - TRequestStatus waiter; - iThread.Logon(waiter); - User::WaitForRequest(waiter); - iThread.Close(); - } - } - -// -------------------------------------------------------------------------------------------- - -TPtrC CNetConn::Description() - { - TBuf<256> buf; - TBuf<16> prioBuf; - CLoadGenUtils::SettingItemToThreadDescription(iAttributes.iPriority, prioBuf); - - _LIT(KNetConnEntry, "[%d] NetConn prio=%S dest=%S idle=%dms random=%d%%"); - buf.Format(KNetConnEntry, iAttributes.iId, &prioBuf, &iAttributes.iDestination, iAttributes.iIdle, iAttributes.iRandomVariance); - - return TPtrC(buf); - } - -// -------------------------------------------------------------------------------------------- -// -------------------------------------------------------------------------------------------- - -CNetConnManager* CNetConnManager::NewL(TNetConnAttributes& aAttributes) - { - CNetConnManager* self = new(ELeave) CNetConnManager(aAttributes); - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(); - return self; - } - -// -------------------------------------------------------------------------------------------- - -CNetConnManager::CNetConnManager(TNetConnAttributes& aAttributes) : - CActive(EPriorityStandard), iAttributes(aAttributes) - { - } - -// -------------------------------------------------------------------------------------------- - -CNetConnManager::~CNetConnManager() - { - Cancel(); - - delete iHTTPReceiver; - } - -// -------------------------------------------------------------------------------------------- - -void CNetConnManager::ConstructL() - { - CActiveScheduler::Add(this); - - // set the status as pending - iStatus = KRequestPending; - SetActive(); - - // set the death status pointer point to the request status of this ao - iAttributes.iDeathStatus = &iStatus; - - iHTTPReceiver = CHTTPReceiver::NewL( *this ); - - // start timer - iPeriodicTimer = CPeriodic::NewL(CActive::EPriorityStandard); - iPeriodicTimer->Start(KDefaultStart, KDefaultPeriod, TCallBack(PeriodicTimerCallBack, this)); - } - -// -------------------------------------------------------------------------------------------- - -void CNetConnManager::RunL() - { - // request status has completed by the main thread meaning that we need to stop now - CActiveScheduler::Stop(); - } - -// -------------------------------------------------------------------------------------------- - -void CNetConnManager::DoCancel() - { - } - -// -------------------------------------------------------------------------------------------- - -TInt CNetConnManager::PeriodicTimerCallBack(TAny* aAny) - { - CNetConnManager* self = static_cast( aAny ); - - self->iPeriodicTimer->Cancel(); - TRAPD(err,self->StartDownloadL()); - - return err; - } - -// -------------------------------------------------------------------------------------------- - -void CNetConnManager::StartDownloadL() - { - - // create new download - TBuf8<256> url; - url.Copy(iAttributes.iDestination); - - iHTTPReceiver->SendHTTPGetL( url ); - } - -// -------------------------------------------------------------------------------------------- - -void CNetConnManager::HTTPFileReceived( TInt aStatus ) - { - switch ( aStatus ) - { - case 200: - { - // assume that the download has finished in this stage - iPeriodicTimer->Start(CLoadGenUtils::MilliSecondsToMicroSeconds(iAttributes.iIdle, iAttributes.iRandomVariance), KDefaultPeriod, TCallBack(PeriodicTimerCallBack, this)); - break; - } - - default: - { - break; - } - } - } - -// -------------------------------------------------------------------------------------------- - -// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/engine/src/loadgen_phonecall.cpp --- a/loadgen/engine/src/loadgen_phonecall.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,353 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -// INCLUDE FILES -#include "loadgen_phonecall.h" -#include "loadgen_utils.h" -#include "loadgen.hrh" -#include - -#include - -_LIT(KThreadName, "PhoneCall %d"); - -const TInt KDefaultStart = 50; -const TInt KDefaultPeriod = 5000000; - -// ===================================== MEMBER FUNCTIONS ===================================== - -CPhoneCall* CPhoneCall::NewL(TPhoneCallAttributes& aAttributes, TInt aReferenceNumber) - { - CPhoneCall* self = new(ELeave) CPhoneCall(aAttributes, aReferenceNumber); - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(self); - return self; - } - -// -------------------------------------------------------------------------------------------- - -CPhoneCall::~CPhoneCall() - { - Close(); - } - -// -------------------------------------------------------------------------------------------- - -CPhoneCall::CPhoneCall(TPhoneCallAttributes& aAttributes, TInt aReferenceNumber) : iAttributes(aAttributes) - { - iAttributes.iId = aReferenceNumber; - } - -// -------------------------------------------------------------------------------------------- - -void CPhoneCall::ConstructL() - { - CLoadBase::ConstructL(); - - iType = ELoadGenCmdNewLoadPhoneCall; - - TBuf<64> threadName; - threadName.Format(KThreadName, iAttributes.iId); - - // create a thread - User::LeaveIfError(iThread.Create(threadName, ThreadFunction, KDefaultStackSize*2, KMinHeapSize, 1024*KMinHeapSize, (TAny*) &iAttributes )); - - // set priority of the thread - SetPriority(); - } - -// -------------------------------------------------------------------------------------------- - -TInt CPhoneCall::ThreadFunction(TAny* aThreadArg) - { - CTrapCleanup* pC = CTrapCleanup::New(); - CActiveScheduler* pS = new CActiveScheduler; - CActiveScheduler::Install(pS); - - // start generating load, pass pointer to arguments - GenerateLoad(*((TPhoneCallAttributes*) aThreadArg)); - - delete pS; - delete pC; - - return KErrNone; - } - -// -------------------------------------------------------------------------------------------- - -void CPhoneCall::GenerateLoad(TPhoneCallAttributes& aAttributes) - { - CPhoneCallManager* phoneCallManager = NULL; - TRAPD(err, phoneCallManager = CPhoneCallManager::NewL(aAttributes)); - if (err == KErrNone) CActiveScheduler::Start(); - delete phoneCallManager; - } - -// -------------------------------------------------------------------------------------------- - -void CPhoneCall::Resume() - { - CLoadBase::Resume(); - - iThread.Resume(); - } - -// -------------------------------------------------------------------------------------------- - -void CPhoneCall::Suspend() - { - CLoadBase::Suspend(); - - iThread.Suspend(); - } - -// -------------------------------------------------------------------------------------------- - -void CPhoneCall::SetPriority() - { - CLoadBase::SetPriority(); - - iThread.SetPriority(CLoadGenUtils::SettingItemToThreadPriority(iAttributes.iPriority)); - } - -// -------------------------------------------------------------------------------------------- - -void CPhoneCall::Close() - { - CLoadBase::Close(); - - if (iThread.ExitReason() == 0) // check if the thread is still alive - { - // signal the thread that it needs to close - iThread.RequestComplete(iAttributes.iDeathStatus, KErrCancel); - - // wait the thread to die - TRequestStatus waiter; - iThread.Logon(waiter); - User::WaitForRequest(waiter); - iThread.Close(); - } - } - -// -------------------------------------------------------------------------------------------- - -TPtrC CPhoneCall::Description() - { - TBuf<256> buf; - TBuf<16> prioBuf; - CLoadGenUtils::SettingItemToThreadDescription(iAttributes.iPriority, prioBuf); - - _LIT(KPhoneCallEntry, "[%d] PhoneCall prio=%S dest=%S length=%dms idle=%dms random=%d%%"); - buf.Format(KPhoneCallEntry, iAttributes.iId, &prioBuf, &iAttributes.iDestination, iAttributes.iLength, iAttributes.iIdle, iAttributes.iRandomVariance); - - return TPtrC(buf); - } - -// -------------------------------------------------------------------------------------------- -// -------------------------------------------------------------------------------------------- - -CPhoneCallManager* CPhoneCallManager::NewL(TPhoneCallAttributes& aAttributes) - { - CPhoneCallManager* self = new(ELeave) CPhoneCallManager(aAttributes); - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(); - return self; - } - -// -------------------------------------------------------------------------------------------- - -CPhoneCallManager::CPhoneCallManager(TPhoneCallAttributes& aAttributes) : - CActive(EPriorityStandard), iAttributes(aAttributes), iState(EStateIdle) - { - } - -// -------------------------------------------------------------------------------------------- - -CPhoneCallManager::~CPhoneCallManager() - { - Cancel(); - - if (iPeriodicTimer) - { - iPeriodicTimer->Cancel(); - delete iPeriodicTimer; - } - - delete iDialer; - } - -// -------------------------------------------------------------------------------------------- - -void CPhoneCallManager::ConstructL() - { - CActiveScheduler::Add(this); - - // set the status as pending - iStatus = KRequestPending; - SetActive(); - - // set the death status pointer point to the request status of this ao - iAttributes.iDeathStatus = &iStatus; - - // init dialer ao - iDialer = CDialer::NewL(*this); - - // start timer - iPeriodicTimer = CPeriodic::NewL(CActive::EPriorityStandard); - iPeriodicTimer->Start(KDefaultStart, KDefaultPeriod, TCallBack(PeriodicTimerCallBack, this)); - } - -// -------------------------------------------------------------------------------------------- - -void CPhoneCallManager::RunL() - { - // request status has completed by the main thread meaning that we need to stop now - CActiveScheduler::Stop(); - } - -// -------------------------------------------------------------------------------------------- - -void CPhoneCallManager::DoCancel() - { - } - -// -------------------------------------------------------------------------------------------- - -TInt CPhoneCallManager::PeriodicTimerCallBack(TAny* aAny) - { - CPhoneCallManager* self = static_cast( aAny ); - - self->iPeriodicTimer->Cancel(); - self->HandleCalls(); - - return KErrNone; - } - -// -------------------------------------------------------------------------------------------- - -void CPhoneCallManager::HandleCalls() - { - if (iState == EStateIdle) - { - // make a new call - iState = EStateCall; - iDialer->Dial(iAttributes.iDestination); - } - - else if (iState == EStateCall) - { - // hangup existing call - iState = EStateIdle; - iDialer->Hangup(); - } - } - -// -------------------------------------------------------------------------------------------- - -void CPhoneCallManager::HandleStatus(TInt /*aErr*/) - { - // call timer after wait - if (iState == EStateCall) - { - iPeriodicTimer->Start(CLoadGenUtils::MilliSecondsToMicroSeconds(iAttributes.iLength, iAttributes.iRandomVariance), KDefaultPeriod, TCallBack(PeriodicTimerCallBack, this)); - } - - else if (iState == EStateIdle) - { - iPeriodicTimer->Start(CLoadGenUtils::MilliSecondsToMicroSeconds(iAttributes.iIdle, iAttributes.iRandomVariance), KDefaultPeriod, TCallBack(PeriodicTimerCallBack, this)); - } - } - -// -------------------------------------------------------------------------------------------- -// -------------------------------------------------------------------------------------------- - -CDialer* CDialer::NewL(CPhoneCallManager& aManager) - { - CDialer* self = new(ELeave) CDialer(aManager); - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(); - return self; - } - -// -------------------------------------------------------------------------------------------- - -CDialer::CDialer(CPhoneCallManager& aManager) : - CActive(EPriorityStandard), iManager(aManager), iCallParamsPckg(iCallParams) - { - } - -// -------------------------------------------------------------------------------------------- - -CDialer::~CDialer() - { - Cancel(); - delete iTelephony; - } - -// -------------------------------------------------------------------------------------------- - -void CDialer::ConstructL() - { - CActiveScheduler::Add(this); - - // init telephony object - iTelephony = CTelephony::NewL(); - } - -// -------------------------------------------------------------------------------------------- - -void CDialer::RunL() - { - // notify the observer that status has changed - iManager.HandleStatus(iStatus.Int()); - } - -// -------------------------------------------------------------------------------------------- - -void CDialer::DoCancel() - { - iTelephony->CancelAsync(CTelephony::EDialNewCallCancel); - iTelephony->CancelAsync(CTelephony::EHangupCancel); - } - -// -------------------------------------------------------------------------------------------- - -void CDialer::Dial(const TDesC& aDestination) - { - CTelephony::TTelNumber telNumber(aDestination); - iCallParams.iIdRestrict = CTelephony::ESendMyId; - iTelephony->DialNewCall(iStatus, iCallParamsPckg, telNumber, iCallId); - SetActive(); - } - -// -------------------------------------------------------------------------------------------- - -void CDialer::Hangup() - { - iTelephony->Hangup(iStatus, iCallId); - SetActive(); - } - -// -------------------------------------------------------------------------------------------- - - - -// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/engine/src/loadgen_photocapture.cpp --- a/loadgen/engine/src/loadgen_photocapture.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,389 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -// INCLUDE FILES -#include "loadgen_photocapture.h" -#include "loadgen_utils.h" -#include "loadgen.hrh" -#include "loadgen_traces.h" -#include -#include -#include -#include -#include - -_LIT(KThreadName, "PhotoCapture %d"); - -const TInt KDefaultStart = 50; -const TInt KDefaultPeriod = 5000000; - -//TInt CPhotoCapture::iImagesReady = 0; - -// ===================================== MEMBER FUNCTIONS ===================================== - -CPhotoCapture* CPhotoCapture::NewL(TPhotoCaptureAttributes& aAttributes, TInt aReferenceNumber) - { - CPhotoCapture* self = new(ELeave) CPhotoCapture(aAttributes, aReferenceNumber); - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(self); - return self; - } - -// -------------------------------------------------------------------------------------------- - -CPhotoCapture::~CPhotoCapture() - { - Close(); - } - -// -------------------------------------------------------------------------------------------- - -CPhotoCapture::CPhotoCapture(TPhotoCaptureAttributes& aAttributes, TInt aReferenceNumber) : iAttributes(aAttributes) - { - iAttributes.iId = aReferenceNumber; - } - -// -------------------------------------------------------------------------------------------- - -void CPhotoCapture::ConstructL() - { - CLoadBase::ConstructL(); - - iType = ELoadGenCmdNewLoadPhotoCaptures; - - TBuf<64> threadName; - threadName.Format(KThreadName, iAttributes.iId); - - // create a thread - User::LeaveIfError(iThread.Create(threadName, ThreadFunction, KDefaultStackSize*2, KMinHeapSize, 1024*KMinHeapSize, (TAny*) &iAttributes )); - - // set priority of the thread - SetPriority(); - } - -// -------------------------------------------------------------------------------------------- - -TInt CPhotoCapture::ThreadFunction(TAny* aThreadArg) - { - TInt err = KErrNone; - - CTrapCleanup* pC = CTrapCleanup::New(); - CActiveScheduler* pS = new CActiveScheduler; - CActiveScheduler::Install(pS); - - // start generating load, pass pointer to arguments - GenerateLoad(*((TPhotoCaptureAttributes*) aThreadArg)); - - delete pS; - delete pC; - - return err; - } - -// -------------------------------------------------------------------------------------------- - -void CPhotoCapture::GenerateLoad(TPhotoCaptureAttributes& aAttributes) - { - CCameraManager* cameraManager = 0; - TRAPD(err, cameraManager = CCameraManager::NewL(aAttributes)); - if (err == KErrNone) CActiveScheduler::Start(); - delete cameraManager; - } - -// -------------------------------------------------------------------------------------------- - -void CPhotoCapture::Resume() - { - CLoadBase::Resume(); - iThread.Resume(); - } - -// -------------------------------------------------------------------------------------------- - -void CPhotoCapture::Suspend() - { - CLoadBase::Suspend(); - iThread.Suspend(); - } - -// -------------------------------------------------------------------------------------------- - -void CPhotoCapture::SetPriority() - { - CLoadBase::SetPriority(); - iThread.SetPriority(CLoadGenUtils::SettingItemToThreadPriority(iAttributes.iPriority)); - } - -// -------------------------------------------------------------------------------------------- - -void CPhotoCapture::Close() - { - CLoadBase::Close(); - - // kill the thread immediately - iThread.Kill(0); - - iThread.Close(); - } - -// -------------------------------------------------------------------------------------------- - -TPtrC CPhotoCapture::Description() - { - TBuf<256> buf; - TBuf<16> prioBuf; - CLoadGenUtils::SettingItemToThreadDescription(iAttributes.iPriority, prioBuf); - - _LIT(KPhotoCaptureEntry, "[%d] PhotoCapture camera=%d prio=%S idle=%dms random=%d%%"); - buf.Format(KPhotoCaptureEntry, iAttributes.iId, iAttributes.iCamera, &prioBuf, iAttributes.iIdle, iAttributes.iRandomVariance); - - return TPtrC(buf); - } - -// -------------------------------------------------------------------------------------------- - - -// -------------------------------------------------------------------------------------------- -CCameraManager* CCameraManager::NewL(TPhotoCaptureAttributes& aAttrs) - { - CCameraManager* self = new (ELeave) CCameraManager(aAttrs); - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(self); - return self; - } - -// -------------------------------------------------------------------------------------------- -CCameraManager::~CCameraManager() - { - delete iCamera; - if (iPeriodicTimer) - { - iPeriodicTimer->Cancel(); - delete iPeriodicTimer; - } - } - -// -------------------------------------------------------------------------------------------- -CCameraManager::CCameraManager(TPhotoCaptureAttributes& aAttrs) -: -CActive(EPriorityStandard), -iAttributes(aAttrs) - { - iState = ENotReady; - iNumOfPics = 0; - } - -// -------------------------------------------------------------------------------------------- -void CCameraManager::ConstructL() - { - CActiveScheduler::Add(this); - // set the status as pending - iStatus = KRequestPending; - SetActive(); - - // set the death status pointer point to the request status of this ao - iAttributes.iDeathStatus = &iStatus; - - // start timer - iPeriodicTimer = CPeriodic::NewL(CActive::EPriorityStandard); - iPeriodicTimer->Start(KDefaultStart, KDefaultPeriod, TCallBack(PeriodicTimerCallBack, this)); - } - -// -------------------------------------------------------------------------------------------- -void CCameraManager::DoCancel() - { - } - -// -------------------------------------------------------------------------------------------- -void CCameraManager::RunL() - { - // request status has completed by the main thread meaning that we need to stop now - CActiveScheduler::Stop(); - } - -// -------------------------------------------------------------------------------------------- -void CCameraManager::ReserveCameraL() - { - LOGSTRING2("LoadGen: CCameraManager::ReserveCameraL() - Using Camera %d", iAttributes.iCamera); - if( iCamera ) - { - iCamera->Release(); - } - delete iCamera; - iCamera = 0; - TRAPD( err, iCamera = CCamera::NewL(*this, iAttributes.iCamera)); - iCurrentCamera = iAttributes.iCamera; - if(err != KErrNone) - { - LOGSTRING2("LoadGen: CCamera::NewL leaves with error: %d", err); - User::Leave(err); - } - iCamera->CameraInfo(iCameraInfo); - iCamera->Reserve(); - } - -// -------------------------------------------------------------------------------------------- -void CCameraManager::ReserveComplete(TInt aError) - { - if( aError != KErrNone ) - LOGSTRING2("LoadGen: CCameraManager::ReserveComplete() - Error: %d", aError); - - if( aError == KErrNone ) - { - iState = ECameraReserved; - iCamera->PowerOn(); - } - } - -// -------------------------------------------------------------------------------------------- -void CCameraManager::PowerOnComplete(TInt aError) - { - if( aError != KErrNone ) - { - LOGSTRING2("LoadGen: CCameraManager::PowerOnComplete() - Error: %d", aError); - return; - } - - // Define image format, try JPEG images first: - CCamera::TFormat format = CCamera::EFormatExif; - - if(iCameraInfo.iImageFormatsSupported & CCamera::EFormatExif) - { - LOGSTRING("LoadGen: CCameraManager::PowerOnComplete() - EXIF JPEG supported"); - format = CCamera::EFormatExif; - } - else if( iCameraInfo.iImageFormatsSupported & CCamera::EFormatJpeg ) - { - LOGSTRING("LoadGen: CCameraManager::PowerOnComplete() - JFIF JPEG supported"); - format = CCamera::EFormatJpeg; - } - else if( iCameraInfo.iImageFormatsSupported & CCamera::EFormatFbsBitmapColor4K ) - { - LOGSTRING("LoadGen: CCameraManager::PowerOnComplete() - Bitmap 4K Color supported"); - format = CCamera::EFormatFbsBitmapColor4K; - } - else if( iCameraInfo.iImageFormatsSupported & CCamera::EFormatFbsBitmapColor64K ) - { - LOGSTRING("LoadGen: CCameraManager::PowerOnComplete() - Bitmap 64K Color supported"); - format = CCamera::EFormatFbsBitmapColor64K; - } - else if( iCameraInfo.iImageFormatsSupported & CCamera::EFormatFbsBitmapColor16M ) - { - LOGSTRING("LoadGen: CCameraManager::PowerOnComplete() - Bitmap 16M Color supported"); - format = CCamera::EFormatFbsBitmapColor16M; - } - else - { - LOGSTRING2("LoadGen: CCameraManager::PowerOnComplete() - JPEGs not supported, trying \"User defined\" (Supported formats: %d)", iCameraInfo.iImageFormatsSupported); - format = CCamera::EFormatUserDefined; - } - const TInt KImageSizeIndex = 0; // Largest image size - TRAPD( err, iCamera->PrepareImageCaptureL(format, KImageSizeIndex)); - if( err != KErrNone ) - { - LOGSTRING2("LoadGen: CCameraManager::PowerOnComplete() - Error while preparing camera: %d", err); - } - // Camera ready: - iState = EIdle; - // Take photo: - TRAP(err, CapturePhotoL()); - if( err != KErrNone ) - { - LOGSTRING2("LoadGen: CCameraManager::PowerOnComplete() - Photo capture error: %d", err); - } - } - -// -------------------------------------------------------------------------------------------- -void CCameraManager::ViewFinderFrameReady(CFbsBitmap& /*aFrame*/) - { - } - -// -------------------------------------------------------------------------------------------- -void CCameraManager::ImageReady(CFbsBitmap* aBitmap, HBufC8* aData, TInt aError) - { - if( aError != KErrNone ) - { - LOGSTRING2("LoadGen: CCameraManager::ImageReady() - Error: %d", aError); - } - else - { - iNumOfPics++; - LOGSTRING2("LoadGen: CCameraManager::ImageReady() - Images successfully captured: %d", iNumOfPics); - } - delete aBitmap; - delete aData; - iState = EIdle; - } - -// -------------------------------------------------------------------------------------------- -void CCameraManager::FrameBufferReady(MFrameBuffer* /*aFrameBuffer*/, TInt aError) - { - if( aError != KErrNone ) - LOGSTRING2("LoadGen: CCameraManager::FrameBufferReady() - Error: %d", aError); - } - -// -------------------------------------------------------------------------------------------- -void CCameraManager::CapturePhotoL() - { - // Camera Manager must be in idle state when taking a photo - if( iState == ENotReady ) - { - // Not ready, camera must be reserved: - ReserveCameraL(); - } - else if (iState == EIdle) - { - if( iCurrentCamera != iAttributes.iCamera ) - { - LOGSTRING3("LoadGen: CCameraManager::CapturePhotoL() - Switching from Camera %d to Camera %d", iCurrentCamera, iAttributes.iCamera); - ReserveCameraL(); - } - else - { - iState = ECapture; - if( iCameraInfo.iFlashModesSupported & CCamera::EFlashForced) - { - iCamera->SetFlashL(CCamera::EFlashForced); - } - iCamera->CaptureImage(); - iPeriodicTimer->Start( CLoadGenUtils::MilliSecondsToMicroSeconds( iAttributes.iIdle, - iAttributes.iRandomVariance ), KDefaultPeriod, - TCallBack( PeriodicTimerCallBack, this ) ); - } - } - else - { - iPeriodicTimer->Start( CLoadGenUtils::MilliSecondsToMicroSeconds( iAttributes.iIdle, - iAttributes.iRandomVariance ), KDefaultPeriod, - TCallBack( PeriodicTimerCallBack, this ) ); - } - } - -// -------------------------------------------------------------------------------------------- - -TInt CCameraManager::PeriodicTimerCallBack(TAny* aAny) - { - CCameraManager* self = static_cast( aAny ); - self->iPeriodicTimer->Cancel(); - TRAP_IGNORE(self->CapturePhotoL()); - return KErrNone; - } - -// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/engine/src/loadgen_pointerevent.cpp --- a/loadgen/engine/src/loadgen_pointerevent.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,271 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -// INCLUDE FILES -#include "loadgen_pointerevent.h" -#include "loadgen_utils.h" -#include "loadgen.hrh" -#include - -#include - -_LIT(KThreadName, "PointerEvent %d"); - -const TInt KDefaultStart = 50; -const TInt KDefaultPeriod = 5000000; - -// ===================================== MEMBER FUNCTIONS ===================================== - -CPointerEvent* CPointerEvent::NewL(TPointerEventAttributes& aAttributes, TInt aReferenceNumber) - { - CPointerEvent* self = new(ELeave) CPointerEvent(aAttributes, aReferenceNumber); - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(self); - return self; - } - -// -------------------------------------------------------------------------------------------- - -CPointerEvent::~CPointerEvent() - { - Close(); - } - -// -------------------------------------------------------------------------------------------- - -CPointerEvent::CPointerEvent(TPointerEventAttributes& aAttributes, TInt aReferenceNumber) : iAttributes(aAttributes) - { - iAttributes.iId = aReferenceNumber; - } - -// -------------------------------------------------------------------------------------------- - -void CPointerEvent::ConstructL() - { - CLoadBase::ConstructL(); - - iType = ELoadGenCmdNewLoadPointerEvent; - - TBuf<64> threadName; - threadName.Format(KThreadName, iAttributes.iId); - - // create a thread - User::LeaveIfError(iThread.Create(threadName, ThreadFunction, KDefaultStackSize*2, KMinHeapSize, 1024*KMinHeapSize, (TAny*) &iAttributes )); - - // set priority of the thread - SetPriority(); - } - -// -------------------------------------------------------------------------------------------- - -TInt CPointerEvent::ThreadFunction(TAny* aThreadArg) - { - CTrapCleanup* pC = CTrapCleanup::New(); - CActiveScheduler* pS = new CActiveScheduler; - CActiveScheduler::Install(pS); - - // start generating load, pass pointer to arguments - GenerateLoad(*((TPointerEventAttributes*) aThreadArg)); - - delete pS; - delete pC; - - return KErrNone; - } - -// -------------------------------------------------------------------------------------------- - -void CPointerEvent::GenerateLoad(TPointerEventAttributes& aAttributes) - { - CPointerEventManager* pointerEventManager = NULL; - TRAPD(err, pointerEventManager = CPointerEventManager::NewL(aAttributes)); - if (err == KErrNone) CActiveScheduler::Start(); - delete pointerEventManager; - } - -// -------------------------------------------------------------------------------------------- - -void CPointerEvent::Resume() - { - CLoadBase::Resume(); - - iThread.Resume(); - } - -// -------------------------------------------------------------------------------------------- - -void CPointerEvent::Suspend() - { - CLoadBase::Suspend(); - - iThread.Suspend(); - } - -// -------------------------------------------------------------------------------------------- - -void CPointerEvent::SetPriority() - { - CLoadBase::SetPriority(); - - iThread.SetPriority(CLoadGenUtils::SettingItemToThreadPriority(iAttributes.iPriority)); - } - -// -------------------------------------------------------------------------------------------- - -void CPointerEvent::Close() - { - CLoadBase::Close(); - - if (iThread.ExitReason() == 0) // check if the thread is still alive - { - // signal the thread that it needs to close - iThread.RequestComplete(iAttributes.iDeathStatus, KErrCancel); - - // wait the thread to die - TRequestStatus waiter; - iThread.Logon(waiter); - User::WaitForRequest(waiter); - iThread.Close(); - } - } - -// -------------------------------------------------------------------------------------------- - -TPtrC CPointerEvent::Description() - { - TBuf<256> buf; - TBuf<16> prioBuf; - CLoadGenUtils::SettingItemToThreadDescription(iAttributes.iPriority, prioBuf); - - _LIT(KPointerEventEntry, "[%d] PointerEvent prio=%S heartbeat=%dms random=%d%%"); - buf.Format(KPointerEventEntry, iAttributes.iId, &prioBuf, iAttributes.iHeartBeat, iAttributes.iRandomVariance); - - return TPtrC(buf); - } - -// -------------------------------------------------------------------------------------------- -// -------------------------------------------------------------------------------------------- - -CPointerEventManager* CPointerEventManager::NewL(TPointerEventAttributes& aAttributes) - { - CPointerEventManager* self = new(ELeave) CPointerEventManager(aAttributes); - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(); - return self; - } - -// -------------------------------------------------------------------------------------------- - -CPointerEventManager::CPointerEventManager(TPointerEventAttributes& aAttributes) : - CActive(EPriorityStandard), iAttributes(aAttributes) - { - } - -// -------------------------------------------------------------------------------------------- - -CPointerEventManager::~CPointerEventManager() - { - Cancel(); - } - -// -------------------------------------------------------------------------------------------- - -void CPointerEventManager::ConstructL() - { - CActiveScheduler::Add(this); - - // set the status as pending - iStatus = KRequestPending; - SetActive(); - - // set the death status pointer point to the request status of this ao - iAttributes.iDeathStatus = &iStatus; - - // init - - // start timer - iPeriodicTimer = CPeriodic::NewL(CActive::EPriorityStandard); - iPeriodicTimer->Start(KDefaultStart, KDefaultPeriod, TCallBack(PeriodicTimerCallBack, this)); - } - -// -------------------------------------------------------------------------------------------- - -void CPointerEventManager::RunL() - { - // request status has completed by the main thread meaning that we need to stop now - CActiveScheduler::Stop(); - } - -// -------------------------------------------------------------------------------------------- - -void CPointerEventManager::DoCancel() - { - } - -// -------------------------------------------------------------------------------------------- - -TInt CPointerEventManager::PeriodicTimerCallBack(TAny* aAny) - { - CPointerEventManager* self = static_cast( aAny ); - - self->iPeriodicTimer->Cancel(); - self->SimulatePointerEvent(); - - return KErrNone; - } - -// -------------------------------------------------------------------------------------------- - -void CPointerEventManager::SimulatePointerEvent() - { - // Check the screen size and select pointer event position - // randomly - TSize screenSize = CLoadGenUtils::ScreenSize(); - - TInt x1 = CLoadGenUtils::RandomNumber(0, screenSize.iWidth); - TInt y1 = CLoadGenUtils::RandomNumber(0, screenSize.iHeight); - - // Generate "Pointer down" event: - TRawEvent eventPointerDown; - eventPointerDown.Set(TRawEvent::EButton1Down, x1, y1); - UserSvr::AddEvent(eventPointerDown); - - // Get new random position for "Move pointer" and - // "Pointer up" events - TInt x2 = CLoadGenUtils::RandomNumber(0, screenSize.iWidth); - TInt y2 = CLoadGenUtils::RandomNumber(0, screenSize.iHeight); - - // Generate "Move pointer" event: - TRawEvent eventMovePointer; - eventMovePointer.Set(TRawEvent::EPointerMove, x2, y2); - UserSvr::AddEvent(eventMovePointer); - - // Generate "Pointer up" event: - TRawEvent eventPointerUp; - eventPointerUp.Set(TRawEvent::EButton1Up, x2, y2); - UserSvr::AddEvent(eventPointerUp); - - // call timer - iPeriodicTimer->Start(CLoadGenUtils::MilliSecondsToMicroSeconds(iAttributes.iHeartBeat, iAttributes.iRandomVariance), KDefaultPeriod, TCallBack(PeriodicTimerCallBack, this)); - } - -// -------------------------------------------------------------------------------------------- - -// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/engine/src/loadgen_utils.cpp --- a/loadgen/engine/src/loadgen_utils.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,266 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -// INCLUDE FILES -#include -#include -#include - -#include "loadgen_utils.h" -#include "loadgen.hrh" - -inline TInt64 INIT_SEED() -{ - TTime now; - now.HomeTime(); - return now.Int64(); -} - -TInt64 CLoadGenUtils::iRandomNumberSeed = INIT_SEED(); - -TThreadPriority CLoadGenUtils::SettingItemToThreadPriority(TInt aIndex) - { - TThreadPriority threadPriority = EPriorityNull; - - switch ( aIndex ) - { - case EThreadPriorityTypeMuchLess: - { - threadPriority = EPriorityMuchLess; break; - } - case EThreadPriorityTypeLess: - { - threadPriority = EPriorityLess; break; - } - case EThreadPriorityTypeNormal: - { - threadPriority = EPriorityNormal; break; - } - case EThreadPriorityTypeMore: - { - threadPriority = EPriorityMore; break; - } - case EThreadPriorityTypeMuchMore: - { - threadPriority = EPriorityMuchMore; break; - } - case EThreadPriorityTypeRealTime: - { - threadPriority = EPriorityRealTime; break; - } - case EThreadPriorityTypeAbsoluteVeryLow: - { - threadPriority = EPriorityAbsoluteVeryLow; break; - } - case EThreadPriorityTypeAbsoluteLow: - { - threadPriority = EPriorityAbsoluteLow; break; - } - case EThreadPriorityTypeAbsoluteBackground: - { - threadPriority = EPriorityAbsoluteBackground; break; - } - case EThreadPriorityTypeAbsoluteForeground: - { - threadPriority = EPriorityAbsoluteForeground; break; - } - case EThreadPriorityTypeAbsoluteHigh: - { - threadPriority = EPriorityAbsoluteHigh; break; - } - - default: - { - User::Panic(_L("Wrong tp index"), 276); - break; - } - } - - return threadPriority; - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenUtils::SettingItemToThreadDescription(TInt aIndex, TDes& aBuf) - { - switch ( aIndex ) - { - case EThreadPriorityTypeMuchLess: - { - aBuf.Append(_L("ML(-20)")); break; - } - case EThreadPriorityTypeLess: - { - aBuf.Append(_L("L(-10)")); break; - } - case EThreadPriorityTypeNormal: - { - aBuf.Append(_L("NO(0)")); break; - } - case EThreadPriorityTypeMore: - { - aBuf.Append(_L("M(10)")); break; - } - case EThreadPriorityTypeMuchMore: - { - aBuf.Append(_L("MM(20)")); break; - } - case EThreadPriorityTypeRealTime: - { - aBuf.Append(_L("RL(30)")); break; - } - case EThreadPriorityTypeAbsoluteVeryLow: - { - aBuf.Append(_L("AVL(100)")); break; - } - case EThreadPriorityTypeAbsoluteLow: - { - aBuf.Append(_L("AL(200)")); break; - } - case EThreadPriorityTypeAbsoluteBackground: - { - aBuf.Append(_L("ABG(300)")); break; - } - case EThreadPriorityTypeAbsoluteForeground: - { - aBuf.Append(_L("AFG(400)")); break; - } - case EThreadPriorityTypeAbsoluteHigh: - { - aBuf.Append(_L("AH(500)")); break; - } - - default: - { - User::Panic(_L("Wrong td index"), 277); - break; - } - } - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenUtils::SettingItemToSourceDescription(TInt aIndex, TDes& aBuf) - { - switch ( aIndex ) - { - case EMemoryEatSourceTypeRAM: - { - aBuf.Append(_L("RAM")); break; - } - case EMemoryEatSourceTypeDriveC: - { - aBuf.Append(_L("C:")); break; - } - case EMemoryEatSourceTypeDriveD: - { - aBuf.Append(_L("D:")); break; - } - case EMemoryEatSourceTypeDriveE: - { - aBuf.Append(_L("E:")); break; - } - case EMemoryEatSourceTypeDriveF: - { - aBuf.Append(_L("F:")); break; - } - case EMemoryEatSourceTypeDriveG: - { - aBuf.Append(_L("G:")); break; - } - case EMemoryEatSourceTypeDriveH: - { - aBuf.Append(_L("H:")); break; - } - case EMemoryEatSourceTypeDriveI: - { - aBuf.Append(_L("I:")); break; - } - case EMemoryEatSourceTypeDriveJ: - { - aBuf.Append(_L("J:")); break; - } - case EMemoryEatSourceTypeDriveK: - { - aBuf.Append(_L("K:")); break; - } - case EMemoryEatSourceTypeDriveL: - { - aBuf.Append(_L("L:")); break; - } - case EMemoryEatSourceTypeDriveM: - { - aBuf.Append(_L("M:")); break; - } - case EMemoryEatSourceTypeDriveN: - { - aBuf.Append(_L("N:")); break; - } - - default: - { - User::Panic(_L("Wrong src index"), 278); - break; - } - } - } - -// -------------------------------------------------------------------------------------------- - -TInt CLoadGenUtils::MilliSecondsToMicroSeconds(TInt aMilliSeconds, TInt aRandomVariance) - { - __ASSERT_ALWAYS(aRandomVariance >= 0 && aRandomVariance <= 100, User::Panic(_L("Inv.var."), 180)); - __ASSERT_ALWAYS(aMilliSeconds >=0, User::Panic(_L("Inv.ms."), 181)); - - // if no variance defined, just do a quick conversion - if (aRandomVariance == 0 || aMilliSeconds == 0) - return aMilliSeconds * 1000; - - // otherwise calculate difference - TInt diff = 1000 * aMilliSeconds / 2 * aRandomVariance / 100; - - return RandomNumber(aMilliSeconds*1000-diff, aMilliSeconds*1000+diff); - } - -// -------------------------------------------------------------------------------------------- - -TInt CLoadGenUtils::RandomNumber(TInt aMin, TInt aMax) - { - TInt range = (aMax > aMin ? aMax - aMin : aMin - aMax) + 1; - TInt random = (TInt) (range * Math::FRand(iRandomNumberSeed)); - - random = (random % range) + aMin; - - if (random > aMax) - random = aMax; - else if (random < aMin) - random = aMin; - - return random; - } - -// -------------------------------------------------------------------------------------------- - -TSize CLoadGenUtils::ScreenSize() - { - TInt x = 0; - TInt y = 0; - HAL::Get(HALData::EDisplayXPixels, x); - HAL::Get(HALData::EDisplayYPixels, y); - return TSize(x, y); - } diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/envpatcher/EnvPatcher.pl --- a/loadgen/envpatcher/EnvPatcher.pl Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,498 +0,0 @@ -# -# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# This component and the accompanying materials are made available -# under the terms of "Eclipse Public License v1.0" -# which accompanies this distribution, and is available -# at the URL "http://www.eclipse.org/legal/epl-v10.html". -# -# Initial Contributors: -# Nokia Corporation - initial contribution. -# -# Contributors: -# -# Description: -# Environment Patcher - Patches older S60 SDKs for supporting -# tricks in newer platforms -# - - -require v5.6.1; - -use File::Copy; -use strict; - -# check amount of commandline options is valid -if (@ARGV != 1) -{ - print "Usage: EnvPatcher \n"; - exit 1; -} - - -# get epocroot and convert, convert \ -> / -(my $epocroot = $ARGV[0]) =~ s{\\}{/}g; - -# remove any trailing forward slashes -$epocroot =~ s/\/$//; - - -# create variables for paths -my $e32toolsdir = $epocroot."/epoc32/tools"; -my $e32includedir = $epocroot."/epoc32/include"; -my $e32includeoemdir = $e32includedir."/oem"; -my $platformpathspath = $e32includedir."/platform_paths.hrh"; -my $domainplatformpathspath = $e32includedir."/domain/osextensions/platform_paths.hrh"; -my $mmppmpath = $e32toolsdir."/mmp.pm"; -my $pathutlpmpath = $e32toolsdir."/pathutl.pm"; -my $prepfilepmpath = $e32toolsdir."/prepfile.pm"; - -# variables for hacked content -my $dependshack = "\t\t\tif (/^DEPENDS\$/o) {\r\n\t\t\t\tnext LINE; # Ignore DEPENDS keyword, not needed by ABLD\r\n\t\t\t}\r\n"; -my $forwardslashhack = "\t\t# EnvPatcher forwardslash hack begins\r\n\t\t\$_=~s{/}{\\\\}g; # convert all forward slashes to backslashes\r\n\t\t# EnvPatcher forwardslash hack ends\r\n\r\n"; -my $coreibyexportsupport = "\r\n// Following definition is used for exporting tools and stubs IBY files to\r\n// Core image.\r\n#define CORE_IBY_EXPORT_PATH(path,exported) /epoc32/rom/include/##exported\r\n"; - - -# check epoc32\tools exists -unless (-d $e32toolsdir) -{ - print "$e32toolsdir not found, please check valid epocroot has been given!\n"; - exit 1; -} - -# check epoc32\include exists -unless (-d $e32includedir) -{ - print "$e32includedir not found, please check valid epocroot has been given!\n"; - exit 1; -} - - -# create epoc32\include\oem if it does not exist -unless (-d $e32includeoemdir) -{ - mkdir $e32includeoemdir or die; - print "Missing directory $e32includeoemdir created succesfully.\n"; -} - - -# check if epoc32\include\domain\osextensions\platform_paths.hrh exists -if (-e $domainplatformpathspath) -{ - # show an error if the file does not have any platform macros - unless (string_exists_in_file($domainplatformpathspath, "OS_LAYER_SYSTEMINCLUDE")) - { - print "ERROR: $domainplatformpathspath does not have SF macros.\n"; - print "Please check your environment, if you have S60 3.2 OEM or newer, please get the latest version!\n"; - exit 2; - } -} - - -# check if epoc32\include\platform_paths.hrh exists -if (-e $platformpathspath) -{ - print "$platformpathspath already exists, not checking it.\n"; -} -else -{ - # create the file missing file - create_default_platform_paths_hrh(); - print "Missing file $platformpathspath created succesfully.\n"; -} - - -# check if CORE_IBY_EXPORT_PATH macro exist in the platform_paths.hrh -unless (string_exists_in_file($platformpathspath, "CORE_IBY_EXPORT_PATH")) -{ - # read content of the platform_paths.hrh - my @filecontent = read_file_to_array($platformpathspath); - - my $match_found = 0; - my $i = 0; - my $match_found_pos = 0; - - # find the position where the include guards start (this should be a safe position) - foreach (@filecontent) - { - if ($_ =~ /#define PLATFORM_PATHS_HRH/) - { - $match_found = 1; - $match_found_pos = $i; - last; - } - - $i++; - } - - if ($match_found) - { - # insert the patched content to the file - splice(@filecontent, $match_found_pos+1, 0, $coreibyexportsupport); - - # write the modified array to the file - write_file_from_array($platformpathspath, @filecontent); - - print "Platform_paths.hrh updated to support CORE_IBY_EXPORT_PATH macro.\n"; - } - else - { - print "WARNING: $platformpathspath is corrupted or not supported!\n"; - } -} - - -# check if epoc32\tools\mmp.pm exists -if (-e $mmppmpath) -{ - # check if DEPENDS keyword already exists in the file - if (string_exists_in_file($mmppmpath, "DEPENDS")) - { - print "The SDK has already been patched with DEPENDS keyword hack.\n"; - } - else - { - # read content of the mmp.pm file - my @filecontent = read_file_to_array($mmppmpath); - - my $match_found = 0; - my $i = 0; - my $match_found_pos = 0; - - # loop through the array to find the correct place - foreach (@filecontent) - { - if ($_ =~ /Unrecognised Resource Keyword/) - { - $match_found = 1; - $match_found_pos = $i; - last; - } - - $i++; - } - - if ($match_found) - { - # insert the patched content to the file - splice(@filecontent, $match_found_pos-1, 0, $dependshack); - - # write the modified array to the file - write_file_from_array($mmppmpath, @filecontent); - - print "Mmp.pm patched with DEPENDS keyword hack.\n"; - } - else - { - print "ERROR: Unable to find correct place from $mmppmpath for patching!\n"; - print "Your SDK environment probably is not supported by this script!\n"; - exit(2); - } - } -} -else -{ - print "WARNING: $mmppmpath not found, this environment is not supported!\n"; -} - - -# check if epoc32\tools\pathutl.pm exists -if (-e $pathutlpmpath) -{ - # check if "sub Path_Norm" already exists in the pathutil.pm file - # if it does not exists, then we need to patch prepfile.pm - if (string_exists_in_file($pathutlpmpath, "sub Path_Norm")) - { - print "The SDK is non Symbian OS 9.1, no need to add forward slash hack.\n"; - } - else - { - # check if prepfile.pm has already been patched - if (string_exists_in_file($prepfilepmpath, "EnvPatcher forwardslash hack")) - { - print "The SDK has already been patched with forwardslash hack.\n"; - } - else - { - # read content of the prepfile.pm file - my @filecontent = read_file_to_array($prepfilepmpath); - - my $match_found = 0; - my $i = 0; - my $match_found_pos = 0; - - # loop through the array to find the correct place - foreach (@filecontent) - { - if ($_ =~ /# skip blank lines/) - { - $match_found = 1; - $match_found_pos = $i; - last; - } - - $i++; - } - - if ($match_found) - { - # insert the patched content to the file - splice(@filecontent, $match_found_pos+6, 0, $forwardslashhack); - - # write the modified array to the file - write_file_from_array($prepfilepmpath, @filecontent); - - print "Prepfile.pm patched with forward slash hack.\n"; - } - else - { - print "ERROR: Unable to find correct place from $prepfilepmpath for patching!\n"; - print "Your SDK environment probably is not supported by this script!\n"; - exit(2); - } - } - } -} -else -{ - print "WARNING: $pathutlpmpath not found, this environment is not supported!\n"; -} - - - -# checks if string exists in the file -sub string_exists_in_file -{ - my $filepath = $_[0]; - my $findstring = $_[1]; - my $match_found = 0; - - open(FILE, "<", $filepath) or die "Failed to open $filepath for reading!"; - - # loop through the file for occurances - while () - { - if ($_ =~ /$findstring/) - { - $match_found = 1; - last; - } - } - - close FILE; - - return $match_found; -} - - -# reads lines from a file to an array -sub read_file_to_array -{ - my $filepath = $_[0]; - - open(FILE, "<", $filepath) or die "Failed to open $filepath for reading!"; - my @data = ; - close FILE; - - return(@data); -} - - -# writes lines from an array to a file -sub write_file_from_array -{ - my ($filepath, @data) = @_; - - # take a backup of the file - copy ($filepath, $filepath."EnvPatcher") or die "Cannot take backup of $filepath to $filepath.EnvPatcher"; - - open(FILE, ">", $filepath) or die "Failed to open $filepath for writing!"; - - # write the array to file - foreach my $line (@data) - { - print FILE "$line"; - } - - close FILE; -} - -sub create_default_platform_paths_hrh -{ - # the file does not exist, so create the missing file - open(FILE, ">", $platformpathspath) or die "Failed to open $platformpathspath for writing!\n"; - - print FILE < thus they are first. -*/ -#define APP_LAYER_SYSTEMINCLUDE SYSTEMINCLUDE /epoc32/include /epoc32/include/oem - -/** -* This define statements defines the SYSTEMINCLUDE-line, which is intended to be -* used in the mmp-files that are part of the middleware-layer. It includes all -* the needed directories from the /epoc32/include, that are valid ones for the -* middleware-layer components. -*/ -#define MW_LAYER_SYSTEMINCLUDE SYSTEMINCLUDE /epoc32/include /epoc32/include/oem - -/** -* This define statements defines the SYSTEMINCLUDE-line, which is intended to be -* used in the mmp-files that are part of the osextensions-layer. It includes all -* the needed directories from the /epoc32/include, that are valid ones for the -* os-layer components. -*/ -#define OS_LAYER_SYSTEMINCLUDE SYSTEMINCLUDE /epoc32/include /epoc32/include/oem - - -// Below statement is Deprecated and the OS_LAYER_SYSTEMINCLUDE-macro has to be -// used. -#define OSEXT_LAYER_SYSTEMINCLUDE OS_LAYER_SYSTEMINCLUDE - -/** -* This define statements defines the SYSTEMINCLUDE-line, which is intended to be -* used in the mmp-files that are part of the os-layer. This is intended -* to be only used by those components which need to use in their mmp-file either -* kern_ext.mmh or nkern_ext.mmh. Reason is that those -* 2 files already contain the /epoc32/include as system include path. -* -*/ -#define OS_LAYER_KERNEL_SYSTEMINCLUDE SYSTEMINCLUDE /epoc32/include/oem - - -// Below statement is Deprecated and the OS_LAYER_KERNEL_SYSTEMINCLUDE-macro -// has to be used. -#define OSEXT_LAYER_KERNEL_SYSTEMINCLUDE OS_LAYER_KERNEL_SYSTEMINCLUDE - -/** -**************************************************************************** -* Definitions that also define the paths to the layer specific source directories. -**************************************************************************** -*/ -/** -* The below 3 macros define the paths to the layer-specific source dirs. -* See usage on top of this hrh-file, these are used the same way as -* for instance the OS_LAYER_DOMAIN_EXPORT_PATH -* Deprecated: is not allowed to be using in Symbian Foundation -*/ -#define APP_LAYER_SOURCE_PATH(rest) /s60/app/##rest -#define MW_LAYER_SOURCE_PATH(rest) /s60/mw/##rest -#define OSEXT_LAYER_SOURCE_PATH(rest) /s60/osext/##rest - -/** -**************************************************************************** -* Definitions to export IBY files to different folders where they will be taken -* to ROM image -**************************************************************************** -*/ -// Following definition is used for exporting tools and stubs IBY files to -// Core image. -#define CORE_IBY_EXPORT_PATH(path,exported) /epoc32/rom/include/##exported - -/** -* --------------------------------------- -* Macros for Configuration tool migration. -* The below macros define the location under epoc32, where the confml -* (Configuration Markup Language) and crml (Central Repository Markup Language) -* files should be exported. -* --------------------------------------- -*/ -#define CONFML_EXPORT_PATH(file,category) /epoc32/rom/config/confml_data/##category##/##file -#define CRML_EXPORT_PATH(file,category) /epoc32/rom/config/confml_data/##category##/##file -#define GCFML_EXPORT_PATH(file,category) /epoc32/rom/config/confml_data/##category##/##file -#define CONFML_CONFIG_EXPORT_PATH(file,category) /epoc32/rom/config/confml_data/##category##/config/##file - -#define APP_LAYER_CONFML(exported) CONFML_EXPORT_PATH(exported,s60) -#define APP_LAYER_CRML(exported) CRML_EXPORT_PATH(exported,s60) -#define APP_LAYER_GCFML(exported) GCFML_EXPORT_PATH(exported,s60) -#define APP_LAYER_CONFML_CONFIG(exported) CONFML_CONFIG_EXPORT_PATH(exported,s60) - -#define MW_LAYER_CONFML(exported) CONFML_EXPORT_PATH(exported,s60) -#define MW_LAYER_CRML(exported) CRML_EXPORT_PATH(exported,s60) -#define MW_LAYER_GCFML(exported) GCFML_EXPORT_PATH(exported,s60) -#define MW_LAYER_CONFML_CONFIG(exported) CONFML_CONFIG_EXPORT_PATH(exported,s60) - -// Deprecate: Use the OS_LAYER_* macros instead of OSEXT_LAYER_* -#define OSEXT_LAYER_CONFML(exported) CONFML_EXPORT_PATH(exported,s60) -#define OSEXT_LAYER_CRML(exported) CRML_EXPORT_PATH(exported,s60) -#define OSEXT_LAYER_GCFML(exported) GCFML_EXPORT_PATH(exported,s60) -#define OSEXT_LAYER_CONFML_CONFIG(exported) CONFML_CONFIG_EXPORT_PATH(exported,s60) -#define OS_LAYER_CONFML(exported) CONFML_EXPORT_PATH(exported,s60) -#define OS_LAYER_CRML(exported) CRML_EXPORT_PATH(exported,s60) -#define OS_LAYER_GCFML(exported) GCFML_EXPORT_PATH(exported,s60) -#define OS_LAYER_CONFML_CONFIG(exported) CONFML_CONFIG_EXPORT_PATH(exported,s60) - -#endif // end of PLATFORM_PATHS_HRH - -ENDOFTHEFILE - - close FILE; -} diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/envpatcher/ReadMe.txt --- a/loadgen/envpatcher/ReadMe.txt Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -Environment Patcher -=================== - -Updated: 9th January 2009 - - -Introduction: -------------- -This tool can be used to patch your S60 SDK environment so that the tricks and -macros introduced in the latest SDKs can be used in a public SDK and older -OEM releases. - -This tool can perform the following tasks: -- Adds support for forward slashes in paths in bld.inf/.mmp files in S60 3.0 -- Removes an unncessary warning about DEPENDS resource keyword in an .mmp file -- Creates a missing epoc32\include\platform_paths.hrh file for supporting - platform macros introduced since S60 3.2 OEM and Symbian Foundation releases -- Modifies epoc32\include\platform_paths.hrh for missing macros -- Creates a missing epoc32\include\oem directory to suppress a possible warning - - -Usage: ------- -EnvPatcher.pl - -Where EPOCROOT is the path to the root of the SDK, for example: - EnvPatcher.pl c:\Symbian\9.1\S60_3rd_MR - EnvPatcher.pl z:\ - - -Requirements: -------------- -- S60 SDK (public or OEM), version 3.0 or newer -- Perl 5.6.1 or newer - - - - -Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights -reserved. - -This material, including documentation and any related computer programs, is -protected by copyright controlled by Nokia. All rights are reserved. Copying, -including reproducing, storing, adapting or translating, any or all of this -material requires the prior written consent of Nokia. This material also -contains confidential information which may not be disclosed to others without -the prior written consent of Nokia. diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/group/ReleaseNotes_LoadGen.txt --- a/loadgen/group/ReleaseNotes_LoadGen.txt Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,134 +0,0 @@ -=============================================================================== - -RELEASE NOTES - LOAD GENERATOR v1.5.0 -RELEASED 23rd April 2010 - -SUPPORTS S60 3.0+ - -=============================================================================== - -Product Description: -==================== -LoadGen is an S60 UI application that provides an easy way to generate load -into a device. You can use LoadGen to simulate the behavior and possible -problems of a device when put under a heavy load in actual usage scenarios. - -Main Features: -============== -- Load types: - - CPU load (yielding or blocking) - - Memory eat (RAM and disks) - - Phone calls - - Network connection - - Key press - - SMS and MMS sending - - Launching applications - - Photo captures - - Bluetooth device discovery - - Touch UI pointer events -- Each load type can be executed periodically (that is, idle time can be - applied after each round) -- Each started load will be run in a separate thread -- Each load type can be paused/resumed and stopped - -=============================================================================== - -What's New in v1.5.0 -==================== -- Feature: Orbit UI introduced - - -=============================================================================== - -Installation Notes: -=================== -LoadGen is typically preinstalled on ROM. If not, it can be added to the -ROM with the .iby file. Alternatively, the .sis file can be found under the sis- -directory, but the user need to sign it with their own developer certificate. -In Nokia R&D environment, you can use directly the R&D-signed .sis file under the -internal\sis directory. - -When signing with own developer certificate, the following capabilities are -needed: - NetworkServices - SwEvent - ReadUserData - WriteUserData - -When builing LoadGen against S60 3.0 or 3.1, you may need to patch your SDK -environment first with some fixes. For more information, please refer to the -instructions under the "envpatcher" directory. - -=============================================================================== - -System Requirements: -==================== -Basic Requirements: -- Any S60 3.x device or emulator environment - -=============================================================================== - -Compatibility Issues: -===================== -N/A - -=============================================================================== - -Known Issues: -============= -- Launched applications are not always terminated by LoadGen. This occurs with - applications that are waiting for user input. - -=============================================================================== - -Version History: -================ - -Version 1.4.0 -==================== -- Feature: New load: Photo capture. -- Feature: New load: Bluetooth actions. -- Feature: New load: Pointer (touch ui) events. - -Version 1.3.0 - 30th June 2009 -============================== -- Feature: SMP support: CPU can be selected for CPU load. - -Version 1.2.1 - 6th March 2009 -============================== -- Fix: Messages load crashes Load Generator - -Version 1.2.0 - 20th February 2009 -================================== -- Feature: New load: application launch -- Fix: LoadGen crashes when changing the Type of CPU load - -Version 1.1.0 - 12th December 2008 -================================== -- Feature: SMS and MMS messages can be sent -- Fix: It was not possible to eat more memory than 2GB - -Version 1.0.1 - 18th March 2008 -=============================== -- Fix: It was possible to edit source type for existing memory eat item -- Fix: Thread priority was not changed when editing existing item -- Fix: Memory eat did not work properly or caused crash in some cases -- Fix: Editing existing memory eat replaced values with default values -- Fix: Memory about queries did not have any check for maximum value -- Fix: Stopping a crashed load crashed the whole application - - -Version 1.0.0 - 6th March 2008 ------------------------------- -- Initial version - -=============================================================================== - - Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). - All rights reserved. - This component and the accompanying materials are made available - under the terms of "Eclipse Public License v1.0" - which accompanies this distribution, and is available - at the URL "http://www.eclipse.org/legal/epl-v10.html". - - diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/group/backup_registration.xml --- a/loadgen/group/backup_registration.xml Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ - - - - - - - - diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/group/bld.inf --- a/loadgen/group/bld.inf Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -// ============================================================================ -// * Makefile for building: group -// * Generated by qmake (2.01a) (Qt 4.6.3) on: 2010-06-17T13:18:03 -// * This file is generated by qmake and should not be modified by the -// * user. -// * Project: group.pro -// * Template: subdirs -// ============================================================================ - -#define BLD_INF_GROUP_037FC092 - - -prj_platforms - -WINSCW GCCE ARMV5 ARMV6 -#include "bld_generic.inf" -#include "../ui/avkon/group/bld.inf" - - -prj_mmpfiles - - -prj_extensions - - -#if defined(WINSCW) -#endif - -START EXTENSION qt/qmake_store_build -END - - diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/group/bld_generic.inf --- a/loadgen/group/bld_generic.inf Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,58 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#include - - -PRJ_EXPORTS -../group/backup_registration.xml Z:/private/20011384/backup_registration.xml - - -PRJ_MMPFILES -#if defined(__SERIES60_30__) || defined(__SERIES60_31__) || defined(__S60_32__) - gnumakefile loadgen_icons_aif.mk - gnumakefile loadgen_extraicons.mk - - #ifdef MARM - gnumakefile loadgen_stub_sis.mk - #endif -#endif - - -#if(!defined __SERIES60_30__ && !defined __SERIES60_31__ && !defined __S60_32__) - PRJ_EXTENSIONS - START EXTENSION s60/mifconv - OPTION TARGETFILE loadgen_aif.mif - OPTION SOURCEDIR ../icons - OPTION SOURCES -c8,8 qgn_menu_loadgen - END - - START EXTENSION s60/mifconv - OPTION TARGETFILE loadgen_extraicons.mif - OPTION HEADERFILE loadgen_extraicons.mbg - OPTION SOURCEDIR ../icons - OPTION SOURCES -c8,8 qgn_prob_status_red -c8,8 qgn_prob_status_green - END - - #ifdef MARM - START EXTENSION app-services/buildstubsis - OPTION SRCDIR ../sis - OPTION SISNAME LoadGen_stub - END - #endif -#endif diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/group/group.pro --- a/loadgen/group/group.pro Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ - - -TEMPLATE = subdirs - -BLD_INF_RULES.prj_platforms += "$${LITERAL_HASH}include \"bld_generic.inf\"" diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/group/loadgen_extraicons.mk --- a/loadgen/group/loadgen_extraicons.mk Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,60 +0,0 @@ -# -# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# This component and the accompanying materials are made available -# under the terms of "Eclipse Public License v1.0" -# which accompanies this distribution, and is available -# at the URL "http://www.eclipse.org/legal/epl-v10.html". -# -# Initial Contributors: -# Nokia Corporation - initial contribution. -# -# Contributors: -# -# Description: -# - -ifeq (WINS,$(findstring WINS, $(PLATFORM))) -ZDIR=\epoc32\release\$(PLATFORM)\$(CFG)\z -else -ZDIR=\epoc32\data\z -endif - -TARGETDIR=$(ZDIR)\resource\apps -ICONTARGETFILENAME=$(TARGETDIR)\loadgen_extraicons.mif - -HEADERDIR=\epoc32\include -HEADERFILENAME=$(HEADERDIR)\loadgen_extraicons.mbg - - -do_nothing : - @rem do_nothing - -MAKMAKE : do_nothing - -BLD : do_nothing - -CLEAN : - @if exist $(ICONTARGETFILENAME) erase $(ICONTARGETFILENAME) - @if exist $(HEADERFILENAME) erase $(HEADERFILENAME) - -LIB : do_nothing - -CLEANLIB : do_nothing - -RESOURCE : $(ICONTARGETFILENAME) - -$(ICONTARGETFILENAME) (HEADERFILENAME) : ..\icons\qgn_prob_status_red.svg ..\icons\qgn_prob_status_green.svg - mifconv $(ICONTARGETFILENAME) /h$(HEADERFILENAME) \ - /c8,8 ..\icons\qgn_prob_status_red.svg \ - /c8,8 ..\icons\qgn_prob_status_green.svg - -FREEZE : do_nothing - -SAVESPACE : do_nothing - -RELEASABLES : - @echo $(HEADERFILENAME) && \ - @echo $(ICONTARGETFILENAME) - -FINAL : do_nothing diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/group/loadgen_icons_aif.mk --- a/loadgen/group/loadgen_icons_aif.mk Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,54 +0,0 @@ -# -# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# This component and the accompanying materials are made available -# under the terms of "Eclipse Public License v1.0" -# which accompanies this distribution, and is available -# at the URL "http://www.eclipse.org/legal/epl-v10.html". -# -# Initial Contributors: -# Nokia Corporation - initial contribution. -# -# Contributors: -# -# Description: -# - -ifeq (WINS,$(findstring WINS, $(PLATFORM))) -ZDIR=\epoc32\release\$(PLATFORM)\$(CFG)\z -else -ZDIR=\epoc32\data\z -endif - -TARGETDIR=$(ZDIR)\resource\apps -ICONTARGETFILENAME=$(TARGETDIR)\loadgen_aif.mif - - -do_nothing : - @rem do_nothing - -MAKMAKE : do_nothing - -BLD : do_nothing - -CLEAN : - @if exist $(ICONTARGETFILENAME) erase $(ICONTARGETFILENAME) - -LIB : do_nothing - -CLEANLIB : do_nothing - -RESOURCE : $(ICONTARGETFILENAME) - -$(ICONTARGETFILENAME) : ..\icons\qgn_menu_loadgen.svg - mifconv $(ICONTARGETFILENAME) \ - /c8,8 ..\icons\qgn_menu_loadgen.svg - -FREEZE : do_nothing - -SAVESPACE : do_nothing - -RELEASABLES : - @echo $(ICONTARGETFILENAME) - -FINAL : do_nothing diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/group/loadgen_stub_sis.mk --- a/loadgen/group/loadgen_stub_sis.mk Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -# -# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# This component and the accompanying materials are made available -# under the terms of "Eclipse Public License v1.0" -# which accompanies this distribution, and is available -# at the URL "http://www.eclipse.org/legal/epl-v10.html". -# -# Initial Contributors: -# Nokia Corporation - initial contribution. -# -# Contributors: -# -# Description: -# - - -TARGETDIR=$(EPOCROOT)EPOC32\Data\Z\System\Install - -SISNAME=LoadGen_stub -PKGNAME=LoadGen_stub - -$(TARGETDIR) : - @perl -S emkdir.pl "$(TARGETDIR)" - -do_nothing : - rem do_nothing - -SISFILE=$(TARGETDIR)\$(SISNAME).sis - -$(SISFILE) : ..\sis\$(PKGNAME).pkg - makesis -s $? $@ - - - -MAKMAKE : do_nothing - -RESOURCE : do_nothing - -SAVESPACE : do_nothing - -BLD : do_nothing - -FREEZE : do_nothing - -LIB : do_nothing - -CLEANLIB : do_nothing - -FINAL : $(TARGETDIR) $(SISFILE) - -CLEAN : - @if exist $(SISFILE) erase $(SISFILE) - -RELEASABLES : - @echo $(SISFILE) diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/icons/qgn_menu_loadgen.svg --- a/loadgen/icons/qgn_menu_loadgen.svg Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ - - - - - - - - - - - - - - - diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/icons/qgn_prob_status_green.svg --- a/loadgen/icons/qgn_prob_status_green.svg Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/icons/qgn_prob_status_red.svg --- a/loadgen/icons/qgn_prob_status_red.svg Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/loadgen.pro --- a/loadgen/loadgen.pro Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,24 +0,0 @@ -# -# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# This component and the accompanying materials are made available -# under the terms of "Eclipse Public License v1.0" -# which accompanies this distribution, and is available -# at the URL "http://www.eclipse.org/legal/epl-v10.html". -# -# Initial Contributors: -# Nokia Corporation - initial contribution. -# -# Contributors: -# -# Description: -# -# - - -TEMPLATE = subdirs - -DEFINES += QT_NO_DEBUG_OUTPUT QT_NO_WARNING_OUTPUT QT_NO_DEBUG - -SUBDIRS = group \ - ui/hb diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/sis/LoadGen_S60-30.pkg --- a/loadgen/sis/LoadGen_S60-30.pkg Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -; -; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -; All rights reserved. -; This component and the accompanying materials are made available -; under the terms of "Eclipse Public License v1.0" -; which accompanies this distribution, and is available -; at the URL "http://www.eclipse.org/legal/epl-v10.html". -; -; Initial Contributors: -; Nokia Corporation - initial contribution. -; -; Contributors: -; -; Description: -; - -; Language - standard language definitions -&EN - -; Standard SIS file header -#{"LoadGen"},(0x20011384),1,4,0,TYPE=SA - -; Supports S60 v 3.0 -[0x101F7961], 0, 0, 0, {"S60ProductID"} - -; Non-localised vendor name -:"Nokia Corporation" - -; Localised vendor names -%{"Nokia Corporation"} - -; normal stuff: -"\epoc32\RELEASE\armv5\UREL\LoadGen.exe"-"!:\sys\bin\LoadGen.exe" -"\epoc32\data\z\Resource\apps\LoadGen_aif.mif"-"!:\Resource\Apps\LoadGen_aif.mif" -"\epoc32\data\z\Resource\apps\LoadGen_ExtraIcons.mif"-"!:\Resource\Apps\LoadGen_ExtraIcons.mif" -"\epoc32\data\z\Resource\apps\LoadGen.rsc"-"!:\Resource\Apps\LoadGen.rsc" -"\epoc32\data\z\PRIVATE\10003A3F\APPS\LoadGen_reg.rsc"-"!:\private\10003a3f\import\apps\LoadGen_reg.rsc" -"..\group\backup_registration.xml"-"!:\private\20011384\backup_registration.xml" diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/sis/LoadGen_S60-30.sis Binary file loadgen/sis/LoadGen_S60-30.sis has changed diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/sis/LoadGen_stub.pkg --- a/loadgen/sis/LoadGen_stub.pkg Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +0,0 @@ -; -; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -; All rights reserved. -; This component and the accompanying materials are made available -; under the terms of "Eclipse Public License v1.0" -; which accompanies this distribution, and is available -; at the URL "http://www.eclipse.org/legal/epl-v10.html". -; -; Initial Contributors: -; Nokia Corporation - initial contribution. -; -; Contributors: -; -; Description: -; - - -; Language - standard language definitions -&EN - -; Standard SIS file header -#{"LoadGen"},(0x20011384),1,0,0 - -; Non-localised vendor name -:"Nokia Corporation" - -; Localised vendor names -%{"Nokia Corporation"} - -; normal stuff: -""-"z:\sys\bin\LoadGen.exe" -""-"z:\Resource\Apps\LoadGen.mif" -""-"z:\Resource\Apps\LoadGen_aif.mif" -""-"z:\Resource\Apps\LoadGen_ExtraIcons.mif" -""-"z:\Resource\Apps\LoadGen.rsc" -""-"z:\private\10003a3f\import\apps\LoadGen_reg.rsc" -""-"z:\private\20011384\backup_registration.xml" diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/ui/avkon/data/loadgen.rss --- a/loadgen/ui/avkon/data/loadgen.rss Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1421 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - -NAME MATT - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "loadgen.hrh" -#include "loadgen_std.h" - - -// --------------------------------------------------------- -// -// Define the resource file signature -// This resource should be empty. -// -// --------------------------------------------------------- -// -RESOURCE RSS_SIGNATURE { } - -// --------------------------------------------------------- -// -// Default Document Name -// -// --------------------------------------------------------- -// -RESOURCE TBUF r_default_document_name { buf=""; } - -// --------------------------------------------------------- -// -// Define default menu and CBA key. -// -// --------------------------------------------------------- -// -RESOURCE EIK_APP_INFO - { - //status_pane = r_loadgen_status_pane; - //menubar = r_loadgen_menubar; - //cba = R_AVKON_SOFTKEYS_OPTIONS_EXIT; - } - - -//---------------------------------------------------- -// -// r_loadgen_hotkeys -// -//---------------------------------------------------- -// -RESOURCE HOTKEYS r_loadgen_hotkeys - { - control= - { - HOTKEY { command=EAknCmdExit; key='e'; } - }; - } - - -//---------------------------------------------------- -// r_loadgen_view_main -//---------------------------------------------------- -// -RESOURCE AVKON_VIEW r_loadgen_view_main - { - hotkeys=r_loadgen_hotkeys; - menubar=r_loadgen_menubar_view_main; - cba=R_AVKON_SOFTKEYS_OPTIONS_EXIT; - } - -//---------------------------------------------------- -// r_loadgen_menubar_view_main -//---------------------------------------------------- -// -RESOURCE MENU_BAR r_loadgen_menubar_view_main - { - titles= - { - MENU_TITLE { menu_pane=r_loadgen_app_menu; txt="App"; }, - MENU_TITLE { menu_pane=r_loadgen_view_main_menu; txt="Main"; } - }; - } - -//---------------------------------------------------- -// r_loadgen_view_main_menu -//---------------------------------------------------- -// - -RESOURCE MENU_PANE r_loadgen_view_main_menu - { - items= - { - }; - } - - - -//---------------------------------------------------- -// r_loadgen_app_menu -//---------------------------------------------------- -// -RESOURCE MENU_PANE r_loadgen_app_menu - { - items= - { - MENU_ITEM { command=ELoadGenCmdNewLoad; txt="New load"; cascade=r_loadgen_newload_submenu; }, - MENU_ITEM { command=ELoadGenStopAll; txt="Stop all"; }, - MENU_ITEM { command=ELoadGenSuspendAll; txt="Suspend all"; }, - MENU_ITEM { command=ELoadGenResumeAll; txt="Resume all"; }, - MENU_ITEM { command=ELoadGenCmdLaunchPerfMon; txt="Launch PerfMon"; }, - MENU_ITEM { command=ELoadGenCmdAbout; txt="About"; }, - MENU_ITEM { command=EAknCmdExit; txt="Exit"; } - }; - } - -RESOURCE MENU_PANE r_loadgen_newload_submenu - { - items = - { - MENU_ITEM { command=ELoadGenCmdNewLoadCPULoad; txt="CPU load"; }, - MENU_ITEM { command=ELoadGenCmdNewLoadEatMemory; txt="Eat memory"; }, - MENU_ITEM { command=ELoadGenCmdNewLoadPhoneCall; txt="Phone calls"; }, - MENU_ITEM { command=ELoadGenCmdNewLoadMessages; txt="Messages"; }, - MENU_ITEM { command=ELoadGenCmdNewLoadNetConn; txt="Network conn."; }, - MENU_ITEM { command=ELoadGenCmdNewLoadKeyPress; txt="Key presses"; }, - MENU_ITEM { command=ELoadGenCmdNewLoadApplications; txt="Applications"; }, - MENU_ITEM { command=ELoadGenCmdNewLoadPhotoCaptures; txt="Photo captures"; }, - MENU_ITEM { command=ELoadGenCmdNewLoadBluetooth; txt="Bluetooth actions"; }, - MENU_ITEM { command=ELoadGenCmdNewLoadPointerEvent; txt="Pointer events"; } - }; - } - -//---------------------------------------------------- -// r_loadgen_settings_dialog -// Dialog for setting list -//---------------------------------------------------- -// -RESOURCE DIALOG r_loadgen_settings_dialog - { - flags = - EEikDialogFlagNoDrag | EEikDialogFlagFillAppClientRect | - EEikDialogFlagButtonsRight | EEikDialogFlagCbaButtons | - EEikDialogFlagWait | EEikDialogFlagNoTitleBar; - buttons = R_AVKON_SOFTKEYS_OPTIONS_BACK; - items = - { - DLG_LINE - { - type = EAknCtSettingListBox; - id = ELoadGenSettingItemList; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = LISTBOX - { - flags = EAknListBoxSelectionList; - }; - } - }; - } - -//---------------------------------------------------- -// r_loadgen_settings_menubar -//---------------------------------------------------- -// - -RESOURCE MENU_BAR r_loadgen_settings_menubar - { - titles = - { - MENU_TITLE - { - menu_pane = r_loadgen_settings_menupane; - txt = " "; // dummy - } - }; - } - -RESOURCE MENU_PANE r_loadgen_settings_menupane - { - items = - { - MENU_ITEM - { - command = ELoadGenCmdSettingsChange; - txt = "Change"; - }, - MENU_ITEM - { - command = ELoadGenCmdSettingsExit; - txt = "Exit"; - } - }; - } - - - - -// --------------------------------------------------------- -// -// r_loadgen_about_dialog -// About dialog - show version and copyright info etc. -// -// --------------------------------------------------------- -// -RESOURCE DIALOG r_loadgen_about_dialog - { - flags = EGeneralQueryFlags | EEikDialogFlagNoBorder | EEikDialogFlagNoShadow; - buttons = R_AVKON_SOFTKEYS_OK_EMPTY; - items= - { - DLG_LINE - { - type = EAknCtPopupHeadingPane; - id = EAknMessageQueryHeaderId; - control = AVKON_HEADING - { - label = "About LoadGen"; - headinglayout = R_AVKON_WML_SIGN_QUERY_HEADING_PANE; - }; - }, - DLG_LINE - { - type = EAknCtMessageQuery; - id = EAknMessageQueryContentId; - control = AVKON_MESSAGE_QUERY - { - message = "Version 1.5.1 - 9th September 2010. Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. Licensed under Eclipse Public License v1.0."; - }; - } - }; - } - -// --------------------------------------------------------- -// r_general_confirmation_query -// --------------------------------------------------------- -// - -RESOURCE DIALOG r_general_confirmation_query - { - flags = EGeneralQueryFlags; - buttons = R_AVKON_SOFTKEYS_YES_NO; - items = - { - DLG_LINE - { - type = EAknCtQuery; - id = EGeneralQuery; - control = AVKON_CONFIRMATION_QUERY - { - layout = EConfirmationQueryLayout; - }; - } - }; - } - -// --------------------------------------------------------- -// r_general_text_query -// --------------------------------------------------------- -// -RESOURCE DIALOG r_general_text_query - { - flags = EGeneralQueryFlags; - buttons = R_AVKON_SOFTKEYS_OK_CANCEL; - items= - { - DLG_LINE - { - type = EAknCtQuery; - id = EGeneralQuery; - control = AVKON_DATA_QUERY - { - layout = EDataLayout; - control = EDWIN - { - width = 256; - lines = 3; - maxlength = 256; - }; - }; - } - }; - } - -// --------------------------------------------------------- -// r_general_text_query -// --------------------------------------------------------- -// -RESOURCE DIALOG r_general_numeric_query - { - flags = EGeneralQueryFlags; - buttons = R_AVKON_SOFTKEYS_OK_CANCEL; - items = - { - DLG_LINE - { - type = EAknCtQuery; - id = EGeneralQuery; - control= AVKON_DATA_QUERY - { - layout = ENumberLayout; - control = AVKON_INTEGER_EDWIN - { - min = -999999; - max = 999999; - }; - }; - } - }; - } - - -// --------------------------------------------------------- -// r_item_action_query -// --------------------------------------------------------- -// -RESOURCE DIALOG r_item_action_query - { - flags = EGeneralQueryFlags; - buttons = R_AVKON_SOFTKEYS_OK_CANCEL; - items = - { - AVKON_LIST_QUERY_DLG_LINE - { - control= AVKON_LIST_QUERY_CONTROL - { - listtype = EAknCtSinglePopupMenuListBox; - listbox = AVKON_LIST_QUERY_LIST - { - array_id = r_item_action_query_array; - }; - heading = ""; - }; - } - }; - } - -RESOURCE ARRAY r_item_action_query_array - { - items = - { - LBUF {txt = "Stop"; }, - LBUF {txt = "Resume/suspend"; }, - LBUF {txt = "Edit"; } - }; - } - - -// --------------------------------------------------------- -// r_cpuload_form_dialog -// --------------------------------------------------------- -// -RESOURCE DIALOG r_cpuload_form_dialog - { - flags = EAknDialogGenericFullScreen; - buttons = R_AVKON_SOFTKEYS_OK_CANCEL; - form = r_cpuload_form; - } - -RESOURCE FORM r_cpuload_form - { - flags = EEikFormEditModeOnly | EEikFormUseDoubleSpacedFormat; - items = - { - DLG_LINE - { - type = EAknCtPopupFieldText; - prompt = "Priority"; - id = ELoadGenCPULoadQueryPriority; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = POPUP_FIELD_TEXT - { - popupfield = POPUP_FIELD - { - width = 100; - }; - textarray = r_thread_priority_textarray; - active = 0; - }; - }, - DLG_LINE - { - type = EAknCtPopupFieldText; - prompt = "Load mode"; - id = ELoadGenCPULoadQueryMode; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = POPUP_FIELD_TEXT - { - popupfield = POPUP_FIELD - { - width = 100; - }; - textarray = r_cpuloadmode_textarray; - active = 0; - }; - }, - DLG_LINE - { - type = EAknCtPopupFieldText; - prompt = "Type"; - id = ELoadGenCPULoadQueryType; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = POPUP_FIELD_TEXT - { - popupfield = POPUP_FIELD - { - width = 100; - }; - textarray = r_cpuloadtype_textarray; - active = 0; - }; - } - }; - } - -RESOURCE DLG_LINE r_cpuload_dlg_line_periodic_length - { - type = EEikCtNumberEditor; - prompt = "Length (ms)"; - id = ELoadGenCPULoadQueryLength; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = NUMBER_EDITOR - { - min = 0; - max = 999999999; - }; - } - -RESOURCE DLG_LINE r_cpuload_dlg_line_periodic_idle - { - type = EEikCtNumberEditor; - prompt = "Idle (ms)"; - id = ELoadGenCPULoadQueryIdle; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = NUMBER_EDITOR - { - min = 0; - max = 999999999; - }; - } - -RESOURCE DLG_LINE r_cpuload_dlg_line_periodic_variance - { - type = EEikCtNumberEditor; - prompt = "Random variance (%)"; - id = ELoadGenCPULoadQueryVariance; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = NUMBER_EDITOR - { - min = 0; - max = 100; - }; - } - -RESOURCE DLG_LINE r_cpuload_dlg_line_cpu - { - type = EAknCtPopupFieldText; - prompt = "CPU"; - id = ELoadGenCPULoadQueryCpu; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = POPUP_FIELD_TEXT - { - popupfield = POPUP_FIELD - { - width = 100; - }; - textarray = r_cpuloadcpu_textarray; - active = 0; - }; - } - - -// --------------------------------------------------------- -// r_memoryeat_form_dialog -// --------------------------------------------------------- -// -RESOURCE DIALOG r_memoryeat_form_dialog - { - flags = EAknDialogGenericFullScreen; - buttons = R_AVKON_SOFTKEYS_OK_CANCEL; - form = r_memoryeat_form; - } - -RESOURCE FORM r_memoryeat_form - { - flags = EEikFormEditModeOnly | EEikFormUseDoubleSpacedFormat; - items = - { - DLG_LINE - { - type = EAknCtPopupFieldText; - prompt = "Priority"; - id = ELoadGenMemoryEatQueryPriority; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = POPUP_FIELD_TEXT - { - popupfield = POPUP_FIELD - { - width = 100; - }; - textarray = r_thread_priority_textarray; - active = 0; - }; - }, - DLG_LINE - { - type = EAknCtPopupFieldText; - prompt = "Source"; - id = ELoadGenMemoryEatQuerySource; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = POPUP_FIELD_TEXT - { - popupfield = POPUP_FIELD - { - width = 100; - }; - textarray = r_memoryeatsource_textarray; - active = 0; - }; - }, - DLG_LINE - { - type = EAknCtPopupFieldText; - prompt = "Type"; - id = ELoadGenMemoryEatQueryType; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = POPUP_FIELD_TEXT - { - popupfield = POPUP_FIELD - { - width = 100; - }; - textarray = r_memoryeattype_textarray; - active = 0; - }; - }, - DLG_LINE - { - type = EEikCtNumberEditor; - prompt = "Buffer (B)"; - id = ELoadGenMemoryEatQueryBuffer; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = NUMBER_EDITOR - { - min = 0; - max = 999999999; - }; - }, - DLG_LINE - { - type = EEikCtNumberEditor; - prompt = "Idle after buffer (ms)"; - id = ELoadGenMemoryEatQueryIdle; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = NUMBER_EDITOR - { - min = 0; - max = 999999999; - }; - }, - DLG_LINE - { - type = EEikCtNumberEditor; - prompt = "Random variance (%)"; - id = ELoadGenMemoryEatQueryVariance; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = NUMBER_EDITOR - { - min = 0; - max = 100; - }; - } - }; - } - -RESOURCE DLG_LINE r_memoryeat_dlg_line_amount - { - type = EEikCtEdwin; - prompt = "Amount (B)"; - id = ELoadGenMemoryEatQueryAmount; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = EDWIN - { - flags = KMultiLineExpandingEditorFlags | EEikEdwinNoLineOrParaBreaks; - maxlength = 14; - width = 6; - default_input_mode = EAknEditorNumericInputMode; - allowed_input_modes = EAknEditorNumericInputMode; - }; - } - -RESOURCE DLG_LINE r_memoryeat_dlg_line_random_min - { - type = EEikCtEdwin; - prompt = "Min to be left (B)"; - id = ELoadGenMemoryEatQueryRandomMin; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = EDWIN - { - flags = KMultiLineExpandingEditorFlags | EEikEdwinNoLineOrParaBreaks; - maxlength = 14; - width = 6; - default_input_mode = EAknEditorNumericInputMode; - allowed_input_modes = EAknEditorNumericInputMode; - }; - } - -RESOURCE DLG_LINE r_memoryeat_dlg_line_random_max - { - type = EEikCtEdwin; - prompt = "Max to be left (B)"; - id = ELoadGenMemoryEatQueryRandomMax; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = EDWIN - { - flags = KMultiLineExpandingEditorFlags | EEikEdwinNoLineOrParaBreaks; - maxlength = 14; - width = 6; - default_input_mode = EAknEditorNumericInputMode; - allowed_input_modes = EAknEditorNumericInputMode; - }; - } - - - -// --------------------------------------------------------- -// r_phonecall_form_dialog -// --------------------------------------------------------- -// -RESOURCE DIALOG r_phonecall_form_dialog - { - flags = EAknDialogGenericFullScreen; - buttons = R_AVKON_SOFTKEYS_OK_CANCEL; - form = r_phonecall_form; - } - -RESOURCE FORM r_phonecall_form - { - flags = EEikFormEditModeOnly | EEikFormUseDoubleSpacedFormat; - items = - { - DLG_LINE - { - type = EAknCtPopupFieldText; - prompt = "Priority"; - id = ELoadGenPhoneCallQueryPriority; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = POPUP_FIELD_TEXT - { - popupfield = POPUP_FIELD - { - width = 100; - }; - textarray = r_thread_priority_textarray; - active = 0; - }; - }, - DLG_LINE - { - type = EEikCtEdwin; - prompt = "Phone number"; - id = ELoadGenPhoneCallQueryDestination; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = EDWIN - { - width = 255; - maxlength = 255; - }; - }, - DLG_LINE - { - type = EEikCtNumberEditor; - prompt = "Length (ms)"; - id = ELoadGenPhoneCallQueryLength; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = NUMBER_EDITOR - { - min = 0; - max = 999999999; - }; - }, - DLG_LINE - { - type = EEikCtNumberEditor; - prompt = "Idle (ms)"; - id = ELoadGenPhoneCallQueryIdle; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = NUMBER_EDITOR - { - min = 0; - max = 999999999; - }; - }, - DLG_LINE - { - type = EEikCtNumberEditor; - prompt = "Random variance (%)"; - id = ELoadGenPhoneCallQueryVariance; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = NUMBER_EDITOR - { - min = 0; - max = 100; - }; - } - }; - } - - -// --------------------------------------------------------- -// r_netconn_form_dialog -// --------------------------------------------------------- -// -RESOURCE DIALOG r_netconn_form_dialog - { - flags = EAknDialogGenericFullScreen; - buttons = R_AVKON_SOFTKEYS_OK_CANCEL; - form = r_netconn_form; - } - -RESOURCE FORM r_netconn_form - { - flags = EEikFormEditModeOnly | EEikFormUseDoubleSpacedFormat; - items = - { - DLG_LINE - { - type = EAknCtPopupFieldText; - prompt = "Priority"; - id = ELoadGenNetConnQueryPriority; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = POPUP_FIELD_TEXT - { - popupfield = POPUP_FIELD - { - width = 100; - }; - textarray = r_thread_priority_textarray; - active = 0; - }; - }, - DLG_LINE - { - type = EEikCtEdwin; - prompt = "Destination URL"; - id = ELoadGenNetConnQueryDestination; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = EDWIN - { - width = 255; - maxlength = 255; - }; - }, - DLG_LINE - { - type = EEikCtNumberEditor; - prompt = "Idle (ms)"; - id = ELoadGenNetConnQueryIdle; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = NUMBER_EDITOR - { - min = 0; - max = 999999999; - }; - }, - DLG_LINE - { - type = EEikCtNumberEditor; - prompt = "Random variance (%)"; - id = ELoadGenNetConnQueryVariance; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = NUMBER_EDITOR - { - min = 0; - max = 100; - }; - } - }; - } - - -// --------------------------------------------------------- -// r_keypress_form_dialog -// --------------------------------------------------------- -// -RESOURCE DIALOG r_keypress_form_dialog - { - flags = EAknDialogGenericFullScreen; - buttons = R_AVKON_SOFTKEYS_OK_CANCEL; - form = r_keypress_form; - } - -RESOURCE FORM r_keypress_form - { - flags = EEikFormEditModeOnly | EEikFormUseDoubleSpacedFormat; - items = - { - DLG_LINE - { - type = EAknCtPopupFieldText; - prompt = "Priority"; - id = ELoadGenKeyPressQueryPriority; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = POPUP_FIELD_TEXT - { - popupfield = POPUP_FIELD - { - width = 100; - }; - textarray = r_thread_priority_textarray; - active = 0; - }; - }, - DLG_LINE - { - type = EEikCtNumberEditor; - prompt = "Heartbeat (ms)"; - id = ELoadGenKeyPressQueryHeartBeat; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = NUMBER_EDITOR - { - min = 0; - max = 999999999; - }; - }, - DLG_LINE - { - type = EEikCtNumberEditor; - prompt = "Random variance (%)"; - id = ELoadGenKeyPressQueryVariance; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = NUMBER_EDITOR - { - min = 0; - max = 100; - }; - } - }; - } - -// --------------------------------------------------------- -// r_pointerevent_form_dialog -// --------------------------------------------------------- -// -RESOURCE DIALOG r_pointerevent_form_dialog - { - flags = EAknDialogGenericFullScreen; - buttons = R_AVKON_SOFTKEYS_OK_CANCEL; - form = r_pointerevent_form; - } - -RESOURCE FORM r_pointerevent_form - { - flags = EEikFormEditModeOnly | EEikFormUseDoubleSpacedFormat; - items = - { - DLG_LINE - { - type = EAknCtPopupFieldText; - prompt = "Priority"; - id = ELoadGenPointerEventQueryPriority; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = POPUP_FIELD_TEXT - { - popupfield = POPUP_FIELD - { - width = 100; - }; - textarray = r_thread_priority_textarray; - active = 0; - }; - }, - DLG_LINE - { - type = EEikCtNumberEditor; - prompt = "Heartbeat (ms)"; - id = ELoadGenPointerEventQueryHeartBeat; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = NUMBER_EDITOR - { - min = 0; - max = 999999999; - }; - }, - DLG_LINE - { - type = EEikCtNumberEditor; - prompt = "Random variance (%)"; - id = ELoadGenPointerEventQueryVariance; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = NUMBER_EDITOR - { - min = 0; - max = 100; - }; - } - }; - } - -// --------------------------------------------------------- -// r_messages_form_dialog -// --------------------------------------------------------- -// -RESOURCE DIALOG r_messages_form_dialog - { - flags = EAknDialogGenericFullScreen; - buttons = R_AVKON_SOFTKEYS_OK_CANCEL; - form = r_messages_form; - } - -RESOURCE FORM r_messages_form - { - flags = EEikFormEditModeOnly | EEikFormUseDoubleSpacedFormat; - items = - { - DLG_LINE - { - type = EAknCtPopupFieldText; - prompt = "Priority"; - id = ELoadGenMessagesQueryPriority; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = POPUP_FIELD_TEXT - { - popupfield = POPUP_FIELD - { - width = 100; - }; - textarray = r_thread_priority_textarray; - active = 0; - }; - }, - DLG_LINE - { - type = EAknCtPopupFieldText; - prompt = "Type"; - id = ELoadGenMessagesQueryType; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = POPUP_FIELD_TEXT - { - popupfield = POPUP_FIELD - { - width = 100; - }; - textarray = r_message_type_textarray; - active = 0; - }; - }, - DLG_LINE - { - type = EEikCtEdwin; - prompt = "Phone number"; - id = ELoadGenMessagesQueryDestination; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = EDWIN - { - width = 255; - maxlength = 255; - }; - }, - DLG_LINE - { - type = EEikCtNumberEditor; - prompt = "Maximum amount of messages"; - id = ELoadGenMessagesQueryAmount; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = NUMBER_EDITOR - { - min = 0; - max = 1000; - }; - }, - DLG_LINE - { - type = EEikCtNumberEditor; - prompt = "Message length"; - id = ELoadGenMessagesQueryLength; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = NUMBER_EDITOR - { - min = 0; - max = 512; - }; - }, - DLG_LINE - { - type = EEikCtNumberEditor; - prompt = "Idle (ms)"; - id = ELoadGenMessagesQueryIdle; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = NUMBER_EDITOR - { - min = 0; - max = 999999999; - }; - }, - DLG_LINE - { - type = EEikCtNumberEditor; - prompt = "Random variance (%)"; - id = ELoadGenMessagesQueryVariance; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = NUMBER_EDITOR - { - min = 0; - max = 100; - }; - } - }; - } - -// --------------------------------------------------------- -// r_applicatios_form_dialog -// --------------------------------------------------------- -// -RESOURCE DIALOG r_applications_form_dialog - { - flags = EAknDialogGenericFullScreen; - buttons = R_AVKON_SOFTKEYS_OK_CANCEL; - form = r_applications_form; - } - -RESOURCE FORM r_applications_form - { - flags = EEikFormEditModeOnly | EEikFormUseDoubleSpacedFormat; - items = - { - DLG_LINE - { - type = EAknCtPopupFieldText; - prompt = "Priority"; - id = ELoadGenApplicationsQueryPriority; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = POPUP_FIELD_TEXT - { - popupfield = POPUP_FIELD - { - width = 100; - }; - textarray = r_thread_priority_textarray; - active = 0; - }; - }, - DLG_LINE - { - type = EEikCtNumberEditor; - prompt = "Max parallel applications"; - id = ELoadGenApplicationsMaxOpen; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = NUMBER_EDITOR - { - min = 0; - max = 100; - }; - }, - DLG_LINE - { - type = EEikCtNumberEditor; - prompt = "Launching interval (ms)"; - id = ELoadGenApplicationsLaunchingInterval; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = NUMBER_EDITOR - { - min = 0; - max = 999999999; - }; - }, - - DLG_LINE - { - type = EAknCtPopupFieldText; - prompt = "Key press type"; - id = ELoadGenApplicationsKeyPressType; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = POPUP_FIELD_TEXT - { - popupfield = POPUP_FIELD - { - width = 100; - }; - textarray = r_applications_keypress_type_textarray; - active = 0; - }; - }, - DLG_LINE - { - type = EEikCtNumberEditor; - prompt = "Key press interval (ms)"; - id = ELoadGenApplicationsKeyPressQueryHeartBeat; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = NUMBER_EDITOR - { - min = 0; - max = 999999999; - }; - }, - DLG_LINE - { - type = EEikCtNumberEditor; - prompt = "Random variance (%)"; - id = ELoadGenApplicationsQueryVariance; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = NUMBER_EDITOR - { - min = 0; - max = 100; - }; - } - }; - } - -// --------------------------------------------------------- -// r_photocapture_form_dialog -// --------------------------------------------------------- -// -RESOURCE DIALOG r_photocapture_form_dialog - { - flags = EAknDialogGenericFullScreen; - buttons = R_AVKON_SOFTKEYS_OK_CANCEL; - form = r_photocapture_form; - } - -RESOURCE FORM r_photocapture_form - { - flags = EEikFormEditModeOnly | EEikFormUseDoubleSpacedFormat; - items = - { - DLG_LINE - { - type = EAknCtPopupFieldText; - prompt = "Priority"; - id = ELoadGenPhotoCaptureQueryPriority; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = POPUP_FIELD_TEXT - { - popupfield = POPUP_FIELD - { - width = 100; - }; - textarray = r_thread_priority_textarray; - active = 0; - }; - }, - DLG_LINE - { - type = EEikCtNumberEditor; - prompt = "Idle (ms)"; - id = ELoadGenPhotoCaptureQueryIdle; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = NUMBER_EDITOR - { - min = 0; - max = 999999999; - }; - }, - DLG_LINE - { - type = EEikCtNumberEditor; - prompt = "Random variance (%)"; - id = ELoadGenPhotoCaptureQueryVariance; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = NUMBER_EDITOR - { - min = 0; - max = 100; - }; - } - }; - } - -/*RESOURCE DLG_LINE r_photocapture_dlg_line_periodic_idle - { - type = EEikCtNumberEditor; - prompt = "Idle (ms)"; - id = ELoadGenPhotoCaptureQueryIdle; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = NUMBER_EDITOR - { - min = 0; - max = 999999999; - }; - } - -RESOURCE DLG_LINE r_photocapture_dlg_line_periodic_variance - { - type = EEikCtNumberEditor; - prompt = "Random variance (%)"; - id = ELoadGenPhotoCaptureQueryVariance; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = NUMBER_EDITOR - { - min = 0; - max = 100; - }; - }*/ - -RESOURCE DLG_LINE r_photocapture_dlg_line_device - { - type = EAknCtPopupFieldText; - prompt = "Device"; - id = ELoadGenPhotoCaptureQueryDevice; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = POPUP_FIELD_TEXT - { - popupfield = POPUP_FIELD - { - width = 100; - }; - textarray = r_photocapturedevice_textarray; - active = 0; - }; - } - -// --------------------------------------------------------- -// r_photocapture_form_dialog -// --------------------------------------------------------- -// -RESOURCE DIALOG r_bluetooth_form_dialog - { - flags = EAknDialogGenericFullScreen; - buttons = R_AVKON_SOFTKEYS_OK_CANCEL; - form = r_bluetooth_form; - } - -RESOURCE FORM r_bluetooth_form - { - flags = EEikFormEditModeOnly | EEikFormUseDoubleSpacedFormat; - items = - { - DLG_LINE - { - type = EAknCtPopupFieldText; - prompt = "Priority"; - id = ELoadGenBluetoothQueryPriority; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = POPUP_FIELD_TEXT - { - popupfield = POPUP_FIELD - { - width = 100; - }; - textarray = r_thread_priority_textarray; - active = 0; - }; - }, - DLG_LINE - { - type = EEikCtNumberEditor; - prompt = "Idle (ms)"; - id = ELoadGenBluetoothQueryIdle; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = NUMBER_EDITOR - { - min = 0; - max = 999999999; - }; - }, - DLG_LINE - { - type = EEikCtNumberEditor; - prompt = "Random variance (%)"; - id = ELoadGenBluetoothQueryVariance; - itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; - control = NUMBER_EDITOR - { - min = 0; - max = 100; - }; - } - }; - } - -// --------------------------------------------------------- -// Arrays for forms: - -RESOURCE ARRAY r_thread_priority_textarray - { - items = - { - LBUF { txt = "Much less (-20)"; }, - LBUF { txt = "Less (-10)"; }, - LBUF { txt = "Normal (0)"; }, - LBUF { txt = "More (10)"; }, - LBUF { txt = "Much more (20)"; }, - LBUF { txt = "Real time (30)"; }, - LBUF { txt = "Abs. very low (100)"; }, - LBUF { txt = "Abs. low (200)"; }, - LBUF { txt = "Abs. backgr. (300)"; }, - LBUF { txt = "Abs. foregr. (400)"; }, - LBUF { txt = "Abs. high (500)"; } - }; - } - -RESOURCE ARRAY r_cpuloadmode_textarray - { - items = - { - LBUF { txt = "Yielding"; }, - LBUF { txt = "Blocking"; } - }; - } - -RESOURCE ARRAY r_cpuloadtype_textarray - { - items = - { - LBUF { txt = "Continuous"; }, - LBUF { txt = "Periodic"; } - }; - } - -RESOURCE ARRAY r_cpuloadcpu_textarray - { - items = - { - LBUF { txt = "CPU0"; } - }; - } - -RESOURCE ARRAY r_memoryeatsource_textarray - { - items = - { - LBUF { txt = "RAM"; }, - LBUF { txt = "C:"; }, - LBUF { txt = "D:"; }, - LBUF { txt = "E:"; }, - LBUF { txt = "F:"; }, - LBUF { txt = "G:"; }, - LBUF { txt = "H:"; }, - LBUF { txt = "I:"; }, - LBUF { txt = "J:"; }, - LBUF { txt = "K:"; }, - LBUF { txt = "L:"; }, - LBUF { txt = "M:"; }, - LBUF { txt = "N:"; } - }; - } - -RESOURCE ARRAY r_memoryeattype_textarray - { - items = - { - LBUF { txt = "Memory to eat"; }, - LBUF { txt = "Memory to be left"; }, - LBUF { txt = "Alternate min/max"; } - }; - } - -RESOURCE ARRAY r_message_type_textarray - { - items = - { - LBUF { txt = "SMS"; }, - LBUF { txt = "MMS"; } - }; - } - -RESOURCE ARRAY r_applications_keypress_type_textarray - { - items = - { - LBUF { txt = "None"; }, - LBUF { txt = "Arrow keys"; } - }; - } - -RESOURCE ARRAY r_photocapturedevice_textarray - { - items = - { - LBUF { txt = "Camera 1"; } - }; - } - - -RESOURCE LOCALISABLE_APP_INFO r_loadgen_localisable_app_info - { - short_caption = "LoadGen"; - caption_and_icon = - CAPTION_AND_ICON_INFO - { - caption = "Load Gener."; - - number_of_icons = 1; - - // Note for ROM-based apps it is recommended to add the drive letter - // icon_file = "z:"APP_BITMAP_DIR"\\myapp_aif.mif"; - icon_file = APP_BITMAP_DIR"\\loadgen_aif.mif"; - }; - } - - - -// --------------------------------------------------------- -// -// RESOURCE LOCALISABLE_APP_INFO -// -// --------------------------------------------------------- -// diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/ui/avkon/data/loadgen_reg.rss --- a/loadgen/ui/avkon/data/loadgen_reg.rss Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - -#include -#include -#include - - -UID2 KUidAppRegistrationResourceFile -UID3 0x20011384 - - -RESOURCE APP_REGISTRATION_INFO - { - app_file = "LoadGen"; - localisable_resource_file = APP_RESOURCE_DIR"\\LoadGen"; - localisable_resource_id = R_LOADGEN_LOCALISABLE_APP_INFO; - group_name = "RnD Tools"; - } diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/ui/avkon/group/bld.inf --- a/loadgen/ui/avkon/group/bld.inf Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ -/* -* ============================================================================ -* Name : bld.inf -* Part of : LoadGen / LoadGenUI -* Description : Build information file for project LoadGen -* Version : %version: 1 % -* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -PRJ_PLATFORMS - -WINSCW ARMV5 - - -PRJ_EXPORTS -../rom/loadgen.iby CORE_IBY_EXPORT_PATH(tools,loadgen.iby) - -PRJ_MMPFILES - - -loadgen.mmp - - -PRJ_TESTMMPFILES - - -PRJ_TESTEXPORTS - diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/ui/avkon/group/loadgen.mmp --- a/loadgen/ui/avkon/group/loadgen.mmp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,118 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - -#include -#include - - -TARGET LoadGen.exe -TARGETTYPE exe -EPOCSTACKSIZE 0x5000 -EPOCHEAPSIZE 0x10000 0x1000000 // Min 64Kb, Max 16Mb - -UID 0x100039CE 0x20011384 - -VENDORID VID_DEFAULT -CAPABILITY swevent ReadUserData WriteUserData NetworkServices UserEnvironment CAP_APPLICATION AllFiles - -LANG SC - -SMPSAFE - -START RESOURCE ../data/loadgen.rss -HEADER -TARGETPATH APP_RESOURCE_DIR -END - -START RESOURCE ../data/loadgen_reg.rss -DEPENDS loadgen.rsg -TARGETPATH /private/10003a3f/apps -END - -APP_LAYER_SYSTEMINCLUDE -USERINCLUDE /epoc32/include/mw/http -USERINCLUDE ../inc -SOURCEPATH ../src - -SOURCE loadgen_app.cpp -SOURCE loadgen_document.cpp -SOURCE loadgen_appui.cpp -SOURCE loadgen_model.cpp -SOURCE loadgen_mainview.cpp -SOURCE loadgen_maincontainer.cpp -SOURCE loadgen_settingsviewdlg.cpp -SOURCE loadgen_editors.cpp - -USERINCLUDE ../../../engine/inc -SOURCEPATH ../../../engine/src - - - -SOURCE loadgen_loadbase.cpp -SOURCE loadgen_cpuload.cpp -SOURCE loadgen_memoryeat.cpp -SOURCE loadgen_phonecall.cpp -SOURCE loadgen_netconn.cpp -SOURCE loadgen_keypress.cpp -SOURCE loadgen_messages.cpp -SOURCE loadgen_applications.cpp -SOURCE loadgen_photocapture.cpp -SOURCE loadgen_bluetooth.cpp -SOURCE loadgen_pointerevent.cpp -SOURCE loadgen_utils.cpp -SOURCE loadgen_httpreceiver.cpp - -LIBRARY euser.lib -LIBRARY commonengine.lib -LIBRARY apparc.lib -LIBRARY cone.lib -LIBRARY eikcore.lib -LIBRARY eikcoctl.lib -LIBRARY eikctl.lib -LIBRARY eikdlg.lib -LIBRARY avkon.lib -LIBRARY ws32.lib -LIBRARY apgrfx.lib -LIBRARY efsrv.lib -LIBRARY bafl.lib -LIBRARY gdi.lib -LIBRARY aknicon.lib -LIBRARY aknskins.lib -LIBRARY aknskinsrv.lib -LIBRARY egul.lib -LIBRARY etel3rdparty.lib -LIBRARY downloadmgr.lib -LIBRARY commdb.lib -LIBRARY flogger.lib -LIBRARY estor.lib -LIBRARY msgs.lib -LIBRARY smcm.lib -LIBRARY gsmu.lib -LIBRARY etext.lib -LIBRARY sendas2.lib -LIBRARY ecam.lib -LIBRARY featdiscovery.lib -LIBRARY centralrepository.lib -LIBRARY esock.lib -LIBRARY bluetooth.lib -LIBRARY hal.lib -LIBRARY http.lib -LIBRARY inetprotutil.lib - -// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/ui/avkon/inc/loadgen_app.h --- a/loadgen/ui/avkon/inc/loadgen_app.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,64 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#ifndef LOADGEN_APP_H -#define LOADGEN_APP_H - - -// INCLUDES -#include - -// CONSTANTS -// UID of the application -const TUid KUidLoadGen = { 0x20011384 }; - -// CLASS DECLARATION - -/** -* CLoadGenApp application class. -* Provides factory to create concrete document object. -* -*/ -class CLoadGenApp : public CAknApplication - { - - public: // Functions from base classes - /** - * From CApaApplication, overridden to enable INI file support. - * @return A pointer to the dictionary store - */ - CDictionaryStore* OpenIniFileLC(RFs& aFs) const; - private: - - /** - * From CApaApplication, creates CLoadGenDocument document object. - * @return A pointer to the created document object. - */ - CApaDocument* CreateDocumentL(); - - /** - * From CApaApplication, returns application's UID (KUidLoadGen). - * @return The value of KUidLoadGen. - */ - TUid AppDllUid() const; - }; - -#endif - -// End of File - diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/ui/avkon/inc/loadgen_appui.h --- a/loadgen/ui/avkon/inc/loadgen_appui.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,64 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#ifndef LOADGEN_APPUI_H -#define LOADGEN_APPUI_H - -// INCLUDES -#include -#include -#include -#include -#include -#include -#include -#include "loadgen_std.h" - -// FORWARD DECLARATIONS -class CLoadGenModel; -class CAknNavigationControlContainer; -class CAknTabGroup; -class CAknNavigationDecorator; - - -// CLASS DECLARATIONS - -class CLoadGenAppUi : public CAknViewAppUi - { -public: // constructors and destructor - void ConstructL(); - ~CLoadGenAppUi(); - -private: // From MEikMenuObserver - void DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane); - -private: - void HandleCommandL(TInt aCommand); - - virtual TKeyResponse HandleKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType); - -private: //Data - CLoadGenModel* iModel; - CAknNavigationControlContainer* iNaviPane; - CAknTabGroup* iTabGroup; - CAknNavigationDecorator* iDecoratedTabGroup; - }; - -#endif - -// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/ui/avkon/inc/loadgen_document.h --- a/loadgen/ui/avkon/inc/loadgen_document.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,77 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#ifndef LOADGEN_DOCUMENT_H -#define LOADGEN_DOCUMENT_H - -// INCLUDES -#include - -// CONSTANTS - -// FORWARD DECLARATIONS -class CEikAppUi; -class CLoadGenModel; - - -// CLASS DECLARATION - -/** -* CLoadGenDocument application class. -*/ -class CLoadGenDocument : public CAknDocument - { - public: // Constructors and destructor - static CLoadGenDocument* NewL(CEikApplication& aApp); - virtual ~CLoadGenDocument(); - - public: // New functions - - public:// from CEikDocument - CFileStore* OpenFileL(TBool aDoOpen,const TDesC& aFilename,RFs& aFs); - protected: // New functions - - protected: // Functions from base classes - - private: - - /** - * EPOC default constructor. - */ - CLoadGenDocument(CEikApplication& aApp); - void ConstructL(); - - private: - - /** - * From CEikDocument, create CLoadGenAppUi "App UI" object. - */ - CEikAppUi* CreateAppUiL(); - - public: - inline CLoadGenModel* Model() { return iModel; } - - private: - CLoadGenModel* iModel; - - }; - -#endif - -// End of File - diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/ui/avkon/inc/loadgen_editors.h --- a/loadgen/ui/avkon/inc/loadgen_editors.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,339 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#ifndef LOADGEN_EDITORS_H -#define LOADGEN_EDITORS_H - -// INCLUDES -#include -#include -#include - -#include "loadgen_loadattributes.h" - - -// FORWARD DECLARATIONS -class CAknQueryValueText; -class CAknQueryValueTextArray; - -// CLASS DECLARATIONS - -class CLoadGenLoadTypeEditorBase : public CAknForm - { -protected: // Constructors - CLoadGenLoadTypeEditorBase(TBool aEditingExisting); - void ConstructL(const TDesC& aTitleText); - -protected: // From CEikDialog - TBool OkToExitL(TInt aButtonId); - void PreLayoutDynInitL(); - void HandleControlStateChangeL(TInt aControlId); - -protected: // New methods - virtual TBool DoRunQueryLD(TInt aResource); - -public: // New methods - virtual TBool RunQueryLD(); - -protected: // New methods - void InsertFieldAfterL(TInt aResourceId, TInt aControlId, TInt aPrevControlId); - void UpdateFormL(); - -protected: // Data - TBool iEditingExisting; - }; - - - - -class CLoadGenCPULoadEditor : public CLoadGenLoadTypeEditorBase - { -public: - static CLoadGenCPULoadEditor* NewL(TCPULoadAttributes& aAttributes, TBool aEditingExisting=EFalse); - virtual ~CLoadGenCPULoadEditor(); - -private: // Constructors - CLoadGenCPULoadEditor(TCPULoadAttributes& aAttributes, TBool aEditingExisting=EFalse); - void ConstructL(); - -protected: // From CEikDialog - TBool OkToExitL(TInt aButtonId); - void PreLayoutDynInitL(); - void HandleControlStateChangeL(TInt aControlId); - -public: // New methods - virtual TBool RunQueryLD(); - -private: // New methods - void UpdateVisibilitiesOfFieldsL(TBool aFormInit=EFalse); - void LoadCPUsL(); - -private: // Data - TCPULoadAttributes& iAttributes; - CAknQueryValueText* iCpuQueryValText; - CAknQueryValueTextArray* iCpuTextArray; - CDesCArray* iCPUsArray; - }; - - - - -class CLoadGenMemoryEatEditor : public CLoadGenLoadTypeEditorBase - { -public: - static CLoadGenMemoryEatEditor* NewL(TMemoryEatAttributes& aAttributes, TBool aEditingExisting=EFalse); - virtual ~CLoadGenMemoryEatEditor(); - -private: // Constructors - CLoadGenMemoryEatEditor(TMemoryEatAttributes& aAttributes, TBool aEditingExisting=EFalse); - void ConstructL(); - -protected: // From CEikDialog - TBool OkToExitL(TInt aButtonId); - void PreLayoutDynInitL(); - void HandleControlStateChangeL(TInt aControlId); - -public: // New methods - virtual TBool RunQueryLD(); - -private: // New methods - void UpdateVisibilitiesOfFieldsL(TBool aFormInit=EFalse); - void UpdateAvailableMemoryL(); - -private: // Data - TMemoryEatAttributes& iAttributes; - }; - - - -class CLoadGenPhoneCallEditor : public CLoadGenLoadTypeEditorBase - { -public: - static CLoadGenPhoneCallEditor* NewL(TPhoneCallAttributes& aAttributes, TBool aEditingExisting=EFalse); - virtual ~CLoadGenPhoneCallEditor(); - -private: // Constructors - CLoadGenPhoneCallEditor(TPhoneCallAttributes& aAttributes, TBool aEditingExisting=EFalse); - void ConstructL(); - -protected: // From CEikDialog - TBool OkToExitL(TInt aButtonId); - void PreLayoutDynInitL(); - void HandleControlStateChangeL(TInt aControlId); - -public: // New methods - virtual TBool RunQueryLD(); - -private: // New methods - void UpdateVisibilitiesOfFieldsL(TBool aFormInit=EFalse); - -private: // Data - TPhoneCallAttributes& iAttributes; - }; - - - -class CLoadGenNetConnEditor : public CLoadGenLoadTypeEditorBase - { -public: - static CLoadGenNetConnEditor* NewL(TNetConnAttributes& aAttributes, TBool aEditingExisting=EFalse); - virtual ~CLoadGenNetConnEditor(); - -private: // Constructors - CLoadGenNetConnEditor(TNetConnAttributes& aAttributes, TBool aEditingExisting=EFalse); - void ConstructL(); - -protected: // From CEikDialog - TBool OkToExitL(TInt aButtonId); - void PreLayoutDynInitL(); - void HandleControlStateChangeL(TInt aControlId); - -public: // New methods - virtual TBool RunQueryLD(); - -private: // New methods - void UpdateVisibilitiesOfFieldsL(TBool aFormInit=EFalse); - -private: // Data - TNetConnAttributes& iAttributes; - }; - - - - -class CLoadGenKeyPressEditor : public CLoadGenLoadTypeEditorBase - { -public: - static CLoadGenKeyPressEditor* NewL(TKeyPressAttributes& aAttributes, TBool aEditingExisting=EFalse); - virtual ~CLoadGenKeyPressEditor(); - -private: // Constructors - CLoadGenKeyPressEditor(TKeyPressAttributes& aAttributes, TBool aEditingExisting=EFalse); - void ConstructL(); - -protected: // From CEikDialog - TBool OkToExitL(TInt aButtonId); - void PreLayoutDynInitL(); - void HandleControlStateChangeL(TInt aControlId); - -public: // New methods - virtual TBool RunQueryLD(); - -private: // New methods - void UpdateVisibilitiesOfFieldsL(TBool aFormInit=EFalse); - -private: // Data - TKeyPressAttributes& iAttributes; - }; - -class CLoadGenPointerEventEditor : public CLoadGenLoadTypeEditorBase - { -public: - static CLoadGenPointerEventEditor* NewL(TPointerEventAttributes& aAttributes, TBool aEditingExisting=EFalse); - virtual ~CLoadGenPointerEventEditor(); - -private: // Constructors - CLoadGenPointerEventEditor(TPointerEventAttributes& aAttributes, TBool aEditingExisting=EFalse); - void ConstructL(); - -protected: // From CEikDialog - TBool OkToExitL(TInt aButtonId); - void PreLayoutDynInitL(); - void HandleControlStateChangeL(TInt aControlId); - -public: // New methods - virtual TBool RunQueryLD(); - -private: // New methods - void UpdateVisibilitiesOfFieldsL(TBool aFormInit=EFalse); - -private: // Data - TPointerEventAttributes& iAttributes; - }; - - - -class CLoadGenMessagesEditor : public CLoadGenLoadTypeEditorBase - { -public: - static CLoadGenMessagesEditor* NewL( TMessageAttributes& aAttributes, - TBool aEditingExisting = EFalse ); - virtual ~CLoadGenMessagesEditor(); - -private: // Constructors - CLoadGenMessagesEditor( TMessageAttributes& aAttributes, - TBool aEditingExisting = EFalse ); - void ConstructL(); - -protected: // From CEikDialog - TBool OkToExitL( TInt aButtonId ); - void PreLayoutDynInitL(); - void HandleControlStateChangeL( TInt aControlId ); - -public: // New methods - virtual TBool RunQueryLD(); - -private: // New methods - void UpdateVisibilitiesOfFieldsL( TBool aFormInit = EFalse ); - -private: // Data - TMessageAttributes& iAttributes; - }; - -class CLoadGenApplicationsEditor : public CLoadGenLoadTypeEditorBase - { -public: - static CLoadGenApplicationsEditor* NewL( TApplicationsAttributes& aAttributes, - TBool aEditingExisting = EFalse ); - virtual ~CLoadGenApplicationsEditor(); - -private: // Constructors - CLoadGenApplicationsEditor( TApplicationsAttributes& aAttributes, - TBool aEditingExisting = EFalse ); - void ConstructL(); - -protected: // From CEikDialog - TBool OkToExitL( TInt aButtonId ); - void PreLayoutDynInitL(); - void HandleControlStateChangeL( TInt aControlId ); - -public: // New methods - virtual TBool RunQueryLD(); - -private: // New methods - void UpdateVisibilitiesOfFieldsL( TBool aFormInit = EFalse ); - -private: // Data - TApplicationsAttributes& iAttributes; - }; - -class CLoadGenPhotoCaptureEditor : public CLoadGenLoadTypeEditorBase - { -public: - static CLoadGenPhotoCaptureEditor* NewL(TPhotoCaptureAttributes& aAttributes, TBool aEditingExisting=EFalse); - virtual ~CLoadGenPhotoCaptureEditor(); - -private: // Constructors - CLoadGenPhotoCaptureEditor(TPhotoCaptureAttributes& aAttributes, TBool aEditingExisting=EFalse); - void ConstructL(); - -protected: // From CEikDialog - TBool OkToExitL(TInt aButtonId); - void PreLayoutDynInitL(); - void HandleControlStateChangeL(TInt aControlId); - -public: // New methods - virtual TBool RunQueryLD(); - -private: // New methods - void UpdateVisibilitiesOfFieldsL(TBool aFormInit=EFalse); - void LoadCamerasL(); - -private: // Data - TPhotoCaptureAttributes& iAttributes; - CAknQueryValueText* iCameraQueryValText; - CAknQueryValueTextArray* iCameraTextArray; - CDesCArray* iCamerasArray; - }; - -class CLoadGenBluetoothEditor : public CLoadGenLoadTypeEditorBase - { -public: - static CLoadGenBluetoothEditor* NewL(TBluetoothAttributes& aAttributes, TBool aEditingExisting=EFalse); - virtual ~CLoadGenBluetoothEditor(); - -private: // Constructors - CLoadGenBluetoothEditor(TBluetoothAttributes& aAttributes, TBool aEditingExisting=EFalse); - void ConstructL(); - -protected: // From CEikDialog - TBool OkToExitL(TInt aButtonId); - void PreLayoutDynInitL(); - void HandleControlStateChangeL(TInt aControlId); - -public: // New methods - virtual TBool RunQueryLD(); - -private: // New methods - void UpdateVisibilitiesOfFieldsL(TBool aFormInit=EFalse); - -private: // Data - TBluetoothAttributes& iAttributes; - }; - -#endif diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/ui/avkon/inc/loadgen_maincontainer.h --- a/loadgen/ui/avkon/inc/loadgen_maincontainer.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,70 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#ifndef LOADGEN_VALUESCONTAINER_H -#define LOADGEN_VALUESCONTAINER_H - -// INCLUDES -#include -#include -#include - -// FORWARD DECLARATIONS -class CLoadGenModel; -class CLoadGenCAknSingleGraphicStyleListBox; - -// CLASS DECLARATIONS - -class CLoadGenMainContainer : public CCoeControl, MCoeControlObserver, MEikListBoxObserver - { -public: - void ConstructL(const TRect& aRect); - ~CLoadGenMainContainer(); - -private: - void SizeChanged(); - TInt CountComponentControls() const; - CCoeControl* ComponentControl(TInt aIndex) const; - void Draw(const TRect& aRect) const; - void HandleResourceChange(TInt aType); - void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType); // From MEikListBoxObserver - void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType); // From MCoeControlObserver - TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType); - -public: - const CArrayFix* ListBoxSelectionIndexes(); - TInt ListBoxSelectionIndexesCount(); - void SetDefaultTitlePaneTextL(); - TInt CurrentListBoxItemIndex(); - void SetListBoxTextArrayL(CDesCArray* aTextArray); - inline CLoadGenCAknSingleGraphicStyleListBox* ListBox() { return iListBox; } - -private: - CLoadGenModel* iModel; - CLoadGenCAknSingleGraphicStyleListBox* iListBox; - }; - -class CLoadGenCAknSingleGraphicStyleListBox : public CAknSingleGraphicStyleListBox - { - void SizeChanged(); - void SizeChangedL(); - }; - -#endif - -// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/ui/avkon/inc/loadgen_mainview.h --- a/loadgen/ui/avkon/inc/loadgen_mainview.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,70 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#ifndef LOADGEN_VALUESVIEW_H -#define LOADGEN_VALUESVIEW_H - -// INCLUDES -#include - -#include "loadgen_std.h" - - - -// CONSTANTS -// UID of view -const TUid KMainViewUID = {1}; - - -// FORWARD DECLARATIONS -class CLoadGenMainContainer; -class CLoadGenModel; - - -// CLASS DECLARATION - -/** -* CLoadGenMainView view class. -* -*/ -class CLoadGenMainView : public CAknView - { - public: // Constructors and destructor - void ConstructL(); - ~CLoadGenMainView(); - - public: // Functions from base classes - TUid Id() const; - void HandleCommandL(TInt aCommand); - void HandleClientRectChange(); - - private: // From MEikMenuObserver - void DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane); - - private: // From AknView - void DoActivateL(const TVwsViewId& aPrevViewId, TUid aCustomMessageId, const TDesC8& aCustomMessage); - void DoDeactivate(); - - private: // Data - CLoadGenMainContainer* iContainer; - CLoadGenModel* iModel; - }; - -#endif - -// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/ui/avkon/inc/loadgen_model.h --- a/loadgen/ui/avkon/inc/loadgen_model.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,124 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#ifndef LOADGEN_MODEL_H -#define LOADGEN_MODEL_H - -// INCLUDES -#include -#include -#include - -#include "loadgen_loadattributes.h" - -// FORWARD DECLARATIONS -class CLoadGenMainContainer; -class CLoadGenGraphsContainer; -class CEikonEnv; -class CLoadBase; - - -typedef CArrayFixSeg CLoadItemList; - -const TUint KMaxCPUs = 4; - -// CLASS DECLARATIONS - -class TLoadGenSettings - { -public: - }; - -class CLoadGenModel : public CActive - { -private: - enum TContainerDrawState - { - EDrawStateInvalid = -1, - EDrawStateMain - }; - -public: - static CLoadGenModel* NewL(); - ~CLoadGenModel(); - void ActivateModelL(); - void DeActivateModelL(); - -private: - void RunL(); - void DoCancel(); - -private: - CLoadGenModel(); - void ConstructL(); - void LoadSettingsL(); - void EditLoadL(CLoadBase* aItem); - void DoStartNewLoadL(TInt aCommand); - void AppendToLoadItemListL(CLoadBase* aItem); - void DeleteFromLoadItemListL(TInt aIndex); - void SuspendOrResumeFromLoadItemListL(TInt aIndex); - void DeleteAllLoadItems(); - void RefreshViewL(TBool aClearSelection=ETrue); - CDesCArray* ListOfAllAppsL(); - -public: - void StopAllLoadItemsL(); - void SuspendAllLoadItemsL(); - void ResumeAllLoadItemsL(); - - TInt LoadItemCount() const; - void ShowItemActionMenuL(); - void StopSelectedOrHighlightedItemsL(); - void SuspendOrResumeSelectedOrHighlightedItemsL(); - - CDesCArray* GenerateListBoxItemTextArrayL(); - void StartNewLoadL(TInt aCommand); - void SaveSettingsL(); - void SetMainContainer(CLoadGenMainContainer* aContainer); - TInt LaunchSettingsDialogL(); - inline TLoadGenSettings& Settings() { return iSettings; } - inline CEikonEnv* EikonEnv() { return iEnv; } - inline RApaLsSession& LsSession() { return iLs; } - inline CLoadGenMainContainer* MainContainer() { return iMainContainer; } - inline TBool LoadItemsExists() { return iLoadItemList->Count() > 0; } - - -private: - RTimer iTimer; - CLoadGenMainContainer* iMainContainer; - CEikonEnv* iEnv; - TLoadGenSettings iSettings; - RApaLsSession iLs; - TInt iDrawState; - CLoadItemList* iLoadItemList; - TInt iReferenceNumber; - TCPULoadAttributes iCpuLoadAttributes; - TMemoryEatAttributes iMemoryEatAttributes; - TPhoneCallAttributes iPhoneCallAttributes; - TNetConnAttributes iNetConnAttributes; - TKeyPressAttributes iKeyPressAttributes; - TMessageAttributes iMessageAttributes; - TApplicationsAttributes iApplicationsAttributes; - TPhotoCaptureAttributes iPhotoCaptureAttributes; - TBluetoothAttributes iBluetoothAttributes; - TPointerEventAttributes iPointerEventAttributes; - static TInt64 iRandomNumberSeed; - }; - - -#endif diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/ui/avkon/inc/loadgen_settingsviewdlg.h --- a/loadgen/ui/avkon/inc/loadgen_settingsviewdlg.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,82 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#ifndef LOADGEN_SETTINGSVIEWDLG_H -#define LOADGEN_SETTINGSVIEWDLG_H - -// INCLUDES -#include -#include -#include -#include - -// FORWARD DECLARATIONS -class CAknSettingItemArray; -class CAknSettingStyleListBox; -class CAknNavigationControlContainer; -class CAknNavigationDecorator; -class CAknTabGroup; -class TLoadGenSettings; - - -// CLASS DEFINITIONS - -class CLoadGenSettingsViewDlg : public CAknDialog, public MEikListBoxObserver, public MAknTabObserver - { -public: - static CLoadGenSettingsViewDlg* NewL(TLoadGenSettings& aSettings); - virtual ~CLoadGenSettingsViewDlg(); - -public: // From MEikListBoxObserver - void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType); - -public: // From MAknTabObserver - void TabChangedL(TInt aIndex); - -public: // From CAknDialog - void ProcessCommandL(TInt aCommandId); - -protected: // From CEikDialog - TKeyResponse OfferKeyEventL(const TKeyEvent &aKeyEvent, TEventCode aType); - void PreLayoutDynInitL(); - TBool OkToExitL(TInt aButtonId); - -private: // New methods - void ShowSettingPageL(TBool aCalledFromMenu); - void SetVisibilitiesOfSettingItemsL(); - void UpdateListBoxL(); - void AddSettingItemL(TInt aId, TInt aTitleResource, TInt aSettingPageResource, TInt aAssociatedResource, TInt aOrdinal); - -private: // Constructors - CLoadGenSettingsViewDlg(TLoadGenSettings& aSettings); - void ConstructL(); - -private: // Data - CAknSettingItemArray* iSettingItemArray; - CAknSettingStyleListBox* iListBox; - CAknNavigationControlContainer* iNaviContainer; - CAknNavigationDecorator* iDecoratedTabGroup; - CAknTabGroup* iTabGroup; - TLoadGenSettings& iSettings; - }; - - -#endif - -// End of File - diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/ui/avkon/rom/loadgen.iby --- a/loadgen/ui/avkon/rom/loadgen.iby Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#ifndef __LOADGEN_IBY__ -#define __LOADGEN_IBY__ - -S60_APP_EXE(LoadGen) -S60_APP_AIF_ICONS(LoadGen) -S60_APP_RESOURCE(LoadGen) -SCALABLE_IMAGE(APP_BITMAP_DIR,APP_BITMAP_DIR,LoadGen_ExtraIcons) -#ifdef S60_UPGRADABLE_APP_REG_RSC - S60_UPGRADABLE_APP_REG_RSC(LoadGen) -#else - S60_APP_AIF_RSC(LoadGen) -#endif - -data=ZPRIVATE\20011384\backup_registration.xml private\20011384\backup_registration.xml -data=ZSYSTEM\Install\LoadGen_stub.sis \system\install\LoadGen_stub.sis - -#endif // __LOADGEN_IBY__ diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/ui/avkon/src/loadgen_app.cpp --- a/loadgen/ui/avkon/src/loadgen_app.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,73 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -// INCLUDE FILES -#include "loadgen_app.h" -#include "loadgen_document.h" - -#include - - -// ================= MEMBER FUNCTIONS ======================= - -// --------------------------------------------------------- -// CLoadGenApp::AppDllUid() -// Returns application UID -// --------------------------------------------------------- -// -TUid CLoadGenApp::AppDllUid() const - { - return KUidLoadGen; - } - -// --------------------------------------------------------- -// CDictionaryStore* CLoadGenApp::OpenIniFileLC(RFs& aFs) const -// overrides CAknApplication::OpenIniFileLC to enable INI file support -// --------------------------------------------------------- -// -CDictionaryStore* CLoadGenApp::OpenIniFileLC(RFs& aFs) const - { - return CEikApplication::OpenIniFileLC(aFs); - } - -// --------------------------------------------------------- -// CLoadGenApp::CreateDocumentL() -// Creates CLoadGenDocument object -// --------------------------------------------------------- -// -CApaDocument* CLoadGenApp::CreateDocumentL() - { - return CLoadGenDocument::NewL( *this ); - } - -// ================= OTHER EXPORTED FUNCTIONS ============== - -LOCAL_C CApaApplication* NewApplication() - { - return new CLoadGenApp; - } - - -GLDEF_C TInt E32Main() - { - return EikStart::RunApplication(NewApplication); - } - - -// End of File - diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/ui/avkon/src/loadgen_appui.cpp --- a/loadgen/ui/avkon/src/loadgen_appui.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,158 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -// INCLUDE FILES -#include "loadgen_appui.h" -#include "loadgen_mainview.h" -#include "loadgen.hrh" -#include "loadgen_model.h" -#include "loadgen_document.h" -#include - -#include -#include -#include - - -// ================= MEMBER FUNCTIONS ======================= - -void CLoadGenAppUi::ConstructL() - { - // disable window server priority control for this application - iEikonEnv->WsSession().ComputeMode( RWsSession::EPriorityControlDisabled ); - - // set as system application to prevent getting shut down events - iEikonEnv->SetSystem(ETrue); - - - BaseConstructL(EAknEnableSkin); - - iModel = static_cast(reinterpret_cast(iEikonEnv->AppUi())->Document())->Model(); - - CLoadGenMainView* mainView = new(ELeave) CLoadGenMainView; - CleanupStack::PushL(mainView); - mainView->ConstructL(); - AddViewL(mainView); // transfer ownership to CAknViewAppUi - CleanupStack::Pop(); // mainView - - SetDefaultViewL(*mainView); - - // notify the model that everything has been constructed - iModel->ActivateModelL(); - } - -// -------------------------------------------------------------------------------------------- - -CLoadGenAppUi::~CLoadGenAppUi() - { - // notify the model that the application is closing - if (iModel) - TRAP_IGNORE(iModel->DeActivateModelL()); - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenAppUi::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane) - { - if (aResourceId == R_LOADGEN_APP_MENU) - { - aMenuPane->SetItemDimmed(ELoadGenStopAll, !iModel->LoadItemsExists()); - aMenuPane->SetItemDimmed(ELoadGenSuspendAll, !iModel->LoadItemsExists()); - aMenuPane->SetItemDimmed(ELoadGenResumeAll, !iModel->LoadItemsExists()); - } - } - -// -------------------------------------------------------------------------------------------- - -TKeyResponse CLoadGenAppUi::HandleKeyEventL(const TKeyEvent& /*aKeyEvent*/, TEventCode /*aType*/) - { - return EKeyWasNotConsumed; - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenAppUi::HandleCommandL(TInt aCommand) - { - switch ( aCommand ) - { - case ELoadGenCmdLaunchPerfMon: - { - // launch Performance Monitor - const TUid KUidPerfMon = { 0x20011385 }; - - RWsSession ws; - User::LeaveIfError( ws.Connect() ); - CleanupClosePushL(ws); - - RApaLsSession ls; - User::LeaveIfError( ls.Connect() ); - CleanupClosePushL(ls); - - - // try to find the task of PerfMon - TApaTaskList tasklist(ws); - TApaTask task = tasklist.FindApp(KUidPerfMon); - - if (task.Exists()) - { - // task exists, bring it to foreground - task.BringToForeground(); - } - else - { - TApaAppInfo appInfo; - User::LeaveIfError(ls.GetAppInfo(appInfo, KUidPerfMon)); - - CApaCommandLine* cmdLine = CApaCommandLine::NewLC(); - cmdLine->SetExecutableNameL(appInfo.iFullName); - cmdLine->SetCommandL(EApaCommandBackground); - - // start the app - User::LeaveIfError(ls.StartApp(*cmdLine)); - - CleanupStack::PopAndDestroy(); //cmdLine - } - - CleanupStack::PopAndDestroy(2); //ws,ls - } - break; - - case ELoadGenCmdAbout: - { - CAknMessageQueryDialog* dialog = new(ELeave) CAknMessageQueryDialog; - dialog->ExecuteLD(R_LOADGEN_ABOUT_DIALOG); - } - break; - - // a normal way to close an application - case EAknCmdExit: - case EEikCmdExit: - case EAknSoftkeyExit: - { - Exit(); - } - break; - - default: - break; - } - } - -// -------------------------------------------------------------------------------------------- - -// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/ui/avkon/src/loadgen_document.cpp --- a/loadgen/ui/avkon/src/loadgen_document.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,83 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -// INCLUDE FILES -#include "loadgen_document.h" -#include "loadgen_appui.h" -#include "loadgen_model.h" - -// ================= MEMBER FUNCTIONS ======================= - -// constructor -CLoadGenDocument::CLoadGenDocument(CEikApplication& aApp) -: CAknDocument(aApp) - { - } - -// ---------------------------------------------------- - -// destructor -CLoadGenDocument::~CLoadGenDocument() - { - delete iModel; - } - -// ---------------------------------------------------- - -// EPOC default constructor can leave. -void CLoadGenDocument::ConstructL() - { - iModel = CLoadGenModel::NewL(); - } - -// ---------------------------------------------------- - -// Two-phased constructor. -CLoadGenDocument* CLoadGenDocument::NewL(CEikApplication& aApp) - { - CLoadGenDocument* self = new(ELeave) CLoadGenDocument(aApp); - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(); - - return self; - } - -// ---------------------------------------------------- -// CLoadGenDocument::CreateAppUiL() -// constructs CLoadGenAppUi -// ---------------------------------------------------- -// -CEikAppUi* CLoadGenDocument::CreateAppUiL() - { - return new (ELeave) CLoadGenAppUi; - } - -// ---------------------------------------------------- -// CLoadGenDocument::OpenFileL -// Overrides CAknDocument::OpenFileL to support document file -// ---------------------------------------------------- -// -CFileStore* CLoadGenDocument::OpenFileL(TBool aDoOpen,const TDesC& aFilename,RFs& aFs) - { - return CEikDocument::OpenFileL(aDoOpen, aFilename, aFs); - } - -// ---------------------------------------------------- - -// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/ui/avkon/src/loadgen_editors.cpp --- a/loadgen/ui/avkon/src/loadgen_editors.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1437 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -// INCLUDE FILES -#include "loadgen_editors.h" -#include "loadgen_loadattributes.h" -#include "loadgen.hrh" -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// ===================================== MEMBER FUNCTIONS ===================================== - -// -------------------------------------------------------------------------------------------- - -CLoadGenLoadTypeEditorBase::CLoadGenLoadTypeEditorBase(TBool aEditingExisting): - iEditingExisting(aEditingExisting) - { - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenLoadTypeEditorBase::ConstructL(const TDesC& aTitleText) - { - CAknForm::ConstructL(); - - // set title text - CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane(); - CAknTitlePane* tp = static_cast( sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); - tp->SetTextL( aTitleText ); - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenLoadTypeEditorBase::PreLayoutDynInitL() - { - CAknForm::PreLayoutDynInitL(); - } - -// -------------------------------------------------------------------------------------------- - -TBool CLoadGenLoadTypeEditorBase::OkToExitL(TInt /*aButtonId*/) - { - return ETrue; - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenLoadTypeEditorBase::HandleControlStateChangeL(TInt aControlId) - { - CAknForm::HandleControlStateChangeL(aControlId); - } - -// -------------------------------------------------------------------------------------------- - -TBool CLoadGenLoadTypeEditorBase::RunQueryLD() - { - User::Panic(_L("Unk.form"), 222); - - return ETrue; - } - -// -------------------------------------------------------------------------------------------- - -TBool CLoadGenLoadTypeEditorBase::DoRunQueryLD(TInt aResource) - { - return ExecuteLD(aResource); - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenLoadTypeEditorBase::InsertFieldAfterL(TInt aResourceId, TInt aControlId, TInt aPrevControlId) - { - CCoeControl* prevControl = Control(aPrevControlId); - __ASSERT_DEBUG(prevControl, User::Panic(_L("Form.Ctrl.Null"), 111)); - TInt pos = FindLineIndex(*prevControl); - pos = pos + 1; - InsertLineL(pos, aResourceId); - Line(aControlId)->ActivateL(); - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenLoadTypeEditorBase::UpdateFormL() - { - UpdatePageL(ETrue); - } - -// -------------------------------------------------------------------------------------------- -// -------------------------------------------------------------------------------------------- - -CLoadGenCPULoadEditor* CLoadGenCPULoadEditor::NewL(TCPULoadAttributes& aAttributes, TBool aEditingExisting) - { - CLoadGenCPULoadEditor* self = new(ELeave) CLoadGenCPULoadEditor(aAttributes, aEditingExisting); - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(self); - return self; - } - -// -------------------------------------------------------------------------------------------- - -CLoadGenCPULoadEditor::~CLoadGenCPULoadEditor() - { - delete iCpuQueryValText; - delete iCpuTextArray; - delete iCPUsArray; - } - -// -------------------------------------------------------------------------------------------- - -CLoadGenCPULoadEditor::CLoadGenCPULoadEditor(TCPULoadAttributes& aAttributes, TBool aEditingExisting) : - CLoadGenLoadTypeEditorBase(aEditingExisting), iAttributes(aAttributes) - { - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenCPULoadEditor::ConstructL() - { - CLoadGenLoadTypeEditorBase::ConstructL(_L("CPU load")); - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenCPULoadEditor::PreLayoutDynInitL() - { - CLoadGenLoadTypeEditorBase::PreLayoutDynInitL(); - - // load values to static editors - CAknPopupFieldText* edPriority = static_cast(Control(ELoadGenCPULoadQueryPriority)); - CAknPopupFieldText* edMode = static_cast(Control(ELoadGenCPULoadQueryMode)); - CAknPopupFieldText* edType = static_cast(Control(ELoadGenCPULoadQueryType)); - edPriority->SetCurrentValueIndex(iAttributes.iPriority); - edMode->SetCurrentValueIndex(iAttributes.iMode); - edType->SetCurrentValueIndex(iAttributes.iType); - - LoadCPUsL(); - - UpdateVisibilitiesOfFieldsL(ETrue); - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenCPULoadEditor::LoadCPUsL() - { - // if we are running in SMP environment - if (iAttributes.iCpuCount > 1) - { - // insert possibility to select which cpu the load is generated to - InsertFieldAfterL(R_CPULOAD_DLG_LINE_CPU, ELoadGenCPULoadQueryCpu, ELoadGenCPULoadQueryType); - - iCPUsArray = new (ELeave) CDesCArrayFlat( 5 ); - - // "Free scheduling" means that no specific cpu is selected. Scheduler desides - // which CPUu runs load thread at which time. - iCPUsArray->AppendL(_L("Free scheduling")); - - // add CPUs - for (int i = 0; i < iAttributes.iCpuCount; i++) - { - TBuf<10> cpu; - _LIT(KCPU, "CPU%d"); - cpu.Format(KCPU, i); - iCPUsArray->AppendL(cpu); - } - - // "All CPUs" means that one thread is started for each CPU. - iCPUsArray->AppendL(_L("All CPUs")); - - iCpuTextArray = CAknQueryValueTextArray::NewL(); - iCpuTextArray->SetArray( *iCPUsArray ); - iCpuQueryValText = CAknQueryValueText::NewL(); - iCpuQueryValText->SetArrayL( iCpuTextArray ); - // CPU is not defined, set "Free scheduling" as default selection in query list - if (iAttributes.iCpu < 0) - { - iCpuQueryValText->SetCurrentValueIndex(0); - } - // "All CPUs" selected. It is last choise in the selection list. - else if (iAttributes.iCpu == KCPUSelection_AllCPUs) - { - iCpuQueryValText->SetCurrentValueIndex(iCpuTextArray->MdcaCount()-1); - } - // CPU is defined, set the correct CPU as default selection in query list - else - { - // iCpu starts from zero (i.e. CPU0 is first CPU), but index zero - // in iCpuQueryValText is "Free scheduling", hence iCpu+1. - iCpuQueryValText->SetCurrentValueIndex(iAttributes.iCpu+1); - } - - CAknPopupField* popup = static_cast(Control( ELoadGenCPULoadQueryCpu)); - popup->SetQueryValueL( iCpuQueryValText ); - } - } - -// -------------------------------------------------------------------------------------------- - -TBool CLoadGenCPULoadEditor::OkToExitL(TInt aButtonId) - { - if (aButtonId == EAknSoftkeyOk) - { - // store values from editors - CAknPopupFieldText* edPriority = static_cast(Control(ELoadGenCPULoadQueryPriority)); - CAknPopupFieldText* edMode = static_cast(Control(ELoadGenCPULoadQueryMode)); - CAknPopupFieldText* edType = static_cast(Control(ELoadGenCPULoadQueryType)); - CEikNumberEditor* edPeak = static_cast(ControlOrNull(ELoadGenCPULoadQueryLength)); - CEikNumberEditor* edIdle = static_cast(ControlOrNull(ELoadGenCPULoadQueryIdle)); - CEikNumberEditor* edVariance = static_cast(ControlOrNull(ELoadGenCPULoadQueryVariance)); - - // we are running in SMP environment - if (iAttributes.iCpuCount > 1) - { - TInt currentValueIndex = iCpuQueryValText->CurrentValueIndex(); - // user selected a specific CPU in which the load thread should be run in. - if (currentValueIndex == 0) - { - // User selected "Free scheduling" - iAttributes.iCpu = KCPUSelection_FreeScheduling; - } - else if( currentValueIndex == iCpuTextArray->MdcaCount()-1 ) - { - // User selected "All CPUs", which is the last item in the selection list - iAttributes.iCpu = KCPUSelection_AllCPUs; - } - else - { - // iCpu should start from zero (CPU0 is the first cpu) - // but zero in currentValueIndex means "Free scheduling". CPU0 in - // currentValueIndex is at index 1, hence -1. - iAttributes.iCpu = currentValueIndex - 1; - } - } - - iAttributes.iPriority = edPriority->CurrentValueIndex(); - iAttributes.iMode = edMode->CurrentValueIndex(); - iAttributes.iType = edType->CurrentValueIndex(); - if (edPeak) iAttributes.iLength = edPeak->Number(); - if (edIdle) iAttributes.iIdle = edIdle->Number(); - if (edVariance) iAttributes.iRandomVariance = edVariance->Number(); - } - - return ETrue; - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenCPULoadEditor::UpdateVisibilitiesOfFieldsL(TBool aFormInit) - { - // filter based on selected cpu load type - CAknPopupFieldText* edType = static_cast( Control( ELoadGenCPULoadQueryType ) ); - - if ( !aFormInit && edType->CurrentValueIndex() == ECpuLoadTypeContinuous ) - { - // save values before deleting the items - CCoeControl* control = ControlOrNull( ELoadGenCPULoadQueryLength ); - if ( control ) - { - CEikNumberEditor* edPeak = static_cast( control ); - iAttributes.iLength = edPeak->Number(); - DeleteLine( ELoadGenCPULoadQueryLength ); - control = NULL; - } - control = ControlOrNull( ELoadGenCPULoadQueryIdle ); - if ( control ) - { - CEikNumberEditor* edIdle = static_cast( control ); - iAttributes.iIdle = edIdle->Number(); - DeleteLine( ELoadGenCPULoadQueryIdle ); - control = NULL; - } - control = ControlOrNull( ELoadGenCPULoadQueryVariance ); - if ( control ) - { - CEikNumberEditor* edVariance = static_cast( control ); - iAttributes.iRandomVariance = edVariance->Number(); - DeleteLine( ELoadGenCPULoadQueryVariance ); - } - } - else if ( edType->CurrentValueIndex() == ECpuLoadTypePeriodic ) - { - // insert new fields - InsertFieldAfterL(R_CPULOAD_DLG_LINE_PERIODIC_LENGTH, ELoadGenCPULoadQueryLength, ELoadGenCPULoadQueryType); - InsertFieldAfterL(R_CPULOAD_DLG_LINE_PERIODIC_IDLE, ELoadGenCPULoadQueryIdle, ELoadGenCPULoadQueryLength); - InsertFieldAfterL(R_CPULOAD_DLG_LINE_PERIODIC_VARIANCE, ELoadGenCPULoadQueryVariance, ELoadGenCPULoadQueryIdle); - - // load values to just created editors - CEikNumberEditor* edPeak = static_cast(Control(ELoadGenCPULoadQueryLength)); - CEikNumberEditor* edIdle = static_cast(Control(ELoadGenCPULoadQueryIdle)); - CEikNumberEditor* edVariance = static_cast(Control(ELoadGenCPULoadQueryVariance)); - edPeak->SetNumber(iAttributes.iLength); - edIdle->SetNumber(iAttributes.iIdle); - edVariance->SetNumber(iAttributes.iRandomVariance); - } - - UpdateFormL(); - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenCPULoadEditor::HandleControlStateChangeL(TInt aControlId) - { - CLoadGenLoadTypeEditorBase::HandleControlStateChangeL(aControlId); - - // update visibilities of fields - if (aControlId == ELoadGenCPULoadQueryType) - { - UpdateVisibilitiesOfFieldsL(); - } - } - -// -------------------------------------------------------------------------------------------- - -TBool CLoadGenCPULoadEditor::RunQueryLD() - { - return CLoadGenLoadTypeEditorBase::DoRunQueryLD(R_CPULOAD_FORM_DIALOG); - } - -// -------------------------------------------------------------------------------------------- -// -------------------------------------------------------------------------------------------- - -CLoadGenMemoryEatEditor* CLoadGenMemoryEatEditor::NewL(TMemoryEatAttributes& aAttributes, TBool aEditingExisting) - { - CLoadGenMemoryEatEditor* self = new(ELeave) CLoadGenMemoryEatEditor(aAttributes, aEditingExisting); - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(self); - return self; - } - -// -------------------------------------------------------------------------------------------- - -CLoadGenMemoryEatEditor::~CLoadGenMemoryEatEditor() - { - } - -// -------------------------------------------------------------------------------------------- - -CLoadGenMemoryEatEditor::CLoadGenMemoryEatEditor(TMemoryEatAttributes& aAttributes, TBool aEditingExisting) : - CLoadGenLoadTypeEditorBase(aEditingExisting), iAttributes(aAttributes) - { - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenMemoryEatEditor::ConstructL() - { - CLoadGenLoadTypeEditorBase::ConstructL(_L("Memory eat")); - - // convert int64 vals to descs - iAttributes.iAmountDes.Copy(KNullDesC); - iAttributes.iRandomMinDes.Copy(KNullDesC); - iAttributes.iRandomMaxDes.Copy(KNullDesC); - - iAttributes.iAmountDes.AppendNum(iAttributes.iAmount); - iAttributes.iRandomMinDes.AppendNum(iAttributes.iRandomMin); - iAttributes.iRandomMaxDes.AppendNum(iAttributes.iRandomMax); - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenMemoryEatEditor::PreLayoutDynInitL() - { - CLoadGenLoadTypeEditorBase::PreLayoutDynInitL(); - - // load values to static editors - CAknPopupFieldText* edPriority = static_cast(Control(ELoadGenMemoryEatQueryPriority)); - CAknPopupFieldText* edSource = static_cast(Control(ELoadGenMemoryEatQuerySource)); - CAknPopupFieldText* edType = static_cast(Control(ELoadGenMemoryEatQueryType)); - CEikNumberEditor* edBuffer = static_cast(Control(ELoadGenMemoryEatQueryBuffer)); - CEikNumberEditor* edIdle = static_cast(Control(ELoadGenMemoryEatQueryIdle)); - CEikNumberEditor* edVariance = static_cast(Control(ELoadGenMemoryEatQueryVariance)); - - edPriority->SetCurrentValueIndex(iAttributes.iPriority); - edSource->SetCurrentValueIndex(iAttributes.iSource); - edType->SetCurrentValueIndex(iAttributes.iType); - edBuffer->SetNumber(iAttributes.iBuffer); - edIdle->SetNumber(iAttributes.iIdle); - edVariance->SetNumber(iAttributes.iRandomVariance); - - UpdateVisibilitiesOfFieldsL(ETrue); - UpdateAvailableMemoryL(); - - // set source as dimmed if editing existing item - if (iEditingExisting) - { - SetLineDimmedNow(ELoadGenMemoryEatQuerySource, ETrue); - } - } - -// -------------------------------------------------------------------------------------------- - -TBool CLoadGenMemoryEatEditor::OkToExitL(TInt aButtonId) - { - if (aButtonId == EAknSoftkeyOk) - { - // store values from editors - CAknPopupFieldText* edPriority = static_cast(Control(ELoadGenMemoryEatQueryPriority)); - CAknPopupFieldText* edSource = static_cast(Control(ELoadGenMemoryEatQuerySource)); - CAknPopupFieldText* edType = static_cast(Control(ELoadGenMemoryEatQueryType)); - CEikNumberEditor* edBuffer = static_cast(Control(ELoadGenMemoryEatQueryBuffer)); - CEikNumberEditor* edIdle = static_cast(Control(ELoadGenMemoryEatQueryIdle)); - CEikNumberEditor* edVariance = static_cast(Control(ELoadGenMemoryEatQueryVariance)); - - iAttributes.iPriority = edPriority->CurrentValueIndex(); - iAttributes.iSource = edSource->CurrentValueIndex(); - iAttributes.iType = edType->CurrentValueIndex(); - iAttributes.iBuffer = edBuffer->Number(); - iAttributes.iIdle = edIdle->Number(); - iAttributes.iRandomVariance = edVariance->Number(); - - - CEikEdwin* edAmount = static_cast(ControlOrNull(ELoadGenMemoryEatQueryAmount)); - CEikEdwin* edRandomMin = static_cast(ControlOrNull(ELoadGenMemoryEatQueryRandomMin)); - CEikEdwin* edRandomMax = static_cast(ControlOrNull(ELoadGenMemoryEatQueryRandomMax)); - - // get desc values and convert to int64 - if (edAmount) - { - edAmount->GetText(iAttributes.iAmountDes); - - TLex converter; - converter.Assign(iAttributes.iAmountDes); - User::LeaveIfError(converter.Val(iAttributes.iAmount)); - } - - if (edRandomMin) - { - edRandomMin->GetText(iAttributes.iRandomMinDes); - - TLex converter; - converter.Assign(iAttributes.iRandomMinDes); - User::LeaveIfError(converter.Val(iAttributes.iRandomMin)); - } - - if (edRandomMax) - { - edRandomMax->GetText(iAttributes.iRandomMaxDes); - - TLex converter; - converter.Assign(iAttributes.iRandomMaxDes); - User::LeaveIfError(converter.Val(iAttributes.iRandomMax)); - - // swap min max values if they in wrong order - if (iAttributes.iRandomMin > iAttributes.iRandomMax) - { - TInt64 temp(iAttributes.iRandomMin); - iAttributes.iRandomMin = iAttributes.iRandomMax; - iAttributes.iRandomMax = temp; - } - - } - } - - return ETrue; - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenMemoryEatEditor::UpdateVisibilitiesOfFieldsL(TBool aFormInit) - { - // filter based on selected memory eat type - CAknPopupFieldText* edType = static_cast(Control(ELoadGenMemoryEatQueryType)); - - if (!aFormInit && (edType->CurrentValueIndex() == EMemoryEatTypeMemoryToEat || edType->CurrentValueIndex() == EMemoryEatTypeMemoryToBeLeft)) - { - // no need for changes if amount field is already active - CEikNumberEditor* edAmount = static_cast(ControlOrNull(ELoadGenMemoryEatQueryAmount)); - if (edAmount) return; - - // save values before deleting the items - CEikEdwin* edRandomMin = static_cast(Control(ELoadGenMemoryEatQueryRandomMin)); - CEikEdwin* edRandomMax = static_cast(Control(ELoadGenMemoryEatQueryRandomMax)); - edRandomMin->GetText(iAttributes.iRandomMinDes); - edRandomMax->GetText(iAttributes.iRandomMaxDes); - - DeleteLine(ELoadGenMemoryEatQueryRandomMin); - DeleteLine(ELoadGenMemoryEatQueryRandomMax); - } - else if (!aFormInit && edType->CurrentValueIndex() == EMemoryEatTypeWavy) - { - // save values before deleting the items - CEikEdwin* edAmount = static_cast(Control(ELoadGenMemoryEatQueryAmount)); - edAmount->GetText(iAttributes.iAmountDes); - - DeleteLine(ELoadGenMemoryEatQueryAmount); - } - - if (edType->CurrentValueIndex() == EMemoryEatTypeMemoryToEat || edType->CurrentValueIndex() == EMemoryEatTypeMemoryToBeLeft) - { - // insert new fields - InsertFieldAfterL(R_MEMORYEAT_DLG_LINE_AMOUNT, ELoadGenMemoryEatQueryAmount, ELoadGenMemoryEatQueryType); - - // load values to just created editors - CEikEdwin* edAmount = static_cast(Control(ELoadGenMemoryEatQueryAmount)); - edAmount->SetTextL(&iAttributes.iAmountDes); - } - else if (edType->CurrentValueIndex() == EMemoryEatTypeWavy) - { - // insert new fields - InsertFieldAfterL(R_MEMORYEAT_DLG_LINE_RANDOM_MIN, ELoadGenMemoryEatQueryRandomMin, ELoadGenMemoryEatQueryType); - InsertFieldAfterL(R_MEMORYEAT_DLG_LINE_RANDOM_MAX, ELoadGenMemoryEatQueryRandomMax, ELoadGenMemoryEatQueryRandomMin); - - // load values to just created editors - CEikEdwin* edRandomMin = static_cast(Control(ELoadGenMemoryEatQueryRandomMin)); - CEikEdwin* edRandomMax = static_cast(Control(ELoadGenMemoryEatQueryRandomMax)); - edRandomMin->SetTextL(&iAttributes.iRandomMinDes); - edRandomMax->SetTextL(&iAttributes.iRandomMaxDes); - } - - UpdateFormL(); - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenMemoryEatEditor::UpdateAvailableMemoryL() - { - // this feature is used only when not editing existing load - if (!iEditingExisting) - { - CAknPopupFieldText* edSource = static_cast(ControlOrNull(ELoadGenMemoryEatQuerySource)); - CEikEdwin* edAmount = static_cast(ControlOrNull(ELoadGenMemoryEatQueryAmount)); - - if (edAmount && edSource) - { - iAttributes.iAmountDes.Copy(KNullDesC); - - if (edSource->CurrentValueIndex() == EMemoryEatSourceTypeRAM) - { - // RAM - TMemoryInfoV1Buf ramMemory; - UserHal::MemoryInfo(ramMemory); - - iAttributes.iAmountDes.AppendNum(ramMemory().iFreeRamInBytes); - } - else - { - // get drive - TVolumeInfo volumeInfo; - if (CEikonEnv::Static()->FsSession().Volume(volumeInfo, edSource->CurrentValueIndex()+1) == KErrNone) - { - iAttributes.iAmountDes.AppendNum(volumeInfo.iFree); - } - else - { - iAttributes.iAmountDes.AppendNum(0); - } - } - - edAmount->SetTextL(&iAttributes.iAmountDes); - } - } - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenMemoryEatEditor::HandleControlStateChangeL(TInt aControlId) - { - CLoadGenLoadTypeEditorBase::HandleControlStateChangeL(aControlId); - - // update visibilities of fields - if (aControlId == ELoadGenMemoryEatQueryType) - { - UpdateVisibilitiesOfFieldsL(); - } - - // update memory when source changes - else if (aControlId == ELoadGenMemoryEatQuerySource) - { - UpdateAvailableMemoryL(); - } - } - -// -------------------------------------------------------------------------------------------- - -TBool CLoadGenMemoryEatEditor::RunQueryLD() - { - return CLoadGenLoadTypeEditorBase::DoRunQueryLD(R_MEMORYEAT_FORM_DIALOG); - } - - -// -------------------------------------------------------------------------------------------- -// -------------------------------------------------------------------------------------------- - -CLoadGenPhoneCallEditor* CLoadGenPhoneCallEditor::NewL(TPhoneCallAttributes& aAttributes, TBool aEditingExisting) - { - CLoadGenPhoneCallEditor* self = new(ELeave) CLoadGenPhoneCallEditor(aAttributes, aEditingExisting); - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(self); - return self; - } - -// -------------------------------------------------------------------------------------------- - -CLoadGenPhoneCallEditor::~CLoadGenPhoneCallEditor() - { - } - -// -------------------------------------------------------------------------------------------- - -CLoadGenPhoneCallEditor::CLoadGenPhoneCallEditor(TPhoneCallAttributes& aAttributes, TBool aEditingExisting) : - CLoadGenLoadTypeEditorBase(aEditingExisting), iAttributes(aAttributes) - { - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenPhoneCallEditor::ConstructL() - { - CLoadGenLoadTypeEditorBase::ConstructL(_L("Phone calls")); - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenPhoneCallEditor::PreLayoutDynInitL() - { - CLoadGenLoadTypeEditorBase::PreLayoutDynInitL(); - - // load values to static editors - CAknPopupFieldText* edPriority = static_cast(Control(ELoadGenPhoneCallQueryPriority)); - CEikEdwin* edDestination = static_cast(Control(ELoadGenPhoneCallQueryDestination)); - CEikNumberEditor* edLength = static_cast(Control(ELoadGenPhoneCallQueryLength)); - CEikNumberEditor* edIdle = static_cast(Control(ELoadGenPhoneCallQueryIdle)); - CEikNumberEditor* edVariance = static_cast(Control(ELoadGenPhoneCallQueryVariance)); - - edPriority->SetCurrentValueIndex(iAttributes.iPriority); - edDestination->SetTextL(&iAttributes.iDestination); - edLength->SetNumber(iAttributes.iLength); - edIdle->SetNumber(iAttributes.iIdle); - edVariance->SetNumber(iAttributes.iRandomVariance); - - UpdateVisibilitiesOfFieldsL(ETrue); - } - -// -------------------------------------------------------------------------------------------- - -TBool CLoadGenPhoneCallEditor::OkToExitL(TInt aButtonId) - { - if (aButtonId == EAknSoftkeyOk) - { - // store values from editors - CAknPopupFieldText* edPriority = static_cast(Control(ELoadGenPhoneCallQueryPriority)); - CEikEdwin* edDestination = static_cast(Control(ELoadGenPhoneCallQueryDestination)); - CEikNumberEditor* edLength = static_cast(Control(ELoadGenPhoneCallQueryLength)); - CEikNumberEditor* edIdle = static_cast(Control(ELoadGenPhoneCallQueryIdle)); - CEikNumberEditor* edVariance = static_cast(Control(ELoadGenPhoneCallQueryVariance)); - - iAttributes.iPriority = edPriority->CurrentValueIndex(); - edDestination->GetText(iAttributes.iDestination); - iAttributes.iLength = edLength->Number(); - iAttributes.iIdle = edIdle->Number(); - iAttributes.iRandomVariance = edVariance->Number(); - } - - return ETrue; - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenPhoneCallEditor::UpdateVisibilitiesOfFieldsL(TBool /*aFormInit*/) - { - UpdateFormL(); - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenPhoneCallEditor::HandleControlStateChangeL(TInt aControlId) - { - CLoadGenLoadTypeEditorBase::HandleControlStateChangeL(aControlId); - } - -// -------------------------------------------------------------------------------------------- - -TBool CLoadGenPhoneCallEditor::RunQueryLD() - { - return CLoadGenLoadTypeEditorBase::DoRunQueryLD(R_PHONECALL_FORM_DIALOG); - } - -// -------------------------------------------------------------------------------------------- -// -------------------------------------------------------------------------------------------- - -CLoadGenNetConnEditor* CLoadGenNetConnEditor::NewL(TNetConnAttributes& aAttributes, TBool aEditingExisting) - { - CLoadGenNetConnEditor* self = new(ELeave) CLoadGenNetConnEditor(aAttributes, aEditingExisting); - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(self); - return self; - } - -// -------------------------------------------------------------------------------------------- - -CLoadGenNetConnEditor::~CLoadGenNetConnEditor() - { - } - -// -------------------------------------------------------------------------------------------- - -CLoadGenNetConnEditor::CLoadGenNetConnEditor(TNetConnAttributes& aAttributes, TBool aEditingExisting) : - CLoadGenLoadTypeEditorBase(aEditingExisting), iAttributes(aAttributes) - { - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenNetConnEditor::ConstructL() - { - CLoadGenLoadTypeEditorBase::ConstructL(_L("Network conn.")); - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenNetConnEditor::PreLayoutDynInitL() - { - CLoadGenLoadTypeEditorBase::PreLayoutDynInitL(); - - // load values to static editors - CAknPopupFieldText* edPriority = static_cast(Control(ELoadGenNetConnQueryPriority)); - CEikEdwin* edDestination = static_cast(Control(ELoadGenNetConnQueryDestination)); - CEikNumberEditor* edIdle = static_cast(Control(ELoadGenNetConnQueryIdle)); - CEikNumberEditor* edVariance = static_cast(Control(ELoadGenNetConnQueryVariance)); - - edPriority->SetCurrentValueIndex(iAttributes.iPriority); - edDestination->SetTextL(&iAttributes.iDestination); - edIdle->SetNumber(iAttributes.iIdle); - edVariance->SetNumber(iAttributes.iRandomVariance); - - UpdateVisibilitiesOfFieldsL(ETrue); - } - -// -------------------------------------------------------------------------------------------- - -TBool CLoadGenNetConnEditor::OkToExitL(TInt aButtonId) - { - if (aButtonId == EAknSoftkeyOk) - { - // store values from editors - CAknPopupFieldText* edPriority = static_cast(Control(ELoadGenNetConnQueryPriority)); - CEikEdwin* edDestination = static_cast(Control(ELoadGenNetConnQueryDestination)); - CEikNumberEditor* edIdle = static_cast(Control(ELoadGenNetConnQueryIdle)); - CEikNumberEditor* edVariance = static_cast(Control(ELoadGenNetConnQueryVariance)); - - iAttributes.iPriority = edPriority->CurrentValueIndex(); - edDestination->GetText(iAttributes.iDestination); - iAttributes.iIdle = edIdle->Number(); - iAttributes.iRandomVariance = edVariance->Number(); - } - - return ETrue; - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenNetConnEditor::UpdateVisibilitiesOfFieldsL(TBool /*aFormInit*/) - { - UpdateFormL(); - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenNetConnEditor::HandleControlStateChangeL(TInt aControlId) - { - CLoadGenLoadTypeEditorBase::HandleControlStateChangeL(aControlId); - } - -// -------------------------------------------------------------------------------------------- - -TBool CLoadGenNetConnEditor::RunQueryLD() - { - return CLoadGenLoadTypeEditorBase::DoRunQueryLD(R_NETCONN_FORM_DIALOG); - } - -// -------------------------------------------------------------------------------------------- - -// -------------------------------------------------------------------------------------------- -// -------------------------------------------------------------------------------------------- - -CLoadGenKeyPressEditor* CLoadGenKeyPressEditor::NewL(TKeyPressAttributes& aAttributes, TBool aEditingExisting) - { - CLoadGenKeyPressEditor* self = new(ELeave) CLoadGenKeyPressEditor(aAttributes, aEditingExisting); - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(self); - return self; - } - -// -------------------------------------------------------------------------------------------- - -CLoadGenKeyPressEditor::~CLoadGenKeyPressEditor() - { - } - -// -------------------------------------------------------------------------------------------- - -CLoadGenKeyPressEditor::CLoadGenKeyPressEditor(TKeyPressAttributes& aAttributes, TBool aEditingExisting) : - CLoadGenLoadTypeEditorBase(aEditingExisting), iAttributes(aAttributes) - { - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenKeyPressEditor::ConstructL() - { - CLoadGenLoadTypeEditorBase::ConstructL(_L("Key presses")); - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenKeyPressEditor::PreLayoutDynInitL() - { - CLoadGenLoadTypeEditorBase::PreLayoutDynInitL(); - - // load values to static editors - CAknPopupFieldText* edPriority = static_cast(Control(ELoadGenKeyPressQueryPriority)); - CEikNumberEditor* edHeartBeat = static_cast(Control(ELoadGenKeyPressQueryHeartBeat)); - CEikNumberEditor* edVariance = static_cast(Control(ELoadGenKeyPressQueryVariance)); - - edPriority->SetCurrentValueIndex(iAttributes.iPriority); - edHeartBeat->SetNumber(iAttributes.iHeartBeat); - edVariance->SetNumber(iAttributes.iRandomVariance); - - UpdateVisibilitiesOfFieldsL(ETrue); - } - -// -------------------------------------------------------------------------------------------- - -TBool CLoadGenKeyPressEditor::OkToExitL(TInt aButtonId) - { - if (aButtonId == EAknSoftkeyOk) - { - // store values from editors - CAknPopupFieldText* edPriority = static_cast(Control(ELoadGenKeyPressQueryPriority)); - CEikNumberEditor* edHeartBeat = static_cast(Control(ELoadGenKeyPressQueryHeartBeat)); - CEikNumberEditor* edVariance = static_cast(Control(ELoadGenKeyPressQueryVariance)); - - iAttributes.iPriority = edPriority->CurrentValueIndex(); - iAttributes.iHeartBeat = edHeartBeat->Number(); - iAttributes.iRandomVariance = edVariance->Number(); - } - - return ETrue; - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenKeyPressEditor::UpdateVisibilitiesOfFieldsL(TBool /*aFormInit*/) - { - UpdateFormL(); - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenKeyPressEditor::HandleControlStateChangeL(TInt aControlId) - { - CLoadGenLoadTypeEditorBase::HandleControlStateChangeL(aControlId); - } - -// -------------------------------------------------------------------------------------------- - -TBool CLoadGenKeyPressEditor::RunQueryLD() - { - return CLoadGenLoadTypeEditorBase::DoRunQueryLD(R_KEYPRESS_FORM_DIALOG); - } - -// -------------------------------------------------------------------------------------------- -// -------------------------------------------------------------------------------------------- - -CLoadGenMessagesEditor* CLoadGenMessagesEditor::NewL( TMessageAttributes& aAttributes, - TBool aEditingExisting ) - { - CLoadGenMessagesEditor* self = new(ELeave) CLoadGenMessagesEditor( aAttributes, - aEditingExisting ); - CleanupStack::PushL( self ); - self->ConstructL(); - CleanupStack::Pop( self ); - return self; - } - -// -------------------------------------------------------------------------------------------- - -CLoadGenMessagesEditor::~CLoadGenMessagesEditor() - { - } - -// -------------------------------------------------------------------------------------------- - -CLoadGenMessagesEditor::CLoadGenMessagesEditor( TMessageAttributes& aAttributes, - TBool aEditingExisting ) : - CLoadGenLoadTypeEditorBase( aEditingExisting ), - iAttributes( aAttributes ) - { - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenMessagesEditor::ConstructL() - { - CLoadGenLoadTypeEditorBase::ConstructL( _L("Messages") ); - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenMessagesEditor::PreLayoutDynInitL() - { - CLoadGenLoadTypeEditorBase::PreLayoutDynInitL(); - - // load values to static editors - CAknPopupFieldText* edPriority = - static_cast( Control( ELoadGenMessagesQueryPriority ) ); - CAknPopupFieldText* edType = - static_cast( Control( ELoadGenMessagesQueryType ) ); - CEikEdwin* edDestination = - static_cast( Control( ELoadGenMessagesQueryDestination ) ); - CEikNumberEditor* edAmount = - static_cast( Control( ELoadGenMessagesQueryAmount ) ); - CEikNumberEditor* edLength = - static_cast( Control( ELoadGenMessagesQueryLength ) ); - CEikNumberEditor* edIdle = - static_cast( Control( ELoadGenMessagesQueryIdle ) ); - CEikNumberEditor* edVariance = - static_cast( Control( ELoadGenMessagesQueryVariance ) ); - - edPriority->SetCurrentValueIndex( iAttributes.iPriority ); - edType->SetCurrentValueIndex( iAttributes.iMessageType ); - edDestination->SetTextL( &iAttributes.iDestination ); - edAmount->SetNumber( iAttributes.iAmount ); - edLength->SetNumber( iAttributes.iLength ); - edIdle->SetNumber( iAttributes.iIdle ); - edVariance->SetNumber( iAttributes.iRandomVariance ); - - UpdateVisibilitiesOfFieldsL( ETrue ); - // set type selection as dimmed if editing existing item - if (iEditingExisting) - { - SetLineDimmedNow(ELoadGenMessagesQueryType, ETrue); - } - - } - -// -------------------------------------------------------------------------------------------- - -TBool CLoadGenMessagesEditor::OkToExitL( TInt aButtonId ) - { - if ( aButtonId == EAknSoftkeyOk ) - { - // store values from editors - CAknPopupFieldText* edPriority = - static_cast( Control( ELoadGenMessagesQueryPriority ) ); - CAknPopupFieldText* edType = - static_cast( Control( ELoadGenMessagesQueryType ) ); - CEikEdwin* edDestination = - static_cast( Control( ELoadGenMessagesQueryDestination ) ); - CEikNumberEditor* edLength = - static_cast( Control( ELoadGenMessagesQueryLength ) ); - CEikNumberEditor* edAmount = - static_cast( Control( ELoadGenMessagesQueryAmount ) ); - CEikNumberEditor* edIdle = - static_cast( Control( ELoadGenMessagesQueryIdle ) ); - CEikNumberEditor* edVariance = - static_cast( Control( ELoadGenMessagesQueryVariance ) ); - - iAttributes.iPriority = edPriority->CurrentValueIndex(); - iAttributes.iMessageType = edType->CurrentValueIndex(); - edDestination->GetText( iAttributes.iDestination ); - iAttributes.iAmount = edAmount->Number(); - iAttributes.iLength = edLength->Number(); - iAttributes.iIdle = edIdle->Number(); - iAttributes.iRandomVariance = edVariance->Number(); - } - - return ETrue; - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenMessagesEditor::UpdateVisibilitiesOfFieldsL( TBool /*aFormInit*/ ) - { - UpdateFormL(); - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenMessagesEditor::HandleControlStateChangeL( TInt aControlId ) - { - CLoadGenLoadTypeEditorBase::HandleControlStateChangeL( aControlId ); - } - -// -------------------------------------------------------------------------------------------- - -TBool CLoadGenMessagesEditor::RunQueryLD() - { - return CLoadGenLoadTypeEditorBase::DoRunQueryLD( R_MESSAGES_FORM_DIALOG ); - } - -// -------------------------------------------------------------------------------------------- -// -------------------------------------------------------------------------------------------- - -CLoadGenApplicationsEditor* CLoadGenApplicationsEditor::NewL( TApplicationsAttributes& aAttributes, - TBool aEditingExisting ) - { - CLoadGenApplicationsEditor* self = new(ELeave) CLoadGenApplicationsEditor( aAttributes, - aEditingExisting ); - CleanupStack::PushL( self ); - self->ConstructL(); - CleanupStack::Pop( self ); - return self; - } - -// -------------------------------------------------------------------------------------------- - -CLoadGenApplicationsEditor::~CLoadGenApplicationsEditor() - { - } - -// -------------------------------------------------------------------------------------------- - -CLoadGenApplicationsEditor::CLoadGenApplicationsEditor( TApplicationsAttributes& aAttributes, - TBool aEditingExisting ) : - CLoadGenLoadTypeEditorBase( aEditingExisting ), - iAttributes( aAttributes ) - { - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenApplicationsEditor::ConstructL() - { - CLoadGenLoadTypeEditorBase::ConstructL( _L("Applications") ); - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenApplicationsEditor::PreLayoutDynInitL() - { - CLoadGenLoadTypeEditorBase::PreLayoutDynInitL(); - - // load values to static editors - CAknPopupFieldText* edPriority = static_cast(Control(ELoadGenApplicationsQueryPriority)); - CEikNumberEditor* edLaunchingInterval = static_cast(Control(ELoadGenApplicationsLaunchingInterval)); - CAknPopupFieldText* edKeyPressType = static_cast(Control(ELoadGenApplicationsKeyPressType)); - CEikNumberEditor* edMaxOpen = static_cast(Control(ELoadGenApplicationsMaxOpen)); - CEikNumberEditor* edHeartBeat = static_cast(Control(ELoadGenApplicationsKeyPressQueryHeartBeat)); - CEikNumberEditor* edVariance = static_cast(Control(ELoadGenApplicationsQueryVariance)); - - edPriority->SetCurrentValueIndex( iAttributes.iPriority ); - edLaunchingInterval->SetNumber( iAttributes.iLaunchingInterval ); - edKeyPressType->SetCurrentValueIndex( iAttributes.iKeyPressType ); - edMaxOpen->SetNumber( iAttributes.iMaxOpen ); - edHeartBeat->SetNumber( iAttributes.iHeartBeat ); - edVariance->SetNumber( iAttributes.iRandomVariance ); - - UpdateVisibilitiesOfFieldsL(ETrue); - } - -// -------------------------------------------------------------------------------------------- - -TBool CLoadGenApplicationsEditor::OkToExitL(TInt aButtonId) - { - if (aButtonId == EAknSoftkeyOk) - { - // store values from editors - CAknPopupFieldText* edPriority = static_cast(Control(ELoadGenApplicationsQueryPriority)); - CEikNumberEditor* edLaunchingInterval = static_cast(Control(ELoadGenApplicationsLaunchingInterval)); - CAknPopupFieldText* edKeyPressType = static_cast(Control(ELoadGenApplicationsKeyPressType)); - CEikNumberEditor* edMaxOpen = static_cast(Control(ELoadGenApplicationsMaxOpen)); - CEikNumberEditor* edHeartBeat = static_cast(Control(ELoadGenApplicationsKeyPressQueryHeartBeat)); - CEikNumberEditor* edVariance = static_cast(Control(ELoadGenApplicationsQueryVariance)); - - iAttributes.iPriority = edPriority->CurrentValueIndex(); - iAttributes.iLaunchingInterval = edLaunchingInterval->Number(); - iAttributes.iKeyPressType = edKeyPressType->CurrentValueIndex(); - iAttributes.iMaxOpen = edMaxOpen->Number(); - iAttributes.iHeartBeat = edHeartBeat->Number(); - iAttributes.iRandomVariance = edVariance->Number(); - } - - return ETrue; - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenApplicationsEditor::UpdateVisibilitiesOfFieldsL( TBool /*aFormInit*/ ) - { - UpdateFormL(); - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenApplicationsEditor::HandleControlStateChangeL( TInt aControlId ) - { - CLoadGenLoadTypeEditorBase::HandleControlStateChangeL( aControlId ); - } - -// -------------------------------------------------------------------------------------------- - -TBool CLoadGenApplicationsEditor::RunQueryLD() - { - return CLoadGenLoadTypeEditorBase::DoRunQueryLD( R_APPLICATIONS_FORM_DIALOG ); - } - -// -------------------------------------------------------------------------------------------- - -// -------------------------------------------------------------------------------------------- - -CLoadGenPhotoCaptureEditor* CLoadGenPhotoCaptureEditor::NewL(TPhotoCaptureAttributes& aAttributes, TBool aEditingExisting) - { - CLoadGenPhotoCaptureEditor* self = new(ELeave) CLoadGenPhotoCaptureEditor(aAttributes, aEditingExisting); - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(self); - return self; - } - -// -------------------------------------------------------------------------------------------- - -CLoadGenPhotoCaptureEditor::~CLoadGenPhotoCaptureEditor() - { - } - -// -------------------------------------------------------------------------------------------- - -CLoadGenPhotoCaptureEditor::CLoadGenPhotoCaptureEditor(TPhotoCaptureAttributes& aAttributes, TBool aEditingExisting) : - CLoadGenLoadTypeEditorBase(aEditingExisting), iAttributes(aAttributes) - { - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenPhotoCaptureEditor::ConstructL() - { - CLoadGenLoadTypeEditorBase::ConstructL(_L("Photo captures")); - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenPhotoCaptureEditor::PreLayoutDynInitL() - { - CLoadGenLoadTypeEditorBase::PreLayoutDynInitL(); - - // load values to static editors - CAknPopupFieldText* edPriority = static_cast(Control(ELoadGenPhotoCaptureQueryPriority)); - //CAknPopupFieldText* edDevice = static_cast(Control(ELoadGenPhotoCaptureQueryDevice)); - CEikNumberEditor* edIdle = static_cast(Control(ELoadGenPhotoCaptureQueryIdle)); - CEikNumberEditor* edVariance = static_cast(Control(ELoadGenPhotoCaptureQueryVariance)); - - edPriority->SetCurrentValueIndex(iAttributes.iPriority); - //edDevice->SetCurrentValueIndex(0); - edIdle->SetNumber(iAttributes.iIdle); - edVariance->SetNumber(iAttributes.iRandomVariance); - - LoadCamerasL(); - - UpdateVisibilitiesOfFieldsL(ETrue); - } - -void CLoadGenPhotoCaptureEditor::LoadCamerasL() - { - if (iAttributes.iCameraCount > 0) - { - // insert possibility to select which cpu the load is generated to - InsertFieldAfterL(R_PHOTOCAPTURE_DLG_LINE_DEVICE, ELoadGenPhotoCaptureQueryDevice, ELoadGenPhotoCaptureQueryPriority); - - iCamerasArray = new (ELeave) CDesCArrayFlat( iAttributes.iCameraCount ); - - // add Cameras - for (int i = 0; i < iAttributes.iCameraCount; i++) - { - TBuf<16> cam; - _LIT(KCam, "Camera %d"); - cam.Format(KCam, i); - iCamerasArray->AppendL(cam); - } - - iCameraTextArray = CAknQueryValueTextArray::NewL(); - iCameraTextArray->SetArray( *iCamerasArray ); - iCameraQueryValText = CAknQueryValueText::NewL(); - iCameraQueryValText->SetArrayL( iCameraTextArray ); - if( iAttributes.iCameraCount > 0 ) - { - iCameraQueryValText->SetCurrentValueIndex(iAttributes.iCamera); - } - CAknPopupField* popup = static_cast(Control( ELoadGenPhotoCaptureQueryDevice)); - popup->SetQueryValueL( iCameraQueryValText ); - } - } - -// -------------------------------------------------------------------------------------------- - -TBool CLoadGenPhotoCaptureEditor::OkToExitL(TInt aButtonId) - { - if (aButtonId == EAknSoftkeyOk) - { - // store values from editors - CAknPopupFieldText* edPriority = static_cast(Control(ELoadGenPhotoCaptureQueryPriority)); - CEikNumberEditor* edIdle = static_cast(Control(ELoadGenPhotoCaptureQueryIdle)); - CEikNumberEditor* edVariance = static_cast(Control(ELoadGenPhotoCaptureQueryVariance)); - - iAttributes.iPriority = edPriority->CurrentValueIndex(); - iAttributes.iIdle = edIdle->Number(); - iAttributes.iRandomVariance = edVariance->Number(); - - if (iAttributes.iCameraCount > 1) - { - iAttributes.iCamera = iCameraQueryValText->CurrentValueIndex(); - } - } - - return ETrue; - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenPhotoCaptureEditor::UpdateVisibilitiesOfFieldsL(TBool /*aFormInit*/) - { - UpdateFormL(); - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenPhotoCaptureEditor::HandleControlStateChangeL(TInt aControlId) - { - CLoadGenLoadTypeEditorBase::HandleControlStateChangeL(aControlId); - } - -// -------------------------------------------------------------------------------------------- - -TBool CLoadGenPhotoCaptureEditor::RunQueryLD() - { - return CLoadGenLoadTypeEditorBase::DoRunQueryLD(R_PHOTOCAPTURE_FORM_DIALOG); - } - - -// -------------------------------------------------------------------------------------------- - -CLoadGenBluetoothEditor* CLoadGenBluetoothEditor::NewL(TBluetoothAttributes& aAttributes, TBool aEditingExisting) - { - CLoadGenBluetoothEditor* self = new(ELeave) CLoadGenBluetoothEditor(aAttributes, aEditingExisting); - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(self); - return self; - } - -// -------------------------------------------------------------------------------------------- - -CLoadGenBluetoothEditor::~CLoadGenBluetoothEditor() - { - } - -// -------------------------------------------------------------------------------------------- - -CLoadGenBluetoothEditor::CLoadGenBluetoothEditor(TBluetoothAttributes& aAttributes, TBool aEditingExisting) : - CLoadGenLoadTypeEditorBase(aEditingExisting), iAttributes(aAttributes) - { - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenBluetoothEditor::ConstructL() - { - CLoadGenLoadTypeEditorBase::ConstructL(_L("Bluetooth")); - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenBluetoothEditor::PreLayoutDynInitL() - { - CLoadGenLoadTypeEditorBase::PreLayoutDynInitL(); - - // load values to static editors - CAknPopupFieldText* edPriority = static_cast(Control(ELoadGenBluetoothQueryPriority)); - CEikNumberEditor* edIdle = static_cast(Control(ELoadGenBluetoothQueryIdle)); - CEikNumberEditor* edVariance = static_cast(Control(ELoadGenBluetoothQueryVariance)); - - edPriority->SetCurrentValueIndex(iAttributes.iPriority); - edIdle->SetNumber(iAttributes.iIdle); - edVariance->SetNumber(iAttributes.iRandomVariance); - - UpdateVisibilitiesOfFieldsL(ETrue); - } - -// -------------------------------------------------------------------------------------------- - -TBool CLoadGenBluetoothEditor::OkToExitL(TInt aButtonId) - { - if (aButtonId == EAknSoftkeyOk) - { - // store values from editors - CAknPopupFieldText* edPriority = static_cast(Control(ELoadGenBluetoothQueryPriority)); - CEikNumberEditor* edIdle = static_cast(Control(ELoadGenBluetoothQueryIdle)); - CEikNumberEditor* edVariance = static_cast(Control(ELoadGenBluetoothQueryVariance)); - - iAttributes.iPriority = edPriority->CurrentValueIndex(); - iAttributes.iIdle = edIdle->Number(); - iAttributes.iRandomVariance = edVariance->Number(); - } - - return ETrue; - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenBluetoothEditor::UpdateVisibilitiesOfFieldsL(TBool /*aFormInit*/) - { - UpdateFormL(); - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenBluetoothEditor::HandleControlStateChangeL(TInt aControlId) - { - CLoadGenLoadTypeEditorBase::HandleControlStateChangeL(aControlId); - } - -// -------------------------------------------------------------------------------------------- - -TBool CLoadGenBluetoothEditor::RunQueryLD() - { - return CLoadGenLoadTypeEditorBase::DoRunQueryLD(R_BLUETOOTH_FORM_DIALOG); - } - -// -------------------------------------------------------------------------------------------- -// -------------------------------------------------------------------------------------------- - -CLoadGenPointerEventEditor* CLoadGenPointerEventEditor::NewL(TPointerEventAttributes& aAttributes, TBool aEditingExisting) - { - CLoadGenPointerEventEditor* self = new(ELeave) CLoadGenPointerEventEditor(aAttributes, aEditingExisting); - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(self); - return self; - } - -// -------------------------------------------------------------------------------------------- - -CLoadGenPointerEventEditor::~CLoadGenPointerEventEditor() - { - } - -// -------------------------------------------------------------------------------------------- - -CLoadGenPointerEventEditor::CLoadGenPointerEventEditor(TPointerEventAttributes& aAttributes, TBool aEditingExisting) : - CLoadGenLoadTypeEditorBase(aEditingExisting), iAttributes(aAttributes) - { - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenPointerEventEditor::ConstructL() - { - CLoadGenLoadTypeEditorBase::ConstructL(_L("Pointer events")); - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenPointerEventEditor::PreLayoutDynInitL() - { - CLoadGenLoadTypeEditorBase::PreLayoutDynInitL(); - - // load values to static editors - CAknPopupFieldText* edPriority = static_cast(Control(ELoadGenPointerEventQueryPriority)); - CEikNumberEditor* edHeartBeat = static_cast(Control(ELoadGenPointerEventQueryHeartBeat)); - CEikNumberEditor* edVariance = static_cast(Control(ELoadGenPointerEventQueryVariance)); - - edPriority->SetCurrentValueIndex(iAttributes.iPriority); - edHeartBeat->SetNumber(iAttributes.iHeartBeat); - edVariance->SetNumber(iAttributes.iRandomVariance); - - UpdateVisibilitiesOfFieldsL(ETrue); - } - -// -------------------------------------------------------------------------------------------- - -TBool CLoadGenPointerEventEditor::OkToExitL(TInt aButtonId) - { - if (aButtonId == EAknSoftkeyOk) - { - // store values from editors - CAknPopupFieldText* edPriority = static_cast(Control(ELoadGenPointerEventQueryPriority)); - CEikNumberEditor* edHeartBeat = static_cast(Control(ELoadGenPointerEventQueryHeartBeat)); - CEikNumberEditor* edVariance = static_cast(Control(ELoadGenPointerEventQueryVariance)); - - iAttributes.iPriority = edPriority->CurrentValueIndex(); - iAttributes.iHeartBeat = edHeartBeat->Number(); - iAttributes.iRandomVariance = edVariance->Number(); - } - - return ETrue; - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenPointerEventEditor::UpdateVisibilitiesOfFieldsL(TBool /*aFormInit*/) - { - UpdateFormL(); - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenPointerEventEditor::HandleControlStateChangeL(TInt aControlId) - { - CLoadGenLoadTypeEditorBase::HandleControlStateChangeL(aControlId); - } - -// -------------------------------------------------------------------------------------------- - -TBool CLoadGenPointerEventEditor::RunQueryLD() - { - return CLoadGenLoadTypeEditorBase::DoRunQueryLD(R_POINTEREVENT_FORM_DIALOG); - } - -// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/ui/avkon/src/loadgen_maincontainer.cpp --- a/loadgen/ui/avkon/src/loadgen_maincontainer.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,457 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -// INCLUDE FILES -#include "loadgen_maincontainer.h" -#include "loadgen.hrh" -#include "loadgen_document.h" -#include "loadgen_appui.h" -#include "loadgen_model.h" -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -_LIT(KExtraIconsPath, "\\resource\\apps\\loadgen_extraicons.mif"); - -// ===================================== MEMBER FUNCTIONS ===================================== - -void CLoadGenMainContainer::ConstructL(const TRect& aRect) - { - iModel = static_cast(reinterpret_cast(iEikonEnv->AppUi())->Document())->Model(); - iModel->SetMainContainer(this); - - CreateWindowL(); - SetRect(aRect); - SetBlank(); - - // init listbox - iListBox = new(ELeave) CLoadGenCAknSingleGraphicStyleListBox; - iListBox->SetContainerWindowL(*this); - iListBox->ConstructL(this, EAknListBoxMarkableList); - iListBox->View()->SetListEmptyTextL(_L("No loads activated\n(Select new load from Options to generate new load)")); - - // create icon array and add marking indicator to it - CAknIconArray* iconArray = new(ELeave) CAknIconArray(1); - CleanupStack::PushL(iconArray); - CFbsBitmap* markBitmap = NULL; - CFbsBitmap* markBitmapMask = NULL; - - TRgb defaultColor; - defaultColor = iEikonEnv->Color(EColorControlText); - - AknsUtils::CreateColorIconL(AknsUtils::SkinInstance(), - KAknsIIDQgnIndiMarkedAdd, - KAknsIIDQsnIconColors, - EAknsCIQsnIconColorsCG13, - markBitmap, - markBitmapMask, - AknIconUtils::AvkonIconFileName(), - EMbmAvkonQgn_indi_marked_add, - EMbmAvkonQgn_indi_marked_add_mask, - defaultColor - ); - - CGulIcon* markIcon = CGulIcon::NewL(markBitmap, markBitmapMask); - iconArray->AppendL(markIcon); - - // append icons from loadgen_extraicons.mif - TFileName extraIconsPath; - extraIconsPath.Copy(KExtraIconsPath); - TParsePtrC parse((CEikonEnv::Static()->EikAppUi()->Application())->AppFullName()); // get path where this app is installed - extraIconsPath.Insert(0, parse.Drive()); // drive letter - - CFbsBitmap* redBitmap = NULL; - CFbsBitmap* redBitmapMask = NULL; - CFbsBitmap* greenBitmap = NULL; - CFbsBitmap* greenBitmapMask = NULL; - - AknIconUtils::CreateIconL(redBitmap, redBitmapMask, extraIconsPath, EMbmLoadgen_extraiconsQgn_prob_status_red, EMbmLoadgen_extraiconsQgn_prob_status_red_mask); - AknIconUtils::CreateIconL(greenBitmap, greenBitmapMask, extraIconsPath, EMbmLoadgen_extraiconsQgn_prob_status_green, EMbmLoadgen_extraiconsQgn_prob_status_green_mask); - - CGulIcon* redIcon = CGulIcon::NewL(redBitmap, redBitmapMask); - iconArray->AppendL(redIcon); - - CGulIcon* greenIcon = CGulIcon::NewL(greenBitmap, greenBitmapMask); - iconArray->AppendL(greenIcon); - - // set icon array - CleanupStack::Pop(); // iconArray - iListBox->ItemDrawer()->ColumnData()->SetIconArray(iconArray); - - iListBox->CreateScrollBarFrameL(ETrue); - iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto); - iListBox->SetListBoxObserver(this); - - // set size of the listbox - TSize outputRectSize; - AknLayoutUtils::LayoutMetricsSize(AknLayoutUtils::EMainPane, outputRectSize); - TRect outputRect(outputRectSize); - iListBox->SetRect(outputRect); - - iListBox->ActivateL(); - - ActivateL(); - } - -// -------------------------------------------------------------------------------------------- - -CLoadGenMainContainer::~CLoadGenMainContainer() - { - if (iListBox) - delete iListBox; - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenMainContainer::SizeChanged() -{ - TSize outputRectSize; - AknLayoutUtils::LayoutMetricsSize(AknLayoutUtils::EMainPane, outputRectSize); - TRect outputRect(outputRectSize); - - if (iListBox) - iListBox->SetRect(outputRect); -} - -// -------------------------------------------------------------------------------------------- - -TInt CLoadGenMainContainer::CountComponentControls() const - { - if (iListBox) - return 1; - else - return 0; - } - -// -------------------------------------------------------------------------------------------- - -CCoeControl* CLoadGenMainContainer::ComponentControl(TInt /*aIndex*/) const - { - if (iListBox) - return iListBox; - else - return NULL; - } - -// -------------------------------------------------------------------------------------------- - -TInt CLoadGenMainContainer::CurrentListBoxItemIndex() - { - if (iListBox) - { - return iListBox->CurrentItemIndex(); - } - else - return KErrNotFound; - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenMainContainer::SetListBoxTextArrayL(CDesCArray* aTextArray) - { - if (iListBox) - { - iListBox->Model()->SetItemTextArray(aTextArray); - iListBox->Model()->SetOwnershipType(ELbmOwnsItemArray); - iListBox->HandleItemAdditionL(); - iListBox->UpdateScrollBarsL(); - } - } - -// -------------------------------------------------------------------------------------------- - -const CArrayFix* CLoadGenMainContainer::ListBoxSelectionIndexes() - { - if (iListBox) - { - const CListBoxView::CSelectionIndexArray* indices = iListBox->SelectionIndexes(); - return static_cast*>(indices); - } - else - return NULL; - } - -// -------------------------------------------------------------------------------------------- - -TInt CLoadGenMainContainer::ListBoxSelectionIndexesCount() - { - if (iListBox) - { - return iListBox->SelectionIndexes()->Count(); - } - else - return KErrNotFound; - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenMainContainer::Draw(const TRect& aRect) const - { - CWindowGc& gc = SystemGc(); - gc.Clear(aRect); - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenMainContainer::HandleControlEventL(CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/) - { - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenMainContainer::SetDefaultTitlePaneTextL() - { - _LIT(KTitleText, "Load Gener."); - - CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane(); - CAknTitlePane* tp = static_cast( sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); - tp->SetTextL( KTitleText ); - } - -// -------------------------------------------------------------------------------------------- - -TKeyResponse CLoadGenMainContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType) - { - if(aType != EEventKey) - return EKeyWasNotConsumed; - - if (iListBox && iListBox->Model()->NumberOfItems() > 0) - { - /* - if (aKeyEvent.iCode == EKeyBackspace || aKeyEvent.iCode == EKeyDelete) - { - iModel->StopSelectedOrHighlightedItemsL(); - return EKeyWasConsumed; - } - else - { - return iListBox->OfferKeyEventL(aKeyEvent, aType); - } - */ - TBool shiftKeyPressed = (aKeyEvent.iModifiers & EModifierShift) || - (aKeyEvent.iModifiers & EModifierLeftShift) || - (aKeyEvent.iModifiers & EModifierRightShift); - TBool controlKeyPressed = (aKeyEvent.iModifiers & EModifierCtrl) || - (aKeyEvent.iModifiers & EModifierRightCtrl); - - - // handle OK/Enter keys - if ((aKeyEvent.iCode == EKeyOK || aKeyEvent.iCode == EKeyEnter) && (shiftKeyPressed || controlKeyPressed)) - { - return iListBox->OfferKeyEventL(aKeyEvent, aType); //send to listbox if modifiers - } - - // handle OK/Enter keys - else if (aKeyEvent.iCode == EKeyOK || aKeyEvent.iCode == EKeyEnter) - { - iModel->ShowItemActionMenuL(); - } - - // handle delete key - else if (aKeyEvent.iCode == EKeyBackspace || aKeyEvent.iCode == EKeyDelete) - { - iModel->StopSelectedOrHighlightedItemsL(); - } - - else - return iListBox->OfferKeyEventL(aKeyEvent, aType); - } - - return EKeyWasNotConsumed; - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenMainContainer::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aEventType) - { - switch (aEventType) - { - case EEventEnterKeyPressed: - case EEventItemDoubleClicked: - { - iModel->ShowItemActionMenuL(); - } - break; - default: - break; - } - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenMainContainer::HandleResourceChange(TInt aType) - { - if ( aType == KEikDynamicLayoutVariantSwitch ) - { - TRect mainPaneRect; - AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect); - SetRect(mainPaneRect); - - TSize outputRectSize; - AknLayoutUtils::LayoutMetricsSize(AknLayoutUtils::EMainPane, outputRectSize); - TRect outputRect(outputRectSize); - iListBox->SetRect(outputRect); - } - else - { - CCoeControl::HandleResourceChange(aType); - } - } - -// -------------------------------------------------------------------------------------------- -// -------------------------------------------------------------------------------------------- - -void CLoadGenCAknSingleGraphicStyleListBox::SizeChanged() - { - // call the base class function first - CAknSingleGraphicStyleListBox::SizeChanged(); - - // customize the list box - TRAP_IGNORE(SizeChangedL()); - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenCAknSingleGraphicStyleListBox::SizeChangedL() - { - const TInt KEmptySize = 2; - - // disable separator line - ItemDrawer()->ColumnData()->SetSeparatorLinePosition(ENoLine); - - // enable marquee - ItemDrawer()->ColumnData()->EnableMarqueeL(ETrue); - - // set fonts - const CFont* font = AknLayoutUtils::FontFromId(EAknLogicalFontPrimarySmallFont); - ItemDrawer()->ColumnData()->SetColumnFontL(0, font); - ItemDrawer()->ColumnData()->SetColumnFontL(1, font); - ItemDrawer()->ColumnData()->SetColumnFontL(2, font); - ItemDrawer()->ColumnData()->SetColumnFontL(3, font); - - // set row height - TInt rowHeight = font->HeightInPixels()+5; - TSize itemCellSize = View()->ItemDrawer()->ItemCellSize(); - itemCellSize.iHeight = rowHeight; - SetItemHeightL(rowHeight); - View()->ItemDrawer()->SetItemCellSize(itemCellSize); - - // set icon sizes - TInt normalIconSize = rowHeight * 0.7; - TInt markingIconSize = rowHeight * 0.8; - ItemDrawer()->ColumnData()->SetSubCellIconSize(0, TSize(normalIconSize,normalIconSize)); - ItemDrawer()->ColumnData()->SetSubCellIconSize(2, TSize(markingIconSize,markingIconSize)); - ItemDrawer()->ColumnData()->SetSubCellIconSize(3, TSize(KEmptySize,KEmptySize)); - - // set column widths - ItemDrawer()->ColumnData()->SetColumnWidthPixelL(0, normalIconSize + 2*normalIconSize * 0.15); - ItemDrawer()->ColumnData()->SetColumnWidthPixelL(1, itemCellSize.iWidth-KEmptySize-markingIconSize); - ItemDrawer()->ColumnData()->SetColumnWidthPixelL(2, markingIconSize); - ItemDrawer()->ColumnData()->SetColumnWidthPixelL(3, KEmptySize); - - // set baseline for the text - ItemDrawer()->ColumnData()->SetColumnBaselinePosL(1, font->HeightInPixels()-font->BaselineOffsetInPixels()); - - // set margins - TMargins iconMargins; - iconMargins.iBottom = 0; - iconMargins.iLeft = normalIconSize * 0.15; - iconMargins.iRight = normalIconSize * 0.15; - iconMargins.iTop = 0; - - TMargins textMargins; - textMargins.iBottom = 0; - textMargins.iLeft = markingIconSize * 0.15; - textMargins.iRight = markingIconSize * 0.15; - textMargins.iTop = 0; - - ItemDrawer()->ColumnData()->SetColumnMarginsL(0, iconMargins); - ItemDrawer()->ColumnData()->SetColumnMarginsL(1, textMargins); - ItemDrawer()->ColumnData()->SetColumnMarginsL(2, iconMargins); - ItemDrawer()->ColumnData()->SetColumnMarginsL(3, iconMargins); - -/* - const TInt KEmptySize = 2; - - // enable marquee - ItemDrawer()->ColumnData()->EnableMarqueeL(ETrue); - - // set fonts - const CFont* font = AknLayoutUtils::FontFromId(EAknLogicalFontPrimarySmallFont); - ItemDrawer()->ColumnData()->SetColumnFontL(0, font); - ItemDrawer()->ColumnData()->SetColumnFontL(1, font); - ItemDrawer()->ColumnData()->SetColumnFontL(2, font); - ItemDrawer()->ColumnData()->SetColumnFontL(3, font); - - // set row height - TInt rowHeight = font->HeightInPixels()+7; - TSize itemCellSize = View()->ItemDrawer()->ItemCellSize(); - itemCellSize.iHeight = rowHeight; - SetItemHeightL(rowHeight); - View()->ItemDrawer()->SetItemCellSize(itemCellSize); - - // set icon sizes - TInt normalIconSize = rowHeight * 0.6; - TInt markingIconSize = rowHeight * 0.8; - ItemDrawer()->ColumnData()->SetSubCellIconSize(0, TSize(normalIconSize,normalIconSize)); - ItemDrawer()->ColumnData()->SetSubCellIconSize(2, TSize(markingIconSize,markingIconSize)); - ItemDrawer()->ColumnData()->SetSubCellIconSize(3, TSize(KEmptySize,KEmptySize)); - - // set column widths - ItemDrawer()->ColumnData()->SetColumnWidthPixelL(0, normalIconSize); - ItemDrawer()->ColumnData()->SetColumnWidthPixelL(1, itemCellSize.iWidth-KEmptySize-markingIconSize); - ItemDrawer()->ColumnData()->SetColumnWidthPixelL(2, markingIconSize); - ItemDrawer()->ColumnData()->SetColumnWidthPixelL(3, KEmptySize); - - // set baseline for the text - ItemDrawer()->ColumnData()->SetColumnBaselinePosL(1, font->HeightInPixels()-font->BaselineOffsetInPixels()); - - // set margins - TMargins iconMargins; - iconMargins.iBottom = 0; - iconMargins.iLeft = 0; - iconMargins.iRight = 0; - iconMargins.iTop = 0; - - TMargins textMargins; - textMargins.iBottom = 0; - textMargins.iLeft = markingIconSize * 0.15; - textMargins.iRight = markingIconSize * 0.15; - textMargins.iTop = 0; - - ItemDrawer()->ColumnData()->SetColumnMarginsL(0, iconMargins); - ItemDrawer()->ColumnData()->SetColumnMarginsL(1, textMargins); - ItemDrawer()->ColumnData()->SetColumnMarginsL(2, iconMargins); - ItemDrawer()->ColumnData()->SetColumnMarginsL(3, iconMargins); -*/ - } - -// -------------------------------------------------------------------------------------------- - -// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/ui/avkon/src/loadgen_mainview.cpp --- a/loadgen/ui/avkon/src/loadgen_mainview.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,175 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -// INCLUDE FILES -#include "loadgen.hrh" -#include "loadgen_mainview.h" -#include "loadgen_maincontainer.h" -#include "loadgen_document.h" -#include "loadgen_model.h" -#include "loadgen_traces.h" -#include - -#include -#include -#include - - -// ================= MEMBER FUNCTIONS ======================= - -// --------------------------------------------------------- -// CLoadGenMainView::ConstructL(const TRect& aRect) -// EPOC two-phased constructor -// --------------------------------------------------------- -// -void CLoadGenMainView::ConstructL() - { - BaseConstructL( R_LOADGEN_VIEW_MAIN ); - iModel = static_cast(reinterpret_cast(iEikonEnv->AppUi())->Document())->Model(); - } - -// --------------------------------------------------------- -// CLoadGenMainView::~CLoadGenMainView() -// --------------------------------------------------------- -// -CLoadGenMainView::~CLoadGenMainView() - { - if (iContainer) - { - AppUi()->RemoveFromViewStack( *this, iContainer ); - delete iContainer; - iContainer = NULL; - } - } - -// --------------------------------------------------------- -// TUid CLoadGenMainView::Id() -// --------------------------------------------------------- -// -TUid CLoadGenMainView::Id() const - { - return KMainViewUID; - } - -// --------------------------------------------------------- -// TUid CLoadGenMainView::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane) -// --------------------------------------------------------- -// -void CLoadGenMainView::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane) - { - AppUi()->DynInitMenuPaneL(aResourceId, aMenuPane); - } - - -// --------------------------------------------------------- -// CLoadGenMainView::HandleCommandL(TInt aCommand) -// --------------------------------------------------------- -// -void CLoadGenMainView::HandleCommandL(TInt aCommand) - { - switch ( aCommand ) - { - case ELoadGenCmdNewLoadCPULoad: - case ELoadGenCmdNewLoadEatMemory: - case ELoadGenCmdNewLoadPhoneCall: - case ELoadGenCmdNewLoadNetConn: - case ELoadGenCmdNewLoadKeyPress: - case ELoadGenCmdNewLoadMessages: - case ELoadGenCmdNewLoadApplications: - case ELoadGenCmdNewLoadPhotoCaptures: - case ELoadGenCmdNewLoadBluetooth: - case ELoadGenCmdNewLoadPointerEvent: - { - TRAPD(err, iModel->StartNewLoadL(aCommand)); - if( err != KErrNone ) - { - LOGSTRING2("LoadGen: Load (command: %d) start failed!", aCommand); - _LIT(message, "Load start failed!"); - CAknErrorNote* errorNote = new(ELeave) CAknErrorNote; - errorNote->ExecuteLD(message); - } - break; - } - case ELoadGenStopAll: - { - iModel->StopAllLoadItemsL(); - break; - } - case ELoadGenSuspendAll: - { - iModel->SuspendAllLoadItemsL(); - break; - } - case ELoadGenResumeAll: - { - iModel->ResumeAllLoadItemsL(); - break; - } - default: - { - AppUi()->HandleCommandL(aCommand); - break; - } - } - } - -// --------------------------------------------------------- -// CLoadGenMainView::HandleClientRectChange() -// --------------------------------------------------------- -// -void CLoadGenMainView::HandleClientRectChange() - { - if ( iContainer ) - { - iContainer->SetRect( ClientRect() ); - } - } - -// --------------------------------------------------------- -// CLoadGenMainView::DoActivateL(...) -// --------------------------------------------------------- -// -void CLoadGenMainView::DoActivateL( - const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/, - const TDesC8& /*aCustomMessage*/) - { - if (!iContainer) - { - iContainer = new (ELeave) CLoadGenMainContainer; - iModel->SetMainContainer(iContainer); - iContainer->SetMopParent(this); - iContainer->ConstructL( ClientRect() ); - AppUi()->AddToStackL( *this, iContainer ); - } - } - -// --------------------------------------------------------- -// CLoadGenMainView::DoDeactivate() -// --------------------------------------------------------- -// -void CLoadGenMainView::DoDeactivate() - { - if (iContainer) - { - AppUi()->RemoveFromViewStack( *this, iContainer ); - delete iContainer; - iContainer = NULL; - } - } - -// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/ui/avkon/src/loadgen_model.cpp --- a/loadgen/ui/avkon/src/loadgen_model.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,910 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -// INCLUDE FILES -#include "loadgen_cpuload.h" -#include "loadgen_memoryeat.h" -#include "loadgen_phonecall.h" -#include "loadgen_netconn.h" -#include "loadgen_keypress.h" -#include "loadgen_pointerevent.h" -#include "loadgen_messages.h" -#include "loadgen_applications.h" -#include "loadgen_photocapture.h" -#include "loadgen_bluetooth.h" -#include "loadgen_utils.h" - -#include "loadgen_traces.h" -#include "loadgen_editors.h" -#include "loadgen_loadattributes.h" -#include "loadgen_model.h" -#include "loadgen_app.h" -#include "loadgen_settingsviewdlg.h" -#include "loadgen_maincontainer.h" -#include "loadgen.hrh" -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -inline TInt64 INIT_SEED() -{ - TTime now; - now.HomeTime(); - return now.Int64(); -} - -TInt64 CLoadGenModel::iRandomNumberSeed = INIT_SEED(); - -// ===================================== MEMBER FUNCTIONS ===================================== - -CLoadGenModel* CLoadGenModel::NewL() - { - CLoadGenModel* self = new(ELeave) CLoadGenModel; - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(); - return self; - } - -// -------------------------------------------------------------------------------------------- - -CLoadGenModel::CLoadGenModel() : CActive(EPriorityStandard) - { - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenModel::ConstructL() - { - iDrawState = EDrawStateInvalid; - iReferenceNumber = 0; - - iEnv = CEikonEnv::Static(); - User::LeaveIfError(iLs.Connect()); - - iLoadItemList = new(ELeave) CLoadItemList(64); - - User::LeaveIfError(iTimer.CreateLocal()); - CActiveScheduler::Add(this); - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenModel::ActivateModelL() - { - // load settings - //TRAP_IGNORE(LoadSettingsL()); - - // set defaults to attributes - iCpuLoadAttributes.iId = 0; - iCpuLoadAttributes.iPriority = EThreadPriorityTypeNormal; - iCpuLoadAttributes.iMode = ECpuLoadModeYielding; - iCpuLoadAttributes.iType = ECpuLoadTypePeriodic; - iCpuLoadAttributes.iLength = 4000; - iCpuLoadAttributes.iIdle = 2000; - iCpuLoadAttributes.iRandomVariance = 0; - iCpuLoadAttributes.iCpu = KCPUSelection_FreeScheduling; // set CPU as "undefined" (can be >= 0 only in SMP environments) - iCpuLoadAttributes.iCpuCount = UserSvr::HalFunction(EHalGroupKernel, KHalFunction_EKernelHalNumLogicalCpus, 0, 0); - if( iCpuLoadAttributes.iCpuCount < 1 || iCpuLoadAttributes.iCpuCount > KMaxCPUs ) - { - // HAL may not support this function, so let's use CPU count 1: - iCpuLoadAttributes.iCpuCount = 1; - } - iMemoryEatAttributes.iId = 0; - iMemoryEatAttributes.iPriority = EThreadPriorityTypeNormal; - iMemoryEatAttributes.iSource = 0; - iMemoryEatAttributes.iType = EMemoryEatTypeMemoryToBeLeft; - iMemoryEatAttributes.iBuffer = 16*1024; - iMemoryEatAttributes.iIdle = 0; - iMemoryEatAttributes.iAmount = 0; - iMemoryEatAttributes.iRandomMin = 1000000; - iMemoryEatAttributes.iRandomMax = 1500000; - iMemoryEatAttributes.iAmountDes.Copy(KNullDesC); - iMemoryEatAttributes.iRandomMinDes.Copy(KNullDesC); - iMemoryEatAttributes.iRandomMaxDes.Copy(KNullDesC); - iMemoryEatAttributes.iRandomVariance = 0; - - iPhoneCallAttributes.iId = 0; - iPhoneCallAttributes.iPriority = EThreadPriorityTypeNormal; - iPhoneCallAttributes.iDestination.Copy(_L("+358")); - iPhoneCallAttributes.iLength = 60000; - iPhoneCallAttributes.iIdle = 10000; - iPhoneCallAttributes.iRandomVariance = 0; - - iNetConnAttributes.iId = 0; - iNetConnAttributes.iPriority = EThreadPriorityTypeNormal; - iNetConnAttributes.iDestination.Copy(_L("http://www.nokia.com")); - iNetConnAttributes.iIdle = 10000; - iNetConnAttributes.iRandomVariance = 0; - - iKeyPressAttributes.iId = 0; - iKeyPressAttributes.iPriority = EThreadPriorityTypeNormal; - iKeyPressAttributes.iHeartBeat = 100; - iKeyPressAttributes.iRandomVariance = 0; - - iPointerEventAttributes.iId = 0; - iPointerEventAttributes.iPriority = EThreadPriorityTypeNormal; - iPointerEventAttributes.iHeartBeat = 1000; - iPointerEventAttributes.iRandomVariance = 0; - - iMessageAttributes.iId = 0; - iMessageAttributes.iPriority = EThreadPriorityTypeNormal; - iMessageAttributes.iMessageType = EMessageTypeSMS; - iMessageAttributes.iDestination.Copy(_L("+358")); - iMessageAttributes.iAmount = 5; - iMessageAttributes.iLength = 160; - iMessageAttributes.iIdle = 15000; - iMessageAttributes.iRandomVariance = 0; - - iApplicationsAttributes.iId = 0; - iApplicationsAttributes.iLaunchingInterval = 2000; - iApplicationsAttributes.iPriority = EThreadPriorityTypeNormal; - iApplicationsAttributes.iKeyPressType = EApplicationsKeyPressTypeNone; - iApplicationsAttributes.iMaxOpen = 20; - iApplicationsAttributes.iHeartBeat = 50; - iApplicationsAttributes.iRandomVariance = 0; - - iPhotoCaptureAttributes.iId = 0; - iPhotoCaptureAttributes.iPriority = EThreadPriorityTypeNormal; - iPhotoCaptureAttributes.iIdle = 10000; - iPhotoCaptureAttributes.iRandomVariance = 0; - iPhotoCaptureAttributes.iCameraCount = CCamera::CamerasAvailable(); - if(iPhotoCaptureAttributes.iCameraCount > 0) - { - iPhotoCaptureAttributes.iCamera = 0; // Main camera - } - else - { - iPhotoCaptureAttributes.iCamera = -1; - } - - iBluetoothAttributes.iId = 0; - iBluetoothAttributes.iPriority = EThreadPriorityTypeNormal; - iBluetoothAttributes.iIdle = 10000; - iBluetoothAttributes.iRandomVariance = 0; - iBluetoothAttributes.iBluetoothSupported = CFeatureDiscovery::IsFeatureSupportedL(KFeatureIdBt); - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenModel::DeActivateModelL() - { - Cancel(); - - // for a faster exit, send the application to background - TApaTask selfTask(iEnv->WsSession()); - selfTask.SetWgId(iEnv->RootWin().Identifier()); - selfTask.SendToBackground(); - } - -// -------------------------------------------------------------------------------------------- - -CLoadGenModel::~CLoadGenModel() - { - if (iLoadItemList) - { - DeleteAllLoadItems(); - delete iLoadItemList; - } - if ( iApplicationsAttributes.iAppsArray ) - { - delete iApplicationsAttributes.iAppsArray; - } - iTimer.Close(); - iLs.Close(); - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenModel::DoCancel() - { - iTimer.Cancel(); - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenModel::RunL() - { - // continue - //iTimer.After(iStatus, 400000); - //SetActive(); - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenModel::SetMainContainer(CLoadGenMainContainer* aContainer) - { - iMainContainer = aContainer; - iDrawState = EDrawStateMain; - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenModel::StartNewLoadL(TInt aCommand) - { - // show new load query - CLoadGenLoadTypeEditorBase* dlg = NULL; - - switch ( aCommand ) - { - case ELoadGenCmdNewLoadCPULoad: - { - dlg = CLoadGenCPULoadEditor::NewL(iCpuLoadAttributes); - break; - } - case ELoadGenCmdNewLoadEatMemory: - { - dlg = CLoadGenMemoryEatEditor::NewL(iMemoryEatAttributes); - break; - } - case ELoadGenCmdNewLoadPhoneCall: - { - dlg = CLoadGenPhoneCallEditor::NewL(iPhoneCallAttributes); - break; - } - case ELoadGenCmdNewLoadNetConn: - { - dlg = CLoadGenNetConnEditor::NewL(iNetConnAttributes); - break; - } - case ELoadGenCmdNewLoadKeyPress: - { - dlg = CLoadGenKeyPressEditor::NewL(iKeyPressAttributes); - break; - } - case ELoadGenCmdNewLoadMessages: - { - dlg = CLoadGenMessagesEditor::NewL( iMessageAttributes ); - break; - } - case ELoadGenCmdNewLoadApplications: - { - dlg = CLoadGenApplicationsEditor::NewL( iApplicationsAttributes ); - break; - } - case ELoadGenCmdNewLoadPhotoCaptures: - { - if( iPhotoCaptureAttributes.iCameraCount > 0 ) - { - dlg = CLoadGenPhotoCaptureEditor::NewL( iPhotoCaptureAttributes ); - } - else - { - _LIT(message, "Cameras not available"); - CAknErrorNote* errorNote = new(ELeave) CAknErrorNote; - errorNote->ExecuteLD(message); - return; - } - break; - } - case ELoadGenCmdNewLoadBluetooth: - { - if( iBluetoothAttributes.iBluetoothSupported ) - { - dlg = CLoadGenBluetoothEditor::NewL(iBluetoothAttributes); - } - else - { - _LIT(message, "Bluetooth device not available"); - CAknErrorNote* errorNote = new(ELeave) CAknErrorNote; - errorNote->ExecuteLD(message); - return; - } - break; - } - case ELoadGenCmdNewLoadPointerEvent: - { - dlg = CLoadGenPointerEventEditor::NewL(iPointerEventAttributes); - break; - } - - default: - { - User::Panic(_L("Wrong new load"), 111); - break; - } - } - - TBool dlgResult = dlg->RunQueryLD(); - - // set back title - if (iMainContainer) - iMainContainer->SetDefaultTitlePaneTextL(); - - // start creating new load if dialog accepted - if (dlgResult) - { - DoStartNewLoadL(aCommand); - } - - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenModel::EditLoadL(CLoadBase* aItem) - { - // suspend current - aItem->Suspend(); - - // show new load query - CLoadGenLoadTypeEditorBase* dlg = NULL; - - switch ( aItem->Type() ) - { - case ELoadGenCmdNewLoadCPULoad: - { - dlg = CLoadGenCPULoadEditor::NewL(static_cast(aItem)->Attributes(), ETrue); - break; - } - case ELoadGenCmdNewLoadEatMemory: - { - dlg = CLoadGenMemoryEatEditor::NewL(static_cast(aItem)->Attributes(), ETrue); - break; - } - case ELoadGenCmdNewLoadPhoneCall: - { - dlg = CLoadGenPhoneCallEditor::NewL(static_cast(aItem)->Attributes(), ETrue); - break; - } - case ELoadGenCmdNewLoadNetConn: - { - dlg = CLoadGenNetConnEditor::NewL(static_cast(aItem)->Attributes(), ETrue); - break; - } - case ELoadGenCmdNewLoadKeyPress: - { - dlg = CLoadGenKeyPressEditor::NewL(static_cast(aItem)->Attributes(), ETrue); - break; - } - case ELoadGenCmdNewLoadMessages: - { - dlg = CLoadGenMessagesEditor::NewL(static_cast(aItem)->Attributes(), ETrue); - break; - } - case ELoadGenCmdNewLoadApplications: - { - dlg = CLoadGenApplicationsEditor::NewL( static_cast(aItem)->Attributes(), ETrue ); - break; - } - case ELoadGenCmdNewLoadPhotoCaptures: - { - dlg = CLoadGenPhotoCaptureEditor::NewL( static_cast(aItem)->Attributes(), ETrue ); - break; - } - case ELoadGenCmdNewLoadBluetooth: - { - dlg = CLoadGenBluetoothEditor::NewL( static_cast(aItem)->Attributes(), ETrue ); - break; - } - case ELoadGenCmdNewLoadPointerEvent: - { - dlg = CLoadGenPointerEventEditor::NewL(static_cast(aItem)->Attributes(), ETrue); - break; - } - default: - { - User::Panic(_L("Wrong edit load"), 114); - break; - } - } - - TBool dlgResult = dlg->RunQueryLD(); - - // set back title - if (iMainContainer) - iMainContainer->SetDefaultTitlePaneTextL(); - - // change priority of the load item - aItem->SetPriority(); - - // resume execution the item - aItem->Resume(); - - if (dlgResult) - RefreshViewL(EFalse); - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenModel::DoStartNewLoadL(TInt aCommand) - { - CLoadBase* item = NULL; - - switch ( aCommand ) - { - case ELoadGenCmdNewLoadCPULoad: - { - if( iCpuLoadAttributes.iCpu == KCPUSelection_AllCPUs ) - { - // Call this function recursively for all CPUs: - for( TUint i = 0; i < iCpuLoadAttributes.iCpuCount; ++i ) - { - iCpuLoadAttributes.iCpu = i; - DoStartNewLoadL(aCommand); - } - // And finally set user selection back to "All CPUs" - iCpuLoadAttributes.iCpu = KCPUSelection_AllCPUs; - return; - } - else - { - item = CCPULoad::NewL(iCpuLoadAttributes, iReferenceNumber); - } - break; - } - case ELoadGenCmdNewLoadEatMemory: - { - item = CMemoryEat::NewL(iMemoryEatAttributes, iReferenceNumber); - break; - } - case ELoadGenCmdNewLoadPhoneCall: - { - item = CPhoneCall::NewL(iPhoneCallAttributes, iReferenceNumber); - break; - } - case ELoadGenCmdNewLoadNetConn: - { - item = CNetConn::NewL(iNetConnAttributes, iReferenceNumber); - break; - } - case ELoadGenCmdNewLoadKeyPress: - { - item = CKeyPress::NewL(iKeyPressAttributes, iReferenceNumber); - break; - } - case ELoadGenCmdNewLoadMessages: - { - item = CMessages::NewL( iMessageAttributes, iReferenceNumber ); - break; - } - case ELoadGenCmdNewLoadApplications: - { - iApplicationsAttributes.iAppsArray = ListOfAllAppsL(); - item = CAppLauncher::NewL( iApplicationsAttributes, iReferenceNumber ); - break; - } - case ELoadGenCmdNewLoadPhotoCaptures: - { - item = CPhotoCapture::NewL( iPhotoCaptureAttributes, iReferenceNumber); - break; - } - case ELoadGenCmdNewLoadBluetooth: - { - item = CBluetooth::NewL( iBluetoothAttributes, iReferenceNumber); - break; - } - case ELoadGenCmdNewLoadPointerEvent: - { - item = CPointerEvent::NewL(iPointerEventAttributes, iReferenceNumber); - break; - } - - default: - { - User::Panic(_L("Wrong new load"), 112); - break; - } - } - - iReferenceNumber++; - - // add item to the array - AppendToLoadItemListL(item); - - // update the listbox - RefreshViewL(EFalse); - - // set item index to the end - iMainContainer->ListBox()->SetCurrentItemIndexAndDraw( iMainContainer->ListBox()->Model()->NumberOfItems()-1 ); - - // start the load - item->Resume(); - - // refresh again - RefreshViewL(EFalse); - } - -// -------------------------------------------------------------------------------------------- - - -void CLoadGenModel::StopAllLoadItemsL() - { - DeleteAllLoadItems(); - - RefreshViewL(); - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenModel::SuspendAllLoadItemsL() - { - for (TInt i=0; iAt(i) ) - { - iLoadItemList->At(i)->Suspend(); - } - } - - RefreshViewL(); - } -// -------------------------------------------------------------------------------------------- - -void CLoadGenModel::ResumeAllLoadItemsL() - { - for (TInt i=0; iAt(i) ) - { - iLoadItemList->At(i)->Resume(); - } - } - - RefreshViewL(); - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenModel::RefreshViewL(TBool aClearSelection) - { - if (iMainContainer && iDrawState == EDrawStateMain && iMainContainer->ListBox()) - { - // clear selections if any - iMainContainer->ListBox()->ClearSelection(); - - // set item index to 0 - if (aClearSelection) - iMainContainer->ListBox()->SetCurrentItemIndex(0); - - // set text items - iMainContainer->SetListBoxTextArrayL(GenerateListBoxItemTextArrayL()); - } - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenModel::AppendToLoadItemListL(CLoadBase* aItem) - { - if (iLoadItemList) - iLoadItemList->AppendL( aItem ); - else - User::Leave(KErrNotReady); - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenModel::DeleteFromLoadItemListL(TInt aIndex) - { - if (iLoadItemList) - { - if (iLoadItemList->Count() > aIndex && aIndex >= 0) - { - // first call delete on the item - if (iLoadItemList->At(aIndex)) - { - delete iLoadItemList->At(aIndex); - iLoadItemList->At(aIndex) = NULL; - } - - // and them remove the array entry - iLoadItemList->Delete(aIndex); - iLoadItemList->Compress(); - } - else - User::Leave(KErrNotFound); - } - else - User::Leave(KErrNotReady); - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenModel::SuspendOrResumeFromLoadItemListL(TInt aIndex) - { - if (iLoadItemList) - { - if (iLoadItemList->Count() > aIndex && aIndex >= 0) - { - if (iLoadItemList->At(aIndex)) - { - if (iLoadItemList->At(aIndex)->State() == CLoadBase::ELoadStateRunning) - { - iLoadItemList->At(aIndex)->Suspend(); - } - else if (iLoadItemList->At(aIndex)->State() == CLoadBase::ELoadStateSuspended) - { - iLoadItemList->At(aIndex)->Resume(); - } - } - } - else - User::Leave(KErrNotFound); - } - else - User::Leave(KErrNotReady); - } - -// -------------------------------------------------------------------------------------------- - -TInt CLoadGenModel::LoadItemCount() const - { - TInt count(0); - - if (iLoadItemList) - count = iLoadItemList->Count(); - - return count; - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenModel::DeleteAllLoadItems() - { - // call delete for each entry and free memory allocated for the array - for (TInt i=0; iAt(i) ) - { - delete iLoadItemList->At(i); - iLoadItemList->At(i) = NULL; - } - } - - iLoadItemList->Reset(); - } - -// -------------------------------------------------------------------------------------------- - -CDesCArray* CLoadGenModel::GenerateListBoxItemTextArrayL() - { - CDesCArray* textArray = new(ELeave) CDesCArrayFlat(64); - CleanupStack::PushL(textArray); - - _LIT(KEntryTemplateRedIcon, "1\t%S\t\t"); - _LIT(KEntryTemplateGreenIcon, "2\t%S\t\t"); - - for (TInt i=0; i textEntry; - TBuf<256> description = iLoadItemList->At(i)->Description(); - - if (iLoadItemList->At(i)->State() == CLoadBase::ELoadStateRunning) - textEntry.Format(KEntryTemplateGreenIcon, &description); - else - textEntry.Format(KEntryTemplateRedIcon, &description); - - textArray->AppendL(textEntry); - } - - CleanupStack::Pop(); //textArray - return textArray; - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenModel::ShowItemActionMenuL() - { - TInt currentItemIndex = iMainContainer->CurrentListBoxItemIndex(); - - if (LoadItemCount() > currentItemIndex && currentItemIndex >= 0) - { - // show a query dialog - TInt queryIndex(0); - CAknListQueryDialog* listQueryDlg = new(ELeave) CAknListQueryDialog(&queryIndex); - - if (listQueryDlg->ExecuteLD(R_ITEM_ACTION_QUERY)) - { - // stop - if (queryIndex == EItemActionMenuTypeStop) - { - StopSelectedOrHighlightedItemsL(); - } - - // suspend or resume - else if (queryIndex == EItemActionMenuTypeSuspendResume) - { - SuspendOrResumeSelectedOrHighlightedItemsL(); - } - - // edit - else if (queryIndex == EItemActionMenuTypeEdit) - { - EditLoadL(iLoadItemList->At(currentItemIndex)); - } - } - } - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenModel::StopSelectedOrHighlightedItemsL() - { - const CArrayFix* selectionIndexes = iMainContainer->ListBoxSelectionIndexes(); - - TInt err(KErrNone); - - // by default use selected items - if (selectionIndexes && selectionIndexes->Count() > 0) - { - CAknQueryDialog* query = CAknQueryDialog::NewL(); - _LIT(KQueryMessage, "Stop %d selections?"); - TFileName queryMsg; - queryMsg.Format(KQueryMessage, selectionIndexes->Count()); - - - if (query->ExecuteLD(R_GENERAL_CONFIRMATION_QUERY, queryMsg)) - { - TInt deleteIndexCounter(0); - TInt ref(0); - TKeyArrayFix key(0, ECmpTUint16); - TInt index(0); - - TInt loadCount = LoadItemCount(); - - for (TInt i=0; iFind(ref, key, index) == 0) - { - TRAP(err, DeleteFromLoadItemListL(i-deleteIndexCounter)); - deleteIndexCounter++; // amount of indexes decreases after each delete - } - } - - RefreshViewL(); - User::LeaveIfError(err); - } - } - - // or if none selected, use the current item index - else - { - TInt currentItemIndex = iMainContainer->CurrentListBoxItemIndex(); - - if (LoadItemCount() > currentItemIndex && currentItemIndex >= 0) - { - CAknQueryDialog* query = CAknQueryDialog::NewL(); - _LIT(KQueryMessage, "Stop hightlighted item?"); - - if (query->ExecuteLD(R_GENERAL_CONFIRMATION_QUERY, KQueryMessage)) - { - TRAP(err, DeleteFromLoadItemListL(currentItemIndex)); - - RefreshViewL(); - User::LeaveIfError(err); - } - } - } - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenModel::SuspendOrResumeSelectedOrHighlightedItemsL() - { - const CArrayFix* selectionIndexes = iMainContainer->ListBoxSelectionIndexes(); - - // by default use selected items - if (selectionIndexes && selectionIndexes->Count() > 0) - { - TInt ref(0); - TKeyArrayFix key(0, ECmpTUint16); - TInt index(0); - - for (TInt i=0; iFind(ref, key, index) == 0) - { - SuspendOrResumeFromLoadItemListL(i); - } - } - - RefreshViewL(EFalse); - } - - // or if none selected, use the current item index - else - { - TInt currentItemIndex = iMainContainer->CurrentListBoxItemIndex(); - - if (LoadItemCount() > currentItemIndex && currentItemIndex >= 0) - { - SuspendOrResumeFromLoadItemListL(currentItemIndex); - - RefreshViewL(EFalse); - } - } - } -// -------------------------------------------------------------------------------------------- - -void CLoadGenModel::LoadSettingsL() - { - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenModel::SaveSettingsL() - { - } - -// -------------------------------------------------------------------------------------------- - -TInt CLoadGenModel::LaunchSettingsDialogL() - { - return 0; - } - -// -------------------------------------------------------------------------------------------- - -CDesCArray* CLoadGenModel::ListOfAllAppsL() - { - const TInt KMaxAppsArraySize=250; - RApaLsSession ls; - CleanupClosePushL(ls); - - User::LeaveIfError( ls.Connect() ); - CDesCArray* allAppsArray = new(ELeave) CDesCArrayFlat( KMaxAppsArraySize ); - CleanupStack::PushL( allAppsArray ); - // reset the apps list - allAppsArray->Reset(); - - // search all apps - TApaAppInfo appInfo; - User::LeaveIfError(ls.GetAllApps()); - - - while ( ls.GetNextApp( appInfo ) == KErrNone ) - { - allAppsArray->AppendL( appInfo.iFullName ); - } - CleanupStack::Pop( allAppsArray ); - CleanupStack::PopAndDestroy( &ls ); - - - // remove loadgen.* from the list - for ( TInt i = 0; i < allAppsArray->MdcaCount(); i++ ) - { - if ( allAppsArray->MdcaPoint(i).FindF( _L("\\loadgen.") ) != KErrNotFound ) - { - allAppsArray->Delete(i); - allAppsArray->Compress(); - break; - } - } - - // sort the elements - allAppsArray->Sort(); - - return allAppsArray; // ownership transferred - } - -// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/ui/avkon/src/loadgen_settingsviewdlg.cpp --- a/loadgen/ui/avkon/src/loadgen_settingsviewdlg.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,323 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -// INCLUDE FILES -#include "loadgen_settingsviewdlg.h" -#include "loadgen_model.h" -#include "loadgen.hrh" -#include "loadgen_std.h" -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -// ===================================== MEMBER FUNCTIONS ===================================== - -CLoadGenSettingsViewDlg* CLoadGenSettingsViewDlg::NewL(TLoadGenSettings& aSettings) - { - CLoadGenSettingsViewDlg* self = new(ELeave) CLoadGenSettingsViewDlg(aSettings); - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(self); - return self; - } - -// -------------------------------------------------------------------------------------------- - -CLoadGenSettingsViewDlg::~CLoadGenSettingsViewDlg() - { - // restore default navi pane - if (iNaviContainer) - iNaviContainer->Pop(); - - if (iSettingItemArray) - { - iSettingItemArray->ResetAndDestroy(); - delete iSettingItemArray; - } - - delete iDecoratedTabGroup; - } - -// -------------------------------------------------------------------------------------------- - -CLoadGenSettingsViewDlg::CLoadGenSettingsViewDlg(TLoadGenSettings& aSettings) : iSettings(aSettings) - { - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenSettingsViewDlg::ConstructL() - { - // construct a menu bar - CAknDialog::ConstructL(R_LOADGEN_SETTINGS_MENUBAR); - - CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane(); - - // set empty navi pane label - iNaviContainer = static_cast(sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi))); - //iNaviContainer->PushDefaultL(); - - // set title text - CAknTitlePane* tp = static_cast( sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); - tp->SetTextL( _L("Settings") ); - - // create a tab group - iDecoratedTabGroup = iNaviContainer->CreateTabGroupL(this); - iTabGroup = static_cast(iDecoratedTabGroup->DecoratedControl()); - iTabGroup->SetTabFixedWidthL(KTabWidthWithTwoLongTabs); - - // add tabs - //iTabGroup->AddTabL(ETabGeneral, _L("General")); - //iTabGroup->AddTabL(ETabScreenShot, _L("Screen shot")); - //iTabGroup->SetActiveTabByIndex(ETabGeneral); - - iNaviContainer->PushL( *iDecoratedTabGroup ); - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenSettingsViewDlg::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aEventType) - { - switch (aEventType) - { - case EEventEnterKeyPressed: - case EEventItemDoubleClicked: - ShowSettingPageL(EFalse); - break; - default: - break; - } - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenSettingsViewDlg::TabChangedL(TInt /*aIndex*/) - { - iListBox->SetCurrentItemIndex(0); - - SetVisibilitiesOfSettingItemsL(); - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenSettingsViewDlg::ProcessCommandL(TInt aCommandId) - { - CAknDialog::ProcessCommandL(aCommandId); - - switch (aCommandId) - { - case ELoadGenCmdSettingsChange: - ShowSettingPageL(ETrue); - break; - case ELoadGenCmdSettingsExit: - TryExitL(EAknCmdExit); - break; - default: - break; - } - } - -// -------------------------------------------------------------------------------------------- - -TKeyResponse CLoadGenSettingsViewDlg::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType) - { - if (iTabGroup == NULL) - { - return EKeyWasNotConsumed; - } - - TInt active = iTabGroup->ActiveTabIndex(); - TInt count = iTabGroup->TabCount(); - - switch ( aKeyEvent.iCode ) - { - case EKeyLeftArrow: - if (active > 0) - { - active--; - iTabGroup->SetActiveTabByIndex(active); - TabChangedL(active); - } - break; - - case EKeyRightArrow: - if((active + 1) < count) - { - active++; - iTabGroup->SetActiveTabByIndex(active); - TabChangedL(active); - } - break; - } - - return CAknDialog::OfferKeyEventL(aKeyEvent, aType); - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenSettingsViewDlg::PreLayoutDynInitL() - { - iListBox = static_cast( Control(ELoadGenSettingItemList) ); - iListBox->SetMopParent(this); - iListBox->CreateScrollBarFrameL(ETrue); - iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto); - iListBox->SetListBoxObserver(this); - - iSettingItemArray = new(ELeave) CAknSettingItemArray(16, EFalse, 0); - - CTextListBoxModel* model = iListBox->Model(); - model->SetItemTextArray(iSettingItemArray); - model->SetOwnershipType(ELbmDoesNotOwnItemArray); - - UpdateListBoxL(); - } - -// -------------------------------------------------------------------------------------------- - -TBool CLoadGenSettingsViewDlg::OkToExitL(TInt aButtonId) - { - return CAknDialog::OkToExitL(aButtonId); - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenSettingsViewDlg::ShowSettingPageL(TInt aCalledFromMenu) - { - TInt listIndex = iListBox->CurrentItemIndex(); - TInt realIndex = iSettingItemArray->ItemIndexFromVisibleIndex(listIndex); - CAknSettingItem* item = iSettingItemArray->At(realIndex); - item->EditItemL(aCalledFromMenu); - item->StoreL(); - SetVisibilitiesOfSettingItemsL(); - DrawNow(); - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenSettingsViewDlg::SetVisibilitiesOfSettingItemsL() - { - if (iSettingItemArray->Count() > 0) - { -/* - switch (iTabGroup->ActiveTabIndex()) - { - - case ETabGeneral: - { - ((*iSettingItemArray)[ESettingListDisplayModeSelection])->SetHidden(EFalse); - ((*iSettingItemArray)[ESettingListFileViewModeSelection])->SetHidden(EFalse); - break; - } - - case ETabScreenShot: - { - ((*iSettingItemArray)[ESettingListDisplayModeSelection])->SetHidden(ETrue); - ((*iSettingItemArray)[ESettingListFileViewModeSelection])->SetHidden(ETrue); - break; - } - - default: - User::Panic(_L("TabIOOB"), 50); - break; - } -*/ - iSettingItemArray->RecalculateVisibleIndicesL(); - iListBox->HandleItemAdditionL(); - iListBox->UpdateScrollBarsL(); - } - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenSettingsViewDlg::UpdateListBoxL() - { - iSettingItemArray->ResetAndDestroy(); - -/* - // create items - TInt ordinal(0); - - AddSettingItemL(ESettingListDisplayModeSelection, - R_DISPLAYMODESELECTION_SETTING_TITLE, - R_DISPLAYMODESELECTION_SETTING_PAGE, - R_DISPLAYMODESELECTION_SETTING_TEXTS, - ordinal++); - - AddSettingItemL(ESettingListFileViewModeSelection, - R_FILEVIEWMODESELECTION_SETTING_TITLE, - R_FILEVIEWMODESELECTION_SETTING_PAGE, - R_FILEVIEWMODESELECTION_SETTING_TEXTS, - ordinal++); -*/ - SetVisibilitiesOfSettingItemsL(); - } - -// -------------------------------------------------------------------------------------------- - -void CLoadGenSettingsViewDlg::AddSettingItemL(TInt aId, - TInt aTitleResource, - TInt aSettingPageResource, - TInt aAssociatedResource, - TInt aOrdinal) - { - // create a setting item - CAknSettingItem* settingItem = NULL; - - switch (aId) - { -/* - case ESettingListDisplayModeSelection: - settingItem = new(ELeave) CAknEnumeratedTextPopupSettingItem(aId, iSettings.iDisplayMode); - break; - - case ESettingListFileViewModeSelection: - settingItem = new(ELeave) CAknEnumeratedTextPopupSettingItem(aId, iSettings.iFileViewMode); - break; - - default: - User::Panic(_L("NotSetItem"), 50); - break; -*/ - } - - CleanupStack::PushL(settingItem); - - // get title text - HBufC* itemTitle = StringLoader::LoadLC(aTitleResource); - - // construct the setting item - settingItem->ConstructL(EFalse, aOrdinal, *itemTitle, NULL, aSettingPageResource, - EAknCtPopupSettingList, NULL, aAssociatedResource); - - // append the setting item to settingitem array - iSettingItemArray->InsertL(aOrdinal, settingItem); - - CleanupStack::PopAndDestroy(); //itemTitle - CleanupStack::Pop(); //settingItem - } - -// -------------------------------------------------------------------------------------------- - -// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/ui/hb/hb.pro --- a/loadgen/ui/hb/hb.pro Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,105 +0,0 @@ -# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# This component and the accompanying materials are made available -# under the terms of "Eclipse Public License v1.0" -# which accompanies this distribution, and is available -# at the URL "http://www.eclipse.org/legal/epl-v10.html". -# Initial Contributors: -# Nokia Corporation - initial contribution. -# Contributors: -# Description: -TEMPLATE = app -TARGET = LoadGen -DEPENDPATH += . -INCLUDEPATH += . \ - /inc -INCLUDEPATH += ./inc \ - ../../engine/inc -load(hb.prf) -symbian:CONFIG -= symbian_i18n -HEADERS += inc/mainview.h \ - inc/settingsview.h \ - inc/notifications.h -SOURCES += src/main.cpp \ - src/mainview.cpp \ - src/settingsview.cpp \ - src/notifications.cpp -RESOURCES += loadgen.qrc -symbian: { - MMP_RULES -= PAGED - MMP_RULES *= UNPAGED - BLD_INF_RULES.prj_exports += "./rom/loadgen.iby CORE_IBY_EXPORT_PATH(tools,loadgen.iby)" - INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE - INCLUDEPATH += /epoc32/include/mw/http - HEADERS += inc/engine.h \ - inc/enginewrapper.h - SOURCES += src/engine.cpp \ - src/enginewrapper.cpp \ - ../../engine/src/loadgen_utils.cpp \ - ../../engine/src/loadgen_loadbase.cpp \ - ../../engine/src/loadgen_cpuload.cpp \ - ../../engine/src/loadgen_memoryeat.cpp \ - ../../engine/src/loadgen_phonecall.cpp \ - ../../engine/src/loadgen_keypress.cpp \ - ../../engine/src/loadgen_messages.cpp \ - ../../engine/src/loadgen_applications.cpp \ - ../../engine/src/loadgen_photocapture.cpp \ - ../../engine/src/loadgen_bluetooth.cpp \ - ../../engine/src/loadgen_pointerevent.cpp \ - ../../engine/src/loadgen_netconn.cpp \ - ../../engine/src/loadgen_httpreceiver.cpp - RSS_RULES += "group_name = \"RnD Tools\""; - LIBS += -leuser \ - -lcommonengine \ - -lapparc \ - -lcone \ - -leikcore \ - -leikcoctl \ - -leikctl \ - -leikdlg \ - -lws32 \ - -lapgrfx \ - -lefsrv \ - -lbafl \ - -lgdi \ - -legul \ - -letel3rdparty \ - -lcommdb \ - -lflogger \ - -lestor \ - -lmsgs \ - -lsmcm \ - -lgsmu \ - -letext \ - -lsendas2 \ - -lecam \ - -lfeatdiscovery \ - -lcentralrepository \ - -lesock \ - -lbluetooth \ - -lhal \ - -lhttp \ - -linetprotutil - TARGET.CAPABILITY = swevent \ - ReadUserData \ - WriteUserData \ - NetworkServices \ - UserEnvironment \ - CAP_APPLICATION \ - AllFiles - TARGET.UID2 = 0x100039CE - TARGET.UID3 = 0x20011384 - // TARGET.SID = 0x20011384 - TARGET.VID = 0x101FB657 \ - // \ - Nokia - TARGET.EPOCHEAPSIZE = 0x10000 \ - 0x1000000 \ - // \ - Min \ - 64Kb, \ - Max \ - 16Mb - ICON = ../../icons/qgn_menu_loadgen.svg -} -else:error("Only Symbian supported!") diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/ui/hb/inc/engine.h --- a/loadgen/ui/hb/inc/engine.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,149 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#ifndef LOADGEN_MODEL_H -#define LOADGEN_MODEL_H - -// INCLUDES -#include -#include -#include - -#include "loadgen_loadattributes.h" -#include "loadgen_loadbase.h" - -// FORWARD DECLARATIONS -class EngineWrapper; -class MainView; -class CLoadGenGraphsContainer; -class CEikonEnv; -//class CLoadBase; - - -typedef CArrayFixSeg CLoadItemList; - -const TUint KMaxCPUs = 4; - -// CLASS DECLARATIONS - -class TLoadGenSettings - { -public: - }; - -class CEngine : public CActive - { -private: - enum TContainerDrawState - { - EDrawStateInvalid = -1, - EDrawStateMain - }; - -public: - static CEngine* NewL(EngineWrapper *aEngineWrapper); - ~CEngine(); - void ActivateEngineL(); - void DeActivateEngineL(); - void LaunchPerfMonL(); - void EditLoadL(TInt aIndex); - void ExistingLoadEditedL(); - void ExistingLoadEditCancelled(); - -private: - void RunL(); - void DoCancel(); - -private: - CEngine(); - void ConstructL(EngineWrapper *aEngineWrapper); - void LoadSettingsL(); - void AppendToLoadItemListL(CLoadBase* aItem); - void DeleteFromLoadItemListL(TInt aIndex); - void SuspendOrResumeFromLoadItemListL(TInt aIndex); - void DeleteAllLoadItems(); - void RefreshViewL(TBool aClearSelection=ETrue); - CDesCArray* ListOfAllAppsL(); - -public: - void StopAllLoadItemsL(); - void SuspendAllLoadItemsL(); - void ResumeAllLoadItemsL(); - - TInt LoadItemCount() const; - void StopSelectedOrHighlightedItemsL(const CArrayFix* aSelectionIndexes); - void SuspendOrResumeSelectedOrHighlightedItemsL(); - - CDesCArray* GenerateListBoxItemTextArrayL(); - void StartNewLoadL(TInt aCommand); - void DoStartNewLoadL(TInt aCommand); - void SaveSettingsL(); - TInt LaunchSettingsDialogL(); - TCPULoadAttributes GetCPULoadAttributes(); - TMemoryEatAttributes GetMemoryEatAttributes(); - TPhoneCallAttributes GetPhoneCallAttributes(); - TNetConnAttributes GetNetConnAttributes(); - TKeyPressAttributes GetKeyPressAttributes(); - TMessageAttributes GetMessageAttributes(); - TApplicationsAttributes GetApplicationsAttributes(); - TPhotoCaptureAttributes GetPhotoCaptureAttributes(); - TBluetoothAttributes GetBluetoothAttributes(); - TPointerEventAttributes GetPointerEventAttributes(); - void ChangeCPULoadAttributes(const TCPULoadAttributes& aAttributes); - void ChangeMemoryEatAttributes(const TMemoryEatAttributes& aAttributes); - void ChangePhoneCallAttributes(const TPhoneCallAttributes& aAttributes); - void ChangeNetConnAttributes(const TNetConnAttributes& aAttributes); - void ChangeKeyPressAttributes(const TKeyPressAttributes& aAttributes); - void ChangeMessageAttributes(const TMessageAttributes& aAttributes); - void ChangeApplicationsAttributes(const TApplicationsAttributes& aAttributes); - void ChangePhotoCaptureAttributes(const TPhotoCaptureAttributes& aAttributes); - void ChangeBluetoothAttributes(const TBluetoothAttributes& aAttributes); - void ChangePointerEventAttributes(const TPointerEventAttributes& aAttributes); - - inline TLoadGenSettings& Settings() { return iSettings; } - inline CEikonEnv* EikonEnv() { return iEnv; } - inline RApaLsSession& LsSession() { return iLs; } - inline TBool LoadItemsExists() { return iLoadItemList->Count() > 0; } - - -private: - RTimer iTimer; - CEikonEnv* iEnv; - TLoadGenSettings iSettings; - RApaLsSession iLs; - CLoadItemList* iLoadItemList; - TInt iReferenceNumber; - TCPULoadAttributes iCpuLoadAttributes; - TMemoryEatAttributes iMemoryEatAttributes; - TPhoneCallAttributes iPhoneCallAttributes; - TNetConnAttributes iNetConnAttributes; - TKeyPressAttributes iKeyPressAttributes; - TMessageAttributes iMessageAttributes; - TApplicationsAttributes iApplicationsAttributes; - TPhotoCaptureAttributes iPhotoCaptureAttributes; - TBluetoothAttributes iBluetoothAttributes; - TPointerEventAttributes iPointerEventAttributes; - EngineWrapper* iEngineWrapper; // used for communicating between QT and Symbian - TInt iCurrentItemIndex; - TBool iEditExistingLoad; - CLoadBase::TLoadState iLoadStatusBeforeEdit; - }; - - -#endif - diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/ui/hb/inc/enginewrapper.h --- a/loadgen/ui/hb/inc/enginewrapper.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,282 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef ENGINEWRAPPER_H -#define ENGINEWRAPPER_H - -#include -#include -#include -#include -#include "loadgen.hrh" - -#include - -class HbMainWindow; -class HbAction; -class MainView; -class SettingsView; -class CPULoadAttributes; -class MemoryEatAttributes; -class PhoneCallAttributes; -class NetConnAttributes; -class KeyPressAttributes; -class PointerEventAttributes; -class MessageAttributes; -class ApplicationsAttributes; -class PhotoCaptureAttributes; -class BluetoothAttributes; - -/** - * class that is used for communicating between Symbian and Qt code. - */ -class EngineWrapper : public QObject - { - Q_OBJECT - -public: - - /** - * Constructor - */ - EngineWrapper(HbMainWindow &mainWindow, MainView &mainView); - - /** - * Destructor - */ - ~EngineWrapper(); - - /** - * Initializes Engine Wrapper - * @return true if engine was started successfully - */ - bool init(); - -public slots: - void StopLoadYesNoDialogClosed(HbAction *action); - void loadAddedOrEdited(TLoadGenCommandIds cmdId); - void loadSettingsCanclled(); - -public: - - /* Functions that are called from UI: */ - - /** - * Start new load - */ - bool startNewLoad(int commandId); - - /** - * Launch Performance Monitor application. - */ - void launchPerfMonApp(); - - /** - * Edit operation for load settings - */ - void loadEdit(int rowIndex); - - /** - * CPU load attributes - */ - CPULoadAttributes getCpuLoadAttributes(); - - /** - * Memory eat attributes - */ - MemoryEatAttributes getMemoryEatAttributes(); - - /** - * Phone call attributes - */ - PhoneCallAttributes getPhoneCallAttributes(); - - /** - * Network connection attributes - */ - NetConnAttributes getNetConnAttributes(); - - /** - * Key presses attributes - */ - KeyPressAttributes getKeyPressAttributes(); - - /** - * Pointer event attributes - */ - PointerEventAttributes getPointerEventAttributes(); - - /** - * Message attributes - */ - MessageAttributes getMessageAttributes(); - - /** - * Applications attributes - */ - ApplicationsAttributes getApplicationsAttributes(); - - /** - * Photo capture attributes - */ - PhotoCaptureAttributes getPhotoCaptureAttributes(); - - /** - * BT attributes - */ - BluetoothAttributes getBluetoothAttributes(); - - /** - * Set attributes for CPU load - */ - void setCpuLoadAttributes(const CPULoadAttributes& attributes); - - /** - * Set attributes for memory eat - */ - void setMemoryEatAttributes(const MemoryEatAttributes& attributes); - - /** - * Set attributes for phone call - */ - void setPhoneCallAttributes(const PhoneCallAttributes& attributes); - - /** - * Set attributes for network connection - */ - void setNetConnAttributes(const NetConnAttributes& attributes); - - /** - * Set attributes for key presses - */ - void setKeyPressAttributes(const KeyPressAttributes& attributes); - - /** - * Set pointer event for messages - */ - void setPointerEventAttributes(const PointerEventAttributes& attributes); - - /** - * Set message attributes - */ - void setMessageAttributes(const MessageAttributes& attributes); - - /** - * Set applications attributes - */ - void setApplicationsAttributes(const ApplicationsAttributes& attributes); - - /** - * Set photo capture attributes - */ - void setPhotoCaptureAttributes(const PhotoCaptureAttributes& attributes); - - /** - * Set BT attributes - */ - void setBluetoothAttributes(const BluetoothAttributes& attributes); - - /** - * Stop load - */ - bool stopLoad(bool stopAll); - - /** - * Resume all loads - */ - void resumeAllLoadItems(); - - /** - * Suspend all loads - */ - void suspendAllLoadItems(); - - /** - * Suspend or resume selected/highlighted item from load list. - */ - void suspendOrResumeSelectedOrHighlightedItems(); - -public: - - /* Functions that are called from engine: */ - - /** - * uses Notifications class to show error message - */ - void ShowErrorMessage(const TDesC& aErrorMessage); - - /** - * uses Notifications class to show user note - */ - void ShowNote(const TDesC& aNoteMessage); - - /** - * Query item index - * @return selected row in load list view - */ - TInt QueryCurrentItemIndex(); - - /** - * selected indexes - */ - const CArrayFix* QueryListSelectedIndexesOrCurrentItemL(); - - /** - * Open settings for load. - */ - void OpenLoadSettings(TInt loadType, bool editExistingLoad); - - void ReFreshView(CDesCArray* aTextArray); - /** - * Clear load list selection(s) in Ui - */ - void ClearSelection(); - - /** - * Set current index in load list - */ - void SetCurrentItemIndex(TInt aIndex); - -public: - inline MainView& ViewReference() { return mMainView; }; - inline HbMainWindow& WindowReference() { return mMainWindow; }; - -private: - - enum LoadTypes { - Cpu, - EatMemory, - PhoneCalls, - Messages, - NWConnections, - KeyPresses, - Apps, - Photos, - BTAct, - PointerEvents - }; - - - /* LoadGen engine */ - CEngine* mEngine; - - MainView &mMainView; - HbMainWindow &mMainWindow; - bool mEditExistingLoad; -}; - -#endif //ENGINEWRAPPER_H diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/ui/hb/inc/mainview.h --- a/loadgen/ui/hb/inc/mainview.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,103 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#ifndef MAINVIEW_H -#define MAINVIEW_H - -#include - -class EngineWrapper; -class HbMainWindow; -class HbApplication; -class HbAction; -class HbLabel; -class HbProgressNote; -class HbListView; -class HbAbstractViewItem; - -class QStandardItemModel; -class QSignalMapper; -class QPointF; - -class MainView : public HbView -{ - Q_OBJECT - -public: - - MainView(HbMainWindow &mainWindow); - ~MainView(); - void init(HbApplication &app); - int currentItemIndex(); - void setCurrentItemIndex(int index); - void clearListSelection(); - void setLoadListData(QStringList& items); - QList listSelectionIndexes(); - -private: - void createMenu(HbApplication &app); - void loadListIinit(); - bool showItemActionPopup(int &index); - void loadListDelete(); - bool stopLoad(bool stopAll /*, int selectedLoad = 0*/); - -private slots: - void handleLoadListEvent(HbAbstractViewItem */*listViewItem*/, const QPointF &/*coords*/); - void ItemActionPopupClosed(HbAction* action ); - void showAboutPopup(); - void stopAllLoads(); - void updateMenu(); - void launchPerfMon(); - void suspendAllLoads(); - void resumeAllLoads(); - - /** - * calls engine wrapper to complete service request, specified by cmd. - */ - void executeMenuCommand(int cmd); - -private: - HbMainWindow &mMainWindow; - EngineWrapper *mEngineWrapper; - HbListView *mListView; - QStandardItemModel *mListModel; - QSignalMapper *mSm; - bool mIsLoadListEmpty; - - HbAction *mActionAbout; - HbMenu *mLoadSubMenu1; - HbMenu *mLoadSubMenu2; - HbAction *mActionExit; - HbAction *mStopAll; - HbAction *mSuspendAll; - HbAction *mResumeAll; - HbAction *mActionPerfMon; - HbAction *mCpuLoadAction; - HbAction *mMemoryEatLoadAction; - HbAction *mPhoneCallLoadAction; - HbAction *mMessagesLoadAction; - HbAction *mNetConnLoadAction; - HbAction *mAppsLoadAction; - HbAction *mKeyPressLoadAction; - HbAction *mPhotoCapturesLoadAction; - HbAction *mBtActionsLoadAction; - HbAction *mPointerEventsLoadAction; - -}; - -#endif // MAINVIEW_H diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/ui/hb/inc/notifications.h --- a/loadgen/ui/hb/inc/notifications.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#ifndef NOTIFICATIONS_H_ -#define NOTIFICATIONS_H_ - -#include - - -class Notifications : public HbPopup - { - - Q_OBJECT - -public: - - /** - * shows about box - */ - static void about(); - - /** - * shows error message - */ - static void error(const QString& errorMessage); - - /** - * shows global HbGlobalCommonNote type note - */ - static void showGlobalNote(const QString& text, HbMessageBox::MessageBoxType type, HbPopup::DefaultTimeout timeout = HbPopup::ConfirmationNoteTimeout); - }; - - - -#endif // NOTIFICATIONS_H_ diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/ui/hb/inc/settingsview.h --- a/loadgen/ui/hb/inc/settingsview.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,253 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#ifndef SETTINGSVIEW_H -#define SETTINGSVIEW_H - -#include -#include -#include "loadgen.hrh" - -class EngineWrapper; -class HbDataFormModelItem; -class HbDataFormModel; -class HbDataForm; -class HbDataFormViewItem; -class HbRadioButtonList; - -class CPULoadAttributes - { -public: - uint mId; - uint mPriority; - uint mMode; - uint mType; - uint mLength; - uint mIdle; - uint mRandomVariance; - int mCpu; - uint mCpuCount; - }; - -class MemoryEatAttributes - { -public: - uint mId; - uint mPriority; - uint mSource; - uint mType; - uint mBuffer; - uint mIdle; - qint64 mAmount; - qint64 mRandomMin; - qint64 mRandomMax; - QString mAmountDes; - QString mRandomMinDes; - QString mRandomMaxDes; - uint mRandomVariance; - }; - -class PhoneCallAttributes - { -public: - uint mId; - uint mPriority; - QString mDestination; - uint mLength; - uint mIdle; - uint mRandomVariance; - }; - -class NetConnAttributes - { -public: - uint mId; - uint mPriority; - QString mDestination; - uint mIdle; - uint mRandomVariance; - }; - -class KeyPressAttributes - { -public: - uint mId; - uint mPriority; - uint mHeartBeat; - uint mRandomVariance; - }; - -class PointerEventAttributes - { -public: - uint mId; - uint mPriority; - uint mHeartBeat; - uint mRandomVariance; - }; - -class MessageAttributes - { -public: - uint mId; - int mMessageType; - QString mDestination; - uint mPriority; - uint mAmount; - int mLength; - uint mIdle; - uint mRandomVariance; - }; - -class ApplicationsAttributes - { -public: - uint mId; - uint mPriority; - uint mLaunchingInterval; - uint mKeyPressType; - uint mMaxOpen; - uint mHeartBeat; - uint mRandomVariance; - QStringList mAppsArray; - - }; - - -class PhotoCaptureAttributes - { -public: - uint mId; - int mPriority; - int mCameraCount; - int mCamera; - uint mIdle; - uint mRandomVariance; - }; - -class BluetoothAttributes - { -public: - uint mId; - int mPriority; - uint mIdle; - uint mRandomVariance; - bool mBluetoothSupported; - }; - - -class SettingsView : public HbView -{ - Q_OBJECT - -public: - SettingsView(HbView &mainView, HbMainWindow &parent, EngineWrapper &engine); - ~SettingsView(); - void open(const QString &settingsName, TLoadGenCommandIds cmdId); - -signals: - void loadCompleted(TLoadGenCommandIds cmdId); - void loadCanclled(); - -private slots: - void backButtonPressed(); - void okExit(); - void cancelled(); - void selectionChanged(int index); - void dataItemDisplayed(const QModelIndex &index); - -private: - void createItems(HbDataFormModel *model, HbDataFormModelItem *parent); - void createCpuLoadItems(HbDataFormModel *model, HbDataFormModelItem *parent); - void createEatMemoryItems(HbDataFormModel *model, HbDataFormModelItem *parent); - void createPhoneCallItems(HbDataFormModel *model, HbDataFormModelItem *parent); - void createNetConnItems(HbDataFormModel *model, HbDataFormModelItem *parent); - void createKeyOrPointerItems(HbDataFormModel *model, HbDataFormModelItem *parent); - void createMessageItems(HbDataFormModel *model, HbDataFormModelItem *parent); - void createAppsItems(HbDataFormModel *model, HbDataFormModelItem *parent); - void createPhotoItems(HbDataFormModel *model, HbDataFormModelItem *parent); - void createBtItems(HbDataFormModel *model, HbDataFormModelItem *parent); - void loadAttributes(); - void saveSettings(); - void saveCpuLoadSettings(); - void saveEatMemorySettings(); - void savePhoneCallSettings(); - void saveNetConnSettings(); - void saveKeyPressSettings(); - void saveMessageSettings(); - void savePointerEventSettings(); - void saveApplicationsSettings(); - void savePhotoSettings(); - void saveBtSettings(); - void exit(); - void setDefaultSettings(); - void setLoadAttributes(); - -private: - HbMainWindow &mMainWindow; - HbView &mMainView; - EngineWrapper &mEngineWrapper; - TLoadGenCommandIds mCmdId; - - /* Setting form */ - HbDataForm *mSettingForm; - - /* Model for Setting form */ - HbDataFormModel *mModel; - - /* Components for the model: */ - - /* grouped load settings */ - HbDataFormModelItem *mLoadSettings; - - HbDataFormModelItem *mPriority; - HbDataFormModelItem *mLoadMode; - HbDataFormModelItem *mSource; - HbDataFormModelItem *mType; - HbDataFormModelItem *mAmount; - HbDataFormModelItem *mMinAmountToBeLeft; - HbDataFormModelItem *mMaxAmountToBeLeft; - HbDataFormModelItem *mBuffer; - HbDataFormModelItem *mLength; - HbDataFormModelItem *mDestination; - HbDataFormModelItem *mIdle; - HbDataFormModelItem *mHeartBeat; - HbDataFormModelItem *mRandomVar; - HbDataFormModelItem *mMaxParallelApps; - HbDataFormModelItem *mLaunchingInterval; - HbDataFormModelItem *mKeyPressType; - HbDataFormModelItem *mCamera; - HbDataFormModelItem *mCpu; - - HbRadioButtonList *mModes; - HbRadioButtonList *mTypes; - - /* load attributes for each load type*/ - CPULoadAttributes mCPULoadAttributes; - MemoryEatAttributes mMemoryEatAttributes; - PhoneCallAttributes mPhoneCallAttributes; - NetConnAttributes mNetConnAttributes; - KeyPressAttributes mKeyPressAttributes; - PointerEventAttributes mPointerEventAttributes; - MessageAttributes mMessageAttributes; - ApplicationsAttributes mApplicationsAttributes; - PhotoCaptureAttributes mPhotoCaptureAttributes; - BluetoothAttributes mBluetoothAttributes; -}; - -#endif // SETTINGSVIEW_H diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/ui/hb/loadgen.qrc --- a/loadgen/ui/hb/loadgen.qrc Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ - - - ..\..\icons\qgn_menu_loadgen.svg - ..\..\icons\qgn_prob_status_green.svg - ..\..\icons\qgn_prob_status_red.svg - - diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/ui/hb/rom/loadgen.iby --- a/loadgen/ui/hb/rom/loadgen.iby Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#ifndef __LOADGEN_IBY__ -#define __LOADGEN_IBY__ - -S60_APP_EXE(LoadGen) -S60_APP_AIF_ICONS(LoadGen) -S60_APP_RESOURCE(LoadGen) -SCALABLE_IMAGE(APP_BITMAP_DIR,APP_BITMAP_DIR,LoadGen_ExtraIcons) -SCALABLE_IMAGE(APP_BITMAP_DIR,APP_BITMAP_DIR,LoadGen) - -//#ifdef S60_UPGRADABLE_APP_REG_RSC -// S60_UPGRADABLE_APP_REG_RSC(LoadGen) -//#else -// S60_APP_AIF_RSC(LoadGen) -//#endif - -data=ZPRIVATE\10003a3f\import\APPS\LoadGen_reg.RSC Private\10003a3f\import\Apps\LoadGen_reg.rsc - -data=ZPRIVATE\20011384\backup_registration.xml private\20011384\backup_registration.xml -data=ZSYSTEM\Install\LoadGen_stub.sis \system\install\LoadGen_stub.sis - -#endif // __LOADGEN_IBY__ diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/ui/hb/src/engine.cpp --- a/loadgen/ui/hb/src/engine.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1240 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -// INCLUDE FILES -#include "engine.h" -#include "enginewrapper.h" -#include "settingsview.h" -#include "loadgen_utils.h" -#include "loadgen_cpuload.h" -#include "loadgen_memoryeat.h" -#include "loadgen_phonecall.h" -#include "loadgen_netconn.h" -#include "loadgen_keypress.h" -#include "loadgen_pointerevent.h" -#include "loadgen_messages.h" -#include "loadgen_applications.h" -#include "loadgen_photocapture.h" -#include "loadgen_bluetooth.h" -#include "loadgen_traces.h" -#include "loadgen_loadattributes.h" -#include "loadgen.hrh" - -//#include "loadgen_editors.h" -//#include "loadgen_app.h" -//#include "loadgen_settingsviewdlg.h" -//#include "loadgen_maincontainer.h" - -//#include - -#include -#include -#include -//#include -#include -#include -#include -#include - -#include -//#include -#include - -const TInt KZeroIndex = 0; - -// ===================================== MEMBER FUNCTIONS ===================================== - -CEngine* CEngine::NewL(EngineWrapper *aEngineWrapper) - { - CEngine* self = new(ELeave) CEngine; - CleanupStack::PushL(self); - self->ConstructL(aEngineWrapper); - CleanupStack::Pop(); - return self; - } - -// -------------------------------------------------------------------------------------------- - -CEngine::CEngine() : CActive(EPriorityStandard) - { - } - -// -------------------------------------------------------------------------------------------- - -void CEngine::ConstructL(EngineWrapper *aEngineWrapper) - { - iEngineWrapper = aEngineWrapper; - - iReferenceNumber = 0; - iCurrentItemIndex = 0; - iEditExistingLoad = EFalse; - - iEnv = CEikonEnv::Static(); - User::LeaveIfError(iLs.Connect()); - - iLoadItemList = new(ELeave) CLoadItemList(64); - - User::LeaveIfError(iTimer.CreateLocal()); - CActiveScheduler::Add(this); - - } - -// -------------------------------------------------------------------------------------------- - -void CEngine::ActivateEngineL() - { - // load settings - //TRAP_IGNORE(LoadSettingsL()); - - // RAM - TMemoryInfoV1Buf ramMemory; - UserHal::MemoryInfo(ramMemory); - - TInt freeRam = ramMemory().iFreeRamInBytes; - - - // set defaults to attributes - iCpuLoadAttributes.iId = 0; - iCpuLoadAttributes.iPriority = EThreadPriorityTypeNormal; - iCpuLoadAttributes.iMode = ECpuLoadModeYielding; - iCpuLoadAttributes.iType = ECpuLoadTypePeriodic; - iCpuLoadAttributes.iLength = 4000; - iCpuLoadAttributes.iIdle = 2000; - iCpuLoadAttributes.iRandomVariance = 0; - iCpuLoadAttributes.iCpu = KCPUSelection_FreeScheduling; // set CPU as "undefined" (can be >= 0 only in SMP environments) - iCpuLoadAttributes.iCpuCount = UserSvr::HalFunction(EHalGroupKernel, KHalFunction_EKernelHalNumLogicalCpus, 0, 0); - if( iCpuLoadAttributes.iCpuCount < 1 || iCpuLoadAttributes.iCpuCount > KMaxCPUs ) - { - // HAL may not support this function, so let's use CPU count 1: - iCpuLoadAttributes.iCpuCount = 1; - } - iMemoryEatAttributes.iId = 0; - iMemoryEatAttributes.iPriority = EThreadPriorityTypeNormal; - iMemoryEatAttributes.iSource = 0; - iMemoryEatAttributes.iType = EMemoryEatTypeMemoryToBeLeft; - iMemoryEatAttributes.iBuffer = 16*1024; - iMemoryEatAttributes.iIdle = 0; - iMemoryEatAttributes.iAmount = freeRam;//0; - iMemoryEatAttributes.iRandomMin = 1000000; - iMemoryEatAttributes.iRandomMax = 1500000; - iMemoryEatAttributes.iAmountDes.Copy(KNullDesC); - iMemoryEatAttributes.iRandomMinDes.Copy(KNullDesC); - iMemoryEatAttributes.iRandomMaxDes.Copy(KNullDesC); - iMemoryEatAttributes.iRandomVariance = 0; - - iPhoneCallAttributes.iId = 0; - iPhoneCallAttributes.iPriority = EThreadPriorityTypeNormal; - iPhoneCallAttributes.iDestination.Copy(_L("+358")); - iPhoneCallAttributes.iLength = 60000; - iPhoneCallAttributes.iIdle = 10000; - iPhoneCallAttributes.iRandomVariance = 0; - - iNetConnAttributes.iId = 0; - iNetConnAttributes.iPriority = EThreadPriorityTypeNormal; - iNetConnAttributes.iDestination.Copy(_L("http://www.nokia.com")); - iNetConnAttributes.iIdle = 10000; - iNetConnAttributes.iRandomVariance = 0; - - iKeyPressAttributes.iId = 0; - iKeyPressAttributes.iPriority = EThreadPriorityTypeNormal; - iKeyPressAttributes.iHeartBeat = 100; - iKeyPressAttributes.iRandomVariance = 0; - - iPointerEventAttributes.iId = 0; - iPointerEventAttributes.iPriority = EThreadPriorityTypeNormal; - iPointerEventAttributes.iHeartBeat = 1000; - iPointerEventAttributes.iRandomVariance = 0; - - iMessageAttributes.iId = 0; - iMessageAttributes.iPriority = EThreadPriorityTypeNormal; - iMessageAttributes.iMessageType = EMessageTypeSMS; - iMessageAttributes.iDestination.Copy(_L("+358")); - iMessageAttributes.iAmount = 5; - iMessageAttributes.iLength = 160; - iMessageAttributes.iIdle = 15000; - iMessageAttributes.iRandomVariance = 0; - - iApplicationsAttributes.iId = 0; - iApplicationsAttributes.iLaunchingInterval = 2000; - iApplicationsAttributes.iPriority = EThreadPriorityTypeNormal; - iApplicationsAttributes.iKeyPressType = EApplicationsKeyPressTypeNone; - iApplicationsAttributes.iMaxOpen = 20; - iApplicationsAttributes.iHeartBeat = 50; - iApplicationsAttributes.iRandomVariance = 0; - - iPhotoCaptureAttributes.iId = 0; - iPhotoCaptureAttributes.iPriority = EThreadPriorityTypeNormal; - iPhotoCaptureAttributes.iIdle = 10000; - iPhotoCaptureAttributes.iRandomVariance = 0; - iPhotoCaptureAttributes.iCameraCount = CCamera::CamerasAvailable(); - if(iPhotoCaptureAttributes.iCameraCount > 0) - { - iPhotoCaptureAttributes.iCamera = 0; // Main camera - } - else - { - iPhotoCaptureAttributes.iCamera = -1; - } - - iBluetoothAttributes.iId = 0; - iBluetoothAttributes.iPriority = EThreadPriorityTypeNormal; - iBluetoothAttributes.iIdle = 10000; - iBluetoothAttributes.iRandomVariance = 0; - iBluetoothAttributes.iBluetoothSupported = CFeatureDiscovery::IsFeatureSupportedL(KFeatureIdBt); - } - -// -------------------------------------------------------------------------------------------- - -void CEngine::DeActivateEngineL() - { - Cancel(); - - // for a faster exit, send the application to background - TApaTask selfTask(iEnv->WsSession()); - selfTask.SetWgId(iEnv->RootWin().Identifier()); - selfTask.SendToBackground(); - } - -// -------------------------------------------------------------------------------------------- - -CEngine::~CEngine() - { - if (iLoadItemList) - { - DeleteAllLoadItems(); - delete iLoadItemList; - } - if ( iApplicationsAttributes.iAppsArray ) - { - delete iApplicationsAttributes.iAppsArray; - } - iTimer.Close(); - iLs.Close(); - } - -// -------------------------------------------------------------------------------------------- - -void CEngine::DoCancel() - { - iTimer.Cancel(); - } - -// -------------------------------------------------------------------------------------------- - -void CEngine::RunL() - { - // continue - //iTimer.After(iStatus, 400000); - //SetActive(); - } - -// -------------------------------------------------------------------------------------------- - -void CEngine::StartNewLoadL(TInt aCommand) - { - // show new load query - //CLoadGenLoadTypeEditorBase* dlg = NULL; - - if(aCommand == ELoadGenCmdNewLoadPhotoCaptures && - iPhotoCaptureAttributes.iCameraCount == 0) - { - _LIT(message, "Cameras not available"); - iEngineWrapper->ShowNote(message); - return; - } - if(aCommand == ELoadGenCmdNewLoadBluetooth && - iBluetoothAttributes.iBluetoothSupported == EFalse) - { - _LIT(message, "Bluetooth device not available"); - iEngineWrapper->ShowNote(message); - return; - } - /* - switch ( aCommand ) - { - case ELoadGenCmdNewLoadCPULoad: - { - //dlg = CLoadGenCPULoadEditor::NewL(iCpuLoadAttributes); - break; - } - case ELoadGenCmdNewLoadEatMemory: - { - //dlg = CLoadGenMemoryEatEditor::NewL(iMemoryEatAttributes); - break; - } - case ELoadGenCmdNewLoadPhoneCall: - { - //dlg = CLoadGenPhoneCallEditor::NewL(iPhoneCallAttributes); - break; - } - case ELoadGenCmdNewLoadNetConn: - { - //dlg = CLoadGenNetConnEditor::NewL(iNetConnAttributes); - break; - } - case ELoadGenCmdNewLoadKeyPress: - { - //dlg = CLoadGenKeyPressEditor::NewL(iKeyPressAttributes); - break; - } - case ELoadGenCmdNewLoadMessages: - { - //dlg = CLoadGenMessagesEditor::NewL( iMessageAttributes ); - break; - } - case ELoadGenCmdNewLoadApplications: - { - //dlg = CLoadGenApplicationsEditor::NewL( iApplicationsAttributes ); - break; - } - case ELoadGenCmdNewLoadPhotoCaptures: - { - if( iPhotoCaptureAttributes.iCameraCount > 0 ) - { - //dlg = CLoadGenPhotoCaptureEditor::NewL( iPhotoCaptureAttributes ); - } - else - { - _LIT(message, "Cameras not available"); - iEngineWrapper->ShowNote(message); - //CAknErrorNote* errorNote = new(ELeave) CAknErrorNote; - //errorNote->ExecuteLD(message); - return; - } - break; - } - case ELoadGenCmdNewLoadBluetooth: - { - if( iBluetoothAttributes.iBluetoothSupported ) - { - //dlg = CLoadGenBluetoothEditor::NewL(iBluetoothAttributes); - } - else - { - _LIT(message, "Bluetooth device not available"); - iEngineWrapper->ShowNote(message); - //CAknErrorNote* errorNote = new(ELeave) CAknErrorNote; - //errorNote->ExecuteLD(message); - return; - } - break; - } - case ELoadGenCmdNewLoadPointerEvent: - { - //dlg = CLoadGenPointerEventEditor::NewL(iPointerEventAttributes); - break; - } - - default: - { - User::Panic(_L("Wrong new load"), 111); - break; - } - } - */ - iEditExistingLoad = EFalse; - iEngineWrapper->OpenLoadSettings(aCommand, EFalse); // = dlg->RunQueryLD(); - - // set back title - - //if (iMainContainer) - // iMainContainer->SetDefaultTitlePaneTextL(); - - // start creating new load if dialog accepted - //if (dlgResult) - // { - // DoStartNewLoadL(aCommand); - // } - // DoStartNewLoadL() called from engine wrapper slot function newLoadAdded() after - // load settings closed by user select: ok. - } - -// -------------------------------------------------------------------------------------------- - -void CEngine::EditLoadL(TInt aIndex) - { - CLoadBase* aItem = iLoadItemList->At(aIndex); - iCurrentItemIndex = aIndex; - iEditExistingLoad = ETrue; - // suspend current - if (aItem->State() == CLoadBase::ELoadStateRunning) - { - iLoadStatusBeforeEdit = CLoadBase::ELoadStateRunning; - aItem->Suspend(); - } - - // show new load query - - /* CLoadGenLoadTypeEditorBase* dlg = NULL; - - - switch ( aItem->Type() ) - { - case ELoadGenCmdNewLoadCPULoad: - { - //dlg = CLoadGenCPULoadEditor::NewL(static_cast(aItem)->Attributes(), ETrue); - break; - } - case ELoadGenCmdNewLoadEatMemory: - { - //dlg = CLoadGenMemoryEatEditor::NewL(static_cast(aItem)->Attributes(), ETrue); - break; - } - case ELoadGenCmdNewLoadPhoneCall: - { - //dlg = CLoadGenPhoneCallEditor::NewL(static_cast(aItem)->Attributes(), ETrue); - break; - } - case ELoadGenCmdNewLoadNetConn: - { - //dlg = CLoadGenNetConnEditor::NewL(static_cast(aItem)->Attributes(), ETrue); - break; - } - case ELoadGenCmdNewLoadKeyPress: - { - //dlg = CLoadGenKeyPressEditor::NewL(static_cast(aItem)->Attributes(), ETrue); - break; - } - case ELoadGenCmdNewLoadMessages: - { - //dlg = CLoadGenMessagesEditor::NewL(static_cast(aItem)->Attributes(), ETrue); - break; - } - case ELoadGenCmdNewLoadApplications: - { - //dlg = CLoadGenApplicationsEditor::NewL( static_cast(aItem)->Attributes(), ETrue ); - break; - } - case ELoadGenCmdNewLoadPhotoCaptures: - { - //dlg = CLoadGenPhotoCaptureEditor::NewL( static_cast(aItem)->Attributes(), ETrue ); - break; - } - case ELoadGenCmdNewLoadBluetooth: - { - //dlg = CLoadGenBluetoothEditor::NewL( static_cast(aItem)->Attributes(), ETrue ); - break; - } - case ELoadGenCmdNewLoadPointerEvent: - { - //dlg = CLoadGenPointerEventEditor::NewL(static_cast(aItem)->Attributes(), ETrue); - break; - } - default: - { - User::Panic(_L("Wrong edit load"), 114); - break; - } - } - */ - iEngineWrapper->OpenLoadSettings(aItem->Type(), iEditExistingLoad); - // ExistingLoadEditedL method called from engine wrapper when load settings view close signal received. - - //TBool dlgResult = ETrue; //dlg->RunQueryLD(); - - // set back title - // TODO: check this. - //if (iMainContainer) - // iMainContainer->SetDefaultTitlePaneTextL(); - - // change priority of the load item - //aItem->SetPriority(); - - // resume execution the item - //aItem->Resume(); - - //if (dlgResult) - // RefreshViewL(EFalse); - } - -// -------------------------------------------------------------------------------------------- - -void CEngine::ExistingLoadEditedL() - { - CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex); - // change priority of the load item - aItem->SetPriority(); - if (iLoadStatusBeforeEdit == CLoadBase::ELoadStateRunning) - { - // resume execution the item - aItem->Resume(); - RefreshViewL(EFalse); - } - // cancel: - - } - -// -------------------------------------------------------------------------------------------- - -void CEngine::ExistingLoadEditCancelled() - { - if (iLoadStatusBeforeEdit == CLoadBase::ELoadStateRunning) - { - CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex); - // resume execution due to suspend action before edit started: - aItem->Resume(); - } - RefreshViewL(EFalse); - } - -// -------------------------------------------------------------------------------------------- - -void CEngine::DoStartNewLoadL(TInt aCommand) - { - CLoadBase* item = NULL; - - switch ( aCommand ) - { - case ELoadGenCmdNewLoadCPULoad: - { - if( iCpuLoadAttributes.iCpu == KCPUSelection_AllCPUs ) - { - // Call this function recursively for all CPUs: - for( TUint i = 0; i < iCpuLoadAttributes.iCpuCount; ++i ) - { - iCpuLoadAttributes.iCpu = i; - DoStartNewLoadL(aCommand); - } - // And finally set user selection back to "All CPUs" - iCpuLoadAttributes.iCpu = KCPUSelection_AllCPUs; - return; - } - else - { - item = CCPULoad::NewL(iCpuLoadAttributes, iReferenceNumber); - } - break; - } - case ELoadGenCmdNewLoadEatMemory: - { - item = CMemoryEat::NewL(iMemoryEatAttributes, iReferenceNumber); - break; - } - case ELoadGenCmdNewLoadPhoneCall: - { - item = CPhoneCall::NewL(iPhoneCallAttributes, iReferenceNumber); - break; - } - case ELoadGenCmdNewLoadNetConn: - { - item = CNetConn::NewL(iNetConnAttributes, iReferenceNumber); - break; - } - - case ELoadGenCmdNewLoadKeyPress: - { - item = CKeyPress::NewL(iKeyPressAttributes, iReferenceNumber); - break; - } - case ELoadGenCmdNewLoadMessages: - { - item = CMessages::NewL( iMessageAttributes, iReferenceNumber ); - break; - } - case ELoadGenCmdNewLoadApplications: - { - iApplicationsAttributes.iAppsArray = ListOfAllAppsL(); - item = CAppLauncher::NewL( iApplicationsAttributes, iReferenceNumber ); - break; - } - case ELoadGenCmdNewLoadPhotoCaptures: - { - item = CPhotoCapture::NewL( iPhotoCaptureAttributes, iReferenceNumber); - break; - } - case ELoadGenCmdNewLoadBluetooth: - { - item = CBluetooth::NewL( iBluetoothAttributes, iReferenceNumber); - break; - } - case ELoadGenCmdNewLoadPointerEvent: - { - item = CPointerEvent::NewL(iPointerEventAttributes, iReferenceNumber); - break; - } - - default: - { - User::Panic(_L("Wrong new load"), 112); - break; - } - } - - iReferenceNumber++; - - // add item to the array - AppendToLoadItemListL(item); - - // update the listbox - RefreshViewL(EFalse); - - // set item index to the end - // Check this feature to be done in Orbit UI. - // iMainContainer->ListBox()->SetCurrentItemIndexAndDraw( iMainContainer->ListBox()->Model()->NumberOfItems()-1 ); - - // start the load - item->Resume(); - - // refresh again - RefreshViewL(EFalse); - } - -// -------------------------------------------------------------------------------------------- - - -void CEngine::StopAllLoadItemsL() - { - DeleteAllLoadItems(); - - RefreshViewL(); - } - -// -------------------------------------------------------------------------------------------- - -void CEngine::SuspendAllLoadItemsL() - { - for (TInt i=0; iAt(i) ) - { - iLoadItemList->At(i)->Suspend(); - } - } - - RefreshViewL(); - } -// -------------------------------------------------------------------------------------------- - -void CEngine::ResumeAllLoadItemsL() - { - for (TInt i=0; iAt(i) ) - { - iLoadItemList->At(i)->Resume(); - } - } - - RefreshViewL(); - } - -// -------------------------------------------------------------------------------------------- - -void CEngine::RefreshViewL(TBool aClearSelection) - { - // clear selections if any - iEngineWrapper->ClearSelection(); - if (aClearSelection) - { - iEngineWrapper->SetCurrentItemIndex(KZeroIndex); - } - iEngineWrapper->ReFreshView(GenerateListBoxItemTextArrayL()); - } - -// -------------------------------------------------------------------------------------------- - -CDesCArray* CEngine::GenerateListBoxItemTextArrayL() - { - CDesCArray* textArray = new(ELeave) CDesCArrayFlat(64); - CleanupStack::PushL(textArray); - - _LIT(KEntryTemplateRedIcon, "1\t%S\t\t"); - _LIT(KEntryTemplateGreenIcon, "2\t%S\t\t"); - TInt cnt = LoadItemCount(); - for (TInt i=0; i< cnt; i++) - { - // add description from each entry - TBuf<256> textEntry; - TBuf<256> description = iLoadItemList->At(i)->Description(); - - if (iLoadItemList->At(i)->State() == CLoadBase::ELoadStateRunning) - textEntry.Format(KEntryTemplateGreenIcon, &description); - else - textEntry.Format(KEntryTemplateRedIcon, &description); - - textArray->AppendL(textEntry); - } - - CleanupStack::Pop(); //textArray - return textArray; - } - -// -------------------------------------------------------------------------------------------- - -void CEngine::AppendToLoadItemListL(CLoadBase* aItem) - { - if (iLoadItemList) - iLoadItemList->AppendL( aItem ); - else - User::Leave(KErrNotReady); - } - -// -------------------------------------------------------------------------------------------- - -void CEngine::DeleteFromLoadItemListL(TInt aIndex) - { - if (iLoadItemList) - { - if (iLoadItemList->Count() > aIndex && aIndex >= 0) - { - // first call delete on the item - if (iLoadItemList->At(aIndex)) - { - delete iLoadItemList->At(aIndex); - iLoadItemList->At(aIndex) = NULL; - } - - // and them remove the array entry - iLoadItemList->Delete(aIndex); - iLoadItemList->Compress(); - } - else - User::Leave(KErrNotFound); - } - else - User::Leave(KErrNotReady); - } - -// -------------------------------------------------------------------------------------------- - -void CEngine::SuspendOrResumeFromLoadItemListL(TInt aIndex) - { - if (iLoadItemList) - { - if (iLoadItemList->Count() > aIndex && aIndex >= 0) - { - if (iLoadItemList->At(aIndex)) - { - if (iLoadItemList->At(aIndex)->State() == CLoadBase::ELoadStateRunning) - { - iLoadItemList->At(aIndex)->Suspend(); - } - else if (iLoadItemList->At(aIndex)->State() == CLoadBase::ELoadStateSuspended) - { - iLoadItemList->At(aIndex)->Resume(); - } - } - } - else - User::Leave(KErrNotFound); - } - else - User::Leave(KErrNotReady); - } - -// -------------------------------------------------------------------------------------------- - -TInt CEngine::LoadItemCount() const - { - TInt count(0); - - if (iLoadItemList) - count = iLoadItemList->Count(); - - return count; - } - -// -------------------------------------------------------------------------------------------- - -void CEngine::DeleteAllLoadItems() - { - // call delete for each entry and free memory allocated for the array - for (TInt i=0; iAt(i) ) - { - delete iLoadItemList->At(i); - iLoadItemList->At(i) = NULL; - } - } - - iLoadItemList->Reset(); - } - -// -------------------------------------------------------------------------------------------- - -void CEngine::StopSelectedOrHighlightedItemsL(const CArrayFix* aSelectionIndexes) - { - TInt err(KErrNone); - - // by default use selected items - if (aSelectionIndexes && aSelectionIndexes->Count() > 0) - { - TInt deleteIndexCounter(0); - TInt ref(0); - TKeyArrayFix key(0, ECmpTUint16); - TInt index(0); - - TInt loadCount = LoadItemCount(); - - for (TInt i=0; iFind(ref, key, index) == 0) - { - TRAP(err, DeleteFromLoadItemListL(i-deleteIndexCounter)); - deleteIndexCounter++; // amount of indexes decreases after each delete - } - } - - RefreshViewL(); - User::LeaveIfError(err); - } - } - -// -------------------------------------------------------------------------------------------- - -void CEngine::SuspendOrResumeSelectedOrHighlightedItemsL() - { - const CArrayFix* selectionIndexes = iEngineWrapper->QueryListSelectedIndexesOrCurrentItemL(); //iMainContainer->ListBoxSelectionIndexes(); - - // by default use selected items - if (selectionIndexes && selectionIndexes->Count() > 0) - { - TInt ref(0); - TKeyArrayFix key(0, ECmpTUint16); - TInt index(0); - - for (TInt i=0; iFind(ref, key, index) == 0) - { - SuspendOrResumeFromLoadItemListL(i); - } - } - - RefreshViewL(EFalse); - } - } -// -------------------------------------------------------------------------------------------- - -void CEngine::LoadSettingsL() - { - } - -// -------------------------------------------------------------------------------------------- - -void CEngine::SaveSettingsL() - { - } - -// -------------------------------------------------------------------------------------------- - -TInt CEngine::LaunchSettingsDialogL() - { - return 0; - } - -// -------------------------------------------------------------------------------------------- -CDesCArray* CEngine::ListOfAllAppsL() - { - const TInt KMaxAppsArraySize=250; - RApaLsSession ls; - CleanupClosePushL(ls); - - User::LeaveIfError( ls.Connect() ); - CDesCArray* allAppsArray = new(ELeave) CDesCArrayFlat( KMaxAppsArraySize ); - CleanupStack::PushL( allAppsArray ); - // reset the apps list - allAppsArray->Reset(); - - // search all apps - TApaAppInfo appInfo; - User::LeaveIfError(ls.GetAllApps()); - - - while ( ls.GetNextApp( appInfo ) == KErrNone ) - { - allAppsArray->AppendL( appInfo.iFullName ); - } - CleanupStack::Pop( allAppsArray ); - CleanupStack::PopAndDestroy( &ls ); - - - // remove loadgen.* from the list - for ( TInt i = 0; i < allAppsArray->MdcaCount(); i++ ) - { - if ( allAppsArray->MdcaPoint(i).FindF( _L("\\loadgen.") ) != KErrNotFound ) - { - allAppsArray->Delete(i); - allAppsArray->Compress(); - break; - } - } - - // sort the elements - allAppsArray->Sort(); - - return allAppsArray; // ownership transferred - } - -// -------------------------------------------------------------------------------------------- - -void CEngine::LaunchPerfMonL() - { - // launch Performance Monitor - const TUid KUidPerfMon = { 0x20011385 }; - - RWsSession ws; - User::LeaveIfError( ws.Connect() ); - CleanupClosePushL(ws); - - RApaLsSession ls; - User::LeaveIfError( ls.Connect() ); - CleanupClosePushL(ls); - - - // try to find the task of PerfMon - TApaTaskList tasklist(ws); - TApaTask task = tasklist.FindApp(KUidPerfMon); - - if (task.Exists()) - { - // task exists, bring it to foreground - task.BringToForeground(); - } - else - { - TApaAppInfo appInfo; - User::LeaveIfError(ls.GetAppInfo(appInfo, KUidPerfMon)); - - CApaCommandLine* cmdLine = CApaCommandLine::NewLC(); - cmdLine->SetExecutableNameL(appInfo.iFullName); - cmdLine->SetCommandL(EApaCommandBackground); - - // start the app - User::LeaveIfError(ls.StartApp(*cmdLine)); - - CleanupStack::PopAndDestroy(); //cmdLine - } - - CleanupStack::PopAndDestroy(2); //ws,ls - } - -// -------------------------------------------------------------------------------------------- - -TCPULoadAttributes CEngine::GetCPULoadAttributes() - { - if (iEditExistingLoad == EFalse) - { - return iCpuLoadAttributes; - } - else - { - CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex); - return (static_cast(aItem)->Attributes()); - } - } - -// -------------------------------------------------------------------------------------------- - -void CEngine::ChangeCPULoadAttributes(const TCPULoadAttributes& aAttributes) - { - if (iEditExistingLoad == EFalse) - { - iCpuLoadAttributes = aAttributes; - } - else - { - CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex); - static_cast(aItem)->SetAttributes(aAttributes); - } - } - -// -------------------------------------------------------------------------------------------- - -TMemoryEatAttributes CEngine::GetMemoryEatAttributes() - { - if (iEditExistingLoad == EFalse) - { - return iMemoryEatAttributes; - } - else - { - CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex); - return (static_cast(aItem)->Attributes()); - } - } - -// -------------------------------------------------------------------------------------------- - -void CEngine::ChangeMemoryEatAttributes(const TMemoryEatAttributes& aAttributes) - { - if (iEditExistingLoad == EFalse) - { - iMemoryEatAttributes = aAttributes; - } - else - { - CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex); - static_cast(aItem)->SetAttributes(aAttributes); - } - } - -// -------------------------------------------------------------------------------------------- - -TPhoneCallAttributes CEngine::GetPhoneCallAttributes() - { - if (iEditExistingLoad == EFalse) - { - return iPhoneCallAttributes; - } - else - { - CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex); - return (static_cast(aItem)->Attributes()); - } - } - -// -------------------------------------------------------------------------------------------- - -void CEngine::ChangePhoneCallAttributes(const TPhoneCallAttributes& aAttributes) - { - if (iEditExistingLoad == EFalse) - { - iPhoneCallAttributes = aAttributes; - } - else - { - CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex); - static_cast(aItem)->SetAttributes(aAttributes); - } - } - -// -------------------------------------------------------------------------------------------- - -TNetConnAttributes CEngine::GetNetConnAttributes() - { - - if (iEditExistingLoad == EFalse) - { - return iNetConnAttributes; - } - else - { - CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex); - return (static_cast(aItem)->Attributes()); - } - - } - -// -------------------------------------------------------------------------------------------- - -void CEngine::ChangeNetConnAttributes(const TNetConnAttributes& aAttributes) - { - - if (iEditExistingLoad == EFalse) - { - iNetConnAttributes = aAttributes; - } - else - { - CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex); - static_cast(aItem)->SetAttributes(aAttributes); - } - - } - -// -------------------------------------------------------------------------------------------- - -TKeyPressAttributes CEngine::GetKeyPressAttributes() - { - if (iEditExistingLoad == EFalse) - { - return iKeyPressAttributes; - } - else - { - CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex); - return (static_cast(aItem)->Attributes()); - } - } - - -// -------------------------------------------------------------------------------------------- - -void CEngine::ChangeKeyPressAttributes(const TKeyPressAttributes& aAttributes) - { - if (iEditExistingLoad == EFalse) - { - iKeyPressAttributes = aAttributes; - } - else - { - CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex); - static_cast(aItem)->SetAttributes(aAttributes); - } - } - -// -------------------------------------------------------------------------------------------- - -TMessageAttributes CEngine::GetMessageAttributes() - { - if (iEditExistingLoad == EFalse) - { - return iMessageAttributes; - } - else - { - CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex); - return (static_cast(aItem)->Attributes()); - } - } - -// -------------------------------------------------------------------------------------------- - -void CEngine::ChangeMessageAttributes(const TMessageAttributes& aAttributes) - { - if (iEditExistingLoad == EFalse) - { - iMessageAttributes = aAttributes; - } - else - { - CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex); - static_cast(aItem)->SetAttributes(aAttributes); - } - } - -// -------------------------------------------------------------------------------------------- - -TApplicationsAttributes CEngine::GetApplicationsAttributes() - { - if (iEditExistingLoad == EFalse) - { - return iApplicationsAttributes; - } - else - { - CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex); - return (static_cast(aItem)->Attributes()); - } - } - -// -------------------------------------------------------------------------------------------- - -void CEngine::ChangeApplicationsAttributes(const TApplicationsAttributes& aAttributes) - { - if (iEditExistingLoad == EFalse) - { - iApplicationsAttributes = aAttributes; - } - else - { - CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex); - static_cast(aItem)->SetAttributes(aAttributes); - } - } - -// -------------------------------------------------------------------------------------------- - -TPhotoCaptureAttributes CEngine::GetPhotoCaptureAttributes() - { - if (iEditExistingLoad == EFalse) - { - return iPhotoCaptureAttributes; - } - else - { - CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex); - return (static_cast(aItem)->Attributes()); - } - } - -// -------------------------------------------------------------------------------------------- - -void CEngine::ChangePhotoCaptureAttributes(const TPhotoCaptureAttributes& aAttributes) - { - if (iEditExistingLoad == EFalse) - { - iPhotoCaptureAttributes = aAttributes; - } - else - { - CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex); - static_cast(aItem)->SetAttributes(aAttributes); - } - } - -// -------------------------------------------------------------------------------------------- - -TBluetoothAttributes CEngine::GetBluetoothAttributes() - { - if (iEditExistingLoad == EFalse) - { - return iBluetoothAttributes; - } - else - { - CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex); - return (static_cast(aItem)->Attributes()); - } - } - - -// -------------------------------------------------------------------------------------------- - -void CEngine::ChangeBluetoothAttributes(const TBluetoothAttributes& aAttributes) - { - if (iEditExistingLoad == EFalse) - { - iBluetoothAttributes = aAttributes; - } - else - { - CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex); - static_cast(aItem)->SetAttributes(aAttributes); - } - } - -// -------------------------------------------------------------------------------------------- - -TPointerEventAttributes CEngine::GetPointerEventAttributes() - { - if (iEditExistingLoad == EFalse) - { - return iPointerEventAttributes; - } - else - { - CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex); - return (static_cast(aItem)->Attributes()); - } - } - -// -------------------------------------------------------------------------------------------- - -void CEngine::ChangePointerEventAttributes(const TPointerEventAttributes& aAttributes) - { - if (iEditExistingLoad == EFalse) - { - iPointerEventAttributes = aAttributes; - } - else - { - CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex); - static_cast(aItem)->SetAttributes(aAttributes); - } - } - -// -------------------------------------------------------------------------------------------- - -// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/ui/hb/src/enginewrapper.cpp --- a/loadgen/ui/hb/src/enginewrapper.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,736 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#include -//#include -#include -#include - -#include - #include - -#include -#include - -#include "notifications.h" -#include "enginewrapper.h" -#include "settingsview.h" -#include "engine.h" -#include "mainview.h" - -QStringList LOADTYPES = (QStringList() << "CPU load" << "Memory eat" << "Phone calls" << "Messages" - << "Network conn." << "Key presses" << "Applications" << "Photo captures" - << "Bluetooth actions" << "Pointer events"); - -// --------------------------------------------------------------------------- - -EngineWrapper::EngineWrapper(HbMainWindow &mainWindow, MainView &mainView) -: mEngine(0), - mMainView(mainView), - mMainWindow(mainWindow), - mEditExistingLoad(false) -{ -} - -// --------------------------------------------------------------------------- - -EngineWrapper::~EngineWrapper() -{ - if (mEngine != 0) { - TRAP_IGNORE(mEngine->DeActivateEngineL()); - delete mEngine; - } -} - -// --------------------------------------------------------------------------- - -bool EngineWrapper::init() -{ - TInt err = KErrNone; - TRAP(err, mEngine = CEngine::NewL(this)); - if(err != KErrNone) { - return false; - } - else { - TRAP(err, mEngine->ActivateEngineL()); - if (err != KErrNone) { - return false; - } - else { - return true; - } - } -} - -// --------------------------------------------------------------------------- - -bool EngineWrapper::startNewLoad(int commandId) -{ - TRAPD(err, mEngine->StartNewLoadL(commandId)); - - // error handling - if(err != KErrNone) { - return false; - } - else { - return true; - } -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::launchPerfMonApp() -{ - TRAPD(err, mEngine->LaunchPerfMonL()); - // error handling - if(err != KErrNone) { - Notifications::error("Perf Mon launch failed."); - } -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::loadAddedOrEdited(TLoadGenCommandIds cmdId) -{ - if (mEditExistingLoad == false) { - TRAP_IGNORE(mEngine->DoStartNewLoadL(cmdId)); - } - else { - TRAP_IGNORE(mEngine->ExistingLoadEditedL()); - } -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::loadSettingsCanclled() -{ - if (mEditExistingLoad == true) { - TRAP_IGNORE(mEngine->ExistingLoadEditCancelled()); - } -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::loadEdit(int rowIndex) -{ - TRAPD(err, mEngine->EditLoadL(rowIndex)); - // error handling - if(err != KErrNone) { - Notifications::error("Load edit failed."); - } -} - -void EngineWrapper::StopLoadYesNoDialogClosed(HbAction *action) -{ - if( action && !action->text().compare("yes", Qt::CaseInsensitive) ){ - const CArrayFix* selectionIndexes = NULL; - try{ - QT_TRAP_THROWING( selectionIndexes = QueryListSelectedIndexesOrCurrentItemL() ); - if(selectionIndexes) - QT_TRAP_THROWING( mEngine->StopSelectedOrHighlightedItemsL(selectionIndexes) ); - } - catch(...){ - Notifications::error("Stop load failed."); - } - if(selectionIndexes) - delete selectionIndexes; - } -} - -// --------------------------------------------------------------------------- -bool EngineWrapper::stopLoad(bool stopAll) -{ - TInt err = KErrNone; - if (stopAll == true) { - TRAP(err, mEngine->StopAllLoadItemsL()); - // error handling - if(err != KErrNone) { - return false; - } - else { - return true; - } - } - else { - // by default use selected items - QList listIndices = mMainView.listSelectionIndexes(); - if (listIndices.count() > 0) - { - QString message = QString("Stop %1 selections?").arg( listIndices.count() ); - HbMessageBox::question(message, this, SLOT(StopLoadYesNoDialogClosed(HbAction *)), HbMessageBox::Yes|HbMessageBox::No); - } - else{ - TInt currentItemIndex = mMainView.currentItemIndex(); - if (mEngine->LoadItemCount() > currentItemIndex && currentItemIndex >= 0) - { - QString message("Stop highlighted selections?"); - HbMessageBox::question(message, this, SLOT(StopLoadYesNoDialogClosed(HbAction *)), HbMessageBox::Yes|HbMessageBox::No); - } - } - return true; - } - -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::resumeAllLoadItems() -{ - TRAPD(err, mEngine->ResumeAllLoadItemsL()); - // error handling - if(err != KErrNone) { - Notifications::error("Error in loads resume."); - } -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::suspendAllLoadItems() -{ - TRAPD(err, mEngine->SuspendAllLoadItemsL()); - // error handling - if(err != KErrNone) { - Notifications::error("Error in loads resume."); - } -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::suspendOrResumeSelectedOrHighlightedItems() -{ - TRAPD(err, mEngine->SuspendOrResumeSelectedOrHighlightedItemsL()); - // error handling - if(err != KErrNone) { - Notifications::error("Error to show item action menu."); - } -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::ShowErrorMessage(const TDesC& aErrorMessage) -{ - QString errorMessage((QChar*)aErrorMessage.Ptr(),aErrorMessage.Length()); - Notifications::error(errorMessage); - -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::ShowNote(const TDesC& aNoteMessage) -{ - QString note((QChar*)aNoteMessage.Ptr(),aNoteMessage.Length()); - Notifications::showGlobalNote(note, HbMessageBox::MessageTypeInformation, HbPopup::StandardTimeout); -} - -// --------------------------------------------------------------------------- - -TInt EngineWrapper::QueryCurrentItemIndex() -{ - return mMainView.currentItemIndex(); -} - -// --------------------------------------------------------------------------- - -const CArrayFix* EngineWrapper::QueryListSelectedIndexesOrCurrentItemL() -{ - QList listIndices = mMainView.listSelectionIndexes(); - TInt cnt = listIndices.count(); - CArrayFix* indices = new(ELeave)CArrayFixFlat( cnt > 0 ? cnt : 1 ); - CleanupDeletePushL(indices); - if(cnt > 0){ - for (TInt i = 0; i < cnt; i++) { - indices->AppendL(listIndices.at(i)); - } - } - else{ - indices->AppendL(mMainView.currentItemIndex()); - } - CleanupStack::Pop(indices); - return static_cast*>(indices); -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::OpenLoadSettings(TInt loadType, bool editExistingLoad) -{ - SettingsView* settings = new SettingsView((HbView&)ViewReference(), - WindowReference(), - *this); - mEditExistingLoad = editExistingLoad; - - switch (loadType) { - case ELoadGenCmdNewLoadCPULoad: { - settings->open(LOADTYPES.at(Cpu), - (TLoadGenCommandIds)loadType); - break; - } - case ELoadGenCmdNewLoadEatMemory: { - settings->open(LOADTYPES.at(EatMemory), - (TLoadGenCommandIds)loadType); - break; - } - case ELoadGenCmdNewLoadPhoneCall: { - settings->open(LOADTYPES.at(PhoneCalls), - (TLoadGenCommandIds)loadType); - break; - } - case ELoadGenCmdNewLoadNetConn: { - settings->open(LOADTYPES.at(NWConnections), - (TLoadGenCommandIds)loadType); - break; - } - case ELoadGenCmdNewLoadKeyPress: { - settings->open(LOADTYPES.at(KeyPresses), - (TLoadGenCommandIds)loadType); - break; - } - case ELoadGenCmdNewLoadMessages: { - settings->open(LOADTYPES.at(Messages), - (TLoadGenCommandIds)loadType); - break; - } - case ELoadGenCmdNewLoadApplications: { - settings->open(LOADTYPES.at(Apps), - (TLoadGenCommandIds)loadType); - break; - } - case ELoadGenCmdNewLoadPhotoCaptures: { - settings->open(LOADTYPES.at(Photos), - (TLoadGenCommandIds)loadType); - break; - } - case ELoadGenCmdNewLoadBluetooth: { - settings->open(LOADTYPES.at(BTAct), - (TLoadGenCommandIds)loadType); - break; - } - case ELoadGenCmdNewLoadPointerEvent: { - settings->open(LOADTYPES.at(PointerEvents), - (TLoadGenCommandIds)loadType); - break; - } - default: { - User::Panic(_L("Wrong new load"), 111); - break; - } - } -} - -// --------------------------------------------------------------------------- - -CPULoadAttributes EngineWrapper::getCpuLoadAttributes() -{ - TCPULoadAttributes tCpuLoadAttributes = mEngine->GetCPULoadAttributes(); - CPULoadAttributes attributes; - - attributes.mId = tCpuLoadAttributes.iId; - attributes.mPriority = tCpuLoadAttributes.iPriority; - attributes.mMode = tCpuLoadAttributes.iMode; - attributes.mType = tCpuLoadAttributes.iType; - attributes.mLength = tCpuLoadAttributes.iLength; - attributes.mIdle = tCpuLoadAttributes.iIdle; - attributes.mRandomVariance = tCpuLoadAttributes.iRandomVariance; - attributes.mCpu = tCpuLoadAttributes.iCpu; - attributes.mCpuCount = tCpuLoadAttributes.iCpuCount; - return attributes; -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::setCpuLoadAttributes(const CPULoadAttributes& attributes) -{ - TCPULoadAttributes tCpuLoadAttributes; - - tCpuLoadAttributes.iId = attributes.mId; - tCpuLoadAttributes.iPriority = attributes.mPriority; - tCpuLoadAttributes.iMode = attributes.mMode; - tCpuLoadAttributes.iType = attributes.mType; - tCpuLoadAttributes.iLength = attributes.mLength; - tCpuLoadAttributes.iIdle = attributes.mIdle; - tCpuLoadAttributes.iRandomVariance = attributes.mRandomVariance; - tCpuLoadAttributes.iCpu = attributes.mCpu; - tCpuLoadAttributes.iCpuCount = attributes.mCpuCount; - - mEngine->ChangeCPULoadAttributes(tCpuLoadAttributes); -} - -// --------------------------------------------------------------------------- - -MemoryEatAttributes EngineWrapper::getMemoryEatAttributes() -{ - - TMemoryEatAttributes tMemoryEatAttributes = mEngine->GetMemoryEatAttributes(); - MemoryEatAttributes attributes; - - // Convert TMemoryEatAttributes to MemoryEatAttributes - attributes.mId = tMemoryEatAttributes.iId; - attributes.mPriority = tMemoryEatAttributes.iPriority; - attributes.mSource = tMemoryEatAttributes.iSource; - attributes.mType = tMemoryEatAttributes.iType; - attributes.mBuffer = tMemoryEatAttributes.iBuffer; - attributes.mIdle = tMemoryEatAttributes.iIdle; - attributes.mAmount = tMemoryEatAttributes.iAmount; - attributes.mRandomMin = tMemoryEatAttributes.iRandomMin; - attributes.mRandomMax = tMemoryEatAttributes.iRandomMax; - - TBuf<64> amount; - amount.Copy(tMemoryEatAttributes.iAmountDes); - attributes.mAmountDes = QString((QChar*)amount.Ptr(), amount.Length()); - - TBuf<64> min; - min.Copy(tMemoryEatAttributes.iRandomMinDes); - attributes.mAmountDes = QString((QChar*)min.Ptr(), min.Length()); - - TBuf<64> max; - max.Copy(tMemoryEatAttributes.iRandomMaxDes); - attributes.mAmountDes = QString((QChar*)max.Ptr(), max.Length()); - - attributes.mRandomVariance = tMemoryEatAttributes.iRandomVariance; - return attributes; -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::setMemoryEatAttributes(const MemoryEatAttributes& attributes) -{ - TMemoryEatAttributes tMemoryEatAttributes = mEngine->GetMemoryEatAttributes();//TMemoryEatAttributes tMemoryEatAttributes; - - tMemoryEatAttributes.iId = attributes.mId; - tMemoryEatAttributes.iPriority = attributes.mPriority; - tMemoryEatAttributes.iSource = attributes.mSource; - tMemoryEatAttributes.iType = attributes.mType; - tMemoryEatAttributes.iBuffer = attributes.mBuffer; - tMemoryEatAttributes.iIdle = attributes.mIdle; - tMemoryEatAttributes.iAmount = attributes.mAmount; - tMemoryEatAttributes.iRandomMin = attributes.mRandomMin; - tMemoryEatAttributes.iRandomMax = attributes.mRandomMax; - - TBuf<64> amount = attributes.mAmountDes.utf16(); - tMemoryEatAttributes.iAmountDes.Copy(amount); - - TBuf<64> min = attributes.mRandomMinDes.utf16(); - tMemoryEatAttributes.iRandomMinDes.Copy(min); - - TBuf<64> max = attributes.mRandomMaxDes.utf16(); - tMemoryEatAttributes.iRandomMaxDes.Copy(max); - - tMemoryEatAttributes.iRandomVariance = attributes.mRandomVariance; - - mEngine->ChangeMemoryEatAttributes(tMemoryEatAttributes); -} - -// --------------------------------------------------------------------------- - -PhoneCallAttributes EngineWrapper::getPhoneCallAttributes() -{ - TPhoneCallAttributes tPhoneCallAttributes = mEngine->GetPhoneCallAttributes(); - PhoneCallAttributes attributes; - - attributes.mId = tPhoneCallAttributes.iId; - attributes.mPriority = tPhoneCallAttributes.iPriority; - - TBuf<128> dest; - dest.Copy(tPhoneCallAttributes.iDestination); - attributes.mDestination = QString((QChar*)dest.Ptr(), dest.Length()); - - attributes.mLength = tPhoneCallAttributes.iLength; - attributes.mIdle = tPhoneCallAttributes.iIdle; - attributes.mRandomVariance = tPhoneCallAttributes.iRandomVariance; - return attributes; -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::setPhoneCallAttributes(const PhoneCallAttributes& attributes) -{ - TPhoneCallAttributes tPhoneCallAttributes = mEngine->GetPhoneCallAttributes(); //TPhoneCallAttributes tPhoneCallAttributes; - - tPhoneCallAttributes.iId = attributes.mId; - tPhoneCallAttributes.iPriority = attributes.mPriority; - - TBuf<128> dest = attributes.mDestination.utf16(); - tPhoneCallAttributes.iDestination.Copy(dest); - - tPhoneCallAttributes.iLength = attributes.mLength; - tPhoneCallAttributes.iIdle = attributes.mIdle; - tPhoneCallAttributes.iRandomVariance = attributes.mRandomVariance; - - mEngine->ChangePhoneCallAttributes(tPhoneCallAttributes); -} - -// --------------------------------------------------------------------------- - -NetConnAttributes EngineWrapper::getNetConnAttributes() -{ - TNetConnAttributes tNetConnAttributes = mEngine->GetNetConnAttributes(); - NetConnAttributes attributes; - - attributes.mId = tNetConnAttributes.iId; - attributes.mPriority = tNetConnAttributes.iPriority; - - attributes.mDestination = QString::fromUtf16(tNetConnAttributes.iDestination.Ptr(), tNetConnAttributes.iDestination.Length()); - - attributes.mIdle = tNetConnAttributes.iIdle; - attributes.mRandomVariance = tNetConnAttributes.iRandomVariance; - return attributes; -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::setNetConnAttributes(const NetConnAttributes& attributes) -{ - TNetConnAttributes tNetConnAttributes = mEngine->GetNetConnAttributes(); //TNetConnAttributes tNetConnAttributes; - - tNetConnAttributes.iId = attributes.mId; - tNetConnAttributes.iPriority = attributes.mPriority; - - TBuf<128> dest = attributes.mDestination.utf16(); - tNetConnAttributes.iDestination.Copy(dest); - - tNetConnAttributes.iIdle = attributes.mIdle; - tNetConnAttributes.iRandomVariance = attributes.mRandomVariance; - - mEngine->ChangeNetConnAttributes(tNetConnAttributes); -} - -// --------------------------------------------------------------------------- - -KeyPressAttributes EngineWrapper::getKeyPressAttributes() -{ - TKeyPressAttributes tKeyPressAttributes = mEngine->GetKeyPressAttributes(); - KeyPressAttributes attributes; - - attributes.mId = tKeyPressAttributes.iId; - attributes.mPriority = tKeyPressAttributes.iPriority; - attributes.mHeartBeat = tKeyPressAttributes.iHeartBeat; - attributes.mRandomVariance = tKeyPressAttributes.iRandomVariance; - return attributes; -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::setKeyPressAttributes(const KeyPressAttributes& attributes) -{ - TKeyPressAttributes tKeyPressAttributes = mEngine->GetKeyPressAttributes(); //TKeyPressAttributes tKeyPressAttributes; - - tKeyPressAttributes.iId = attributes.mId; - tKeyPressAttributes.iPriority = attributes.mPriority; - tKeyPressAttributes.iHeartBeat = attributes.mHeartBeat; - tKeyPressAttributes.iRandomVariance = attributes.mRandomVariance; - - mEngine->ChangeKeyPressAttributes(tKeyPressAttributes); -} - -// --------------------------------------------------------------------------- - -PointerEventAttributes EngineWrapper::getPointerEventAttributes() -{ - TPointerEventAttributes tPointerEventAttributes = mEngine->GetPointerEventAttributes(); - PointerEventAttributes attributes; - - attributes.mId = tPointerEventAttributes.iId; - attributes.mPriority = tPointerEventAttributes.iPriority; - attributes.mHeartBeat = tPointerEventAttributes.iHeartBeat; - attributes.mRandomVariance = tPointerEventAttributes.iRandomVariance; - return attributes; -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::setPointerEventAttributes(const PointerEventAttributes& attributes) -{ - TPointerEventAttributes tPointerEventAttributes = mEngine->GetPointerEventAttributes();//TPointerEventAttributes tPointerEventAttributes; - - tPointerEventAttributes.iId = attributes.mId; - tPointerEventAttributes.iPriority = attributes.mPriority; - tPointerEventAttributes.iHeartBeat = attributes.mHeartBeat; - tPointerEventAttributes.iRandomVariance = attributes.mRandomVariance; - - mEngine->ChangePointerEventAttributes(tPointerEventAttributes); -} - -// --------------------------------------------------------------------------- - -MessageAttributes EngineWrapper::getMessageAttributes() -{ - TMessageAttributes tMessageAttributes = mEngine->GetMessageAttributes(); - MessageAttributes attributes; - - attributes.mId = tMessageAttributes.iId; - attributes.mMessageType = tMessageAttributes.iMessageType; - - TBuf<128> dest; - dest.Copy(tMessageAttributes.iDestination); - attributes.mDestination = QString((QChar*)dest.Ptr(), dest.Length()); - - attributes.mPriority = tMessageAttributes.iPriority; - attributes.mAmount = tMessageAttributes.iAmount; - attributes.mLength = tMessageAttributes.iLength; - attributes.mIdle = tMessageAttributes.iIdle; - attributes.mRandomVariance = tMessageAttributes.iRandomVariance; - return attributes; -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::setMessageAttributes(const MessageAttributes& attributes) -{ - TMessageAttributes tMessageAttributes = mEngine->GetMessageAttributes();//TMessageAttributes tMessageAttributes; - - tMessageAttributes.iId = attributes.mId; - tMessageAttributes.iMessageType = attributes.mMessageType; - - TBuf<128> dest = attributes.mDestination.utf16(); - tMessageAttributes.iDestination.Copy(dest); - - tMessageAttributes.iPriority = attributes.mPriority; - tMessageAttributes.iAmount = attributes.mAmount; - tMessageAttributes.iLength = attributes.mLength; - tMessageAttributes.iIdle = attributes.mIdle; - tMessageAttributes.iRandomVariance = attributes.mRandomVariance; - - mEngine->ChangeMessageAttributes(tMessageAttributes); -} - -// --------------------------------------------------------------------------- - -ApplicationsAttributes EngineWrapper::getApplicationsAttributes() -{ - TApplicationsAttributes tApplicationsAttributes = mEngine->GetApplicationsAttributes(); - ApplicationsAttributes attributes; - - attributes.mId = tApplicationsAttributes.iId; - attributes.mPriority = tApplicationsAttributes.iPriority; - attributes.mLaunchingInterval = tApplicationsAttributes.iLaunchingInterval; - attributes.mKeyPressType = tApplicationsAttributes.iKeyPressType; - attributes.mMaxOpen = tApplicationsAttributes.iMaxOpen; - attributes.mHeartBeat = tApplicationsAttributes.iHeartBeat; - attributes.mRandomVariance = tApplicationsAttributes.iRandomVariance; - - return attributes; -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::setApplicationsAttributes(const ApplicationsAttributes& attributes) -{ - TApplicationsAttributes tApplicationsAttributes = mEngine->GetApplicationsAttributes(); //TApplicationsAttributes tApplicationsAttributes; - - tApplicationsAttributes.iId = attributes.mId; - tApplicationsAttributes.iPriority = attributes.mPriority; - tApplicationsAttributes.iLaunchingInterval = attributes.mLaunchingInterval; - tApplicationsAttributes.iKeyPressType = attributes.mKeyPressType; - tApplicationsAttributes.iMaxOpen = attributes.mMaxOpen; - tApplicationsAttributes.iHeartBeat = attributes.mHeartBeat; - tApplicationsAttributes.iRandomVariance = attributes.mRandomVariance; - - mEngine->ChangeApplicationsAttributes(tApplicationsAttributes); -} - - QStringList mAppsArray; - -// --------------------------------------------------------------------------- - -PhotoCaptureAttributes EngineWrapper::getPhotoCaptureAttributes() -{ - TPhotoCaptureAttributes tPhotoCaptureAttributes = mEngine->GetPhotoCaptureAttributes(); - PhotoCaptureAttributes attributes; - - attributes.mId = tPhotoCaptureAttributes.iId; - attributes.mPriority = tPhotoCaptureAttributes.iPriority; - attributes.mCameraCount = tPhotoCaptureAttributes.iCameraCount; - attributes.mCamera = tPhotoCaptureAttributes.iCamera; - attributes.mIdle = tPhotoCaptureAttributes.iIdle; - attributes.mRandomVariance = tPhotoCaptureAttributes.iRandomVariance; - return attributes; -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::setPhotoCaptureAttributes(const PhotoCaptureAttributes& attributes) -{ - TPhotoCaptureAttributes tPhotoCaptureAttributes; - - tPhotoCaptureAttributes.iId = attributes.mId; - tPhotoCaptureAttributes.iPriority = attributes.mPriority; - tPhotoCaptureAttributes.iCameraCount = attributes.mCameraCount; - tPhotoCaptureAttributes.iCamera = attributes.mCamera; - tPhotoCaptureAttributes.iIdle = attributes.mIdle; - tPhotoCaptureAttributes.iRandomVariance = attributes.mRandomVariance; - - mEngine->ChangePhotoCaptureAttributes(tPhotoCaptureAttributes); -} - -// --------------------------------------------------------------------------- - -BluetoothAttributes EngineWrapper::getBluetoothAttributes() -{ - TBluetoothAttributes tBluetoothAttributes = mEngine->GetBluetoothAttributes(); - BluetoothAttributes attributes; - - attributes.mId = tBluetoothAttributes.iId; - attributes.mPriority = tBluetoothAttributes.iPriority; - attributes.mIdle = tBluetoothAttributes.iIdle; - attributes.mRandomVariance = tBluetoothAttributes.iRandomVariance; - attributes.mBluetoothSupported = tBluetoothAttributes.iBluetoothSupported ? true : false; - return attributes; -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::setBluetoothAttributes(const BluetoothAttributes& attributes) -{ - TBluetoothAttributes tBluetoothAttributes; - - tBluetoothAttributes.iId = attributes.mId; - tBluetoothAttributes.iPriority = attributes.mPriority; - tBluetoothAttributes.iIdle = attributes.mIdle; - tBluetoothAttributes.iRandomVariance = attributes.mRandomVariance; - - mEngine->ChangeBluetoothAttributes(tBluetoothAttributes); -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::ReFreshView(CDesCArray* aTextArray) -{ - QStringList itemList; - TInt arrayCnt = aTextArray->Count(); - for (int i = 0; i < arrayCnt; i++) { - itemList.append(QString::fromUtf16( - aTextArray->MdcaPoint(i).Ptr(), - aTextArray->MdcaPoint(i).Length())); - } - mMainView.setLoadListData(itemList); -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::ClearSelection() -{ - mMainView.clearListSelection(); -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::SetCurrentItemIndex(TInt aIndex) -{ - mMainView.setCurrentItemIndex(aIndex); -} - -// --------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/ui/hb/src/main.cpp --- a/loadgen/ui/hb/src/main.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,42 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include -#include -#include -#include "mainview.h" - - -int main(int argc, char *argv[]) -{ - HbApplication app(argc, argv); - HbMainWindow mainWindow; - - // set as system application to prevent getting shut down events - CEikonEnv::Static()->SetSystem( ETrue ); - - //Create main view - MainView* view = new MainView(mainWindow); - - //initialize main view - view->init(app); - // Add Views to main window and reveal it. - mainWindow.addView(view); - mainWindow.show(); - - return app.exec(); -} diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/ui/hb/src/mainview.cpp --- a/loadgen/ui/hb/src/mainview.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,399 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include "mainview.h" -#include "enginewrapper.h" -#include "notifications.h" -#include "loadgen.hrh" -#include -#include -#include -#include -#include -#include -//#include -//#include -#include -#include -#include -#include - -#include -#include -#include -#include - -// --------------------------------------------------------------------------- - -MainView::MainView(HbMainWindow &mainWindow) : - mMainWindow(mainWindow), - mEngineWrapper(0), - mIsLoadListEmpty(true), - mStopAll(NULL), - mSuspendAll(NULL), - mResumeAll(NULL) - -{ -} - -// --------------------------------------------------------------------------- - -MainView::~MainView() -{ - if (mEngineWrapper != 0) { - delete mEngineWrapper; - } - delete mListModel; - delete mListView; - delete mSm; -} - -// --------------------------------------------------------------------------- - -void MainView::init(HbApplication &app) -{ - this->setTitle("Load Gener."); - mEngineWrapper = new EngineWrapper(mMainWindow, *this); - int error = mEngineWrapper->init(); - Q_ASSERT_X(error == 1, "LoadGen", "Engine initialization failed"); - createMenu(app); - loadListIinit(); -} - -// --------------------------------------------------------------------------- - -void MainView::createMenu(HbApplication &app) -{ - HbMenu *menu = this->menu(); - - // signal mapper for identifying the different command actions - // in executeCommand() handler function: - mSm = new QSignalMapper(this); - connect(mSm, SIGNAL(mapped(int)), this, SLOT(executeMenuCommand(int))); - - if (menu != NULL) { - // Temp work-around for menu item bug in Orbit Wk38, - // sub menu cannot contain more than 6 functional action items! - // two sub menus created to fix this problem. - mLoadSubMenu1 = menu->addMenu("New loads"); - mLoadSubMenu2 = menu->addMenu("More new loads"); - mCpuLoadAction = mLoadSubMenu1->addAction("CPU load"); - connect(mCpuLoadAction, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mCpuLoadAction, ELoadGenCmdNewLoadCPULoad); - - mMemoryEatLoadAction = mLoadSubMenu1->addAction("Eat memory"); - connect(mMemoryEatLoadAction, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mMemoryEatLoadAction, ELoadGenCmdNewLoadEatMemory); - - mPhoneCallLoadAction = mLoadSubMenu1->addAction("Phone calls"); - connect(mPhoneCallLoadAction, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mPhoneCallLoadAction, ELoadGenCmdNewLoadPhoneCall); - - mMessagesLoadAction = mLoadSubMenu1->addAction("Messages"); - connect(mMessagesLoadAction, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mMessagesLoadAction, ELoadGenCmdNewLoadMessages); -//TODO to be fixed using replacement for downloadmanager - - mNetConnLoadAction = mLoadSubMenu1->addAction("Network conn."); - connect(mNetConnLoadAction, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mNetConnLoadAction, ELoadGenCmdNewLoadNetConn); - - mKeyPressLoadAction = mLoadSubMenu2->addAction("Key presses"); - connect(mKeyPressLoadAction, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mKeyPressLoadAction, ELoadGenCmdNewLoadKeyPress); - - mAppsLoadAction = mLoadSubMenu2->addAction("Applications"); - connect(mAppsLoadAction, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mAppsLoadAction, ELoadGenCmdNewLoadApplications); - - mPhotoCapturesLoadAction = mLoadSubMenu2->addAction("Photo captures"); - connect(mPhotoCapturesLoadAction, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mPhotoCapturesLoadAction, ELoadGenCmdNewLoadPhotoCaptures); - - mBtActionsLoadAction = mLoadSubMenu2->addAction("Bluetooth actions"); - connect(mBtActionsLoadAction, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mBtActionsLoadAction, ELoadGenCmdNewLoadBluetooth); - - mPointerEventsLoadAction = mLoadSubMenu2->addAction("Pointer events"); - connect(mPointerEventsLoadAction, SIGNAL( triggered() ), mSm, SLOT(map())); - mSm->setMapping(mPointerEventsLoadAction, ELoadGenCmdNewLoadPointerEvent); - - mActionPerfMon = menu->addAction("Launch PerfMon"); - connect(mActionPerfMon, SIGNAL(triggered()), this, SLOT( launchPerfMon())); - - mActionAbout = menu->addAction("About"); - connect(mActionAbout, SIGNAL(triggered()), this, SLOT( showAboutPopup())); - - mActionExit = menu->addAction("Exit"); - connect(mActionExit, SIGNAL(triggered()), &app, SLOT(quit())); - - // menu dynamic update - connect(menu, SIGNAL(aboutToShow()), this, SLOT(updateMenu())); - } -} - -// --------------------------------------------------------------------------- - -void MainView::loadListIinit() -{ - // Create list view and model for it - mListView = new HbListView(this); - mListModel = new QStandardItemModel(this); - mListView->setModel(mListModel); - mListView->setSelectionMode(HbListView::NoSelection); - mListView->setVisible( false ); //HighlightMode(HbItemHighlight::Hidden); - - QStandardItem *item = new QStandardItem(QString("No loads activated. (Select new load from menu to generate new load)")); - mListModel->setItem(0, item); - - connect(mListView, - SIGNAL(longPressed(HbAbstractViewItem*, QPointF)), - this, - SLOT(handleLoadListEvent(HbAbstractViewItem*, QPointF))); - - - // Create layout and add list view there: - QGraphicsLinearLayout *mainlayout = new QGraphicsLinearLayout(Qt::Vertical, this); - mainlayout->addItem(mListView); - mainlayout->setAlignment(mListView, Qt::AlignCenter); - setLayout(mainlayout); -} - -// --------------------------------------------------------------------------- - -void MainView::showAboutPopup() -{ - Notifications::about(); -} - -// --------------------------------------------------------------------------- - -void MainView::executeMenuCommand(int cmd) -{ - mEngineWrapper->startNewLoad(cmd); -} - -// --------------------------------------------------------------------------- - -void MainView::handleLoadListEvent(HbAbstractViewItem */*listViewItem*/, const QPointF &/*coords*/) -{ - const QStringList items = (QStringList() << "Stop" << "Resume/Suspend" << "Edit"); - HbSelectionDialog *dlg = new HbSelectionDialog(); - dlg->setAttribute(Qt::WA_DeleteOnClose); - dlg->setStringItems(items); - dlg->setSelectionMode(HbAbstractItemView::SingleSelection); - dlg->open(this, SLOT(ItemActionPopupClosed(HbAction*))); -} - -// --------------------------------------------------------------------------- - -void MainView::ItemActionPopupClosed(HbAction* action) -{ - HbSelectionDialog *dlg = static_cast(sender()); - if(!action && dlg->selectedItems().count()){ - int userSelectionIndex = dlg->selectedItems().at(0).toInt(); - // all operations for selected list item only. Query selected load list item index from model. - if (userSelectionIndex == 0) { - // stop selected load from the load list: - stopLoad(false); - } - else if (userSelectionIndex == 1) { - // Suspend or Resume - mEngineWrapper->suspendOrResumeSelectedOrHighlightedItems(); - } - else { - // current selected row number from the load list. - int selectedRow = mListView->selectionModel()->currentIndex().row(); - // edit load setttings: - mEngineWrapper->loadEdit(selectedRow); - } - } -} - -// -------------------------------------------------------------------------- - -void MainView::stopAllLoads() -{ - stopLoad(true); -} - -// --------------------------------------------------------------------------- - -bool MainView::stopLoad(bool stopAll) -{ - int success = false; - if (mListView != NULL) { - if (stopAll == true) { - success = mEngineWrapper->stopLoad(stopAll); - mIsLoadListEmpty = true; - } - else { - success = mEngineWrapper->stopLoad(stopAll); - } - } - return success; -} - -// --------------------------------------------------------------------------- - -void MainView::updateMenu() -{ - if (mIsLoadListEmpty != true) { - if (mStopAll == NULL) { - mStopAll = new HbAction("Stop all", menu()); - connect(mStopAll, SIGNAL(triggered()), this, SLOT(stopAllLoads())); - menu()->insertAction(mActionAbout, mStopAll); - } - else{ - mStopAll->setVisible(true); - } - if (mSuspendAll == NULL) { - mSuspendAll = new HbAction("Suspend all", menu()); - connect(mSuspendAll, SIGNAL(triggered()), this, SLOT(suspendAllLoads())); - menu()->insertAction(mActionAbout, mSuspendAll); - } - else{ - mSuspendAll->setVisible(true); - } - if (mResumeAll == NULL) { - mResumeAll = new HbAction("Resume all", menu()); - connect(mResumeAll, SIGNAL(triggered()), this, SLOT(resumeAllLoads())); - menu()->insertAction(mActionAbout, mResumeAll); - } - else{ - mResumeAll->setVisible(true); - } - } - else if (mIsLoadListEmpty == true) { - if (mStopAll != NULL && mStopAll->text() == "Stop all") { - mStopAll->setVisible(false); - } - if (mSuspendAll != NULL && mSuspendAll->text() == "Suspend all") { - mSuspendAll->setVisible(false); - } - if (mResumeAll != NULL && mResumeAll->text() == "Resume all") { - mSuspendAll->setVisible(false); - } - } -} - - -// --------------------------------------------------------------------------- - -int MainView::currentItemIndex() -{ - return mListView->selectionModel()->currentIndex().row(); -} - -// --------------------------------------------------------------------------- - -void MainView::setCurrentItemIndex(int index) -{ - QModelIndex newIndex = mListView->model()->index(index, 0); - mListView->selectionModel()->setCurrentIndex(newIndex, - QItemSelectionModel::SelectCurrent); - //mListView->setCurrentIndex( index ); //setCurrentRow(index); -} - -// --------------------------------------------------------------------------- - -void MainView::launchPerfMon() -{ - mEngineWrapper->launchPerfMonApp(); -} - -// --------------------------------------------------------------------------- - -QList MainView::listSelectionIndexes() - { - QList indices; - if (mListView != NULL) { - QItemSelectionModel *selectionModel = mListView->selectionModel(); - if (selectionModel->hasSelection()) { - QModelIndexList modelIndexes = selectionModel->selectedIndexes(); - QModelIndex index; - foreach (index, modelIndexes) { - indices.append(index.row()); - } - } - } - return indices; - } - -// -------------------------------------------------------------------------------------------- - -void MainView::suspendAllLoads() -{ - mEngineWrapper->suspendAllLoadItems(); -} - -// --------------------------------------------------------------------------- - -void MainView::resumeAllLoads() -{ - mEngineWrapper->resumeAllLoadItems(); -} - -void MainView::clearListSelection() -{ - if (mListView != NULL) { - mListView->clearSelection(); - } -} - -// --------------------------------------------------------------------------- - -void MainView::setLoadListData(QStringList& items) -{ - QString loadItem; - QString iconName; - - if (mListView) { - mListView->setSelectionMode(HbListView::MultiSelection); - mListView->setVisible(true); //setHighlightMode(HbItemHighlight::AlwaysVisible); - if(mListModel->rowCount()) - { - mListModel->removeRows(0,mListModel->rowCount()); - } -// mListModel->clear(); - } - if (items.count() > 0) { - mIsLoadListEmpty = false; - } - else if (items.count() == 0) { - mIsLoadListEmpty = true; - } - for (int i = 0; i < items.count(); i++) { - QStandardItem *item = new QStandardItem(); - loadItem = items.at(i); - if (loadItem.startsWith("1")) { - iconName = ":/paused.svg"; - } - else { - iconName = ":/active.svg"; - } - // remove icon indicator info from string - // to show in load in load list - loadItem.remove(0,2); - item->setText(loadItem); - item->setIcon(QIcon(iconName)); - // set new load to correct row in load list - mListModel->insertRow(i, item); - } -} - -// --------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/ui/hb/src/notifications.cpp --- a/loadgen/ui/hb/src/notifications.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include -#include -#include - -#include "notifications.h" - - -// --------------------------------------------------------------------------- - -void Notifications::about() -{ - HbMessageBox *messageBox = new HbMessageBox(HbMessageBox::MessageTypeInformation); - messageBox->setText("Version 1.5.2 - September 23rd 2010. Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. Licensed under Eclipse Public License v1.0."); - HbLabel *header = new HbLabel("About LoadGen", messageBox); - messageBox->setHeadingWidget(header); - messageBox->setAttribute(Qt::WA_DeleteOnClose); - messageBox->setTimeout(HbPopup::NoTimeout); - messageBox->open(); -} - -// --------------------------------------------------------------------------- - -void Notifications::error(const QString& errorMessage) -{ - showGlobalNote(errorMessage, HbMessageBox::MessageTypeWarning ); -} - -// --------------------------------------------------------------------------- - -void Notifications::showGlobalNote(const QString& text, HbMessageBox::MessageBoxType type, HbPopup::DefaultTimeout timeout) -{ - HbMessageBox *messageBox = new HbMessageBox(type); - messageBox->setText(text); - messageBox->setTimeout(timeout); - messageBox->setAttribute(Qt::WA_DeleteOnClose); - messageBox->open(); -} - -// --------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 loadgen/ui/hb/src/settingsview.cpp --- a/loadgen/ui/hb/src/settingsview.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1258 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include "settingsview.h" -#include "enginewrapper.h" -#include "loadgen.hrh" -#include "loadgen_loadattributes.h" -#include -#include -//#include -#include -#include -#include -//#include -#include -#include -#include -#include -#include -#include -#include - - -#include - -QStringList PRIORITIES = (QStringList() << "Much less (-20)" << "Less (-10)" << "Normal (0)" << "More (10)" - << "Much more (20)" << "Real time (30)" << "Abs. very low (100)" << "Abs. low (200)" - << "Abs. backgr. (300)" << "Abs. foregr. (400)" << "Abs. high (500)"); -QStringList LOADMODES = (QStringList() << "Yielding" << "Blocking"); -QStringList CPULOADTYPES = (QStringList() << "Continuous" << "Periodic"); -QStringList MEMSOURCES = (QStringList() << "RAM" << "C:" << "D:" << "E:" << "F:" << "G:" << "H:" << "J:" << "K:" - << "L:" << "M:" << "N:"); -QStringList MEMEATTYPES = (QStringList() << "Memory to eat" << "Memory to be left" << "Alternate min/max"); -QStringList KEYPRESSTYPES = (QStringList() << "None" << "Arrow keys"); -QStringList MESSAGETYPES = (QStringList() << "SMS" << "MMS"); - - -SettingsView::SettingsView(HbView &mainView, HbMainWindow &parent, EngineWrapper &engine) - - : mMainWindow(parent), - mMainView(mainView), - mEngineWrapper(engine), - mAmount(NULL), - mMinAmountToBeLeft(NULL), - mMaxAmountToBeLeft(NULL), - mLength(NULL), - mIdle(NULL), - mRandomVar(NULL) -{ -} - -SettingsView::~SettingsView() -{ - -} - -// TODO HbDataFormModelItem data operations does not work correctly with WK38. -// Item data does not get updated correctly as set by initial settings(HbDataFormModelItem::RadioButtonListItem) -// or user settings.(HbDataFormModelItem::TextItem) - -// --------------------------------------------------------------------------- - -void SettingsView::open(const QString &settingsName, TLoadGenCommandIds cmdId) -{ - mCmdId = cmdId; - // Remove main view from main window and add this view to main window - mMainWindow.addView(this); - mMainWindow.setCurrentView(this); - setTitle(settingsName); - - //create toolbar showing launch popup - HbToolBar *toolBar = this->toolBar(); - HbAction *actionOk = new HbAction("Ok", toolBar); - HbAction *actionCancel = new HbAction("Cancel", toolBar); - toolBar->addAction( actionOk ); - toolBar->addAction( actionCancel ); - - //create setting form - mSettingForm = new HbDataForm(); - - //create a model class - mModel = new HbDataFormModel(this); - createItems(mModel, 0); - // Set created model to form - mSettingForm->setModel(mModel); - setWidget(mSettingForm); - loadAttributes(); - - connect(actionOk, SIGNAL(triggered()), this, SLOT(okExit())); - connect(actionCancel, SIGNAL(triggered()), this, SLOT(cancelled())); - connect(this, SIGNAL(aboutToClose()), this, SLOT(backButtonPressed())); - //connect(mSettingForm, SIGNAL(activated(const QModelIndex)), this, SLOT(dataItemDisplayed(const QModelIndex))); - show(); -} - -// --------------------------------------------------------------------------- - -void SettingsView::createItems(HbDataFormModel *model, - HbDataFormModelItem *parent) -{ - switch (mCmdId) { - case ELoadGenCmdNewLoadCPULoad: { - createCpuLoadItems(model, parent); - break; - } - case ELoadGenCmdNewLoadEatMemory: { - createEatMemoryItems(model, parent); - break; - } - case ELoadGenCmdNewLoadPhoneCall: { - createPhoneCallItems(model, parent); - break; - } - case ELoadGenCmdNewLoadNetConn: { - createNetConnItems(model, parent); - break; - } - case ELoadGenCmdNewLoadKeyPress: - case ELoadGenCmdNewLoadPointerEvent: { - createKeyOrPointerItems(model, parent); - break; - } - case ELoadGenCmdNewLoadMessages: { - createMessageItems(model, parent); - break; - } - case ELoadGenCmdNewLoadApplications: { - createAppsItems(model, parent); - break; - } - case ELoadGenCmdNewLoadPhotoCaptures: { - createPhotoItems(model, parent); - break; - } - case ELoadGenCmdNewLoadBluetooth: { - createBtItems(model, parent); - break; - } - default: { - break; - } - } -} - -// --------------------------------------------------------------------------- - -void SettingsView::createCpuLoadItems(HbDataFormModel *model, HbDataFormModelItem *parent) -{ - - mLoadSettings = model->appendDataFormGroup(QString("CPU load settings"), parent); - - // DataFormItem for priority selection - mPriority = model->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem, - QString("Priority"), - mLoadSettings); - mPriority->setContentWidgetData(QString("items"), PRIORITIES); - - // DataFormItem for load mode selection - mLoadMode = model->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem, - QString("Load mode"), - mLoadSettings); - mLoadMode->setContentWidgetData(QString("items"), LOADMODES); - - // DataFormItem for load type selection - mType = model->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem, - QString("Type"), - mLoadSettings); - mType->setContentWidgetData(QString("items"), CPULOADTYPES); - - mSettingForm->addConnection(mType,SIGNAL(itemSelected(int)),this,SLOT(selectionChanged(int))); -} - -// --------------------------------------------------------------------------- - -void SettingsView::createEatMemoryItems(HbDataFormModel *model, HbDataFormModelItem *parent) -{ - mLoadSettings = model->appendDataFormGroup(QString("Eat memory settings"), parent); - - // DataFormItem for priority selection - mPriority = model->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem, - QString("Priority"), - mLoadSettings); - mPriority->setContentWidgetData(QString("items"), PRIORITIES); - - // DataFormItem for memory eat type selection - mSource = model->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem, - QString("Source"), - mLoadSettings); - mSource->setContentWidgetData(QString("items"), MEMSOURCES); - - - // DataFormItem for memory eat type selection - mType = model->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem, - QString("Type"), - mLoadSettings); - mType->setContentWidgetData(QString("items"), MEMEATTYPES); - - // DataFormItem for idle length selection - mBuffer = model->appendDataFormItem(HbDataFormModelItem::TextItem, - QString("Buffer (B)"), - mLoadSettings); - mBuffer->setContentWidgetData("maximum" , 999999999); - mBuffer->setContentWidgetData("minimum", 0); - - // DataFormItem for idle length selection - mIdle = model->appendDataFormItem(HbDataFormModelItem::TextItem, - QString("Idle after buffer (ms)"), - mLoadSettings); - mIdle->setContentWidgetData("maximum" , 999999999); - mIdle->setContentWidgetData("minimum", 0); - - mRandomVar = model->appendDataFormItem(HbDataFormModelItem::TextItem, - QString("Random variance (%)"), - mLoadSettings); - mRandomVar->setContentWidgetData("maximum" , 100); - mRandomVar->setContentWidgetData("minimum", 0); - - mSettingForm->addConnection(mType,SIGNAL(itemSelected(int)),this,SLOT(selectionChanged(int))); -} - -// --------------------------------------------------------------------------- - -void SettingsView::createPhoneCallItems(HbDataFormModel *model, HbDataFormModelItem *parent) -{ - - mLoadSettings = model->appendDataFormGroup(QString("Phone calls settings"), parent); - - // DataFormItem for priority selection - mPriority = model->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem, - QString("Priority"), - mLoadSettings); - mPriority->setContentWidgetData(QString("items"), PRIORITIES); - - mDestination = mModel->appendDataFormItem(HbDataFormModelItem::TextItem, - QString("Phone number:"), - mLoadSettings); - mDestination->setContentWidgetData("maximum" , 99999999999999999999.0 ); - mDestination->setContentWidgetData("minimum", 0); - - mLength = mModel->appendDataFormItem(HbDataFormModelItem::TextItem, - QString("Length (ms)"), - mLoadSettings); - mLength->setContentWidgetData("maximum" , 999999999); - mLength->setContentWidgetData("minimum", 0); - - // DataFormItem for idle length selection - mIdle = model->appendDataFormItem(HbDataFormModelItem::TextItem, - QString("Idle (ms)"), - mLoadSettings); - mIdle->setContentWidgetData("maximum" , 999999999); - mIdle->setContentWidgetData("minimum", 0); - - mRandomVar = model->appendDataFormItem(HbDataFormModelItem::TextItem, - QString("Random variance (%)"), - mLoadSettings); - mRandomVar->setContentWidgetData("maximum" , 100); - mRandomVar->setContentWidgetData("minimum", 0); -} - -// --------------------------------------------------------------------------- - -void SettingsView::createNetConnItems(HbDataFormModel *model, HbDataFormModelItem *parent) -{ - - mLoadSettings = model->appendDataFormGroup(QString("Network conn. settings"), parent); - - // DataFormItem for priority selection - mPriority = model->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem, - QString("Priority"), - mLoadSettings); - mPriority->setContentWidgetData(QString("items"), PRIORITIES); - - mDestination = mModel->appendDataFormItem(HbDataFormModelItem::TextItem, - QString("Destination URL:"), - mLoadSettings); - - // DataFormItem for idle length selection - mIdle = model->appendDataFormItem(HbDataFormModelItem::TextItem, - QString("Idle (ms)"), - mLoadSettings); - mIdle->setContentWidgetData("maximum" , 999999999); - mIdle->setContentWidgetData("minimum", 0); - - mRandomVar = model->appendDataFormItem(HbDataFormModelItem::TextItem, - QString("Random variance (%)"), - mLoadSettings); - mRandomVar->setContentWidgetData("maximum" , 100); - mRandomVar->setContentWidgetData("minimum", 0); -} - -// --------------------------------------------------------------------------- - -void SettingsView::createKeyOrPointerItems(HbDataFormModel *model, HbDataFormModelItem *parent) -{ - QString settingsName; - if (mCmdId == ELoadGenCmdNewLoadPointerEvent) { - settingsName = "Pointer events settings"; - } - else { - settingsName = "Key presses settings"; - } - mLoadSettings = model->appendDataFormGroup(settingsName, parent); - - // DataFormItem for priority selection - mPriority = model->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem, - QString("Priority"), - mLoadSettings); - mPriority->setContentWidgetData(QString("items"), PRIORITIES); - - - // DataFormItem for heartbeat length selection - mHeartBeat = model->appendDataFormItem(HbDataFormModelItem::TextItem, - QString("Heartbeat (ms)"), - mLoadSettings); - mHeartBeat->setContentWidgetData("maximum" , 999999999); - mHeartBeat->setContentWidgetData("minimum", 0); - - // Random variance - mRandomVar = model->appendDataFormItem(HbDataFormModelItem::TextItem, - QString("Random variance (%)"), - mLoadSettings); - mRandomVar->setContentWidgetData("maximum" , 100); - mRandomVar->setContentWidgetData("minimum", 0); -} - -// --------------------------------------------------------------------------- - -void SettingsView::createMessageItems(HbDataFormModel *model, HbDataFormModelItem *parent) -{ - mLoadSettings = model->appendDataFormGroup(QString("Messages settings"), parent); - - // DataFormItem for priority selection - mPriority = model->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem, - QString("Priority"), - mLoadSettings); - mPriority->setContentWidgetData(QString("items"), PRIORITIES); - - - mType = model->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem, - QString("Type"), - mLoadSettings); - mType->setContentWidgetData(QString("items"), MESSAGETYPES); - - - mDestination = mModel->appendDataFormItem(HbDataFormModelItem::TextItem, - QString("Phone number:"), - mLoadSettings); - mDestination->setContentWidgetData("maximum" , 99999999999999999999.0 ); - mDestination->setContentWidgetData("minimum", 0); - - mAmount = mModel->insertDataFormItem(3, HbDataFormModelItem::TextItem, - QString("Maximum amount of messages"), - mLoadSettings); - mAmount->setContentWidgetData("maximum" , 1000); - mAmount->setContentWidgetData("minimum", 0); - - mLength = mModel->appendDataFormItem(HbDataFormModelItem::TextItem, - QString("Message length"), - mLoadSettings); - mLength->setContentWidgetData("maximum" , 999999999); - mLength->setContentWidgetData("minimum", 0); - - // DataFormItem for idle length selection - mIdle = model->appendDataFormItem(HbDataFormModelItem::TextItem, - QString("Idle (ms)"), - mLoadSettings); - mIdle->setContentWidgetData("maximum" , 999999999); - mIdle->setContentWidgetData("minimum", 0); - - mRandomVar = model->appendDataFormItem(HbDataFormModelItem::TextItem, - QString("Random variance (%)"), - mLoadSettings); - mRandomVar->setContentWidgetData("maximum" , 100); - mRandomVar->setContentWidgetData("minimum", 0); -} - -// --------------------------------------------------------------------------- - -void SettingsView::createAppsItems(HbDataFormModel *model, HbDataFormModelItem *parent) -{ - mLoadSettings = model->appendDataFormGroup(QString("Applications settings"), parent); - - // DataFormItem for priority selection - mPriority = model->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem, - QString("Priority"), - mLoadSettings); - mPriority->setContentWidgetData(QString("items"), PRIORITIES); - - mMaxParallelApps = model->appendDataFormItem(HbDataFormModelItem::TextItem, - QString("Max parallel applications"), - mLoadSettings); - mMaxParallelApps->setContentWidgetData("maximum" , 100); - mMaxParallelApps->setContentWidgetData("minimum", 0); - - - // DataFormItem for launching interval length selection - mLaunchingInterval = model->appendDataFormItem(HbDataFormModelItem::TextItem, - QString("Launching interval (ms)"), - mLoadSettings); - mLaunchingInterval->setContentWidgetData("maximum" , 999999999); - mLaunchingInterval->setContentWidgetData("minimum", 0); - - // DataFormItem for key press type selection - mKeyPressType = model->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem, - QString("Key press type"), - mLoadSettings); - mKeyPressType->setContentWidgetData(QString("items"), KEYPRESSTYPES); - - // DataFormItem for heartbeat length selection - mHeartBeat = model->appendDataFormItem(HbDataFormModelItem::TextItem, - QString("Key press interval (ms)"), - mLoadSettings); - mHeartBeat->setContentWidgetData("maximum" , 999999999); - mHeartBeat->setContentWidgetData("minimum", 0); - - // Random variance - mRandomVar = model->appendDataFormItem(HbDataFormModelItem::TextItem, - QString("Random variance (%)"), - mLoadSettings); - mRandomVar->setContentWidgetData("maximum" , 100); - mRandomVar->setContentWidgetData("minimum", 0); -} - -// --------------------------------------------------------------------------- - -void SettingsView::createPhotoItems(HbDataFormModel *model, HbDataFormModelItem *parent) -{ - mLoadSettings = model->appendDataFormGroup(QString("Camera settings"), parent); - - // DataFormItem for priority selection - mPriority = model->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem, - QString("Priority"), - mLoadSettings); - mPriority->setContentWidgetData(QString("items"), PRIORITIES); - - - // DataFormItem for idle length selection - mIdle = model->appendDataFormItem(HbDataFormModelItem::TextItem, - QString("Idle (ms)"), - mLoadSettings); - mIdle->setContentWidgetData("maximum" , 999999999); - mIdle->setContentWidgetData("minimum", 0); - - // Random variance - mRandomVar = model->appendDataFormItem(HbDataFormModelItem::TextItem, - QString("Random variance (%)"), - mLoadSettings); - mRandomVar->setContentWidgetData("maximum" , 100); - mRandomVar->setContentWidgetData("minimum", 0); -} - -// --------------------------------------------------------------------------- - -void SettingsView::createBtItems(HbDataFormModel *model, HbDataFormModelItem *parent) -{ - mLoadSettings = model->appendDataFormGroup(QString("Bluetooth settings"), parent); - - // DataFormItem for priority selection - mPriority = model->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem, - QString("Priority"), - mLoadSettings); - mPriority->setContentWidgetData(QString("items"), PRIORITIES); - - - // DataFormItem for idle length selection - mIdle = model->appendDataFormItem(HbDataFormModelItem::TextItem, - QString("Idle (ms)"), - mLoadSettings); - mIdle->setContentWidgetData("maximum" , 999999999); - mIdle->setContentWidgetData("minimum", 0); - - // Random variance - mRandomVar = model->appendDataFormItem(HbDataFormModelItem::TextItem, - QString("Random variance (%)"), - mLoadSettings); - mRandomVar->setContentWidgetData("maximum" , 100); - mRandomVar->setContentWidgetData("minimum", 0); -} - -// --------------------------------------------------------------------------- -// Load attributes from engine & set the data into each form model item: - -void SettingsView::loadAttributes() -{ - switch (mCmdId) - { - case ELoadGenCmdNewLoadCPULoad: { - mCPULoadAttributes = mEngineWrapper.getCpuLoadAttributes(); - mPriority->setContentWidgetData(QString("selected"), mCPULoadAttributes.mPriority); - mLoadMode->setContentWidgetData(QString("selected"), mCPULoadAttributes.mMode); - mType->setContentWidgetData(QString("selected"), mCPULoadAttributes.mType); - - if (mCPULoadAttributes.mType == ECpuLoadTypePeriodic) { //if (mCPULoadAttributes.mMode == ECpuLoadTypePeriodic) { - // Create and append to model these items: Length, Idle, Random variance, if load type is peridodic. - - // DataFormItem for load length selection - mLength = mModel->appendDataFormItem(HbDataFormModelItem::TextItem, - QString("Length (ms)"), - mLoadSettings); - mLength->setContentWidgetData("maximum" , 999999999); - mLength->setContentWidgetData("minimum", 0); - - - // DataFormItem for load length selection - mIdle = mModel->appendDataFormItem(HbDataFormModelItem::TextItem, - QString("Idle (ms)"), - mLoadSettings); - mIdle->setContentWidgetData("maximum" , 999999999); - mIdle->setContentWidgetData("minimum", 0); - - mRandomVar = mModel->appendDataFormItem(HbDataFormModelItem::TextItem, - QString("Random variance (%)"), - mLoadSettings); - mRandomVar->setContentWidgetData("maximum" , 100); - mRandomVar->setContentWidgetData("minimum", 0); - - mLength->setContentWidgetData(QString("text"), mCPULoadAttributes.mLength); - mIdle->setContentWidgetData(QString("text"), mCPULoadAttributes.mIdle); - mRandomVar->setContentWidgetData(QString("text"), mCPULoadAttributes.mRandomVariance); - } - - // if there's more than one cpu available in the system, - // insert possibility to select which cpu the load is generated to - if (mCPULoadAttributes.mCpuCount > 1) - { - QStringList cpuArray; - cpuArray.append("Free scheduling"); - // add cpus to list: - for (int i = 0; i < mCPULoadAttributes.mCpuCount; i++) - { - QString cpu = QString("CPU%1").arg(i); - cpuArray.append(cpu); - } - // "All CPUs" means that one thread is started for each CPU. - cpuArray.append("All CPUs"); - - mCpu = mModel->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem, - QString("CPU"), - mLoadSettings); - mCpu->setContentWidgetData(QString("items"), cpuArray); - - if (mCPULoadAttributes.mCpu < 0) { - mCpu->setContentWidgetData(QString("selected"), 0); - } - - else if (mCPULoadAttributes.mCpu == KCPUSelection_AllCPUs) { - mCpu->setContentWidgetData(QString("selected"), cpuArray.count()-1); - } - // CPU is defined, set the correct CPU as default selection in query list - else { - // mCpu starts from zero (i.e. CPU0 is first CPU), but index zero - // in settings Ui form item is reserved for "Free scheduling", hence iCpu+1. - mCpu->setContentWidgetData(QString("selected"), mCPULoadAttributes.mCpu+1); - } - } - break; - } - case ELoadGenCmdNewLoadEatMemory: { - mMemoryEatAttributes = mEngineWrapper.getMemoryEatAttributes(); - mPriority->setContentWidgetData(QString("selected"), mMemoryEatAttributes.mPriority); - mSource->setContentWidgetData(QString("selected"), mMemoryEatAttributes.mSource); - mType->setContentWidgetData(QString("selected"), mMemoryEatAttributes.mType); - - if (mMemoryEatAttributes.mType == EMemoryEatTypeWavy) { - mMinAmountToBeLeft = mModel->insertDataFormItem(3, HbDataFormModelItem::TextItem, - QString("Min to be left (B)"), - mLoadSettings); - mMinAmountToBeLeft->setContentWidgetData("maximum" , 99999999999999); - mMinAmountToBeLeft->setContentWidgetData("minimum", 0); - - mMaxAmountToBeLeft = mModel->insertDataFormItem(4, HbDataFormModelItem::TextItem, - QString("Max to be left (B)"), - mLoadSettings); - mMaxAmountToBeLeft->setContentWidgetData("maximum" , 99999999999999); - mMaxAmountToBeLeft->setContentWidgetData("minimum", 0); - - mMinAmountToBeLeft->setContentWidgetData(QString("text"), mMemoryEatAttributes.mRandomMinDes); - mMaxAmountToBeLeft->setContentWidgetData(QString("text"), mMemoryEatAttributes.mRandomMaxDes); - } - else if (mMemoryEatAttributes.mType == EMemoryEatTypeMemoryToEat || - mMemoryEatAttributes.mType == EMemoryEatTypeMemoryToBeLeft ) { - mAmount = mModel->insertDataFormItem(3, HbDataFormModelItem::TextItem, - QString("Amout(B)"), - mLoadSettings); - mAmount->setContentWidgetData("maximum" , 99999999999999); - mAmount->setContentWidgetData("minimum", 0); - - mAmount->setContentWidgetData(QString("text"), mMemoryEatAttributes.mAmount); - } - mBuffer->setContentWidgetData(QString("text"), mMemoryEatAttributes.mBuffer); - mIdle->setContentWidgetData(QString("text"), mMemoryEatAttributes.mIdle); - mRandomVar->setContentWidgetData(QString("text"), mMemoryEatAttributes.mRandomVariance); - break; - } - case ELoadGenCmdNewLoadPhoneCall: { - mPhoneCallAttributes = mEngineWrapper.getPhoneCallAttributes(); - mPriority->setContentWidgetData(QString("selected"), mPhoneCallAttributes.mPriority); - mDestination->setContentWidgetData(QString("text"), mPhoneCallAttributes.mDestination); - mLength->setContentWidgetData(QString("text"), mPhoneCallAttributes.mLength); - mIdle->setContentWidgetData(QString("text"), mPhoneCallAttributes.mIdle); - mRandomVar->setContentWidgetData(QString("text"), mPhoneCallAttributes.mRandomVariance); - break; - } - case ELoadGenCmdNewLoadNetConn: { - mNetConnAttributes = mEngineWrapper.getNetConnAttributes(); - mPriority->setContentWidgetData(QString("selected"), mNetConnAttributes.mPriority); - mDestination->setContentWidgetData(QString("text"), mNetConnAttributes.mDestination); - mIdle->setContentWidgetData(QString("text"), mNetConnAttributes.mIdle); - mRandomVar->setContentWidgetData(QString("text"), mNetConnAttributes.mRandomVariance); - break; - } - case ELoadGenCmdNewLoadKeyPress: { - mKeyPressAttributes = mEngineWrapper.getKeyPressAttributes(); - mPriority->setContentWidgetData(QString("selected"), mKeyPressAttributes.mPriority); - mHeartBeat->setContentWidgetData(QString("text"), mKeyPressAttributes.mHeartBeat); - mRandomVar->setContentWidgetData(QString("text"), mKeyPressAttributes.mRandomVariance); - break; - } - case ELoadGenCmdNewLoadPointerEvent: { - mPointerEventAttributes = mEngineWrapper.getPointerEventAttributes(); - mPriority->setContentWidgetData(QString("selected"), mPointerEventAttributes.mPriority); - mHeartBeat->setContentWidgetData(QString("text"), mPointerEventAttributes.mHeartBeat); - mRandomVar->setContentWidgetData(QString("text"), mPointerEventAttributes.mRandomVariance); - break; - } - case ELoadGenCmdNewLoadMessages: { - mMessageAttributes = mEngineWrapper.getMessageAttributes(); - mPriority->setContentWidgetData(QString("selected"), mMessageAttributes.mPriority); - mType->setContentWidgetData(QString("selected"), mMessageAttributes.mMessageType); - mDestination->setContentWidgetData(QString("text"), mMessageAttributes.mDestination); - mAmount->setContentWidgetData(QString("text"), mMessageAttributes.mAmount); - mLength->setContentWidgetData(QString("text"), mMessageAttributes.mLength); - mIdle->setContentWidgetData(QString("text"), mMessageAttributes.mIdle); - mRandomVar->setContentWidgetData(QString("text"), mMessageAttributes.mRandomVariance); - break; - } - case ELoadGenCmdNewLoadApplications: { - mApplicationsAttributes = mEngineWrapper.getApplicationsAttributes(); - mPriority->setContentWidgetData(QString("selected"), mApplicationsAttributes.mPriority); - mMaxParallelApps->setContentWidgetData(QString("text"), mApplicationsAttributes.mMaxOpen); - mHeartBeat->setContentWidgetData(QString("text"), mApplicationsAttributes.mHeartBeat); - mLaunchingInterval->setContentWidgetData(QString("text"), mApplicationsAttributes.mLaunchingInterval); - mKeyPressType->setContentWidgetData(QString("selected"), mApplicationsAttributes.mKeyPressType); - mRandomVar->setContentWidgetData(QString("text"), mApplicationsAttributes.mRandomVariance); - break; - } - case ELoadGenCmdNewLoadPhotoCaptures: { - mPhotoCaptureAttributes = mEngineWrapper.getPhotoCaptureAttributes(); - mPriority->setContentWidgetData(QString("selected"), mPhotoCaptureAttributes.mPriority); - mIdle->setContentWidgetData(QString("text"), mPhotoCaptureAttributes.mIdle); - mRandomVar->setContentWidgetData(QString("text"), mPhotoCaptureAttributes.mRandomVariance); - - // if there's any cameras avaialable in system, construct form item for it/them: - if (mPhotoCaptureAttributes.mCameraCount > 0) - { - QStringList devices; - // add cameras to list: - for (int i = 0; i < mPhotoCaptureAttributes.mCameraCount; i++) - { - QString cam = QString("Camera %1").arg(i); - devices.append(cam); - } - mCamera = mModel->insertDataFormItem(1, HbDataFormModelItem::RadioButtonListItem, - QString("Device"), - mLoadSettings); - mCamera->setContentWidgetData(QString("items"), devices); - mCamera->setContentWidgetData(QString("selected"), mPhotoCaptureAttributes.mCamera); - } - break; - } - case ELoadGenCmdNewLoadBluetooth: { - mBluetoothAttributes = mEngineWrapper.getBluetoothAttributes(); - mPriority->setContentWidgetData(QString("selected"), mBluetoothAttributes.mPriority); - mIdle->setContentWidgetData(QString("text"), mBluetoothAttributes.mIdle); - mRandomVar->setContentWidgetData(QString("text"), mBluetoothAttributes.mRandomVariance); - break; - } - - default: { - break; - } - } -} - -// --------------------------------------------------------------------------- - -void SettingsView::setDefaultSettings() -{ - -} - -// --------------------------------------------------------------------------- - -void SettingsView::backButtonPressed() -{ - okExit(); -} - -// --------------------------------------------------------------------------- - -void SettingsView::saveSettings() -{ - switch (mCmdId) { - case ELoadGenCmdNewLoadCPULoad: { - saveCpuLoadSettings(); - break; - } - case ELoadGenCmdNewLoadEatMemory: { - saveEatMemorySettings(); - break; - } - case ELoadGenCmdNewLoadPhoneCall: { - savePhoneCallSettings(); - break; - } - case ELoadGenCmdNewLoadNetConn: { - saveNetConnSettings(); - break; - } - case ELoadGenCmdNewLoadKeyPress: { - saveKeyPressSettings(); - break; - } - case ELoadGenCmdNewLoadPointerEvent: { - savePointerEventSettings(); - break; - } - case ELoadGenCmdNewLoadMessages: { - saveMessageSettings(); - break; - } - case ELoadGenCmdNewLoadApplications: { - saveApplicationsSettings(); - break; - } - case ELoadGenCmdNewLoadPhotoCaptures: { - savePhotoSettings(); - break; - } - case ELoadGenCmdNewLoadBluetooth: { - saveBtSettings(); - break; - } - default: { - break; - } - } -} - -// --------------------------------------------------------------------------- - -void SettingsView::saveCpuLoadSettings() -{ - mCPULoadAttributes.mPriority = mPriority->contentWidgetData("selected").toInt(); - mCPULoadAttributes.mMode = mLoadMode->contentWidgetData("selected").toInt(); - mCPULoadAttributes.mType = mType->contentWidgetData("selected").toInt(); - if (mType->contentWidgetData("selected").toInt() == ECpuLoadTypePeriodic) { - // TODO: remove temp checks if (mLength != NULL) etc. when HbDataFormModelItem bugs fixed. - if (mLength != NULL) { - mCPULoadAttributes.mLength = mLength->contentWidgetData("text").toInt(); - } - if (mIdle != NULL) { - mCPULoadAttributes.mIdle = mIdle->contentWidgetData("text").toInt(); - } - if (mRandomVar != NULL) { - int randVar = mRandomVar->contentWidgetData("text").toInt(); - if( randVar >=0 && randVar <= mRandomVar->contentWidgetData("maximum").toInt() ) - { - mCPULoadAttributes.mRandomVariance = mRandomVar->contentWidgetData("text").toInt(); - } - else - { - mCPULoadAttributes.mRandomVariance = mRandomVar->contentWidgetData("maximum").toInt(); - } - } - } - - // we are running in SMP environment - if (mCPULoadAttributes.mCpuCount > 1) - { - TInt currentValueIndex = mCpu->contentWidgetData("selected").toInt(); - // user selected a specific CPU in which the load thread should be run in. - if (currentValueIndex == 0) - { - // User selected "Free scheduling" - mCPULoadAttributes.mCpu = KCPUSelection_FreeScheduling; - } - else if( currentValueIndex == (mCpu->childCount()-1) ) - { - // User selected "All CPUs", which is the last item in the form radio button selection list - mCPULoadAttributes.mCpu = KCPUSelection_AllCPUs; - } - else - { - // mCpu should start from zero (CPU0 is the first cpu) - // but zero in Ui form item index means "Free scheduling". CPU0 in - // index of form radio button list is at index 1, hence -1. - mCPULoadAttributes.mCpu = currentValueIndex - 1; - } - } - - -} - -// --------------------------------------------------------------------------- - -void SettingsView::saveEatMemorySettings() -{ - mMemoryEatAttributes.mPriority = mPriority->contentWidgetData("selected").toInt(); - mMemoryEatAttributes.mSource = mSource->contentWidgetData("selected").toInt(); - mMemoryEatAttributes.mType = mType->contentWidgetData("selected").toInt(); - - if (mType->contentWidgetData("selected").toInt() == EMemoryEatTypeWavy) { - // TODO: remove temp checks if (mLength != NULL) etc. when HbDataFormModelItem bugs fixed. - if (mMinAmountToBeLeft != NULL) { - mMemoryEatAttributes.mRandomMin = - mMinAmountToBeLeft->contentWidgetData("text").toInt(); - } - if (mMaxAmountToBeLeft != NULL) { - mMemoryEatAttributes.mRandomMax = - mMaxAmountToBeLeft->contentWidgetData("text").toInt(); - } - } - else if (mType->contentWidgetData("selected").toInt() == EMemoryEatTypeMemoryToEat || - mType->contentWidgetData("selected").toInt() == EMemoryEatTypeMemoryToBeLeft) { - if (mAmount != NULL) { - mMemoryEatAttributes.mAmount = mAmount->contentWidgetData("text").toInt(); - } - } - mMemoryEatAttributes.mBuffer = mBuffer->contentWidgetData("text").toInt(); - mMemoryEatAttributes.mIdle = mIdle->contentWidgetData("text").toInt(); - - int randVar = mRandomVar->contentWidgetData("text").toInt(); - if( randVar >=0 && randVar <= mRandomVar->contentWidgetData("maximum").toInt() ) - { - mMemoryEatAttributes.mRandomVariance = mRandomVar->contentWidgetData("text").toInt(); - } - else - { - mMemoryEatAttributes.mRandomVariance = mRandomVar->contentWidgetData("maximum").toInt(); - } - - // swap min- & max values if they are in wrong order - if (mMemoryEatAttributes.mRandomMin > mMemoryEatAttributes.mRandomMax) - { - qint64 temp(mMemoryEatAttributes.mRandomMin); - mMemoryEatAttributes.mRandomMin = mMemoryEatAttributes.mRandomMax; - mMemoryEatAttributes.mRandomMax = temp; - } -} - -// --------------------------------------------------------------------------- - -void SettingsView::savePhoneCallSettings() -{ - mPhoneCallAttributes.mPriority = mPriority->contentWidgetData("selected").toInt(); - mPhoneCallAttributes.mLength = mLength->contentWidgetData("text").toInt(); - mPhoneCallAttributes.mIdle = mIdle->contentWidgetData("text").toInt(); - - int randVar = mRandomVar->contentWidgetData("text").toInt(); - if( randVar >=0 && randVar <= mRandomVar->contentWidgetData("maximum").toInt() ) - { - mPhoneCallAttributes.mRandomVariance = mRandomVar->contentWidgetData("text").toInt(); - } - else - { - mPhoneCallAttributes.mRandomVariance = mRandomVar->contentWidgetData("maximum").toInt(); - } - - - mPhoneCallAttributes.mDestination = mDestination->contentWidgetData("text").toString(); -} - -// --------------------------------------------------------------------------- - -void SettingsView::saveNetConnSettings() -{ - mPhoneCallAttributes.mPriority = mPriority->contentWidgetData("selected").toInt(); - mPhoneCallAttributes.mIdle = mIdle->contentWidgetData("text").toInt(); - int randVar = mRandomVar->contentWidgetData("text").toInt(); - if( randVar >=0 && randVar <= mRandomVar->contentWidgetData("maximum").toInt() ) - { - mPhoneCallAttributes.mRandomVariance = mRandomVar->contentWidgetData("text").toInt(); - } - else - { - mPhoneCallAttributes.mRandomVariance = mRandomVar->contentWidgetData("maximum").toInt(); - } - mPhoneCallAttributes.mDestination = mDestination->contentWidgetData("text").toString(); -} - -// --------------------------------------------------------------------------- - -void SettingsView::saveKeyPressSettings() -{ - mKeyPressAttributes.mPriority = mPriority->contentWidgetData("selected").toInt(); - mKeyPressAttributes.mHeartBeat = mHeartBeat->contentWidgetData("text").toInt(); - int randVar = mRandomVar->contentWidgetData("text").toInt(); - if( randVar >=0 && randVar <= mRandomVar->contentWidgetData("maximum").toInt() ) - { - mKeyPressAttributes.mRandomVariance = mRandomVar->contentWidgetData("text").toInt(); - } - else - { - mKeyPressAttributes.mRandomVariance = mRandomVar->contentWidgetData("maximum").toInt(); - } - -} - -// --------------------------------------------------------------------------- - -void SettingsView::savePointerEventSettings() -{ - mPointerEventAttributes.mPriority = mPriority->contentWidgetData("selected").toInt(); - mPointerEventAttributes.mHeartBeat = mHeartBeat->contentWidgetData("text").toInt(); - int randVar = mRandomVar->contentWidgetData("text").toInt(); - if( randVar >=0 && randVar <= mRandomVar->contentWidgetData("maximum").toInt() ) - { - mPointerEventAttributes.mRandomVariance = mRandomVar->contentWidgetData("text").toInt(); - } - else - { - mPointerEventAttributes.mRandomVariance = mRandomVar->contentWidgetData("maximum").toInt(); - } - -} - -// --------------------------------------------------------------------------- - -void SettingsView::saveMessageSettings() -{ - mMessageAttributes.mPriority = mPriority->contentWidgetData("selected").toInt(); - mMessageAttributes.mMessageType = mType->contentWidgetData("selected").toInt(); - mMessageAttributes.mDestination = mDestination->contentWidgetData("text").toString(); - int amount = mAmount->contentWidgetData("text").toInt(); - if( amount >=0 && amount <= mAmount->contentWidgetData("maximum").toInt() ) - { - mMessageAttributes.mAmount = mAmount->contentWidgetData("text").toInt(); - } - else - { - mMessageAttributes.mAmount = mAmount->contentWidgetData("maximum").toInt(); - } - mMessageAttributes.mLength = mLength->contentWidgetData("text").toInt(); - mMessageAttributes.mIdle = mIdle->contentWidgetData("text").toInt(); - int randVar = mRandomVar->contentWidgetData("text").toInt(); - if( randVar >=0 && randVar <= mRandomVar->contentWidgetData("maximum").toInt() ) - { - mMessageAttributes.mRandomVariance = mRandomVar->contentWidgetData("text").toInt(); - } - else - { - mMessageAttributes.mRandomVariance = mRandomVar->contentWidgetData("maximum").toInt(); - } - -} - -// --------------------------------------------------------------------------- - -void SettingsView::saveApplicationsSettings() -{ - mApplicationsAttributes.mPriority = mPriority->contentWidgetData("selected").toInt(); - int maxApps = mMaxParallelApps->contentWidgetData("text").toInt(); - if( maxApps >=0 && maxApps <= mMaxParallelApps->contentWidgetData("maximum").toInt() ) - { - mApplicationsAttributes.mMaxOpen = mMaxParallelApps->contentWidgetData("text").toInt(); - } - else - { - mApplicationsAttributes.mMaxOpen = mMaxParallelApps->contentWidgetData("maximum").toInt(); - } - mApplicationsAttributes.mLaunchingInterval = mLaunchingInterval->contentWidgetData("text").toInt(); - mApplicationsAttributes.mKeyPressType = mKeyPressType->contentWidgetData("selected").toInt(); - mPointerEventAttributes.mHeartBeat = mHeartBeat->contentWidgetData("text").toInt(); - int randVar = mRandomVar->contentWidgetData("text").toInt(); - if( randVar >=0 && randVar <= mRandomVar->contentWidgetData("maximum").toInt() ) - { - mApplicationsAttributes.mRandomVariance = mRandomVar->contentWidgetData("text").toInt(); - } - else - { - mApplicationsAttributes.mRandomVariance = mRandomVar->contentWidgetData("maximum").toInt(); - } -} - -// --------------------------------------------------------------------------- - -void SettingsView::savePhotoSettings() -{ - mPhotoCaptureAttributes.mPriority = mPriority->contentWidgetData("selected").toInt(); - mPhotoCaptureAttributes.mIdle = mIdle->contentWidgetData("text").toInt(); - int randVar = mRandomVar->contentWidgetData("text").toInt(); - if( randVar >=0 && randVar <= mRandomVar->contentWidgetData("maximum").toInt() ) - { - mPhotoCaptureAttributes.mRandomVariance = mRandomVar->contentWidgetData("text").toInt(); - } - else - { - mPhotoCaptureAttributes.mRandomVariance = mRandomVar->contentWidgetData("maximum").toInt(); - } - - // update only if there's more than one camera device available in the system, - // for use case of one camera available, the selection cannot be changed by user. - if (mPhotoCaptureAttributes.mCameraCount > 1) - { - mPhotoCaptureAttributes.mCamera = mCamera->contentWidgetData("selected").toInt(); - } -} - -// --------------------------------------------------------------------------- - -void SettingsView::saveBtSettings() -{ - mBluetoothAttributes.mPriority = mPriority->contentWidgetData("selected").toInt(); - mBluetoothAttributes.mIdle = mIdle->contentWidgetData("text").toInt(); - int randVar = mRandomVar->contentWidgetData("text").toInt(); - if( randVar >=0 && randVar <= mRandomVar->contentWidgetData("maximum").toInt() ) - { - mBluetoothAttributes.mRandomVariance = mRandomVar->contentWidgetData("text").toInt(); - } - else - { - mBluetoothAttributes.mRandomVariance = mRandomVar->contentWidgetData("maximum").toInt(); - } - -} - -// --------------------------------------------------------------------------- - -void SettingsView::cancelled() -{ - connect(this, - SIGNAL(loadCanclled()), - &mEngineWrapper, - SLOT(loadSettingsCanclled())); - emit loadCanclled(); - - mMainWindow.removeView(this); - mMainWindow.setCurrentView(&mMainView, true); - deleteLater(); -} - -// --------------------------------------------------------------------------- - -void SettingsView::okExit() -{ - saveSettings(); - setLoadAttributes(); - connect(this, - SIGNAL(loadCompleted(TLoadGenCommandIds)), - &mEngineWrapper, - SLOT(loadAddedOrEdited(TLoadGenCommandIds))); - emit loadCompleted(mCmdId); - - mMainWindow.removeView(this); - mMainWindow.setCurrentView(&mMainView, true); - deleteLater(); -} - -// --------------------------------------------------------------------------- - -void SettingsView::setLoadAttributes() -{ - switch (mCmdId) { - case ELoadGenCmdNewLoadCPULoad: { - mEngineWrapper.setCpuLoadAttributes(mCPULoadAttributes); - break; - } - case ELoadGenCmdNewLoadEatMemory: { - mEngineWrapper.setMemoryEatAttributes(mMemoryEatAttributes); - break; - } - case ELoadGenCmdNewLoadPhoneCall: { - mEngineWrapper.setPhoneCallAttributes(mPhoneCallAttributes); - break; - } - case ELoadGenCmdNewLoadNetConn: { - mEngineWrapper.setNetConnAttributes(mNetConnAttributes); - break; - } - case ELoadGenCmdNewLoadKeyPress: { - mEngineWrapper.setKeyPressAttributes(mKeyPressAttributes); - break; - } - case ELoadGenCmdNewLoadPointerEvent: { - mEngineWrapper.setPointerEventAttributes(mPointerEventAttributes); - break; - } - case ELoadGenCmdNewLoadMessages: { - mEngineWrapper.setMessageAttributes(mMessageAttributes); - break; - } - case ELoadGenCmdNewLoadApplications: { - mEngineWrapper.setApplicationsAttributes(mApplicationsAttributes); - break; - } - case ELoadGenCmdNewLoadPhotoCaptures: { - mEngineWrapper.setPhotoCaptureAttributes(mPhotoCaptureAttributes); - break; - } - case ELoadGenCmdNewLoadBluetooth: { - mEngineWrapper.setBluetoothAttributes(mBluetoothAttributes); - break; - } - default: { - break; - } - } -} - -// --------------------------------------------------------------------------- - -void SettingsView::dataItemDisplayed(const QModelIndex &index) -{ - HbDataFormViewItem *item = static_cast(mSettingForm->itemByIndex(index)); - HbWidget *contentWidget = static_cast(item->dataItemContentWidget()); - switch(mCmdId){ - case ELoadGenCmdNewLoadCPULoad: { - if (index.row() == 2) { // Cpu load type selection is in this row: periodic vs. continuous - mModes = static_cast(contentWidget); - connect(mModes , SIGNAL(itemSelected(int)), this, SLOT(selectionChanged(int))); - } - break; - } - case ELoadGenCmdNewLoadEatMemory: { - // Memory eat type is in this row: mem to eat/ mem to be left vs. alternate min/max - if (index.row() == 2) { - mTypes = static_cast(contentWidget ); - connect(mTypes ,SIGNAL(itemSelected(int)), this,SLOT(selectionChanged(int))); - } - break; - } - } -} - -// --------------------------------------------------------------------------- - -void SettingsView::selectionChanged(int index) -{ - switch (mCmdId) { - case ELoadGenCmdNewLoadCPULoad: { - if (index == ECpuLoadTypePeriodic) { - // if periodic selected, add Length, Idle and Random variance to settings, - // if they does not exist yet. - if (mLength == NULL) { - mLength = mModel->insertDataFormItem(3, - HbDataFormModelItem::TextItem, - QString("Length (ms)"), - mLoadSettings); - mLength->setContentWidgetData("maximum" , 999999999); - mLength->setContentWidgetData("minimum", 0); - mLength->setContentWidgetData(QString("text"), mCPULoadAttributes.mLength); - } - if (mIdle == NULL) { - // DataFormItem for load length selection - mIdle = mModel->insertDataFormItem(4, - HbDataFormModelItem::TextItem, - QString("Idle (ms)"), - mLoadSettings); - mIdle->setContentWidgetData("maximum" , 999999999); - mIdle->setContentWidgetData("minimum", 0); - mIdle->setContentWidgetData(QString("text"), mCPULoadAttributes.mIdle); - } - if (mRandomVar == NULL) { - mRandomVar = mModel->insertDataFormItem(5, - HbDataFormModelItem::TextItem, - QString("Random variance (%)"), - mLoadSettings); - mRandomVar->setContentWidgetData("maximum" , 100); - mRandomVar->setContentWidgetData("minimum", 0); - mRandomVar->setContentWidgetData(QString("text"), mCPULoadAttributes.mRandomVariance); - } - } - else if (index == ECpuLoadTypeContinuous) { - // if continuous selected, remove existing Length, Idle and Random variance from settings view: - // if they does not exist do nothing. - if (mLength != NULL) { - mModel->removeItem(mLength); - mLength = NULL; - } - if (mIdle != NULL) { - mModel->removeItem(mIdle); - mIdle = NULL; - } - if (mRandomVar != NULL) { - mModel->removeItem(mRandomVar); - mRandomVar = NULL; - } - } - break; - } - case ELoadGenCmdNewLoadEatMemory: { - if (index == EMemoryEatTypeWavy) { - // remove one item, if exists. - if (mAmount != NULL) { - mModel->removeItem(mAmount); - mAmount = NULL; - } - // insert two new item rows, if not exists. - if (mMinAmountToBeLeft == NULL) { - mMinAmountToBeLeft = mModel->insertDataFormItem(3, HbDataFormModelItem::TextItem, - QString("Min to be left (B)"), - mLoadSettings); - mMinAmountToBeLeft->setContentWidgetData("maximum" , 99999999999999); - mMinAmountToBeLeft->setContentWidgetData("minimum", 0); - mMinAmountToBeLeft->setContentWidgetData( QString("text"),mMemoryEatAttributes.mRandomMin ); - } - if (mMaxAmountToBeLeft == NULL) { - mMaxAmountToBeLeft = mModel->insertDataFormItem(4, HbDataFormModelItem::TextItem, - QString("Max to be left (B)"), - mLoadSettings); - mMaxAmountToBeLeft->setContentWidgetData("maximum" , 99999999999999); - mMaxAmountToBeLeft->setContentWidgetData("minimum", 0); - mMaxAmountToBeLeft->setContentWidgetData( QString("text"),mMemoryEatAttributes.mRandomMax ); - } - } - else if (index == EMemoryEatTypeMemoryToEat || index == EMemoryEatTypeMemoryToBeLeft) { - // remove two item rows, if exists. - if (mMinAmountToBeLeft != NULL) { - mModel->removeItem(mMinAmountToBeLeft); - mMinAmountToBeLeft = NULL; - } - if (mMaxAmountToBeLeft != NULL) { - mModel->removeItem(mMaxAmountToBeLeft); - mMaxAmountToBeLeft = NULL; - } - // insert one item, if not exists. - if (mAmount == NULL) { - mAmount = mModel->insertDataFormItem(3, HbDataFormModelItem::TextItem, - QString("Amout(B)"), - mLoadSettings); - mAmount->setContentWidgetData("maximum" , 99999999999999); - mAmount->setContentWidgetData("minimum", 0); - mAmount->setContentWidgetData( QString("text"),mMemoryEatAttributes.mAmount ); - } - } - } - default: { - break; - } - } -} - -// --------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 perfapps/perfmon/icons/PerfMon_application_icon_svgt.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/perfapps/perfmon/icons/PerfMon_application_icon_svgt.svg Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,176 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 819e59dfc032 -r 2d9cac8919d3 perfapps/perfmon/ui/avkon/group/perfmon.mmp --- a/perfapps/perfmon/ui/avkon/group/perfmon.mmp Mon Oct 04 10:09:02 2010 +0300 +++ b/perfapps/perfmon/ui/avkon/group/perfmon.mmp Mon Oct 18 16:30:05 2010 +0300 @@ -87,4 +87,7 @@ LIBRARY centralrepository.lib LIBRARY HWRMPowerClient.lib +UNPAGEDDATA +SMPSAFE + // End of File diff -r 819e59dfc032 -r 2d9cac8919d3 perfapps/perfmon/ui/hb/app/app.pro --- a/perfapps/perfmon/ui/hb/app/app.pro Mon Oct 04 10:09:02 2010 +0300 +++ b/perfapps/perfmon/ui/hb/app/app.pro Mon Oct 18 16:30:05 2010 +0300 @@ -75,7 +75,11 @@ TARGET.EPOCHEAPSIZE = 0x10000 0x2000000 // Min 64Kb, Max 32Mb - ICON = ../../../icons/qgn_menu_perfmon.svg + ICON = ../../../icons/PerfMon_application_icon_svgt.svg RSS_RULES += "group_name = \"RnD Tools\""; + + MMP_RULES -= PAGED + MMP_RULES *= UNPAGEDDATA + MMP_RULES += SMPSAFE } diff -r 819e59dfc032 -r 2d9cac8919d3 screengrabber/ReleaseNotes_ScreenGrabber.txt --- a/screengrabber/ReleaseNotes_ScreenGrabber.txt Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,144 +0,0 @@ -=============================================================================== - -RELEASE NOTES - SCREENGRABBER v5.0.0 -RELEASED 10th March 2010 - -SUPPORTS S60 3.0+ - -=============================================================================== - -Product Description: -==================== -ScreenGrabber tool is used to capture images and video of the visible screen -area in S60 platform. Captures can be handled with the Media Gallery -application or with PC when the device is connected via PC suite. - -Main Features: -============== -- Image capture in single or in sequential mode supporting PNG, JPEG and BMP - formats -- Video capture in animated GIF format -- Configurable saving format, hotkey, time delta in sequential mode, target - memory and default filename -- Ability to change the screen mode to one of the supported more by the device - -=============================================================================== - -What's New in v5.0.0 -==================== -- Orbit UI - -=============================================================================== - -Installation Notes: -=================== -ScreenGrabber is typically preinstalled on ROM. If not, it can be added to the -ROM with the .iby file. Alternatively, the .sis file can be found under the sis- -directory, but the user need to sign it with their own developer certificate. -In Nokia R&D environment, you can use directly the R&D-signed .sis file under the -internal\sis directory. - -When signing with own developer certificate, the following capabilities are -needed: - WriteDeviceData - SwEvent - -When builing ScreenGrabber against S60 3.0 or 3.1, you may need to patch your -SDK environment first with some fixes. For more information, please refer to -the instructions under the "envpatcher" directory. - -=============================================================================== - -System Requirements: -==================== -Basic Requirements: -- Any S60 3.x device or emulator environment - -=============================================================================== - -Compatibility Issues: -===================== -N/A - -=============================================================================== - -Known Issues: -============= - -Sluggish UI when capturing video --------------------------------- -- Video capturing requires huge amount of processing power and thus may cause - the UI to become sluggish. If supported by the device, try to decrease the - screen resolution. - -=============================================================================== - -Version History: -================ -Version 4.2.0 - 14th May 2009 ------------------------------- -- Feature: Added a new SIS file for S60 3.2 devices and newer to support the - features in newer platforms -- Feature: Added multidrive support in the settings dialog - -Version 4.1.3 - 8th March 2009 ------------------------------- -- Fix: ScreenGrabber does not work in devices which do not have Media Gallery - (Media Gallery File Manager API dependency changed from static to dynamic) - -Version 4.1.2 - 8th February 2008 ---------------------------------- -- Fix: Transparency errors in GIF animations (hopefully) finally fixed - -Version 4.1.1 - 28th January 2008 ---------------------------------- -- Feature: Added hash+* and alternative camera key into selection of capture - keys -- Change: Reimplemented settings handling so that AllFiles and WriteUserData - capabilities are no longer needed - -Version 4.1.0 - 14th January 2008 ---------------------------------- -- Feature: Added support for GIF and MBM formats although it is always - recommended to capture screens in PNG format -- Feature: JPEG format can now be selected as high quality (97%) or low quality - (60%) -- Feature: Added POC key under capturing key options -- Change: Dimensions of a video will be grown if the screen resolution of the - device will grow during capturing -- Change: Capturing is now done always from current focus screen which allows to - support secondary displays -- Change: Send key is now the default key -- Fix: Black color didn't always work correctly in GIF animation optimization - with transparency -- Fix: Capturing to JPEG format leaked memory - -Version 4.0.3 - 16th November 2007 ----------------------------------- -- Fix: Scroll bar in the main view can be scrolled on a touch UI -- Fix: Application closes automatically when closed via open applications menu - -Version 4.0.2 - 9th October 2007 --------------------------------- -- Fix: Main screen layout in mirrored mode - -Version 4.0.1 - 14th February 2007 ----------------------------------- -- Fix: Help screen on larger displays - -Version 4.0.0 - 25th October 2006 ---------------------------------- -- Feature: Support for sequential capture mode -- Feature: Support for capturing video in animated GIF format -- Feature: Ability to change screen mode to one of the supported more by the - device - -=============================================================================== - -Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -All rights reserved. - -This component and the accompanying materials are made available -under the terms of "Eclipse Public License v1.0" -which accompanies this distribution, and is available -at the URL "http://www.eclipse.org/legal/epl-v10.html". diff -r 819e59dfc032 -r 2d9cac8919d3 screengrabber/icons/qgn_menu_screengrabber.svg --- a/screengrabber/icons/qgn_menu_screengrabber.svg Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,169 +0,0 @@ - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r 819e59dfc032 -r 2d9cac8919d3 screengrabber/inc/application.h --- a/screengrabber/inc/application.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef SGAPPLICATION_H -#define SGAPPLICATION_H - -#include -#include - -#include -class EngineWrapper; - -class SGApplication : public HbApplication -{ -public: - SGApplication(int argc, char *argv[]);//, EngineWrapper &engine); - ~SGApplication(); -#if defined(Q_WS_S60) - -#if defined(HB_QT_S60_EVENT_FILTER) - virtual bool s60EventFilter(TWsEvent *aEvent); -#else - virtual bool symbianEventFilter(const QSymbianEvent *event); -#endif // (HB_QT_S60_EVENT_FILTER) -#endif//(Q_WS_S60) - inline void SetEngineWrapper(EngineWrapper *aEngine){iEngine = aEngine;} -private: - RWsSession iWsSession_a; - RWindowGroup iRootWin_a; - - - EngineWrapper *iEngine; -}; - -#endif // SGAPPLICATION_H diff -r 819e59dfc032 -r 2d9cac8919d3 screengrabber/inc/enginewrapper.h --- a/screengrabber/inc/enginewrapper.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,141 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef ENGINEWRAPPER_H -#define ENGINEWRAPPER_H - -#include -#include - - -class SGEngine; -class GrabSettings; -class MainView; -class TWsEvent; -class HbDeviceProgressDialog; - -/** - * class that is used for communicating between Symbian and Qt code. - */ -class EngineWrapper{ -public: - - /** - * Constructor - */ - EngineWrapper(); - - /** - * Destructor - */ - ~EngineWrapper(); - - /** - * Initializes Engine Wrapper - * @return true if engine was started successfully - */ - bool init(); - -public: - - /* Functions that are called from UI */ - - /** - * Fetches settings from engine and converts Symbian data types to Qt's types. - */ - GrabSettings getGrabSettings(); - - /** - * Converts given parameters into Symbian data types and saves them into ScreenGrabber engine - * @param settings new settings - */ - bool saveSettings(const GrabSettings& settings); - - - /* - * Sends received s60 event to engine - */ -#if defined(HB_QT_S60_EVENT_FILTER) - bool handleCaptureCommands(const TWsEvent* aEvent); -#else - bool handleCaptureCommands(const QSymbianEvent *aEvent); -#endif - - - /** - * Sends UI to background - */ - void sendUIToBackground(); - void EnableRcpOfFoc(TBool aState); - void LoadSettings(void); -public: - - /* Functions that are called from engine: */ - - /** - * uses Notifications class to show image captured note - */ - void ShowImageCapturedNote(); - - /** - * uses Notifications class to show video captured note - */ - void ShowVideoCapturedNote(); - - /** - * uses Notifications class to show seguantial images captured note - */ - void ShowSequantialImagesCapturedNote(TInt amount); - - /** - * uses Notifications class to show error message - */ - void ShowErrorMessage(const TDesC16& aErrorMessage); - - /** - * uses Notifications class to show progressbar - */ - void ShowProgressBar(int max); - - /** - * increments shown progressbar's value - */ - void IncrementProgressbarValue(); - - /** - * closes progressbar - */ - void CloseProgressbar(); - - -private: - - bool convertTBoolToBool(TBool value); - -private: - - - /* Screen grabber engine */ - SGEngine *iSGEngine; - - /* progressnote that is shown */ - HbDeviceProgressDialog *iProgressNote; - -}; - -#endif; - diff -r 819e59dfc032 -r 2d9cac8919d3 screengrabber/inc/gifanimator.h --- a/screengrabber/inc/gifanimator.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,69 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - -#ifndef __GIFANIMATOR_H__ -#define __GIFANIMATOR_H__ - -#include -#include -#include "sgengine.h" - - - -class CImageEncoder; - -class MDialogCallback - { -public: - virtual void DialogDismissedL( TInt aButtonId ) = 0; - }; - - -class CGifAnimator : public CBase - { -public: - static int CreateGifAnimation(const TDesC& aFileName, TSize aDimensions, CVideoFrameArray* aVideoFrameArray, EngineWrapper& aEngineWrapper); - ~CGifAnimator(); - -private: - CGifAnimator(); - void StartL(const TDesC& aFileName, const TSize& aDimensions, CVideoFrameArray* aVideoFrameArray, EngineWrapper& aEngineWrapper); - void WriteHeaderL(const TSize& aDimensions); - void WriteGraphicControlL(const TVideoFrame& aFrame); - void WriteImageDescriptorL(const TVideoFrame& aFrame); - CFbsBitmap* GetBitmapLC(TVideoFrame& aFrame, const TSize& aDimensions); - void WriteRasterDataL(CFbsBitmap* aBitmap); - void WriteFooterL(); - void FinishL(); - void WriteInt8L(TInt aValue); - void WriteInt16L(TInt aValue); - - - -private: - RFs iFs; - RFile iOutFile; - CImageEncoder* iImageEncoder; - HBufC8* iGIFImageData; - - }; - - - -#endif // __GIFANIMATOR_H__ diff -r 819e59dfc032 -r 2d9cac8919d3 screengrabber/inc/mainview.h --- a/screengrabber/inc/mainview.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,119 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef MAINVIEW_H -#define MAINVIEW_H - -#include -#include - -class EngineWrapper; -class HbMainWindow; -class HbApplication; -class SettingsView; -class HbAction; - - - -/** - * Class that implements the main view of Screen Grabber - */ -class MainView : public HbView -{ - Q_OBJECT - -public: - - /** - * Constructor - */ - MainView(HbMainWindow &mainWindow, EngineWrapper &engineWrapper); - - /** - * Destructor - */ - ~MainView(); - - /** - * Initializes Engine Wrapper - * @param app application class of Screen Grabber - */ - void init(HbApplication &app); - - inline void setSettingsView(SettingsView *aSettingsView){ mSettingsView = aSettingsView; } - - -private: - - /** - * Creates menu - */ - void createMenu(HbApplication &app); - - /** - * Created info text ui components - */ - void createInfoText(); - - /** - * Creates toolbar components - */ - void createToolbar(); - -public slots: - - - /** - * Shows about pop-up - */ - void showAboutPopup(); - - /** - * Sends UI to background - */ - void sendToBackground(); - - /** - * opens settings view - */ - void showSettings(); - - void my_quit(); - - void quitYesNoQuestionClosed(HbAction*); - - -public: - - /* Main windo of Screen Grabber */ - HbMainWindow &mMainWindow; - - /* Settings view */ - SettingsView *mSettingsView; - - /* Engine Wrapper */ - EngineWrapper &mEngineWrapper; - - /* Actions that are used in toolbars and menus */ - HbAction* actionSendToBg; - HbAction* actionSettings; - HbAction* actionAbout; - HbAction* actionExit; - -}; - -#endif // MAINVIEW_H diff -r 819e59dfc032 -r 2d9cac8919d3 screengrabber/inc/notifications.h --- a/screengrabber/inc/notifications.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,64 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef NOTIFICATIONS_H_ -#define NOTIFICATIONS_H_ - -#include -#include - - - -class Notifications - { -public: - - /** - * shows about box - */ - static void about(); - - /** - * shows image captured note - */ - static void imageCaptured(); - - /** - * shows video captured note - */ - static void videoCaptured(); - - /** - * shows seguantial images captured note - */ - static void sequantialImagesCaptured(int amount); - - /** - * shows error message - */ - static void error(const QString& errorMessage); - - /** - * to shows progressbar - */ - static HbDeviceProgressDialog* showProgressBar(int max); - - }; - - - -#endif // NOTIFICATIONS_H_ diff -r 819e59dfc032 -r 2d9cac8919d3 screengrabber/inc/settingsview.h --- a/screengrabber/inc/settingsview.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,187 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#ifndef SETTINGS_H -#define SETTINGS_H - -#include -#include -#include - -class EngineWrapper; -class HbDataFormModelItem; -class HbDataFormModel; -class HbDataForm; -class HbDataFormViewItem; - -const QStringList CAPTUREMODES = (QStringList() << "Single capture" << "Sequential capture" << "Video capture"); -const QStringList KEYS = (QStringList() << "Send key" << "Power key" << "Side key" << "Camera key"); -const QStringList VIDEOFORMATS = (QStringList() << "Animated GIF"); -const QStringList IMAGEFORMATS = (QStringList() << "PNG" << "JPEG high qual." << "JPEG low qual." << "BMP" << "GIF"); -const QStringList MEMORYMODES = (QStringList() << "Phone memory" << "Memory card"); - - -/** - * Settings class that is used for - */ -class GrabSettings - { -public: - int mCaptureMode; - - int mSingleCaptureHotkey; - int mSingleCaptureImageFormat; - int mSingleCaptureMemoryInUseMultiDrive; - QString mSingleCaptureFileName; - - int mSequantialCaptureHotkey; - int mSequantialCaptureImageFormat; - int mSequantialCaptureDelay; - int mSequantialCaptureMemoryInUseMultiDrive; - QString mSequantialCaptureFileName; - - int mVideoCaptureHotkey; - int mVideoCaptureVideoFormat; - int mVideoCaptureMemoryInUseMultiDrive; - QString mVideoCaptureFileName; - }; - -/** - * Class that creates settings view of Screen Grabber - */ -class SettingsView : public HbView -{ - Q_OBJECT - - enum CaptureMode{ SINGLE, SEQUENTIAL, VIDEO }; - -public: - /** - * Constuctor - * @param mainView pointer to main view - * @param mainWindow pointer to main window - */ - SettingsView(HbView &mainView, HbMainWindow &mainWindow, EngineWrapper &engineWrapper); - - /** - * destructor - */ - ~SettingsView(); - - - /** - * Loads settings from engine and formats those settings into form items - */ - void loadSettings(); - - -private slots: - - /** - * saves settings and closes view. - */ - void saveAndClose(); - - /** - * closes setting view - */ - void close(); - - /** - * Slot that is called each time capture mode is changed - */ -// void updateShownItems(); -private: - - /** - * Creates single capture related components - */ - void createSingleCaptureComponents(HbDataFormModel *model, HbDataFormModelItem *parent); - - /* - * Creates sequential capture related components. - */ - void createSequentialCaptureComponents(HbDataFormModel *model, HbDataFormModelItem *parent); - - /** - * creates video capture related components - */ - void createVideoCaptureComponents(HbDataFormModel *model, HbDataFormModelItem *parent); - - - - /** - * Reads form items and saves them into member variable mSettings - */ - void readFormItems(); - -private: - - /* Settings */ - GrabSettings mSettings; - - /* EngineWrapper */ - EngineWrapper &mEngineWrapper; - - /* Main Window of Screen Grabber */ - HbMainWindow &mMainWindow; - - /* Main View of Screen Grabber */ - HbView &mMainView; - - /* settingform */ - HbDataForm *mSettingForm; - - /* model for settingform */ - HbDataFormModel *mModel; - - /* model's components: */ - - /* mode selection item */ - HbDataFormModelItem *mModeItem; - - /* groups that contain mode specific settings */ - HbDataFormModelItem *mGroupImageCapture; - HbDataFormModelItem *mGroupSeguantialCapture; - HbDataFormModelItem *mGroupVideoCapture; - - /* Still image components */ - HbDataFormModelItem *mImageHotKeyItem; - HbDataFormModelItem *mImageFormatItem; - HbDataFormModelItem *mImageMemoryInUseItem; - HbDataFormModelItem *mImageFileNameItem; - - /* Sequential image components */ - HbDataFormModelItem *mSequantialHotKeyItem; - HbDataFormModelItem *mSequantialFormatItem; - HbDataFormModelItem *mSequantialDelayItem; - HbDataFormModelItem *mSequantialMemoryInUseItem; - HbDataFormModelItem *mSequantialFileNameItem; - - /* Video capture components */ - HbDataFormModelItem *mVideoHotKeyItem; - HbDataFormModelItem *mVideoFormatItem; - HbDataFormModelItem *mVideoMemoryInUseItem; - HbDataFormModelItem *mVideoFileNameItem; - - - - -}; - -#endif diff -r 819e59dfc032 -r 2d9cac8919d3 screengrabber/inc/sgengine.h --- a/screengrabber/inc/sgengine.h Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,271 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef SGENGINE_H -#define SGENGINE_H - - -// INCLUDES -#include -#include -#include -#include -#include -#include - - -class CFrameImageData; -class CDictionaryFileStore; -class CImageEncoder; -class EngineWrapper; - - -// setting keys (do not change uids of existing keys to maintain compatibility to older versions!) -const TUid KSGSettingCaptureMode = { 0x00 }; - -const TUid KSGSettingSingleCaptureHotkey = { 0x01 }; -const TUid KSGSettingSingleCaptureImageFormat = { 0x02 }; -const TUid KSGSettingSingleCaptureMemoryInUseMultiDrive = { 0x04 }; -const TUid KSGSettingSingleCaptureFileName = { 0x05 }; - -const TUid KSGSettingSequantialCaptureHotkey = { 0x06 }; -const TUid KSGSettingSequantialCaptureImageFormat = { 0x07 }; -const TUid KSGSettingSequantialCaptureDelay = { 0x08 }; -const TUid KSGSettingSequantialCaptureMemoryInUseMultiDrive = { 0x0A }; -const TUid KSGSettingSequantialCaptureFileName = { 0x0B }; - -const TUid KSGSettingVideoCaptureHotkey = { 0x0C }; -const TUid KSGSettingVideoCaptureVideoFormat = { 0x0D }; -const TUid KSGSettingVideoCaptureMemoryInUseMultiDrive = { 0x0F }; -const TUid KSGSettingVideoCaptureFileName = { 0x10 }; - -const TUid KUidScreenGrabber = { 0x101FB751 }; - - -#define TRANSPARENCY_INDEX 30 -#define TRANSPARENCY_ALTERNATIVE_INDEX 24 - -enum TScreenGrabberSettingCaptureModes - { - ECaptureModeSingleCapture = 0, - ECaptureModeSequantialCapture, - ECaptureModeVideoCapture - }; - -enum TScreenGrabberSettingHotkeys - { - EHotkeySendKey = 0, - EHotkeyPowerKey, - EHotkeySideKey, - EHotkeyCameraKey1 - }; - -enum TScreenGrabberSettingImageFormats - { - EImageFormatPNG = 0, - EImageFormatJPGHQ, - EImageFormatJPGLQ, - EImageFormatBMP, - EImageFormatGIF, - EImageFormatMBM - }; - -enum TScreenGrabberSettingVideoFormats - { - EVideoFormatAnimatedGIF = 0 - }; - -enum TScreenGrabberSettingMultiDrive - { - EPhoneMemory = 0, - EMemoryCard - }; - - -class TGrabSettings - { -public: - TInt iCaptureMode; - - TInt iSingleCaptureHotkey; - TInt iSingleCaptureImageFormat; - TInt iSingleCaptureMemoryInUseMultiDrive; - TFileName iSingleCaptureFileName; - - TInt iSequantialCaptureHotkey; - TInt iSequantialCaptureImageFormat; - TInt iSequantialCaptureDelay; - TInt iSequantialCaptureMemoryInUseMultiDrive; - TFileName iSequantialCaptureFileName; - - TInt iVideoCaptureHotkey; - TInt iVideoCaptureVideoFormat; - TInt iVideoCaptureMemoryInUseMultiDrive; - TFileName iVideoCaptureFileName; - }; - -class TVideoFrame - { -public: - TUint iWidth; - TUint iHeight; - TUint iXPos; - TUint iYPos; - TUint iDelay; // 1000 = 1 sec - TBool iEnableTransparency; - TBool iFillsWholeScreen; - TFileName iFileStorePath; - }; - - -typedef CArrayFixSeg CVideoFrameArray; - -/** - * CEngine - * - */ -class SGEngine : public CActive //, public MMdaAudioToneObserver - { - - // active object states - - enum TState - { - EIdle = 0, // do nothing - EEncodingImage, // ICL encoding of an image - ESequenceDelay, // waiting till next capture - ECancelCapturing, // asking to cancel capturing - ENextVideoFrame, // get next frame for video - ECancelVideoCapturing, // asking to cancel video capturing - EQueryDelay // waiting till to remove query - }; - -public: - // Constructors and destructor - - /** - * Destructor. - */ - ~SGEngine(); - - /** - * Two-phased constructor. - */ - static SGEngine* NewL(EngineWrapper *aEngineWrapper); - - /** - * Two-phased constructor. - */ - static SGEngine* NewLC(EngineWrapper *aEngineWrapper); - - /** - * returns current settings - */ - inline TGrabSettings GrabSettings(){ return iGrabSettings; }; - - /** - * saves settings to engine - */ - void SaveSettingsL(TGrabSettings aGrabSettings); - - /** - * takes one screen shot - */ - bool TakeScreenShotAndSaveL(); - - TBool DriveOK(TDriveNumber aNumber); - - TBool IsDriveMMC(TDriveNumber aDrive); - -#if defined(HB_QT_S60_EVENT_FILTER) - TBool HandleCaptureCommandsL(const TWsEvent* aEvent); -#else - TBool HandleCaptureCommandsL(const QSymbianEvent *event); -#endif - - - void ActivateModelL(); - void DeActivateModelL(); - void ActivateCaptureKeysL(TBool aChangeKey=EFalse); - void EnableRcpOfFoc(TBool aState); - void LoadSettingsL(); - -private: - - void CapturingFinishedL(TInt aErr); - - void RunL(); - void DoCancel(); - void SaveVideoL(TInt aErr); - void CleanTemporaryFilesL(); - void LoadDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, TInt& aValue); - void LoadDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, TDes& aValue); - - void SaveDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, const TInt& aValue); - void SaveDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, const TDes& aValue); - - void CancelCapturing(); - void CaptureFrameForVideoL(); - - - /** - * Constructor for performing 1st stage construction - */ - SGEngine(); - - /** - * EPOC default constructor for performing 2nd stage construction - */ - void ConstructL(EngineWrapper *aEngineWrapper); - - -private: - RFs iFileSession; - - CActiveScheduler* iActiveScheduler; - CActiveSchedulerWait* iWait; - - TGrabSettings iGrabSettings; // a simple class to store the settings used in the screen capture - RWindowGroup iRootWin; // application's window group - TInt iCapturedKey; // a handle to the key which is captured - TInt iCapturedKeyUnD; // a handle to the key which is captured, up and down - TInt iCapturedKeyHash; // a handle to the hash key which is captured - TInt iCapturedKeyHashUnD; // a handle to the hash key which is captured, up and down - TBool iHashKeyCapturingActivated; // captures hash key is activated - CFbsBitmap* iPreviouslyCapturedBitmap; // a previously captured bitmap - TFileName iSaveFileName; - CImageEncoder* iImageEncoder; // engine from ICL to do the image conversion// target filename of the taken screen shot - CFrameImageData* iFrameImageData; // frame and image block data needed by ICL - TState iState; // state of this active object - TBool iHashKeyDown; // stores state if hash key is currently down - TBool iCapturingInProgress; // boolean to check if capturing is in progress - TBool iStopCapturing; // boolean to specify if to ask capturing - TUint iNumberOfTakenShots; // a number of the taken screen shots in the sequantial mode - RTimer iTimer; // a timer for async delays - TUint iCurrentFrameNumber; // a number of taken frames in video mode - TTime iPreviousFrameTaken; // time when the last frame was taken - TSize iVideoDimensions; // dimension of the video - TSize iPreviousFrameScreenDimension; // dimension of the screen in previous frame - CVideoFrameArray* iVideoFrameArray; // the frames of the video - EngineWrapper* iEngineWrapper; // Eninewrapper that is used for communicating between QT and Symbian - }; - - - - - -#endif // SGENGINE_H diff -r 819e59dfc032 -r 2d9cac8919d3 screengrabber/rom/backup_registration.xml --- a/screengrabber/rom/backup_registration.xml Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ - - - - - - - - diff -r 819e59dfc032 -r 2d9cac8919d3 screengrabber/rom/screengrabber.iby --- a/screengrabber/rom/screengrabber.iby Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#ifndef __SCREENGRABBER_IBY__ -#define __SCREENGRABBER_IBY__ - -S60_APP_EXE(ScreenGrabber) -S60_APP_RESOURCE(ScreenGrabber) -SCALABLE_IMAGE(APP_BITMAP_DIR,APP_BITMAP_DIR,ScreenGrabber) -//#ifdef S60_UPGRADABLE_APP_REG_RSC -// S60_UPGRADABLE_APP_REG_RSC(ScreenGrabber) -//#else -// S60_APP_AIF_RSC(ScreenGrabber) -//#endif - -data=ZPRIVATE\10003a3f\import\APPS\ScreenGrabber_reg.RSC Private\10003a3f\import\Apps\ScreenGrabber_reg.rsc -data=ZPRIVATE\101FB751\backup_registration.xml private\101FB751\backup_registration.xml -data=ZSYSTEM\Install\ScreenGrabber_stub.sis \system\install\ScreenGrabber_stub.sis - -#endif // __SCREENGRABBER_IBY__ diff -r 819e59dfc032 -r 2d9cac8919d3 screengrabber/screengrabber.pro --- a/screengrabber/screengrabber.pro Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,78 +0,0 @@ -# -# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# This component and the accompanying materials are made available -# under the terms of "Eclipse Public License v1.0" -# which accompanies this distribution, and is available -# at the URL "http://www.eclipse.org/legal/epl-v10.html". -# -# Initial Contributors: -# Nokia Corporation - initial contribution. -# -# Contributors: -# -# Description: -# -# - - -TEMPLATE = app -TARGET = ScreenGrabber -DEPENDPATH += src -INCLUDEPATH += inc -INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE -load(hb.prf) -symbian:CONFIG -= symbian_i18n - -HEADERS += inc/mainview.h \ - inc/settingsview.h \ - inc/application.h \ - inc/notifications.h - -SOURCES += main.cpp \ - mainview.cpp \ - application.cpp \ - settingsview.cpp \ - notifications.cpp - -symbian: { - BLD_INF_RULES.prj_exports += "./rom/screengrabber.iby CORE_IBY_EXPORT_PATH(tools,screengrabber.iby) - BLD_INF_RULES.prj_exports += "./rom/backup_registration.xml Z:/private/101FB751/backup_registration.xml" - - screengrabber_buildstubsis_extension = \ - "$${LITERAL_HASH}ifdef MARM" \ - " START EXTENSION app-services/buildstubsis" \ - " OPTION SRCDIR sis" \ - " OPTION SISNAME screengrabber_stub" \ - " END" \ - "$${LITERAL_HASH}endif" - - BLD_INF_RULES.prj_extensions += screengrabber_buildstubsis_extension - - LIBS += -lestor -lws32 -lPlatformEnv -limageconversion -lapgrfx -lcommonengine -lfbscli -lgdi -leikcore -lbafl -lefsrv -lapparc -lcone - - HEADERS += inc/sgengine.h \ - inc/enginewrapper.h \ - inc/gifanimator.h - - SOURCES += sgengine.cpp \ - enginewrapper.cpp \ - gifanimator.cpp - - RSS_RULES += "group_name = \"RnD Tools\""; - - TARGET.CAPABILITY = WriteDeviceData SwEvent - - TARGET.UID2 = 0x100039CE - TARGET.UID3 = 0x101FB751 - TARGET.SID = 0x101FB751 - TARGET.VID = 0x101FB657 // Nokia - - - TARGET.EPOCHEAPSIZE = 0x20000 0x1000000 // Min 128Kb, Max 16Mb - - ICON = ./icons/qgn_menu_screengrabber.svg - -} else { - error("Only Symbian supported!") -} diff -r 819e59dfc032 -r 2d9cac8919d3 screengrabber/sis/ScreenGrabber_stub.pkg --- a/screengrabber/sis/ScreenGrabber_stub.pkg Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -; -; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -; All rights reserved. -; This component and the accompanying materials are made available -; under the terms of "Eclipse Public License v1.0" -; which accompanies this distribution, and is available -; at the URL "http://www.eclipse.org/legal/epl-v10.html". -; -; Initial Contributors: -; Nokia Corporation - initial contribution. -; -; Contributors: -; -; Description: -; - -; Language - standard language definitions -&EN - -; Standard SIS file header -#{"ScreenGrabber"},(0x101FB751),1,0,0 - -; Non-localised vendor name -:"Nokia Corporation" - -; Localised vendor names -%{"Nokia Corporation"} - -; normal stuff: -""-"z:\sys\bin\ScreenGrabber.exe" -""-"z:\Resource\Apps\ScreenGrabber.mif" -""-"z:\Resource\Apps\ScreenGrabber.rsc" -""-"z:\private\10003a3f\import\apps\ScreenGrabber_reg.rsc" -""-"z:\private\101FB751\backup_registration.xml" diff -r 819e59dfc032 -r 2d9cac8919d3 screengrabber/src/application.cpp --- a/screengrabber/src/application.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,63 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ -#include -#include "application.h" -#include "enginewrapper.h" - -#define KEY_CAPTURE_PRIORITY 100 - -SGApplication::SGApplication(int argc, char *argv[]) - : HbApplication(argc, argv) - { - - - } - - -SGApplication::~SGApplication() -{ - -} - -// --------------------------------------------------------------------------- - -#if defined(Q_WS_S60) -#if defined(HB_QT_S60_EVENT_FILTER) -bool SGApplication::s60EventFilter(TWsEvent *aEvent) -#else -bool SGApplication::symbianEventFilter(const QSymbianEvent *aEvent) -#endif // (HB_QT_S60_EVENT_FILTER) -{ - // pass event to engine, if engine returns true(event was not handled), - // forward it. - if(!iEngine->handleCaptureCommands(aEvent)) - { - return false; - } - else - { -#if defined(HB_QT_S60_EVENT_FILTER) - return HbApplication::s60EventFilter(aEvent); -#else - return HbApplication::symbianEventFilter(aEvent); -#endif - } - - } -#endif - -// --------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 screengrabber/src/enginewrapper.cpp --- a/screengrabber/src/enginewrapper.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,250 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ -#include -#include -#include -#include "enginewrapper.h" - -#include "settingsview.h" -#include "sgengine.h" -#include "mainview.h" -#include "notifications.h" - - -// --------------------------------------------------------------------------- - -EngineWrapper::EngineWrapper() -: iSGEngine(0), iProgressNote(0) -{ -} - -// --------------------------------------------------------------------------- - -EngineWrapper::~EngineWrapper() -{ - if (iSGEngine) { - iSGEngine->DeActivateModelL(); - delete iSGEngine; - } - if(iProgressNote){ - delete iProgressNote; - } -} - -// --------------------------------------------------------------------------- - -bool EngineWrapper::init() -{ - TRAPD(error, iSGEngine = SGEngine::NewL(this)); - - - if (error == KErrNone) { - TRAP(error, iSGEngine->ActivateModelL()); - } - - if (error != KErrNone) { - return false; - } - else { - return true; - } - -} - -// --------------------------------------------------------------------------- - -GrabSettings EngineWrapper::getGrabSettings() -{ - TGrabSettings tSettings = iSGEngine->GrabSettings(); - GrabSettings settings; - - // Convert TGrabSettings to GrabSettings - settings.mCaptureMode = tSettings.iCaptureMode; - - // Single image settings - settings.mSingleCaptureHotkey = tSettings.iSingleCaptureHotkey; - settings.mSingleCaptureImageFormat = tSettings.iSingleCaptureImageFormat; - settings.mSingleCaptureMemoryInUseMultiDrive = tSettings.iSingleCaptureMemoryInUseMultiDrive; - settings.mSingleCaptureFileName = QString((QChar*)tSettings.iSingleCaptureFileName.Ptr(),tSettings.iSingleCaptureFileName.Length()); - - //Seguantial image settings - settings.mSequantialCaptureDelay = tSettings.iSequantialCaptureDelay; - settings.mSequantialCaptureHotkey = tSettings.iSequantialCaptureHotkey; - settings.mSequantialCaptureImageFormat = tSettings.iSequantialCaptureImageFormat; - settings.mSequantialCaptureMemoryInUseMultiDrive = tSettings.iSequantialCaptureMemoryInUseMultiDrive; - settings.mSequantialCaptureDelay = tSettings.iSequantialCaptureDelay; - //convert TFilename to QString - settings.mSequantialCaptureFileName = QString((QChar*)tSettings.iSequantialCaptureFileName.Ptr(),tSettings.iSequantialCaptureFileName.Length()); - - - // Video settings - settings.mVideoCaptureHotkey = tSettings.iVideoCaptureHotkey; - settings.mVideoCaptureVideoFormat = tSettings.iVideoCaptureVideoFormat; - settings.mVideoCaptureMemoryInUseMultiDrive = tSettings.iVideoCaptureMemoryInUseMultiDrive; - //convert TFilename to QString - settings.mVideoCaptureFileName = QString((QChar*)tSettings.iVideoCaptureFileName.Ptr(),tSettings.iVideoCaptureFileName.Length()); - - return settings; -} - -// --------------------------------------------------------------------------- - -bool EngineWrapper::saveSettings(const GrabSettings& settings) -{ - TGrabSettings tSettings; - // Convert GrabSettings to TGrabSettings - tSettings.iCaptureMode = settings.mCaptureMode; - - tSettings.iSingleCaptureHotkey = settings.mSingleCaptureHotkey; - tSettings.iSingleCaptureImageFormat = settings.mSingleCaptureImageFormat; - tSettings.iSingleCaptureMemoryInUseMultiDrive = settings.mSingleCaptureMemoryInUseMultiDrive; - //convert TFilename to QString - tSettings.iSingleCaptureFileName = TFileName(settings.mSingleCaptureFileName.utf16()); - tSettings.iSequantialCaptureDelay = settings.mSequantialCaptureDelay; - tSettings.iSequantialCaptureHotkey = settings.mSequantialCaptureHotkey; - tSettings.iSequantialCaptureImageFormat = settings.mSequantialCaptureImageFormat; - tSettings.iSequantialCaptureMemoryInUseMultiDrive = settings.mSequantialCaptureMemoryInUseMultiDrive; - tSettings.iSequantialCaptureDelay = settings.mSequantialCaptureDelay; - //convert TFilename to QString - tSettings.iSequantialCaptureFileName = TFileName(settings.mSequantialCaptureFileName.utf16()); - - tSettings.iVideoCaptureHotkey = settings.mVideoCaptureHotkey; - tSettings.iVideoCaptureVideoFormat = settings.mVideoCaptureVideoFormat; - tSettings.iVideoCaptureMemoryInUseMultiDrive = settings.mVideoCaptureMemoryInUseMultiDrive; - //convert TFilename to QString - tSettings.iVideoCaptureFileName = TFileName(settings.mVideoCaptureFileName.utf16()); - TRAPD(error, iSGEngine->SaveSettingsL(tSettings)); - - if (error == KErrNone) { - TRAP(error, iSGEngine->ActivateCaptureKeysL(true)); - } - - if (error == KErrNone) { - return true; - } - else { - return false; - } - - -} - -// --------------------------------------------------------------------------- - - -void EngineWrapper::ShowImageCapturedNote() -{ - Notifications::imageCaptured(); -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::ShowErrorMessage(const TDesC16& aErrorMessage) -{ - QString errorMessage((QChar*)aErrorMessage.Ptr(),aErrorMessage.Length()); - Notifications::error(errorMessage); - -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::sendUIToBackground() -{ - CCoeEnv* coeEnv = CCoeEnv::Static(); - TApaTask selfTask(coeEnv->WsSession()); - selfTask.SetWgId(coeEnv->RootWin().Identifier()); - selfTask.SendToBackground(); -} - -// --------------------------------------------------------------------------- - - -#if defined(HB_QT_S60_EVENT_FILTER) -bool EngineWrapper::handleCaptureCommands(const TWsEvent* aEvent) -#else -bool EngineWrapper::handleCaptureCommands(const QSymbianEvent *aEvent) -#endif -{ - TBool retVal = ETrue; - TRAPD(errorCode, retVal = iSGEngine->HandleCaptureCommandsL(aEvent)); - if (errorCode != KErrNone) { - Notifications::error("Error occured when capturing screen."); - } - - return convertTBoolToBool(retVal); - -} - -// --------------------------------------------------------------------------- - -bool EngineWrapper::convertTBoolToBool(TBool value) -{ - if (value) { - return true; - } - else { - return false; - } -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::ShowSequantialImagesCapturedNote(TInt amount) -{ - Notifications::sequantialImagesCaptured(amount); -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::ShowVideoCapturedNote() -{ - Notifications::videoCaptured(); -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::ShowProgressBar(int max) -{ - iProgressNote = Notifications::showProgressBar(max); -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::IncrementProgressbarValue() -{ - iProgressNote->setProgressValue(iProgressNote->progressValue() + 1); -} - -// --------------------------------------------------------------------------- - -void EngineWrapper::CloseProgressbar() -{ - delete iProgressNote; - iProgressNote = 0; -} - -void EngineWrapper::EnableRcpOfFoc(TBool aState) -{ - iSGEngine->EnableRcpOfFoc(aState); -} - -void EngineWrapper::LoadSettings(void) -{ - iSGEngine->LoadSettingsL(); -} - -// --------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 screengrabber/src/gifanimator.cpp --- a/screengrabber/src/gifanimator.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,308 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - - -#include "gifanimator.h" - -#include -#include -#include -#include -#include "enginewrapper.h" - - -// --------------------------------------------------------------------------- - -TInt CGifAnimator::CreateGifAnimation(const TDesC& aFileName, TSize aDimensions, CVideoFrameArray* aVideoFrameArray, EngineWrapper& aEngineWrapper) - { - CGifAnimator* self = new(ELeave) CGifAnimator; - CleanupStack::PushL(self); - TRAPD(err, self->StartL(aFileName, aDimensions, aVideoFrameArray, aEngineWrapper)); - CleanupStack::PopAndDestroy(); - return err; - } - -// --------------------------------------------------------------------------- - -CGifAnimator::CGifAnimator() - { - } - -// --------------------------------------------------------------------------- - -void CGifAnimator::StartL(const TDesC& aFileName, const TSize& aDimensions, CVideoFrameArray* aVideoFrameArray, EngineWrapper& aEngineWrapper) - { - - __ASSERT_ALWAYS(aFileName.Length() > 0, User::Panic(_L("GifAnim"), 100)); - __ASSERT_ALWAYS(aDimensions.iHeight > 0, User::Panic(_L("GifAnim"), 101)); - __ASSERT_ALWAYS(aDimensions.iWidth > 0, User::Panic(_L("GifAnim"), 102)); - __ASSERT_ALWAYS(aVideoFrameArray != NULL, User::Panic(_L("GifAnim"), 103)); - - - // show a progress dialog - aEngineWrapper.ShowProgressBar(aVideoFrameArray->Count()-1); - - // open the file for writing - User::LeaveIfError(iFs.Connect()); - User::LeaveIfError(iOutFile.Replace(iFs, aFileName, EFileWrite)); - - // write header - WriteHeaderL(aDimensions); - - // process each frame of the animation - for (TInt i=0; iCount(); i++) - { - // write headers and raster block - TVideoFrame frame = aVideoFrameArray->At(i); - WriteGraphicControlL(frame); - CFbsBitmap* bitmap = GetBitmapLC(frame, aDimensions); - WriteImageDescriptorL(frame); - WriteRasterDataL(bitmap); - CleanupStack::PopAndDestroy(); //bitmap - - // update the progress bar - aEngineWrapper.IncrementProgressbarValue(); - } - - // write footer and finish - WriteFooterL(); - FinishL(); - - // remove the progress dialog from the screen - aEngineWrapper.CloseProgressbar(); - } - -// --------------------------------------------------------------------------- - -CGifAnimator::~CGifAnimator() - { - - if (iImageEncoder) - delete iImageEncoder; - - if (iGIFImageData) - delete iGIFImageData; - - } - -// --------------------------------------------------------------------------- - -void CGifAnimator::WriteHeaderL(const TSize& aDimensions) - { - WriteInt8L('G'); - WriteInt8L('I'); - WriteInt8L('F'); - WriteInt8L('8'); - WriteInt8L('9'); - WriteInt8L('a'); - - WriteInt16L(aDimensions.iWidth); // width of animation - WriteInt16L(aDimensions.iHeight); // height of animation - - // logical screen descriptor - TUint8 packedFlags = 0; - packedFlags |= 8 - 1; // size of colour table is number of bits in each color table minus one (bits 0-2) - packedFlags |= (8 - 1) << 4; // colour resolution ie maximum size of the original colour palette (bits 4-6) - packedFlags |= 0x80; // use global colour table (bit 7) - - WriteInt8L(packedFlags); - - WriteInt8L(TRANSPARENCY_INDEX); // background color index - - WriteInt8L(0); // pixel aspect ratio, 0=not used - - // write the Symbian default palette since that's what is used - CPalette* palette = CPalette::NewDefaultL(EColor256); - CleanupStack::PushL(palette); - - for (TInt i=0; iEntries(); i++) - { - TRgb entry = palette->GetEntry(i); - - WriteInt8L(entry.Red()); - WriteInt8L(entry.Green()); - WriteInt8L(entry.Blue()); - } - - CleanupStack::PopAndDestroy(); //palette - } - -// --------------------------------------------------------------------------- - -void CGifAnimator::WriteGraphicControlL(const TVideoFrame& aFrame) - { - TInt packedFlags(0); - - // enable transparency if needed - if (aFrame.iEnableTransparency) - packedFlags |= 0x01; - - // set disposal method: - // 0 = disposal method not specified, 1 = do not dispose of graphic, - // 2 = overwrite graphic with background color, 3 = overwrite graphic with previous graphic - TInt disposalMethod = 1; - packedFlags |= ((disposalMethod << 2) & 0x1c); - - WriteInt8L(0x21); // GIF extension - WriteInt8L(0xf9); // GIF graphic control block - WriteInt8L(0x04); // block size - WriteInt8L(packedFlags); // packed - WriteInt16L(aFrame.iDelay); // delay - WriteInt8L(TRANSPARENCY_INDEX); // transparent color index - WriteInt8L(0); // block terminator, always 0 - } - -// --------------------------------------------------------------------------- - -void CGifAnimator::WriteImageDescriptorL(const TVideoFrame& aFrame) - { - WriteInt8L(0x2c); // GIF image descriptor - WriteInt16L(aFrame.iXPos); - WriteInt16L(aFrame.iYPos); - WriteInt16L(aFrame.iWidth); - WriteInt16L(aFrame.iHeight); - WriteInt8L(0); // packed flags, none specified in this case - } - -// --------------------------------------------------------------------------- - -CFbsBitmap* CGifAnimator::GetBitmapLC(TVideoFrame& aFrame, const TSize& aDimensions) - { - CFbsBitmap* bitmap = new(ELeave) CFbsBitmap; - CleanupStack::PushL(bitmap); - - // read the bitmap from the temporary file - RFile bitmapFile; - User::LeaveIfError( bitmapFile.Open(iFs, aFrame.iFileStorePath, EFileRead) ); - RFileReadStream readStream(bitmapFile); - bitmap->InternalizeL(readStream); - readStream.Close(); - bitmapFile.Close(); - - // delete the temporary file since it's not needed anymore - iFs.Delete(aFrame.iFileStorePath); - - // resize the bitmap to match the video dimensions if it is a full screen one - if (aFrame.iFillsWholeScreen && (aFrame.iWidth != aDimensions.iWidth || aFrame.iHeight != aDimensions.iHeight)) - { - if (bitmap->Resize(aDimensions) == KErrNone) - { - // also update dimensions of this frame to match the dimensions of the video - aFrame.iWidth = aDimensions.iWidth; - aFrame.iHeight = aDimensions.iHeight; - } - } - - return bitmap; - } - -// --------------------------------------------------------------------------- - -void CGifAnimator::WriteRasterDataL(CFbsBitmap* aBitmap) - { - // reset the encoder - if (iImageEncoder) - { - delete iImageEncoder; - iImageEncoder = NULL; - } - - // make sure the buffer for conversion is empty - if (iGIFImageData) - { - delete iGIFImageData; - iGIFImageData = NULL; - } - - - TRequestStatus Stat = KRequestPending; - - // init & convert the bitmap to GIF format - iImageEncoder = CImageEncoder::DataNewL(iGIFImageData, CImageEncoder::EOptionAlwaysThread, KImageTypeGIFUid); - iImageEncoder->Convert( &Stat, *aBitmap ); - User::WaitForRequest(Stat); - - - // check any erros in converting - User::LeaveIfError( Stat.Int() ); - - // check if we have valid data - if (iGIFImageData == NULL || iGIFImageData->Des().Length()<793) - User::Leave(KErrNoMemory); - - // in GIF files generated by Symbian, the raster data always starts at offset 791, - // initial code size in GIF encoding should be 8 since we have a 8bpp image, - // also check that the second last byte is the terminator 0, - // if this check fails in newer releases of S60, proper parsing of GIF format is probably needed - TUint8* imagePtr = &iGIFImageData->Des()[0]; - if (imagePtr[791] != 8 || imagePtr[iGIFImageData->Des().Length()-2] != 0) - User::Leave(KErrNotSupported); - - // write the raster data block to the file - TUint writeLength = iGIFImageData->Des().Length() - 1 - 791; - imagePtr+=791; - TPtr8 writePtr(imagePtr, writeLength, writeLength); - User::LeaveIfError( iOutFile.Write(writePtr) ); - } - -// --------------------------------------------------------------------------- - -void CGifAnimator::WriteFooterL() - { - WriteInt8L(0x3b); // GIF trailer - } - -// --------------------------------------------------------------------------- - -void CGifAnimator::FinishL() - { - iOutFile.Close(); - iFs.Close(); - } - -// --------------------------------------------------------------------------- - -void CGifAnimator::WriteInt8L(TInt aValue) - { - HBufC8* buf = HBufC8::NewMaxLC(1); - - TUint8* ptr = &buf->Des()[0]; - ptr[0] = TUint8(aValue); - - User::LeaveIfError( iOutFile.Write(buf->Des()) ); - - CleanupStack::PopAndDestroy(); // buf - } - -// --------------------------------------------------------------------------- - -void CGifAnimator::WriteInt16L(TInt aValue) - { - HBufC8* buf = HBufC8::NewMaxLC(2); - - TUint8* ptr = &buf->Des()[0]; - ptr[0] = TUint8(aValue); - ptr[1] = TUint8(aValue>>8); - - User::LeaveIfError( iOutFile.Write(buf->Des()) ); - - CleanupStack::PopAndDestroy(); // buf - } - -// --------------------------------------------------------------------------- - diff -r 819e59dfc032 -r 2d9cac8919d3 screengrabber/src/main.cpp --- a/screengrabber/src/main.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,68 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include - -#include -#include -#include -#include - -#include "mainview.h" -#include "application.h" -#include "enginewrapper.h" -#include "settingsview.h" - - - -int main(int argc, char *argv[]) -{ - - SGApplication app(argc, argv); - - EngineWrapper engineWrapper; - app.SetEngineWrapper(&engineWrapper); - if (!engineWrapper.init()) { - return EXIT_FAILURE; - } - - - - HbMainWindow mainWindow; - - //Create main view - MainView* view = new MainView(mainWindow, engineWrapper); - //initialize main view - view->init(app); - - - SettingsView* settingsView = new SettingsView(*view, mainWindow, engineWrapper); - - view->setSettingsView(settingsView); - - // Add Views to main window and reveal it. - mainWindow.addView(view); - mainWindow.addView(settingsView); - - - mainWindow.show(); - - int result = app.exec(); - - return result; -} - diff -r 819e59dfc032 -r 2d9cac8919d3 screengrabber/src/mainview.cpp --- a/screengrabber/src/mainview.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,175 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "enginewrapper.h" -#include "settingsview.h" -#include "mainview.h" -#include "notifications.h" -#include "hbtoolbar.h" - -// --------------------------------------------------------------------------- - -MainView::MainView(HbMainWindow &mainWindow, EngineWrapper &engineWrapper): - mMainWindow(mainWindow), - mSettingsView(0), - mEngineWrapper(engineWrapper) -{ -} - -// --------------------------------------------------------------------------- - -MainView::~MainView() -{ -} - -// --------------------------------------------------------------------------- - -void MainView::init(HbApplication &app) -{ - this->setTitle("Screen Grabber"); - createMenu(app); - createInfoText(); - createToolbar(); - -} - -void MainView::createMenu(HbApplication& app) -{ - - HbMenu* menu = this->menu(); - - if (menu != NULL) { - - actionSendToBg = menu->addAction("Send to background"); - connect(actionSendToBg, SIGNAL( triggered() ), this, SLOT( sendToBackground() ) ); - - actionSettings = menu->addAction("Settings"); - connect(actionSettings, SIGNAL( triggered() ), this, SLOT( showSettings() ) ); - - actionAbout = menu->addAction("About"); - connect(actionAbout, SIGNAL( triggered() ), this, SLOT( showAboutPopup() ) ); - - actionExit = menu->addAction("Exit"); - connect(actionExit, SIGNAL(triggered()), this, SLOT( my_quit() ) ); - - HbAction *mDefaultNavigationAction = new HbAction(Hb::QuitNaviAction, this); - connect(mDefaultNavigationAction,SIGNAL(triggered()), this, SLOT(my_quit())); - setNavigationAction(mDefaultNavigationAction); - - //setNavigationAction(actionExit); - } -} - - -void MainView::quitYesNoQuestionClosed(HbAction* action) - { - HbMessageBox *dlg = static_cast(sender()); - if(action == dlg->primaryAction()) - { - qApp->quit(); - } - } - -void MainView::my_quit() - { - HbMessageBox::question("Do you really want to exit the Screen Grabber application?", - this, //receiver - SLOT(quitYesNoQuestionClosed(HbAction *)), //member - tr("Yes"), //primaryButtonText - tr("No"), //secondaryButtonText - new HbLabel("Exit Screen grabber confirm", this) - ); - } - -// --------------------------------------------------------------------------- - -void MainView::createInfoText() -{ - QGraphicsLinearLayout* layout = new QGraphicsLinearLayout(Qt::Vertical, this); - if (layout != NULL) { - HbTextEdit* edit = new HbTextEdit(this); - if(edit != NULL) { - edit->setPlainText("Please use the settings screen to define the " - "capture mode and any other related settings " - "such as capture hotkey and saving format. " - "Using the PNG format for screen shots is " - "recommended, since it is compressed but " - "lossless. The captures can be managed with " - "the Media Gallery application.\n\nYou may " - "start taking screenshots or capturing video " - "now. Please press the Applications key to go back " - "to the Application menu or send this application " - "to the background via the Options menu. To be " - "able to take screenshots or capture video, this " - "application needs to stay running in the " - "background."); - edit->setReadOnly(true); - //TODO edit->setCursorHidden(true); - //TODO edit->setAttribute(Qt::WA_InputMethodEnabled, false); - layout->addItem(edit); - layout->setContentsMargins(5, 5, 5, 5); - this->setLayout(layout); - } - - } - -} - -// --------------------------------------------------------------------------- - -void MainView::showSettings() -{ - mEngineWrapper.EnableRcpOfFoc(ETrue); - mEngineWrapper.LoadSettings(); - mSettingsView->loadSettings(); - mMainWindow.setCurrentView(mSettingsView); -} - -// --------------------------------------------------------------------------- - -void MainView::createToolbar() -{ - HbToolBar *toolbar = new HbToolBar(this); // main view takes the ownership - toolbar->addAction(actionSettings); - toolbar->addAction(actionSendToBg); - setToolBar(toolbar); -} - -// --------------------------------------------------------------------------- - -void MainView::showAboutPopup() -{ - Notifications::about(); -} - -// --------------------------------------------------------------------------- - -void MainView::sendToBackground() - { - mEngineWrapper.sendUIToBackground(); - } - - diff -r 819e59dfc032 -r 2d9cac8919d3 screengrabber/src/notifications.cpp --- a/screengrabber/src/notifications.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,85 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include -#include -#include - -#include "notifications.h" - - - -// --------------------------------------------------------------------------- - -void Notifications::imageCaptured() -{ - HbDeviceMessageBox::information("Screen shot saved to Media Gallery"); -} - -// --------------------------------------------------------------------------- - -void Notifications::about() -{ - HbMessageBox *messageBox = new HbMessageBox(HbMessageBox::MessageTypeInformation); - messageBox->setText("Version 5.0.0 - March 10th 2010. Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. Licensed under Eclipse Public License v1.0."); - HbLabel *header = new HbLabel("About Screen Grabber", messageBox); - messageBox->setHeadingWidget(header); - messageBox->setAttribute(Qt::WA_DeleteOnClose); - messageBox->setTimeout(HbPopup::NoTimeout); - messageBox->open(); -} - -// --------------------------------------------------------------------------- - -void Notifications::error(const QString& errorMessage) -{ - HbDeviceMessageBox::warning(errorMessage); - -} - -// --------------------------------------------------------------------------- - -void Notifications::sequantialImagesCaptured(int amount){ - // Code below launches a global note - QString text; - text.setNum(amount, 10); - text.append(" screen shots saved to Media Gallery"); - - HbDeviceMessageBox::information(text); - -} - -// --------------------------------------------------------------------------- - -void Notifications::videoCaptured() -{ - HbDeviceMessageBox::information("Video saved to Media Gallery"); - -} - -// --------------------------------------------------------------------------- - -HbDeviceProgressDialog* Notifications::showProgressBar(int max) -{ - HbDeviceProgressDialog *note = new HbDeviceProgressDialog(HbProgressDialog::ProgressDialog); - note->setText("Saving..."); - note->setMaximum(max); - note->show(); - return note; -} - -// --------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 screengrabber/src/settingsview.cpp --- a/screengrabber/src/settingsview.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,278 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#include "settingsview.h" -#include "enginewrapper.h" -#include "sgengine.h" -#include "hbslider.h" -#include "notifications.h" - - - -// --------------------------------------------------------------------------- - -SettingsView::SettingsView(HbView &mainView, HbMainWindow &mainWindow, EngineWrapper &engineWrapper): - mEngineWrapper(engineWrapper), - mMainWindow(mainWindow), - mMainView(mainView) -{ - // Set title and add this view to main window - setTitle("Settings"); - - HbAction *actionSaveSettings = menu()->addAction(QString("Save & close")); - HbAction *actionCancel = menu()->addAction("Cancel & close"); - - toolBar()->addAction(actionSaveSettings); - toolBar()->addAction(actionCancel); - - - //create setting form - mSettingForm = new HbDataForm(); - - //create a model class - mModel = new HbDataFormModel(this); - - // DataFormItem for mode selection - mModeItem = mModel->appendDataFormItem( - HbDataFormModelItem::RadioButtonListItem, QString("Capture mode"), 0); - mModeItem->setContentWidgetData(QString("items"), CAPTUREMODES); - - // Create setting model - createSingleCaptureComponents(mModel, 0); - createSequentialCaptureComponents(mModel, 0); - createVideoCaptureComponents(mModel, 0); - - // Set created model model to form - mSettingForm->setModel(mModel); - setWidget(mSettingForm);//takes ownership - - // Get view item of mode selection item - HbDataFormViewItem *viewItemVideoPage = static_cast(mSettingForm->itemByIndex(mModel->indexFromItem(mModeItem))); - - loadSettings(); - - // Connect signals from item modifications and close with this form's slots - connect(actionSaveSettings, SIGNAL(triggered()), this, SLOT(saveAndClose())); - connect(actionCancel, SIGNAL(triggered()), this, SLOT(close())); - - HbAction *mDefaultNavigationAction = new HbAction(Hb::QuitNaviAction, this); - connect(mDefaultNavigationAction,SIGNAL(triggered()), this, SLOT(saveAndClose())); - setNavigationAction(mDefaultNavigationAction); - - - -} - - -// --------------------------------------------------------------------------- - -SettingsView::~SettingsView() -{ - -} - -// --------------------------------------------------------------------------- - -void SettingsView::loadSettings() -{ - - // get settings from engine; - mSettings = mEngineWrapper.getGrabSettings(); - - //Capture mode - mModeItem->setContentWidgetData("selected", mSettings.mCaptureMode); - - // Still image - mImageHotKeyItem->setContentWidgetData("selected", mSettings.mSingleCaptureHotkey); - mImageFormatItem->setContentWidgetData("selected", mSettings.mSingleCaptureImageFormat); - mImageMemoryInUseItem->setContentWidgetData("selected", mSettings.mSingleCaptureMemoryInUseMultiDrive); - mImageFileNameItem->setContentWidgetData("text", mSettings.mSingleCaptureFileName); - - // Seguantial image components - mSequantialHotKeyItem->setContentWidgetData("selected", mSettings.mSequantialCaptureHotkey); - mSequantialFormatItem->setContentWidgetData("selected", mSettings.mSequantialCaptureImageFormat); - mSequantialDelayItem->setContentWidgetData("text", mSettings.mSequantialCaptureDelay); - mSequantialMemoryInUseItem->setContentWidgetData("selected", mSettings.mSequantialCaptureMemoryInUseMultiDrive); - mSequantialFileNameItem->setContentWidgetData("text", mSettings.mSequantialCaptureFileName); - - // Video capture components - mVideoHotKeyItem->setContentWidgetData("selected", mSettings.mVideoCaptureHotkey); - mVideoFormatItem->setContentWidgetData("selected", mSettings.mVideoCaptureVideoFormat); - mVideoMemoryInUseItem->setContentWidgetData("selected", mSettings.mVideoCaptureMemoryInUseMultiDrive); - mVideoFileNameItem->setContentWidgetData("text", mSettings.mVideoCaptureFileName); - - -} - -// --------------------------------------------------------------------------- - -void SettingsView::createSingleCaptureComponents(HbDataFormModel *model, HbDataFormModelItem *parent) -{ - - // Create Group for single image components - mGroupImageCapture = model->appendDataFormGroup(QString("Single image settings"), parent); - - // DataFormItem for hotkey selection - mImageHotKeyItem = model->appendDataFormItem( - HbDataFormModelItem::RadioButtonListItem, QString("Capture hotkey"), mGroupImageCapture); - mImageHotKeyItem->setContentWidgetData(QString("items"), KEYS); - - // DataFormItem for image format selection - mImageFormatItem = model->appendDataFormItem( - HbDataFormModelItem::RadioButtonListItem, QString("Image format"), mGroupImageCapture); - mImageFormatItem->setContentWidgetData(QString("items"), IMAGEFORMATS); - - // DataFormItem for memory in use selection - mImageMemoryInUseItem = model->appendDataFormItem( - HbDataFormModelItem::RadioButtonListItem, QString("Memory in use"), mGroupImageCapture); - mImageMemoryInUseItem->setContentWidgetData(QString("items"), MEMORYMODES); - - // DataFormItem for file name - mImageFileNameItem = model->appendDataFormItem( - HbDataFormModelItem::TextItem, QString("File name"), mGroupImageCapture); - mImageFileNameItem->setContentWidgetData(QString("text"), QString("Shot")); - -} - -// --------------------------------------------------------------------------- - -void SettingsView::createSequentialCaptureComponents(HbDataFormModel *model, HbDataFormModelItem *parent) -{ - - - // Create Group for sequential image components - mGroupSeguantialCapture = model->appendDataFormGroup(QString("Sequential image settings"), parent); - - // DataFormItem for hotkey selection - mSequantialHotKeyItem = model->appendDataFormItem( - HbDataFormModelItem::RadioButtonListItem, QString("Capture hotkey"), mGroupSeguantialCapture); - mSequantialHotKeyItem->setContentWidgetData(QString("items"), KEYS); - - // DataFormItem for image format selection - mSequantialFormatItem = model->appendDataFormItem( - HbDataFormModelItem::RadioButtonListItem, QString("Image format"), mGroupSeguantialCapture); - mSequantialFormatItem->setContentWidgetData(QString("items"), IMAGEFORMATS); - - // DataFormItem for delay between images selection - mSequantialDelayItem = model->appendDataFormItem( - HbDataFormModelItem::TextItem, QString("Delay between two images(ms)"), mGroupSeguantialCapture); - mSequantialDelayItem->setContentWidgetData(QString("text"), QString("Shot")); - - // DataFormItem for memory selection - mSequantialMemoryInUseItem = model->appendDataFormItem( - HbDataFormModelItem::RadioButtonListItem, QString("Memory in use"), mGroupSeguantialCapture); - mSequantialMemoryInUseItem->setContentWidgetData(QString("items"), MEMORYMODES); - - // DataFormItem for file name - mSequantialFileNameItem = model->appendDataFormItem( - HbDataFormModelItem::TextItem, QString("File name"), mGroupSeguantialCapture); - mSequantialFileNameItem->setContentWidgetData(QString("text"), QString("Shot")); - -} - -// --------------------------------------------------------------------------- - -void SettingsView::createVideoCaptureComponents(HbDataFormModel *model, HbDataFormModelItem *parent) -{ - - // Create Group for video capturing components - mGroupVideoCapture = model->appendDataFormGroup(QString("Video settings"), parent); - - // DataFormItem for hotkey selection - mVideoHotKeyItem = model->appendDataFormItem( - HbDataFormModelItem::RadioButtonListItem, QString("Start/Stop hotkey"), mGroupVideoCapture); - mVideoHotKeyItem->setContentWidgetData(QString("items"), KEYS); - - // DataFormItem for video format selection - mVideoFormatItem = model->appendDataFormItem( - HbDataFormModelItem::RadioButtonListItem, QString("Video format"), mGroupVideoCapture); - mVideoFormatItem->setContentWidgetData(QString("items"), VIDEOFORMATS); - - // DataFormItem for memory selection - mVideoMemoryInUseItem = model->appendDataFormItem( - HbDataFormModelItem::RadioButtonListItem, QString("Memory in use"), mGroupVideoCapture); - mVideoMemoryInUseItem->setContentWidgetData(QString("items"), MEMORYMODES); - - // DataFormItem for file name - mVideoFileNameItem = model->appendDataFormItem( - HbDataFormModelItem::TextItem, QString("File name"), mGroupVideoCapture); - mVideoFileNameItem->setContentWidgetData(QString("text"), QString("Video")); - -} - -// --------------------------------------------------------------------------- - -void SettingsView::saveAndClose() -{ - - readFormItems(); - if (!mEngineWrapper.saveSettings(mSettings)) { - Notifications::error("Unable to save settings"); - } - - mEngineWrapper.EnableRcpOfFoc(EFalse); - mMainWindow.setCurrentView(&mMainView); - -} - -// --------------------------------------------------------------------------- - -void SettingsView::readFormItems() -{ - - //TODO this does not work correctly with WK38 ( Text box items ) - - mSettings.mCaptureMode = mModeItem->contentWidgetData("selected").toInt(); - - mSettings.mSingleCaptureImageFormat = mImageFormatItem->contentWidgetData("selected").toInt(); - mSettings.mSingleCaptureHotkey = mImageHotKeyItem->contentWidgetData("selected").toInt(); - mSettings.mSingleCaptureMemoryInUseMultiDrive = mImageMemoryInUseItem->contentWidgetData("selected").toInt(); - mSettings.mSingleCaptureFileName = mImageFileNameItem->contentWidgetData("text").toString(); - - mSettings.mSequantialCaptureImageFormat = mSequantialFormatItem->contentWidgetData("selected").toInt(); - mSettings.mSequantialCaptureHotkey = mSequantialHotKeyItem ->contentWidgetData("selected").toInt(); - mSettings.mSequantialCaptureMemoryInUseMultiDrive = mSequantialMemoryInUseItem ->contentWidgetData("selected").toInt(); - mSettings.mSequantialCaptureFileName = mSequantialFileNameItem->contentWidgetData("text").toString(); - mSettings.mSequantialCaptureDelay = mSequantialDelayItem->contentWidgetData("text").toInt(); - - - mSettings.mVideoCaptureVideoFormat = mVideoFormatItem->contentWidgetData("selected").toInt(); - mSettings.mVideoCaptureHotkey = mVideoHotKeyItem ->contentWidgetData("selected").toInt(); - mSettings.mVideoCaptureMemoryInUseMultiDrive = mVideoMemoryInUseItem ->contentWidgetData("selected").toInt(); - mSettings.mVideoCaptureFileName = mVideoFileNameItem ->contentWidgetData("text").toString(); - - -} - -// --------------------------------------------------------------------------- - -void SettingsView::close() -{ - mEngineWrapper.EnableRcpOfFoc(EFalse); - mMainWindow.setCurrentView(&mMainView); -} diff -r 819e59dfc032 -r 2d9cac8919d3 screengrabber/src/sgengine.cpp --- a/screengrabber/src/sgengine.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1483 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "mainview.h" -#include "sgengine.h" -#include "enginewrapper.h" -#include "gifanimator.h" - - -#define SC_PRINTS - - #ifdef SC_PRINTS - #define SC_DEBUG(a) RDebug::Print(a) - #define SC_DEBUG2(a,b) RDebug::Print(a,b) - #else - #define SC_DEBUG(a) - #define SC_DEBUG2(a,b) - #endif - - - - -_LIT(KDefaultImageFileName, "Shot"); -_LIT(KDefaultVideoFileName, "Video"); - -#define HIGH_QUALITY_JPEG 97 -#define LOW_QUALITY_JPEG 60 -#define DEFAULT_SEQ_CAPTURE_DELAY_MS 5000 // 5.000 secs -#define VIDEO_CAPTURE_DELAY 250 // 0.25 secs -#define VIDEO_CAPTURE_MINIMUM_DELAY 200 // 0.20 secs -const TInt KSettingsDrive = EDriveC; -_LIT(KSettingsFileName, "screengrabber_settings.ini"); -_LIT(KScreenShotsSubDirectory, "Screen Shots\\"); -_LIT(KSGTemporaryDirectory, "\\system\\temp\\screengrabber\\"); - - -#define KEY_CAPTURE_PRIORITY 100 // do not change, this is for window server - -// --------------------------------------------------------------------------- - -SGEngine::SGEngine() : CActive(EPriorityStandard) - { - // No implementation required - } - -// --------------------------------------------------------------------------- - -SGEngine::~SGEngine() - { - - TRAP_IGNORE( CleanTemporaryFilesL() ); - - - if (iFrameImageData) - delete iFrameImageData; - - if (iPreviouslyCapturedBitmap) - delete iPreviouslyCapturedBitmap; - - if (iImageEncoder) - delete iImageEncoder; - - delete iVideoFrameArray; - - Cancel(); - iTimer.Close(); - - iFileSession.Close(); - - } - -// --------------------------------------------------------------------------- - -SGEngine* SGEngine::NewLC(EngineWrapper *aEngineWrapper) - { - SGEngine* self = new (ELeave) SGEngine(); - CleanupStack::PushL(self); - self->ConstructL(aEngineWrapper); - return self; - } - -// --------------------------------------------------------------------------- - -SGEngine* SGEngine::NewL(EngineWrapper *aEngineWrapper) - { - SGEngine* self = SGEngine::NewLC(aEngineWrapper); - CleanupStack::Pop(); // self; - return self; - } - -// --------------------------------------------------------------------------- - -void SGEngine::ConstructL(EngineWrapper *aEngineWrapper) - { - - iEngineWrapper = aEngineWrapper; - - iHashKeyCapturingActivated = EFalse; // Check this - - User::LeaveIfError(iTimer.CreateLocal()); - - iVideoFrameArray = new(ELeave) CVideoFrameArray(10000); - - iPreviouslyCapturedBitmap = new(ELeave) CFbsBitmap; - - iCapturingInProgress = EFalse; - iStopCapturing = EFalse; - iNumberOfTakenShots = 0; - iCurrentFrameNumber = 0; - iHashKeyDown = EFalse; - - - CActiveScheduler::Add(this); - User::LeaveIfError(iFileSession.Connect()); - - // create window group. - iRootWin = CEikonEnv::Static()->RootWin(); - iRootWin.EnableReceiptOfFocus(EFalse); - - } - -// --------------------------------------------------------------------------- - -void SGEngine::RunL(){ - - - SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- RunL begin")); - - switch (iState) - { - // encoding of the image is now finished - case EEncodingImage: - { - if (iGrabSettings.iCaptureMode == ECaptureModeSingleCapture) - { - // single shot done - CapturingFinishedL( iStatus.Int() ); - } - - else if (iGrabSettings.iCaptureMode == ECaptureModeSequantialCapture) - { - // increase the counter - iNumberOfTakenShots++; - - // check if we can take more shots or just finish - if (!iStopCapturing && iStatus.Int()==KErrNone) - { - - // some delay before the next shot can be taken - iState = ESequenceDelay; - - // some checking that the value of delay is valid - TInt delay(iGrabSettings.iSequantialCaptureDelay); //ms - if (delay<0 && delay > 999999) - delay = DEFAULT_SEQ_CAPTURE_DELAY_MS; - - iTimer.After(iStatus, delay*1000); - SetActive(); - } - else - { - // finished - CapturingFinishedL( iStatus.Int() ); - } - } - else - User::Panic(_L("Wrong mode"), 32); - - break; - } - - // delay finished, ready to take the next shot - case ESequenceDelay: - { - TakeScreenShotAndSaveL(); - - break; - } - - // asked to cancel capturing - case ECancelCapturing: - { - // finished - CapturingFinishedL( iStatus.Int() ); - - break; - } - - case ENextVideoFrame: - { - // increase the counter - iCurrentFrameNumber++; - - // check if we can take more frames or just finish - if (!iStopCapturing && iStatus.Int()==KErrNone) - { - // take next frame - CaptureFrameForVideoL(); - } - else - { - // finished, save video - SaveVideoL( iStatus.Int() ); - } - } - break; - - case ECancelVideoCapturing: - { - // finished, save video - SaveVideoL( iStatus.Int() ); - } - break; - - - default: - { - break; - } - } - SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- RunL end")); - - -} - - -void SGEngine::EnableRcpOfFoc(TBool aState) - { - iRootWin.EnableReceiptOfFocus(aState); - } - - -// --------------------------------------------------------------------------- - -void SGEngine::DoCancel(){ - iTimer.Cancel(); -} - -// --------------------------------------------------------------------------- - -void SGEngine::LoadDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, TInt& aValue) - { - if (aDicFS->IsPresentL(aUid)) - { - RDictionaryReadStream in; - in.OpenLC(*aDicFS, aUid); - aValue = in.ReadInt16L(); - CleanupStack::PopAndDestroy(); // in - } - } - -// --------------------------------------------------------------------------- - -void SGEngine::LoadDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, TDes& aValue) - { - if (aDicFS->IsPresentL(aUid)) - { - RDictionaryReadStream in; - in.OpenLC(*aDicFS, aUid); - TInt bufLength = in.ReadInt16L(); // get length of descriptor - in.ReadL(aValue, bufLength); // get the descriptor itself - CleanupStack::PopAndDestroy(); // in - } - } -// ---------------------------------------------------------------------------- - -void SGEngine::LoadSettingsL() - { - - // set defaults - iGrabSettings.iCaptureMode = ECaptureModeSingleCapture; - - iGrabSettings.iSingleCaptureHotkey = EHotkeySendKey; - iGrabSettings.iSingleCaptureImageFormat = EImageFormatPNG; - iGrabSettings.iSingleCaptureMemoryInUseMultiDrive = EPhoneMemory; - iGrabSettings.iSingleCaptureFileName.Copy( KDefaultImageFileName ); - - iGrabSettings.iSequantialCaptureHotkey = EHotkeySendKey; - iGrabSettings.iSequantialCaptureImageFormat = EImageFormatPNG; - iGrabSettings.iSequantialCaptureDelay = DEFAULT_SEQ_CAPTURE_DELAY_MS; - iGrabSettings.iSequantialCaptureMemoryInUseMultiDrive = EPhoneMemory; - iGrabSettings.iSequantialCaptureFileName.Copy( KDefaultImageFileName ); - - iGrabSettings.iVideoCaptureHotkey = EHotkeySendKey; - iGrabSettings.iVideoCaptureVideoFormat = EVideoFormatAnimatedGIF; - iGrabSettings.iVideoCaptureMemoryInUseMultiDrive = EPhoneMemory; - iGrabSettings.iVideoCaptureFileName.Copy( KDefaultVideoFileName ); - - - // make sure that the private path of this app in c-drive exists - - iFileSession.CreatePrivatePath( KSettingsDrive ); // c:\\private\\101fb751\\ - - // handle settings always in the private directory - - if (iFileSession.SetSessionToPrivate( KSettingsDrive ) == KErrNone) - { - // open or create a dictionary file store - CDictionaryFileStore* settingsStore = CDictionaryFileStore::OpenLC(iFileSession, KSettingsFileName, KUidScreenGrabber); - - LoadDFSValueL(settingsStore, KSGSettingCaptureMode, iGrabSettings.iCaptureMode); - - LoadDFSValueL(settingsStore, KSGSettingSingleCaptureHotkey, iGrabSettings.iSingleCaptureHotkey); - LoadDFSValueL(settingsStore, KSGSettingSingleCaptureImageFormat, iGrabSettings.iSingleCaptureImageFormat); - LoadDFSValueL(settingsStore, KSGSettingSingleCaptureMemoryInUseMultiDrive, iGrabSettings.iSingleCaptureMemoryInUseMultiDrive); - LoadDFSValueL(settingsStore, KSGSettingSingleCaptureFileName, iGrabSettings.iSingleCaptureFileName); - - LoadDFSValueL(settingsStore, KSGSettingSequantialCaptureHotkey, iGrabSettings.iSequantialCaptureHotkey); - LoadDFSValueL(settingsStore, KSGSettingSequantialCaptureImageFormat, iGrabSettings.iSequantialCaptureImageFormat); - LoadDFSValueL(settingsStore, KSGSettingSequantialCaptureDelay, iGrabSettings.iSequantialCaptureDelay); - LoadDFSValueL(settingsStore, KSGSettingSequantialCaptureMemoryInUseMultiDrive, iGrabSettings.iSequantialCaptureMemoryInUseMultiDrive); - LoadDFSValueL(settingsStore, KSGSettingSequantialCaptureFileName, iGrabSettings.iSequantialCaptureFileName); - - LoadDFSValueL(settingsStore, KSGSettingVideoCaptureHotkey, iGrabSettings.iVideoCaptureHotkey); - LoadDFSValueL(settingsStore, KSGSettingVideoCaptureVideoFormat, iGrabSettings.iVideoCaptureVideoFormat); - LoadDFSValueL(settingsStore, KSGSettingVideoCaptureMemoryInUseMultiDrive, iGrabSettings.iVideoCaptureMemoryInUseMultiDrive); - LoadDFSValueL(settingsStore, KSGSettingVideoCaptureFileName, iGrabSettings.iVideoCaptureFileName); - - CleanupStack::PopAndDestroy(); // settingsStore - } -//chesk if all settings are in range - for safety reason, not to set some controls out of range - it causes the crash - if (!(iGrabSettings.iCaptureMode >= ECaptureModeSingleCapture && iGrabSettings.iCaptureMode <= ECaptureModeVideoCapture)) - { //give it default value - iGrabSettings.iCaptureMode = ECaptureModeSingleCapture; - } - if (!(iGrabSettings.iSingleCaptureHotkey >= EHotkeySendKey && iGrabSettings.iSingleCaptureHotkey <= EHotkeyCameraKey1)) - { - iGrabSettings.iSingleCaptureHotkey = EHotkeySendKey; - } - if (!(iGrabSettings.iSingleCaptureImageFormat >= EImageFormatPNG && iGrabSettings.iSingleCaptureImageFormat <= EImageFormatGIF)) - { - iGrabSettings.iSingleCaptureImageFormat = EImageFormatPNG; - } - if (!(iGrabSettings.iSingleCaptureMemoryInUseMultiDrive >= EPhoneMemory && iGrabSettings.iSingleCaptureMemoryInUseMultiDrive <= EMemoryCard)) - { - iGrabSettings.iSingleCaptureMemoryInUseMultiDrive = EPhoneMemory; - } - - if (!(iGrabSettings.iSequantialCaptureHotkey >= EHotkeySendKey && iGrabSettings.iSequantialCaptureHotkey <= EHotkeyCameraKey1)) - { - iGrabSettings.iSequantialCaptureHotkey = EHotkeySendKey; - } - if (!(iGrabSettings.iSequantialCaptureImageFormat >= EImageFormatPNG && iGrabSettings.iSequantialCaptureImageFormat <= EImageFormatGIF)) - { - iGrabSettings.iSequantialCaptureImageFormat = EImageFormatPNG; - } - if (!(iGrabSettings.iSequantialCaptureMemoryInUseMultiDrive >= EPhoneMemory && iGrabSettings.iSequantialCaptureMemoryInUseMultiDrive <= EMemoryCard)) - { - iGrabSettings.iSequantialCaptureMemoryInUseMultiDrive = EPhoneMemory; - } - - if (!(iGrabSettings.iVideoCaptureHotkey >= EHotkeySendKey && iGrabSettings.iVideoCaptureHotkey <= EHotkeyCameraKey1)) - { - iGrabSettings.iVideoCaptureHotkey = EHotkeySendKey; - } - if (iGrabSettings.iVideoCaptureVideoFormat != EVideoFormatAnimatedGIF) - { - iGrabSettings.iVideoCaptureVideoFormat = EVideoFormatAnimatedGIF; - } - if (!(iGrabSettings.iVideoCaptureMemoryInUseMultiDrive >= EPhoneMemory && iGrabSettings.iVideoCaptureMemoryInUseMultiDrive <= EMemoryCard)) - { - iGrabSettings.iVideoCaptureMemoryInUseMultiDrive = EPhoneMemory; - } - - } - -// --------------------------------------------------------------------------- - -void SGEngine::SaveDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, const TInt& aValue) - { - RDictionaryWriteStream out; - out.AssignLC(*aDicFS, aUid); - out.WriteInt16L(aValue); - out.CommitL(); - CleanupStack::PopAndDestroy(1);// out - } - -// --------------------------------------------------------------------------- - -void SGEngine::SaveDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, const TDes& aValue) - { - RDictionaryWriteStream out; - out.AssignLC(*aDicFS, aUid); - out.WriteInt16L(aValue.Length()); // write length of the descriptor - out.WriteL(aValue, aValue.Length()); // write the descriptor itself - out.CommitL(); - CleanupStack::PopAndDestroy(1);// out - } - -// --------------------------------------------------------------------------- -void SGEngine::SaveSettingsL(TGrabSettings aGrabSettings) - { - - - // set the new settings - iGrabSettings = aGrabSettings; - - // handle settings always in c:\\private\\101fb751\\ - if (iFileSession.SetSessionToPrivate( KSettingsDrive ) == KErrNone) - { - // delete existing store to make sure that it is clean and not eg corrupted - if (BaflUtils::FileExists(iFileSession, KSettingsFileName)) - { - iFileSession.Delete(KSettingsFileName); - } - - // create a dictionary file store - CDictionaryFileStore* settingsStore = CDictionaryFileStore::OpenLC(iFileSession, KSettingsFileName, KUidScreenGrabber); - - SaveDFSValueL(settingsStore, KSGSettingCaptureMode, iGrabSettings.iCaptureMode); - - SaveDFSValueL(settingsStore, KSGSettingSingleCaptureHotkey, iGrabSettings.iSingleCaptureHotkey); - SaveDFSValueL(settingsStore, KSGSettingSingleCaptureImageFormat, iGrabSettings.iSingleCaptureImageFormat); - SaveDFSValueL(settingsStore, KSGSettingSingleCaptureMemoryInUseMultiDrive, iGrabSettings.iSingleCaptureMemoryInUseMultiDrive); - SaveDFSValueL(settingsStore, KSGSettingSingleCaptureFileName, iGrabSettings.iSingleCaptureFileName); - - SaveDFSValueL(settingsStore, KSGSettingSequantialCaptureHotkey, iGrabSettings.iSequantialCaptureHotkey); - SaveDFSValueL(settingsStore, KSGSettingSequantialCaptureImageFormat, iGrabSettings.iSequantialCaptureImageFormat); - SaveDFSValueL(settingsStore, KSGSettingSequantialCaptureDelay, iGrabSettings.iSequantialCaptureDelay); - SaveDFSValueL(settingsStore, KSGSettingSequantialCaptureMemoryInUseMultiDrive, iGrabSettings.iSequantialCaptureMemoryInUseMultiDrive); - SaveDFSValueL(settingsStore, KSGSettingSequantialCaptureFileName, iGrabSettings.iSequantialCaptureFileName); - - SaveDFSValueL(settingsStore, KSGSettingVideoCaptureHotkey, iGrabSettings.iVideoCaptureHotkey); - SaveDFSValueL(settingsStore, KSGSettingVideoCaptureVideoFormat, iGrabSettings.iVideoCaptureVideoFormat); - SaveDFSValueL(settingsStore, KSGSettingVideoCaptureMemoryInUseMultiDrive, iGrabSettings.iVideoCaptureMemoryInUseMultiDrive); - SaveDFSValueL(settingsStore, KSGSettingVideoCaptureFileName, iGrabSettings.iVideoCaptureFileName); - - settingsStore->CommitL(); - CleanupStack::PopAndDestroy(); // settingsStore - } - - } - -// --------------------------------------------------------------------------- - -void SGEngine::ActivateCaptureKeysL(TBool aChangeKey) - { - - // if changing the capture key, capturing needs to be cancelled first - if (aChangeKey) - { - CancelCapturing(); - } - - // get hotkey of the capture - TInt captureHotkey(0); - if (iGrabSettings.iCaptureMode == ECaptureModeSingleCapture) - captureHotkey = iGrabSettings.iSingleCaptureHotkey; - else if (iGrabSettings.iCaptureMode == ECaptureModeSequantialCapture) - captureHotkey = iGrabSettings.iSequantialCaptureHotkey; - else if (iGrabSettings.iCaptureMode == ECaptureModeVideoCapture) - captureHotkey = iGrabSettings.iVideoCaptureHotkey; - else - User::Panic(_L("Wrong mode"), 40); - - - - // start capturing based on user selected key - switch (captureHotkey) - { - case EHotkeySendKey: - { - iCapturedKey = iRootWin.CaptureKey(EStdKeyYes, EModifierCtrl|EModifierShift|EModifierFunc, 0, KEY_CAPTURE_PRIORITY); - iCapturedKeyUnD = iRootWin.CaptureKeyUpAndDowns(EStdKeyYes, EModifierCtrl|EModifierShift|EModifierFunc, 0, KEY_CAPTURE_PRIORITY); - break; - } - case EHotkeyPowerKey: - { - iCapturedKey = iRootWin.CaptureKey(EStdKeyDevice2, EModifierCtrl|EModifierShift|EModifierFunc, 0, KEY_CAPTURE_PRIORITY); - iCapturedKeyUnD = iRootWin.CaptureKeyUpAndDowns(EStdKeyDevice2, EModifierCtrl|EModifierShift|EModifierFunc, 0, KEY_CAPTURE_PRIORITY); - break; - } - case EHotkeySideKey: - { - iCapturedKey = iRootWin.CaptureKey(EStdKeyDevice6, EModifierCtrl|EModifierShift|EModifierFunc, 0, KEY_CAPTURE_PRIORITY); - iCapturedKeyUnD = iRootWin.CaptureKeyUpAndDowns(EStdKeyDevice6, EModifierCtrl|EModifierShift|EModifierFunc, 0, KEY_CAPTURE_PRIORITY); - break; - } - case EHotkeyCameraKey1: - { - iCapturedKey = iRootWin.CaptureKey(EStdKeyDevice7, EModifierCtrl|EModifierShift|EModifierFunc, 0, KEY_CAPTURE_PRIORITY); - iCapturedKeyUnD = iRootWin.CaptureKeyUpAndDowns(EStdKeyDevice7, EModifierCtrl|EModifierShift|EModifierFunc, 0, KEY_CAPTURE_PRIORITY); - break; - } - default: - { - User::Panic(_L("Key not supported"), 100); - break; - } - } - - } - -// --------------------------------------------------------------------------- - - -void SGEngine::CancelCapturing() - { - - SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- CancelCapturing start")); - // cancel all captures - iRootWin.CancelCaptureKey(iCapturedKey); - iRootWin.CancelCaptureKeyUpAndDowns(iCapturedKeyUnD); - - if (iHashKeyCapturingActivated) - { - iRootWin.CancelCaptureKey(iCapturedKeyHash); - iRootWin.CancelCaptureKeyUpAndDowns(iCapturedKeyHashUnD); - - iHashKeyCapturingActivated = EFalse; - } - - SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- CancelCapturing end")); - - } - -// --------------------------------------------------------------------------- - -bool SGEngine::TakeScreenShotAndSaveL() - { - - SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- TakeSsAndSave start")); - if ( IsActive() ) - { - SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- TakeSsAndSave already active, ignored")); - return false; - } - - // take a screen shot - CWsScreenDevice* screenDevice = new( ELeave ) CWsScreenDevice(CEikonEnv::Static()->WsSession() ); - CleanupStack::PushL( screenDevice ); - - User::LeaveIfError( screenDevice->Construct( CEikonEnv::Static()->WsSession().GetFocusScreen() ) ); - - - User::LeaveIfError( iPreviouslyCapturedBitmap->Create(screenDevice->SizeInPixels(), screenDevice->DisplayMode()) ); - User::LeaveIfError( screenDevice->CopyScreenToBitmap(iPreviouslyCapturedBitmap) ); - CleanupStack::PopAndDestroy(); // screenDevice - - - // get memory in use & image format of the screen capture - TDriveNumber memoryInUse(EDriveC); - TInt intMemInUse(0); - TInt imageFormat(0); - TFileName fileName; - - if (iGrabSettings.iCaptureMode == ECaptureModeSingleCapture) - { -// memoryInUse = iGrabSettings.iSingleCaptureMemoryInUseMultiDrive; - intMemInUse = iGrabSettings.iSingleCaptureMemoryInUseMultiDrive; - - imageFormat = iGrabSettings.iSingleCaptureImageFormat; - fileName = iGrabSettings.iSingleCaptureFileName; - } - else if (iGrabSettings.iCaptureMode == ECaptureModeSequantialCapture) - { -// memoryInUse = iGrabSettings.iSequantialCaptureMemoryInUseMultiDrive; - intMemInUse = iGrabSettings.iSequantialCaptureMemoryInUseMultiDrive; - - imageFormat = iGrabSettings.iSequantialCaptureImageFormat; - fileName = iGrabSettings.iSequantialCaptureFileName; - } - else - User::Panic(_L("Wrong mode"), 30); - - - // init the path for saving the file - - iSaveFileName.Copy( PathInfo::PhoneMemoryRootPath() ); - -// if (memoryInUse != EDriveC)//something different as PhoneMemory (memory card or mass memory) - if (intMemInUse != 0)//something different as PhoneMemory (memory card or mass memory) - { - memoryInUse = EDriveY; - if (PathInfo::GetRootPath(iSaveFileName, memoryInUse) != KErrNone || !DriveOK(memoryInUse)) - { - //we need to find first available memory card in EDriveE - EDriveY range - for (TInt i = EDriveY; i>=EDriveE; i--) - { - if ( DriveOK((TDriveNumber)(i))) - { - if (IsDriveMMC((TDriveNumber)(i))) - { - PathInfo::GetRootPath(iSaveFileName, (TDriveNumber)(i)); - break; - } - } - } - } - } - - iSaveFileName.Append( PathInfo::ImagesPath() ); - iSaveFileName.Append( KScreenShotsSubDirectory ); - - - // a quick check that filename is valid - if (fileName.Length() > 0 && fileName.Length() <= 255) - iSaveFileName.Append( fileName ); - else - iSaveFileName.Append( KDefaultImageFileName ); - - iSaveFileName.Append( _L(".") ); - - - // reset the encoder - if (iImageEncoder) - { - delete iImageEncoder; - iImageEncoder = NULL; - } - - - switch (imageFormat) - { - case EImageFormatPNG: - { - // set filename - iSaveFileName.Append(_L("png")); - CApaApplication::GenerateFileName(iFileSession, iSaveFileName ); // unique filename - - // init & convert - iImageEncoder = CImageEncoder::FileNewL(iFileSession, iSaveFileName, CImageEncoder::EOptionAlwaysThread, KImageTypePNGUid); - - iImageEncoder->Convert( &iStatus, *iPreviouslyCapturedBitmap ); - } - break; - - case EImageFormatJPGHQ: - case EImageFormatJPGLQ: - { - // reset frameimagedata - if (iFrameImageData) - { - delete iFrameImageData; - iFrameImageData = NULL; - } - - // set filename - iSaveFileName.Append(_L("jpg")); - CApaApplication::GenerateFileName(iFileSession, iSaveFileName ); // unique filename - - // init - iImageEncoder = CImageEncoder::FileNewL(iFileSession, iSaveFileName, CImageEncoder::EOptionAlwaysThread, KImageTypeJPGUid); - - // JPEG properties - TJpegImageData* imageData = new(ELeave) TJpegImageData; - imageData->iSampleScheme = TJpegImageData::EColor444; - imageData->iQualityFactor = (imageFormat==EImageFormatJPGHQ) ? HIGH_QUALITY_JPEG : LOW_QUALITY_JPEG; - iFrameImageData = CFrameImageData::NewL(); - User::LeaveIfError(iFrameImageData->AppendImageData(imageData)); //ownership of imageData is transferred - - // convert - iImageEncoder->Convert( &iStatus, *iPreviouslyCapturedBitmap, iFrameImageData ); - } - break; - - case EImageFormatBMP: - { - // set filename - iSaveFileName.Append(_L("bmp")); - CApaApplication::GenerateFileName(iFileSession, iSaveFileName ); // unique filename - - // init & convert - iImageEncoder = CImageEncoder::FileNewL(iFileSession, iSaveFileName, CImageEncoder::EOptionAlwaysThread, KImageTypeBMPUid); - iImageEncoder->Convert( &iStatus, *iPreviouslyCapturedBitmap ); - } - break; - - case EImageFormatGIF: - { - // set filename - iSaveFileName.Append(_L("gif")); - CApaApplication::GenerateFileName(iFileSession, iSaveFileName ); // unique filename - - // init & convert - iImageEncoder = CImageEncoder::FileNewL(iFileSession, iSaveFileName, CImageEncoder::EOptionAlwaysThread, KImageTypeGIFUid); - iImageEncoder->Convert( &iStatus, *iPreviouslyCapturedBitmap ); - } - break; - - case EImageFormatMBM: - { - // set filename - iSaveFileName.Append(_L("mbm")); - CApaApplication::GenerateFileName(iFileSession, iSaveFileName ); // unique filename - - // init & convert - iImageEncoder = CImageEncoder::FileNewL(iFileSession, iSaveFileName, CImageEncoder::EOptionAlwaysThread, KImageTypeMBMUid); - iImageEncoder->Convert( &iStatus, *iPreviouslyCapturedBitmap ); - } - break; - - default: - { - User::Panic(_L("Invalid Img Type"), 20); - } - } - - // set the state of the active object - iState = EEncodingImage; - - // indicate an outstanding request - SetActive(); - SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- TakeSsAndSave end")); - return true; - } - -// --------------------------------------------------------------------------- - - -TBool SGEngine::DriveOK(TDriveNumber aNumber) - { - - SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- Driveok start")); - TBool isOK(EFalse); - - TVolumeInfo vInfo; - - // check if we can access the drive - if (iFileSession.Volume(vInfo, aNumber) == KErrNone) - isOK = ETrue; - - // returns ETrue if memory card working properly - SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- DriveOK end")); - return isOK; - - } -// --------------------------------------------------------------------------- - - -TBool SGEngine::IsDriveMMC(TDriveNumber aDrive) - { - SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- IsDriveMMC start")); - TBool isOK(EFalse); - - TDriveInfo ii; - if (iFileSession.Drive(ii, aDrive)==KErrNone) - { - if (ii.iType!=EMediaNotPresent && - ii.iType!=EMediaUnknown && - ii.iType!=EMediaCdRom && - ii.iType!=EMediaRom) - { // memory card - isOK=ETrue; - } - } - - - SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- IsDriveMMC end")); - return isOK; - } - - -void SGEngine::CapturingFinishedL(TInt aErr) - { - - SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- CapturingFinished start")); - // display a global query to show the results - - if (aErr == KErrNone) - { - switch (iGrabSettings.iCaptureMode) - { - case ECaptureModeSingleCapture: - { - iEngineWrapper->ShowImageCapturedNote(); - } - break; - - case ECaptureModeSequantialCapture: - { - iEngineWrapper->ShowSequantialImagesCapturedNote(iNumberOfTakenShots); - } - break; - - case ECaptureModeVideoCapture: - { - iEngineWrapper->ShowVideoCapturedNote(); - } - break; - - default: - User::Panic(_L("Inv.capt.mode"), 51); - break; - } - - } - else - { - - // Get error message with CTextResolver - CTextResolver* textResolver = CTextResolver::NewLC(); - iEngineWrapper->ShowErrorMessage(textResolver->ResolveErrorString(aErr)); - - CleanupStack::PopAndDestroy(); //textResolver - - } - - // capturing can now be restarted - iState = EIdle; - iCapturingInProgress = EFalse; - iStopCapturing = EFalse; - - // reset values - iNumberOfTakenShots = 0; - iCurrentFrameNumber = 0; - iVideoFrameArray->Reset(); - - - iState = EQueryDelay; - iTimer.After(iStatus, 2000000); - SetActive(); - - SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- capturingfinished end")); - - } - - -#if defined(HB_QT_S60_EVENT_FILTER) - TBool SGEngine::HandleCaptureCommandsL(const TWsEvent* aEvent) - { -#else - TBool SGEngine::HandleCaptureCommandsL(const QSymbianEvent *event) - { - if (event->type() != QSymbianEvent::WindowServerEvent) { - return ETrue; //continueEventLoop - } - const TWsEvent *aEvent = event->windowServerEvent(); -#endif - - SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- HandleCaptureCommand start")); - - - TBool continueEventLoop(ETrue); - - // get hotkey of the capture - TInt captureHotkey(0); - if (iGrabSettings.iCaptureMode == ECaptureModeSingleCapture) - captureHotkey = iGrabSettings.iSingleCaptureHotkey; - else if (iGrabSettings.iCaptureMode == ECaptureModeSequantialCapture) - captureHotkey = iGrabSettings.iSequantialCaptureHotkey; - else if (iGrabSettings.iCaptureMode == ECaptureModeVideoCapture) - captureHotkey = iGrabSettings.iVideoCaptureHotkey; - else - User::Panic(_L("Wrong mode"), 41); - - // ignore any errors - if (aEvent->Type()==EEventErrorMessage) - { - // error - } - - - // handle captured keys, we are interested here only of the keydown events - else - - if ( - ( captureHotkey == EHotkeySendKey && - aEvent->Type()==EEventKeyDown && aEvent->Key()->iScanCode==EStdKeyYes ) - || - ( captureHotkey == EHotkeyPowerKey && - aEvent->Type()==EEventKeyDown && aEvent->Key()->iScanCode==EStdKeyDevice2 ) - || - ( captureHotkey == EHotkeySideKey && - aEvent->Type()==EEventKeyDown && aEvent->Key()->iScanCode==EStdKeyDevice6 ) - || - ( captureHotkey == EHotkeyCameraKey1 && - aEvent->Type()==EEventKeyDown && aEvent->Key()->iScanCode==EStdKeyDevice7 ) - ) - { - - // check if already capturing images in sequence - if ( iCapturingInProgress && !iStopCapturing && iNumberOfTakenShots!=0 && iGrabSettings.iCaptureMode == ECaptureModeSequantialCapture ) - { - // asking to stop capturing - iStopCapturing = ETrue; - - // cancel the active object, this will cancel any timer delays and ICL stuff - Cancel(); - - // set status - iState = ECancelCapturing; - - // jump smoothly to RunL() - iTimer.After(iStatus, 50); - SetActive(); - - // do not continue the event loop in HandleWsEventL for these events - continueEventLoop = EFalse; - } - - // check if already capturing video - else if ( iCapturingInProgress && !iStopCapturing && iGrabSettings.iCaptureMode == ECaptureModeVideoCapture ) - { - // asking to stop capturing - iStopCapturing = ETrue; - - // cancel the active object, this will cancel any timer delays and ICL stuff - Cancel(); - - // set status - iState = ECancelVideoCapturing; - - // jump smoothly to RunL() - iTimer.After(iStatus, 50); - SetActive(); - - // do not continue the event loop in HandleWsEventL for these events - continueEventLoop = EFalse; - } - else if (!iCapturingInProgress && (iGrabSettings.iCaptureMode == ECaptureModeSingleCapture || iGrabSettings.iCaptureMode == ECaptureModeSequantialCapture )) - { - - // take a screen shot and save it - if( TakeScreenShotAndSaveL()) - { - // not capturing anything, so start doing that - iCapturingInProgress = ETrue; - // do not continue the event loop in HandleWsEventL for these events - continueEventLoop = EFalse; - } - } - - else if (!iCapturingInProgress && iGrabSettings.iCaptureMode == ECaptureModeVideoCapture ) - { - // not capturing anything, so start doing that - iCapturingInProgress = ETrue; - - // clean temporary files - TRAP_IGNORE( CleanTemporaryFilesL() ); - - // get initial dimensions for the video - CWsScreenDevice* screenDevice = new(ELeave) CWsScreenDevice ( CEikonEnv::Static()->WsSession() ); - CleanupStack::PushL(screenDevice); - - User::LeaveIfError( screenDevice->Construct( CEikonEnv::Static()->WsSession().GetFocusScreen() ) ); - - iVideoDimensions = screenDevice->SizeInPixels(); - iPreviousFrameScreenDimension = screenDevice->SizeInPixels(); - CleanupStack::PopAndDestroy(); // screenDevice - - // capture the first frame - CaptureFrameForVideoL(); - - // do not continue the event loop in HandleWsEventL for these events - continueEventLoop = EFalse; - } - - } - - // catch other event types as well so that we can ignore them - else if ( - ( captureHotkey == EHotkeySendKey && - aEvent->Key()->iScanCode==EStdKeyYes ) - || - ( captureHotkey == EHotkeyPowerKey && - aEvent->Key()->iScanCode==EStdKeyDevice2 ) - || - ( captureHotkey == EHotkeySideKey && - aEvent->Key()->iScanCode==EStdKeyDevice6 ) - || - ( captureHotkey == EHotkeyCameraKey1 && - aEvent->Key()->iScanCode==EStdKeyDevice7 ) - ) - { - // do not continue the event loop in HandleWsEventL for these events - continueEventLoop = EFalse; - } - - SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- HandleCapturcommand end")); - - - return continueEventLoop; - - } - -// --------------------------------------------------------------------------- - -void SGEngine::CleanTemporaryFilesL() - { - - SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- CleanTempFiles start")); - - // delete temporary files from C and D drives - CFileMan* fileMan = CFileMan::NewL(iFileSession); - - TFileName delFilesPath; - - for (TInt i=0; i<1; i++) - { - delFilesPath.Copy(KNullDesC); - delFilesPath.Append('C'+i); - delFilesPath.Append(_L(":")); - delFilesPath.Append(KSGTemporaryDirectory); - delFilesPath.Append(_L("*.$$$")); - - fileMan->Delete(delFilesPath); - } - - delete fileMan; - SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- CleanTempfile end")); - - } - -// --------------------------------------------------------------------------- - -void SGEngine::ActivateModelL() - { - // clean temporary files - TRAP_IGNORE( CleanTemporaryFilesL() ); - - // load settings - TRAP_IGNORE( LoadSettingsL() ); - - // start capturing - ActivateCaptureKeysL(); - } - -// --------------------------------------------------------------------------- - -void SGEngine::DeActivateModelL() - { - - CancelCapturing(); - - // for a faster exit, send the application to background - TApaTask selfTask(CEikonEnv::Static()->WsSession()); - selfTask.SetWgId(iRootWin.Identifier()); - selfTask.SendToBackground(); - - - } - -// --------------------------------------------------------------------------- - - -void SGEngine::CaptureFrameForVideoL() - { - - SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- CaptureFrameforvide start")); - // record time - TTime timeNow; - timeNow.HomeTime(); - - // take a screen shot - CFbsBitmap* currentCapturedBitmap = new(ELeave) CFbsBitmap; - CleanupStack::PushL(currentCapturedBitmap); - - CWsScreenDevice* screenDevice = new(ELeave) CWsScreenDevice( CEikonEnv::Static()->WsSession() ); - CleanupStack::PushL( screenDevice ); - User::LeaveIfError( screenDevice->Construct( CEikonEnv::Static()->WsSession().GetFocusScreen() ) ); - - TSize currentScreenSize = screenDevice->SizeInPixels(); - - User::LeaveIfError( currentCapturedBitmap->Create(currentScreenSize, EColor256) ); - User::LeaveIfError( screenDevice->CopyScreenToBitmap(currentCapturedBitmap) ); - CleanupStack::PopAndDestroy(); // screenDevice - - // grow video's dimensions if the size has changed - if (currentScreenSize.iWidth > iVideoDimensions.iWidth) - { - iVideoDimensions.iWidth = currentScreenSize.iWidth; - } - if (currentScreenSize.iHeight > iVideoDimensions.iHeight) - { - iVideoDimensions.iHeight = currentScreenSize.iHeight; - } - - TInt64 currentDelay(0); - - - // create a new frame - TVideoFrame frame; - frame.iDelay = 500; // use default delay 5.00 secs - - // get info of the RAM drive - TDriveNumber ramDrive = EDriveD; - TVolumeInfo ramDriveInfo; - iFileSession.Volume(ramDriveInfo, ramDrive); - - // init the directory for saving the file, preferably use ram drive if there is enough disk space, otherwise use always C drive - TFileName tempDirectory; - TFileName sessionPath; - - if (ramDriveInfo.iFree > (iVideoDimensions.iWidth*iVideoDimensions.iHeight+50000)) - sessionPath.Copy( _L("D:") ); - else - sessionPath.Copy( _L("C:") ); - - sessionPath.Append(KSGTemporaryDirectory); - tempDirectory.Copy(KSGTemporaryDirectory); - - iFileSession.MkDirAll(sessionPath); - iFileSession.SetSessionPath(sessionPath); - - // create a temp file, path to the bitmap is saved automatically to frame.iFileStorePath - RFile file; - User::LeaveIfError( file.Temp(iFileSession, tempDirectory, frame.iFileStorePath, EFileWrite) ); - RFileWriteStream writeStream(file); - - TBool ignoreFrame(EFalse); - - // check if is this the first frame - if (iCurrentFrameNumber == 0) - { - // first frame is always the full one - frame.iWidth = currentScreenSize.iWidth; - frame.iHeight = currentScreenSize.iHeight; - frame.iXPos = 0; - frame.iYPos = 0; - frame.iEnableTransparency = EFalse; - frame.iFillsWholeScreen = ETrue; - - currentCapturedBitmap->ExternalizeL(writeStream); - - } - - else - { - // next frame is a difference between the previous one - currentDelay = timeNow.MicroSecondsFrom(iPreviousFrameTaken).Int64(); - - // get reference to previos frame - TVideoFrame& prevFrame = iVideoFrameArray->At(iVideoFrameArray->Count()-1); - - - // check if video dimensions have changed - if (currentScreenSize.iWidth != iPreviousFrameScreenDimension.iWidth - || currentScreenSize.iHeight != iPreviousFrameScreenDimension.iHeight) - { - // dimensions have changed -> save a full bitmap - frame.iWidth = currentScreenSize.iWidth; - frame.iHeight = currentScreenSize.iHeight; - frame.iXPos = 0; - frame.iYPos = 0; - frame.iEnableTransparency = EFalse; - frame.iFillsWholeScreen = ETrue; - - currentCapturedBitmap->ExternalizeL(writeStream); - - // update the previous frame to contain the new delay value - prevFrame.iDelay = TUint( (double) currentDelay / 10000 ); - } - - else - { - // compare the bitmaps - HBufC8* curImgScanLineBuf = HBufC8::NewLC(currentScreenSize.iWidth*3); - TPtr8 curImgScanLinePtr = curImgScanLineBuf->Des(); - HBufC8* prevImgScanLineBuf = HBufC8::NewLC(currentScreenSize.iWidth*3); - TPtr8 prevImgScanLinePtr = prevImgScanLineBuf->Des(); - - TPoint pt(0,0); - TBool differenceFound(EFalse); - TPoint leftTopDifferencePoint(0,0); - TPoint rightBottomDifferencePoint(currentScreenSize.iWidth,currentScreenSize.iHeight); - - // scan the image from top to bottom - for (TInt i=0; iGetScanLine(curImgScanLinePtr, pt, currentScreenSize.iWidth, EColor256); - iPreviouslyCapturedBitmap->GetScanLine(prevImgScanLinePtr, pt, currentScreenSize.iWidth, EColor256); - - if (curImgScanLinePtr != prevImgScanLinePtr) - { - differenceFound = ETrue; - - // get the y-coordinate - leftTopDifferencePoint.iY = i; - - break; - } - } - - if (differenceFound) - { - // now we know that there is some difference between those two captured frames, - // get the bottom value by scaning from bottom to top - for (TInt i=currentScreenSize.iHeight-1; i>=0; i--) - { - pt.iY = i; - - currentCapturedBitmap->GetScanLine(curImgScanLinePtr, pt, currentScreenSize.iWidth, EColor256); - iPreviouslyCapturedBitmap->GetScanLine(prevImgScanLinePtr, pt, currentScreenSize.iWidth, EColor256); - - if (curImgScanLinePtr != prevImgScanLinePtr) - { - // get the y-coordinate - rightBottomDifferencePoint.iY = i+1; - - break; - } - } - - // check that the height of the cropped image will be at least 1 - if (rightBottomDifferencePoint.iY <= leftTopDifferencePoint.iY) - rightBottomDifferencePoint.iY = leftTopDifferencePoint.iY+1; - - - // get also the x-coordinates by scanning vertical scan lines - HBufC8* curImgVerticalScanLineBuf = HBufC8::NewLC(currentScreenSize.iHeight*3); - TPtr8 curImgVerticalScanLinePtr = curImgScanLineBuf->Des(); - HBufC8* prevImgVerticalScanLineBuf = HBufC8::NewLC(currentScreenSize.iHeight*3); - TPtr8 prevImgVerticalScanLinePtr = prevImgScanLineBuf->Des(); - - // first scan by from left to right - for (TInt i=0; iGetVerticalScanLine(curImgVerticalScanLinePtr, i, EColor256); - iPreviouslyCapturedBitmap->GetVerticalScanLine(prevImgVerticalScanLinePtr, i, EColor256); - - if (curImgVerticalScanLinePtr != prevImgVerticalScanLinePtr) - { - leftTopDifferencePoint.iX = i; - break; - } - } - - // finally scan from right to left - for (TInt i=currentScreenSize.iWidth-1; i>=0; i--) - { - currentCapturedBitmap->GetVerticalScanLine(curImgVerticalScanLinePtr, i, EColor256); - iPreviouslyCapturedBitmap->GetVerticalScanLine(prevImgVerticalScanLinePtr, i, EColor256); - - if (curImgVerticalScanLinePtr != prevImgVerticalScanLinePtr) - { - rightBottomDifferencePoint.iX = i+1; - break; - } - } - - CleanupStack::PopAndDestroy(2); //curImgVerticalScanLineBuf,prevImgVerticalScanLineBuf - - - // check that the width of the cropped image will be at least 1 - if (rightBottomDifferencePoint.iX <= leftTopDifferencePoint.iX) - rightBottomDifferencePoint.iX = leftTopDifferencePoint.iX+1; - - - // record dimensions and position of the image - frame.iWidth = rightBottomDifferencePoint.iX - leftTopDifferencePoint.iX; - frame.iHeight = rightBottomDifferencePoint.iY - leftTopDifferencePoint.iY; - frame.iXPos = leftTopDifferencePoint.iX; - frame.iYPos = leftTopDifferencePoint.iY; - frame.iEnableTransparency = ETrue; - frame.iFillsWholeScreen = EFalse; - - - // take a copy of the current frame - CFbsBitmap* workingBitmap = new(ELeave) CFbsBitmap; - CleanupStack::PushL(workingBitmap); - User::LeaveIfError( workingBitmap->Create(currentScreenSize, EColor256) ); - - HBufC8* tempScanLineBuf = HBufC8::NewLC(currentScreenSize.iWidth*3); - TPtr8 tempScanLinePtr = tempScanLineBuf->Des(); - - for (TInt i=0; iGetScanLine(tempScanLinePtr, pt, currentScreenSize.iWidth, EColor256); - workingBitmap->SetScanLine(tempScanLinePtr, i); - } - - CleanupStack::PopAndDestroy(); //tempScanLineBuf - - - // mark the non-changed areas with transparency color - TUint8* curPtr = NULL; - TUint8* prevPtr = NULL; - for (TInt i=frame.iYPos; iGetScanLine(curImgScanLinePtr, pt, currentScreenSize.iWidth, EColor256); - iPreviouslyCapturedBitmap->GetScanLine(prevImgScanLinePtr, pt, currentScreenSize.iWidth, EColor256); - - // check single pixels in the scanline - for (TInt j=frame.iXPos; jSetScanLine(curImgScanLinePtr, i); - } - - - // externalize the bitmap - TRect changedRect(leftTopDifferencePoint, rightBottomDifferencePoint); - workingBitmap->ExternalizeRectangleL(writeStream, changedRect); - - CleanupStack::PopAndDestroy(); //workingBitmap - - // update the previous frame to contain the new delay value - prevFrame.iDelay = TUint( (double) currentDelay / 10000 ); - } - - else - { - // frames are identical, we can just ignore this one - ignoreFrame = ETrue; - } - - CleanupStack::PopAndDestroy(2); //curImgScanLineBuf,prevImgScanLineBuf - - } // if (videoDimensionsHaveChanged) - - } //if (iCurrentFrameNumber == 0) - - // close the stream - writeStream.CommitL(); - writeStream.Close(); - file.Close(); - - - if (ignoreFrame) - { - // delete the temp file since we don't need that - iFileSession.Delete(frame.iFileStorePath); - } - else - { - // remember for the next frame when this frame was taken - iPreviousFrameTaken = timeNow; - - // take a copy of currentCapturedBitmap to iPreviouslyCapturedBitmap - User::LeaveIfError( iPreviouslyCapturedBitmap->Create(iVideoDimensions, EColor256) ); - - TPoint pt(0,0); - HBufC8* tempScanLineBuf = HBufC8::NewMaxLC(iVideoDimensions.iWidth); - TPtr8 tempScanLinePtr = tempScanLineBuf->Des(); - - for (TInt i=0; iGetScanLine(tempScanLinePtr, pt, iVideoDimensions.iWidth, EColor256); - iPreviouslyCapturedBitmap->SetScanLine(tempScanLinePtr, i); - } - - CleanupStack::PopAndDestroy(); //tempScanLineBuf - - // append frame information to the array - iVideoFrameArray->AppendL(frame); - - // remember screen size - iPreviousFrameScreenDimension = currentScreenSize; - } - - - CleanupStack::PopAndDestroy(); //currentCapturedBitmap - - - // set the state of the active object - iState = ENextVideoFrame; - - // check time spent on the work above (probably this is not so important) - TTime timeNow2; - timeNow2.HomeTime(); - TInt64 handlingDelay = timeNow2.MicroSecondsFrom(timeNow).Int64(); - - // calculate delay till next frame - TUint idealDelay = VIDEO_CAPTURE_DELAY*1000; - TInt usedDelay; - if (currentDelay > idealDelay) - usedDelay = idealDelay - (currentDelay - idealDelay) - handlingDelay; - else - usedDelay = idealDelay - handlingDelay; - - // check that the delay is atleast minimum delay anyway - if (usedDelay < VIDEO_CAPTURE_MINIMUM_DELAY*1000) - usedDelay = VIDEO_CAPTURE_MINIMUM_DELAY*1000; - - iTimer.After(iStatus, usedDelay); - - // indicate an outstanding request - SetActive(); - - SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- Captureframeforvideo end")); - - } - -// --------------------------------------------------------------------------- - -void SGEngine::SaveVideoL(TInt aErr) - { - - SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- SaveVideo start")); - - if (aErr) - CapturingFinishedL(aErr); - - else if (iGrabSettings.iVideoCaptureVideoFormat == EVideoFormatAnimatedGIF) - { - TInt err(KErrNone); - - - iSaveFileName.Copy( PathInfo::PhoneMemoryRootPath() ); - if (iGrabSettings.iVideoCaptureMemoryInUseMultiDrive != 0)//something different as PhoneMemory (memory card or mass memory) - { - if (PathInfo::GetRootPath(iSaveFileName,EDriveY) != KErrNone || !DriveOK(EDriveY)) - { - //we need to find first available memory card in EDriveE - EDriveY range - for (TInt i = EDriveY; i>=EDriveE; i--) - { - if ( DriveOK((TDriveNumber)(i))) - { - if (IsDriveMMC((TDriveNumber)(i))) - { - PathInfo::GetRootPath(iSaveFileName, (TDriveNumber)(i)); - break; - } - } - } - } - } - - - iSaveFileName.Append( PathInfo::ImagesPath() ); // animated gif is actually an image, not a video - iSaveFileName.Append( KScreenShotsSubDirectory ); - - // a quick check that filename is valid - if (iGrabSettings.iVideoCaptureFileName.Length() > 0 && iGrabSettings.iVideoCaptureFileName.Length() <= 255) - iSaveFileName.Append( iGrabSettings.iVideoCaptureFileName ); - else - iSaveFileName.Append( KDefaultVideoFileName ); - - iSaveFileName.Append( _L(".gif") ); - - CApaApplication::GenerateFileName(iFileSession, iSaveFileName ); // unique filename - - // create and save the gif animation - err = CGifAnimator::CreateGifAnimation(iSaveFileName, iVideoDimensions, iVideoFrameArray, *iEngineWrapper); - - // remove the saved file in case of errors since it's likely corrupted - if (err != KErrNone) - iFileSession.Delete(iSaveFileName); - - CapturingFinishedL(err); - } - - else - CapturingFinishedL(KErrNotSupported); - - SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- SaveVideo end")); - } -// --------------------------------------------------------------------------- - diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/creator.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/creator.pro Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,226 @@ +TEMPLATE = app +TARGET = Creator + +DEPENDPATH += . +DEPENDPATH += src engine/src +INCLUDEPATH += inc engine/inc + +load(hb.prf) +symbian:CONFIG -= symbian_i18n + +HEADERS += \ + inc/mainview.h \ + inc/notifications.h + +SOURCES += main.cpp \ + src/mainview.cpp \ + src/notifications.cpp + +symbian: { + INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE + HEADERS += engine/inc/creator.hrh \ + engine/inc/creator_calendar.h \ + engine/inc/creator_calendarbase.h \ + engine/inc/creator_calendarelement.h \ + engine/inc/creator_cmdscriptrun.h \ + engine/inc/creator_contactelement.h \ + engine/inc/creator_contactsetcache.h \ + engine/inc/creator_factory.h \ + engine/inc/creator_file.h \ + engine/inc/creator_fileelement.h \ + engine/inc/creator_landmark.h \ + engine/inc/creator_landmarkelement.h \ + engine/inc/creator_log.h \ + engine/inc/creator_logelement.h \ + engine/inc/creator_mailbox.h \ + engine/inc/creator_mailboxelement.h \ + engine/inc/creator_message.h \ + engine/inc/creator_messageelement.h \ + engine/inc/creator_modulebase.h \ + engine/inc/creator_note.h \ + engine/inc/creator_notepadwrapper.h \ + engine/inc/creator_phonebook.h \ + engine/inc/creator_phonebookwrapper.h \ + engine/inc/creator_phonebookapi.h \ + engine/inc/creator_phonebookbase.h \ + engine/inc/creator_randomdatafield.h \ + engine/inc/creator_randomdataparser.h \ + engine/inc/creator_scriptelement.h \ + engine/inc/creator_scriptelementfactory.h \ + engine/inc/creator_scriptentry.h \ + engine/inc/creator_scriptparser.h \ + engine/inc/creator_std.h \ + engine/inc/creator_traces.h \ + engine/inc/creator_wepsecuritysettings.h \ + engine/inc/randomdata.txt \ + inc/engine.h \ + inc/enginewrapper.h + + SOURCES += engine/src/creator_calendar.cpp \ + engine/src/creator_calendarelement.cpp \ + engine/src/creator_cmdscriptrun.cpp \ + engine/src/creator_contactelement.cpp \ + engine/src/creator_contactsetcache.cpp \ + engine/src/creator_factory.cpp \ + engine/src/creator_file.cpp \ + engine/src/creator_fileelement.cpp \ + engine/src/creator_landmark.cpp \ + engine/src/creator_landmarkelement.cpp \ + engine/src/creator_log.cpp \ + engine/src/creator_logelement.cpp \ + engine/src/creator_mailbox.cpp \ + engine/src/creator_mailboxelement.cpp \ + engine/src/creator_message.cpp \ + engine/src/creator_messageelement.cpp \ + engine/src/creator_note.cpp \ + engine/src/creator_notepadwrapper.cpp \ + engine/src/creator_phonebook.cpp \ + engine/src/creator_phonebookwrapper.cpp \ + engine/src/creator_phonebookapi.cpp \ + engine/src/creator_phonebookbase.cpp \ + engine/src/creator_randomdataparser.cpp \ + engine/src/creator_scriptelement.cpp \ + engine/src/creator_scriptelementfactory.cpp \ + engine/src/creator_scriptentry.cpp \ + engine/src/creator_scriptparser.cpp \ + src/engine.cpp \ + src/enginewrapper.cpp + + LIBS += -lestor \ + -lws32 \ + -lPlatformEnv \ + -limageconversion \ + -leikcore \ + -leuser \ + -lapparc \ + -lcone \ + -lcntmodel \ + -lmsgs \ + -llogwrap \ + -llogcli \ + -lefsrv \ + -lgsmu \ + -limcm \ + -lbafl \ + -leikcoctl \ + -leikctl \ + -lcommdb \ + -letext \ + -lcommonengine \ + -lcommonui \ + -lplatformenv \ + -lapgrfx \ + -lapmime \ + -lobexmtmutil \ + -lsmcm \ + -laknskins \ + -laknskinsrv \ + -lflogger \ + -letel \ + -letelmm \ + -lxmlframework \ + -lcharconv \ + -lsenutils \ + -lcalinterimapi \ + -leposlandmarks \ + -llbs \ + -lecom \ + -lcaf \ + -lcafutils \ + -ldrmrights \ + -ledbms \ + -lfbscli \ + -lbitmaptransforms \ + -lcmmanager \ + -lcmmanagerdatabase \ + -lnoteseditor \ + -lxqservice \ + -lQtContacts \ + -lagendainterface + + creatorDataBlock = \ + "SOURCEPATH ." \ + "START RESOURCE data/datacreator.rss" \ + "HEADER" \ + "TARGETPATH /resource/apps" \ + "END" + + MMP_RULES += creatorDataBlock + MMP_RULES -= PAGED + MMP_RULES *= UNPAGEDDATA + MMP_RULES += SMPSAFE + + BLD_INF_RULES.prj_exports += "./rom/creator.iby CORE_IBY_EXPORT_PATH(tools,creator.iby) + BLD_INF_RULES.prj_exports += \ + "./files/backup_registration.xml Z:/private/20011383/backup_registration.xml" \ + "./files/3GPP-70kB.dat Z:/private/20011383/3GPP-70kB.3gpp" \ + "./files/AAC-100kB.dat Z:/private/20011383/AAC-100kB.aac" \ + "./files/AMR-20kB.dat Z:/private/20011383/AMR-20kB.amr" \ + "./files/BMP-25kB.dat Z:/private/20011383/BMP-25kB.bmp" \ + "./files/Deck-1kB.dat Z:/private/20011383/Deck-1kB.saveddeck" \ + "./files/DOC-20kB.dat Z:/private/20011383/DOC-20kB.doc" \ + "./files/GIF-2kB.dat Z:/private/20011383/GIF-2kB.gif" \ + "./files/HTML-20kB.dat Z:/private/20011383/HTML-20kB.html" \ + "./files/JAD-1kB.dat Z:/private/20011383/JAD-1kB.jad" \ + "./files/JAR-10kB.dat Z:/private/20011383/JAR-10kB.jar" \ + "./files/JP2-65kB.dat Z:/private/20011383/JP2-65kB.jp2" \ + "./files/JPEG-200kB.dat Z:/private/20011383/JPEG-200kB.jpg" \ + "./files/JPEG-25kB.dat Z:/private/20011383/JPEG-25kB.jpg" \ + "./files/JPEG-500kB.dat Z:/private/20011383/JPEG-500kB.jpg" \ + "./files/MIDI-10kB.dat Z:/private/20011383/MIDI-10kB.mid" \ + "./files/MP3-250kB.dat Z:/private/20011383/MP3-250kB.mp3" \ + "./files/MP4-200kB.dat Z:/private/20011383/MP4-200kB.mp4" \ + "./files/MXMF-40kB.dat Z:/private/20011383/MXMF-40kB.mxmf" \ + "./files/PNG-15kB.dat Z:/private/20011383/PNG-15kB.png" \ + "./files/PPT-40kB.dat Z:/private/20011383/PPT-40kB.ppt" \ + "./files/RAM-1kB.dat Z:/private/20011383/RAM-1kB.ram" \ + "./files/RM-95kB.dat Z:/private/20011383/RM-95kB.rm" \ + "./files/RNG-1kB.dat Z:/private/20011383/RNG-1kB.rng" \ + "./files/SVG-15kB.dat Z:/private/20011383/SVG-15kB.svg" \ + "./files/SWF-15kB.dat Z:/private/20011383/SWF-15kB.swf" \ + "./files/TIF-25kB.dat Z:/private/20011383/TIF-25kB.tif" \ + "./files/TXT-10kB.dat Z:/private/20011383/TXT-10kB.txt" \ + "./files/TXT-70kB.dat Z:/private/20011383/TXT-70kB.txt" \ + "./files/VCF-1kB.dat Z:/private/20011383/VCF-1kB.vcf" \ + "./files/VCS-1kB.dat Z:/private/20011383/VCS-1kB.vcs" \ + "./files/WAV-20kB.dat Z:/private/20011383/WAV-20kB.wav" \ + "./files/XLS-15kB.dat Z:/private/20011383/XLS-15kB.xls" \ + "./files/SISX-10kB.dat Z:/private/20011383/SISX-10kB.sisx" \ + "./files/WMA-50kB.dat Z:/private/20011383/WMA-50kB.wma" \ + "./files/WMV-200kB.dat Z:/private/20011383/WMV-200kB.wmv" \ + "./scripts/creator.xsd +/tools/s60rndtools/creator/creator.xsd" \ + "./scripts/browserEx.creatorxml +/tools/s60rndtools/creator/browserEx.creatorxml" \ + "./scripts/calendarEx.creatorxml +/tools/s60rndtools/creator/calendarEx.creatorxml" \ + "./scripts/connectionmethodEx.creatorxml +/tools/s60rndtools/creator/connectionmethodEx.creatorxml" \ + "./scripts/contactEx.creatorxml +/tools/s60rndtools/creator/contactEx.creatorxml" \ + "./scripts/filesEx.creatorxml +/tools/s60rndtools/creator/filesEx.creatorxml" \ + "./scripts/landmarkEx.creatorxml +/tools/s60rndtools/creator/landmarkEx.creatorxml" \ + "./scripts/logEx.creatorxml +/tools/s60rndtools/creator/logEx.creatorxml" \ + "./scripts/mailboxEx.creatorxml +/tools/s60rndtools/creator/mailboxEx.creatorxml" \ + "./scripts/messagesEx.creatorxml +/tools/s60rndtools/creator/messagesEx.creatorxml" \ + "./scripts/notepadEx.creatorxml +/tools/s60rndtools/creator/notepadEx.creatorxml" + + creator_buildstubsis_extension = \ + "$${LITERAL_HASH}ifdef MARM" \ + " START EXTENSION app-services/buildstubsis" \ + " OPTION SRCDIR sis" \ + " OPTION SISNAME creator_stub" \ + " END" \ + "$${LITERAL_HASH}endif" + + BLD_INF_RULES.prj_extensions += creator_buildstubsis_extension + + RSS_RULES += "group_name = \"RnD Tools\""; + TARGET.CAPABILITY = CAP_APPLICATION AllFiles + + TARGET.UID2 = 0x100039CE + TARGET.UID3 = 0x20011383 + TARGET.SID = 0x20011383 + TARGET.VID = 0x101FB657 // Nokia + TARGET.EPOCHEAPSIZE = 0x20000 0x1000000 // Min 128Kb, Max 16Mb + + ICON = icons/Creator_application_icon_svgt.svg + +} else { + error("Only Symbian supported!") +} diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/data/datacreator.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/data/datacreator.rss Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,665 @@ +NAME ORBT + +#include +#include +#include + +RESOURCE RSS_SIGNATURE { } + +RESOURCE ARRAY r_data_firstnames + { + items= + { + LBUF { txt="John"; }, + LBUF { txt="Francis"; }, + LBUF { txt="Andrew"; }, + LBUF { txt="Lawrence"; }, + LBUF { txt="Gregory"; }, + LBUF { txt="Fulke"; }, + LBUF { txt="Thomas"; }, + LBUF { txt="Nicholas"; }, + LBUF { txt="Hakle"; }, + LBUF { txt="Roger"; }, + LBUF { txt="Nathaniel"; }, + LBUF { txt="Luke"; }, + LBUF { txt="William"; }, + LBUF { txt="Ralph"; }, + LBUF { txt="Leonar"; }, + LBUF { txt="Daniel"; }, + LBUF { txt="Aban"; }, + LBUF { txt="Mathias"; }, + LBUF { txt="Robert"; }, + LBUF { txt="Christopher"; }, + LBUF { txt="Martin"; }, + LBUF { txt="Michael"; }, + LBUF { txt="Barnaby"; }, + LBUF { txt="Tobias"; }, + LBUF { txt="Richard"; }, + LBUF { txt="Anthony"; }, + LBUF { txt="Simon"; }, + LBUF { txt="Samuel"; }, + LBUF { txt="Geoffrey"; }, + LBUF { txt="Isaac"; }, + LBUF { txt="Henry"; }, + LBUF { txt="Matthew"; }, + LBUF { txt="Peter"; }, + LBUF { txt="Allen"; }, + LBUF { txt="Reynold"; }, + LBUF { txt="Jerome"; }, + LBUF { txt="Elizabeth"; }, + LBUF { txt="Catherine"; }, + LBUF { txt="Frances"; }, + LBUF { txt="Cecily"; }, + LBUF { txt="Millicent"; }, + LBUF { txt="Audrey"; }, + LBUF { txt="Joan"; }, + LBUF { txt="Elinor"; }, + LBUF { txt="Joyce"; }, + LBUF { txt="Frideswide"; }, + LBUF { txt="Rose"; }, + LBUF { txt="Helen"; }, + LBUF { txt="Margaret"; }, + LBUF { txt="Isabel"; }, + LBUF { txt="Bridget"; }, + LBUF { txt="Grace"; }, + LBUF { txt="Thomasin"; }, + LBUF { txt="Janet"; }, + LBUF { txt="Agnes"; }, + LBUF { txt="Dorothy"; }, + LBUF { txt="Christian"; }, + LBUF { txt="Amy"; }, + LBUF { txt="Fortune"; }, + LBUF { txt="Sybil"; }, + LBUF { txt="Alice"; }, + LBUF { txt="Margery"; }, + LBUF { txt="Edith"; }, + LBUF { txt="Barbara"; }, + LBUF { txt="Gillian"; }, + LBUF { txt="Ursula"; } + }; + } + +RESOURCE ARRAY r_data_surnames + { + items= + { + LBUF { txt="Lux"; }, + LBUF { txt="Mandot"; }, + LBUF { txt="Mansfield"; }, + LBUF { txt="Mayberry"; }, + LBUF { txt="McCarrel"; }, + LBUF { txt="McDaniel"; }, + LBUF { txt="Mefford"; }, + LBUF { txt="Metcalf"; }, + LBUF { txt="Metchell"; }, + LBUF { txt="Moller"; }, + LBUF { txt="Margan"; }, + LBUF { txt="Keaney"; }, + LBUF { txt="Kenyon"; }, + LBUF { txt="Kesler"; }, + LBUF { txt="Kinman"; }, + LBUF { txt="Kreinert"; }, + LBUF { txt="Kummerlin"; }, + LBUF { txt="Lamgley"; }, + LBUF { txt="Leas"; }, + LBUF { txt="Leighton"; }, + LBUF { txt="Lillie"; }, + LBUF { txt="Hilms"; }, + LBUF { txt="Holt"; }, + LBUF { txt="Hosier"; }, + LBUF { txt="Howard"; }, + LBUF { txt="Hypes"; }, + LBUF { txt="Jacmor"; }, + LBUF { txt="Behnson"; }, + LBUF { txt="Kammer"; }, + LBUF { txt="Patts"; }, + LBUF { txt="West"; }, + LBUF { txt="Wilbar"; }, + LBUF { txt="Witsan"; }, + LBUF { txt="Gillams"; }, + LBUF { txt="Good"; }, + LBUF { txt="Wreght"; }, + LBUF { txt="Worthley"; }, + LBUF { txt="Adams"; }, + LBUF { txt="Allen"; }, + LBUF { txt="Ansley"; }, + LBUF { txt="Ayries"; }, + LBUF { txt="Bartlett"; }, + LBUF { txt="Barton"; }, + LBUF { txt="Payne"; }, + LBUF { txt="Pintard"; }, + LBUF { txt="Prence"; }, + LBUF { txt="Richards"; }, + LBUF { txt="Dillman"; }, + LBUF { txt="Dory"; }, + LBUF { txt="Edgards"; }, + LBUF { txt="Engell"; }, + LBUF { txt="Farprington"; }, + LBUF { txt="Fisher"; }, + LBUF { txt="Foed"; }, + LBUF { txt="Burges"; }, + LBUF { txt="Childwall"; }, + LBUF { txt="Smith"; }, + LBUF { txt="Sipon"; }, + LBUF { txt="Simmons"; }, + LBUF { txt="Stewert"; }, + LBUF { txt="Stiles"; }, + LBUF { txt="Stratton"; }, + LBUF { txt="Dennis"; }, + LBUF { txt="Talmot"; } + }; + } + +RESOURCE ARRAY r_data_companies + { + items= + { + LBUF { txt="CDP"; }, + LBUF { txt="Exbox"; }, + LBUF { txt="Munro"; }, + LBUF { txt="Majaka"; }, + LBUF { txt="Bitzumi"; }, + LBUF { txt="Melroy"; }, + LBUF { txt="Matal"; }, + LBUF { txt="Japponi"; }, + LBUF { txt="Siwaka"; }, + LBUF { txt="Keiku"; }, + LBUF { txt="Naamate"; }, + LBUF { txt="Remonti"; }, + LBUF { txt="Melleva"; }, + LBUF { txt="WEX"; }, + LBUF { txt="Chataz"; }, + LBUF { txt="Ponly"; }, + LBUF { txt="Alriva"; }, + LBUF { txt="Giate"; }, + LBUF { txt="Kesso"; }, + LBUF { txt="Nyssa"; }, + LBUF { txt="Peger"; }, + LBUF { txt="Metrio"; }, + LBUF { txt="Mitchitatchi"; }, + LBUF { txt="Neppari"; }, + LBUF { txt="Amcuila"; }, + LBUF { txt="Muipitsu"; }, + LBUF { txt="Redex"; }, + LBUF { txt="Maariz"; }, + LBUF { txt="Swerck"; }, + LBUF { txt="Makiac"; }, + LBUF { txt="Dumpia"; }, + LBUF { txt="Worldmom"; }, + LBUF { txt="Renfaul"; }, + LBUF { txt="Kmartissori"; }, + LBUF { txt="Findo"; }, + LBUF { txt="Samsanc"; }, + LBUF { txt="Dellervo"; }, + LBUF { txt="Manrel"; }, + LBUF { txt="WSMRL"; }, + LBUF { txt="Eripox"; }, + LBUF { txt="Abiturien"; }, + LBUF { txt="Vesus"; }, + LBUF { txt="MI4"; }, + LBUF { txt="Overhiba"; }, + LBUF { txt="Tridune"; }, + LBUF { txt="Kyomcera"; }, + LBUF { txt="Praston"; }, + LBUF { txt="Gapmis"; }, + LBUF { txt="WPPDCD"; } + }; + } + +RESOURCE ARRAY r_data_addresses + { + items= + { + LBUF { txt="Barnes Street"; }, + LBUF { txt="Barnes Place"; }, + LBUF { txt="Eastman Street"; }, + LBUF { txt="West Park"; }, + LBUF { txt="South Park"; }, + LBUF { txt="Park Avenue"; }, + LBUF { txt="Richards Court"; }, + LBUF { txt="Pukershire Avenue"; }, + LBUF { txt="Ellis Avenue"; }, + LBUF { txt="East Mountain"; }, + LBUF { txt="Chestnut Hill"; }, + LBUF { txt="Plains Road"; }, + LBUF { txt="Fremont Street"; }, + LBUF { txt="Heritage Court"; }, + LBUF { txt="Highland Avenue Extension"; }, + LBUF { txt="Maple Heights"; }, + LBUF { txt="McKenzie Avenue"; }, + LBUF { txt="McKenzie Lane"; }, + LBUF { txt="West Terrace Street"; }, + LBUF { txt="Windsor Avenue"; }, + LBUF { txt="Windsor Road"; }, + LBUF { txt="Mechanic Street Extension"; }, + LBUF { txt="Granite Place"; }, + LBUF { txt="Meadow Street"; }, + LBUF { txt="Sugar River"; } + }; + } + +RESOURCE ARRAY r_data_cities + { + items= + { + LBUF { txt="Kuopio"; }, + LBUF { txt="Los Angeles"; }, + LBUF { txt="Lappeenranta"; }, + LBUF { txt="London"; }, + LBUF { txt="Bangkok"; }, + LBUF { txt="St. Michel"; }, + LBUF { txt="St. Petersburg"; }, + LBUF { txt="Tokyo"; }, + LBUF { txt="Helsinki"; }, + LBUF { txt="Trondheim"; }, + LBUF { txt="Nairobi"; }, + LBUF { txt="Havana"; } + }; + } + +RESOURCE ARRAY r_data_countries + { + items= + { + LBUF { txt="Finland"; }, + LBUF { txt="Cuba"; }, + LBUF { txt="United States of America"; }, + LBUF { txt="Thailand"; }, + LBUF { txt="Sweden"; }, + LBUF { txt="Russia"; }, + LBUF { txt="Japan"; }, + LBUF { txt="Norway"; }, + LBUF { txt="Kenya"; } + }; + } + +RESOURCE ARRAY r_data_postcodes + { + items= + { + LBUF { txt="00310"; }, + LBUF { txt="FI-70100"; }, + LBUF { txt="99002"; }, + LBUF { txt="11233"; } + }; + } + +RESOURCE ARRAY r_data_states + { + items= + { + LBUF { txt="California state"; }, + LBUF { txt="Alaska state"; }, + LBUF { txt="Florida state"; } + }; + } + +RESOURCE ARRAY r_data_poboxes + { + items= + { + LBUF { txt="P.O BOX 5532"; }, + LBUF { txt="P.O BOX 701"; }, + LBUF { txt="99"; }, + LBUF { txt="1133"; }, + LBUF { txt="P.O. BOX 113322"; }, + LBUF { txt="112"; } + }; + } + +RESOURCE ARRAY r_data_prefixes + { + items= + { + LBUF { txt="Ms."; }, + LBUF { txt="Mrs."; }, + LBUF { txt="Mr."; }, + LBUF { txt="Dr."; } + + }; + } + +RESOURCE ARRAY r_data_suffixes + { + items= + { + LBUF { txt="Jr."; }, + LBUF { txt="Sr."; } + }; + } + +RESOURCE ARRAY r_data_jobtitles + { + items= + { + LBUF { txt="Doctor"; }, + LBUF { txt="SW Engineer"; }, + LBUF { txt="Administrative Assistant"; }, + LBUF { txt="Bookkeeper"; }, + LBUF { txt="Credit Controller"; }, + LBUF { txt="Data Entry Operator"; }, + LBUF { txt="Payroll Officer"; }, + LBUF { txt="Receptionist"; }, + LBUF { txt="Trainee"; }, + LBUF { txt="Accounts Clerk"; }, + LBUF { txt="Administrator"; }, + LBUF { txt="Taxation Assistant"; }, + LBUF { txt="Financial Director"; }, + LBUF { txt="Bank Manager"; }, + LBUF { txt="Mobile Lending"; }, + LBUF { txt="Overseas Transactions"; }, + LBUF { txt="Restructuring"; }, + LBUF { txt="Business Analyst"; }, + LBUF { txt="Call Centre Manager"; }, + LBUF { txt="Administration"; }, + LBUF { txt="Manager"; }, + LBUF { txt="Student"; }, + LBUF { txt="Mail Sorter"; }, + LBUF { txt="Mayor"; }, + LBUF { txt="Account Servicing"; }, + LBUF { txt="Management"; }, + LBUF { txt="Media Consultant"; }, + LBUF { txt="Newsagent"; }, + LBUF { txt="Librarian"; }, + LBUF { txt="Creative Director"; }, + LBUF { txt="Announcer"; }, + LBUF { txt="Copywriter"; }, + LBUF { txt="Presenter"; }, + LBUF { txt="Promotions Manager"; }, + LBUF { txt="Advertising Sales Representative"; }, + LBUF { txt="Editor"; }, + LBUF { txt="Marketing, Sales & Publicity"; }, + LBUF { txt="Publisher"; }, + LBUF { txt="Gallery Assistant"; }, + LBUF { txt="Photographer"; }, + LBUF { txt="Storyboard Artist"; }, + LBUF { txt="Events Manager"; }, + LBUF { txt="Cameraman"; }, + LBUF { txt="Technician"; }, + LBUF { txt="Producer"; } + }; + } + +RESOURCE ARRAY r_data_phonenumbers + { + items= + { + LBUF { txt="0307834387"; }, + LBUF { txt="0230328732"; }, + LBUF { txt="0430365562"; }, + LBUF { txt="0530328732"; }, + LBUF { txt="0433032865"; }, + LBUF { txt="0542306532"; }, + LBUF { txt="0342303777"; }, + LBUF { txt="0250235603"; }, + LBUF { txt="0492303652"; }, + LBUF { txt="0542303286"; }, + LBUF { txt="0543656546"; }, + LBUF { txt="0545545454"; }, + LBUF { txt="0543444454"; }, + LBUF { txt="0776463255"; }, + LBUF { txt="0432443343"; }, + LBUF { txt="0243334344"; }, + LBUF { txt="0544543443"; }, + LBUF { txt="0231343243"; }, + LBUF { txt="0213443434"; }, + LBUF { txt="0143234476"; }, + LBUF { txt="0785434444"; }, + LBUF { txt="0454445345"; }, + LBUF { txt="0342443433"; }, + LBUF { txt="0432434454"; }, + LBUF { txt="0455454454"; }, + LBUF { txt="0656565655"; }, + LBUF { txt="0343434443"; }, + LBUF { txt="0565645455"; }, + LBUF { txt="0343243243"; }, + LBUF { txt="0565466565"; }, + LBUF { txt="0465565655"; }, + LBUF { txt="0435445454"; }, + LBUF { txt="+35854553456"; }, + LBUF { txt="+35878453486"; }, + LBUF { txt="+35876653456"; }, + LBUF { txt="+35834435486"; }, + LBUF { txt="+35876766466"; }, + LBUF { txt="+4465665456"; }, + LBUF { txt="+4432434334"; }, + LBUF { txt="+4488776776"; }, + LBUF { txt="+4465655656"; }, + LBUF { txt="+4443433434"; }, + LBUF { txt="+4465656565"; }, + LBUF { txt="+4454454354"; } + }; + } + +RESOURCE ARRAY r_data_groupnames + { + items= + { + LBUF { txt="Nice guys"; }, + LBUF { txt="Repairs"; }, + LBUF { txt="Office works"; }, + LBUF { txt="The buddies"; }, + LBUF { txt="Football team"; }, + LBUF { txt="Gold club"; }, + LBUF { txt="Silver club"; }, + LBUF { txt="Bronze club"; }, + LBUF { txt="Best buddies"; }, + LBUF { txt="Rockers"; }, + LBUF { txt="Science group"; } + }; + } + +RESOURCE ARRAY r_data_meetingreasons + { + items= + { + LBUF { txt="Security issues"; }, + LBUF { txt="Team meeting"; }, + LBUF { txt="Discussion about"; }, + LBUF { txt="Work plans"; }, + LBUF { txt="Meeting with the professor"; }, + LBUF { txt="Meeting with the boss"; }, + LBUF { txt="Work issues"; }, + LBUF { txt="New workers"; } + }; + } + +RESOURCE ARRAY r_data_meetingplaces + { + items= + { + LBUF { txt="Room"; }, + LBUF { txt="Home"; }, + LBUF { txt="Auditorium"; }, + LBUF { txt="Company"; } + }; + } + +RESOURCE ARRAY r_data_landmark_names + { + items= + { + LBUF { txt="Good place to fish";}, + LBUF { txt="Uncle over board";}, + LBUF { txt="Best food ever!";}, + LBUF { txt="Nice beach";}, + LBUF { txt="Good hamburgers";}, + LBUF { txt="Nice view";}, + LBUF { txt="John's home";}, + LBUF { txt="Carage";}, + LBUF { txt="Gas station";}, + LBUF { txt="Food store";}, + LBUF { txt="Car wash";}, + LBUF { txt="Summer cottage";}, + LBUF { txt="My home";}, + LBUF { txt="Bank";}, + LBUF { txt="Hospital";}, + LBUF { txt="Ice hall";}, + LBUF { txt="Work place";} + }; + } + +RESOURCE ARRAY r_data_landmark_descriptions + { + items= + { + LBUF { txt="The salmons were really big here!";}, + LBUF { txt="Delicious strawberries sold here. Must visit again sometime!";}, + LBUF { txt="Place looks really nice.";}, + LBUF { txt="This is my favorite place";}, + LBUF { txt="Words are not enough to describe this landmark";}, + LBUF { txt="What a shocking place to visit! Remember to bring camera next time :-)";} + }; + } + +RESOURCE ARRAY r_data_memos + { + items= + { + LBUF { txt="No work today!"; }, + LBUF { txt="Movies tonight"; }, + LBUF { txt="Ship new binaries"; }, + LBUF { txt="New works"; }, + LBUF { txt="Exam"; }, + LBUF { txt="Community service"; }, + LBUF { txt="Volunteer work"; }, + LBUF { txt="Don't forget the dinner at the restaurant"; }, + LBUF { txt="Go the bank"; }, + LBUF { txt="Go to the store"; }, + LBUF { txt="Buy goods"; }, + LBUF { txt="Buy food"; }, + LBUF { txt="Buy new pair of socks"; }, + LBUF { txt="Buy vegetables"; }, + LBUF { txt="Buy fruits"; }, + LBUF { txt="Umbrella"; }, + LBUF { txt="New shoes"; }, + LBUF { txt="New suit"; }, + LBUF { txt="Buy flowers"; }, + LBUF { txt="School day"; } + }; + } +RESOURCE ARRAY r_data_anniversaries + { + items= + { + LBUF { txt="birthday"; }, + LBUF { txt="anniversary"; } + }; + } + +RESOURCE ARRAY r_data_todos + { + items= + { + LBUF { txt="Watch for gum on my shoe"; }, + LBUF { txt="Watch my step in the hall"; }, + LBUF { txt="Always think big"; }, + LBUF { txt="Don't ever think small"; }, + LBUF { txt="Keep pedaling my bike"; }, + LBUF { txt="Watch for bees in my pop"; }, + LBUF { txt="Keep moving forward"; }, + LBUF { txt="Don't ever stop"; }, + LBUF { txt="Keep my sled underneath me"; }, + LBUF { txt="Keep my stick on the ice"; }, + LBUF { txt="Don't swim in a whirlpool"; }, + LBUF { txt="Don't look for a fight"; }, + LBUF { txt="Don't spit in the wind"; }, + LBUF { txt="Just do what is right"; }, + LBUF { txt="Go out in the world"; }, + LBUF { txt="Enjoy a warm rain"; }, + LBUF { txt="Don't worship TV"; }, + LBUF { txt="Keep my oars in the water"; }, + LBUF { txt="Point my boat right downstream"; }, + LBUF { txt="Face head on my problems"; }, + LBUF { txt="Change underwear daily"; }, + LBUF { txt="Believe myself first"; }, + LBUF { txt="Go out and have fun"; }, + LBUF { txt="Turn the cards one by one"; }, + LBUF { txt="Get out and do something"; } + }; + } + +RESOURCE ARRAY r_data_reminders + { + items= + { + LBUF { txt="Remeber to fix car"; }, + LBUF { txt="Remeber to eat vegetables"; }, + LBUF { txt="Remeber to go shopping"; }, + LBUF { txt="Remeber to buy boxes for moving"; }, + LBUF { txt="Remeber to fix bike"; }, + LBUF { txt="Remeber to buy christmast presents"; }, + LBUF { txt="Remeber to send flowers to grandmother"; }, + LBUF { txt="Remeber to talk with son"; }, + LBUF { txt="Remeber to cut hedge"; }, + LBUF { txt="Remeber to bumper potatoes"; }, + LBUF { txt="Remeber to harvest corn field"; }, + LBUF { txt="Remeber to sleep enaugh"; }, + LBUF { txt="Remeber to wash teeths ewery morning"; }, + LBUF { txt="Remeber to get sleep early"; }, + LBUF { txt="Remeber to give some wather to flowers"; }, + LBUF { txt="Remeber to wax snowboard"; }, + LBUF { txt="Remeber to wax skiis"; }, + LBUF { txt="Remeber to wax cross country skiis"; }, + LBUF { txt="Remeber to call mother"; }, + LBUF { txt="Remeber to call father"; }, + LBUF { txt="Remeber to call brother"; }, + LBUF { txt="Remeber to call sister"; }, + LBUF { txt="Remeber to call daughter"; }, + LBUF { txt="Remeber to call son"; }, + LBUF { txt="Remeber to rent villa"; } + }; + } + +RESOURCE ARRAY r_data_messagesubjects + { + items= + { + LBUF { txt="Whaaasssaaap!!??"; }, + LBUF { txt="Hello"; }, + LBUF { txt="How are you doing?"; }, + LBUF { txt="You will win the battle, GUARANTEED!"; }, + LBUF { txt="Why pay more for something if you don't have to?"; }, + LBUF { txt="You can afford health care now"; }, + LBUF { txt="Re: *Buddy* *Lists*!!~ (it's soooo cool)!!~"; }, + LBUF { txt="Weedmon say: call, we be open 7 days, mon"; }, + LBUF { txt="Want her to look better?"; }, + LBUF { txt="Good Morning andyw, how are you?"; }, + LBUF { txt="Happy Assumption"; }, + LBUF { txt="There is NO Risk involved"; }, + LBUF { txt="Free Bottle Offer!"; }, + LBUF { txt="Introduction on MDSL"; }, + LBUF { txt="Theres Help out there for you"; }, + LBUF { txt="hello there - check this out"; }, + LBUF { txt="Darling"; }, + LBUF { txt="It doesn't have to be that way"; }, + LBUF { txt="Webmaster, Free health insurance quotes!"; }, + LBUF { txt="Join us at the OSGi 2003 World Congress"; }, + LBUF { txt="Put your subject line here"; }, + LBUF { txt="You are not protected"; }, + LBUF { txt="Please try again"; }, + LBUF { txt="you didn't reply my email ? why ? ???"; }, + LBUF { txt="A very funny game"; }, + LBUF { txt="Meeting notice"; }, + LBUF { txt="Opportunities"; } + }; + } + +RESOURCE ARRAY r_data_messagetexts + { + items= + { + LBUF { txt="The contents of these pages are copyrighted. Any rights not expressly granted herein are reserved. The use of this site is permitted to private use."; }, + LBUF { txt="Reproduction, transfer, distribution or storage of part or all of the contents in any form without the prior written permission is prohibited."; }, + LBUF { txt="We consents to you browsing the pages on your computer or printing copies of extracts from these pages for your personal use only."; }, + LBUF { txt="If you place an order for a product, request a service or submit content to this site, we may need to contact you for additional information."; }, + LBUF { txt="The use of press releases and other documents classified as public is permitted in public communications if the source for the information has been stated."; }, + LBUF { txt="For your easy accessibility we may include links to sites on the Internet that are owned or operated by third parties."; }, + LBUF { txt="You also agree that we have no control over the content of that site and cannot assume any responsibility for material by such third-party sites."; }, + LBUF { txt="In addition, a link to a such site does not imply that we endorses the site or the products or services referenced in such third party site."; }, + LBUF { txt="In order to respond to your questions or manage interactive customer programs, it may be necessary to ask for personal information."; }, + LBUF { txt="We may use this information to respond to your requests, or to contact you via mail, e-mail or phone to inform you of new products."; }, + LBUF { txt="If you place an order for a product, request a service or submit content to this site, we may need to contact you for additional information."; } + }; + } + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/inc/creator.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/inc/creator.hrh Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,180 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef __CREATOR_HRH__ +#define __CREATOR_HRH__ + + +enum TCreatorIds + { + + // Phonebook entries shuld be the first, bacause some other entries references them + ECmdCreatePhoneBookEntries = 1, + ECmdCreatePhoneBookEntryContacts, + ECmdCreatePhoneBookEntryGroups, + ECmdCreatePhoneBookEntrySubscribedContacts, + + ECmdCreateFromFile, + + ECmdCreateCalendarEntries, + ECmdCreateCalendarEntryAppointments, + ECmdCreateCalendarEntryEvents, + ECmdCreateCalendarEntryAnniversaries, + ECmdCreateCalendarEntryToDos, + ECmdCreateCalendarEntryReminders, + + ECmdCreateBrowserEntries, + ECmdCreateBrowserBookmarkEntries, + ECmdCreateBrowserBookmarkFolderEntries, + ECmdCreateBrowserSavedPageEntries, + ECmdCreateBrowserSavedPageFolderEntries, + + ECmdCreateFileEntries, + ECmdCreateFileEntryEmptyFolder, + + ECmdCreateFileEntry3GPP_70kB, + ECmdCreateFileEntryAAC_100kB, + ECmdCreateFileEntryAMR_20kB, + ECmdCreateFileEntryBMP_25kB, + ECmdCreateFileEntryDeck_1kB, + ECmdCreateFileEntryDOC_20kB, + ECmdCreateFileEntryGIF_2kB, + ECmdCreateFileEntryHTML_20kB, + ECmdCreateFileEntryJAD_1kB, + ECmdCreateFileEntryJAR_10kB, + ECmdCreateFileEntryJP2_65kB, + ECmdCreateFileEntryJPEG_200kB, + ECmdCreateFileEntryJPEG_25kB, + ECmdCreateFileEntryJPEG_500kB, + ECmdCreateFileEntryMIDI_10kB, + ECmdCreateFileEntryMP3_250kB, + ECmdCreateFileEntryMP4_200kB, + ECmdCreateFileEntryMXMF_40kB, + ECmdCreateFileEntryPNG_15kB, + ECmdCreateFileEntryPPT_40kB, + ECmdCreateFileEntryRAM_1kB, + ECmdCreateFileEntryRM_95kB, + ECmdCreateFileEntryRNG_1kB, + ECmdCreateFileEntrySVG_15kB, + ECmdCreateFileEntrySWF_15kB, + ECmdCreateFileEntryTIF_25kB, + ECmdCreateFileEntryTXT_10kB, + ECmdCreateFileEntryTXT_70kB, + ECmdCreateFileEntryVCF_1kB, + ECmdCreateFileEntryVCS_1kB, + ECmdCreateFileEntryWAV_20kB, + ECmdCreateFileEntryXLS_15kB, + ECmdCreateFileEntrySISX_10kB, + ECmdCreateFileEntryWMA_50kB, + ECmdCreateFileEntryWMV_200kB, + + ECmdCreateLogEntries, + ECmdCreateLogEntryMissedCalls, + ECmdCreateLogEntryReceivedCalls, + ECmdCreateLogEntryDialledNumbers, + + ECmdCreateMessagingEntries, + ECmdCreateMessagingEntryCBSTopics, + ECmdCreateMessagingEntryDocumentsFolders, + ECmdCreateMessagingEntrySMSMessageCenters, + ECmdCreateMessagingEntryMailboxes, + ECmdCreateMessagingEntryMessages, + ECmdCreateMessagingEntryMessagesViaScript, + ECmdCreateMessagingEntryTemplates, + + ECmdCreateRandomEntrySMSInbox, + ECmdCreateRandomEntrySMSDrafts, + ECmdCreateRandomEntrySMSOutbox, + ECmdCreateRandomEntrySMSSent, + ECmdCreateRandomEntryMMSInbox, + ECmdCreateRandomEntryMMSDrafts, + ECmdCreateRandomEntryMMSOutbox, + ECmdCreateRandomEntryMMSSent, + ECmdCreateRandomEntryAMSInbox, + ECmdCreateRandomEntryAMSDrafts, + ECmdCreateRandomEntryAMSOutbox, + ECmdCreateRandomEntryAMSSent, + ECmdCreateRandomEntryEmailInbox, + ECmdCreateRandomEntryEmailDrafts, + ECmdCreateRandomEntryEmailOutbox, + ECmdCreateRandomEntryEmailSent, + ECmdCreateRandomEntryBIOInbox, + ECmdCreateRandomEntryBIODrafts, + ECmdCreateRandomEntryBIOOutbox, + ECmdCreateRandomEntryBIOSent, + ECmdCreateRandomEntryIRInbox, + ECmdCreateRandomEntryIRDrafts, + ECmdCreateRandomEntryIROutbox, + ECmdCreateRandomEntryIRSent, + ECmdCreateRandomEntryBTInbox, + ECmdCreateRandomEntryBTDrafts, + ECmdCreateRandomEntryBTOutbox, + ECmdCreateRandomEntryBTSent, + + ECmdCreateMiscEntries, + ECmdCreateMiscEntryAccessPoints, + ECmdCreateMiscEntryAppMenuFolders, + ECmdCreateMiscEntryIMPSServers, + ECmdCreateMiscEntryNotes, + ECmdCreateMiscEntrySyncSettings, + ECmdCreateMiscEntryLandmarks, + + ECmdDeleteEntries, + ECmdDeleteAllEntries, + ECmdDeleteAllCreatorEntries, + ECmdDeleteContacts, + ECmdDeleteCreatorContacts, + ECmdDeleteContactGroups, + ECmdDeleteCreatorContactGroups, + ECmdDeleteCalendarEntries, + ECmdDeleteCreatorCalendarEntries, + ECmdDeleteBrowserBookmarks, + ECmdDeleteCreatorBrowserBookmarks, + ECmdDeleteBrowserBookmarkFolders, + ECmdDeleteCreatorBrowserBookmarkFolders, + ECmdDeleteBrowserSavedPages, + ECmdDeleteCreatorBrowserSavedPages, + ECmdDeleteBrowserSavedPageFolders, + ECmdDeleteCreatorBrowserSavedPageFolders, + ECmdDeleteCreatorFiles, + ECmdDeleteLogs, + ECmdDeleteCreatorLogs, + ECmdDeleteMessages, + ECmdDeleteCreatorMessages, + ECmdDeleteMailboxes, + ECmdDeleteCreatorMailboxes, + ECmdDeleteIAPs, + ECmdDeleteCreatorIAPs, + ECmdDeleteIMPSs, + ECmdDeleteCreatorIMPSs, + ECmdDeleteNotes, + // ECmdDeleteCreatorNotes, not supported + ECmdDeleteLandmarks, + ECmdDeleteCreatorLandmarks, + + ECmdAboutCreator, + + ECmdSelectRandomDataFile, + + EProgressNote + + }; + +#endif // __CREATOR_HRH__ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/inc/creator.pan --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/inc/creator.pan Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef __CREATOR_PAN__ +#define __CREATOR_PAN__ + + +/** Creator application panic codes */ +enum TCreatorPanics + { + ECreatorBasicUi = 1 + // add further panics here + }; + +#endif // __CREATOR_PAN__ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/inc/creator_accesspoint.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/inc/creator_accesspoint.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,126 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + + +#ifndef __CREATORACCESSPOINTS_H__ +#define __CREATORACCESSPOINTS_H__ + +#include "engine.h" +#include "creator_modulebase.h" +#include "creator_connectionmethodbase.h" + +#include +#include +//#include +//#include +//#include +//#include +//#include +#include +#include +#include + + +class CCreatorEngine; +class CAccessPointsParameters; + + + +class CCreatorAccessPoints : public CCreatorConnectionSettingsBase, public MMsvSessionObserver + { +public: + static CCreatorAccessPoints* NewL(CCreatorEngine* aEngine); + static CCreatorAccessPoints* NewLC(CCreatorEngine* aEngine); + ~CCreatorAccessPoints(); + +private: + CCreatorAccessPoints(); + void ConstructL(CCreatorEngine* aEngine); // from MCreatorModuleBase + + void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3); // from MMsvSessionObserver + +public: + TBool AskDataFromUserL( TInt aCommand ); // from MCreatorModuleBase + + TInt CreateConnectionSettingsEntryL(CCreatorModuleBaseParameters *aParameters); + TUint32 AccessPointNameToIdL(const TDesC& aAPName, TBool aAnyIfNotFound = EFalse ); + + void DeleteAllL(); + void DeleteAllCreatedByCreatorL(); + +private: + CCommsDatabase* iCommsDb; + CApDataHandler* iApDataHandler; + CApUtils* iApUtils; + CAccessPointsParameters* iParameters; + RArray iEntryIds; // TUint32 CApDataHandler::CreateFromDataL + +public: + }; + + +class CAccessPointsParameters : public CCreatorModuleBaseParameters + { +public: + HBufC* iConnectionName; // connection name + TApBearerType iBearerType; // bearer type + HBufC* iWapStartPage; // WAP start page + TUint32 iWapWspOption; // connection type + HBufC* iGprsAcessPointName; // access point name + HBufC* iIspLoginName; // username + TBool iSecureAuthentication; // password authentication + HBufC* iIspLoginPass; // password + TBool iPromptPassword; // prompt password + HBufC* iWapGatewayAddress; // WAP gateway address + HBufC* iIspIPAddr; // phone IP + HBufC* iIspIPNameServer1; // primary name server + HBufC* iIspIPNameServer2; // secondary name server + HBufC* iIspDefaultTelNumber; // datacall number + TUint32 iIspBearerCallTypeIsdn; // datacall type + TUint32 iIspBearerSpeed; // max connection speed + HBufC* iProxyServerAddress; // proxy address + TUint32 iProxyPortNumber; // proxy number + + void SetRandomCMNameL(CCreatorEngine& aEngine); + void SetRandomLoginNameL(CCreatorEngine& aEngine); + void SetRandomLoginPassL(CCreatorEngine& aEngine); + void SetRandomSecureAuthenticationL(CCreatorEngine& aEngine); + void SetRandomPromptPasswordL(CCreatorEngine& aEngine); + void SetRandomProxyAddressL(CCreatorEngine& aEngine); + void SetRandomProxyPortL(CCreatorEngine& aEngine); + void SetRandomStartPageL(CCreatorEngine& aEngine); + void SetRandomIPAddressL(CCreatorEngine& aEngine); + void SetRandomIP4NameServer1L(CCreatorEngine& aEngine); + void SetRandomIP4NameServer2L(CCreatorEngine& aEngine); + void SetRandomTelephoneNumberL(CCreatorEngine& aEngine); + void SetRandomBearerTypeIsdnL(CCreatorEngine& aEngine); + void SetRandomBearerSpeedL(CCreatorEngine& aEngine); + void SetRandomWapWspOptionL(CCreatorEngine& aEngine); + void SetRandomGatewayAddressL(CCreatorEngine& aEngine); + + +public: + CAccessPointsParameters(); + ~CAccessPointsParameters(); + }; + + + +#endif // __CREATORACCESSPOINTS_H__ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/inc/creator_browser.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/inc/creator_browser.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,108 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + + +#ifndef __CREATORBROWSER_H__ +#define __CREATORBROWSER_H__ + +#include "engine.h" +#include "creator_modulebase.h" + +#include +//#include +//#include +//#include + + + +class CCreatorEngine; +class CBrowserParameters; + + +class CCreatorBrowser : public CCreatorModuleBase + { +public: + static CCreatorBrowser* NewL(CCreatorEngine* aEngine); + static CCreatorBrowser* NewLC(CCreatorEngine* aEngine); + ~CCreatorBrowser(); + +private: + CCreatorBrowser(); + void ConstructL(CCreatorEngine* aEngine); // from MCreatorModuleBase + +public: + TBool AskDataFromUserL( TInt aCommand ); // from MCreatorModuleBase + + TInt CreateBookmarkEntryL(CBrowserParameters *aParameters); + TInt CreateBookmarkFolderEntryL(CBrowserParameters *aParameters); + TInt CreateSavedDeckEntryL(CBrowserParameters *aParameters); + TInt CreateSavedDeckFolderEntryL(CBrowserParameters *aParameters); + + void DeleteAllL(); + void DeleteAllCreatedByCreatorL(); + + void DeleteAllBookmarksL(); + void DeleteAllBookmarksCreatedByCreatorL(); + void DeleteAllBookmarkFoldersL(); + void DeleteAllBookmarkFoldersCreatedByCreatorL(); + void DeleteAllSavedPagesL(); + void DeleteAllSavedPagesCreatedByCreatorL(); + void DeleteAllSavedPageFoldersL(); + void DeleteAllSavedPageFoldersCreatedByCreatorL(); + +private: + void DeleteAllItemsL( const TDesC& aDbName, CFavouritesItem::TType aTypeFilter, TBool aOnlyCreatedWithCreator, RArray& aEntryIds, const TUid aDictUid ); + + + +private: + CBrowserParameters* iParameters; + RArray iBmEntryIds; + RArray iBmFEntryIds; + RArray iSpEntryIds; + RArray iSpFEntryIds; +public: + }; + + +class CBrowserParameters : public CCreatorModuleBaseParameters + { +public: + HBufC* iBookmarkName; + HBufC* iBookmarkAddress; + TFavouritesWapAp iBookmarkAccessPoint; + HBufC* iBookmarkUsername; + HBufC* iBookmarkPassword; + + HBufC* iBookmarkFolderName; + + HBufC* iSavedDeckLinkName; + HBufC* iSavedDeckLocalAddress; + + HBufC* iSavedDeckFolderName; + +public: + CBrowserParameters(); + ~CBrowserParameters(); + }; + + + +#endif // __CREATORBROWSER_H__ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/inc/creator_browserelement.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/inc/creator_browserelement.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef CREATORBROWSERELEMENT_H_ +#define CREATORBROWSERELEMENT_H_ + +#include "creator_scriptelement.h" + +namespace creatorbrowser +{ +_LIT(KBookmark, "bookmark"); +_LIT(KBookmarkFolder, "bookmarkfolder"); +_LIT(KSavedPage, "savedpage"); +_LIT(KSavedPageFolder, "savedpagefolder"); + +_LIT(KName, "name"); +_LIT(KPath, "path"); +_LIT(KUsername, "username"); +_LIT(KPassword, "password"); +_LIT(KUrl, "url"); +} + +class CCreatorBrowserElement : public CCreatorScriptElement +{ +public: + static CCreatorBrowserElement* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC); + void ExecuteCommandL(); + +protected: + CCreatorBrowserElement(CCreatorEngine* aEngine); + TInt GetBrowserCommandL() const; +}; +#endif /*CREATORBROWSERELEMENT_H_*/ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/inc/creator_calendar.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/inc/creator_calendar.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,209 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + + +#ifndef __CREATORCALENDARINTERIM_H__ +#define __CREATORCALENDARINTERIM_H__ + +#include "engine.h" +#include "creator_modulebase.h" +#include "creator_calendarbase.h" + +#include +#include + +//#include +#include +#include +#include +#include +#include +#include +#include +#include + + +class CCreatorEngine; +class CCalenderInterimParameters; +class CAsyncWaiter; + +class CCreatorInterimCalendar : public CCreatorCalendarBase, public MCalProgressCallBack + { +enum TCreatorCalendarStatus{ + ECreatorCalendarDelete = 0, + ECreatorCalendarStart, + ECreatorCalendarGetWeeklyEntries, + ECreatorCalendarGetAttendies, + ECreatorCalendarGetStartDate, + ECreatorCalendarGetEndDate, + ECreatorCalendarAddDefaultAlarm +}; + +public: + static CCreatorInterimCalendar* NewL(CCreatorEngine* aEngine); + static CCreatorInterimCalendar* NewLC(CCreatorEngine* aEngine); + ~CCreatorInterimCalendar(); + +private: + CCreatorInterimCalendar(); + void ConstructL(CCreatorEngine* aEngine); // from MCreatorModuleBase + void AddRepeatingRuleL(const TCalTime& aStartTime, CCalEntry& aCalEntry, CCalenderInterimParameters* parameters=0); + void SetRandomAlarmL(CCalEntry& aCalEntry); + void SetAlarmL(CCalEntry& aCalEntry, CCalenderInterimParameters* params); + void AddAttendeesL(CCalEntry& aCalEntry, CCalenderInterimParameters* parameters=0); + void SetPhoneOwnerL(CCalEntry& aCalEntry, const TDesC& aCN, const TDesC& aEmail, const TDesC& aSentBy ); + void SetOrganizerL(CCalEntry& aCalEntry, const TDesC& aCN, const TDesC& aEmail, const TDesC& aSentBy); + void SetOrganizerL(CCalEntry& aCalEntry, CCalenderInterimParameters* parameters ); + +public: + TBool AskDataFromUserL( TInt aCommand ); // from MCreatorModuleBase + void QueryDialogClosedL(TBool aPositiveAction, TInt aUserData); //from MUIObserver + + TInt CreateAppointmentEntryL(CCreatorModuleBaseParameters *aParameters); + TInt CreateEventEntryL(CCreatorModuleBaseParameters *aParameters); + TInt CreateAnniversaryEntryL(CCreatorModuleBaseParameters *aParameters); + TInt CreateTodoEntryL(CCreatorModuleBaseParameters *aParameters); + TInt CreateReminderEntryL(CCreatorModuleBaseParameters *aParameters); + + void GenerateRandomId(TDes8& aText); + void DeleteAllL(); + void DeleteAllCreatedByCreatorL(); + +private: + + CCalenderInterimParameters* iParameters; + TTime iRandomModeStartTime; + TTime iRandomModeEndTime; + TInt iNumberRepeatingEntries; + TInt iNumberOfAttendees; + CCalEntryView* iCalEntryView; + CCalSession* iCalSession; + TBool iSetAlarm; + CDesCArrayFlat* iSoundFileArray; + CAsyncWaiter* iWaiter; + HBufC* iTmpCN; + HBufC* iTmpEmail; + RArray iEntryIds; // TCalLocalUid ( == TUint32 ) CCalEntry::LocalUidL + +public: + + //Observer implementation for MCalProgressCallBack + void Progress(TInt aPercentageCompleted); + + void Completed(TInt aError); + + TBool NotifyProgress(); + + }; + +class CCreatorCalenderAttendee : public CBase +{ +public: + virtual ~CCreatorCalenderAttendee(); + static CCreatorCalenderAttendee* NewL(); + void SetCommonNameL(const TDesC& aName); + void SetEmailAddressL(const TDesC& aEmail); + void SetRole(CCalAttendee::TCalRole aRole); + void SetStatus(CCalAttendee::TCalStatus); + + const TDesC& CommonName() const; + const TDesC& EmailAddress() const; + CCalAttendee::TCalRole Role() const; + CCalAttendee::TCalStatus Status() const; + +private: + CCreatorCalenderAttendee(); + TPtrC iDummy; + HBufC* iCommonName; + HBufC* iEmailAddress; + CCalAttendee::TCalRole iRole; + CCalAttendee::TCalStatus iStatus; +}; + +class CCalenderInterimParameters : public CCreatorModuleBaseParameters + { +public: + + void ParseL(CCommandParser* parser, TParseParams aCase); + TBool IsAllowedEntryStatus(CCalEntry::TType aType, CCalEntry::TStatus aStatus); + + TCalRRule::TType iRecurrentFrequency; + TInt iRecurrentInterval; + TTime iRecurrentStartTime; + TTime iRecurrentEndTime; + TInt iRepeatingCount; // This is used when running a script... + TTime iAlarmTime; // NullTTime means no alarm + TBool iUseRandomAlarmTime; // ETrue if random alarm should be set. Overwrites the iAlarmTime. + + RPointerArray iAttendees; + RArray iAttendeeLinkIds; // For attendees. Stores the linked contact ids. + HBufC* iOrganizerName; + HBufC* iOrganizerEmail; + + HBufC* iDescription; + HBufC* iSummary; + HBufC* iLocation; + TTime iStartTime; + TTime iEndTime; + TInt iNumberRepeatingEntries; // This is used when user input is used... + TInt iNumberOfAttendees; // Number of randomly generated attendees + TInt iNumberOfExistingAttendees; // Number of attendees selected from existing contacts. + + //An appointment, which has a start time and end time. + TTime iAppointmentStartTime; + TTime iAppointmentEndTime; + HBufC* iAppointmentLocation; + HBufC* iAppointmentReason; + + //An event, which has a start time and end time. + + TTime iEventStartTime; + TTime iEventEndTime; + HBufC* iEventReason; + + //A reminder, which has a start time only. + TTime iReminderStartTime; + HBufC* iReminderReason; + + //An anniversary, which has a start time and end time. + TTime iAnniversaryStartTime; + TTime iAnniversaryEndTime; + HBufC* iAnniversaryReason; + + //A to-do, which can have a start time and end time (the end time is the due date), or can be undated. + TTime iTodoStartTime;//optional + TTime iTodoDueTime;//also end time (optional) + HBufC* iTodoTask; + TInt iTodoPriority; + + TTime iRandomModeStartTime; + TTime iRandomModeEndTime; + + CCalEntry::TStatus iStatus; + +public: + CCalenderInterimParameters(); + ~CCalenderInterimParameters(); + + }; + + + +#endif // __CREATORCALENDARINTERIM_H__ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/inc/creator_calendarbase.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/inc/creator_calendarbase.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef CCREATORCALENDARBASE_ +#define CCREATORCALENDARBASE_ + +#include "creator_modulebase.h" + +class CCreatorModuleBaseParameters; + +class CCreatorCalendarBase : public CCreatorModuleBase{ +public: + + + //An appointment, which has a start time and end time. EAppt. + virtual TInt CreateAppointmentEntryL(CCreatorModuleBaseParameters *aParameters) = 0; + //An event, which has a start time and end time. EEvent. + virtual TInt CreateEventEntryL(CCreatorModuleBaseParameters *aParameters) = 0; + //An anniversary, which has a start time and end time. EAnniv. + virtual TInt CreateAnniversaryEntryL(CCreatorModuleBaseParameters *aParameters) = 0; + //A to-do, which can have a start time and end time (the end time is the due date), or can be undated. ETodo. + virtual TInt CreateTodoEntryL(CCreatorModuleBaseParameters *aParameters) = 0; + //A reminder, which has a start time only. EReminder. + virtual TInt CreateReminderEntryL(CCreatorModuleBaseParameters *aParameters) = 0; + +}; + +#endif /*CCREATORCALENDARBASE_*/ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/inc/creator_calendarelement.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/inc/creator_calendarelement.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,120 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef CREATORCALENDARELEMENT_H_ +#define CREATORCALENDARELEMENT_H_ + +#include "creator_scriptelement.h" + +class CCalenderInterimParameters; + +// Calendar elements: +namespace creatorcalendar +{ + _LIT(KCalendar, "calendar"); + + // Calendar entry types: + _LIT(KType, "type"); + _LIT(KCalTypeAppointment, "appointment"); + _LIT(KCalTypeEvent, "event"); + _LIT(KCalTypeReminder, "reminder"); + _LIT(KCalTypeAnniversary, "anniversary"); + _LIT(KCalTypeTodo, "todo"); + + // Calendar entry field elements: + _LIT(KSummary, "summary"); + _LIT(KDescription, "description"); + _LIT(KLocation, "location"); + _LIT(KStarttime, "starttime"); + _LIT(KEndtime, "endtime"); + _LIT(KRecurrentFreq, "recurrentfrequency"); + _LIT(KRecurrentInterval, "recurrentinterval"); + _LIT(KRecurrentFrom, "recurrentfrom"); + _LIT(KRecurrentTo, "recurrentto"); + _LIT(KRepeatingCount, "repeatingcount"); + _LIT(KAlarmtime, "alarmtime"); + _LIT(KSynchronization, "synchronization"); + _LIT(KOrganizername, "organizername"); + _LIT(KOrganizeremail, "organizeremail"); + _LIT(KAttendees, "attendees"); + _LIT(KAttendee, "attendee"); + _LIT(KCommonname, "commonname"); + _LIT(KEmail, "email"); + _LIT(KRole, "role"); + _LIT(KStatus, "status"); + _LIT(KPriority, "priority"); + + // Recurrency frequency values: + _LIT(KNotRepeated, "not-repeated"); + _LIT(KWeekly, "weekly"); + _LIT(KDaily, "daily"); + _LIT(KMonthly, "monthly"); + _LIT(KYearly, "yearly"); + + // Attendee role values: + _LIT(KRoleRequired, "required"); + _LIT(KRoleOptional, "optional"); + _LIT(KRoleNonPart, "non-participant"); + _LIT(KRoleChair, "chair"); + + // Calendar entry status values: + _LIT(KCalStatusTentative, "tentative"); + _LIT(KCalStatusConfirmed, "confirmed"); + _LIT(KCalStatusCancelled, "cancelled"); + _LIT(KCalStatusNeedsAction, "todoneedsaction"); + _LIT(KCalStatusCompleted, "todocompleted"); + _LIT(KCalStatusInProcess, "todoinprocess"); + + // Attendee status values: + _LIT(KStatusNeedsAction, "needsaction"); + _LIT(KStatusAccepted, "accepted"); + _LIT(KStatusTentative, "tentative"); + _LIT(KStatusConfirmed, "confirmed"); + _LIT(KStatusDeclined, "declined"); + _LIT(KStatusCompleted, "completed"); + _LIT(KStatusDelegated, "delegated"); + _LIT(KStatusInProcess, "inprocess"); + + // Priority values: + _LIT(KPriorityHigh, "high"); + _LIT(KPriorityMedium, "medium"); + _LIT(KPriorityLow, "low"); +} + +class CCreatorCalendarElement : public CCreatorScriptElement +{ +public: + static CCreatorCalendarElement* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC); + void ExecuteCommandL(); +protected: + CCreatorCalendarElement(CCreatorEngine* aEngine); + + enum TEntryType { + EAppointment, + EEvent, + EReminder, + EAnniversary, + ETodo + }; + + void FillEntryParamsL(TEntryType aType, const RPointerArray& fields, CCalenderInterimParameters* parameters); +}; + +#endif /*CREATORCALENDARELEMENT_H_*/ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/inc/creator_cmdscriptrun.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/inc/creator_cmdscriptrun.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef __CREATORCMDSCRIPTRUN_H__ +#define __CREATORCMDSCRIPTRUN_H__ + +#include "engine.h" + +class CCreatorCmdScriptRun : public CBase, public MBeating + { +public: + + static CCreatorCmdScriptRun* NewL(CCreatorEngine* aEngine); + static CCreatorCmdScriptRun* NewLC(CCreatorEngine* aEngine); + ~CCreatorCmdScriptRun(); + + // callback from engine when the commands from the script file have been executed + void RunScriptDone(); + + // from MBeating + void Beat(); + void Synchronize(); + +private: + CCreatorCmdScriptRun(); + void ConstructL(CCreatorEngine* aEngine); + void TickL(); + +private: + CCreatorEngine* iEngine; + HBufC* iCommandLineScriptName; + HBufC* iCommandLineRandomDataFileName; + CHeartbeat* iTimer; + enum TTimerMode + { + ETimerModeNone, + ETimerModeStartScript, + ETimerModeExitAppUi + }; + TTimerMode iMode; + TInt iTickCount; + }; + +#endif // __CREATORCMDSCRIPTRUN_H__ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/inc/creator_connectionmethod.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/inc/creator_connectionmethod.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,155 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef __CREATORCONNECTIONSETTINGS_H__ +#define __CREATORCONNECTIONSETTINGS_H__ + +#include "engine.h" +#include "creator_modulebase.h" +#include "creator_connectionmethodbase.h" + +#include +#include +#include +#include +#include + +#include +#include +#include +using namespace CMManager; + +#include //ETel Packet API needed for enums + +class CCreatorEngine; +class CConnectionSettingsParameters; + +class CCreatorConnectionSettings : public CCreatorConnectionSettingsBase, public MMsvSessionObserver + { +public: + static CCreatorConnectionSettings* NewL(CCreatorEngine* aEngine); + static CCreatorConnectionSettings* NewLC(CCreatorEngine* aEngine); + ~CCreatorConnectionSettings(); + +private: + CCreatorConnectionSettings(); + void ConstructL(CCreatorEngine* aEngine); // from MCreatorModuleBase + + void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3); // from MMsvSessionObserver + +public: + TBool AskDataFromUserL( TInt aCommand ); // from MCreatorModuleBase + + TInt CreateConnectionSettingsEntryL(CCreatorModuleBaseParameters *aParameters); + TUint32 AccessPointNameToIdL(const TDesC& aAPName, TBool aAnyIfNotFound = EFalse ); + + //Setting default connection method, if not set + void SetDefaultCML(RCmConnectionMethodExt conMethod); + //Set random parameters + void SetRandomParametersL(CConnectionSettingsParameters& parameters); + void SetRandomBearerTypeL(CConnectionSettingsParameters& parameters); + void DeleteAllL(); + void DeleteAllCreatedByCreatorL(); +private: + void DeleteAllDestinationsL( TBool aOnlyCreatedWithCreator ); +private: + CCommsDatabase* iCommsDb; + + RCmManagerExt iCmManagerExt; + + CConnectionSettingsParameters* iParameters; + + RArray iEntryIds; // TUint32 RCmDestinationExt::Id() + +public: + }; + + +class CConnectionSettingsParameters : public CCreatorModuleBaseParameters + { +public: + HBufC* iConnectionName; // connection name + TUint iBearerType; // bearer type + HBufC* iStartPage; // start page + TWapWSPOption iWapWspOption; // Indicating whether connection-oriented or connectionless API should be used. + + RPacketContext::TProtocolType iProtocolType; //Type of protocol EPdpTypeIPv4 or EPdpTypeIPv4 + + HBufC* iLoginName; // username + TBool iSecureAuthentication; // password authentication + HBufC* iLoginPass; // password + TBool iPromptPassword; // prompt password + HBufC* iGatewayAddress; // gateway address + HBufC* iSubnetMask; // subnet mask + HBufC* iIPAddr; // phone IP + HBufC* iIP4NameServer1; // primary name server + HBufC* iIP4NameServer2; // secondary name server + HBufC* iDefaultTelNumber; // datacall number + TUint32 iBearerCallTypeIsdn; // datacall type + TUint32 iBearerSpeed; // max connection speed + TBool iUseProxy; //Use proxy or not + HBufC* iProxyServerAddress; // proxy address + TUint32 iProxyPortNumber; // proxy number + HBufC* iWLANName;//WLAN network name + HBufC* iWlanIpAddr;//IP address of EPOC. + TWlanSecMode iWLanSecMode;//WLAN security modes + TWlanNetMode iWlanNetMode;//WLAN connection mode. Ad-hoc or infrastructure. + + HBufC* iIP6NameServer1; // primary name server for IP v6 + HBufC* iIP6NameServer2; // secondary name server for IP v6 + TBool iDisableTextAuth; // Disable plaintext authentication + + CCreatorEngine* iEngine; + +public: + CConnectionSettingsParameters(); + ~CConnectionSettingsParameters(); + + void SetRandomCMNameL(CCreatorEngine& aEngine); + void SetRandomWLANNameL(CCreatorEngine& aEngine); + void SetRandomWLANNetModeL(CCreatorEngine& aEngine); + void SetRandomWLANSecurityModeL(CCreatorEngine& aEngine); + void SetRandomLoginNameL(CCreatorEngine& aEngine); + void SetRandomLoginPassL(CCreatorEngine& aEngine); + void SetRandomSecureAuthenticationL(CCreatorEngine& aEngine); + void SetRandomPromptPasswordL(CCreatorEngine& aEngine); + void SetRandomUseProxyL(CCreatorEngine& aEngine); + void SetRandomProxyAddressL(CCreatorEngine& aEngine); + void SetRandomProxyPortL(CCreatorEngine& aEngine); + void SetRandomStartPageL(CCreatorEngine& aEngine); + void SetRandomIPAddressL(CCreatorEngine& aEngine); + void SetRandomIP4NameServer1L(CCreatorEngine& aEngine); + void SetRandomIP4NameServer2L(CCreatorEngine& aEngine); + void SetRandomProtocolTypeL(CCreatorEngine& aEngine); + void SetRandomTelephoneNumberL(CCreatorEngine& aEngine); + void SetRandomBearerTypeIsdnL(CCreatorEngine& aEngine); + void SetRandomBearerSpeedL(CCreatorEngine& aEngine); + void SetRandomWapWspOptionL(CCreatorEngine& aEngine); + void SetRandomSubnetMaskL(CCreatorEngine& aEngine); + void SetRandomGatewayAddressL(CCreatorEngine& aEngine); + void SetRandomWlanIpAddrL(CCreatorEngine& aEngine); + void SetRandomIPv6NameServer1L(CCreatorEngine& aEngine); + void SetRandomIPv6NameServer2L(CCreatorEngine& aEngine); + void SetRandomDisableTextAuthL(CCreatorEngine& aEngine); + }; + + + +#endif // __CREATORCONNECTIONSETTINGS_H__ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/inc/creator_connectionmethodbase.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/inc/creator_connectionmethodbase.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef __CCREATORCONNECTIONSETTINGSBASE_H_ +#define __CCREATORCONNECTIONSETTINGSBASE_H_ + +#include "creator_modulebase.h" + +class CCreatorModuleBaseParameters; + +const TUint KRandomBearerType = 0xEEEEEEEE; + +class CCreatorConnectionSettingsBase : public CCreatorModuleBase + { +public: + + virtual ~CCreatorConnectionSettingsBase(){}; + + virtual TInt CreateConnectionSettingsEntryL(CCreatorModuleBaseParameters *aParameters) = 0; + virtual TUint32 AccessPointNameToIdL(const TDesC& aAPName, TBool aAnyIfNotFound = EFalse ) = 0; + virtual void DeleteAllConnectionMethodsL(){}; + }; + +#endif /*__CCREATORCONNECTIONSETTINGSBASE_H_*/ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/inc/creator_connectionmethodelement.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/inc/creator_connectionmethodelement.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,99 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef CREATORCONNECTIONMETHODELEMENT_H_ +#define CREATORCONNECTIONMETHODELEMENT_H_ + +#include "creator_scriptelement.h" + +namespace creatorconnectionmethod +{ + _LIT(KCm, "connectionmethod"); + _LIT(Kconnectionname, "connectionname"); + _LIT(Kbearertype, "bearertype"); + _LIT(Kstartpage, "startpage"); + _LIT(Kwapwspoption, "wapwspoption"); + _LIT(Kprotocoltype, "protocoltype"); + _LIT(Kloginname, "loginname"); + _LIT(Ksecureauthentication, "secureauthentication"); + _LIT(Kloginpass, "loginpass"); + _LIT(Kpromptpassword, "promptpassword"); + _LIT(Kgatewayaddress, "gatewayaddress"); + _LIT(Ksubnetmask, "subnetmask"); + _LIT(Kdeviceipaddr, "deviceipaddr"); + _LIT(Kip4nameserver1, "ip4nameserver1"); + _LIT(Kip4nameserver2, "ip4nameserver2"); + _LIT(Kdatacalltelnumber, "datacalltelnumber"); + _LIT(Kdatacalltypeisdn, "datacalltypeisdn"); + _LIT(Kdatacalllinespeed, "datacalllinespeed"); + _LIT(Kuseproxy, "useproxy"); + _LIT(Kproxyserveraddress, "proxyserveraddress"); + _LIT(Kproxyportnumber, "proxyportnumber"); + _LIT(Kip6nameserver1, "ip6nameserver1"); + _LIT(Kip6nameserver2, "ip6nameserver2"); + _LIT(Kdisabletextauth, "disabletextauth"); + _LIT(Kwlanname, "wlanname"); + _LIT(Kwlanipaddr, "wlanipaddr"); + _LIT(Kwlansecmode, "wlansecmode"); + _LIT(Kwlannetmode, "wlannetmode"); + + // Bearer type: + _LIT(Kwlan, "wlan"); + _LIT(Kgprs, "gprs"); + _LIT(Kdatacall, "datacall"); + _LIT(Khsgsm, "hsgsm"); + _LIT(Kembedded, "embedded"); + _LIT(Kvpn, "vpn"); + _LIT(Klan, "lan"); + + // Data call type isdn: + _LIT(Kanalogue, "analogue"); + _LIT(Kisdnv110, "isdnv110"); + _LIT(Kisdnv120, "isdnv120"); + + // Line speed: + _LIT(Kautomatic, "automatic"); + // WAP wps options: + _LIT(Kconnectionless, "connectionless"); // ECmWapWspOptionConnectionless + _LIT(Kconnectionoriented, "connectionoriented"); // ECmWapWspOptionConnectionOriented + + // Protocol + _LIT(Kipv4, "ipv4"); + _LIT(Kipv6, "ipv6"); + + // WLAN security mode: + _LIT(Kopen, "open"); + _LIT(Kwep, "wep"); + _LIT(Ke802_1x, "e802_1x"); + _LIT(Kwpa, "wpa"); + _LIT(Kwpa2, "wpa2"); +} + +class CCreatorConnectionMethodElement : public CCreatorScriptElement +{ +public: + static CCreatorConnectionMethodElement* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC); + void ExecuteCommandL(); + +protected: + CCreatorConnectionMethodElement(CCreatorEngine* aEngine); +}; + +#endif /*CREATORCONNECTIONMETHODELEMENT_H_*/ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/inc/creator_contactelement.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/inc/creator_contactelement.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,187 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef CREATORCONTACTELEMENT_H_ +#define CREATORCONTACTELEMENT_H_ + +#include "creator_scriptelement.h" + +namespace creatorcontact +{ + _LIT(KContact, "contact"); + _LIT(KContactSet, "contact-set"); + _LIT(KContactGroup, "contactgroup"); + _LIT(KMembers, "members"); + _LIT(KName, "name"); + + // Contact field elements: + _LIT(KFirstname, "firstname"); + _LIT(KLastname, "lastname"); + _LIT(KFirstnameReading, "firstnamereading"); + _LIT(KLastnameReading, "lastnamereading"); + _LIT(KPrefix, "prefix"); + _LIT(KSuffix, "suffix"); + _LIT(KSecondname, "secondname"); + _LIT(KLandphoneHome, "landphonehome"); + + _LIT(KMobilephoneHome, "mobilephonehome"); + _LIT(KVideonumberHome, "videonumberhome"); + _LIT(KFaxnumberHome, "faxnumberhome"); + _LIT(KVoipHome, "voiphome"); + _LIT(KEmailHome, "emailhome"); + _LIT(KUrlHome, "urlhome"); + _LIT(KAddrlabelHome, "addrlabelhome"); + _LIT(KAddrpoHome, "addrpohome"); + + _LIT(KAddrextHome, "addrexthome"); + _LIT(KAddrstreetHome, "addrstreethome"); + _LIT(KAddrlocalHome, "addrlocalhome"); + _LIT(KAddrregionHome, "addrregionhome"); + _LIT(KAddrpostcodeHome, "addrpostcodehome"); + _LIT(KAddrcountryHome, "addrcountryhome"); + _LIT(KJobtitle, "jobtitle"); + _LIT(KCompanyname, "company"); + + _LIT(KLandphoneWork, "landphonework"); + _LIT(KMobilephoneWork, "mobilephonework"); + _LIT(KVideonumberWork, "videonumberwork"); + _LIT(KFaxnumberWork, "faxnumberwork"); + _LIT(KVoipWork, "voipwork"); + _LIT(KEmailWork, "emailwork"); + _LIT(KUrlWork, "urlwork"); + _LIT(KAddrlabelWork, "addrlabelwork"); + + _LIT(KAddrpoWork, "addrpowork"); + _LIT(KAddrextWork, "addrextwork"); + _LIT(KAddrstreetWork, "addrstreetwork"); + _LIT(KAddrlocalWork, "addrlocalwork"); + _LIT(KAddrregionWork, "addrregionwork"); + _LIT(KAddrpostcodeWork, "addrpostcodework"); + _LIT(KAddrcountryWork, "addrcountrywork"); + _LIT(KLandphoneGen, "landphonegen"); + + _LIT(KMobilephoneGen, "mobilephonegen"); + _LIT(KVideonumberGen, "videonumbergen"); + _LIT(KFaxnumberGen, "faxnumbergen"); + _LIT(KVoipGen, "voipgen"); + _LIT(KPoc, "poc"); + _LIT(KSwis, "swis"); + _LIT(KSip, "sip"); + _LIT(KEmailGen, "emailgen"); + + _LIT(KUrlGen, "urlgen"); + _LIT(KAddrlabelGen, "addrlabelgen"); + _LIT(KAddrpoGen, "addrpogen"); + _LIT(KAddrextGen, "addrextgen"); + _LIT(KAddrstreetGen, "addrstreetgen"); + _LIT(KAddrlocalGen, "addrlocalgen"); + _LIT(KAddrregionGen, "addrregiongen"); + _LIT(KAddrpostcodeGen, "addrpostcodegen"); + + _LIT(KAddrcountryGen, "addrcountrygen"); + _LIT(KPagerNumber, "pagernumber"); + _LIT(KDtmfString, "dtmfstring"); + _LIT(KWvAddress, "wvaddress"); + _LIT(KDate, "date"); + _LIT(KNote, "note"); + _LIT(KThumbnailPath, "thumbnailpath"); + _LIT(KThumbnailId, "thumbnailid"); + _LIT(KRingTone, "ringtonepath"); + _LIT(KRingToneId, "ringtoneid"); + + _LIT(KCallerobjImg, "callerobjimg"); + _LIT(KCallerobjText, "callerobjtext"); + _LIT(KMiddlename, "middlename"); + _LIT(KDepartment, "department"); + _LIT(KAsstname, "asstname"); + _LIT(KSpouse, "spouse"); + _LIT(KChildren, "children"); + _LIT(KAsstphone, "asstphone"); + + _LIT(KCarphone, "caphone"); + _LIT(KAnniversary, "anniversary"); + _LIT(KSyncclass, "synchronization"); + _LIT(KLocPrivacy, "locprivacy"); + _LIT(KGenlabel, "genlabel"); +} +/** + * Contact elements + */ + +/** + * Base class for contact elements + */ +class CCreatorContactElementBase : public CCreatorScriptElement +{ +public: + static CCreatorContactElementBase* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC); +protected: + CCreatorContactElementBase(CCreatorEngine* aEngine); +}; + +/** + * Contact element + */ +class CCreatorContactElement : public CCreatorContactElementBase +{ +public: + static CCreatorContactElement* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC); + void ExecuteCommandL(); +protected: + CCreatorContactElement(CCreatorEngine* aEngine); +}; + +/** + * Contact-set element + */ +class CCreatorContactSetElement : public CCreatorContactElementBase +{ +public: + static CCreatorContactSetElement* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC); + void ExecuteCommandL(); + virtual void AddToCacheL(); +protected: + CCreatorContactSetElement(CCreatorEngine* aEngine); +}; + +/** + * Contact group element + */ +class CCreatorContactGroupElement : public CCreatorContactElementBase +{ +public: + static CCreatorContactGroupElement* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC); + void ExecuteCommandL(); +protected: + CCreatorContactGroupElement(CCreatorEngine* aEngine); +}; + +/** + * Contact field element + */ +class CCreatorContactFieldElement : public CCreatorScriptElement +{ +public: + static CCreatorContactFieldElement* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC); +protected: + CCreatorContactFieldElement(CCreatorEngine* aEngine); +}; + +#endif /*CREATORCONTACTELEMENT_H_*/ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/inc/creator_contactsetcache.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/inc/creator_contactsetcache.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,74 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef CREATORCONTACTSETCACHE_H_ +#define CREATORCONTACTSETCACHE_H_ + +#include + +// Forward declarations +class CContactLinkCacheImp; + +class CCreatorContactSet : public CBase +{ +public: + static CCreatorContactSet* NewL(TInt aLinkId, TInt aNumOfExistingContacts); + virtual ~CCreatorContactSet(); + void AppendL(TUint32); + TInt NumberOfExistingContacts() const; + RArray ContactLinks(); + const RArray ContactLinks() const; + + TInt LinkId() const; + +private: + CCreatorContactSet(TInt aLinkId, TInt aNumOfExistingContacts); + //void ConstructL(); + TInt iLinkId; + TInt iNumOfExistingContacts; + RArray iContactLinks; +}; + +class MContactLinkCache +{ +public: + virtual void AppendL(CCreatorContactSet* aContactSet) = 0; + virtual RArray ContactLinks(TInt aLinkId) = 0; + virtual const RArray ContactLinks(TInt aLinkId) const = 0; + virtual RPointerArray& ContactSets() = 0; + virtual const RPointerArray& ContactSets() const = 0; + virtual const CCreatorContactSet& ContactSet(TInt aLinkId) const = 0; + virtual CCreatorContactSet& ContactSet(TInt aLinkId) = 0; +}; + +class ContactLinkCache +{ +public: + static void InitializeL(); + static void DestroyL(); + + static MContactLinkCache* Instance(); + +private: + ContactLinkCache(){}; + static CContactLinkCacheImp* iImp; +}; + +#endif /*CREATORCONTACTSETCACHE_H_*/ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/inc/creator_factory.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/inc/creator_factory.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef TCREATORFACTORY_H_ +#define TCREATORFACTORY_H_ + +#include "creator_modulebase.h" + +class CCreatorEngine; +class CCreatorPhonebookBase; +//class CCreatorConnectionSettingsBase; + + +class TCreatorFactory{ + +public: + static CCreatorPhonebookBase* CreatePhoneBookL(CCreatorEngine* aEngine); + static CCreatorModuleBaseParameters* CreatePhoneBookParametersL(); + +// static CCreatorConnectionSettingsBase* CreateConnectionSettingsL(CCreatorEngine* aEngine); +// static CCreatorModuleBaseParameters* CreateConnectionSettingsParametersL(); + + +}; + +#endif /*TCREATORFACTORY_H_*/ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/inc/creator_file.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/inc/creator_file.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,106 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + + +#ifndef __CREATORFiles_H__ +#define __CREATORFiles_H__ + +#include "engine.h" +#include "creator_modulebase.h" + +#include +using namespace ContentAccess; +#include + +#include +#include +#include +#include // RApaLsSession + +class CCreatorEngine; +class CFilesParameters; +class CDRMPermission; +class CDRMConstraint; + +class CCreatorFiles : public CCreatorModuleBase + { +enum TCreatorFilesState{ + ECreatorFilesDelete, + ECreatorFilesStart, + ECreatorFilesGetDirectory, + ECreatorFilesAskDRMData, + ECreatorFilesAskDRM_CD_Counts, + ECreatorFilesAskDRM_CD_Minutes +}; +public: + static CCreatorFiles* NewL(CCreatorEngine* aEngine); + static CCreatorFiles* NewLC(CCreatorEngine* aEngine); + ~CCreatorFiles(); + +private: + CCreatorFiles(); + void ConstructL(CCreatorEngine* aEngine); // from MCreatorModuleBase + +public: + TBool AskDataFromUserL( TInt aCommand ); // from MCreatorModuleBase + void QueryDialogClosedL(TBool aPositiveAction, TInt aUserData); //from MUIObserver + TInt CreateFileEntryL(CFilesParameters *aParameters, TInt aCommand); + void DeleteAllL(); + void DeleteAllCreatedByCreatorL(); + +private: + + void EncryptFileL( const TDesC& aFileName, const TDesC& aOutFileName, CFilesParameters *aParameters ); + void SetPermissionsL( CMetaDataArray* aMetaData, const TDesC& aOutFileName, CFilesParameters *aParameters ); + void SetMimeTypeL( const TDesC& aFileName, TDes8& aMime, CFilesParameters *aParameters ); + TBool AskDRMDataFromUserL(); + void StorePathsForDeleteL( CDesCArray& aPaths ); + void GenerateFileNameL( TFileName& aRootName ); + +private: + CFilesParameters* iParameters; + CFilesParameters* iUserParameters; + TFileName iDirectoryQueriedFromUser; + RFs& iFs; + RApaLsSession iApaLs; + CDesCArray* iFilePaths; + TInt iFileId; + +public: + }; + + +class CFilesParameters : public CCreatorModuleBaseParameters + { +public: + HBufC* iFullFilePath; + TInt iFileCommand; + CDRMPermission* iPermission; + TBool iEncrypt; + +public: + CFilesParameters(); + CFilesParameters( CFilesParameters& aCopy ); + ~CFilesParameters(); + }; + + + +#endif // __CREATORFiles_H__ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/inc/creator_fileelement.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/inc/creator_fileelement.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef CREATORFILEELEMENT_H_ +#define CREATORFILEELEMENT_H_ + +#include "creator_scriptelement.h" + +namespace creatorfile +{ + _LIT(KFile, "file"); + _LIT(KType, "type"); + _LIT(KDirectory, "directory"); + _LIT(KDefaultDir, "c:\\data"); + _LIT(KEncryption, "encryption"); + _LIT(KDRMRight, "right"); + _LIT(KDRMFL, "DRM-FL"); + _LIT(KDRMCD, "DRM-CD"); + _LIT(KDRMPlayRight, "play"); + _LIT(KDRMDisplayRight, "display"); + _LIT(KDRMPrintRight, "print"); + _LIT(KDRMExecuteRight, "execute"); + _LIT(KDRMCount, "count"); + _LIT(KDRMInterval, "interval"); + _LIT(KDRMStartTime, "starttime"); + _LIT(KDRMEndTime, "endtime"); + _LIT(KDRMAccumulated, "accumulated"); +} + +class CDRMConstraint; +class CFilesParameters; + +class CCreatorFileElement : public CCreatorScriptElement +{ +public: + static CCreatorFileElement* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC); + void ExecuteCommandL(); + +protected: + CCreatorFileElement(CCreatorEngine* aEngine); + TInt GetFileCommandL( const TDesC& aFileIdStr, TBool aRandom ) const; +private: + void ParseDRMElementsL( CCreatorScriptElement* aField, CFilesParameters* aParam ); + void ParseDRMConstraintsL( CCreatorScriptElement* aRight, CDRMConstraint* aConstraint ); + TTimeIntervalSeconds ParseTimeInterval( TDesC& aTimeString ); +private: // Data + TInt64 iTimeZone; +}; + +#endif // CREATORFILEELEMENT_H_ \ No newline at end of file diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/inc/creator_landmark.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/inc/creator_landmark.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,106 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef LANDMARKS_H_ +#define LANDMARKS_H_ + +#include "engine.h" +#include "creator_modulebase.h" + +#include +#include + +class CLandmarkParameters; +class CPosLandmarkDatabase; +class CPosLmOperation; + +static const TInt KLandmarkFieldLength = 256; + +class CCreatorLandmarks : public CCreatorModuleBase + { +public: + static CCreatorLandmarks* NewL(CCreatorEngine* aEngine); + static CCreatorLandmarks* NewLC(CCreatorEngine* aEngine); + ~CCreatorLandmarks(); + +private: + CCreatorLandmarks(); + void ConstructL(CCreatorEngine* aEngine); // from MCreatorModuleBase + TPosLmItemId GetCategoryIdL( TPosLmGlobalCategory aGlobalCategoryID ); + +public: + TBool AskDataFromUserL( TInt aCommand ); // from MCreatorModuleBase + + TInt CreateLandmarkEntryL(CLandmarkParameters *aParameters); + static TPosLmGlobalCategory GetCategoryIdL(const TDesC& aCategoryStr); + void DeleteAllL(); + void DeleteAllCreatedByCreatorL(); + +private: + CPosLandmarkDatabase* iLandmarkDb; + CLandmarkParameters* iParameters; + CPosLmOperation* iLmOperation; + RArray iEntryIds; // TPosLmItemId (==TUint32) CPosLandmark::LandmarkId() +public: + }; + + +class CLandmarkParameters : public CCreatorModuleBaseParameters + { +public: + HBufC* iName; + RArray iCategories; + HBufC* iStreet; + HBufC* iCity; + HBufC* iState; + HBufC* iCountry; + HBufC* iPostCode; + HBufC* iDescription; + HBufC* iPhonenumber; + HBufC* iUrl; + TReal64 iLatitude; + TReal64 iLongitude; + TReal32 iPositionAccuracy; + TReal32 iAltitude; + TReal32 iAltitudeAccuracy; + + void SetRandomNameL(CCreatorEngine& aEngine); + void SetRandomUrlL(CCreatorEngine& aEngine); + void AddRandomCategoryL(CCreatorEngine& aEngine); + void SetRandomStreetL(CCreatorEngine& aEngine); + void SetRandomCityL(CCreatorEngine& aEngine); + void SetRandomStateL(CCreatorEngine& aEngine); + void SetRandomCountryL(CCreatorEngine& aEngine); + void SetRandomPostCodeL(CCreatorEngine& aEngine); + void SetRandomLatitudeL(CCreatorEngine& aEngine); + void SetRandomLongitudeL(CCreatorEngine& aEngine); + void SetRandomPositionAccuracyL(CCreatorEngine& aEngine); + void SetRandomAltitudeL(CCreatorEngine& aEngine); + void SetRandomAltitudeAccuracyL(CCreatorEngine& aEngine); + void SetRandomDescriptionL(CCreatorEngine& aEngine); + void SetRandomPhoneNumberL(CCreatorEngine& aEngine); + +private: + +public: + CLandmarkParameters(); + ~CLandmarkParameters(); + }; +#endif /*LANDMARKS_H_*/ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/inc/creator_landmarkelement.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/inc/creator_landmarkelement.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef CREATORLANDMARKELEMENT_H_ +#define CREATORLANDMARKELEMENT_H_ + +#include "creator_scriptelement.h" + +namespace creatorlandmark +{ + _LIT(KLandmark, "landmark"); + _LIT(KName, "name"); + _LIT(KCategory, "category"); + _LIT(KDescription, "description"); + _LIT(KStreet, "street"); + _LIT(KPostalcode, "postalcode"); + _LIT(KCity, "city"); + _LIT(KState, "state"); + _LIT(KCountry, "country"); + _LIT(KPhonenumber, "phonenbr"); + _LIT(KUrl, "url"); + _LIT(KLatitude, "latitude"); + _LIT(KLongitude, "longitude"); + _LIT(KPositionaccuracy, "positionaccuracy"); + _LIT(KAltitude, "altitude"); + _LIT(KAltitudeaccuracy, "altitudeaccuracy"); +} + +class CCreatorLandmarkElement : public CCreatorScriptElement +{ +public: + static CCreatorLandmarkElement* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC); + void ExecuteCommandL(); + +protected: + CCreatorLandmarkElement(CCreatorEngine* aEngine); +}; + +#endif /*CREATORLANDMARKELEMENT_H_*/ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/inc/creator_log.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/inc/creator_log.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,112 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + + +#ifndef __CREATORLOGS_H__ +#define __CREATORLOGS_H__ + +#include "engine.h" +#include "creator_modulebase.h" + + +#include +//#include +#include +#include +//#include +#include + + + +class CCreatorEngine; +class CLogsParameters; + + +class CCreatorLogs : public CActive, public MCreatorModuleBase, public MUIObserver + { +enum TCreatorLogsStatus{ + ECreatorLogsDelete = 0, + ECreatorLogsStart +}; + +public: + static CCreatorLogs* NewL(CCreatorEngine* aEngine); + static CCreatorLogs* NewLC(CCreatorEngine* aEngine); + ~CCreatorLogs(); + +private: + CCreatorLogs(); + void ConstructL(CCreatorEngine* aEngine); // from MCreatorModuleBase + + void RunL(); // from CActive + void DoCancel(); // from CActive + +public: + TBool AskDataFromUserL( TInt aCommand ); // from MCreatorModuleBase + void QueryDialogClosedL(TBool aPositiveAction, TInt aUserData); + + TInt CreateMissedCallEntryL(CLogsParameters *aParameters); + TInt CreateReceivedCallEntryL(CLogsParameters *aParameters); + TInt CreateDialledNumberEntryL(CLogsParameters *aParameters); + void DeleteAllL(); + void DeleteAllCreatedByCreatorL(); + +private: + CCreatorEngine* iEngine; + TInt iCommand; + TInt iEntriesToBeCreated; + TInt iDummy; + + CLogClient* iLogClient; + CLogEvent* iLogEvent; + CActiveSchedulerWait iLogWriteWait; + + CLogsParameters* iParameters; + RArray iEntryIds; // TLogId ( == TInt32) CLogEvent::Id() + +public: + }; + + +class CLogsParameters : public CCreatorModuleBaseParameters + { +public: + /*HBufC* iMissedCallPhoneNumber; + TTime iMissedCallEventTime; + + HBufC* iReceivedCallPhoneNumber; + TTime iReceivedCallEventTime; + TLogDuration iReceivedCallDuration; + + HBufC* iDialledNumberPhoneNumber; + TTime iDialledNumberEventTime; + TLogDuration iDialledNumberDuration;*/ + HBufC* iPhoneNumber; + TTime iEventTime; + TLogDuration iDuration; + +public: + CLogsParameters(); + ~CLogsParameters(); + }; + + + +#endif // __CREATORLOGS_H__ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/inc/creator_logelement.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/inc/creator_logelement.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef CREATORLOGELEMENT_H_ +#define CREATORLOGELEMENT_H_ + +#include "creator_scriptelement.h" + +namespace creatorlog +{ + _LIT(KLog, "log"); + _LIT(KDirection, "direction"); + _LIT(KDuration, "duration"); + _LIT(KPhonenumber, "phonenumber"); + _LIT(KDatetime, "datetime"); + _LIT(KMissed, "missed"); + _LIT(KIn, "in"); + _LIT(KOut, "out"); +} + +class CCreatorLogElement : public CCreatorScriptElement +{ +public: + static CCreatorLogElement* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC); + void ExecuteCommandL(); + +protected: + CCreatorLogElement(CCreatorEngine* aEngine); + TInt GetLogCommandL( const TDesC& aFileIdStr, TBool aRandom ) const; +}; + +#endif /*CREATORLOGELEMENT_H_*/ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/inc/creator_mailbox.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/inc/creator_mailbox.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,190 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + + +#ifndef __CREATORMAILBOXES_H__ +#define __CREATORMAILBOXES_H__ + +#include "engine.h" +#include "creator_modulebase.h" + + +#include +#include +#include +#include +#include +#include +#include +#include + +class CCreatorEngine; +class CMailboxesParameters; + +const TInt KDefaultSmtpPort = 25; + +enum TMailboxType + { + EMailboxPOP3, + EMailboxIMAP4 + }; + +class CCreatorMailboxes : public CCreatorModuleBase, public MMsvSessionObserver + { +public: + static CCreatorMailboxes* NewL(CCreatorEngine* aEngine); + static CCreatorMailboxes* NewLC(CCreatorEngine* aEngine); + ~CCreatorMailboxes(); + +private: + CCreatorMailboxes(); + void ConstructL(CCreatorEngine* aEngine); // from MCreatorModuleBase + + void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3); // from MMsvSessionObserver + void StoreIMEIToEntryL(const TMsvId aMailboxId); + void GetIMEIFromThePhoneL(); + + void PopulateSmtpSettingsL( + CEmailAccounts& aEmailAccount, + CImSmtpSettings& aSmtpSettings, + CImIAPPreferences& aIApSettings, + const CMailboxesParameters& aParameters ); + + void PopulateImapSettingsL( + CEmailAccounts& aEmailAccount, + CImImap4Settings& aImapSettings, + CImIAPPreferences& aIApSettings, + const CMailboxesParameters& aParameters ); + + void PopulatePopSettingsL( + CEmailAccounts& aEmailAccount, + CImPop3Settings& aPopSettings, + CImIAPPreferences& aIApSettings, + const CMailboxesParameters& aParameters ); + + +public: + TBool AskDataFromUserL( TInt aCommand ); // from MCreatorModuleBase + + TInt CreateMailboxEntryL(CMailboxesParameters *aParameters); + void DeleteAllL(); + void DeleteAllCreatedByCreatorL(); + + +private: + CMailboxesParameters* iParameters; + TBuf<50> iIMEI; + RArray iEntryIds; + +public: + }; + + +class CMailboxesParameters : public CCreatorModuleBaseParameters + { +public: +// HBufC* iMailboxName; +// HBufC* iAccessPoint; +// HBufC* iMyMailAddress; +// HBufC* iOutgoingMailServer; +// TBool iSendMessageImmediately; +// TBool iSendCopyToSelf; +// TBool iIncludeSignature; +// HBufC* iUserName; +// HBufC* iPassword; +// HBufC* iIncomingMailServer; +// TMailboxType iMailboxType; // IMAP4 or POP3 +// TBool iSecurityOn; // SecureSockets +// TBool iSSLWrapper; // SSL Wrapper +// TBool iAPOPSecureLogin; // POP3 only +// TBool iRetrieveAttachment; // IMAP4 only +// TInt32 iRetrieveHeaders; // IMAP4 only + + enum TGetEmailOption + { + EUndef = 0, + EGetHeaders, + EGetBodyText, + EGetBodyTextAndAttachments, + EGetAttachments, + EGetBodyAlternativeText, + EGetEmailOptionLast + }; + + HBufC* iMailboxName; + HBufC* iIncomingLoginName; + HBufC* iIncomingPassword; + HBufC* iIncomingServerName; + HBufC* iIncomingConnectionMethod; + HBufC* iIncomingFolderPath; + HBufC* iPathSeparator; + HBufC* iOutgoingLoginName; + HBufC* iOutgoingPassword; + HBufC* iOutgoingServerName; + HBufC* iOutgoingConnectionMethod; + HBufC* iOwnEmailAddress; + HBufC* iOwnEmailAlias; + HBufC* iReceiptAddress; + HBufC* iReplyToAddress; + + TInt iIncomingPort; + TInt iAttachmentSizeLimit; + TInt iBodyTextSizeLimit; + TInt iAttachmentFetchSize; + TInt iImapIdleTimeout; + TInt iMaxEmailSize; + TInt iSyncRate; + TInt iInboxSyncLimit; // -1 = All + TInt iMailboxSyncLimit; // -1 = All + TInt iOutgoingPort; + TInt iToCCIncludeLimit; + + TBool iIncomingSSLWrapper; + TBool iIncomingSecureSockets; + TBool iAcknowledgeReceipts; + TBool iAutoSendOnConnect; + TBool iDeleteEmailsAtDisconnect; + TBool iImapIdleCommand; + TBool iMarkSeenInSync; + TBool iEnableExpungeMode; + TBool iUseApop; + TBool iDisconnectedUserMode; + TBool iOutgoingSSLWrapper; + TBool iOutgoingSecureSockets; + TBool iIncludeSignature; + TBool iAddVCard; + TBool iRequestReceipts; + TBool iSmtpAuth; + + TGetEmailOption iGetEmailOptions; + TFolderSubscribeType iSubscribeType; + TFolderSyncType iSyncType; + TImSMTPSendCopyToSelf iSendCopyToSelf; + TImSMTPSendMessageOption iSendOption; + TMailboxType iMailboxType; // IMAP4 or POP3 + +public: + CMailboxesParameters(); + ~CMailboxesParameters(); + }; + + + +#endif // __CREATORMAILBOXES_H__ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/inc/creator_mailboxelement.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/inc/creator_mailboxelement.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,132 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef CREATORMAILBOXELEMENT_H_ +#define CREATORMAILBOXELEMENT_H_ + +#include "creator_scriptelement.h" + +class CMailboxesParameters; + +namespace creatormailbox +{ + _LIT(Kmailbox, "mailbox"); + _LIT(Kname, "name"); + _LIT(Kincomingport, "incomingport"); + _LIT(Kincomingsslwrapper, "incomingsslwrapper"); + _LIT(Kincomingsecuresockets, "incomingsecuresockets"); + _LIT(Kincomingloginname, "incomingloginname"); + _LIT(Kincomingpassword, "incomingpassword"); + _LIT(Kincomingservername, "incomingservername"); + _LIT(Kincomingconnectionmethod, "incomingconnectionmethod"); + _LIT(Kacknowledgereceipts, "acknowledgereceipts"); + _LIT(Kattachmentsizelimit, "attachmentsizelimit"); + _LIT(Kautosendonconnect, "autosendonconnect"); + _LIT(Kbodytextsizelimit, "bodytextsizelimit"); + _LIT(Kdeletemailsatdisconnect, "deletemailsatdisconnect"); + _LIT(Kattachmentfetchsize, "attachmentfetchsize"); + _LIT(Kincomingfolderpath, "incomingfolderpath"); + _LIT(Kpathseparator, "pathseparator"); + _LIT(Kgetemailoptions, "getemailoptions"); + _LIT(Kimapidlecommand, "imapidlecommand"); + _LIT(Kimapidletimeout, "imapidletimeout"); + _LIT(Kmaxemailsize, "maxemailsize"); + _LIT(Ksubscribetype, "subscribetype"); + _LIT(Ksyncrate, "syncrate"); + _LIT(Kfoldersynctype, "foldersynctype"); + _LIT(Kmarkseeninsync, "markseeninsync"); + _LIT(Kenableexpungemode, "enableexpungemode"); + _LIT(Kuseapopsecurelogin, "useapopsecurelogin"); + _LIT(Kinboxsynclimit, "inboxsynclimit"); + _LIT(Kmailboxsynclimit, "mailboxsynclimit"); + _LIT(Kdisconnectedusermode, "disconnectedusermode"); + _LIT(Koutgoingport, "outgoingport"); + _LIT(Koutgoingsslwrapper, "outgoingsslwrapper"); + _LIT(Koutgoingsecuresockets, "outgoingsecuresockets"); + _LIT(Koutgoingloginname, "outgoingloginname"); + _LIT(Koutgoingpassword, "outgoingpassword"); + _LIT(Koutgoingservername, "outgoingservername"); + _LIT(Koutgoingconnectionmethod, "outgoingconnectionmethod"); + _LIT(Kincludesignature, "includesignature"); + _LIT(Kaddvcard, "addvcard"); + _LIT(Kownemail, "ownemail"); + _LIT(Kemailalias, "emailalias"); + _LIT(Kreceiptaddress, "receiptaddress"); + _LIT(Kreplytoaddress, "replytoaddress"); + _LIT(Krequestreceipts, "requestreceipts"); + _LIT(Ksmtpauth, "smtpauth"); + _LIT(Kcopytoself, "copytoself"); + _LIT(Ksendoption, "sendoption"); + _LIT(Ktoccincludelimit, "toccincludelimit"); + + + // Get email options: + _LIT(Kgetheaders, "getheaders"); + _LIT(Kgetbodytext, "getbodytext"); + _LIT(Kgetbodytextandattachments, "getbodytextandattachments"); + _LIT(Kgetattachments, "getattachments"); + _LIT(Kgetbodyalternativetext, "getbodyalternativetext"); + + // Subscribe types: + _LIT(Kupdateneither, "updateneither"); + _LIT(Kupdatelocal, "updatelocal"); + _LIT(Kupdateremote, "updateremote"); + _LIT(Kupdateboth, "updateboth"); + + // Folder sync. types: + _LIT(Kusecombination, "usecombination"); + _LIT(Kuselocal, "uselocal"); + _LIT(Kuseremote, "useremote"); + + // Send copy to self option: + _LIT(Kno, "no"); + _LIT(Kto, "to"); + _LIT(Kcc, "cc"); + _LIT(Kbcc, "bcc"); + + // Send option: + _LIT(Kimmediately, "immediately"); + _LIT(Konnextconnection, "onnextconnection"); + _LIT(Konrequest, "onrequest"); + + // Mailbox types: + _LIT(KMailboxType, "type"); + _LIT(Kpop3, "pop3"); + _LIT(Kimap4, "imap4"); + _LIT(Ksyncml, "syncml"); +} + +class CCreatorMailboxElement : public CCreatorScriptElement +{ +public: + static CCreatorMailboxElement* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC); + void ExecuteCommandL(); + +protected: + CCreatorMailboxElement(CCreatorEngine* aEngine); + TBool SetTextParamL(const TDesC& aElemName, const TDesC& aElemContent, CMailboxesParameters* aParams, TBool aSetRandom ); + TBool SetBooleanParamL(const TDesC& aElemName, const TDesC& aElemContent, CMailboxesParameters* aParams, TBool aSetRandom ); + TBool SetIntegerParamL(const TDesC& aElemName, const TDesC& aElemContent, CMailboxesParameters* aParams, TBool aSetRandom ); + TBool SetEnumParamL(const TDesC& aElemName, const TDesC& aElemContent, CMailboxesParameters* aParams, TBool aSetRandom ); + + TBool GetBooleanValueL(const TDesC& aElemContent, TBool aSetRandom); +}; + +#endif /*CREATORMAILBOXELEMENT_H_*/ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/inc/creator_message.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/inc/creator_message.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,197 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + + +#ifndef __CREATORMESSAGES_H__ +#define __CREATORMESSAGES_H__ + +#include "engine.h" +#include "creator_modulebase.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + + +class CCreatorEngine; +class CMessagesParameters; +class CAsyncWaiter; + +enum TMessageType + { + ESMS = 0, + EMMS, + EAMS, + EEmail, + ESmartMessage, + EIrMessage, + EBTMessage + }; + +enum TFolderType + { + EInbox = 0, + EDrafts, + EOutbox, + ESent, + EMailbox + }; + +class CRecipientInfo : public CBase +{ +public: + CRecipientInfo(); + virtual ~CRecipientInfo(); + + void SetPhoneNumber(HBufC* aPhone); + void SetEmailAddress(HBufC* aEmail); + const HBufC* PhoneNumber() const; + const HBufC* EmailAddress() const; + +private: + HBufC* iPhoneNumber; + HBufC* iEmailAddress; +}; + +class CCreatorMessages : public CCreatorModuleBase, public MMsvSessionObserver + { +enum TCreatorMessagesStatus{ + ECreatorMessagesDelete = 0, + ECreatorMessagesStart, + ECreatorMessagesMessageType, + ECreatorMessagesFolderType, + ECreatorMessagesMessageStatus, + ECreatorMessagesCharsInBody, + ECreatorMessagesAttachment, +}; + +public: + static CCreatorMessages* NewL(CCreatorEngine* aEngine); + static CCreatorMessages* NewLC(CCreatorEngine* aEngine); + ~CCreatorMessages(); + +private: + CCreatorMessages(); + void ConstructL(CCreatorEngine* aEngine); // from MCreatorModuleBase + + TInt CreateSMSEntryL(const CMessagesParameters& parameters); + TInt CreateMMSEntryL(const CMessagesParameters& parameters); + TInt CreateAMSEntryL(const CMessagesParameters& parameters); + TInt CreateEmailEntryL(const CMessagesParameters& parameters); + TInt CreateSmartMessageEntryL(const CMessagesParameters& parameters); + TInt CreateObexEntryL(TUid aMtm, const CMessagesParameters& parameters); + void HandleAttachementsL(const CMessagesParameters& parameters, CMsvStore* store, TInt err ); + void HandleAttachementL(CMsvStore* store, TInt err, TFileName& sourceFileName ); + + CMsvEntrySelection* DoGetListOfAccountsL(CMsvSession& aSession, TUid aMtm, TBool aAlwaysListHidden); + TMsvId DefaultServiceForMTML(CMsvSession& aSession, TUid aMtm, TBool aFindFirstServiceIfNoDefault); + + void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3); // from MMsvSessionObserver + + void AddRecipientsL(CBaseMtm& aMtm, const CMessagesParameters& aParameters, TBool aUseEmailAddress ); + void GetLinkedAddressesL( RPointerArray& aAddressArray, + const RArray& aLinkIds, + TBool aUseEmailAddress, + TInt aNumOfExistingAddresses ); + + void GetAllRecipientsL(RPointerArray& aRecipientArray, const CMessagesParameters& aParameters, TBool aUseEmailAddress ); + void SetSenderToEntryDetailsL(TMsvEntry& aMsgEntry, const CMessagesParameters& aParameters, TBool aUseEmailAddress); + void SetRecipientToEntryDetailsL(TMsvEntry& aMsgEntry, const CMessagesParameters& aParameters, TBool aUseEmailAddress); + void AddSenderToMtmAddresseeL(CBaseMtm& aMtm, const CMessagesParameters& aParameters, TBool aUseEmailAddress ); + void AddMtmSenderL(CMmsClientMtm& aMtm, const CMessagesParameters& aParameters, TBool aUseEmailAddress ); + void GetSendersL(RPointerArray& aSenderArray, const CMessagesParameters& aParameters, TBool aUseEmailAddress, TInt aMaxNum ); + void DeleteAllMessagesL( TBool aOnlyCreatedWithCreator ); + void DeleteAllFromFolderL( const TMsvId aContext, CMsvSession* aSession, CSmsClientMtm* aClientMtm, TBool aOnlyCreatedWithCreator = EFalse ); + +public: + TBool AskDataFromUserL( TInt aCommand ); // from MCreatorModuleBase + void QueryDialogClosedL(TBool aPositiveAction, TInt aUserData); //from MUIObserver + + TInt CreateMessageEntryL(CMessagesParameters *aParameters, TBool aTakeUserGivenParameters=EFalse); + TInt CreateRandomMessageEntryL(TInt aCommand); + void DeleteAllL(); + void DeleteAllCreatedByCreatorL(); + +private: + CMessagesParameters* iParameters; + TMessageType iMessageType; + TFolderType iFolderType; + TInt iDefinedMessageLength; + CArrayFixFlat* iAttachments; + //RPointerArray iAttachmentPaths; + TBool iCreateAsUnread; + TMsvId iUserSelectedMailbox; + HBufC* iTmpPhoneNumber; + HBufC* iTmpEmail; + RArray iEntryIds; // TMsvId ( == TInt32 ) TMsvEntry::Id() + CAsyncWaiter* iWaiter; + RPointerArray iSenderArray; + RPointerArray iRecipientArray; +public: + }; + + +class CMessagesParameters : public CCreatorModuleBaseParameters + { +public: + TMessageType iMessageType; + TFolderType iFolderType; + HBufC* iSenderAddress; + HBufC* iRecipientAddress; + RPointerArray iRecipientAddressArray; + HBufC* iMessageSubject; + HBufC* iMessageBodyText; + CArrayFixFlat* iAttachments; + RPointerArray iAttachmentPaths; + TInt iDefinedMessageLength; + TUid iBIOMessageType; + TBool iCreateAsUnread; + RArray iRecipientLinkIds; + RArray iSenderLinkIds; + TInt iNumberOfExistingRecipients; + TInt iNumberOfExistingSenders; + +public: + CMessagesParameters(); + ~CMessagesParameters(); + }; + + + +#endif // __CREATORMESSAGES_H__ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/inc/creator_messageelement.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/inc/creator_messageelement.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,93 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +#ifndef CREATORMESSAGEELEMENT_H_ +#define CREATORMESSAGEELEMENT_H_ + +#include "creator_scriptelement.h" +#include "creator_message.h" + +namespace creatormsg +{ + _LIT(KMessage, "message"); + _LIT(KType, "type"); + _LIT(KTo, "to"); + _LIT(KFrom, "from"); + _LIT(KFolder, "folder"); + _LIT(KSubject, "subject"); + _LIT(KText, "text"); + _LIT(KAttachmentPath, "attachmentpath"); + _LIT(KAttachmentId, "attachmentid"); + _LIT(KStatus, "status"); + _LIT(KSms, "sms"); + _LIT(KMms, "mms"); + _LIT(KAms, "ams"); + _LIT(KEmail, "email"); + _LIT(KSmart, "smart"); + _LIT(KBt, "bt"); + _LIT(KIr, "ir"); + _LIT(KSent, "sent"); + _LIT(KInbox, "inbox"); + _LIT(KDraft, "draft"); + _LIT(KOutbox, "outbox"); + _LIT(KMailbox, "mailbox"); + _LIT(KRead, "read"); + _LIT(KNew, "new"); +} + +/* + * Builds message parameters from the parsed script and adds a command to the engine + */ +class CCreatorMessageElement : public CCreatorScriptElement +{ +public: + static CCreatorMessageElement* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC); + void ExecuteCommandL(); +protected: + CCreatorMessageElement(CCreatorEngine* aEngine); + /* + * Creates message address. The address type is based on the message type. + * @return Phone number string for SMS, MMS, AMS and Smart messages. Email address for other types. + * @param msgType Message type. + */ + HBufC* CreateMessageAddressLC(const TDesC& msgType); + /* + * Sets message type to parameters + * @param aParameters Message parameters + * @param aMsgTypeStr Message type string + */ + void SetMessageTypeL(CMessagesParameters& aParameters, const TDesC& aMsgTypeStr ) const; + /* + * Gets length of the random data + * @return Length of the random data + * @param aRandomLenStr String defining the random length (from the script) + * @param aMsgType Message type string + */ + TInt GetRandomBodyLengthL(const TDesC& aRandomLenStr, const TDesC& aMsgType ) const; + /* + * Gets maximum length of the body text + * @return Maximum length of the body text + * @param aMsgType Message type string + */ + TInt GetMaxBodyLength( const TDesC& aMsgType ) const; + +}; + + +#endif /*CREATORMESSAGEELEMENT_H_*/ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/inc/creator_modulebase.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/inc/creator_modulebase.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,188 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef __CREATOR_MODULEBASE_H__ +#define __CREATOR_MODULEBASE_H__ + +#include + +#include "engine.h" +#include "creator_traces.h" + +// Dictionary uids for each Creator module. +// Dictionaries are for storing item identifiers created by Creator. +// Item identifiers are for enabling deletion of only items created by Creator. +const TUid KUidDictionaryUidContacts = { 0x00 }; +const TUid KUidDictionaryUidContactGroups = { 0x01 }; +const TUid KUidDictionaryUidCalendar = { 0x02 }; +const TUid KUidDictionaryUidBrowserBookmarks = { 0x03 }; +const TUid KUidDictionaryUidFiles = { 0x04 }; +const TUid KUidDictionaryUidLogs = { 0x05 }; +const TUid KUidDictionaryUidMessages = { 0x06 }; +const TUid KUidDictionaryUidMailbox = { 0x07 }; +const TUid KUidDictionaryUidIAP = { 0x08 }; +const TUid KUidDictionaryUidIMPS = { 0x09 }; +const TUid KUidDictionaryUidNotes = { 0x0A }; +const TUid KUidDictionaryUidLandmarks = { 0x0B }; +const TUid KUidDictionaryUidBrowserSavedPg = { 0x0C }; +const TUid KUidDictionaryUidBrowserBookmarkF = { 0x0D }; +const TUid KUidDictionaryUidBrowserSavedPgF = { 0x0E }; + +class CCreatorEngine; +class MCreatorModuleBaseParameters; +class CCommandParser; + +_LIT(KSavingText, "Saving"); +_LIT(KDeletingText, "Deleting"); + +class MCreatorModuleBase + { +public: + +private: + // constructs the module, add "iEngine = aEngine" and other construction stuff to the body + virtual void ConstructL( CCreatorEngine* aEngine ) = 0; + +public: + // this one is called when user select some features directly from menu, not running a script + // should call CreateRandomData() function + // returns ETrue when success, EFalse when user has cancelled + virtual TBool AskDataFromUserL( TInt aCommand ) = 0; + virtual void DeleteAllL() = 0; + virtual void DeleteAllCreatedByCreatorL() = 0; + }; + + +class CCreatorModuleBase : public CBase, public MCreatorModuleBase, public MUIObserver + { + +public: + enum TCreatorModuleStatus + { + ECreatorModuleDelete = 0, + ECreatorModuleStart + }; + + CCreatorModuleBase() + { + iEntriesToBeCreated = 1; + } + + virtual TBool AskDataFromUserL(TInt aCommand) + { + iCommand = aCommand; + return EFalse;// will finish user interaction and engine will shutdown modules + } + + virtual void QueryDialogClosedL(TBool aPositiveAction, TInt aUserData) + { + LOGSTRING("Creator: CCreatorModuleBase::QueryDialogClosedL"); + + if( aPositiveAction == EFalse ) + { + iEngine->ShutDownEnginesL(); + return; + } + const TDesC* showText = &KSavingText; + TBool finished(EFalse); + TBool retval(ETrue); + switch(aUserData) + { + case ECreatorModuleDelete: + showText = &KDeletingText; + iEntriesToBeCreated = 1; + finished = ETrue; + break; + case ECreatorModuleStart: + finished = ETrue; + break; + default: + //some error + retval = EFalse; + break; + } + if( retval == EFalse ) + { + iEngine->ShutDownEnginesL(); + } + else if( finished ) + { + // add this command to command array + iEngine->AppendToCommandArrayL(iCommand, NULL, iEntriesToBeCreated); + // started exucuting commands + iEngine->ExecuteFirstCommandL( *showText ); + } + } + +protected: + // constructs the module, add "iEngine = aEngine" and other construction stuff to the body + virtual void ConstructL(CCreatorEngine* aEngine) + { + iEngine = aEngine; + }; + +protected: + CCreatorEngine* iEngine; + TInt iCommand; + TInt iEntriesToBeCreated; + TInt iDummy; + }; + +class MCreatorModuleBaseParameters + { + // a base class for the parameters, no default implementation + + public: + enum TParseParams + { + EParamNone = 0, + ECalendarMeeting, + ECalendarMemo, + ECalendarAnniv, + ECalendarTodo + }; + +public: + virtual void ParseL(CCommandParser* /*aParser*/, TParseParams /*aCase = 0*/) = 0; + + + }; + +// Following struct represents the parameters that links for example contact groups +// to contac-sets. +typedef struct + { + TInt iLinkId; // ID + TInt iLinkAmount; // Amount of elements in linked set + } TLinkIdParam; + + +class CCreatorModuleBaseParameters : public CBase, public MCreatorModuleBaseParameters + { + public: + virtual void ParseL(CCommandParser* /*aParser*/, TParseParams /*aCase = 0*/){}; + virtual TInt ScriptLinkId() const {return -1;}; + virtual void SetScriptLinkId(TInt) {}; + // a base class for the parameters, no default implementation + }; + + + + +#endif // __CREATOR_MODULEBASE_H__ + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/inc/creator_note.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/inc/creator_note.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,75 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef __CREATORNOTEPAD_H__ +#define __CREATORNOTEPAD_H__ + +#include "engine.h" +#include "creator_modulebase.h" +#include "creator_notepadwrapper.h" + +#include + +static const TInt KNotepadFieldLength = 1024; + +class CCreatorEngine; +class CNotepadParameters; +class CCreatorNotepadWrapper; + + +class CCreatorNotepad : public CCreatorModuleBase + { +public: + static CCreatorNotepad* NewL(CCreatorEngine* aEngine); + static CCreatorNotepad* NewLC(CCreatorEngine* aEngine); + ~CCreatorNotepad(); + +private: + CCreatorNotepad(); + void ConstructL(CCreatorEngine* aEngine); // from MCreatorModuleBase + +public: + TBool AskDataFromUserL( TInt aCommand ); // from MCreatorModuleBase + + TInt CreateNoteEntryL(CNotepadParameters *aParameters); + void DeleteAllL(); + void DeleteAllCreatedByCreatorL(); + +private: + CCreatorNotepadWrapper* iNotepadWrapper; + + CNotepadParameters* iParameters; + RFs& iFs; + +public: + }; + + +class CNotepadParameters : public CCreatorModuleBaseParameters + { +public: + HBufC* iNoteText; + +public: + CNotepadParameters(); + ~CNotepadParameters(); + }; + + + +#endif // __CREATORNOTEPAD_H__ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/inc/creator_noteelement.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/inc/creator_noteelement.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +#ifndef CREATORNOTEELEMENT_H_ +#define CREATORNOTEELEMENT_H_ + +#include "creator_scriptelement.h" + +namespace creatornote +{ + _LIT(KNote, "note"); + _LIT(KText, "text"); +} + +class CCreatorNoteElement : public CCreatorScriptElement +{ +public: + static CCreatorNoteElement* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC); + void ExecuteCommandL(); + +protected: + CCreatorNoteElement(CCreatorEngine* aEngine); +}; + +#endif /*CREATORNOTEELEMENT_H_*/ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/inc/creator_notepadwrapper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/inc/creator_notepadwrapper.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef __CREATORNOTEPADWRAPPER_H__ +#define __CREATORNOTEPADWRAPPER_H__ + +//#include "engine.h" +//#include "creator_modulebase.h" + + +#include +#include +#include +#include +#include + + +class CCreatorNotepadWrapper : public CBase + { + public: + static CCreatorNotepadWrapper* NewL(); + static CCreatorNotepadWrapper* NewLC(); + ~CCreatorNotepadWrapper(); + + private: + CCreatorNotepadWrapper(); + void ConstructL(); + + public: + TInt CreateNoteL( const TDesC& aText ); + void DeleteAllL(); + + private: + AgendaUtil *iAgendaUtil; + NotesEditorInterface *iNotepadApi; //QT Notes api + QPluginLoader* iNotesEditorPluginLoader; // for loading QT Notes api + }; + +#endif // __CREATORNOTEPADWRAPPER_H__ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/inc/creator_phonebook.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/inc/creator_phonebook.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,142 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +#ifndef __CREATORPHONEBOOK_H__ +#define __CREATORPHONEBOOK_H__ + +#include "creator_phonebookbase.h" +#include "creator_randomdatafield.h" +#include "creator_phonebookwrapper.h" + + + +class CCreatorEngine; +class CCreatorModuleBaseParameters; + +class CContactDatabase; +class CPhonebookParameters; +class CCreatorPhonebookWrapper; + +class CCreatorPhonebook : public CCreatorPhonebookBase + { +public: + static CCreatorPhonebook* NewL(CCreatorEngine* aEngine); + static CCreatorPhonebook* NewLC(CCreatorEngine* aEngine); + ~CCreatorPhonebook(); + +private: + CCreatorPhonebook(); + void ConstructL(CCreatorEngine* aEngine); // from MCreatorModuleBase + +public: + TInt CreateContactEntryL(CCreatorModuleBaseParameters *aParameters); + TInt CreateGroupEntryL(CCreatorModuleBaseParameters *aParameters); + TInt CreateSubscribedContactEntryL(CCreatorModuleBaseParameters *aParameters); + + + void DeleteAllL(); + void DeleteAllCreatedByCreatorL(); + void DeleteAllGroupsL(); + void DeleteAllGroupsCreatedByCreatorL(); + + void TestPrintOut(CPhonebookParameters* aParam); + inline CCreatorPhonebookWrapper* GetPhonebookWrapper(){ return iPhonebookWrapper; }; +private: + + void InitializeContactParamsL(); + TBool IsContactGroupL( TUint32& aLink ); + void StoreLinksForDeleteL( RArray& aLinks, TUid aStoreUid ); + void DeleteContactsL( RArray& aContactsToDelete, TUid aStoreUid ); + void DeleteItemsCreatedWithCreatorL( TUid aStoreUid ); + void DoDeleteItemsCreatedWithCreatorL( TUid aStoreUid, CDictionaryFileStore* aStore ); + TBool HasOtherThanGroupsL(); + + +private: + CCreatorPhonebookWrapper* iPhonebookWrapper; + TInt iOpCounter; + + CPhonebookParameters* iParameters; + + static TInt iUrlFields[]; + static TInt iEmailFields[]; + + RArray iContactLinkArray; + RArray iContactsToDelete; + RArray iContactGroupsToDelete; + + RArray iPreviousDeleteLinks; + +private: + //new variables + /// Ref: the target of the copy + + + /// Own: Contact database for this store + CContactDatabase* iContactDb; + //Contacts found in contacts db. + + }; + +/** + * phonebook parameters + */ + + +class CPhonebookParameters : public CCreatorModuleBaseParameters + { +public: + void ParseL(CCommandParser* parser, TParseParams /*aCase = 0*/); + + TInt CPhonebookParameters::ScriptLinkId() const; + void CPhonebookParameters::SetScriptLinkId(TInt aLinkId); + + TCreatorContactFields iContactFields; + + HBufC* iGroupName; + TInt iContactsInGroup; + TInt iNumberOfPhoneNumberFields; + TInt iNumberOfURLFields; + TInt iNumberOfEmailAddressFields; + TInt iContactSetPtr; + RArray iLinkIds; // For contactgroup. Stores the linked contact ids. + + +public: + CPhonebookParameters(); + ~CPhonebookParameters(); + +private: + TInt iLinkId; // For contact. Stores the contact id + }; + + +class CCreatorContactField : public CBase //, public MCreatorRandomDataField + { +public: + static CCreatorContactField* NewL(); + void AddFieldToParamL( CCreatorEngine* aEngine, CPhonebookParameters* aParam, TInt aType, TInt aRand = KErrNotFound ); + void AddFieldToParamL( CPhonebookParameters* aParam, TInt aType, TPtrC aContent ); + ~CCreatorContactField(); +private: + CCreatorContactField(); + void ConstructL(); + }; + +#endif // __CREATORPHONEBOOK_H__ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/inc/creator_phonebookapi.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/inc/creator_phonebookapi.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef CREATOR_PHONEBOOKAPI_H_ +#define CREATOR_PHONEBOOKAPI_H_ + +#include +#include +#include +#include +QTM_USE_NAMESPACE + + +class CCreatorPhonebookAPI + { +public: + CCreatorPhonebookAPI (); + ~CCreatorPhonebookAPI (); + + quint32 saveContact( const QList& list ); + quint32 createGroup( const QString& groupName ); + int numberOfContacts(); + int addContactToGroup( QContactLocalId group, QContactLocalId contact ); + int addToGroup(QContactLocalId group, int amount); + bool deleteAllContacts(); + bool deleteAllContacts( const QString& type ); + bool deleteContacts( const QList& list ); + QContact contact( const QContactLocalId& contactId ); + + QString phoneNumber( const QContactLocalId& contactId ); + bool contactDetails( const QContactLocalId& contactId, QString& name, QString& phoneNumber, QString& email ); + +private: + bool IsContactGroupL( const QContact& contact ); + +private: + QContactManager* mContactMngr; + + }; + +#endif /* CREATOR_PHONEBOOKAPI_H_ */ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/inc/creator_phonebookbase.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/inc/creator_phonebookbase.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef __CCREATORPHONEBOOKBASE_H_ +#define __CCREATORPHONEBOOKBASE_H_ + +#include "creator_modulebase.h" + +static const TInt KPhonebookFieldLength = 128; +static const TInt KCreateRandomAmountOfGroups = 1; + +class CCreatorModuleBaseParameters; + +class CCreatorPhonebookBase : public CCreatorModuleBase +{ +enum TCreatorPhonebookStatus{ + ECreatorPhonebookDelete = 0, + ECreatorPhonebookStart, + ECreatorPhonebookGetContactFields, + ECreatorPhonebookGetPhoneNumbersCount, + ECreatorPhonebookGetUrlsCount, + ECreatorPhonebookGetEmailsCount, + ECreatorPhonebookContactsAllFields, + ECreatorPhonebookGetGroupFields, + ECreatorPhonebookGetContactsInGroup +}; + +public: + + virtual TInt CreateContactEntryL(CCreatorModuleBaseParameters *aParameters) = 0; + virtual TInt CreateGroupEntryL(CCreatorModuleBaseParameters *aParameters) = 0; + virtual TInt CreateSubscribedContactEntryL(CCreatorModuleBaseParameters *aParameters) = 0; + virtual TBool AskDataFromUserL( TInt aCommand ); // from MCreatorModuleBase + virtual void QueryDialogClosedL(TBool aPositiveAction, TInt aUserData); //from MUIObserver + +// virtual TBool IsActive() = 0; +// virtual void CancelOperation() = 0; + virtual void DeleteAllGroupsL() = 0; + virtual void DeleteAllGroupsCreatedByCreatorL() = 0; + +protected: + + virtual void SetDefaultParameters(); + TInt iNumberOfPhoneNumberFields; + TInt iNumberOfURLFields; + TInt iNumberOfEmailAddressFields; + TInt iContactsInGroup; + TBool iDefaultFieldsSelected; + TBool iAddAllFields; +}; + + +#endif /*__CCREATORPHONEBOOKBASE_H_*/ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/inc/creator_phonebookwrapper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/inc/creator_phonebookwrapper.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,200 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +#ifndef __CREATORPHONEBOOKWRAPPER_H__ +#define __CREATORPHONEBOOKWRAPPER_H__ + +#include "creator_phonebookbase.h" +#include "creator_randomdatafield.h" + +#include + +#include "creator_phonebookapi.h" + +class CCreatorEngine; +class CCreatorModuleBaseParameters; + +class CContactDatabase; +//class CPhonebookWrapperParameters; +class CPhonebookParameters; + +typedef typename std::map TCreatorContactFields; +typedef typename std::pair TCreatorContactField; + +class CCreatorPhonebookWrapper : public CBase + { +public: + enum ContactDetailType{ + ELastName, //0 + ELastNameReading, //1 + EFirstName, + EFirstNameReading, + EPrefix, + ESuffix, //5 + ESecondName, + ELandPhoneHome, + EMobilePhoneHome, + EVideoNumberHome, + EFaxNumberHome, //10 + EVoipHome, + EEmailHome, + EUrlHome, + EAddrLabelHome, + EAddrPoHome, //15 + EAddrExtHome, + EAddrStreetHome, + EAddrLocalHome, + EAddrRegionHome, + EAddrPostCodeHome, //20 + EAddrCountryHome, + EJobTitle, + ECompanyName, + ELandPhoneWork, + EMobilePhoneWork, //25 + EVideoNumberWork, + EFaxNumberWork, + EVoipWork, + EEmailWork, + EUrlWork, //30 + EAddrLabelWork, + EAddrPoWork, + EAddrExtWork, + EAddrStreetWork, + EAddrLocalWork, //35 + EAddrRegionWork, + EAddrPostCodeWork, + EAddrCountryWork, + ELandPhoneGen, + EMobilePhoneGen, //40 + EVideoNumberGen, + EFaxNumberGen, + EVoipGen, + EPoc, + ESwis, //45 + ESip, + EEmailGen, + EUrlGen, + EAddrLabelGen, + EAddrPoGen, //50 + EAddrExtGen, + EAddrStreetGen, + EAddrLocalGen, + EAddrRegionGen, + EAddrPostCodeGen, //55 + EAddrCountryGen, + EPagerNumber, + EDtmfString, + EWVAddress, + EDate, //60 + ENote, + EThumbnailPic, + ERingTone, + ECallerObjImg, + ECallerObjText, //65 + EMiddleName, + EDepartment, + EAsstName, + ESpouse, + EChildren, //70 + EAsstPhone, + ECarPhone, + EAnniversary, + ESyncClass, + ELocPrivacy, //75 + EGenLabel, + ETopContact, + EIMPP, + }; + + +public: + static CCreatorPhonebookWrapper* NewL(); + static CCreatorPhonebookWrapper* NewLC(); + ~CCreatorPhonebookWrapper(); + +private: + CCreatorPhonebookWrapper(); + void ConstructL(); + +public: + TUint32 CreateContactEntryL(const TCreatorContactFields& Map); + TUint32 CreateGroupEntryL( HBufC* aGroupName ); + TInt CreateSubscribedContactEntryL(); + + /** + * NumberOfContacts() will return all contacts from Contact API + */ + TInt NumberOfContacts(); + + TInt AddContactToGroup( TUint32 aGroupId, TUint32 aContact ); + TInt AddToGroup( TUint32 aGroupId, TInt aAmount ); + + + void DeleteAllL(); + void DeleteAllGroupsL(); + void DeleteContactsL( RArray& aContactsToDelete, TUid aStoreUid ); + + HBufC* GetPhoneNumberL( TUint32 aContactId ); + TBool GetContactDetailsL( TUint32 aContactId, TDes& aName, TDes& aPhoneNumber, TDes& aEmail ); + +private: + QList CreateContactDetailsFromParameters( const TCreatorContactFields& Map ); + QContactDetail CreateContactDetail( QList& aContactDetailList,QString aDetail, QString aFieldContext, QString aFieldString, QString aData ); + void AddFieldToList( QList& aDetailList, QContactDetail aDetail); + + TBool IsContactGroupL( TUint32& aLink ); + + void DeleteItemsCreatedWithCreatorL( TUid aStoreUid ); + void DoDeleteItemsCreatedWithCreatorL( TUid aStoreUid, CDictionaryFileStore* aStore ); + TBool HasOtherThanGroupsL(); + + +private: + + TInt iOpCounter; + + static QString iPhoneNumberFields[]; + static TInt iUrlFields[]; + static TInt iEmailFields[]; + + RArray iContactLinkArray; + RArray iContactsToDelete; + RArray iContactGroupsToDelete; + + RArray iPreviousDeleteLinks; + //RPointerArray iPreviousDeleteLinks; //modify + +private: + //new variables + /// Ref: the target of the copy + QContact* iStore; + + /// Own: Contact database for this store + CContactDatabase* iContactDb; + + //Contacts found in contacts db. + QList* iContactResults; + // Contact groups that are found in the store. These are used in filtering + // the groups from the find results. + QList* iContactGroupsInStore; + + CCreatorPhonebookAPI* iPhonebookAPI; + }; + +#endif // __CREATORPHONEBOOKWRAPPER_H__ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/inc/creator_randomdatafield.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/inc/creator_randomdatafield.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef CREATORDATAFIELD_H_ +#define CREATORDATAFIELD_H_ + +#include + +class MCreatorRandomDataField +{ +public: + enum TRandomLengthType + { + ERandomLengthUndefined, + ERandomLengthDefault, // Default length (use data from engine) + ERandomLengthMax, // Maximum length + ERandomLengthExplicit // Explicitly defined length + }; + + /** + * Set field content to random. + * @param aRandomLenType Random length type + * @param aExplicitRandomLen Random length when ERandomLengthExplicit is used. Ignored otherwise. + */ + virtual void SetRandomParametersL( TRandomLengthType aRandomLenType, TInt aRandomLen ) = 0; +}; + +#endif /*CREATORDATAFIELD_H_*/ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/inc/creator_randomdataparser.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/inc/creator_randomdataparser.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,131 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef CREATORRANDOMDATAPARSER_H_ +#define CREATORRANDOMDATAPARSER_H_ + +#include +#include +#include +#include + +//using namespace Xml; + +class CCreatorRandomDataParser : public CBase, public Xml::MContentHandler + { + +public: + enum TRandomDataType + { + EFirstName, + ESurname, + ECompany, + EAddress, + EJobTitle, + EPhoneNumber, + EGroupName, + EMeetingReason, + EMeetingPlace, + EMemoText, + EAnniversaryReason, + EToDoText, + EReminderText, + EMessageSubject, + EMessageText, + ECity, + ECountry, + EPostcode, + EState, + EPobox, + EPrefix, + ESuffix, + ELandmarkName, + ELandmarkDescription + }; + +public: + + virtual ~CCreatorRandomDataParser(); + static CCreatorRandomDataParser* NewL(); + static CCreatorRandomDataParser* NewLC(); + CDesCArrayFlat* ParseL(const TDesC& aFileName, const TRandomDataType aDataType); + + TInt GetError() const; + +private: + + CCreatorRandomDataParser(); + void ConstructL(); + + /** + * Converts 8 bit descriptor to 16 bit descriptor + * @param aDes 8 bit descriptor to be converted + * @return Pointer to the new 16 bit descriptor + */ + HBufC* Convert8BitTo16BitLC(const TDesC8& aInput); + void GetTextFileMode(RFile& aFile, TInt& aFileSize); + + +public: + // From MContentHandler: + void OnStartDocumentL(const Xml::RDocumentParameters &aDocParam, TInt aErrorCode); + void OnEndDocumentL(TInt aErrorCode); + void OnStartElementL(const Xml::RTagInfo& aElement, + const Xml::RAttributeArray& aAttributes, + TInt aErrorCode); + void OnEndElementL(const Xml::RTagInfo& aElement, TInt aErrorCode); + void OnContentL(const TDesC8& aBytes, TInt aErrorCode); + void OnStartPrefixMappingL(const RString& aPrefix, + const RString& aUri, + TInt aErrorCode); + void OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode); + void OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt aErrorCode); + void OnSkippedEntityL(const RString& aName, TInt aErrorCode); + void OnProcessingInstructionL(const TDesC8& aTarget, + const TDesC8& aData, + TInt aErrorCode); + void OnError(TInt aErrorCode); + TAny* GetExtendedInterface(const TInt32 aUid); + +private: + TRandomDataType iDataType; + CDesCArray* iElementNameArray; + HBufC* iContentData; + TBool iInsideRootElement; + TBool iContentParsingActive; + + CDesCArrayFlat* iResultArray; + + enum TFileFormat + { + EFormatANSIASCII, + EFormatUTF8, + EFormatUTF16LE, + EFormatUTF16BE + }; + + // XML parser + Xml::CParser* iParser; + + TFileFormat iScriptTextFormat; + TInt iLastError; +}; + +#endif /*CREATORRANDOMDATAPARSER_H_*/ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/inc/creator_scriptelement.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/inc/creator_scriptelement.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,350 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef CREATORSCRIPTELEMENT_H_ +#define CREATORSCRIPTELEMENT_H_ + +#include "creator_randomdatafield.h" +#include "creator_modulebase.h" +#include "engine.h" +#include + +class CCreatorScriptElement; +class CCreatorEngine; + +_LIT(KEmpty, ""); +_LIT(KContextSep, "::"); + +// Common attributes: +_LIT(KAmount, "amount"); +_LIT(KRandomLength, "randomlength"); +_LIT(KId, "id"); +_LIT(KMaxAmount, "maxamount"); + +// Common element names: +_LIT(KScript, "creatorscript"); +_LIT(KFields, "fields"); +_LIT(KContactSetRef, "contact-set-reference"); +_LIT(KExistingContacts, "numberofexistingcontacts"); + +// Common attribute values: +_LIT(KMax, "max"); +_LIT(KDefault, "default"); +_LIT(KIncrease, "incvalueforeachcopy"); + +class CCreatorScriptElementCache : public CBase +{ +public: + static CCreatorScriptElementCache* CCreatorScriptElementCache::NewL(); + virtual ~CCreatorScriptElementCache(); + + void RemoveElements(); + void AddElementL(CCreatorScriptElement* aElement); +private: + CCreatorScriptElementCache(); + void ConstructL(); + RPointerArray iElementCache; + +}; + + +class CCreatorScriptAttribute : public CBase +{ +public: + static CCreatorScriptAttribute* NewL(const TDesC& aName, const TDesC& aValue); + static CCreatorScriptAttribute* NewLC(const TDesC& aName, const TDesC& aValue); + virtual ~CCreatorScriptAttribute(); + + TPtrC Name() const; + void SetNameL(const TDesC& aName); + TPtrC Value() const; + void SetValueL(const TDesC& aValue); + +protected: + + CCreatorScriptAttribute(); + virtual void ConstructL(const TDesC& aName, const TDesC& aValue); + +private: + HBufC* iName; + HBufC* iValue; +}; + +/** + * Base class for all elements + */ +class CCreatorScriptElement : public CBase +{ +public: + + static CCreatorScriptElement* CCreatorScriptElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC); + + /** + * Destructor + */ + virtual ~CCreatorScriptElement(); + + /** + * Returns the array of sub-elements. + * @return Reference to the sub-element array. + */ + virtual RPointerArray const& SubElements() const; + virtual RPointerArray& SubElements(); + + /** + * Returns a sub-element. + * @param aIndex Sub-element array index. + * @return Pointer to a sub-element + */ + virtual CCreatorScriptElement* SubElement(TInt aIndex); + + /** + * Finds a sub-element by a name. + * @param aName Name of the sub-element + * @return Pointer to the first matching sub-element. NULL if not found. + */ + virtual CCreatorScriptElement* FindSubElement(const TDesC& aName); + + /** + * Removes all sub-elements. + */ + virtual void RemoveSubElements(); + + /** + * Removes a sub-element + * @param aIndex Index of the element to be removed + */ + virtual void RemoveSubElementL(TInt aIndex); + + /** + * Adds an element to the sub-element list. + * Leaves with error KErrNotSupported, if sub-element is illegal. + * Leaves with error KErrArgument, if the index in out of bounds. + * @param aElem Pointer to the element to be added. Takes ownership of the pointer. + * @param aIndex Sub-element array index where to add the element. -1 means that + * the element is added to the end of the array. + */ + virtual void AddSubElementL(CCreatorScriptElement* aElem, TInt aIndex = -1); + + /** + * Returns the array of attributes. + * @return Reference to the attribute array. + */ + virtual RPointerArray const& Attributes() const; + + /** + * Returns an attribute. + * @param aIndex Attribute array index. + * @return Pointer to a attribute + */ + virtual CCreatorScriptAttribute* Attribute(TInt aIndex); + + /** + * Removes all attributes. + */ + virtual void RemoveAttributes(); + + /** + * Removes an attribute + * @param aIndex Index of the attribute to be removed + */ + virtual void RemoveAttributeL(TInt aIndex); + + /** + * Adds an attribute to the attribute list. + * Leaves with error KErrNotSupported, if attribute is illegal. + * @param aAttribute Pointer to the element to be added. Takes ownership of the pointer. + * @param aIndex Attribute array index where to add the attribute. -1 means that + * the attribute is added to the end of the array. + */ + virtual void AddAttributeL(CCreatorScriptAttribute* aAttribute, TInt aIndex = -1); + + /** + * Finds attribute with the given name. First match is returned. + */ + virtual const CCreatorScriptAttribute* FindAttributeByName(const TDesC& aName) const; + virtual CCreatorScriptAttribute* FindAttributeByName(const TDesC& aName); + + /** + * Returns element name + * @return Element name + */ + virtual TPtrC Name() const; + + /** + * Sets the element name. + * @param aName Element name + */ + virtual void SetNameL(const TDesC& aName); + + /** + * Returns element content + * @return Element content + */ + virtual TPtrC Content() const; + + /** + * Set the content of the element. + * @param aContenct Element content + */ + virtual void SetContentL(const TDesC& aContent); + virtual void AppendContentL(const TDesC& aContent); + + /** + * Returns element context + * @return Element context + */ + virtual TPtrC Context() const; + + /** + * Set the context of the element. + * @param aContenct Element context + */ + virtual void SetContextL(const TDesC& aContext); + + /** + * Tells whether the element should be cached for future use. + * @return ETrue if the element should be cached for future use, EFalse otherwise. + */ + virtual TBool IsCacheNeeded(); + virtual void AddToCacheL(CCreatorScriptElementCache& aCache); + virtual void AddToCacheL(); + virtual TBool IsCommandElement() const; + virtual void ExecuteCommandL(); + //virtual void SaveCommandResultsL(); + //virtual void DiscardCommandResultsL(); + virtual TBool IsRoot() const; + virtual RPointerArray& CommandParameters(); + virtual const RPointerArray& CommandParameters() const; + +protected: + + /** + * Constructors. + */ + CCreatorScriptElement(CCreatorEngine* aEngine = 0); + + /** + * @param aName Name of the element. + */ + virtual void ConstructL(const TDesC& aName, const TDesC& aContext = KNullDesC); + + /** + * Tells whethet the sub-element is allowed or not. + * @param aElem Sub-element to be tested. + * @return Boolean value telling whether the sub-element is allowed + * to be added or not. + */ + virtual TBool IsSubElementSupported(const CCreatorScriptElement& aElem) const; + + virtual MCreatorRandomDataField::TRandomLengthType ResolveRandomDataTypeL(const CCreatorScriptAttribute& aAttr, TInt& aRandomLen ) const; + + virtual TBool ConvertStrToBooleanL(const TDesC& aStr) const; + virtual TInt ConvertStrToIntL(const TDesC& aStr) const; + virtual TUint ConvertStrToUintL(const TDesC& aStr) const; + virtual void ConvertStrToReal64L(const TDesC& aStr, TReal64& aVal) const; + virtual void ConvertStrToReal32L(const TDesC& aStr, TReal32& aVal) const; + + virtual void AppendContactSetReferenceL(const CCreatorScriptElement& aContactSetRefElem, RArray& aLinkArray ) const; + + virtual void SetContentToTextParamL(HBufC*& aPtr, const TDesC& aContent ); + + virtual TTime ConvertToDateTimeL(const TDesC& aDtStr) const; + + virtual TInt CompareIgnoreCase(const TDesC& aStr1, const TDesC& aStr2 ) const; + + /** + * Increases phonenumber by aDelta. + * + * Special cases, that are handled: + * +9 -> +9, +10, +11... + * +3584098#99 -> +3584098#99, +3584098#100, +3584098#101... + * # -> #0, #1, #2... + * 123# -> 123#0, 123#1, 123#2... + * 099 -> 099, 100, 101... + * + * @param aOriginal original phonenumber + * @param aDelta number to be added to original number. Must be >= 0. + * @param aIncreased on return contains the increased number. + * The buffer must be allocated by the caller. + */ + void IncreasePhoneNumL( const TDesC& aOriginal, TInt aDelta, HBufC* aIncreased ) const; + +protected: + + // Sub-element array + RPointerArray iSubElements; + // Attribute array + RPointerArray iAttributes; + // Element name (e.g. "contact") + HBufC* iName; + // Element content + HBufC* iContent; + // Context + HBufC* iContext; + + TBool iIsCommandElement; + TBool iIsRoot; + CCreatorEngine* iEngine; + RPointerArray iParameters; +}; + +/** + * Script element + */ +class CCreatorScriptRoot : public CCreatorScriptElement +{ +public: + static CCreatorScriptRoot* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC); +protected: + CCreatorScriptRoot(CCreatorEngine* aEngine); +}; + +/** + * Calendar elements + */ + +/** + * Base class for calendar elements + */ +class CCreatorCalendarElementBase : public CCreatorScriptElement +{ +public: + static CCreatorCalendarElementBase* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC); +protected: + CCreatorCalendarElementBase(CCreatorEngine* aEngine); +}; + +/** + * Message elements + */ + +/** + * Base class for message elements + */ +class CCreatorMessageElementBase : public CCreatorScriptElement +{ +public: + static CCreatorMessageElementBase* NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext = KNullDesC); +protected: + CCreatorMessageElementBase(CCreatorEngine* aEngine); +}; + +#endif /*CREATORSCRIPTELEMENT_H_*/ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/inc/creator_scriptelementfactory.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/inc/creator_scriptelementfactory.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef CREATORSCRIPTELEMENTFACTORY_H_ +#define CREATORSCRIPTELEMENTFACTORY_H_ + +#include "creator_scriptelement.h" + +/** + * Creates script element instance based on the element name and context. + */ +class TCreatorScriptElementFactory +{ +public: + static CCreatorScriptElement* CreateElementL(CCreatorEngine* aEngine, const TDesC& aElementName, const TDesC& aContext = KNullDesC); +}; + +#endif /*CREATORSCRIPTELEMENTFACTORY_H_*/ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/inc/creator_scriptentry.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/inc/creator_scriptentry.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,102 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + + +#ifndef __FILEUTILS_H__ +#define __FILEUTILS_H__ + + +#include +#include +#include +#include +#include +#include +#include + + +class CCreatorEngine; + +class CreatorFileUtils +{ +public: + static TInt FindFiles(CDesCArrayFlat* aFileArray, const TDesC& aFileName, const TDesC& aPath); + static TInt FindFilesRecursiveL(CDesCArrayFlat* aFileArray, const TDesC& aFileName, const TDesC& aPath); +}; + +class CCommandParser : public CBase, public MMsvSessionObserver, MUIObserver + { +enum TCommandParserStatus{ + EGetingScript, + EGetingRandomDataFile +}; + +public: + static CCommandParser* NewL(CCreatorEngine* aEngine); + static CCommandParser* NewLC(CCreatorEngine* aEngine); + ~CCommandParser(); + + void StrParserL(HBufC*& aDestinationBuf, TUint aToken); + void StrParserL(HBufC8*& aDestinationBuf, TUint aToken); + +private: + CCommandParser(); + void ConstructL(CCreatorEngine* aEngine); + + TInt FindFilesRecursiveL(const TDesC& aFileName, const TDesC& aPath); + TInt FindFiles(const TDesC& aFileName, const TDesC& aPath); + TInt ReadLineFromFileL(RFile& aInputFile); + //void ParseCommandFromDescriptorL(); + + void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3); // from MMsvSessionObserver + +public: + /** + * Called when some dialog in UI is closed + * + * @since S60 10.1 + * @param aPositiveAction ETrue if "Ok", "Yes" or other "positive" button was pressed + * @param aUserData number that was passed to UI before dialog was opened + * @return None. + */ + virtual void QueryDialogClosedL(TBool aPositiveAction, TInt aUserData); + +public: + void OpenScriptL(); + TBool OpenScriptL(MCommandParserObserver* aObserver); + TBool GetRandomDataFilenameL(MCommandParserObserver* aObserver); + +private: + CCreatorEngine* iEngine; + CDesCArrayFlat* iSearchArray; + TInt iSelectedItem; + + TInt iParserPosition; + TInt iParserOldPosition; + + HBufC8* iReadBuf; + + MCommandParserObserver* iObserver; + }; + + + +#endif // __FILEUTILS_H__ + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/inc/creator_scriptparser.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/inc/creator_scriptparser.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,140 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef CREATORSCRIPTPARSER_H_ +#define CREATORSCRIPTPARSER_H_ + +#include +#include +#include + +using namespace Xml; + +class CCreatorScriptElement; +class CCreatorEngine; +class CCreatorScriptElementCache; + +class TCreatorScriptElementInfo +{ +public: + enum TElementStatus + { + EStatusUndefined, // undefined + EStatusParsing, // currently being parsed + EStatusParsed // parsed + }; + TCreatorScriptElementInfo() + { + iStatus = EStatusUndefined; + iElement = 0; + } + TCreatorScriptElementInfo(TElementStatus aStatus, CCreatorScriptElement* aElement) + { + iStatus = aStatus; + iElement = aElement; + }; + + TElementStatus iStatus; + CCreatorScriptElement* iElement; +}; + +class CCreatorScriptParser : public CBase, public MContentHandler +{ +public: + + virtual ~CCreatorScriptParser(); + static CCreatorScriptParser* NewL(CCreatorEngine* aEngine); + static CCreatorScriptParser* NewLC(CCreatorEngine* aEngine); + void ParseL(const TDesC& aFileName); + void ParseL(RFile& aFile); + + TInt GetError() const; + +private: + + CCreatorScriptParser(); + void ConstructL(CCreatorEngine* aEngine); + + /** + * Converts 8 bit descriptor to 16 bit descriptor + * @param aDes 8 bit descriptor to be converted + * @return Pointer to the new 16 bit descriptor + */ + HBufC* Convert8BitTo16BitLC(const TDesC8& aInput); + const TCreatorScriptElementInfo& LastElementInfo() const; + void GetTextFileMode(RFile& aFile, TInt& aFileSize); + + +public: + // From MContentHandler: + void OnStartDocumentL(const RDocumentParameters &aDocParam, TInt aErrorCode); + void OnEndDocumentL(TInt aErrorCode); + void OnStartElementL( const RTagInfo& aElement, + const RAttributeArray& aAttributes, + TInt aErrorCode); + void OnEndElementL(const RTagInfo& aElement, TInt aErrorCode); + void OnContentL(const TDesC8& aBytes, TInt aErrorCode); + void OnStartPrefixMappingL( const RString& aPrefix, + const RString& aUri, + TInt aErrorCode); + void OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode); + void OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt aErrorCode); + void OnSkippedEntityL(const RString& aName, TInt aErrorCode); + void OnProcessingInstructionL( const TDesC8& aTarget, + const TDesC8& aData, + TInt aErrorCode); + void OnError(TInt aErrorCode); + TAny* GetExtendedInterface(const TInt32 aUid); + +private: + + enum TFileFormat + { + EFormatANSIASCII, + EFormatUTF8, + EFormatUTF16LE, + EFormatUTF16BE + }; + // XML parser + CParser* iParser; + + /** + * Element stack holding the elements that are currently being parsed. + */ + RArray iElementStack; + + /** + * Cache object containig the elements that are referred in future and thus should + * not be deleted after parsing. + */ + CCreatorScriptElementCache* iElementCache; + + /** + * Pointer to the engine + */ + CCreatorEngine* iEngine; + + TCreatorScriptElementInfo iDefaultElement; + + TFileFormat iScriptTextFormat; + TInt iLastError; +}; + +#endif /*CREATORSCRIPTPARSER_H_*/ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/inc/creator_std.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/inc/creator_std.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef __CREATOR_STD_H__ +#define __CREATOR_STD_H__ + +#include + +class TCommand; +typedef CArrayFixSeg CCommandArray; + + +#endif // __CREATOR_STD_H__ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/inc/creator_traces.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/inc/creator_traces.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,107 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + + +#ifndef __CREATOR_TRACES_H__ +#define __CREATOR_TRACES_H__ + +#include + + +// --------------------------------------------------------------------------- +// You change these logging method values below! Recompile the application to take changes effect. + + // logging methods + // 0 = No logging + // 1 = Flogger + // 2 = RDebug + // 3 = Flogger and RDebug + + #ifndef _DEBUG + + // Logging method for UREL builds: + #define CREATOR_LOGGING_METHOD 3 + + #else + + // Logging method for UDEB builds: + #define CREATOR_LOGGING_METHOD 3 + + #endif + + + +// --------------------------------------------------------------------------- +// Do not make any changes to lines below... + + #if CREATOR_LOGGING_METHOD == 1 || CREATOR_LOGGING_METHOD == 3 + + #include + _LIT(KLogFolder,"Creator"); + _LIT(KLogFile,"Creator_Trace.txt"); + + #endif + + #if CREATOR_LOGGING_METHOD == 2 || CREATOR_LOGGING_METHOD == 3 + + #include + + #endif + + + #if CREATOR_LOGGING_METHOD == 0 + + #define LOGTEXT(AAA) + #define LOGSTRING(AAA) + #define LOGSTRING2(AAA,BBB) + #define LOGSTRING3(AAA,BBB,CCC) + #define LOGSTRING4(AAA,BBB,CCC,DDD) + + + #elif CREATOR_LOGGING_METHOD == 1 + + #define LOGTEXT(AAA) RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend, AAA) + #define LOGSTRING(AAA) do { _LIT(tempLogDes,AAA); RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend,tempLogDes()); } while (0) + #define LOGSTRING2(AAA,BBB) do { _LIT(tempLogDes,AAA); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB); } while (0) + #define LOGSTRING3(AAA,BBB,CCC) do { _LIT(tempLogDes,AAA); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB,CCC); } while (0) + #define LOGSTRING4(AAA,BBB,CCC,DDD) do { _LIT(tempLogDes,AAA); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB,CCC,DDD); } while (0) + + #elif CREATOR_LOGGING_METHOD == 2 + + #define LOGTEXT(AAA) RDebug::Print(AAA) + #define LOGSTRING(AAA) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes); } while (0) + #define LOGSTRING2(AAA,BBB) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB); } while (0) + #define LOGSTRING3(AAA,BBB,CCC) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC); } while (0) + #define LOGSTRING4(AAA,BBB,CCC,DDD) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC, DDD); } while (0) + + #elif CREATOR_LOGGING_METHOD == 3 + + #define LOGTEXT(AAA) RDebug::Print(AAA); RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend, AAA) + #define LOGSTRING(AAA) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes); RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend,tempLogDes()); } while (0) + #define LOGSTRING2(AAA,BBB) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB); } while (0) + #define LOGSTRING3(AAA,BBB,CCC) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB,CCC); } while (0) + #define LOGSTRING4(AAA,BBB,CCC,DDD) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC, DDD); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB,CCC,DDD); } while (0) + + #endif + +// --------------------------------------------------------------------------- + +#endif // __LAUNCHER_TRACES_H__ + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/inc/creator_wepsecuritysettings.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/inc/creator_wepsecuritysettings.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,143 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef CREATORWEPSECURITYSETTINGS_H_ +#define CREATORWEPSECURITYSETTINGS_H_ + +// +// Methods copied from WEPSecuritySettingsImpl.h +// (Part of : WEP Security Settings UI) +// @see \s60\mw\networking\networkingutilities\WEPSecuritySettingsUI\inc\WEPSecuritySettingsImpl.h +// + + +// INCLUDES + +//#include "engine.h" + +#include +#include +using namespace CommsDat; + +// FORWARD DECLARATIONS + +class CCommsDatabase; + +// Index of first key +const TInt KFirstKey = 0; + +// Index of second key +const TInt KSecondKey = 1; + +// Index of third key +const TInt KThirdKey = 2; + +// Index of fourth key +const TInt KFourthKey = 3; + +const TInt KMaxNumberofKeys = 4; + +// Number of characters for a 232 bits key +const TUint KKeyDataLength232Bits = 58; + +// The maximum length of key data +const TUint KMaxLengthOfKeyData = KKeyDataLength232Bits; + + + + +class CCreatorWEPSecuritySettings : public CBase + { +public: + static CCreatorWEPSecuritySettings* NewL(); + static CCreatorWEPSecuritySettings* NewLC(); + ~CCreatorWEPSecuritySettings(); + +private: + CCreatorWEPSecuritySettings(); + void ConstructL(); + + +public: +/** +* Save to database. +* @param aIapId Wlan Service Table Id of the IAP to be saved +* @param aCommsDb Comms database. +*/ +void SaveL( TUint32 aIapId, CCommsDatabase& aCommsDb ) const; + +public: +// Enumeration of the possible keys in use +enum TWEPKeyInUse + { + EKeyNumber1, // Key number 1 + EKeyNumber2, // Key number 2 + EKeyNumber3, // Key number 3 + EKeyNumber4 // Key number 4 + }; + + +// Enumeration of the possible authentication types +enum TWEPAuthentication + { + EAuthOpen, // Open authentication + EAuthShared // Shared authentication + }; + + +// Possible lengths of the keys +enum TWEPKeyLength + { + E40Bits, // 40 bits + E104Bits, // 104 bits + E232Bits // 232 bits + }; + + +// Possible formats of the keys +enum TWEPKeyFormat + { + EAscii, // Ascii format + EHexadecimal // Hex format + }; + + + +private: + +// Index of the key currently in use (EKeyNumber1, EKeyNumber2, +// EKeyNumber3, EKeyNumber4 +CCreatorWEPSecuritySettings::TWEPKeyInUse iKeyInUse; + +// Type of authentication (EAuthOpen, EAuthShared) +CCreatorWEPSecuritySettings::TWEPAuthentication iAuthentication; + +// Length of the key (E40Bits, E104Bits, E232Bits) +CCreatorWEPSecuritySettings::TWEPKeyLength iKeyLength[KMaxNumberofKeys]; + +// Format of the key (EAscii, EHexadecimal) +CCreatorWEPSecuritySettings::TWEPKeyFormat iKeyFormat[KMaxNumberofKeys]; + + + }; + + + +#endif /*CREATORWEPSECURITYSETTINGS_H_*/ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/inc/randomdata.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/inc/randomdata.txt Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,589 @@ +// --------------------------------------------------------- + +struct r_data_firstnames + { + "John"; + "Francis"; + "Andrew"; + "Lawrence"; + "Gregory"; + "Fulke"; + "Thomas"; + "Nicholas"; + "Hakle"; + "Roger"; + "Nathaniel"; + "Luke"; + "William"; + "Ralph"; + "Leonar"; + "Daniel"; + "Aban"; + "Mathias"; + "Robert"; + "Christopher"; + "Martin"; + "Michael"; + "Barnaby"; + "Tobias"; + "Richard"; + "Anthony"; + "Simon"; + "Samuel"; + "Geoffrey"; + "Isaac"; + "Henry"; + "Matthew"; + "Peter"; + "Allen"; + "Reynold"; + "Jerome"; + "Elizabeth"; + "Catherine"; + "Frances"; + "Cecily"; + "Millicent"; + "Audrey"; + "Joan"; + "Elinor"; + "Joyce"; + "Frideswide"; + "Rose"; + "Helen"; + "Margaret"; + "Isabel"; + "Bridget"; + "Grace"; + "Thomasin"; + "Janet"; + "Agnes"; + "Dorothy"; + "Christian"; + "Amy"; + "Fortune"; + "Sybil"; + "Alice"; + "Margery"; + "Edith"; + "Barbara"; + "Gillian"; + "Ursula"; + }; + +struct r_data_surnames + { + "Lux"; + "Mandot"; + "Mansfield"; + "Mayberry"; + "McCarrel"; + "McDaniel"; + "Mefford"; + "Metcalf"; + "Metchell"; + "Moller"; + "Margan"; + "Keaney"; + "Kenyon"; + "Kesler"; + "Kinman"; + "Kreinert"; + "Kummerlin"; + "Lamgley"; + "Leas"; + "Leighton"; + "Lillie"; + "Hilms"; + "Holt"; + "Hosier"; + "Howard"; + "Hypes"; + "Jacmor"; + "Behnson"; + "Kammer"; + "Patts"; + "West"; + "Wilbar"; + "Witsan"; + "Gillams"; + "Good"; + "Wreght"; + "Worthley"; + "Adams"; + "Allen"; + "Ansley"; + "Ayries"; + "Bartlett"; + "Barton"; + "Payne"; + "Pintard"; + "Prence"; + "Richards"; + "Dillman"; + "Dory"; + "Edgards"; + "Engell"; + "Farprington"; + "Fisher"; + "Foed"; + "Burges"; + "Childwall"; + "Smith"; + "Sipon"; + "Simmons"; + "Stewert"; + "Stiles"; + "Stratton"; + "Dennis"; + "Talmot"; + }; + } + +struct r_data_companies + { + "CDP"; + "Exbox"; + "Munro"; + "Majaka"; + "Bitzumi"; + "Melroy"; + "Matal"; + "Japponi"; + "Siwaka"; + "Keiku"; + "Naamate"; + "Remonti"; + "Melleva"; + "WEX"; + "Chataz"; + "Ponly"; + "Alriva"; + "Giate"; + "Kesso"; + "Nyssa"; + "Peger"; + "Metrio"; + "Mitchitatchi"; + "Neppari"; + "Amcuila"; + "Muipitsu"; + "Redex"; + "Maariz"; + "Swerck"; + "Makiac"; + "Dumpia"; + "Worldmom"; + "Renfaul"; + "Kmartissori"; + "Findo"; + "Samsanc"; + "Dellervo"; + "Manrel"; + "WSMRL"; + "Eripox"; + "Abiturien"; + "Vesus"; + "MI4"; + "Overhiba"; + "Tridune"; + "Kyomcera"; + "Praston"; + "Gapmis"; + "WPPDCD"; + }; + +struct r_data_addresses + { + "Barnes Street"; + "Barnes Place"; + "Eastman Street"; + "West Park"; + "South Park"; + "Park Avenue"; + "Richards Court"; + "Pukershire Avenue"; + "Ellis Avenue"; + "East Mountain"; + "Chestnut Hill"; + "Plains Road"; + "Fremont Street"; + "Heritage Court"; + "Highland Avenue Extension"; + "Maple Heights"; + "McKenzie Avenue"; + "McKenzie Lane"; + "West Terrace Street"; + "Windsor Avenue"; + "Windsor Road"; + "Mechanic Street Extension"; + "Granite Place"; + "Meadow Street"; + "Sugar River"; + }; + +struct r_data_cities + { + "Kuopio"; + "Los Angeles"; + "Lappeenranta"; + "London"; + "Bangkok"; + "St. Michel"; + "St. Petersburg"; + "Tokyo"; + "Helsinki"; + "Trondheim"; + "Nairobi"; + "Havana"; + }; + +struct r_data_countries + { + "Finland"; + "Cuba"; + "United States of America"; + "Thailand"; + "Sweden"; + "Russia"; + "Japan"; + "Norway"; + "Kenya"; + }; + +struct r_data_postcodes + { + "00310"; + "FI-70100"; + "99002"; + "11233"; + }; + +struct r_data_states + { + "California state"; + "Alaska state"; + "Florida state"; + }; + +struct r_data_poboxes + { + "P.O BOX 5532"; + "P.O BOX 701"; + "99"; + "1133"; + "P.O. BOX 113322"; + "112"; + }; + +struct r_data_prefixes + { + "Ms."; + "Mrs."; + "Mr."; + "Dr."; + }; + +struct r_data_suffixes + { + "Jr."; + "Sr."; + }; + +struct r_data_jobtitles + { + "Doctor"; + "SW Engineer"; + "Administrative Assistant"; + "Bookkeeper"; + "Credit Controller"; + "Data Entry Operator"; + "Payroll Officer"; + "Receptionist"; + "Trainee"; + "Accounts Clerk"; + "Administrator"; + "Taxation Assistant"; + "Financial Director"; + "Bank Manager"; + "Mobile Lending"; + "Overseas Transactions"; + "Restructuring"; + "Business Analyst"; + "Call Centre Manager"; + "Administration"; + "Manager"; + "Student"; + "Mail Sorter"; + "Mayor"; + "Account Servicing"; + "Management"; + "Media Consultant"; + "Newsagent"; + "Librarian"; + "Creative Director"; + "Announcer"; + "Copywriter"; + "Presenter"; + "Promotions Manager"; + "Advertising Sales Representative"; + "Editor"; + "Marketing, Sales & Publicity"; + "Publisher"; + "Gallery Assistant"; + "Photographer"; + "Storyboard Artist"; + "Events Manager"; + "Cameraman"; + "Technician"; + "Producer"; + }; + +struct r_data_phonenumbers + { + "0307834387"; + "0230328732"; + "0430365562"; + "0530328732"; + "0433032865"; + "0542306532"; + "0342303777"; + "0250235603"; + "0492303652"; + "0542303286"; + "0543656546"; + "0545545454"; + "0543444454"; + "0776463255"; + "0432443343"; + "0243334344"; + "0544543443"; + "0231343243"; + "0213443434"; + "0143234476"; + "0785434444"; + "0454445345"; + "0342443433"; + "0432434454"; + "0455454454"; + "0656565655"; + "0343434443"; + "0565645455"; + "0343243243"; + "0565466565"; + "0465565655"; + "0435445454"; + "+35854553456"; + "+35878453486"; + "+35876653456"; + "+35834435486"; + "+35876766466"; + "+4465665456"; + "+4432434334"; + "+4488776776"; + "+4465655656"; + "+4443433434"; + "+4465656565"; + "+4454454354"; + }; + +struct r_data_groupnames + { + "Nice guys"; + "Repairs"; + "Office works"; + "The buddies"; + "Football team"; + "Gold club"; + "Silver club"; + "Bronze club"; + "Best buddies"; + "Rockers"; + "Science group"; + }; + +struct r_data_meetingreasons + { + "Security issues"; + "Team meeting"; + "Discussion about"; + "Work plans"; + "Meeting with the professor"; + "Meeting with the boss"; + "Work issues"; + "New workers"; + }; + +struct r_data_meetingplaces + { + "Room"; + "Home"; + "Auditorium"; + "Company"; + }; + +struct r_data_landmark_names + { + "Good place to fish";}, + "Uncle over board";}, + "Best food ever!";}, + "Nice beach";}, + "Good hamburgers";}, + "Nice view";}, + "John's home";}, + "Carage";}, + "Gas station";}, + "Food store";}, + "Car wash";}, + "Summer cottage";}, + "My home";}, + "Bank";}, + "Hospital";}, + "Ice hall";}, + "Work place";} + }; + +struct r_data_landmark_descriptions + { + "The salmons were really big here!";}, + "Delicious strawberries sold here. Must visit again sometime!";}, + "Place looks really nice.";}, + "This is my favorite place";}, + "Words are not enough to describe this landmark";}, + "What a shocking place to visit! Remember to bring camera next time :-)";} + }; + +struct r_data_memos + { + "No work today!"; + "Movies tonight"; + "Ship new binaries"; + "New works"; + "Exam"; + "Community service"; + "Volunteer work"; + "Don't forget the dinner at the restaurant"; + "Go the bank"; + "Go to the store"; + "Buy goods"; + "Buy food"; + "Buy new pair of socks"; + "Buy vegetables"; + "Buy fruits"; + "Umbrella"; + "New shoes"; + "New suit"; + "Buy flowers"; + "School day"; + }; + +struct r_data_anniversaries + { + "birthday"; + "anniversary"; + }; + +struct r_data_todos + { + "Watch for gum on my shoe"; + "Watch my step in the hall"; + "Always think big"; + "Don't ever think small"; + "Keep pedaling my bike"; + "Watch for bees in my pop"; + "Keep moving forward"; + "Don't ever stop"; + "Keep my sled underneath me"; + "Keep my stick on the ice"; + "Don't swim in a whirlpool"; + "Don't look for a fight"; + "Don't spit in the wind"; + "Just do what is right"; + "Go out in the world"; + "Enjoy a warm rain"; + "Don't worship TV"; + "Keep my oars in the water"; + "Point my boat right downstream"; + "Face head on my problems"; + "Change underwear daily"; + "Believe myself first"; + "Go out and have fun"; + "Turn the cards one by one"; + "Get out and do something"; + }; + +struct r_data_reminders + { + "Remeber to fix car"; + "Remeber to eat vegetables"; + "Remeber to go shopping"; + "Remeber to buy boxes for moving"; + "Remeber to fix bike"; + "Remeber to buy christmast presents"; + "Remeber to send flowers to grandmother"; + "Remeber to talk with son"; + "Remeber to cut hedge"; + "Remeber to bumper potatoes"; + "Remeber to harvest corn field"; + "Remeber to sleep enaugh"; + "Remeber to wash teeths ewery morning"; + "Remeber to get sleep early"; + "Remeber to give some wather to flowers"; + "Remeber to wax snowboard"; + "Remeber to wax skiis"; + "Remeber to wax cross country skiis"; + "Remeber to call mother"; + "Remeber to call father"; + "Remeber to call brother"; + "Remeber to call sister"; + "Remeber to call daughter"; + "Remeber to call son"; + "Remeber to rent villa"; + }; + +struct r_data_messagesubjects + { + "Whaaasssaaap!!??"; + "Hello"; + "How are you doing?"; + "You will win the battle, GUARANTEED!"; + "Why pay more for something if you don't have to?"; + "You can afford health care now"; + "Re: *Buddy* *Lists*!!~ (it's soooo cool)!!~"; + "Weedmon say: call, we be open 7 days, mon"; + "Want her to look better?"; + "Good Morning andyw, how are you?"; + "Happy Assumption"; + "There is NO Risk involved"; + "Free Bottle Offer!"; + "Introduction on MDSL"; + "Theres Help out there for you"; + "hello there - check this out"; + "Darling"; + "It doesn't have to be that way"; + "Webmaster, Free health insurance quotes!"; + "Join us at the OSGi 2003 World Congress"; + "Put your subject line here"; + "You are not protected"; + "Please try again"; + "you didn't reply my email ? why ? ???"; + "A very funny game"; + "Meeting notice"; + "Opportunities"; + }; + +struct r_data_messagetexts + { + "The contents of these pages are copyrighted. Any rights not expressly granted herein are reserved. The use of this site is permitted to private use."; + "Reproduction, transfer, distribution or storage of part or all of the contents in any form without the prior written permission is prohibited."; + "We consents to you browsing the pages on your computer or printing copies of extracts from these pages for your personal use only."; + "If you place an order for a product, request a service or submit content to this site, we may need to contact you for additional information."; + "The use of press releases and other documents classified as public is permitted in public communications if the source for the information has been stated."; + "For your easy accessibility we may include links to sites on the Internet that are owned or operated by third parties."; + "You also agree that we have no control over the content of that site and cannot assume any responsibility for material by such third-party sites."; + "In addition, a link to a such site does not imply that we endorses the site or the products or services referenced in such third party site."; + "In order to respond to your questions or manage interactive customer programs, it may be necessary to ask for personal information."; + "We may use this information to respond to your requests, or to contact you via mail, e-mail or phone to inform you of new products."; + "If you place an order for a product, request a service or submit content to this site, we may need to contact you for additional information."; + }; + + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/src/creator_accesspoint.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/src/creator_accesspoint.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,473 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +//#include "creator_accesspoint.h" +#include "creator_traces.h" +#include +#include +#include "enginewrapper.h" + +static const TInt KAccessPointsFieldLength = 128; + +_LIT(KCreatorAccessPointsPrefixName, "CR_"); +_LIT(KZeroIP, "0.0.0.0"); + +//---------------------------------------------------------------------------- + +CAccessPointsParameters::CAccessPointsParameters() + { + LOGSTRING("Creator: CAccessPointsParameters::CAccessPointsParameters"); + + iConnectionName = HBufC::New(KAccessPointsFieldLength); + iWapStartPage = HBufC::New(KAccessPointsFieldLength); + iGprsAcessPointName = HBufC::New(KAccessPointsFieldLength); + iIspLoginName = HBufC::New(KAccessPointsFieldLength); + iIspLoginPass = HBufC::New(KAccessPointsFieldLength); + iWapGatewayAddress = HBufC::New(KAccessPointsFieldLength); + iIspIPAddr = HBufC::New(KAccessPointsFieldLength); + iIspIPNameServer1 = HBufC::New(KAccessPointsFieldLength); + iIspIPNameServer2 = HBufC::New(KAccessPointsFieldLength); + iIspDefaultTelNumber = HBufC::New(KAccessPointsFieldLength); + iProxyServerAddress = HBufC::New(KAccessPointsFieldLength); + } + +CAccessPointsParameters::~CAccessPointsParameters() + { + LOGSTRING("Creator: CAccessPointsParameters::~CAccessPointsParameters"); + + delete iProxyServerAddress; + delete iIspDefaultTelNumber; + delete iIspIPNameServer2; + delete iIspIPNameServer1; + delete iIspIPAddr; + delete iWapGatewayAddress; + delete iIspLoginPass; + delete iIspLoginName; + delete iGprsAcessPointName; + delete iWapStartPage; + delete iConnectionName; + } + +void CAccessPointsParameters::SetRandomCMNameL(CCreatorEngine& aEngine) + { + TInt num = aEngine.RandomNumber(1, 3); + TBuf<10> apType; + + if (num==1) + apType = _L("mms"); + else if (num==2) + apType = _L("wap"); + else + apType = _L("internet"); + + TBuf<160> company = aEngine.RandomString(CCreatorEngine::ECompany); + + iConnectionName->Des() = KCreatorAccessPointsPrefixName; + iConnectionName->Des().Append( company ); + iConnectionName->Des().Append(_L(" ")); + iConnectionName->Des().Append(apType); + } + +void CAccessPointsParameters::SetRandomLoginNameL(CCreatorEngine& aEngine) + { + iIspLoginName->Des() = aEngine.RandomString(CCreatorEngine::EFirstName); + iIspLoginName->Des().LowerCase(); + } + +void CAccessPointsParameters::SetRandomLoginPassL(CCreatorEngine& /*aEngine*/) + {} + +void CAccessPointsParameters::SetRandomSecureAuthenticationL(CCreatorEngine& /*aEngine*/) + {} + +void CAccessPointsParameters::SetRandomPromptPasswordL(CCreatorEngine& /*aEngine*/) + {} + +void CAccessPointsParameters::SetRandomProxyAddressL(CCreatorEngine& /*aEngine*/) + {} + +void CAccessPointsParameters::SetRandomProxyPortL(CCreatorEngine& /*aEngine*/) + {} + +void CAccessPointsParameters::SetRandomStartPageL(CCreatorEngine& /*aEngine*/) + {} + +void CAccessPointsParameters::SetRandomIPAddressL(CCreatorEngine& /*aEngine*/) + {} + +void CAccessPointsParameters::SetRandomIP4NameServer1L(CCreatorEngine& /*aEngine*/) + {} + +void CAccessPointsParameters::SetRandomIP4NameServer2L(CCreatorEngine& /*aEngine*/) + {} + +void CAccessPointsParameters::SetRandomTelephoneNumberL(CCreatorEngine& /*aEngine*/) + {} + +void CAccessPointsParameters::SetRandomBearerTypeIsdnL(CCreatorEngine& /*aEngine*/) + {} + +void CAccessPointsParameters::SetRandomBearerSpeedL(CCreatorEngine& /*aEngine*/) + {} + +void CAccessPointsParameters::SetRandomWapWspOptionL(CCreatorEngine& /*aEngine*/) + {} + +void CAccessPointsParameters::SetRandomGatewayAddressL(CCreatorEngine& /*aEngine*/) + {} + +//---------------------------------------------------------------------------- + +CCreatorAccessPoints* CCreatorAccessPoints::NewL(CCreatorEngine* aEngine) + { + CCreatorAccessPoints* self = CCreatorAccessPoints::NewLC(aEngine); + CleanupStack::Pop(self); + return self; + } + +CCreatorAccessPoints* CCreatorAccessPoints::NewLC(CCreatorEngine* aEngine) + { + CCreatorAccessPoints* self = new (ELeave) CCreatorAccessPoints; + CleanupStack::PushL(self); + self->ConstructL(aEngine); + return self; + } + +CCreatorAccessPoints::CCreatorAccessPoints() + { + } + +void CCreatorAccessPoints::ConstructL(CCreatorEngine* aEngine) + { + LOGSTRING("Creator: CCreatorAccessPoints::ConstructL"); + + iEngine = aEngine; + + iCommsDb = CCommsDatabase::NewL();; + iApDataHandler = CApDataHandler::NewLC(*iCommsDb); + CleanupStack::Pop(); + iApUtils = CApUtils::NewLC(*iCommsDb); + CleanupStack::Pop(); + } + +CCreatorAccessPoints::~CCreatorAccessPoints() + { + LOGSTRING("Creator: CCreatorAccessPoints::~CCreatorAccessPoints"); + + if ( iEngine && iEntryIds.Count() ) + { + TRAP_IGNORE( iEngine->WriteEntryIdsToStoreL( iEntryIds, KUidDictionaryUidIAP ) ); + } + iEntryIds.Reset(); + iEntryIds.Close(); + + delete iApUtils; + delete iApDataHandler; + delete iCommsDb; + + if (iParameters) + delete iParameters; + } + +//---------------------------------------------------------------------------- + +TBool CCreatorAccessPoints::AskDataFromUserL(TInt aCommand) + { + LOGSTRING("Creator: CCreatorAccessPoints::AskDataFromUserL"); + + CCreatorModuleBase::AskDataFromUserL( aCommand );//ignore retval + + if( aCommand == ECmdDeleteIAPs ) + { + return iEngine->GetEngineWrapper()->YesNoQueryDialog(_L("Delete all Access Points?"), this, ECreatorModuleDelete ); + } + else if( aCommand == ECmdDeleteCreatorIAPs ) + { + return iEngine->GetEngineWrapper()->YesNoQueryDialog(_L("Delete all Access Points created with Creator?"), this, ECreatorModuleDelete ); + } + + return iEngine->GetEngineWrapper()->EntriesQueryDialog(&iEntriesToBeCreated, _L("How many entries to create?"), EFalse, this, ECreatorModuleStart ); + } + + +//---------------------------------------------------------------------------- + +TInt CCreatorAccessPoints::CreateConnectionSettingsEntryL(CCreatorModuleBaseParameters *aParameters) + { + LOGSTRING("Creator: CCreatorAccessPoints::CreateAccessPointEntryL"); + + CAccessPointsParameters* parameters = (CAccessPointsParameters*) aParameters; + + // clear any existing parameter definations + delete iParameters; + iParameters = NULL; + + + + // random data needed if no predefined data available + if (!parameters) + { + TBuf<160> company = iEngine->RandomString(CCreatorEngine::ECompany); + TInt num = iEngine->RandomNumber(1, 3); + TBuf<10> apType; + + if (num==1) + apType = _L("mms"); + else if (num==2) + apType = _L("wap"); + else + apType = _L("internet"); + + iParameters = new(ELeave) CAccessPointsParameters; + parameters = iParameters; + + parameters->SetRandomCMNameL(*iEngine); + + // in random mode just create GPRS access points + parameters->iBearerType = EApBearerTypeGPRS; + + parameters->SetRandomLoginNameL(*iEngine); + + iParameters->iIspLoginPass->Des() = iEngine->RandomString(CCreatorEngine::ESurname); + iParameters->iIspLoginPass->Des().LowerCase(); + + iParameters->iSecureAuthentication = EFalse; + iParameters->iPromptPassword = EFalse; + + iParameters->iProxyServerAddress->Des() = _L("127.0.0.1"); + iParameters->iProxyPortNumber = 80; + + iParameters->iWapStartPage->Des() = _L("http://"); + iParameters->iWapStartPage->Des().Append(apType); + iParameters->iWapStartPage->Des().Append(_L(".")); + iParameters->iWapStartPage->Des().Append(company); + iParameters->iWapStartPage->Des().Append(_L(".com")); + iParameters->iWapStartPage->Des().LowerCase(); + + iParameters->iIspIPAddr->Des() = KZeroIP; + iParameters->iIspIPNameServer1->Des() = KZeroIP; + iParameters->iIspIPNameServer1->Des() = KZeroIP; + iParameters->iGprsAcessPointName->Des() = apType; + iParameters->iIspDefaultTelNumber->Des() = iEngine->RandomString(CCreatorEngine::EPhoneNumber); + iParameters->iIspBearerCallTypeIsdn = ECallTypeISDNv110; + iParameters->iIspBearerSpeed = KSpeed14400; + + iParameters->iWapWspOption = EWapWspOptionConnectionOriented; + iParameters->iWapGatewayAddress->Des() = KZeroIP; + } + else + { + // otherwise replace the parameters object + iParameters = parameters; + } + + TInt err = KErrNone; + + // access point item + CApAccessPointItem* apItem = CApAccessPointItem::NewLC(); + + // set the bearer type, if it fails try to set a default type + TRAPD(bearerErr, apItem->SetBearerTypeL(iParameters->iBearerType)); + if (bearerErr != KErrNone) + { + iParameters->iBearerType = EApBearerTypeGPRS; + TRAPD(bearerErr2, apItem->SetBearerTypeL(iParameters->iBearerType)); + bearerErr2=bearerErr2; + } + + if (iParameters->iBearerType == EApBearerTypeGPRS) // GPRS + { + err = apItem->WriteLongTextL(EApGprsAccessPointName, iParameters->iGprsAcessPointName->Des()); + } + else // CSD or HCSD + { + err = apItem->WriteTextL(EApIspDefaultTelNumber, iParameters->iIspDefaultTelNumber->Des()); + err = apItem->WriteUint(EApIspBearerCallTypeIsdn, iParameters->iIspBearerCallTypeIsdn); + err = apItem->WriteUint(EApIspBearerSpeed, iParameters->iIspBearerSpeed); + } + + err = apItem->WriteTextL(EApIspLoginName, iParameters->iIspLoginName->Des()); + err = apItem->WriteTextL(EApIspIfAuthName, iParameters->iIspLoginName->Des()); + err = apItem->WriteTextL(EApIspLoginPass, iParameters->iIspLoginPass->Des()); + err = apItem->WriteTextL(EApIspIfAuthPass, iParameters->iIspLoginPass->Des()); + err = apItem->WriteTextL(EApGprsIfAuthPassword, iParameters->iIspLoginPass->Des()); + err = apItem->WriteBool(EApIspDisablePlainTextAuth, iParameters->iSecureAuthentication); + err = apItem->WriteBool(EApIspPromptForLogin, iParameters->iPromptPassword); + err = apItem->WriteTextL(EApWapGatewayAddress, iParameters->iWapGatewayAddress->Des()); + err = apItem->WriteLongTextL(EApProxyServerAddress, iParameters->iProxyServerAddress->Des()); + err = apItem->WriteUint(EApProxyPortNumber, iParameters->iProxyPortNumber); + err = apItem->WriteLongTextL(EApWapStartPage, iParameters->iWapStartPage->Des()); + err = apItem->WriteUint(EApWapWspOption, iParameters->iWapWspOption); + err = apItem->WriteTextL(EApGprsIPNameServer1, iParameters->iIspIPNameServer1->Des()); + err = apItem->WriteTextL(EApGprsIPNameServer2, iParameters->iIspIPNameServer2->Des()); + err = apItem->WriteTextL(EApIspIPAddr, iParameters->iIspIPAddr->Des()); + + + TUint32 uid = iApDataHandler->CreateFromDataL(*apItem); // save the access point, returns the uid of the AP + + // id has been generated, store it for being able to delete + // entries created only with Creator + iEntryIds.AppendL( uid ); + + TBuf<256> name = iParameters->iConnectionName->Des(); + iApUtils->SetNameL(name, uid); // sets the AP name + + + // if no defaults set, set the created AP as a default + + // MMS access point + if (iParameters->iWapStartPage->Des().FindF(_L("mms")) >=0 || iParameters->iConnectionName->Des().FindF(_L("mms")) >=0 ) + { + //User::Panic(_L("Not done yet..."), 123); + } + + + // WAP access point + else if (iParameters->iConnectionName->Des().FindF(_L("wap")) >=0 || iParameters->iGprsAcessPointName->Des().FindF(_L("wap")) >= 0) + { + TUint32 defID = 0; + TRAP( err, defID = iApDataHandler->DefaultL(ETrue) ); // ETrue==WAP + + if (defID <= 1) + TRAP( err, iApDataHandler->SetAsDefaultL(uid, EIspTypeWAPOnly) ); + + } + + // Internet access point + else if (iParameters->iConnectionName->Des().FindF(_L("internet")) >=0 || iParameters->iGprsAcessPointName->Des().FindF(_L("internet")) >= 0) + { + TUint32 defID = 0; + TRAP( err, defID = iApDataHandler->DefaultL(EFalse) ); // EFalse==IAP + + if (defID <= 1) + TRAP( err, iApDataHandler->SetAsDefaultL(uid, EIspTypeInternetOnly) ); // <-- POSSIBLY NOT CORRECT, NEEDS MORE TESTING + } + + + + CleanupStack::PopAndDestroy(); //apItem + + return err; + } + +//---------------------------------------------------------------------------- + +TUint32 CCreatorAccessPoints::AccessPointNameToIdL(const TDesC& aAPName, TBool /*aAnyIfNotFound*/ ) + { + LOGSTRING("Creator: CCreatorEngine::AccessPointNameToIdL"); + + TBuf<256> apName = aAPName.Left(256); + apName.Trim(); + + TUint32 APId = iEngine->GetDefaultIAPL(); + + // return default IAP if requested + if (apName.CompareF(_L("DEFAULT-IAP")) == 0 || apName.CompareF(_L("DEFAULT")) == 0) + { + return APId; + } + + CCommsDatabase* db = CCommsDatabase::NewL(EDatabaseTypeIAP); + CleanupStack::PushL(db); + CApUtils* apUtils = CApUtils::NewLC(*db); + CApSelect* apSelect = CApSelect::NewLC(*db, KEApIspTypeAll, EApBearerTypeAll, KEApSortNameAscending); + + + // loop through all access points and try to find a matching name + if (apSelect->MoveToFirst()) + { + do + { + TBuf<256> apName2; + apUtils->NameL(apSelect->Uid(), apName2); + apName2.Trim(); + + if (apName2.CompareF( apName ) == 0) + { + // match found, get uid and break the loop + TRAPD( err, APId = apUtils->IapIdFromWapIdL(apSelect->Uid()) ); + err=err; + break; + } + } + while (apSelect->MoveNext()); + } + + CleanupStack::PopAndDestroy(3); //apSelect, apUtils, db + + return APId; + } + +//---------------------------------------------------------------------------- + +void CCreatorAccessPoints::HandleSessionEventL(TMsvSessionEvent /*aEvent*/, TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/) // from MMsvSessionObserver + { + } + +//---------------------------------------------------------------------------- +void CCreatorAccessPoints::DeleteAllL() + { + LOGSTRING("Creator: CCreatorEngine::DeleteAllL"); + + CApSelect* selector = CApSelect::NewLC( *iCommsDb, + KEApIspTypeAll, + EApBearerTypeAllBearers, + KEApSortUidAscending ); + + CApListItemList* list = new (ELeave) CApListItemList(); + CleanupStack::PushL( list ); + TInt count = selector->AllListItemDataL( *list ); + for ( TInt i = 0; i < count; i++ ) + { + TRAP_IGNORE( iApDataHandler->RemoveAPL( (*list)[i]->Uid() ) ); + } + + CleanupStack::PopAndDestroy( list ); + CleanupStack::PopAndDestroy( selector ); + + // reset must be done here, because iEntryIds is stored in destructor + iEntryIds.Reset(); + + // all entries deleted, remove the Logs related registry + iEngine->RemoveStoreL( KUidDictionaryUidIAP ); + } + +//---------------------------------------------------------------------------- + +void CCreatorAccessPoints::DeleteAllCreatedByCreatorL() + { + LOGSTRING("Creator: CCreatorEngine::DeleteAllCreatedByCreatorL"); + iEntryIds.Reset(); + + // fetch ids of entries created by Creator + iEngine->ReadEntryIdsFromStoreL( iEntryIds, KUidDictionaryUidIAP ); + + // delete entries + for ( TInt i = 0; i < iEntryIds.Count(); i++ ) + { + TRAP_IGNORE( iApDataHandler->RemoveAPL( iEntryIds[i] ) ); + } + + // reset must be done here, because iEntryIds is stored in destructor + iEntryIds.Reset(); + + // all entries deleted, remove the Logs related registry + iEngine->RemoveStoreL( KUidDictionaryUidIAP ); + } diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/src/creator_browser.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/src/creator_browser.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,595 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include + +#include "engine.h" +#include "enginewrapper.h" +#include "creator_browser.h" +#include "creator_traces.h" + + +static const TInt KBrowserFieldLength = 128; + +_LIT(KCreatorBrowserPrefixName, "CR_"); +_LIT(KCreatorBrowserPrefixFolderName, "CR_FLDR_"); + +//---------------------------------------------------------------------------- + +CBrowserParameters::CBrowserParameters() + { + LOGSTRING("Creator: CBrowserParameters::CBrowserParameters"); + + iBookmarkName = HBufC::New(KBrowserFieldLength); + iBookmarkAddress = HBufC::New(KBrowserFieldLength); + iBookmarkUsername = HBufC::New(KBrowserFieldLength); + iBookmarkPassword = HBufC::New(KBrowserFieldLength); + iBookmarkFolderName = HBufC::New(KBrowserFieldLength); + iSavedDeckLinkName = HBufC::New(KBrowserFieldLength); + iSavedDeckLocalAddress = HBufC::New(KBrowserFieldLength); + iSavedDeckFolderName = HBufC::New(KBrowserFieldLength); + } + +CBrowserParameters::~CBrowserParameters() + { + LOGSTRING("Creator: CBrowserParameters::~CBrowserParameters"); + + delete iSavedDeckFolderName; + delete iSavedDeckLocalAddress; + delete iSavedDeckLinkName; + delete iBookmarkFolderName; + delete iBookmarkPassword; + delete iBookmarkUsername; + delete iBookmarkAddress; + delete iBookmarkName; + + } + +//---------------------------------------------------------------------------- + +CCreatorBrowser* CCreatorBrowser::NewL(CCreatorEngine* aEngine) + { + CCreatorBrowser* self = CCreatorBrowser::NewLC(aEngine); + CleanupStack::Pop(self); + return self; + } + +CCreatorBrowser* CCreatorBrowser::NewLC(CCreatorEngine* aEngine) + { + CCreatorBrowser* self = new (ELeave) CCreatorBrowser; + CleanupStack::PushL(self); + self->ConstructL(aEngine); + return self; + } + +CCreatorBrowser::CCreatorBrowser() + { + } + +void CCreatorBrowser::ConstructL(CCreatorEngine* aEngine) + { + LOGSTRING("Creator: CCreatorBrowser::ConstructL"); + + iEngine = aEngine; + } + +CCreatorBrowser::~CCreatorBrowser() + { + LOGSTRING("Creator: CCreatorBrowser::~CCreatorBrowser"); + if ( iEngine && iBmEntryIds.Count() ) + { + TRAP_IGNORE( iEngine->WriteEntryIdsToStoreL( iBmEntryIds, KUidDictionaryUidBrowserBookmarks ) ); + } + iBmEntryIds.Reset(); + iBmEntryIds.Close(); + + if ( iEngine && iBmFEntryIds.Count() ) + { + TRAP_IGNORE( iEngine->WriteEntryIdsToStoreL( iBmFEntryIds, KUidDictionaryUidBrowserBookmarkF ) ); + } + iBmFEntryIds.Reset(); + iBmFEntryIds.Close(); + + if ( iEngine && iSpEntryIds.Count() ) + { + TRAP_IGNORE( iEngine->WriteEntryIdsToStoreL( iSpEntryIds, KUidDictionaryUidBrowserSavedPg ) ); + } + iSpEntryIds.Reset(); + iSpEntryIds.Close(); + + if ( iEngine && iSpFEntryIds.Count() ) + { + TRAP_IGNORE( iEngine->WriteEntryIdsToStoreL( iSpFEntryIds, KUidDictionaryUidBrowserSavedPgF ) ); + } + iSpFEntryIds.Reset(); + iSpFEntryIds.Close(); + + delete iParameters; + } + +//---------------------------------------------------------------------------- + +TBool CCreatorBrowser::AskDataFromUserL(TInt aCommand) + { + LOGSTRING("Creator: CCreatorBrowser::AskDataFromUserL"); + + CCreatorModuleBase::AskDataFromUserL( aCommand );//ignore retval + + TBool result( EFalse ); + switch ( aCommand ) + { + case ECmdDeleteBrowserBookmarks: + { + result = iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all Browser bookmarks?"), this, ECreatorModuleDelete ); + break; + } + case ECmdDeleteCreatorBrowserBookmarks: + { + result = iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all Browser bookmarks created with Creator?"), this, ECreatorModuleDelete ); + break; + } + case ECmdDeleteBrowserBookmarkFolders: + { + result = iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all Browser bookmark folders?"), this, ECreatorModuleDelete ); + break; + } + case ECmdDeleteCreatorBrowserBookmarkFolders: + { + result = iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all Browser bookmark folders created with Creator?"), this, ECreatorModuleDelete ); + break; + } + case ECmdDeleteBrowserSavedPages: + { + result = iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all Browser saved pages?"), this, ECreatorModuleDelete ); + break; + } + case ECmdDeleteCreatorBrowserSavedPages: + { + result = iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all Browser saved pages created with Creator?"), this, ECreatorModuleDelete ); + break; + } + case ECmdDeleteBrowserSavedPageFolders: + { + result = iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all Browser saved pages folders?"), this, ECreatorModuleDelete ); + break; + } + case ECmdDeleteCreatorBrowserSavedPageFolders: + { + result = iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all Browser saved pages folders created with Creator?"), this, ECreatorModuleDelete ); + break; + } + default: + { + result = iEngine->GetEngineWrapper()->EntriesQueryDialog(&iEntriesToBeCreated, _L("How many entries to create?"), EFalse, this, ECreatorModuleStart ); + break; + } + } + return result; + } + + +//---------------------------------------------------------------------------- + +TInt CCreatorBrowser::CreateBookmarkEntryL(CBrowserParameters *aParameters) + { + LOGSTRING("Creator: CCreatorBrowser::CreateBookmarkEntryL"); + + // clear any existing parameter definations + delete iParameters; + iParameters = NULL; + + CBrowserParameters* parameters = aParameters; + + // random data needed if no predefined data available + if( !parameters ) + { + iParameters = new(ELeave) CBrowserParameters; + parameters = iParameters; + + TFileName userAndPassword = iEngine->RandomString(CCreatorEngine::EFirstName); + TFileName name = iEngine->RandomString(CCreatorEngine::ECompany); + TFileName url = name; + url.Insert(0, _L("http://www.")); + url.Append(_L(".com/")); + name.Insert(0, KCreatorBrowserPrefixName); + + parameters->iBookmarkName->Des() = name; + parameters->iBookmarkAddress->Des() = url; + parameters->iBookmarkUsername->Des() = userAndPassword; + parameters->iBookmarkPassword->Des() = userAndPassword; + } + + TInt err = KErrNone; + + RFavouritesSession session; + User::LeaveIfError( session.Connect() ); + CleanupClosePushL(session); + RFavouritesDb db; + User::LeaveIfError( db.Open(session, KBrowserBookmarks) ); + CleanupClosePushL(db); + + CFavouritesItem* item = CFavouritesItem::NewLC(); + item->SetType( CFavouritesItem::EItem ); + item->SetParentFolder( KFavouritesRootUid ) ; + item->SetNameL( parameters->iBookmarkName->Des() ); + item->SetUrlL( parameters->iBookmarkAddress->Des() ); + item->SetUserNameL( parameters->iBookmarkUsername->Des() ); + item->SetPasswordL( parameters->iBookmarkPassword->Des() ); + err = db.Add(*item, /*aAutoRename=*/ETrue); + if (err) + db.Commit(); + + // id has been generated, store it for being able to delete + // only entries created with Creator + iBmEntryIds.AppendL( item->Uid() ); + + CleanupStack::PopAndDestroy(3); //db, session, item + + return err; + } + +//---------------------------------------------------------------------------- + +TInt CCreatorBrowser::CreateBookmarkFolderEntryL(CBrowserParameters *aParameters) + { + LOGSTRING("Creator: CCreatorBrowser::CreateBookmarkFolderEntryL"); + + // clear any existing parameter definations + delete iParameters; + iParameters = NULL; + + CBrowserParameters* parameters = aParameters; + + // random data needed if no predefined data available + if (!parameters) + { + iParameters = new(ELeave) CBrowserParameters; + parameters = iParameters; + + TFileName name = iEngine->RandomString(CCreatorEngine::ECompany); + name.Insert(0, KCreatorBrowserPrefixFolderName); + + parameters->iBookmarkFolderName->Des() = name; + } + + TInt err = KErrNone; + + RFavouritesSession session; + User::LeaveIfError( session.Connect() ); + CleanupClosePushL(session); + RFavouritesDb db; + User::LeaveIfError( db.Open(session, KBrowserBookmarks) ); + CleanupClosePushL(db); + + CFavouritesItem* item = CFavouritesItem::NewLC(); + item->SetType( CFavouritesItem::EFolder ); + item->SetParentFolder( KFavouritesRootUid ) ; + item->SetNameL( parameters->iBookmarkFolderName->Des() ); + + err = db.Add(*item, /*aAutoRename=*/ETrue); + if (err) + db.Commit(); + + // id has been generated, store it for being able to delete + // only entries created with Creator + iBmFEntryIds.AppendL( item->Uid() ); + + CleanupStack::PopAndDestroy(3); //db, session, item + + + return err; + + } + +//---------------------------------------------------------------------------- + +TInt CCreatorBrowser::CreateSavedDeckEntryL(CBrowserParameters *aParameters) + { + LOGSTRING("Creator: CCreatorBrowser::CreateSavedDeckEntryL"); + + // clear any existing parameter definations + delete iParameters; + iParameters = NULL; + + CBrowserParameters* parameters = aParameters; + + // random data needed if no predefined data available + if (!parameters) + { + iParameters = new(ELeave) CBrowserParameters; + parameters = iParameters; + + TFileName name = iEngine->RandomString(CCreatorEngine::ECompany); + name.Insert(0, KCreatorBrowserPrefixName); + + parameters->iSavedDeckLinkName->Des() = name; + parameters->iSavedDeckLocalAddress->Des() = iEngine->TestDataPathL(CCreatorEngine::ESavedDeck_1kB); + } + + TInt err = KErrNone; + + // check the deck address is correct + if ( parameters->iSavedDeckLocalAddress->Des().Length() == 0 || + !BaflUtils::FileExists( CEikonEnv::Static()->FsSession(), parameters->iSavedDeckLocalAddress->Des() )) + { + // not found, use a default deck instead + delete parameters->iSavedDeckLocalAddress; + parameters->iSavedDeckLocalAddress = 0; + TPtrC tmp = iEngine->TestDataPathL(CCreatorEngine::ESavedDeck_1kB); + parameters->iSavedDeckLocalAddress = HBufC::NewL(tmp.Length()); + parameters->iSavedDeckLocalAddress->Des() = tmp; + } + + + RFavouritesSession session; + User::LeaveIfError( session.Connect() ); + CleanupClosePushL(session); + RFavouritesDb db; + User::LeaveIfError( db.Open(session, KBrowserSavedPages) ); + CleanupClosePushL(db); + + CFavouritesItem* item = CFavouritesItem::NewLC(); + item->SetType( CFavouritesItem::EItem ); + item->SetParentFolder( KFavouritesRootUid ) ; + item->SetNameL( parameters->iSavedDeckLinkName->Des() ); + item->SetUrlL( _L(" ") ); + + TFavouritesWapAp favouritesAp; + favouritesAp.SetDefault(); + item->SetWapAp( favouritesAp ); + + + err = db.Add(*item, /*aAutoRename=*/ETrue); + if (err) + db.Commit(); + + // read the source deck to buffer + RFile sourceFile; + User::LeaveIfError( sourceFile.Open(CEikonEnv::Static()->FsSession(), parameters->iSavedDeckLocalAddress->Des(), EFileRead) ); + CleanupClosePushL(sourceFile); + TInt sourceFileSize(0); + err = sourceFile.Size(sourceFileSize); + HBufC8* sourceBuf = HBufC8::NewLC(sourceFileSize); + TPtr8 sourcePtr = sourceBuf->Des(); + sourceFile.Read(sourcePtr); + + // write the deck + RFavouritesFile destinationFile; + User::LeaveIfError( destinationFile.Replace(db, item->Uid() )); + CleanupClosePushL(destinationFile); + err = destinationFile.Write(sourceBuf->Des()); + + // id has been generated, store it for being able to delete + // only entries created with Creator + iSpEntryIds.AppendL( item->Uid() ); + + + CleanupStack::PopAndDestroy(6); //db, session, item, sourceFile, destinationFile, sourceBuf + + return err; + } + +//---------------------------------------------------------------------------- + +TInt CCreatorBrowser::CreateSavedDeckFolderEntryL(CBrowserParameters *aParameters) + { + LOGSTRING("Creator: CCreatorBrowser::CreateSavedDeckFolderEntryL"); + + // clear any existing parameter definations + delete iParameters; + iParameters = NULL; + + CBrowserParameters* parameters = aParameters; + // random data needed if no predefined data available + if (!parameters) + { + iParameters = new(ELeave) CBrowserParameters; + parameters = iParameters; + + TFileName name = iEngine->RandomString(CCreatorEngine::ECompany); + name.Insert(0, KCreatorBrowserPrefixFolderName); + + parameters->iSavedDeckFolderName->Des() = name; + } + + TInt err = KErrNone; + + RFavouritesSession session; + User::LeaveIfError( session.Connect() ); + CleanupClosePushL(session); + RFavouritesDb db; + User::LeaveIfError( db.Open(session, KBrowserSavedPages) ); + CleanupClosePushL(db); + + CFavouritesItem* item = CFavouritesItem::NewLC(); + item->SetType( CFavouritesItem::EFolder ); + item->SetParentFolder( KFavouritesRootUid ) ; + item->SetNameL( parameters->iSavedDeckFolderName->Des() ); + + err = db.Add(*item, /*aAutoRename=*/ETrue); + if (err) + db.Commit(); + + // id has been generated, store it for being able to delete + // only entries created with Creator + iSpFEntryIds.AppendL( item->Uid() ); + + CleanupStack::PopAndDestroy(3); //db, session, item + + return err; + + } + + +//---------------------------------------------------------------------------- +void CCreatorBrowser::DeleteAllL() + { + LOGSTRING("Creator: CCreatorBrowser::DeleteAllL"); + User::Leave( KErrNotSupported ); + // will not be supported, see separate implementations below + } + +//---------------------------------------------------------------------------- +void CCreatorBrowser::DeleteAllCreatedByCreatorL() + { + LOGSTRING("Creator: CCreatorBrowser::DeleteAllCreatedByCreatorL"); + User::Leave( KErrNotSupported ); + // will not be supported, see separate implementations below + } + +//---------------------------------------------------------------------------- +void CCreatorBrowser::DeleteAllBookmarksL() + { + LOGSTRING("Creator: CCreatorBrowser::DeleteAllBookmarksL"); + DeleteAllItemsL( KBrowserBookmarks, + CFavouritesItem::EItem, + EFalse, + iBmEntryIds, // ignored, because deleting all + KUidDictionaryUidBrowserBookmarks ); + } + +//---------------------------------------------------------------------------- +void CCreatorBrowser::DeleteAllBookmarksCreatedByCreatorL() + { + LOGSTRING("Creator: CCreatorBrowser::DeleteAllBookmarksCreatedByCreatorL"); + DeleteAllItemsL( KBrowserBookmarks, + CFavouritesItem::EItem, + ETrue, + iBmEntryIds, + KUidDictionaryUidBrowserBookmarks ); + } + +//---------------------------------------------------------------------------- +void CCreatorBrowser::DeleteAllBookmarkFoldersL() + { + LOGSTRING("Creator: CCreatorBrowser::DeleteAllBookmarkFoldersL"); + DeleteAllItemsL( KBrowserBookmarks, + CFavouritesItem::EFolder, + EFalse, + iBmFEntryIds, // ignored, because deleting all + KUidDictionaryUidBrowserBookmarkF ); + } + +//---------------------------------------------------------------------------- +void CCreatorBrowser::DeleteAllBookmarkFoldersCreatedByCreatorL() + { + LOGSTRING("Creator: CCreatorBrowser::DeleteAllBookmarkFoldersCreatedByCreatorL"); + DeleteAllItemsL( KBrowserBookmarks, + CFavouritesItem::EFolder, + ETrue, + iBmFEntryIds, + KUidDictionaryUidBrowserBookmarkF ); + } + +//---------------------------------------------------------------------------- +void CCreatorBrowser::DeleteAllSavedPagesL() + { + LOGSTRING("Creator: CCreatorBrowser::DeleteAllSavedPagesL"); + DeleteAllItemsL( KBrowserSavedPages, + CFavouritesItem::EItem, + EFalse, + iSpEntryIds, // ignored, because deleting all + KUidDictionaryUidBrowserSavedPg ); + } + +//---------------------------------------------------------------------------- +void CCreatorBrowser::DeleteAllSavedPagesCreatedByCreatorL() + { + LOGSTRING("Creator: CCreatorBrowser::DeleteAllSavedPagesCreatedByCreatorL"); + DeleteAllItemsL( KBrowserSavedPages, + CFavouritesItem::EItem, + ETrue, + iSpEntryIds, + KUidDictionaryUidBrowserSavedPg ); + } + +//---------------------------------------------------------------------------- +void CCreatorBrowser::DeleteAllSavedPageFoldersL() + { + LOGSTRING("Creator: CCreatorBrowser::DeleteAllSavedPageFoldersL"); + DeleteAllItemsL( KBrowserSavedPages, + CFavouritesItem::EFolder, + EFalse, + iSpFEntryIds, // ignored, because deleting all + KUidDictionaryUidBrowserSavedPgF ); + } + +//---------------------------------------------------------------------------- +void CCreatorBrowser::DeleteAllSavedPageFoldersCreatedByCreatorL() + { + LOGSTRING("Creator: CCreatorBrowser::DeleteAllSavedPageFolderssCreatedByCreatorL"); + DeleteAllItemsL( KBrowserSavedPages, + CFavouritesItem::EFolder, + ETrue, + iSpFEntryIds, + KUidDictionaryUidBrowserSavedPgF ); + } + +//---------------------------------------------------------------------------- +void CCreatorBrowser::DeleteAllItemsL( const TDesC& aDbName, + CFavouritesItem::TType aTypeFilter, + TBool aOnlyCreatedWithCreator, + RArray& aEntryIds, + const TUid aDictUid ) + { + LOGSTRING("Creator: CCreatorBrowser::DeleteItemL"); + RFavouritesSession session; + User::LeaveIfError( session.Connect() ); + CleanupClosePushL( session ); + RFavouritesDb db; + User::LeaveIfError( db.Open( session, aDbName ) ); + CleanupClosePushL( db ); + + if ( aOnlyCreatedWithCreator ) + { + // read uids from Creator internal store + aEntryIds.Reset(); + iEngine->ReadEntryIdsFromStoreL( aEntryIds, aDictUid ); + + // delete entries from db + for ( TInt i = 0; i < aEntryIds.Count(); i++ ) + { + db.Delete( aEntryIds[i] ); + } + } + else + { + CArrayFixFlat* uids = new (ELeave) CArrayFixFlat(64); + CleanupStack::PushL( uids ); + + // read uids from browser db + User::LeaveIfError( db.GetUids( *uids, KFavouritesRootUid, aTypeFilter ) ); + + // delete entries from db + for ( TInt i = 0; i < uids->Count(); i++ ) + { + db.Delete( uids->At(i) ); + } + + // db.Commit() seems to panic with EFavouritesNoTransaction + // deletion is successful even without commit, so not calling it + CleanupStack::PopAndDestroy( uids ); + } + + // entries deleted, remove the Browser related registry + aEntryIds.Reset(); + iEngine->RemoveStoreL( aDictUid ); + + CleanupStack::PopAndDestroy( &db ); + CleanupStack::PopAndDestroy( &session ); + } diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/src/creator_browserelement.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/src/creator_browserelement.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,216 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#include "creator_browserelement.h" +#include "creator_traces.h" +#include "creator_browser.h" + +using namespace creatorbrowser; + +/* + * + */ +CCreatorBrowserElement* CCreatorBrowserElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext ) + { + CCreatorBrowserElement* self = new (ELeave) CCreatorBrowserElement(aEngine); + CleanupStack::PushL(self); + self->ConstructL(aName, aContext); + CleanupStack::Pop(self); + return self; + } +/* + * + */ +CCreatorBrowserElement::CCreatorBrowserElement(CCreatorEngine* aEngine) +: +CCreatorScriptElement(aEngine) + { + iIsCommandElement = ETrue; + } + + +/* + * + */ +void CCreatorBrowserElement::ExecuteCommandL() + { + const CCreatorScriptAttribute* amountAttr = FindAttributeByName(KAmount); + TInt entryAmount = 1; + TBool addAll = EFalse; + if( amountAttr ) + { + entryAmount = ConvertStrToIntL(amountAttr->Value()); + } + // Get 'fields' element + CCreatorScriptElement* fieldsElement = FindSubElement(KFields); + if( fieldsElement ) + { + // Get sub-elements + const RPointerArray& fields = fieldsElement->SubElements(); + // Create browser entries, the amount of entries is defined by entryAmount: + for( TInt cI = 0; cI < entryAmount; ++cI ) + { + CBrowserParameters* param = 0; + + if( fields.Count() > 0 ) + param = new (ELeave) CBrowserParameters; + else + { + // No fields defined --> Add all fields with random values: + addAll = ETrue; + break; + } + + CleanupStack::PushL(param); + + for( TInt i = 0; i < fields.Count(); ++i ) + { + CCreatorScriptElement* field = fields[i]; + TPtrC elemName = field->Name(); + TPtrC elemContent = field->Content(); + const CCreatorScriptAttribute* randomAttr = fields[i]->FindAttributeByName(KRandomLength); + if( elemName == KName ) + { + if( randomAttr || elemContent.Length() == 0) + { + elemContent.Set(iEngine->RandomString(CCreatorEngine::ECompany)); + } + if( iName->Des() == KBookmark ) + { + SetContentToTextParamL(param->iBookmarkName, elemContent); + } + else if( iName->Des() == KBookmarkFolder ) + { + SetContentToTextParamL(param->iBookmarkFolderName, elemContent); + } + else if( iName->Des() == KSavedPage ) + { + SetContentToTextParamL(param->iSavedDeckLinkName, elemContent); + } + else if( iName->Des() == KSavedPageFolder ) + { + SetContentToTextParamL(param->iSavedDeckFolderName, elemContent); + } + } + + else if( elemName == KPath ) + { + if( randomAttr || elemContent.Length() == 0) + { + SetContentToTextParamL(param->iSavedDeckLocalAddress, iEngine->TestDataPathL(CCreatorEngine::ESavedDeck_1kB)); + } + else + { + SetContentToTextParamL(param->iSavedDeckLocalAddress, elemContent); + } + } + else if( elemName == KUsername ) + { + if( randomAttr || elemContent.Length() == 0) + { + // Set username and password to same string + if( param->iBookmarkPassword && param->iBookmarkPassword->Length() > 0 ) + { + SetContentToTextParamL(param->iBookmarkUsername, param->iBookmarkPassword->Des()); + } + else + { + SetContentToTextParamL(param->iBookmarkUsername, iEngine->RandomString(CCreatorEngine::EFirstName)); + } + } + else + { + SetContentToTextParamL(param->iBookmarkUsername, elemContent); + } + } + else if( elemName == KPassword ) + { + if( randomAttr || elemContent.Length() == 0) + { + // Set username and password to same string + if( param->iBookmarkUsername && param->iBookmarkUsername->Length() > 0 ) + { + SetContentToTextParamL(param->iBookmarkPassword, param->iBookmarkUsername->Des()); + } + else + { + SetContentToTextParamL(param->iBookmarkPassword, iEngine->RandomString(CCreatorEngine::EFirstName)); + } + } + else + { + SetContentToTextParamL(param->iBookmarkPassword, elemContent); + } + } + else if( elemName == KUrl ) + { + if( randomAttr || elemContent.Length() == 0) + { + TDesC* tmpUrl = iEngine->CreateHTTPUrlLC(); + if( tmpUrl ) + { + SetContentToTextParamL(param->iBookmarkAddress, *tmpUrl ); + } + CleanupStack::PopAndDestroy(); // tmpUrl + } + else + { + SetContentToTextParamL(param->iBookmarkAddress, elemContent); + } + } + } + iEngine->AppendToCommandArrayL(GetBrowserCommandL(), param); + CleanupStack::Pop(); // param + } + } + else + { + addAll = ETrue; + } + + if( addAll ) + { + iEngine->AppendToCommandArrayL(GetBrowserCommandL(), 0, entryAmount); + } + } + +TInt CCreatorBrowserElement::GetBrowserCommandL() const + { + if( iName->Des() == KBookmark ) + { + return ECmdCreateBrowserBookmarkEntries; + } + else if( iName->Des() == KBookmarkFolder ) + { + return ECmdCreateBrowserBookmarkFolderEntries; + } + else if( iName->Des() == KSavedPage ) + { + return ECmdCreateBrowserSavedPageEntries; + } + else if( iName->Des() == KSavedPageFolder ) + { + return ECmdCreateBrowserSavedPageFolderEntries; + } + + LOGSTRING("CCreatorFileElement::GetBrowserCommandL: Unknown browser entry"); + User::Leave(KErrGeneral); + return 0; // Not reached, but disables compiler warning... + } diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/src/creator_calendar.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/src/creator_calendar.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,1373 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include "engine.h" +#include "enginewrapper.h" + +#include "creator_calendar.h" +#include "creator_traces.h" +#include "creator_scriptentry.h" +#include +#include +#include +#include +#include "creator_contactsetcache.h" +#include "creator_phonebook.h" + +static const TInt KCalendarFieldLength = 128; + + +CCreatorCalenderAttendee::CCreatorCalenderAttendee() + {} + +CCreatorCalenderAttendee::~CCreatorCalenderAttendee() + { + delete iCommonName; + delete iEmailAddress; + } + +CCreatorCalenderAttendee* CCreatorCalenderAttendee::NewL() + { + CCreatorCalenderAttendee* self = new (ELeave) CCreatorCalenderAttendee; + return self; + } + +void CCreatorCalenderAttendee::SetCommonNameL(const TDesC& aName) + { + delete iCommonName; + iCommonName = 0; + iCommonName = HBufC::NewL(aName.Length()); + iCommonName->Des().Copy(aName); + } + +void CCreatorCalenderAttendee::SetEmailAddressL(const TDesC& aEmail) + { + delete iEmailAddress; + iEmailAddress = 0; + iEmailAddress = HBufC::NewL(aEmail.Length()); + iEmailAddress->Des().Copy(aEmail); + } + +void CCreatorCalenderAttendee::SetRole(CCalAttendee::TCalRole aRole) + { + iRole = aRole; + } + +void CCreatorCalenderAttendee::SetStatus(CCalAttendee::TCalStatus aStatus) + { + iStatus = aStatus; + } + +const TDesC& CCreatorCalenderAttendee::CommonName() const + { + if( iCommonName == 0 ) + return iDummy; + return *iCommonName; + } + +const TDesC& CCreatorCalenderAttendee::EmailAddress() const + { + if( iEmailAddress == 0 ) + return iDummy; + + return *iEmailAddress; + } + +CCalAttendee::TCalRole CCreatorCalenderAttendee::Role() const + { + return iRole; + } + +CCalAttendee::TCalStatus CCreatorCalenderAttendee::Status() const + { + return iStatus; + } + +TBool CCalenderInterimParameters::IsAllowedEntryStatus(CCalEntry::TType aType, CCalEntry::TStatus aStatus) + { + if( aType == CCalEntry::ETodo ) + { + return aStatus == CCalEntry::ECancelled || + aStatus == CCalEntry::ETodoNeedsAction || + aStatus == CCalEntry::ETodoCompleted || + aStatus == CCalEntry::ETodoInProcess; + } + + return aStatus == CCalEntry::ETentative || + aStatus == CCalEntry::EConfirmed || + aStatus == CCalEntry::ECancelled; + } + +//---------------------------------------------------------------------------- + +CCalenderInterimParameters::CCalenderInterimParameters ( ) + { + LOGSTRING("Creator: CCalenderInterimParameters::CCalenderInterimParameters"); + + iAppointmentLocation = HBufC::New (KCalendarFieldLength ); + iAppointmentReason = HBufC::New (KCalendarFieldLength ); + iEventReason = HBufC::New (KCalendarFieldLength ); + iAnniversaryReason = HBufC::New (KCalendarFieldLength ); + iTodoTask = HBufC::New (KCalendarFieldLength ); + iReminderReason = HBufC::New (KCalendarFieldLength ); + iDescription = HBufC::New (KCalendarFieldLength ); + iSummary = HBufC::New (KCalendarFieldLength ); + iLocation = HBufC::New (KCalendarFieldLength ); + iOrganizerName = HBufC::New (KCalendarFieldLength ); + iOrganizerEmail = HBufC::New (KCalendarFieldLength ); + + // set defaults, start date today and end date = today + 1 month + iRandomModeStartTime.HomeTime ( ); + iRandomModeEndTime = iRandomModeStartTime; + iRandomModeEndTime += TTimeIntervalMonths (1 ); + iAlarmTime = Time::NullTTime(); + iUseRandomAlarmTime = EFalse; + iStatus = CCalEntry::ENullStatus; + } + +CCalenderInterimParameters::~CCalenderInterimParameters ( ) + { + LOGSTRING("Creator: CCalenderInterimParameters::~CCalenderInterimParameters"); + + delete iTodoTask; + delete iAnniversaryReason; + delete iEventReason; + delete iAppointmentReason; + delete iAppointmentLocation; + delete iReminderReason; + delete iDescription; + delete iSummary; + delete iLocation; + delete iOrganizerName; + delete iOrganizerEmail; + iAttendees.ResetAndDestroy(); + iAttendees.Close(); + iAttendeeLinkIds.Reset(); + iAttendeeLinkIds.Close(); + } + +void CCalenderInterimParameters::ParseL (CCommandParser* parser, + TParseParams aCase ) + { + LOGSTRING("Creator: CCalenderInterimParameters::ParseL"); + + HBufC* tempBuf= NULL; + + switch (aCase ) + { + + case MCreatorModuleBaseParameters::ECalendarTodo: + { + + parser->StrParserL (tempBuf, '|' ); + + CleanupStack::PushL (tempBuf ); + + this->iTodoDueTime = TTime (tempBuf->Des ( ) ); + + parser->StrParserL (this->iTodoTask, '|' ); + + parser->StrParserL (tempBuf, ';' ); + this->iTodoPriority = 2; + if (tempBuf->Compare (_L("LOW") ) == 0 ) + this->iTodoPriority = 3; + else + if (tempBuf->Compare (_L("HIGH") ) == 0 ) + this->iTodoPriority = 1; + + CleanupStack::PopAndDestroy (tempBuf ); + + } + break; + + case MCreatorModuleBaseParameters::ECalendarMemo: + { + + parser->StrParserL (tempBuf, '|' ); + + this->iStartTime = TTime (tempBuf->Des ( ) ); + + parser->StrParserL (tempBuf, '|' ); + this->iEndTime = TTime (tempBuf->Des ( ) ); + + parser->StrParserL (this->iDescription, ';' ); + + CleanupStack::PopAndDestroy (tempBuf ); + } + break; + + case MCreatorModuleBaseParameters::ECalendarMeeting: + { + + parser->StrParserL (tempBuf, '|' ); + + CleanupStack::PushL (tempBuf ); + + this->iStartTime = TTime (tempBuf->Des ( ) ); + + parser->StrParserL (tempBuf, '|' ); + this->iEndTime = TTime (tempBuf->Des ( ) ); + + parser->StrParserL (this->iLocation, '|' ); + parser->StrParserL (this->iDescription, ';' ); + + CleanupStack::PopAndDestroy (tempBuf ); + } + break; + + case MCreatorModuleBaseParameters::ECalendarAnniv: + { + + parser->StrParserL (tempBuf, '|' ); + + CleanupStack::PushL (tempBuf ); + + this->iStartTime = TTime (tempBuf->Des ( ) ); + + parser->StrParserL (this->iDescription, ';' ); + + CleanupStack::PopAndDestroy (tempBuf ); + + } + break; + default: + { + //implement + } + break; + } + } +//---------------------------------------------------------------------------- + +CCreatorInterimCalendar* CCreatorInterimCalendar::NewL (CCreatorEngine* aEngine ) + { + CCreatorInterimCalendar* self = CCreatorInterimCalendar::NewLC (aEngine ); + CleanupStack::Pop (self ); + return self; + } + +CCreatorInterimCalendar* CCreatorInterimCalendar::NewLC (CCreatorEngine* aEngine ) + { + CCreatorInterimCalendar* self = new (ELeave) CCreatorInterimCalendar; + CleanupStack::PushL (self ); + self->ConstructL (aEngine ); + return self; + } + +CCreatorInterimCalendar::CCreatorInterimCalendar ( ) + { + } + +void CCreatorInterimCalendar::ConstructL (CCreatorEngine* aEngine ) + { + LOGSTRING("Creator: CCreatorInterimCalendar::ConstructL"); + + iEngine = aEngine; + + // set defaults, start date today and end date = today + 1 month + iRandomModeStartTime.HomeTime ( ); + iRandomModeEndTime = iRandomModeStartTime; + iRandomModeEndTime += TTimeIntervalMonths (1 ); + + iCalSession = CCalSession::NewL ( ); + // Create and open a calendar file + const TDesC& fileName = iCalSession->DefaultFileNameL ( );//default filename is: "C:Calendar" + TRAPD(err, iCalSession->CreateCalFileL(fileName)) + ; + // ignore KErrAlreadyExists leave code + if (err != KErrAlreadyExists ) + { + User::LeaveIfError (err ); + } + // Open the calendar file + iCalSession->OpenL (fileName ); + iCalEntryView = CCalEntryView::NewL (*iCalSession, *this ); + iNumberRepeatingEntries = 0; + iNumberOfAttendees = 0; //iEngine->RandomNumber(2, 15); + iSetAlarm = EFalse; + iWaiter = CAsyncWaiter::NewL(); + } + +CCreatorInterimCalendar::~CCreatorInterimCalendar ( ) + { + LOGSTRING("Creator: CCreatorInterimCalendar::~CCreatorInterimCalendar"); + + if ( iEngine && iEntryIds.Count() ) + { + TRAP_IGNORE( iEngine->WriteEntryIdsToStoreL( iEntryIds, KUidDictionaryUidCalendar ) ); + } + + iEntryIds.Reset(); + iEntryIds.Close(); + + if (iParameters ) + { + delete iParameters; + } + + if (iCalEntryView ) + { + delete iCalEntryView; + } + + if (iCalSession ) + { + delete iCalSession; + } + delete iSoundFileArray; + delete iWaiter; + delete iTmpCN; + delete iTmpEmail; + } + +//---------------------------------------------------------------------------- + +void CCreatorInterimCalendar::QueryDialogClosedL(TBool aPositiveAction, TInt aUserData) + { + LOGSTRING("Creator: CCreatorInterimCalendar::QueryDialogClosedL"); + + if( aPositiveAction == EFalse && aUserData != ECreatorCalendarAddDefaultAlarm ) + { + iEngine->ShutDownEnginesL(); + return; + } + + const TDesC* showText = &KSavingText; + TBool finished(EFalse); + TBool retval(ETrue); + switch(aUserData) + { + case ECreatorCalendarDelete: + iEntriesToBeCreated = 1; + showText = &KDeletingText; + finished = ETrue; + break; + case ECreatorCalendarStart: + if( iCommand == ECmdCreateCalendarEntryEvents || iCommand == ECmdCreateCalendarEntryAppointments ) + { + _LIT(KRepeatingNum, "How many repeating (weekly) entries"); + retval = iEngine->GetEngineWrapper()->EntriesQueryDialog(&iNumberRepeatingEntries, KRepeatingNum, ETrue, this, ECreatorCalendarGetWeeklyEntries); + } + else + { + _LIT(KStartPeriodDate, "Start date of creation period");// \n dd/mm/yyyy + retval = iEngine->GetEngineWrapper()->TimeQueryDialog(&iRandomModeStartTime, KStartPeriodDate, this, ECreatorCalendarGetStartDate); // ask start date + } + break; + case ECreatorCalendarGetWeeklyEntries: + _LIT(KAttendeesNum, "How many attendees to create"); + retval = iEngine->GetEngineWrapper()->EntriesQueryDialog(&iNumberOfAttendees, KAttendeesNum, ETrue, this, ECreatorCalendarGetAttendies); + break; + case ECreatorCalendarGetAttendies: + { + // ask start date + _LIT(KStartPeriodDate, "Start date of creation period"); + retval = iEngine->GetEngineWrapper()->TimeQueryDialog(&iRandomModeStartTime, KStartPeriodDate, this, ECreatorCalendarGetStartDate ); + } + break; + case ECreatorCalendarGetStartDate: + { + _LIT(KEndPeriodDate, "End date of creation period\n dd/mm/yyyy"); + iEngine->GetEngineWrapper()->TimeQueryDialog (&iRandomModeEndTime, KEndPeriodDate, this, ECreatorCalendarGetEndDate ); // ask end date + } + break; + case ECreatorCalendarGetEndDate: + if (iRandomModeStartTime > iRandomModeEndTime ) // check end date is ok + { + iEngine->GetEngineWrapper()->ShowNote(_L("End date must be after start date") ); + retval = EFalse; + } + else + { + retval = iEngine->GetEngineWrapper()->YesNoQueryDialog(_L("Add default alarm?"), this, ECreatorCalendarAddDefaultAlarm); + } + break; + case ECreatorCalendarAddDefaultAlarm: + iSetAlarm = aPositiveAction; + finished = ETrue; + break; + default: + //some error + retval = EFalse; + break; + } + if( retval == EFalse ) + { + iEngine->ShutDownEnginesL(); + } + else if( finished ) + { + // add this command to command array + iEngine->AppendToCommandArrayL(iCommand, NULL, iEntriesToBeCreated); + // started exucuting commands + iEngine->ExecuteFirstCommandL( *showText ); + } + } + +//---------------------------------------------------------------------------- + +TBool CCreatorInterimCalendar::AskDataFromUserL( TInt aCommand ) + { + LOGSTRING("Creator: CCreatorInterimCalendar::AskDataFromUserL"); + + CCreatorModuleBase::AskDataFromUserL( aCommand );//ignore retval + + if( aCommand == ECmdDeleteCalendarEntries ) + { + return iEngine->GetEngineWrapper()->YesNoQueryDialog(_L("Delete all calendar entries?"), this, ECreatorCalendarDelete ); + } + if( aCommand == ECmdDeleteCreatorCalendarEntries ) + { + return iEngine->GetEngineWrapper()->YesNoQueryDialog(_L("Delete all calendar entries created with Creator?"), this, ECreatorCalendarDelete ); + } + + // display queries + return iEngine->GetEngineWrapper()->EntriesQueryDialog(&iEntriesToBeCreated, _L("How many entries to create?"), EFalse, this, ECreatorCalendarStart ); // ask number of entries to create + } + +//---------------------------------------------------------------------------- + +TInt CCreatorInterimCalendar::CreateAppointmentEntryL ( + CCreatorModuleBaseParameters *aParameters ) + { + LOGSTRING("Creator: CCreatorInterimCalendar::CreateAppointmentEntryL"); + + delete iParameters; + iParameters = 0; + + CCalenderInterimParameters* parameters = (CCalenderInterimParameters*)aParameters; + + if( !parameters ) + { + iParameters = new(ELeave) CCalenderInterimParameters; + parameters = iParameters; + parameters->iRandomModeStartTime = iRandomModeStartTime; + parameters->iRandomModeEndTime = iRandomModeEndTime; + + // difference between start and end times + TTimeIntervalMinutes differenceInMinutes; + parameters->iRandomModeEndTime.MinutesFrom ( + parameters->iRandomModeStartTime, differenceInMinutes ); + + // start time (= something between the period start and end date) + parameters->iStartTime = parameters->iRandomModeStartTime; + parameters->iStartTime + += TTimeIntervalMinutes (iEngine->RandomNumber (differenceInMinutes.Int ( ) ) ); + // set end time (= start time + some random time) + parameters->iEndTime = parameters->iStartTime; + parameters->iEndTime + += TTimeIntervalMinutes (iEngine->RandomNumber (5, 500 ) ); + + + // strings + parameters->iLocation->Des ( ) + = iEngine->RandomString (CCreatorEngine::EMeetingPlace ); + parameters->iDescription->Des ( ) + = iEngine->RandomString (CCreatorEngine::EMeetingReason ); + + parameters->iSummary->Des() + = parameters->iDescription->Des(); + + parameters->iNumberRepeatingEntries = iNumberRepeatingEntries; + parameters->iNumberOfAttendees = iNumberOfAttendees; + } + + TInt err = KErrNone; + HBufC8* guid = HBufC8::NewLC (255 ); + TPtr8 uidP=guid->Des ( ); + GenerateRandomId (uidP ); + CCalEntry* entry = CCalEntry::NewL (CCalEntry::EAppt, guid, + CCalEntry::EMethodAdd, 0 ); + CleanupStack::PushL (entry ); + + //Using same text as description and summary + entry->SetDescriptionL (parameters->iDescription->Des ( ) ); + entry->SetSummaryL (parameters->iSummary->Des ( ) ); + entry->SetLocationL (parameters->iLocation->Des ( ) ); + + TCalTime startTime; + TCalTime endTime; + // Set the start and end times using time values local to the current system time zone + TInt month = (TInt) parameters->iStartTime.DateTime().Month(); + TInt date = parameters->iStartTime.DateTime().Day(); + startTime.SetTimeLocalL (parameters->iStartTime ); + endTime.SetTimeLocalL (parameters->iEndTime ); + entry->SetStartAndEndTimeL (startTime, endTime ); + + if( parameters->IsAllowedEntryStatus(CCalEntry::EAppt, parameters->iStatus)) + { + LOGSTRING2("Creator: CCreatorInterimCalendar::CreateAppointmentEntryL setting entry status: %d", parameters->iStatus); + entry->SetStatusL(parameters->iStatus); + } + + // Repeating times: + AddRepeatingRuleL(startTime, *entry, parameters); + SetOrganizerL(*entry, parameters); + + // Alarm: + if( iSetAlarm || parameters->iUseRandomAlarmTime ) + { + SetRandomAlarmL(*entry); + } + else + { + SetAlarmL(*entry, parameters); + } + + // Add attendees: + AddAttendeesL(*entry, parameters); + + RPointerArray array; + CleanupClosePushL (array ); + array.AppendL (entry ); + + TInt success(0); + //If StoreL() leaves, 'success' contains the number of entries that were stored before it failed + iCalEntryView->StoreL (array, success ); + + // id has been generated, store it for being able to delete + // entries created only with Creator + iEntryIds.AppendL( entry->LocalUidL() ); + + //One item should be added at time + if (success != 1 ) + { + err = 1; + } + + CleanupStack::PopAndDestroy (&array ); + CleanupStack::PopAndDestroy (entry ); + CleanupStack::Pop (guid );//guid has been destroyed by entry, which has ownership to guid + + return err; + } + +void CCreatorInterimCalendar::SetOrganizerL(CCalEntry& aCalEntry, CCalenderInterimParameters* parameters ) + { + HBufC* orgName = 0; + HBufC* orgEmail = 0; + _LIT(KSpace, " "); + + // + // Common name + // + if( parameters == 0 || + parameters->iOrganizerName == 0 || + parameters->iOrganizerName->Length() == 0 ) + { + // Random: + TPtrC firstname = iEngine->RandomString(CCreatorEngine::EFirstName); + TPtrC lastname = iEngine->RandomString(CCreatorEngine::ESurname); + orgName = HBufC::NewL(firstname.Length() + lastname.Length() + 1 ); + CleanupStack::PushL(orgName); + orgName->Des().Copy(firstname); + orgName->Des().Append(KSpace); + orgName->Des().Append(lastname); + } + else + { + orgName = HBufC::NewL(parameters->iOrganizerName->Length()); + CleanupStack::PushL(orgName); + orgName->Des().Copy(parameters->iOrganizerName->Des()); + } + + // + // Email + // + if( parameters == 0 || + parameters->iOrganizerEmail == 0 || + parameters->iOrganizerEmail->Length() == 0 ) + { + // Random: + TDesC* tmp = iEngine->CreateEmailAddressLC(); + orgEmail = HBufC::NewL(tmp->Length()); + orgEmail->Des().Copy(*tmp); + CleanupStack::PopAndDestroy(); // tmp + CleanupStack::PushL(orgEmail); + } + else + { + orgEmail = HBufC::NewL(parameters->iOrganizerEmail->Length()); + CleanupStack::PushL(orgEmail); + orgEmail->Des().Copy(parameters->iOrganizerEmail->Des()); + } + + SetOrganizerL(aCalEntry, orgName->Des(), orgEmail->Des(), orgEmail->Des()); + CleanupStack::PopAndDestroy(); // orgName + CleanupStack::PopAndDestroy(); // orgEmail + } + +void CCreatorInterimCalendar::AddRepeatingRuleL(const TCalTime& aStartTime, CCalEntry& aCalEntry, CCalenderInterimParameters* parameters ) + { + RArray days; + CleanupClosePushL(days); + + // Recurrence rule. Weekly event. + if( parameters->iNumberRepeatingEntries > 0 ) + { + TCalRRule calRepeat(TCalRRule::EWeekly); + calRepeat.SetDtStart(aStartTime); + calRepeat.SetCount(parameters->iNumberRepeatingEntries); + calRepeat.SetInterval(1); + //days.AppendL((TDay) iEngine->RandomNumber((TInt)EMonday, (TInt) ESunday)); + TDay tempDay(aStartTime.TimeLocalL().DayNoInWeek()); + days.AppendL(tempDay); + calRepeat.SetByDay(days); + aCalEntry.SetRRuleL(calRepeat); + } + else if(parameters->iRecurrentFrequency > TCalRRule::EInvalid) + { + TCalTime calTime; + // Recurrent frequency + TCalRRule calRepeat(parameters->iRecurrentFrequency); + // Recurrent start + calRepeat.SetDtStart(aStartTime); + if( parameters->iRecurrentFrequency == TCalRRule::EWeekly ) + { + TDay tempDay(aStartTime.TimeLocalL().DayNoInWeek()); + days.AppendL(tempDay); + calRepeat.SetByDay(days); + } + else if( parameters->iRecurrentFrequency == TCalRRule::EMonthly ) + { + RArray< TInt > daysInMonth; + CleanupClosePushL(daysInMonth); + daysInMonth.AppendL(aStartTime.TimeLocalL().DayNoInMonth()); + calRepeat.SetByMonthDay(daysInMonth); + CleanupStack::PopAndDestroy(&daysInMonth); + } + else if( parameters->iRecurrentFrequency == TCalRRule::EYearly) + { + RArray< TMonth > monthsInYear; + CleanupClosePushL(monthsInYear); + monthsInYear.AppendL(aStartTime.TimeLocalL().DateTime().Month()); + calRepeat.SetByMonth(monthsInYear); + CleanupStack::PopAndDestroy(&monthsInYear); + } + + // Recurrent interval + if( parameters->iRecurrentInterval > 0 ) + calRepeat.SetInterval(parameters->iRecurrentInterval); + + // Recurrent end. End can be given as a number of repeating entries or as an end date. + // End date must be later than the start date, otherwise CCalEntry::SetRRuleL() panics. + if( parameters->iRepeatingCount > 0 ) + { + calRepeat.SetCount(parameters->iRepeatingCount); + aCalEntry.SetRRuleL(calRepeat); + } + else + { + TCalTime endTime; + endTime.SetTimeLocalL(parameters->iRecurrentEndTime); + if( endTime.TimeLocalL() > aStartTime.TimeLocalL()) + { + calRepeat.SetUntil(endTime); + aCalEntry.SetRRuleL(calRepeat); + } + } + } + CleanupStack::PopAndDestroy(&days); + } + +void CCreatorInterimCalendar::SetAlarmL(CCalEntry& aCalEntry, CCalenderInterimParameters* params) + { + if( params->iAlarmTime != Time::NullTTime() ) + { + CCalAlarm* alarm = CCalAlarm::NewL(); + CleanupStack::PushL(alarm); + //if( params->iAlarmTime <= params->iStartTime ) + // { + TTimeIntervalMinutes diff; + TInt err = params->iStartTime.MinutesFrom(params->iAlarmTime, diff); + if( err == KErrNone) + { + alarm->SetTimeOffset(diff); + TRAP(err, aCalEntry.SetAlarmL(alarm)); + if( err != KErrNone && err != KErrNotSupported ) + { + User::Leave(err); + } + } + // } + CleanupStack::PopAndDestroy(alarm); + } + } + +void CCreatorInterimCalendar::SetRandomAlarmL(CCalEntry& aCalEntry) + { + CCalAlarm* alarm = CCalAlarm::NewL(); + CleanupStack::PushL(alarm); + alarm->SetTimeOffset(TTimeIntervalMinutes(iEngine->RandomNumber(0, 60))); + + TRAPD(err, aCalEntry.SetAlarmL(alarm)); + if( err != KErrNone && err != KErrNotSupported ) + { + User::Leave(err); + } + CleanupStack::PopAndDestroy(alarm); + } + +void CCreatorInterimCalendar::SetPhoneOwnerL(CCalEntry& aCalEntry, const TDesC& aCN, const TDesC& aEmail, const TDesC& aSentBy ) + { + CCalUser* phOwner = CCalUser::NewL(aEmail, aSentBy); + CleanupStack::PushL(phOwner); + TRAPD(err, aCalEntry.SetPhoneOwnerL(phOwner)); + CleanupStack::Pop(phOwner); + if( err == KErrNone ) + { + phOwner->SetCommonNameL(aCN); + } + else + { + delete phOwner; + } + } + +void CCreatorInterimCalendar::SetOrganizerL(CCalEntry& aCalEntry, const TDesC& aCN, const TDesC& aEmail, const TDesC& aSentBy) + { + CCalUser* organizer = CCalUser::NewL(aEmail, aSentBy); + CleanupStack::PushL(organizer); + TRAPD(err, aCalEntry.SetOrganizerL(organizer)); + CleanupStack::Pop(organizer); + if( err == KErrNone ) + { + organizer->SetCommonNameL(aCN); + } + else + { + delete organizer; + } + } + +void CCreatorInterimCalendar::AddAttendeesL(CCalEntry& aCalEntry, CCalenderInterimParameters* parameters ) + { + if( !parameters ) + return; + + // Random attendees: + TInt numOfAttendees = parameters->iNumberOfAttendees; + for( TInt i = 0; i < numOfAttendees; ++i ) + { + TPtrC firstname = iEngine->RandomString(CCreatorEngine::EFirstName); + TPtrC lastname = iEngine->RandomString(CCreatorEngine::ESurname); + TPtrC company = iEngine->RandomString(CCreatorEngine::ECompany); + _LIT(KCountry, "com"); + TDesC* emailAddr = iEngine->CreateEmailAddressLC(firstname, lastname, company, KCountry); + CCalAttendee* attendee = CCalAttendee::NewL(*emailAddr); + CleanupStack::PushL(attendee); + aCalEntry.AddAttendeeL(attendee); + CleanupStack::Pop(attendee); + attendee->SetCommonNameL(firstname); + + // Set phone owner: + if( i == 1 ) + { + SetPhoneOwnerL(aCalEntry, firstname, *emailAddr, *emailAddr); + attendee->SetRoleL(CCalAttendee::EReqParticipant); + } + // Set organizer: + else if ( i == 0 ) + { + // Organizer is the chairman of the meeting: + SetOrganizerL(aCalEntry, firstname, *emailAddr, *emailAddr); + attendee->SetRoleL(CCalAttendee::EChair); + } + else if( i % 3 == 0 ) + { + // every third attendee is optional: + attendee->SetRoleL(CCalAttendee::EOptParticipant); + } + else + { + // Others are required attendees: + attendee->SetRoleL(CCalAttendee::EReqParticipant); + } + + TInt attStatus = iEngine->RandomNumber(0,5); + attendee->SetStatusL((CCalAttendee::TCalStatus) attStatus); + + CleanupStack::PopAndDestroy(emailAddr); + } + + // Explicit attendees: + for( TInt i = 0; i < parameters->iAttendees.Count(); ++i ) + { + CCreatorCalenderAttendee* attendeeInfo = parameters->iAttendees[i]; + if( attendeeInfo && attendeeInfo->EmailAddress().Length() > 0) + { + CCalAttendee* attendee = CCalAttendee::NewL(attendeeInfo->EmailAddress()); + CleanupStack::PushL(attendee); + if( attendeeInfo->CommonName().Length() > 0 ) + attendee->SetCommonNameL(attendeeInfo->CommonName()); + attendee->SetRoleL(attendeeInfo->Role()); + attendee->SetStatusL(attendeeInfo->Status()); + attendee->SetResponseRequested(ETrue); + aCalEntry.AddAttendeeL(attendee); + CleanupStack::Pop(); // attendee + } + } + // linked attendees: + for( TInt i = 0; i < parameters->iAttendeeLinkIds.Count(); ++i ) + { + CCreatorPhonebook* phonebook = dynamic_cast(iEngine->GetPhonebook()); + User::LeaveIfNull( phonebook ); + CCreatorPhonebookWrapper* phonebookWrapper = phonebook->GetPhonebookWrapper(); + + TLinkIdParam attendeeLinkId = parameters->iAttendeeLinkIds[i]; + const CCreatorContactSet& set = ContactLinkCache::Instance()->ContactSet(attendeeLinkId.iLinkId); + const RArray links = set.ContactLinks(); + TInt numberOfExplicitLinks = links.Count(); // Number of defined contacts in contact-set + for( TInt j = 0; j < numberOfExplicitLinks; ++j ) + { + TBuf<128> email; + TBuf<128> name; + TBuf<128> phoneNumber; + phonebookWrapper->GetContactDetailsL( links[j], name, phoneNumber, email ); + CCalAttendee* attendee = CCalAttendee::NewL( email ); + CleanupStack::PushL(attendee); + if( name.Length() > 0 ) + attendee->SetCommonNameL( name ); + attendee->SetResponseRequested(ETrue); + aCalEntry.AddAttendeeL(attendee); + CleanupStack::Pop(); // attendee + } + } + } +//---------------------------------------------------------------------------- + +TInt CCreatorInterimCalendar::CreateEventEntryL ( + CCreatorModuleBaseParameters *aParameters ) + { + LOGSTRING("Creator: CCreatorInterimCalendar::CreateEventEntryL"); + + delete iParameters; + iParameters = 0; + + CCalenderInterimParameters* parameters = (CCalenderInterimParameters*)aParameters; + + // random data needed if no predefined data available + if (!parameters ) + { + iParameters = new(ELeave) CCalenderInterimParameters; + + iParameters->iRandomModeStartTime = iRandomModeStartTime; + iParameters->iRandomModeEndTime = iRandomModeEndTime; + iParameters->iNumberRepeatingEntries = iNumberRepeatingEntries; + iParameters->iNumberOfAttendees = iNumberOfAttendees; + + // difference between start and end times + TTimeIntervalMinutes differenceInMinutes; + iParameters->iRandomModeEndTime.MinutesFrom ( + iParameters->iRandomModeStartTime, differenceInMinutes ); + + // start time (= something between the period start and end date) + iParameters->iStartTime = iParameters->iRandomModeStartTime; + iParameters->iStartTime + += TTimeIntervalMinutes (iEngine->RandomNumber (differenceInMinutes.Int ( ) ) ); + + // set end time (= start time + some random time) + iParameters->iEndTime = iParameters->iStartTime; + iParameters->iEndTime + += TTimeIntervalMinutes (iEngine->RandomNumber (5, 500 ) ); + + // strings + iParameters->iDescription->Des() + = iEngine->RandomString (CCreatorEngine::EMemoText ); + + iParameters->iSummary->Des() = iParameters->iDescription->Des(); + + // Random event status: + iParameters->iStatus = + (CCalEntry::TStatus) iEngine->RandomNumber(0, (TInt) CCalEntry::ECancelled); + + parameters = iParameters; + } + + TInt err = KErrNone; + HBufC8* guid = HBufC8::NewLC (255 ); + TPtr8 uidP=guid->Des ( ); + GenerateRandomId (uidP ); + CCalEntry* entry = CCalEntry::NewL (CCalEntry::EEvent, guid, + CCalEntry::EMethodAdd, 0 ); + CleanupStack::PushL (entry ); + // iEntryUids->AppendL( *guid->Alloc() ); + + entry->SetDescriptionL (parameters->iDescription->Des ( ) ); + entry->SetSummaryL (parameters->iSummary->Des ( ) ); + + TCalTime startTime; + TCalTime endTime; + // Set the start and end times using time values local to the current system time zone + startTime.SetTimeLocalL (parameters->iStartTime ); + endTime.SetTimeLocalL (parameters->iEndTime ); + entry->SetStartAndEndTimeL (startTime, endTime ); + + // Repeating times: + AddRepeatingRuleL(startTime, *entry, parameters); + + if( iSetAlarm || parameters->iUseRandomAlarmTime ) + { + SetRandomAlarmL(*entry); + } + else + { + SetAlarmL(*entry, parameters); + } + + // Add attendees: + AddAttendeesL(*entry, parameters); + + if( parameters->IsAllowedEntryStatus(CCalEntry::EEvent, parameters->iStatus)) + { + LOGSTRING2("Creator: CCreatorInterimCalendar::CreateEventEntryL setting entry status: %d", parameters->iStatus); + entry->SetStatusL(parameters->iStatus); + } + + RPointerArray array; + CleanupClosePushL (array ); + array.AppendL (entry ); + + TInt success(0); + //If StoreL() leaves, 'success' contains the number of entries that were stored before it failed + iCalEntryView->StoreL (array, success ); + + // id has been generated, store it for being able to delete + // entries created only with Creator + iEntryIds.AppendL( entry->LocalUidL() ); + + //One item should be added at time + if (success != 1 ) + { + err = 1; + } + + CleanupStack::PopAndDestroy (&array ); + CleanupStack::PopAndDestroy (entry ); + CleanupStack::Pop (guid );//guid has been destroyed by entry, which has ownership to guid + return err; + + } + +//---------------------------------------------------------------------------- + + +TInt CCreatorInterimCalendar::CreateReminderEntryL ( + CCreatorModuleBaseParameters *aParameters ) + { + LOGSTRING("Creator: CCreatorInterimCalendar::CreateReminderEntryL"); + + delete iParameters; + iParameters = NULL; + + CCalenderInterimParameters* parameters = (CCalenderInterimParameters*)aParameters; + + // random data needed if no predefined data available + if (!parameters ) + { + iParameters = new(ELeave) CCalenderInterimParameters; + + iParameters->iRandomModeStartTime = iRandomModeStartTime; + iParameters->iRandomModeEndTime = iRandomModeEndTime; + + // difference between start and end times + TTimeIntervalDays + differenceInDays = iParameters->iRandomModeEndTime.DaysFrom (iParameters->iRandomModeStartTime ); + + // due time (= something between the period start and end date) + iParameters->iStartTime = iParameters->iRandomModeStartTime; + iParameters->iStartTime + += TTimeIntervalDays (iEngine->RandomNumber (differenceInDays.Int ( ) ) ); + + // strings + iParameters->iDescription->Des() + = iEngine->RandomString (CCreatorEngine::EReminderText ); + + iParameters->iSummary->Des() = iParameters->iDescription->Des(); + + parameters = iParameters; + } + + TInt err = KErrNone; + + HBufC8* guid = HBufC8::NewLC (255 ); + TPtr8 uidP=guid->Des ( ); + GenerateRandomId (uidP ); + + CCalEntry* entry = CCalEntry::NewL (CCalEntry::EReminder, guid, + CCalEntry::EMethodAdd, 0 ); + CleanupStack::PushL (entry ); + + //Using same text as description and summary + entry->SetDescriptionL (parameters->iDescription->Des ( ) ); + entry->SetSummaryL (parameters->iSummary->Des ( ) ); + + TCalTime startTime; + TCalTime endTime; + // Set the start and end times using time values local to the current system time zone + startTime.SetTimeLocalL (parameters->iStartTime ); + TTime nullTime = Time::NullTTime ( ); + endTime.SetTimeLocalL (nullTime ); + entry->SetStartAndEndTimeL (startTime, endTime ); + + if( parameters->IsAllowedEntryStatus(CCalEntry::EReminder, parameters->iStatus)) + { + LOGSTRING2("Creator: CCreatorInterimCalendar::CreateReminderEntryL setting entry status: %d", parameters->iStatus); + entry->SetStatusL(parameters->iStatus); + } + + if( iSetAlarm || parameters->iUseRandomAlarmTime ) + { + SetRandomAlarmL(*entry); + } + else + { + SetAlarmL(*entry, parameters); + } + + RPointerArray array; + CleanupClosePushL (array ); + array.AppendL (entry ); + + TInt success(0); + //If StoreL() leaves, 'success' contains the number of entries that were stored before it failed + iCalEntryView->StoreL (array, success ); + + // id has been generated, store it for being able to delete + // entries created only with Creator + iEntryIds.AppendL( entry->LocalUidL() ); + + //One item should be added at time + if (success != 1 ) + { + err = 1; + } + + CleanupStack::PopAndDestroy (&array ); + CleanupStack::PopAndDestroy (entry ); + CleanupStack::Pop (guid );//guid has been destroyed by entry, which has ownership to guid + + return err; + } + +//---------------------------------------------------------------------------- + +TInt CCreatorInterimCalendar::CreateAnniversaryEntryL ( + CCreatorModuleBaseParameters *aParameters ) + { + LOGSTRING("Creator: CCreatorInterimCalendar::CreateAnniversaryEntryL"); + + delete iParameters; + iParameters = NULL; + + CCalenderInterimParameters* parameters = (CCalenderInterimParameters*)aParameters; + + // random data needed if no predefined data available + if (!parameters ) + { + iParameters = new(ELeave) CCalenderInterimParameters; + + iParameters->iRandomModeStartTime = iRandomModeStartTime; + iParameters->iRandomModeEndTime = iRandomModeEndTime; + + // difference between start and end times + TTimeIntervalDays differenceInDays = iParameters->iRandomModeEndTime.DaysFrom(iParameters->iRandomModeStartTime); + + // start time (= something between the period start and end date) + iParameters->iStartTime = iParameters->iRandomModeStartTime; + iParameters->iStartTime += TTimeIntervalDays( iEngine->RandomNumber(differenceInDays.Int()) ); + + // strings + iParameters->iDescription->Des().Copy (iEngine->RandomString (CCreatorEngine::EFirstName ) ); + iParameters->iDescription->Des().Append ( _L("'s ") ); + iParameters->iDescription->Des().Append (iEngine->RandomString (CCreatorEngine::EAnniversaryReason ) ); + iParameters->iSummary->Des() = iParameters->iDescription->Des(); + parameters = iParameters; + } + + TInt err = KErrNone; + + HBufC8* guid = HBufC8::NewLC (255 ); + TPtr8 uidP=guid->Des ( ); + GenerateRandomId (uidP ); + + CCalEntry* entry = CCalEntry::NewL (CCalEntry::EAnniv, guid, + CCalEntry::EMethodNone, 0 ); + CleanupStack::PushL (entry ); + + //Using same text as description and summary + entry->SetDescriptionL (parameters->iDescription->Des ( ) ); + entry->SetSummaryL (parameters->iSummary->Des ( ) ); + + TCalTime startTime; + TCalTime endTime; + TTime nullTime = Time::NullTTime ( ); + endTime.SetTimeLocalL (nullTime ); + + // Set the start time using time value local to the current system time zone + startTime.SetTimeLocalL (parameters->iStartTime ); + + entry->SetStartAndEndTimeL (startTime, endTime ); + + if( iSetAlarm || parameters->iUseRandomAlarmTime ) + { + SetRandomAlarmL(*entry); + } + else + { + SetAlarmL(*entry, parameters); + } + + //set repeating rule + TCalRRule yearlyRptRule(TCalRRule::EYearly); + yearlyRptRule.SetDtStart (startTime ); + //Set repeating until forever, not setting it to stop + //yearlyRptRule.SetUntil(endTime); + entry->SetRRuleL (yearlyRptRule ); + + RPointerArray array; + CleanupClosePushL (array ); + array.AppendL (entry ); + + TInt success(0); + //If StoreL() leaves, 'success' contains the number of entries that were stored before it failed + iCalEntryView->StoreL (array, success ); + + // id has been generated, store it for being able to delete + // entries created only with Creator + iEntryIds.AppendL( entry->LocalUidL() ); + + //One item should be added at time + if (success != 1 ) + { + err = 1; + } + + CleanupStack::PopAndDestroy (&array ); + CleanupStack::PopAndDestroy (entry ); + CleanupStack::Pop (guid );//guid has been destroyed by entry, which has ownership to guid + + return err; + } + +//---------------------------------------------------------------------------- + +TInt CCreatorInterimCalendar::CreateTodoEntryL ( + CCreatorModuleBaseParameters *aParameters ) + { + LOGSTRING("Creator: CCreatorInterimCalendar::CreateTodoEntryL"); + + delete iParameters; + iParameters = NULL; + + CCalenderInterimParameters* parameters = (CCalenderInterimParameters*)aParameters; + + // random data needed if no predefined data available + if (!parameters ) + { + iParameters = new(ELeave) CCalenderInterimParameters; + + iParameters->iRandomModeStartTime = iRandomModeStartTime; + iParameters->iRandomModeEndTime = iRandomModeEndTime; + + // difference between start and end times + TTimeIntervalDays + differenceInDays = iParameters->iRandomModeEndTime.DaysFrom (iParameters->iRandomModeStartTime ); + + // due time (= something between the period start and end date) + iParameters->iTodoDueTime = iParameters->iRandomModeStartTime; + iParameters->iTodoDueTime + += TTimeIntervalDays (iEngine->RandomNumber (differenceInDays.Int ( ) ) ); + + // strings + iParameters->iDescription->Des ( ) + = iEngine->RandomString (CCreatorEngine::EToDoText ); + + iParameters->iSummary->Des() = iParameters->iDescription->Des(); + + //priority + iParameters->iTodoPriority = iEngine->RandomNumber (1, 3 ); + iParameters->iStatus = (CCalEntry::TStatus) iEngine->RandomNumber((TInt) CCalEntry::ETodoNeedsAction, (TInt) CCalEntry::ETodoInProcess); + parameters = iParameters; + + } + + TInt err = KErrNone; + + HBufC8* guid = HBufC8::NewLC (255 ); + TPtr8 uidP=guid->Des ( ); + GenerateRandomId (uidP ); + + CCalEntry* entry = CCalEntry::NewL (CCalEntry::ETodo, guid, + CCalEntry::EMethodAdd, 0 ); + CleanupStack::PushL (entry ); + + //Using same text as description and summary + entry->SetDescriptionL (parameters->iDescription->Des ( ) ); + entry->SetSummaryL (parameters->iSummary->Des ( ) ); + + entry->SetPriorityL (parameters->iTodoPriority ); + + if( parameters->IsAllowedEntryStatus(CCalEntry::ETodo, parameters->iStatus)) + { + LOGSTRING2("Creator: CCreatorInterimCalendar::CreateTodoEntryL setting entry status: %d", parameters->iStatus); + entry->SetStatusL(parameters->iStatus); + } + + TCalTime startTime; + TCalTime endTime; + // Set the start and end times using time values local to the current system time zone + startTime.SetTimeLocalL (parameters->iTodoDueTime ); + endTime.SetTimeLocalL (parameters->iTodoDueTime ); + entry->SetStartAndEndTimeL (startTime, endTime ); + + if( iSetAlarm || parameters->iUseRandomAlarmTime ) + { + SetRandomAlarmL(*entry); + } + else + { + SetAlarmL(*entry, parameters); + } + + RPointerArray array; + CleanupClosePushL (array ); + array.AppendL (entry ); + + TInt success(0); + //If StoreL() leaves, 'success' contains the number of entries that were stored before it failed + iCalEntryView->StoreL (array, success ); + + // id has been generated, store it for being able to delete + // entries created only with Creator + iEntryIds.AppendL( entry->LocalUidL() ); + + //One item should be added at time + if (success != 1 ) + { + err = 1; + } + + CleanupStack::PopAndDestroy (&array ); + CleanupStack::PopAndDestroy (entry ); + CleanupStack::Pop (guid );//guid has been destroyed by entry, which has ownership to guid + + return err; + } + +//---------------------------------------------------------------------------- + +void CCreatorInterimCalendar::Progress (TInt /*aPercentageCompleted*/) + { + //Not really needed but observer need to be implement + } + +void CCreatorInterimCalendar::Completed (TInt aError ) + { + //Not really needed but observer need to be implement + LOGSTRING2("Creator: CCreatorInterimCalendar::Completed err=%d", aError); + } + +TBool CCreatorInterimCalendar::NotifyProgress ( ) + { + //Not really needed but observer need to be implement + return NULL; + } + +//---------------------------------------------------------------------------- + + +void CCreatorInterimCalendar::GenerateRandomId (TDes8& aText ) + { + LOGSTRING("Creator: CCreatorInterimCalendar::GenerateRandomId"); + + aText.Zero ( ); + + TTime now; + now.UniversalTime ( ); + TInt64 time = now.Int64 ( ); + + // The number of characters in the guid should be + // more than 8 (to ensure the guids are not too small) + // less than 255 (this is the maximum length of a guid) + // less than MaxLength of the descriptor passed in + TInt numChar(0); + do + { + numChar = Math::Rand (time ) % (aText.MaxLength ( ) - 1); + } + while (numChar > 255|| numChar < 8 ); + + for (TInt i(0); i < numChar ; ++i ) + { + TInt character = Math::Rand (time )%6; + character = Math::Rand (time ) % 26+ ((character == 2) ? 'A' : 'a'); + aText.Append (character ); + } + + } + +//---------------------------------------------------------------------------- +void CCreatorInterimCalendar::DeleteAllL() + { + LOGSTRING("Creator: CCreatorInterimCalendar::DeleteAllL"); + TCalTime zeroTime; + zeroTime.SetTimeUtcL( TCalTime::MinTime() ); + RArray allIds; + CleanupClosePushL( allIds ); + iCalEntryView->GetIdsModifiedSinceDateL( zeroTime, allIds ); + if ( allIds.Count() ) + { + TInt successCount( KErrNotFound ); + iCalEntryView->DeleteL( allIds, successCount ); + if ( successCount != allIds.Count() ) + { + User::Leave( KErrGeneral ); + } + } + CleanupStack::PopAndDestroy( &allIds ); + + // reset must be done here, because iEntryIds is stored in destructor + iEntryIds.Reset(); + + // all entries deleted, remove the Calendar related registry + iEngine->RemoveStoreL( KUidDictionaryUidCalendar ); + } + +//---------------------------------------------------------------------------- +void CCreatorInterimCalendar::DeleteAllCreatedByCreatorL() + { + LOGSTRING("Creator: CCreatorInterimCalendar::DeleteAllCreatedByCreatorL"); + iEntryIds.Reset(); + + // fetch ids of entries created by Creator + iEngine->ReadEntryIdsFromStoreL( iEntryIds, KUidDictionaryUidCalendar ); + + // delete entries + TInt successCount(0); // ignore + TRAP_IGNORE( iCalEntryView->DeleteL( iEntryIds, successCount ) ); + + // reset must be done here, because iEntryIds is stored in destructor + iEntryIds.Reset(); + + // all entries deleted, remove the Calendar related registry + iEngine->RemoveStoreL( KUidDictionaryUidCalendar ); + } + +//---------------------------------------------------------------------------- + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/src/creator_calendarelement.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/src/creator_calendarelement.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,596 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +#include "creator_calendarelement.h" +#include "creator_traces.h" +#include "creator_calendar.h" + +using namespace creatorcalendar; + +CCreatorCalendarElement* CCreatorCalendarElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext ) + { + CCreatorCalendarElement* self = new (ELeave) CCreatorCalendarElement(aEngine); + CleanupStack::PushL(self); + self->ConstructL(aName, aContext); + CleanupStack::Pop(self); + return self; + } + +void CCreatorCalendarElement::FillEntryParamsL(TEntryType aType, const RPointerArray& fields, CCalenderInterimParameters* parameters) + { + if( parameters == 0 ) + return; + + TBool startResolved = EFalse; + TBool endResolved = EFalse; + + for( TInt i = 0; i < fields.Count(); ++i ) + { + TPtrC elemName = fields[i]->Name(); + TPtrC elemContent = fields[i]->Content(); + const CCreatorScriptAttribute* randomAttr = fields[i]->FindAttributeByName(KRandomLength); + + if( elemName == KSummary || elemName == KDescription ) + { + if( randomAttr || elemContent.Length() == 0 ) + { + TPtrC reason; + if( aType == EAppointment ) + { + reason.Set(iEngine->RandomString (CCreatorEngine::EMeetingReason )); + } + else if( aType == EEvent ) + { + reason.Set(iEngine->RandomString(CCreatorEngine::EMemoText)); + } + else if( aType == EReminder ) + { + reason.Set(iEngine->RandomString(CCreatorEngine::EReminderText)); + } + else if( aType == EAnniversary ) + { + reason.Set(iEngine->RandomString(CCreatorEngine::EAnniversaryReason)); + } + else if( aType == ETodo ) + { + reason.Set(iEngine->RandomString(CCreatorEngine::EToDoText)); + } + + if( elemName == KDescription ) + { + delete parameters->iDescription; + parameters->iDescription = 0; + parameters->iDescription = HBufC::NewL(reason.Length()); + parameters->iDescription->Des().Copy(reason); + } + else if(elemName == KSummary) + { + delete parameters->iSummary; + parameters->iSummary = 0; + parameters->iSummary = HBufC::NewL(reason.Length()); + parameters->iSummary->Des().Copy(reason); + } + } + else if( elemName == KDescription ) + { + delete parameters->iDescription; + parameters->iDescription = 0; + parameters->iDescription = HBufC::NewL(elemContent.Length()); + parameters->iDescription->Des().Copy(elemContent); + } + else if( elemName == KSummary) + { + delete parameters->iSummary; + parameters->iSummary = 0; + parameters->iSummary = HBufC::NewL(elemContent.Length()); + parameters->iSummary->Des().Copy(elemContent); + } + } + else if( elemName == KLocation ) + { + delete parameters->iLocation; + parameters->iLocation = 0; + + if( randomAttr || elemContent.Length() == 0 ) + { + TPtrC reason = iEngine->RandomString (CCreatorEngine::EMeetingPlace ); + parameters->iLocation = HBufC::NewL(reason.Length()); + parameters->iLocation->Des().Copy(reason); + } + else + { + parameters->iLocation = HBufC::NewL(elemContent.Length()); + parameters->iLocation->Des().Copy(elemContent); + } + } + else if( elemName == KStarttime ) + { + if( randomAttr || elemContent.Length() == 0 ) + { + // Random start time used. If end time is already resolved, let's use that one for the basis. + if( endResolved ) + { + parameters->iStartTime = iEngine->RandomTime(parameters->iEndTime, CCreatorEngine::EDatePast); + } + else + { + // Past or future: + CCreatorEngine::TRandomDateType pastOrfuture = + (CCreatorEngine::TRandomDateType) iEngine->RandomNumber((TInt) CCreatorEngine::EDatePast, + (TInt) CCreatorEngine::EDateFuture); + + parameters->iStartTime = + iEngine->RandomTime(iEngine->RandomDate(pastOrfuture), pastOrfuture); + } + } + else + { + parameters->iStartTime = ConvertToDateTimeL(elemContent); + } + startResolved = ETrue; + } + else if( elemName == KEndtime ) + { + if( randomAttr || elemContent.Length() == 0 ) + { + // Random end time used. If start time is already resolved, let's use that one. + if( startResolved ) + { + parameters->iEndTime = iEngine->RandomTime(parameters->iStartTime, CCreatorEngine::EDateFuture); + } + else + { + // Past or future: + CCreatorEngine::TRandomDateType pastOrfuture = + (CCreatorEngine::TRandomDateType) iEngine->RandomNumber((TInt) CCreatorEngine::EDatePast, + (TInt) CCreatorEngine::EDateFuture); + + parameters->iEndTime = + iEngine->RandomTime(iEngine->RandomDate(pastOrfuture), pastOrfuture); + } + } + else + { + parameters->iEndTime = ConvertToDateTimeL(elemContent); + } + if( aType == ETodo ) + { + parameters->iTodoDueTime = parameters->iEndTime; + } + endResolved = ETrue; + } + else if( elemName == KRecurrentFreq ) + { + TInt randomFreq = 0; + if( randomAttr || elemContent.Length() == 0 ) + { + randomFreq = iEngine->RandomNumber(1, 4); + } + if(randomFreq == 1 || CompareIgnoreCase(elemContent, KDaily) == 0 ) + parameters->iRecurrentFrequency = TCalRRule::EDaily; + else if( randomFreq == 2 || CompareIgnoreCase(elemContent, KWeekly) == 0 ) + parameters->iRecurrentFrequency = TCalRRule::EWeekly; + else if( randomFreq == 3 || CompareIgnoreCase(elemContent, KMonthly) == 0 ) + parameters->iRecurrentFrequency = TCalRRule::EMonthly; + else if( randomFreq == 4 || CompareIgnoreCase(elemContent, KYearly) == 0 ) + parameters->iRecurrentFrequency = TCalRRule::EYearly; + else + parameters->iRecurrentFrequency = TCalRRule::EInvalid; + } + else if( elemName == KRecurrentInterval ) + { + if( randomAttr || elemContent.Length() == 0 ) + { + parameters->iRecurrentInterval = iEngine->RandomNumber(1,7); + } + else + { + parameters->iRecurrentInterval = ConvertStrToIntL(elemContent); + } + } + else if( elemName == KRecurrentFrom ) + { + if( randomAttr || elemContent.Length() == 0 ) + { + if( startResolved ) + { + // Let's use the start time if it's resolved. + parameters->iRecurrentStartTime = parameters->iStartTime; + } + else + { + parameters->iRecurrentStartTime = iEngine->RandomDate(CCreatorEngine::EDateFuture); + } + } + else + { + parameters->iRecurrentStartTime = ConvertToDateTimeL(elemContent); + } + } + else if( elemName == KRecurrentTo ) + { + if( randomAttr || elemContent.Length() == 0 ) + { + parameters->iRepeatingCount = iEngine->RandomNumber(1, 6); + //parameters->iRecurrentEndTime = iEngine->RandomDate(CCreatorEngine::EDateFuture); + } + else + { + parameters->iRecurrentEndTime = ConvertToDateTimeL(elemContent); + } + } + else if( elemName == KRepeatingCount ) + { + if( randomAttr || elemContent.Length() == 0 ) + { + parameters->iRepeatingCount = iEngine->RandomNumber(1, 52); + } + else + { + parameters->iRepeatingCount = ConvertStrToIntL(elemContent); + } + } + else if( elemName == KAlarmtime ) + { + if( randomAttr || elemContent.Length() == 0 ) + { + parameters->iUseRandomAlarmTime = ETrue; + } + else + { + parameters->iAlarmTime = ConvertToDateTimeL(elemContent); + } + } + else if( elemName == KOrganizername ) + { + delete parameters->iOrganizerName; + parameters->iOrganizerName = 0; + if( randomAttr || elemContent.Length() == 0 ) + { + TPtrC name = iEngine->RandomString (CCreatorEngine::EFirstName ); + parameters->iOrganizerName = HBufC::NewL(name.Length()); + parameters->iOrganizerName->Des().Copy(name); + } + else + { + parameters->iOrganizerName = HBufC::NewL(elemContent.Length()); + parameters->iOrganizerName->Des().Copy(elemContent); + } + } + else if( elemName == KOrganizeremail ) + { + delete parameters->iOrganizerEmail; + parameters->iOrganizerEmail = 0; + if( randomAttr || elemContent.Length() == 0 ) + { + TDesC* email = iEngine->CreateEmailAddressLC(); + parameters->iOrganizerEmail = (HBufC*) email; + CleanupStack::Pop(); // email + } + else + { + parameters->iOrganizerEmail = HBufC::NewL(elemContent.Length()); + parameters->iOrganizerEmail->Des().Copy(elemContent); + } + } + else if( elemName == KStatus ) + { + if( randomAttr || elemContent.Length() == 0 ) + { + if( aType == ETodo ) + { + parameters->iStatus = (CCalEntry::TStatus) iEngine->RandomNumber(CCalEntry::ETodoNeedsAction, CCalEntry::ETodoInProcess); + } + else + { + parameters->iStatus = (CCalEntry::TStatus) iEngine->RandomNumber(CCalEntry::ETentative, CCalEntry::ECancelled); + } + } + else if( CompareIgnoreCase(elemContent, KCalStatusTentative) == 0 ) + { + parameters->iStatus = CCalEntry::ETentative; + } + else if( CompareIgnoreCase(elemContent, KCalStatusConfirmed) == 0 ) + { + parameters->iStatus = CCalEntry::EConfirmed; + } + else if( CompareIgnoreCase(elemContent, KCalStatusCancelled) == 0 ) + { + parameters->iStatus = CCalEntry::ECancelled; + } + else if( CompareIgnoreCase(elemContent, KCalStatusNeedsAction) == 0 ) + { + parameters->iStatus = CCalEntry::ETodoNeedsAction; + } + else if( CompareIgnoreCase(elemContent, KCalStatusCompleted) == 0 ) + { + parameters->iStatus = CCalEntry::ETodoCompleted; + } + else if( CompareIgnoreCase(elemContent, KCalStatusInProcess) == 0 ) + { + parameters->iStatus = CCalEntry::ETodoInProcess; + } + else + { + parameters->iStatus = CCalEntry::ENullStatus; + } + } + else if( elemName == KPriority ) + { + if( randomAttr || elemContent.Length() == 0 ) + { + parameters->iTodoPriority = iEngine->RandomNumber(1,3); + } + else if( CompareIgnoreCase(elemContent, KPriorityHigh) == 0) + { + parameters->iTodoPriority = 1; + } + else if( CompareIgnoreCase(elemContent, KPriorityMedium) == 0) + { + parameters->iTodoPriority = 2; + } + else if( CompareIgnoreCase(elemContent, KPriorityLow) == 0 ) + { + parameters->iTodoPriority = 3; + } + else + { + parameters->iTodoPriority = ConvertStrToIntL(elemContent); + } + } + else if( elemName == KAttendees ) + { + const RPointerArray& attendeesSubElems = fields[i]->SubElements(); + for( TInt j = 0; j < attendeesSubElems.Count(); ++j ) + { + TPtrC eName = attendeesSubElems[j]->Name(); + TPtrC eContent = attendeesSubElems[j]->Content(); + if( eName == KContactSetRef ) + { + AppendContactSetReferenceL(*attendeesSubElems[j], parameters->iAttendeeLinkIds); + } + else if( eName == KAttendee ) + { + CCreatorCalenderAttendee* calAtt = CCreatorCalenderAttendee::NewL(); + CleanupStack::PushL(calAtt); + const RPointerArray& attendeeFields = attendeesSubElems[j]->SubElements(); + // Make sure that at least email is given: + if(attendeeFields.Count() == 0 ) + { + CCreatorScriptElement* emailField = CCreatorScriptElement::NewL(iEngine, KEmail ); + CleanupStack::PushL(emailField); + fields[i]->SubElements().AppendL(emailField); + CleanupStack::Pop(); // emailField + } + for( TInt k = 0; k < attendeeFields.Count(); ++k ) + { + const CCreatorScriptAttribute* randomAttr = attendeeFields[k]->FindAttributeByName(KRandomLength); + TPtrC attElemName = attendeeFields[k]->Name(); + TPtrC attElemCont = attendeeFields[k]->Content(); + if( attElemName == KCommonname ) + { + if( randomAttr || attElemCont.Length() == 0) + { + // Random data: + calAtt->SetCommonNameL(iEngine->RandomString(CCreatorEngine::EFirstName)); + } + else + { + calAtt->SetCommonNameL(attElemCont); + } + } + else if( attElemName == KEmail ) + { + if( randomAttr || attElemCont.Length() == 0) + { + // Random data: + TDesC* email = iEngine->CreateEmailAddressLC(); + calAtt->SetEmailAddressL(*email); + CleanupStack::PopAndDestroy(); // email + } + else + { + calAtt->SetEmailAddressL(attElemCont); + } + } + else if( attElemName == KRole ) + { + if( randomAttr || attElemCont.Length() == 0) + { + // Random role: + CCalAttendee::TCalRole randomRole = + (CCalAttendee::TCalRole) iEngine->RandomNumber( + (TInt) CCalAttendee::EReqParticipant, + (TInt) CCalAttendee::EChair); + calAtt->SetRole(randomRole); + } + else if( CompareIgnoreCase(attElemCont, KRoleRequired) == 0 ) + { + calAtt->SetRole(CCalAttendee::EReqParticipant); + } + else if( CompareIgnoreCase(attElemCont, KRoleOptional) == 0 ) + { + calAtt->SetRole(CCalAttendee::EOptParticipant); + } + else if( CompareIgnoreCase(attElemCont, KRoleNonPart) == 0 ) + { + calAtt->SetRole(CCalAttendee::ENonParticipant); + } + else if( CompareIgnoreCase(attElemCont, KRoleChair) == 0 ) + { + calAtt->SetRole(CCalAttendee::EChair); + } + } + else if( attElemName == KStatus ) + { + if( randomAttr || attElemCont.Length() == 0) + { + // Random role: + CCalAttendee::TCalStatus randomStatus = + (CCalAttendee::TCalStatus) iEngine->RandomNumber( + (TInt) CCalAttendee::ENeedsAction, + (TInt) CCalAttendee::EInProcess); + calAtt->SetStatus(randomStatus); + } + else if( CompareIgnoreCase(attElemCont, KStatusNeedsAction) == 0 ) + { + calAtt->SetStatus(CCalAttendee::ENeedsAction); + } + else if( CompareIgnoreCase(attElemCont, KStatusAccepted) == 0 ) + { + calAtt->SetStatus(CCalAttendee::EAccepted); + } + else if( CompareIgnoreCase(attElemCont, KStatusTentative) == 0 ) + { + calAtt->SetStatus(CCalAttendee::ETentative); + } + else if( CompareIgnoreCase(attElemCont, KStatusConfirmed) == 0 ) + { + calAtt->SetStatus(CCalAttendee::EConfirmed); + } + else if( CompareIgnoreCase(attElemCont, KStatusDeclined) == 0 ) + { + calAtt->SetStatus(CCalAttendee::EDeclined); + } + else if( CompareIgnoreCase(attElemCont, KStatusCompleted) == 0 ) + { + calAtt->SetStatus(CCalAttendee::ECompleted); + } + else if( CompareIgnoreCase(attElemCont, KStatusDelegated) == 0 ) + { + calAtt->SetStatus(CCalAttendee::EDelegated); + } + else if( CompareIgnoreCase(attElemCont, KStatusInProcess) == 0 ) + { + calAtt->SetStatus(CCalAttendee::EInProcess); + } + } + } + parameters->iAttendees.AppendL(calAtt); + CleanupStack::Pop(); // calAtt + } + } + } + } + } + +void CCreatorCalendarElement::ExecuteCommandL() + { + LOGSTRING("Creator: CCreatorCalendarElement::ExecuteCommandL"); + // Amount of calendar entries: + const CCreatorScriptAttribute* calEntryAmountAttr = this->FindAttributeByName(KAmount); + const CCreatorScriptAttribute* calEntryTypeAttr = this->FindAttributeByName(KType); + TInt entryAmount = 1; + if( calEntryAmountAttr ) + { + entryAmount = ConvertStrToIntL(calEntryAmountAttr->Value()); + } + if( calEntryTypeAttr == 0 ) + { + LOGSTRING("ERROR in CCreatorCalendarElement::ExecuteCommandL: Type attribute is missing."); + User::Leave(KErrGeneral); // type is required attribute + } + + // Find fields element: + CCreatorScriptElement* fieldsElement = FindSubElement(KFields); + + for( TInt cI = 0; cI < entryAmount; ++cI ) + { + CCalenderInterimParameters* param = new (ELeave) CCalenderInterimParameters; + CleanupStack::PushL(param); + if( CompareIgnoreCase(calEntryTypeAttr->Value(), KCalTypeAppointment) == 0 ) + { + if( fieldsElement && fieldsElement->SubElements().Count() > 0 ) + { + FillEntryParamsL(EAppointment, fieldsElement->SubElements(), param); + iEngine->AppendToCommandArrayL(ECmdCreateCalendarEntryAppointments, param); + } + else + { + iEngine->AppendToCommandArrayL(ECmdCreateCalendarEntryAppointments, 0, entryAmount); + CleanupStack::PopAndDestroy(param); + break; // We can step out from the for-loop, because the amount is given to engine. + } + } + else if( CompareIgnoreCase(calEntryTypeAttr->Value(), KCalTypeEvent ) == 0 ) + { + if( fieldsElement && fieldsElement->SubElements().Count() > 0 ) + { + FillEntryParamsL(EEvent, fieldsElement->SubElements(), param); + iEngine->AppendToCommandArrayL(ECmdCreateCalendarEntryEvents, param); + } + else + { + iEngine->AppendToCommandArrayL(ECmdCreateCalendarEntryEvents, 0, entryAmount); + CleanupStack::PopAndDestroy(param); + break; // We can step out from the for-loop, because the amount is given to engine. + } + } + else if( CompareIgnoreCase(calEntryTypeAttr->Value(), KCalTypeReminder ) == 0 ) + { + if( fieldsElement && fieldsElement->SubElements().Count() > 0 ) + { + FillEntryParamsL(EReminder, fieldsElement->SubElements(), param); + iEngine->AppendToCommandArrayL(ECmdCreateCalendarEntryReminders, param); + } + else + { + iEngine->AppendToCommandArrayL(ECmdCreateCalendarEntryReminders, 0, entryAmount); + CleanupStack::PopAndDestroy(param); + break; // We can step out from the for-loop, because the amount is given to engine. + } + } + else if( CompareIgnoreCase(calEntryTypeAttr->Value(), KCalTypeAnniversary ) == 0 ) + { + if( fieldsElement && fieldsElement->SubElements().Count() > 0 ) + { + FillEntryParamsL(EAnniversary, fieldsElement->SubElements(), param); + iEngine->AppendToCommandArrayL(ECmdCreateCalendarEntryAnniversaries, param); + } + else + { + iEngine->AppendToCommandArrayL(ECmdCreateCalendarEntryAnniversaries, 0, entryAmount); + CleanupStack::PopAndDestroy(param); + break; // We can step out from the for-loop, because the amount is given to engine. + } + } + else if( CompareIgnoreCase(calEntryTypeAttr->Value(), KCalTypeTodo ) == 0 ) + { + if( fieldsElement && fieldsElement->SubElements().Count() > 0 ) + { + FillEntryParamsL(ETodo, fieldsElement->SubElements(), param); + iEngine->AppendToCommandArrayL(ECmdCreateCalendarEntryToDos, param); + } + else + { + iEngine->AppendToCommandArrayL(ECmdCreateCalendarEntryToDos, 0, entryAmount); + CleanupStack::PopAndDestroy(param); + break; // We can step out from the for-loop, because the amount is given to engine. + } + } + CleanupStack::Pop(); // param + } + } + +CCreatorCalendarElement::CCreatorCalendarElement(CCreatorEngine* aEngine) +: +CCreatorScriptElement(aEngine) + { + iIsCommandElement = ETrue; + } diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/src/creator_cmdscriptrun.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/src/creator_cmdscriptrun.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,172 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include +#include +#include +#include "creator_cmdscriptrun.h" +#include "engine.h" +#include "enginewrapper.h" +#include "creator.pan" + + +// delay before script running and application exiting in seconds +// when script is run from command line +const TInt KCommandLineDelay = 3; + +//---------------------------------------------------------------------------- + +CCreatorCmdScriptRun* CCreatorCmdScriptRun::NewL(CCreatorEngine* aEngine) + { + CCreatorCmdScriptRun* self = CCreatorCmdScriptRun::NewLC(aEngine); + CleanupStack::Pop(self); + return self; + } + +CCreatorCmdScriptRun* CCreatorCmdScriptRun::NewLC(CCreatorEngine* aEngine) + { + CCreatorCmdScriptRun* self = new (ELeave) CCreatorCmdScriptRun; + CleanupStack::PushL(self); + self->ConstructL(aEngine); + return self; + } + + +// ConstructL +void CCreatorCmdScriptRun::ConstructL(CCreatorEngine* aEngine) + { + iEngine = aEngine; + + iMode = ETimerModeNone; + iTickCount = 0; + iTimer = CHeartbeat::NewL(0); + + // parse script name and random data file name from command line + iCommandLineScriptName = HBufC::NewL(User::CommandLineLength()); + iCommandLineRandomDataFileName = HBufC::NewL(User::CommandLineLength()); + HBufC* commandLine = HBufC::NewLC(User::CommandLineLength()); + TPtr16 ptr = commandLine->Des(); + User::CommandLine(ptr); + commandLine->Des().Trim(); + + TInt pos = commandLine->Des().Find(_L(" ")); + if (pos != KErrNotFound) + { + iCommandLineScriptName->Des().Copy(commandLine->Des().Left(pos)); + iCommandLineRandomDataFileName->Des().Copy(commandLine->Des().Mid(pos)); + iCommandLineRandomDataFileName->Des().Trim(); + } + else + { + iCommandLineScriptName->Des().Copy(commandLine->Des()); + iCommandLineRandomDataFileName->Des().Copy(KNullDesC); + } + + CleanupStack::PopAndDestroy(commandLine); + + if (iCommandLineScriptName->Des().Length() > 0) + { + iMode = ETimerModeStartScript; + iTimer->Start(ETwelveOClock, this); + } + } + + + CCreatorCmdScriptRun::CCreatorCmdScriptRun() + { + // add any construction that cannot leave here + } + + + CCreatorCmdScriptRun::~CCreatorCmdScriptRun() + { + delete iCommandLineRandomDataFileName; + delete iCommandLineScriptName; + + if (iTimer) + { + iTimer->Cancel(); + delete iTimer; + iTimer = NULL; + } + } + +void CCreatorCmdScriptRun::RunScriptDone() + { + if (iMode == ETimerModeStartScript) + { + iMode = ETimerModeExitAppUi; + iTimer->Start(ETwelveOClock, this); + } + } + +void CCreatorCmdScriptRun::Beat() + { + TRAP_IGNORE( TickL() ); + } + +void CCreatorCmdScriptRun::Synchronize() + { + TRAP_IGNORE( TickL() ); + } + +void CCreatorCmdScriptRun::TickL() + { + iTickCount++; + if (iTickCount > KCommandLineDelay) + { + iTimer->Cancel(); + iTickCount = 0; + if (iMode == ETimerModeStartScript) + { + iEngine->GetRandomDataFromFileL(*iCommandLineRandomDataFileName); + TInt status = iEngine->RunScriptL(*iCommandLineScriptName); + if (status != KErrNone) + { + TBuf<128> noteMsg; + if (status == KErrNotFound) + { + _LIT(KMessage1, "Error in opening script file."); + noteMsg.Copy(KMessage1); + } + else if (status == KErrCorrupt) + { + _LIT(KMessage2, "Error in parsing script file."); + noteMsg.Copy(KMessage2); + } + else if (status == KErrCompletion) + { + _LIT(KMessage3, "Script file does not contain any elements."); + noteMsg.Copy(KMessage3); + } + else + { + _LIT(KMessage4, "Unknown error in opening script file."); + noteMsg.Copy(KMessage4); + } + iEngine->GetEngineWrapper()->ShowNote(noteMsg); + RunScriptDone(); + } + } + else if (iMode == ETimerModeExitAppUi) + { + iMode = ETimerModeNone; + iEngine->GetEngineWrapper()->CloseCreatorApp(); + } + } + } diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/src/creator_connectionmethod.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/src/creator_connectionmethod.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,954 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include "engine.h" +#include "enginewrapper.h" +#include "creator_connectionmethod.h" +#include "creator_traces.h" + + + +using namespace CMManager; +//#define KUidLanBearerType 0x1020737A +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#include +#include +#include +#include +#include +#include +#include + +//#include //For WEP setting +//#include + +static const TInt KConnectionSettingssFieldLength = 128; + +_LIT(KCreatorConnectionSettingssPrefixName, "CR_"); + +//---------------------------------------------------------------------------- + +CConnectionSettingsParameters::CConnectionSettingsParameters() + { + LOGSTRING("Creator: CConnectionSettingsParameters::CConnectionSettingsParameters"); + + iConnectionName = HBufC::New(KConnectionSettingssFieldLength); + iStartPage = HBufC::New(KConnectionSettingssFieldLength); + iLoginName = HBufC::New(KConnectionSettingssFieldLength); + iLoginPass = HBufC::New(KConnectionSettingssFieldLength); + iIPAddr = HBufC::New(KConnectionSettingssFieldLength); + iIP4NameServer1 = HBufC::New(KConnectionSettingssFieldLength); + iIP4NameServer2 = HBufC::New(KConnectionSettingssFieldLength); + iDefaultTelNumber = HBufC::New(KConnectionSettingssFieldLength); + iProxyServerAddress = HBufC::New(KConnectionSettingssFieldLength); + iSubnetMask = HBufC::New(KConnectionSettingssFieldLength); + iGatewayAddress = HBufC::New(KConnectionSettingssFieldLength); + iWLANName = HBufC::New(KConnectionSettingssFieldLength); + iWlanIpAddr = HBufC::New(KConnectionSettingssFieldLength); + iIP6NameServer1 = HBufC::New(KConnectionSettingssFieldLength); + iIP6NameServer2 = HBufC::New(KConnectionSettingssFieldLength); + } + +CConnectionSettingsParameters::~CConnectionSettingsParameters() + { + LOGSTRING("Creator: CConnectionSettingssParameters::~CConnectionSettingssParameters"); + + delete iProxyServerAddress; + delete iDefaultTelNumber; + delete iIP4NameServer2; + delete iIP4NameServer1; + delete iIPAddr; + delete iLoginPass; + delete iLoginName; + delete iStartPage; + delete iConnectionName; + delete iSubnetMask; + delete iGatewayAddress; + delete iWLANName; + delete iWlanIpAddr; + delete iIP6NameServer1; + delete iIP6NameServer2; + } + +//---------------------------------------------------------------------------- + +CCreatorConnectionSettings* CCreatorConnectionSettings::NewL(CCreatorEngine* aEngine) + { + CCreatorConnectionSettings* self = CCreatorConnectionSettings::NewLC(aEngine); + CleanupStack::Pop(self); + return self; + } + +CCreatorConnectionSettings* CCreatorConnectionSettings::NewLC(CCreatorEngine* aEngine) + { + CCreatorConnectionSettings* self = new (ELeave) CCreatorConnectionSettings; + CleanupStack::PushL(self); + self->ConstructL(aEngine); + return self; + } + +CCreatorConnectionSettings::CCreatorConnectionSettings() + { + } + +void CCreatorConnectionSettings::ConstructL(CCreatorEngine* aEngine) + { + LOGSTRING("Creator: CCreatorConnectionSettings::ConstructL"); + + iEngine = aEngine; + + iCmManagerExt.CreateTablesAndOpenL(); + } + +CCreatorConnectionSettings::~CCreatorConnectionSettings() + { + LOGSTRING("Creator: CCreatorConnectionSettings::~CCreatorConnectionSettings"); + + if ( iEngine && iEntryIds.Count() ) + { + TRAP_IGNORE( iEngine->WriteEntryIdsToStoreL( iEntryIds, KUidDictionaryUidIAP ) ); + } + iEntryIds.Reset(); + iEntryIds.Close(); + + if (iParameters) + { + delete iParameters; + } + + iCmManagerExt.Close(); + } + + +//---------------------------------------------------------------------------- + +TBool CCreatorConnectionSettings::AskDataFromUserL(TInt aCommand) + { + LOGSTRING("Creator: CCreatorConnectionSettings::AskDataFromUserL"); + + CCreatorModuleBase::AskDataFromUserL( aCommand ); + + if( aCommand == ECmdDeleteIAPs ) + { + return iEngine->GetEngineWrapper()->YesNoQueryDialog(_L("Delete all Connection Methods?"), this, ECreatorModuleDelete ); + } + else if( aCommand == ECmdDeleteCreatorIAPs ) + { + return iEngine->GetEngineWrapper()->YesNoQueryDialog(_L("Delete all Connection Methods created with Creator?"), this, ECreatorModuleDelete ); + } + else + { + return iEngine->GetEngineWrapper()->EntriesQueryDialog(&iEntriesToBeCreated, _L("How many entries to create?"), EFalse, this, ECreatorModuleStart ); + } + } + + +//---------------------------------------------------------------------------- + +TInt CCreatorConnectionSettings::CreateConnectionSettingsEntryL(CCreatorModuleBaseParameters *aParameters) + { + LOGSTRING("Creator: CCreatorConnectionSettings::CreateConnectionSettingsEntryL"); + + CConnectionSettingsParameters* parameters = (CConnectionSettingsParameters*) aParameters; + + // clear any existing parameter definations + delete iParameters; + iParameters = NULL; + + // random data needed if no predefined data available + if (!parameters) + { + iParameters = new (ELeave) CConnectionSettingsParameters(); + parameters = iParameters; + SetRandomParametersL(*parameters); + } + + if( parameters->iBearerType == KRandomBearerType ) + { + SetRandomBearerTypeL(*parameters); + } + + TInt err = KErrNone; + + // create unique name for each network destination + RCmDestinationExt dest; + TInt destinationError = KErrNone; + TInt count = 0; + TBuf name; + name.Copy(parameters->iConnectionName->Des()); + do + { + TRAP(destinationError, dest = iCmManagerExt.CreateDestinationL(name)); + if (destinationError == KErrAlreadyExists) + { + name.Copy(parameters->iConnectionName->Des()); + count++; + name.AppendFormat(_L(" (%d)"), count); + } + else if (destinationError != KErrNone) + { + User::Leave(destinationError); + } + } + while (destinationError == KErrAlreadyExists); + parameters->iConnectionName->Des().Copy(name); + + CleanupClosePushL(dest); + dest.UpdateL(); + + RCmConnectionMethodExt conMethod = dest.CreateConnectionMethodL( parameters->iBearerType);//KUidPacketDataBearerType + CleanupClosePushL( conMethod ); + + if(parameters->iBearerType == KUidWlanBearerType) + { + //IP net mask of interface + conMethod.SetStringAttributeL( EWlanIpNetMask, parameters->iSubnetMask->Des() ); + + //IP address of EPOC. + conMethod.SetStringAttributeL( EWlanIpAddr, parameters->iWlanIpAddr->Des() ); + // + //following gateway ID:s is not workin, + //logically ID would be EWlanIpGateway because EWlanIpNetMask + //is going to net mask, which is just before gateway in ui + //---> + conMethod.SetStringAttributeL( EWlanIpGateway, parameters->iGatewayAddress->Des() ); + //conMethod.SetStringAttributeL( EApIspIPGateway, parameters->iGatewayAddress->Des() ); + conMethod.SetStringAttributeL( ECmWapIPGatewayAddress, parameters->iGatewayAddress->Des() ); + conMethod.SetStringAttributeL( ECmIPGateway, parameters->iGatewayAddress->Des() ); + //<--- + + //IP Address of primary and secondary name server (IP v4). + conMethod.SetStringAttributeL( EWlanIpNameServer1, parameters->iIP4NameServer1->Des() ); + conMethod.SetStringAttributeL( EWlanIpNameServer2, parameters->iIP4NameServer2->Des() ); + //The SSID of this WLAN connection. + conMethod.SetStringAttributeL( EWlanSSID, parameters->iWLANName->Des() ); + + //IP6 address of primary and secondary name servers + conMethod.SetStringAttributeL( EWlanIp6NameServer1, parameters->iIP6NameServer1->Des() ); + conMethod.SetStringAttributeL( EWlanIp6NameServer2, parameters->iIP6NameServer2->Des() ); + + // + //Setting secure mode settings + // + + //Network status (default: EWlanSecModeOpen) // EWlanAuthenticationMode use instead? + conMethod.SetIntAttributeL( EWlanSecurityMode, parameters->iWLanSecMode ); + //WLAN Network mode + conMethod.SetIntAttributeL( EWlanConnectionMode, parameters->iWlanNetMode ); + + + if(parameters->iWLanSecMode == EWlanSecModeOpen) + {}//Nothing to set when mode is open + else if(parameters->iWLanSecMode == EWlanSecModeWep) + { + //See WEPSecuritySettingsUI.h + + + ///CWEPSecuritySettings + // conMethod.SetIntAttributeL( EWlanSecurityMode, parameters->iWLanSecMode ); + } + else if(parameters->iWLanSecMode == EWlanSecMode802_1x) + { + } + else if(parameters->iWLanSecMode == EWlanSecModeWpa) + { + } + else if(parameters->iWLanSecMode == EWlanSecModeWpa2) + { + } + + //WLAN security setting + //conMethod.SetStringAttributeL( EWlanAuthenticationMode, parameters->iIP6NameServer2->Des() ); + //Utilise this method + //conMethod.SetStringAttributeL( EWlanSecurityMode, parameters->iWLanSecMode ); + } + //Not known special attributes for packet data + else if(parameters->iBearerType == KUidPacketDataBearerType) + { + + //Access point name. + conMethod.SetStringAttributeL( EPacketDataAPName, parameters->iConnectionName->Des() );//crash + + //Authentication user name + conMethod.SetStringAttributeL( EPacketDataIFAuthName, parameters->iLoginName->Des() ); + ///TProtocolType a; + //EPdpTypeIPv4 or EPdpTypeIPv6 + conMethod.SetIntAttributeL( EPacketDataPDPType, parameters->iProtocolType ); + + //IP6 address of primary and secondary name servers + conMethod.SetStringAttributeL( EPacketDataIPIP6NameServer1, parameters->iIP6NameServer1->Des() ); + conMethod.SetStringAttributeL( EPacketDataIPIP6NameServer2, parameters->iIP6NameServer2->Des() ); + //IP address of primary name server + conMethod.SetStringAttributeL( EPacketDataIPNameServer1, parameters->iIP4NameServer1->Des() ); + //IP address of secondary name server + conMethod.SetStringAttributeL( EPacketDataIPNameServer2, parameters->iIP4NameServer2->Des() ); + + //Also existing but UI not showing them: EPacketDataHeaderCompression, EPacketDataDisablePlainTextAuth + //EPacketDataIFAuthPass, EDialIFAuthPass, EPacketDataIFPromptForAuth, EPacketDataIPAddr + } + else if(parameters->iBearerType == KUidCSDBearerType || parameters->iBearerType == KUidHSCSDBearerType) + { + //Authentication user name + conMethod.SetStringAttributeL( EDialIFAuthName, parameters->iLoginName->Des() ); + //Dial-up number + conMethod.SetStringAttributeL( EDialDefaultTelNum, parameters->iDefaultTelNumber->Des() ); + //Call type + conMethod.SetIntAttributeL( EDialCallType , parameters->iBearerCallTypeIsdn ); + //Maximum speed + conMethod.SetIntAttributeL( EDialMaxConnSpeed, parameters->iBearerSpeed ); + //Prompt user for username and password? (Only for dial out) + conMethod.SetBoolAttributeL( EDialPromptForLogin, parameters->iPromptPassword ); + //IP6 address of primary and secondary name servers + conMethod.SetStringAttributeL( EDialIP6NameServer1, parameters->iIP6NameServer1->Des() ); + conMethod.SetStringAttributeL( EDialIP6NameServer2, parameters->iIP6NameServer2->Des() ); + //Disable plaintext authentication + conMethod.SetBoolAttributeL( EDialDisablePlainTextAuth, parameters->iDisableTextAuth ); + //IP address of primary name server + conMethod.SetStringAttributeL( EDialIPNameServer1, parameters->iIP4NameServer1->Des() ); + //IP address of secondary name server + conMethod.SetStringAttributeL( EDialIPNameServer2, parameters->iIP4NameServer2->Des() ); + + //Also existing EDialEnableIPHeaderComp; EDialIFPromptForAuth;EDialIPAddress parameters + + } + else if(parameters->iBearerType == KUidLanBearerType) + { + + conMethod.SetStringAttributeL( ELanIpNetMask, parameters->iSubnetMask->Des() ); + conMethod.SetStringAttributeL( ELanIpGateway, parameters->iGatewayAddress->Des()); + conMethod.SetStringAttributeL( ELanIpAddr, parameters->iIPAddr->Des() ); + conMethod.SetStringAttributeL( ELanIpNameServer1, parameters->iIP4NameServer1->Des() ); + conMethod.SetStringAttributeL( ELanIpNameServer2, parameters->iIP4NameServer2->Des() ); + conMethod.SetStringAttributeL( ELanIp6NameServer1,parameters->iIP6NameServer1->Des() ); + conMethod.SetStringAttributeL( ELanIp6NameServer2,parameters->iIP6NameServer2->Des() ); + + } + else //KUidEmbeddedDestination and KPluginVPNBearerTypeUid + { + //NOTE: NOT Tested, because no supporting Emulator for them + + //Authentication user name + conMethod.SetStringAttributeL( ECmIFAuthName, parameters->iLoginName->Des() ); + //IP6 address of primary and secondary name servers + conMethod.SetStringAttributeL( ECmIP6NameServer1, parameters->iIP6NameServer1->Des() ); + conMethod.SetStringAttributeL( ECmIP6NameServer2, parameters->iIP6NameServer2->Des() ); + //Disable plaintext authentication + conMethod.SetBoolAttributeL( ECmDisablePlainTextAuth, parameters->iDisableTextAuth ); + //Prompt user for authentication + conMethod.SetBoolAttributeL( ECmIFPromptForAuth, parameters->iPromptPassword ); + //Authentication password + conMethod.SetStringAttributeL( ECmIFAuthPass, parameters->iLoginPass->Des() ); + } + + // + //Adding common attributes, all not neccessary used with all bearer types, but should not cause any problems eather + // + + //CM Name (Connection Method, formelly known as Access Point) + conMethod.SetStringAttributeL( ECmName, parameters->iConnectionName->Des() ); + // Start page of CM + conMethod.SetStringAttributeL( ECmStartPage, parameters->iStartPage->Des() ); + // Enable Proxy + conMethod.SetBoolAttributeL( ECmProxyUsageEnabled, parameters->iUseProxy ); + // Server Name + conMethod.SetStringAttributeL( ECmProxyServerName, parameters->iProxyServerAddress->Des() ); + // Port Number + conMethod.SetIntAttributeL( ECmProxyPortNumber, parameters->iProxyPortNumber ); + //Proxy login name + conMethod.SetStringAttributeL( ECmWapIPProxyLoginName, parameters->iLoginName->Des() ); + //Proxy login password + conMethod.SetStringAttributeL( ECmWapIPProxyLoginPass, parameters->iLoginPass->Des() ); + //IP address of gateway + conMethod.SetStringAttributeL( ECmIPGateway, parameters->iGatewayAddress->Des() ); + //connection-oriented or connectionless API should be used + //ECmWapIPWSPOption option TWapWSPOption: ECmWapWspOptionConnectionless or ECmWapWspOptionConnectionOriented + conMethod.SetIntAttributeL( ECmWapIPWSPOption, parameters->iWapWspOption ); + //NOT WORKING????? Attempt secure WTLS connection to the gateway + conMethod.SetBoolAttributeL( ECmWapIPSecurity, parameters->iSecureAuthentication ); + + // + //Adding advanced settings (Network type, Phone IP addr, DNS addr, proxy srv name, proxy port nbr + // + + //IP address of interface + conMethod.SetStringAttributeL( ECmIPAddress, parameters->iIPAddr->Des() ); + //IP address of primary name server + conMethod.SetStringAttributeL( ECmIPNameServer1, parameters->iIP4NameServer1->Des() ); + //IP address of secondary name server + conMethod.SetStringAttributeL( ECmIPNameServer2, parameters->iIP4NameServer2->Des() ); + + + conMethod.UpdateL(); + + //If no defaults set, set the created CM as a default + SetDefaultCML( conMethod ); + + // id has been generated, store it for being able to delete + // only entries created with Creator + iEntryIds.AppendL( dest.Id() ); + + conMethod.Close(); + CleanupStack::Pop( );//conMethod + + dest.UpdateL(); + dest.Close(); + CleanupStack::Pop(); // dest + + return err; + } + +//---------------------------------------------------------------------------- +void CConnectionSettingsParameters::SetRandomCMNameL(CCreatorEngine& aEngine) + { + LOGSTRING("Creator: CConnectionSettingsParameters::SetRandomCMNameL"); + + TInt num = aEngine.RandomNumber(1, 3); + TBuf<10> apType; + + if (num==1) + { + apType = _L("mms"); + } + else if (num==2) + { + apType = _L("wap"); + } + else + { + apType = _L("internet"); + } + TBuf<160> company = aEngine.RandomString(CCreatorEngine::ECompany); + iConnectionName->Des() = KCreatorConnectionSettingssPrefixName; + iConnectionName->Des().Append( company ); + iConnectionName->Des().Append(_L(" ")); + iConnectionName->Des().Append(apType); + } + +void CConnectionSettingsParameters::SetRandomWLANNameL(CCreatorEngine& aEngine) + { + LOGSTRING("Creator: CConnectionSettingsParameters::SetRandomWLANNameL"); + + TBuf<160> company = aEngine.RandomString(CCreatorEngine::ECompany); + iWLANName->Des() = KCreatorConnectionSettingssPrefixName; + iWLANName->Des().Append( company ); + iWLANName->Des().Append( _L(" WLAN") ); + } + +void CConnectionSettingsParameters::SetRandomWLANNetModeL(CCreatorEngine& aEngine) + { + LOGSTRING("Creator: CConnectionSettingsParameters::SetRandomWLANNetModeL"); + + TInt wlanNetModeRand = aEngine.RandomNumber(1, 2); + if(wlanNetModeRand == 1) + { + iWlanNetMode = EAdhoc;//Ad-Hoc mode + } + else + { + iWlanNetMode = CMManager::EInfra;//Infrastructure mode + } + } + +void CConnectionSettingsParameters::SetRandomWLANSecurityModeL(CCreatorEngine& aEngine) + { + LOGSTRING("Creator: CConnectionSettingsParameters::SetRandomWLANSecurityModeL"); + + TInt wlanSecModeRand = aEngine.RandomNumber(1, 5); + if(wlanSecModeRand == 1) + { + iWLanSecMode = EWlanSecModeOpen;///< Open security mode + } + else if(wlanSecModeRand == 2) + { + iWLanSecMode = EWlanSecModeWep;///< WEP security mode + //See WEPSecuritySettingsUI.h + + ///CWEPSecuritySettings + + //WEP key in us + + //Authentication type + + //WEP Key settings (key len, key format, key data) + } + else if(wlanSecModeRand == 3) + { + iWLanSecMode = EWlanSecMode802_1x; ///< 802.1x security mode + } + else if(wlanSecModeRand == 4) + { + iWLanSecMode = EWlanSecModeWpa;///< WPA security mode + } + else if(wlanSecModeRand == 5) + { + iWLanSecMode = EWlanSecModeWpa2;///< WPA@ security mode + } + } + +void CConnectionSettingsParameters::SetRandomLoginNameL(CCreatorEngine& aEngine) + { + iLoginName->Des() = aEngine.RandomString(CCreatorEngine::EFirstName); + iLoginName->Des().LowerCase(); + } + +void CConnectionSettingsParameters::SetRandomLoginPassL(CCreatorEngine& aEngine) + { + iLoginPass->Des() = aEngine.RandomString(CCreatorEngine::ESurname); + iLoginPass->Des().LowerCase(); + } + +void CConnectionSettingsParameters::SetRandomSecureAuthenticationL(CCreatorEngine& /*aEngine*/) + { + iSecureAuthentication = EFalse; + } + +void CConnectionSettingsParameters::SetRandomPromptPasswordL(CCreatorEngine& /*aEngine*/) + { + iPromptPassword = ETrue; + } + +void CConnectionSettingsParameters::SetRandomUseProxyL(CCreatorEngine& /*aEngine*/) + { + iUseProxy = ETrue; + } + +void CConnectionSettingsParameters::SetRandomProxyAddressL(CCreatorEngine& /*aEngine*/) + { + iProxyServerAddress->Des() = _L("127.0.0.1"); + } + +void CConnectionSettingsParameters::SetRandomProxyPortL(CCreatorEngine& /*aEngine*/) + { + iProxyPortNumber = 80; + } + +void CConnectionSettingsParameters::SetRandomStartPageL(CCreatorEngine& aEngine) + { + LOGSTRING("Creator: CConnectionSettingsParameters::SetRandomStartPageL"); + + TInt num = aEngine.RandomNumber(1, 3); + TBuf<10> apType; + + if (num==1) + { + apType = _L("mms"); + } + else if (num==2) + { + apType = _L("wap"); + } + else + { + apType = _L("internet"); + } + TBuf<160> company = aEngine.RandomString(CCreatorEngine::ECompany); + iStartPage->Des() = _L("http://"); + iStartPage->Des().Append(apType); + iStartPage->Des().Append(_L(".")); + iStartPage->Des().Append(company); + iStartPage->Des().Append(_L(".com")); + iStartPage->Des().LowerCase(); + } + +void CConnectionSettingsParameters::SetRandomIPAddressL(CCreatorEngine& /*aEngine*/) + { + iIPAddr->Des() = _L("10.10.10.10"); + } + +void CConnectionSettingsParameters::SetRandomIP4NameServer1L(CCreatorEngine& /*aEngine*/) + { + iIP4NameServer1->Des() = _L("10.1.1.1"); + } +void CConnectionSettingsParameters::SetRandomIP4NameServer2L(CCreatorEngine& /*aEngine*/) + { + iIP4NameServer2->Des() = _L("10.2.2.2"); + } + +void CConnectionSettingsParameters::SetRandomProtocolTypeL(CCreatorEngine& aEngine) + { + LOGSTRING("Creator: CConnectionSettingsParameters::SetRandomProtocolTypeL"); + + TInt protocolTypeRand = aEngine.RandomNumber(1, 2); + if(protocolTypeRand == 1) + { + iProtocolType = RPacketContext::EPdpTypeIPv4; + } + else + { + iProtocolType = RPacketContext::EPdpTypeIPv6; + } + } + +void CConnectionSettingsParameters::SetRandomTelephoneNumberL(CCreatorEngine& aEngine) + { + iDefaultTelNumber->Des() = aEngine.RandomString(CCreatorEngine::EPhoneNumber); + } + +void CConnectionSettingsParameters::SetRandomBearerTypeIsdnL(CCreatorEngine& /*aEngine*/) + { + iBearerCallTypeIsdn = ECmCallTypeISDNv110; + } + +void CConnectionSettingsParameters::SetRandomBearerSpeedL(CCreatorEngine& /*aEngine*/) + { + iBearerSpeed = ECmSpeed14400; + } + +void CConnectionSettingsParameters::SetRandomWapWspOptionL(CCreatorEngine& /*aEngine*/) + { + iWapWspOption = ECmWapWspOptionConnectionless; + } + +void CConnectionSettingsParameters::SetRandomSubnetMaskL(CCreatorEngine& /*aEngine*/) + { + iSubnetMask->Des() = _L("255.255.255.0"); + } + +void CConnectionSettingsParameters::SetRandomGatewayAddressL(CCreatorEngine& /*aEngine*/) + { + iGatewayAddress->Des() = _L("10.0.0.1"); + } + +void CConnectionSettingsParameters::SetRandomWlanIpAddrL(CCreatorEngine& /*aEngine*/) + { + iWlanIpAddr->Des() = _L("10.0.0.99"); + } + +void CConnectionSettingsParameters::SetRandomIPv6NameServer1L(CCreatorEngine& /*aEngine*/) + { + iIP6NameServer1->Des() = _L("2007:abcd:1000:2000:3000:4000:5000:6001"); + } + +void CConnectionSettingsParameters::SetRandomIPv6NameServer2L(CCreatorEngine& /*aEngine*/) + { + iIP6NameServer2->Des() = _L("2007:abcd:1000:2000:3000:4000:5000:6002"); + } + +void CConnectionSettingsParameters::SetRandomDisableTextAuthL(CCreatorEngine& /*aEngine*/) + { + iDisableTextAuth = EFalse; + } + +void CCreatorConnectionSettings::SetRandomBearerTypeL(CConnectionSettingsParameters& parameters) + { + LOGSTRING("Creator: CCreatorConnectionSettings::SetRandomBearerTypeL"); + + RArray supportedBearers = RArray( 10 ); + iCmManagerExt.SupportedBearersL(supportedBearers); + CleanupClosePushL( supportedBearers ); + + //In random mode, skipping KUidLanBearerType + //Because of Emulator migh show it as supported, when it's really not + //and that causes weird situation in UI when there is an item, but it can't be opened + TInt lanID = supportedBearers.Find(KUidLanBearerType); + if( lanID != KErrNotFound ) + { + supportedBearers.Remove(lanID); + } + + // in emulator remove WLAN + #ifdef __WINSCW__ + TInt wlanID = supportedBearers.Find(KUidWlanBearerType); + if( wlanID != KErrNotFound ) + { + supportedBearers.Remove(wlanID); + } + #endif + + /* + for(TInt i = 0; iRandomNumber(0, supportedCount-1); + + TUint bearerType = supportedBearers[bearerTypeID]; + + //Bearer types KUidEmbeddedDestination and KPluginVPNBearerTypeUid is not supported + if(bearerType == KUidWlanBearerType)//Wireless LAN + { + parameters.iBearerType = KUidWlanBearerType; + } + else if(bearerType == KUidPacketDataBearerType)//Packet data (GPRS) + { + parameters.iBearerType = KUidPacketDataBearerType; + } + else if(bearerType == KUidCSDBearerType)//Data Call + { + parameters.iBearerType = KUidCSDBearerType; + } + else if(bearerType == KUidHSCSDBearerType) //High speed GSM + { + parameters.iBearerType = KUidHSCSDBearerType; + } + else if(bearerType == KUidEmbeddedDestination) + { + parameters.iBearerType = KUidEmbeddedDestination; + } + else// if(bearerType == KPluginVPNBearerTypeUid) + { + parameters.iBearerType = KPluginVPNBearerTypeUid; + } + /* In random mode skipping LAN type + else// if(bearerType == KUidLanBearerType) + { + iBearerType = KUidLanBearerType; + }*/ + + CleanupStack::PopAndDestroy(); // supportedBearers + } + +void CCreatorConnectionSettings::SetRandomParametersL(CConnectionSettingsParameters& parameters) + { + LOGSTRING("Creator: CCreatorConnectionSettings::SetRandomParametersL"); + + // Connection method name: + parameters.SetRandomCMNameL(*iEngine); + + SetRandomBearerTypeL(parameters); + + if(parameters.iBearerType == KUidWlanBearerType)//Wireless LAN + { + // WLAN name: + parameters.SetRandomWLANNameL(*iEngine); + + //WLAN network mode + parameters.SetRandomWLANNetModeL(*iEngine); + + //WLAN security mode: + parameters.SetRandomWLANSecurityModeL(*iEngine); + } + + // Login name: + parameters.SetRandomLoginNameL(*iEngine); + + // Login password: + parameters.SetRandomLoginPassL(*iEngine); + + // Secure authentication: + parameters.SetRandomSecureAuthenticationL(*iEngine); + + // Prompt password: + parameters.SetRandomPromptPasswordL(*iEngine); + + // Use proxy: + parameters.SetRandomUseProxyL(*iEngine); + + // Proxy address + parameters.SetRandomProxyAddressL(*iEngine); + + // Proxy port number: + parameters.SetRandomProxyPortL(*iEngine); + + // Start page: + parameters.SetRandomStartPageL(*iEngine); + + // IP address: + parameters.SetRandomIPAddressL(*iEngine); + + // IPv4 name servers: + parameters.SetRandomIP4NameServer1L(*iEngine); + parameters.SetRandomIP4NameServer2L(*iEngine); + + // Protocol type: + parameters.SetRandomProtocolTypeL(*iEngine); + + // Default telephone number: + parameters.SetRandomTelephoneNumberL(*iEngine); + + // Bearer isdn + parameters.SetRandomBearerTypeIsdnL(*iEngine); + + // Bearer speed: + parameters.SetRandomBearerSpeedL(*iEngine); + + // WAP wsp option: + parameters.SetRandomWapWspOptionL(*iEngine); + + // Subnet mask: + parameters.SetRandomSubnetMaskL(*iEngine); + + // Gateway address: + parameters.SetRandomGatewayAddressL(*iEngine); + + // WLAN ip address: + parameters.SetRandomWlanIpAddrL(*iEngine); + + // IPv6 name servers: + parameters.SetRandomIPv6NameServer1L(*iEngine); + parameters.SetRandomIPv6NameServer2L(*iEngine); + + // Disable text authorization: + parameters.SetRandomDisableTextAuthL(*iEngine); + } + +//---------------------------------------------------------------------------- + +void CCreatorConnectionSettings::SetDefaultCML(RCmConnectionMethodExt conMethod) + { + LOGSTRING("Creator: CCreatorConnectionSettings::SetDefaultCM"); + + TCmDefConnValue defConnValue; + + //Returns the default connection method/SNAP. + TRAPD( err, iCmManagerExt.ReadDefConnL( defConnValue ) ); + if( err == KErrNotSupported ) + { + return; //If Default Connection NOT supported, just returning + } + else if ( err != KErrNone ) + { + User::Leave( err ); //If something else happend + } + else if ( defConnValue.iId == 0 ) // default not set + { + TCmDefConnValue newDefaultCM; + HBufC* cmName = conMethod.GetStringAttributeL( ECmName ); + CleanupStack::PushL( cmName ); + newDefaultCM.iId = AccessPointNameToIdL( cmName->Des() ); + newDefaultCM.iType = ECmDefConnDestination; + //Stores the default connection method/SNAP. + iCmManagerExt.WriteDefConnL( newDefaultCM ); + CleanupStack::PopAndDestroy( cmName ); + } + } + +//---------------------------------------------------------------------------- + +TUint32 CCreatorConnectionSettings::AccessPointNameToIdL(const TDesC& aAPName, + TBool aAnyIfNotFound ) + { + LOGSTRING("Creator: CCreatorConnectionSettings::AccessPointNameToIdL"); + + //RCmDestination destination + + RArray destIdArray = RArray( 10 ); + + iCmManagerExt.AllDestinationsL( destIdArray ); + + CleanupClosePushL( destIdArray ); + TUint32 id = 0 ; + TBool found = EFalse; + + for( TInt i = 0; i < destIdArray.Count(); i++ ) + { + RCmDestinationExt dest = iCmManagerExt.DestinationL( destIdArray[i] ); + CleanupClosePushL( dest ); + + HBufC* destName = dest.NameLC(); + + if (destName->CompareF(aAPName) == 0){ + id = dest.Id(); + found = ETrue; + } + if ( !found && id == 0 && aAnyIfNotFound ) + { + id = dest.Id(); + } + CleanupStack::PopAndDestroy( 2 ); // destName , dest + if(found) + { + break; + } + } + + CleanupStack::PopAndDestroy(); // destIdArray + return id; + } + +//---------------------------------------------------------------------------- + +void CCreatorConnectionSettings::HandleSessionEventL(TMsvSessionEvent /*aEvent*/, TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/) // from MMsvSessionObserver + { + LOGSTRING("Creator: CCreatorConnectionSettings::HandleSessionEventL"); + } + +//---------------------------------------------------------------------------- +void CCreatorConnectionSettings::DeleteAllL() + { + LOGSTRING("Creator: CCreatorConnectionSettings::DeleteAllL"); + DeleteAllDestinationsL( EFalse ); + } + +//---------------------------------------------------------------------------- +void CCreatorConnectionSettings::DeleteAllCreatedByCreatorL() + { + LOGSTRING("Creator: CCreatorConnectionSettings::DeleteAllCreatedByCreatorL"); + iEntryIds.Reset(); + + // fetch ids of entries created by Creator + iEngine->ReadEntryIdsFromStoreL( iEntryIds, KUidDictionaryUidIAP ); + + // delete entries + DeleteAllDestinationsL( ETrue ); + } + +//---------------------------------------------------------------------------- + +void CCreatorConnectionSettings::DeleteAllDestinationsL( TBool aOnlyCreatedWithCreator ) + { + LOGSTRING("Creator: CCreatorConnectionSettings::DeleteAllDestinationsL"); + RArray destIdArray(5); + CleanupClosePushL( destIdArray ); + iCmManagerExt.AllDestinationsL( destIdArray ); + + for( TInt i = 0; i < destIdArray.Count(); i++ ) + { + TRAP_IGNORE + ( + RCmDestinationExt dest = iCmManagerExt.DestinationL( destIdArray[i] ); + CleanupClosePushL( dest ); + + if ( !aOnlyCreatedWithCreator || iEntryIds.Find( destIdArray[i]) != KErrNotFound ) + { + dest.DeleteLD(); + } + CleanupStack::PopAndDestroy(); // dest + ); + } + + CleanupStack::PopAndDestroy(); // destIdArray + + // reset must be done here, because iEntryIds is stored in destructor + iEntryIds.Reset(); + + // all entries deleted, remove the IMPS related registry + iEngine->RemoveStoreL( KUidDictionaryUidIAP ); + } +//---------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/src/creator_connectionmethodelement.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/src/creator_connectionmethodelement.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,333 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include "engine.h" +#include "enginewrapper.h" +#include "creator_connectionmethodelement.h" +#include "creator_traces.h" +//#include "creator_accesspoint.h" + + +using namespace creatorconnectionmethod; + +// connection name needs extra space for possible renaming +const TInt KExtraSpace = 10; + +/* + * + */ +CCreatorConnectionMethodElement* CCreatorConnectionMethodElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext ) + { + CCreatorConnectionMethodElement* self = new (ELeave) CCreatorConnectionMethodElement(aEngine); + CleanupStack::PushL(self); + self->ConstructL(aName, aContext); + CleanupStack::Pop(self); + return self; + } +/* + * + */ +CCreatorConnectionMethodElement::CCreatorConnectionMethodElement(CCreatorEngine* aEngine) +: +CCreatorScriptElement(aEngine) + { + iIsCommandElement = ETrue; + } + +void CCreatorConnectionMethodElement::ExecuteCommandL() + { + const CCreatorScriptAttribute* amountAttr = FindAttributeByName(KAmount); + TInt cmAmount = 1; + if( amountAttr ) + { + cmAmount = ConvertStrToIntL(amountAttr->Value()); + } + // Get 'fields' element + CCreatorScriptElement* fieldsElement = FindSubElement(KFields); + if( fieldsElement ) + { + // Get sub-elements + const RPointerArray& fields = fieldsElement->SubElements(); + // Create connection method entries, the amount of entries is defined by cmAmount: + for( TInt cI = 0; cI < cmAmount; ++cI ) + { + CAccessPointsParameters* param = new (ELeave) CAccessPointsParameters; + CleanupStack::PushL(param); + + for( TInt i = 0; i < fields.Count(); ++i ) + { + CCreatorScriptElement* field = fields[i]; + TPtrC elemName = field->Name(); + TPtrC elemContent = field->Content(); + const CCreatorScriptAttribute* randomAttr = fields[i]->FindAttributeByName(KRandomLength); + TBool useRandom = EFalse; + if( randomAttr || elemContent.Length() == 0 ) + { + useRandom = ETrue; + } + + if( elemName == Kconnectionname ) + { + if( useRandom ) + { + param->SetRandomCMNameL(*iEngine); + } + else + { + SetContentToTextParamL(param->iConnectionName, elemContent); + // reserve extra space for possible renaming + TInt newLen = param->iConnectionName->Length() + KExtraSpace; + param->iConnectionName = param->iConnectionName->ReAllocL(newLen); + + SetContentToTextParamL(param->iGprsAcessPointName, elemContent); + } + } + else if( elemName == Kstartpage ) + { + if( useRandom ) + { + param->SetRandomStartPageL(*iEngine); + } + else + { + SetContentToTextParamL(param->iWapStartPage, elemContent); + } + } + else if( elemName == Kwapwspoption ) + { + if( useRandom ) + { + param->SetRandomWapWspOptionL(*iEngine); + } + else + { + if( CompareIgnoreCase(elemContent, Kconnectionless) == 0 ) + { + param->iWapWspOption = EWapWspOptionConnectionless; + } + else if( CompareIgnoreCase(elemContent, Kconnectionoriented) == 0 ) + { + param->iWapWspOption = EWapWspOptionConnectionOriented; + } + } + } + else if( elemName == Kloginname ) + { + if( useRandom ) + { + param->SetRandomLoginNameL(*iEngine); + } + else + { + SetContentToTextParamL(param->iIspLoginName, elemContent); + } + } + else if( elemName == Ksecureauthentication ) + { + if( useRandom ) + { + param->SetRandomSecureAuthenticationL(*iEngine); + } + else + { + param->iSecureAuthentication = ConvertStrToBooleanL(elemContent); + } + } + else if( elemName == Kloginpass ) + { + if( useRandom ) + { + param->SetRandomLoginPassL(*iEngine); + } + else + { + SetContentToTextParamL(param->iIspLoginPass, elemContent); + } + } + else if( elemName == Kpromptpassword ) + { + if( useRandom ) + { + param->SetRandomPromptPasswordL(*iEngine); + } + else + { + param->iPromptPassword = ConvertStrToBooleanL(elemContent); + } + } + else if( elemName == Kgatewayaddress ) + { + if( useRandom ) + { + param->SetRandomGatewayAddressL(*iEngine); + } + else + { + SetContentToTextParamL(param->iWapGatewayAddress, elemContent); + } + } + else if( elemName == Kdeviceipaddr ) + { + if( useRandom ) + { + param->SetRandomIPAddressL(*iEngine); + } + else + { + SetContentToTextParamL(param->iIspIPAddr, elemContent); + } + } + else if( elemName == Kip4nameserver1 ) + { + if( useRandom ) + { + param->SetRandomIP4NameServer1L(*iEngine); + } + else + { + SetContentToTextParamL(param->iIspIPNameServer1, elemContent); + } + } + else if( elemName == Kip4nameserver2 ) + { + if( useRandom ) + { + param->SetRandomIP4NameServer2L(*iEngine); + } + else + { + SetContentToTextParamL(param->iIspIPNameServer2, elemContent); + } + } + else if( elemName == Kdatacalltelnumber ) + { + if( useRandom ) + { + param->SetRandomTelephoneNumberL(*iEngine); + } + else + { + SetContentToTextParamL(param->iIspDefaultTelNumber, elemContent); + } + } + else if( elemName == Kdatacalltypeisdn ) + { + if( useRandom ) + { + param->SetRandomBearerTypeIsdnL(*iEngine); + } + else + { + if( CompareIgnoreCase(elemContent, Kanalogue) == 0 ) + param->iIspBearerCallTypeIsdn = ECallTypeAnalogue; + else if( CompareIgnoreCase( elemContent, Kisdnv110) == 0 ) + param->iIspBearerCallTypeIsdn = ECallTypeISDNv110; + else if( CompareIgnoreCase( elemContent, Kisdnv120) == 0 ) + param->iIspBearerCallTypeIsdn = ECallTypeISDNv120; + } + } + else if( elemName == Kbearertype ) + { + if( useRandom ) + { + param->iBearerType = EApBearerTypeGPRS; + } + else + { + if( CompareIgnoreCase(elemContent, Kwlan) == 0 ) + { + param->iBearerType = EApBearerTypeWLAN; + } + else if( CompareIgnoreCase(elemContent, Kgprs) == 0 ) + { + param->iBearerType = EApBearerTypeGPRS; + } + else if( CompareIgnoreCase(elemContent, Kdatacall) == 0 ) + { + param->iBearerType = EApBearerTypeCSD; + } + else if( CompareIgnoreCase(elemContent, Khsgsm) == 0 ) + { + param->iBearerType = EApBearerTypeHSCSD; + } + else if( CompareIgnoreCase(elemContent, Klan) == 0 ) + { + param->iBearerType = EApBearerTypeLAN; + } + } + } + else if( elemName == Kdatacalllinespeed ) + { + if( useRandom ) + { + param->SetRandomBearerSpeedL(*iEngine); + } + else + { + if( CompareIgnoreCase(elemContent, Kautomatic) == 0 ) + { + param->iIspBearerSpeed = KSpeedAutobaud; + } + else + { + TUint lineSpeed = ConvertStrToUintL(elemContent); + if( lineSpeed == 9600 ) + param->iIspBearerSpeed = KSpeed9600; + else if( lineSpeed == 14400 ) + param->iIspBearerSpeed = KSpeed14400; + else if( lineSpeed == 19200 ) + param->iIspBearerSpeed = KSpeed19200; + else if( lineSpeed == 28800 ) + param->iIspBearerSpeed = KSpeed28800; + else if( lineSpeed == 38400 ) + param->iIspBearerSpeed = KSpeed38400; + else if( lineSpeed == 43200 ) + param->iIspBearerSpeed = KSpeed43200; + else if( lineSpeed == 56000 ) + param->iIspBearerSpeed = KSpeed56000; + } + } + } + else if( elemName == Kproxyserveraddress ) + { + if( useRandom ) + { + param->SetRandomProxyAddressL(*iEngine); + } + else + { + SetContentToTextParamL(param->iProxyServerAddress, elemContent); + } + } + else if( elemName == Kproxyportnumber ) + { + if( useRandom ) + { + param->SetRandomProxyPortL(*iEngine); + } + else + { + param->iProxyPortNumber = ConvertStrToUintL(elemContent); + } + } + } + iEngine->AppendToCommandArrayL(ECmdCreateMiscEntryAccessPoints, param); + CleanupStack::Pop(); // param + } + } + } diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/src/creator_contactelement.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/src/creator_contactelement.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,401 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +#include "creator_contactelement.h" +#include "creator_traces.h" +#include "creator_phonebook.h" +#include "creator_factory.h" +#include "creator_contactsetcache.h" +#include +#include + +using namespace Xml; +using namespace creatorcontact; + +/** + * Contact field element mappings: + */ +enum TContactFieldDataType + { + EDataTypeText, + EDataTypeBinary, + EDataTypeDateTime + }; + +class FieldMapping +{ +public: + TPtrC iElementName; + TInt iFieldCode; + TContactFieldDataType iDataType; +}; +FieldMapping fieldMappingTbl[] = { + {TPtrC(KFirstname), CCreatorPhonebookWrapper::EFirstName, EDataTypeText}, + {TPtrC(KLastname), CCreatorPhonebookWrapper::ELastName, EDataTypeText}, + {TPtrC(KFirstnameReading), CCreatorPhonebookWrapper::EFirstNameReading, EDataTypeText}, + {TPtrC(KLastnameReading), CCreatorPhonebookWrapper::ELastNameReading, EDataTypeText}, + {TPtrC(KPrefix), CCreatorPhonebookWrapper::EPrefix, EDataTypeText}, + {TPtrC(KSuffix), CCreatorPhonebookWrapper::ESuffix, EDataTypeText}, + {TPtrC(KSecondname), CCreatorPhonebookWrapper::ESecondName, EDataTypeText}, + {TPtrC(KLandphoneHome), CCreatorPhonebookWrapper::ELandPhoneHome, EDataTypeText}, + + {TPtrC(KMobilephoneHome), CCreatorPhonebookWrapper::EMobilePhoneHome, EDataTypeText}, + {TPtrC(KVideonumberHome), CCreatorPhonebookWrapper::EVideoNumberHome, EDataTypeText}, + {TPtrC(KFaxnumberHome), CCreatorPhonebookWrapper::EFaxNumberHome, EDataTypeText}, + {TPtrC(KVoipHome), CCreatorPhonebookWrapper::EVoipHome, EDataTypeText}, + {TPtrC(KEmailHome), CCreatorPhonebookWrapper::EEmailHome, EDataTypeText}, + {TPtrC(KUrlHome), CCreatorPhonebookWrapper::EUrlHome, EDataTypeText}, + {TPtrC(KAddrlabelHome), CCreatorPhonebookWrapper::EAddrLabelHome, EDataTypeText}, + {TPtrC(KAddrpoHome), CCreatorPhonebookWrapper::EAddrPoHome, EDataTypeText}, + + {TPtrC(KAddrextHome), CCreatorPhonebookWrapper::EAddrExtHome, EDataTypeText}, + {TPtrC(KAddrstreetHome), CCreatorPhonebookWrapper::EAddrStreetHome, EDataTypeText}, + {TPtrC(KAddrlocalHome), CCreatorPhonebookWrapper::EAddrLocalHome, EDataTypeText}, + {TPtrC(KAddrregionHome), CCreatorPhonebookWrapper::EAddrRegionHome, EDataTypeText}, + {TPtrC(KAddrpostcodeHome), CCreatorPhonebookWrapper::EAddrPostCodeHome, EDataTypeText}, + {TPtrC(KAddrcountryHome), CCreatorPhonebookWrapper::EAddrCountryHome, EDataTypeText}, + {TPtrC(KJobtitle), CCreatorPhonebookWrapper::EJobTitle, EDataTypeText}, + {TPtrC(KCompanyname), CCreatorPhonebookWrapper::ECompanyName, EDataTypeText}, + + {TPtrC(KLandphoneWork), CCreatorPhonebookWrapper::ELandPhoneWork, EDataTypeText}, + {TPtrC(KMobilephoneWork), CCreatorPhonebookWrapper::EMobilePhoneWork, EDataTypeText}, + {TPtrC(KVideonumberWork), CCreatorPhonebookWrapper::EVideoNumberWork, EDataTypeText}, + {TPtrC(KFaxnumberWork), CCreatorPhonebookWrapper::EFaxNumberWork, EDataTypeText}, + {TPtrC(KVoipWork), CCreatorPhonebookWrapper::EVoipWork, EDataTypeText}, + {TPtrC(KEmailWork), CCreatorPhonebookWrapper::EEmailWork, EDataTypeText}, + {TPtrC(KUrlWork), CCreatorPhonebookWrapper::EUrlWork, EDataTypeText}, + {TPtrC(KAddrlabelWork), CCreatorPhonebookWrapper::EAddrLabelWork, EDataTypeText}, + + {TPtrC(KAddrpoWork), CCreatorPhonebookWrapper::EAddrPoWork, EDataTypeText}, + {TPtrC(KAddrextWork), CCreatorPhonebookWrapper::EAddrExtWork, EDataTypeText}, + {TPtrC(KAddrstreetWork), CCreatorPhonebookWrapper::EAddrStreetWork, EDataTypeText}, + {TPtrC(KAddrlocalWork), CCreatorPhonebookWrapper::EAddrLocalWork, EDataTypeText}, + {TPtrC(KAddrregionWork), CCreatorPhonebookWrapper::EAddrRegionWork, EDataTypeText}, + {TPtrC(KAddrpostcodeWork), CCreatorPhonebookWrapper::EAddrPostCodeWork, EDataTypeText}, + {TPtrC(KAddrcountryWork), CCreatorPhonebookWrapper::EAddrCountryWork, EDataTypeText}, + {TPtrC(KLandphoneGen), CCreatorPhonebookWrapper::ELandPhoneGen, EDataTypeText}, + + {TPtrC(KMobilephoneGen), CCreatorPhonebookWrapper::EMobilePhoneGen, EDataTypeText}, + {TPtrC(KVideonumberGen), CCreatorPhonebookWrapper::EVideoNumberGen, EDataTypeText}, + {TPtrC(KFaxnumberGen), CCreatorPhonebookWrapper::EFaxNumberGen, EDataTypeText}, + {TPtrC(KVoipGen), CCreatorPhonebookWrapper::EVoipGen, EDataTypeText}, + {TPtrC(KPoc), CCreatorPhonebookWrapper::EPoc, EDataTypeText}, + {TPtrC(KSwis), CCreatorPhonebookWrapper::ESwis, EDataTypeText}, + {TPtrC(KSip), CCreatorPhonebookWrapper::ESip, EDataTypeText}, + {TPtrC(KEmailGen), CCreatorPhonebookWrapper::EEmailGen, EDataTypeText}, + + {TPtrC(KUrlGen), CCreatorPhonebookWrapper::EUrlGen, EDataTypeText}, + {TPtrC(KAddrlabelGen), CCreatorPhonebookWrapper::EAddrLabelGen, EDataTypeText}, + {TPtrC(KAddrpoGen), CCreatorPhonebookWrapper::EAddrPoGen, EDataTypeText}, + {TPtrC(KAddrextGen), CCreatorPhonebookWrapper::EAddrExtGen, EDataTypeText}, + {TPtrC(KAddrstreetGen), CCreatorPhonebookWrapper::EAddrStreetGen, EDataTypeText}, + {TPtrC(KAddrlocalGen), CCreatorPhonebookWrapper::EAddrLocalGen, EDataTypeText}, + {TPtrC(KAddrregionGen), CCreatorPhonebookWrapper::EAddrRegionGen, EDataTypeText}, + {TPtrC(KAddrpostcodeGen), CCreatorPhonebookWrapper::EAddrPostCodeGen, EDataTypeText}, + + {TPtrC(KAddrcountryGen), CCreatorPhonebookWrapper::EAddrCountryGen, EDataTypeText}, + {TPtrC(KPagerNumber), CCreatorPhonebookWrapper::EPagerNumber, EDataTypeText}, + {TPtrC(KDtmfString), CCreatorPhonebookWrapper::EDtmfString, EDataTypeText}, + {TPtrC(KWvAddress), CCreatorPhonebookWrapper::EWVAddress, EDataTypeText}, + {TPtrC(KDate), CCreatorPhonebookWrapper::EDate, EDataTypeDateTime}, + {TPtrC(KNote), CCreatorPhonebookWrapper::ENote, EDataTypeText}, + {TPtrC(KThumbnailPath), CCreatorPhonebookWrapper::EThumbnailPic, EDataTypeText}, + {TPtrC(KThumbnailId), CCreatorPhonebookWrapper::EThumbnailPic, EDataTypeText}, + {TPtrC(KRingTone), CCreatorPhonebookWrapper::ERingTone, EDataTypeText}, + {TPtrC(KRingToneId), CCreatorPhonebookWrapper::ERingTone, EDataTypeText}, + + {TPtrC(KCallerobjImg), CCreatorPhonebookWrapper::ECallerObjImg, EDataTypeText}, + {TPtrC(KCallerobjText), CCreatorPhonebookWrapper::ECallerObjText, EDataTypeText}, + {TPtrC(KMiddlename), CCreatorPhonebookWrapper::EMiddleName, EDataTypeText}, + {TPtrC(KDepartment), CCreatorPhonebookWrapper::EDepartment, EDataTypeText}, + {TPtrC(KAsstname), CCreatorPhonebookWrapper::EAsstName, EDataTypeText}, + {TPtrC(KSpouse), CCreatorPhonebookWrapper::ESpouse, EDataTypeText}, + {TPtrC(KChildren), CCreatorPhonebookWrapper::EChildren, EDataTypeText}, + {TPtrC(KAsstphone), CCreatorPhonebookWrapper::EAsstPhone, EDataTypeText}, + + {TPtrC(KCarphone), CCreatorPhonebookWrapper::ECarPhone, EDataTypeText}, + {TPtrC(KAnniversary), CCreatorPhonebookWrapper::EAnniversary, EDataTypeDateTime}, + {TPtrC(KSyncclass), CCreatorPhonebookWrapper::ESyncClass, EDataTypeText}, + {TPtrC(KLocPrivacy), CCreatorPhonebookWrapper::ELocPrivacy, EDataTypeText}, + {TPtrC(KGenlabel), CCreatorPhonebookWrapper::EGenLabel, EDataTypeText} +}; + +//********************************************************************************* + +CCreatorContactElementBase* CCreatorContactElementBase::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext) + { + LOGSTRING("Creator: CCreatorContactElementBase::NewL"); + CCreatorContactElementBase* self = new (ELeave) CCreatorContactElementBase(aEngine); + CleanupStack::PushL(self); + self->ConstructL(aName, aContext); + CleanupStack::Pop(); + return self; + } +CCreatorContactElementBase::CCreatorContactElementBase(CCreatorEngine* aEngine) : CCreatorScriptElement(aEngine) + { } + +CCreatorContactElement* CCreatorContactElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext) + { + LOGSTRING("Creator: CCreatorContactElement::NewL"); + CCreatorContactElement* self = new (ELeave) CCreatorContactElement(aEngine); + CleanupStack::PushL(self); + self->ConstructL(aName, aContext); + CleanupStack::Pop(); + return self; + } +CCreatorContactElement::CCreatorContactElement(CCreatorEngine* aEngine) +: +CCreatorContactElementBase(aEngine) + { + iIsCommandElement = ETrue; + } + + +void CCreatorContactElement::ExecuteCommandL() + { + LOGSTRING("Creator: CCreatorContactElement::ExecuteCommandL"); + // Find out how many contacts should we create: + const CCreatorScriptAttribute* contactAmountAttr = this->FindAttributeByName(KAmount); + TInt contactAmount = 1; + if( contactAmountAttr ) + { + contactAmount = ConvertStrToIntL(contactAmountAttr->Value()); + } + CCreatorScriptElement* fieldsElement = FindSubElement(KFields); + TInt fieldMappingTblSize = sizeof(fieldMappingTbl)/sizeof(FieldMapping); + for( TInt cI = 0; cI < contactAmount; ++cI ) + { + CPhonebookParameters* param = (CPhonebookParameters*) TCreatorFactory::CreatePhoneBookParametersL(); + CleanupStack::PushL(param); + // Loop all the field elements + if( fieldsElement && fieldsElement->SubElements().Count() > 0 ) + { + + const RPointerArray& fieldList = fieldsElement->SubElements(); + + if( fieldList.Count() == 0 ) + { + + } + for( TInt i = 0; i < fieldList.Count(); ++i ) + { + TPtrC fieldName = fieldList[i]->Name(); + //const CCreatorScriptAttribute* amountAttr = fieldList[i]->FindAttributeByName(KAmount); + //const CCreatorScriptAttribute* rndLenAttr = fieldList[i]->FindAttributeByName(KRandomLength); + //const CCreatorScriptAttribute* increaseAttr = fieldList[i]->FindAttributeByName(KIncrease); + //TBool increase( EFalse ); + //if ( increaseAttr ) + // { + // increase = ConvertStrToBooleanL( increaseAttr->Value() ); + // } + for( TInt j = 0; j < fieldMappingTblSize; ++j ) + { + const FieldMapping& mapping = fieldMappingTbl[j]; + if( fieldName == mapping.iElementName ) + { + TPtrC content = fieldList[i]->Content(); + +// MCreatorRandomDataField::TRandomLengthType randomLenType = MCreatorRandomDataField::ERandomLengthUndefined; + + if( content == TPtrC(KEmpty) || content == TPtrC(KNullDesC) ) + { + CCreatorContactField* field = CCreatorContactField::NewL(); + CleanupStack::PushL(field); + field->AddFieldToParamL( iEngine,param, mapping.iFieldCode, KErrNotFound ); + CleanupStack::Pop(field); + } + else + { + CCreatorContactField* field = CCreatorContactField::NewL(); + CleanupStack::PushL(field); + field->AddFieldToParamL( param, mapping.iFieldCode, content ); + CleanupStack::Pop(field); + } + + + break; + + } + } + + } + } + else + { + // No fields specified, so add all fields with random content: + for( TInt i = 0; i < fieldMappingTblSize; ++i ) + { + if( fieldMappingTbl[i].iElementName == KThumbnailId || + fieldMappingTbl[i].iElementName == KRingToneId ) + { + // Skip thumbnail and ringtone IDs, since they are duplicates with thumbnailpath and ringtonepath + continue; + } + CCreatorContactField* field = CCreatorContactField::NewL(); + CleanupStack::PushL(field); + field->AddFieldToParamL( iEngine,param, fieldMappingTbl[i].iFieldCode, KErrNotFound ); + CleanupStack::Pop(field); + } + + } + iEngine->AppendToCommandArrayL(ECmdCreatePhoneBookEntryContacts, param); + iParameters.AppendL(param); // Save the pointer to the parametes. + CleanupStack::Pop(param); + } + } + + +/* +void CCreatorContactElement::ExecuteCommandL() + {} +*/ +CCreatorContactSetElement* CCreatorContactSetElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext) + { + LOGSTRING("Creator: CCreatorContactSetElement::NewL"); + CCreatorContactSetElement* self = new (ELeave) CCreatorContactSetElement(aEngine); + CleanupStack::PushL(self); + self->ConstructL(aName, aContext); + CleanupStack::Pop(); + return self; + } +CCreatorContactSetElement::CCreatorContactSetElement(CCreatorEngine* aEngine) +: +CCreatorContactElementBase(aEngine) + { } + +void CCreatorContactSetElement::ExecuteCommandL() + { } + +void CCreatorContactSetElement::AddToCacheL() + { + LOGSTRING("Creator: CCreatorContactSetElement::AddToCacheL"); + const CCreatorScriptAttribute* linkIdAttr = this->FindAttributeByName(KId); + const CCreatorScriptAttribute* existingElemsAttr = this->FindAttributeByName(KExistingContacts); + TInt numOfExistingContacts = 0; + if( existingElemsAttr ) + { + numOfExistingContacts = ConvertStrToIntL(existingElemsAttr->Value()); + } + if( linkIdAttr ) + { + TInt linkId = ConvertStrToIntL(linkIdAttr->Value()); + if( linkId > 0 ) + { + CCreatorContactSet* newSet = CCreatorContactSet::NewL(linkId, numOfExistingContacts); + CleanupStack::PushL(newSet); + ContactLinkCache::Instance()->AppendL(newSet); + CleanupStack::Pop(newSet); + + // Mark sub-elements (i.e. contacts) to this contact-set: + for( TInt i = 0; i < iSubElements.Count(); ++i ) + { + for( TInt j = 0; j < iSubElements[i]->CommandParameters().Count(); ++j) + { + CCreatorModuleBaseParameters* params = iSubElements[i]->CommandParameters()[j]; + if( params ) + { + params->SetScriptLinkId(linkId); + } + } + } + } + } + } + +CCreatorContactGroupElement* CCreatorContactGroupElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext) + { + LOGSTRING("Creator: CCreatorContactGroupElement::NewL"); + CCreatorContactGroupElement* self = new (ELeave) CCreatorContactGroupElement(aEngine); + CleanupStack::PushL(self); + self->ConstructL(aName, aContext); + CleanupStack::Pop(); + return self; + } +CCreatorContactGroupElement::CCreatorContactGroupElement(CCreatorEngine* aEngine) +: +CCreatorContactElementBase(aEngine) + { + iIsCommandElement = ETrue; + } + + +void CCreatorContactGroupElement::ExecuteCommandL() + { + LOGSTRING("Creator: CCreatorContactGroupElement::ExecuteCommandL"); + // Get attributes (amount and name) + const CCreatorScriptAttribute* groupAmountAttr = this->FindAttributeByName(KAmount); + const CCreatorScriptAttribute* groupNameAttr = this->FindAttributeByName(KName); + // How many groups to create: + TInt groupAmount = 1; + if( groupAmountAttr ) + { + groupAmount = ConvertStrToIntL(groupAmountAttr->Value()); + } + + for( TInt i = 0; i < groupAmount; ++i ) + { + CCreatorScriptElement* membersElement = FindSubElement(KMembers); + + if( membersElement ) + { + CPhonebookParameters* param = (CPhonebookParameters*) TCreatorFactory::CreatePhoneBookParametersL(); + CleanupStack::PushL(param); + + // Links to contact-sets: + const RPointerArray& linkList = membersElement->SubElements(); + if( linkList.Count() > 0 ) + { + for( TInt i = 0; i < linkList.Count(); ++i ) + { + AppendContactSetReferenceL(*linkList[i], param->iLinkIds); + } + } + + if( groupNameAttr ) + { + param->iGroupName->Des().Copy( groupNameAttr->Value() ); + } + else + { + param->iGroupName->Des().Copy( iEngine->RandomString(CCreatorEngine::EGroupName) ); + } + iEngine->AppendToCommandArrayL(ECmdCreatePhoneBookEntryGroups, param); + CleanupStack::Pop(param); + } + } + } + +/* +void CCreatorContactGroupElement::ExecuteCommandL() + {} +*/ +CCreatorContactFieldElement* CCreatorContactFieldElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext) + { + LOGSTRING("Creator: CCreatorContactFieldElement::NewL"); + CCreatorContactFieldElement* self = new (ELeave) CCreatorContactFieldElement(aEngine); + CleanupStack::PushL(self); + self->ConstructL(aName, aContext); + CleanupStack::Pop(); + return self; + } + +CCreatorContactFieldElement::CCreatorContactFieldElement(CCreatorEngine* aEngine) +: +CCreatorScriptElement(aEngine) + { } diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/src/creator_contactsetcache.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/src/creator_contactsetcache.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,218 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +#include "creator_contactsetcache.h" + + +CContactLinkCacheImp* ContactLinkCache::iImp = 0; + +CCreatorContactSet* CCreatorContactSet::NewL(TInt aLinkId, TInt aNumOfExistingContacts) + { + return new (ELeave) CCreatorContactSet(aLinkId, aNumOfExistingContacts); + } + +TInt CCreatorContactSet::LinkId() const + { + return iLinkId; + } + +void CCreatorContactSet::AppendL(TUint32 aContactLink) + { + iContactLinks.AppendL(aContactLink); + } + +RArray CCreatorContactSet::ContactLinks() + { + return iContactLinks; + } + +const RArray CCreatorContactSet::ContactLinks() const + { + return iContactLinks; + } + + +TInt CCreatorContactSet::NumberOfExistingContacts() const + { + return iNumOfExistingContacts; + } + +CCreatorContactSet::~CCreatorContactSet() + { + iContactLinks.Reset(); + iContactLinks.Close(); + } + + +CCreatorContactSet::CCreatorContactSet(TInt aLinkId, TInt aNumOfExistingContacts) + { + iLinkId = aLinkId; + iNumOfExistingContacts = aNumOfExistingContacts; + } + +class CContactLinkCacheImp : public CBase, public MContactLinkCache +{ +public: + static CContactLinkCacheImp* NewL(); + virtual ~CContactLinkCacheImp(); + virtual void AppendL(CCreatorContactSet* aContactSet); + + virtual RArray ContactLinks(TInt aLinkId); + virtual const RArray ContactLinks(TInt aLinkId) const; + + virtual RPointerArray& ContactSets(); + virtual const RPointerArray& ContactSets() const; + virtual const CCreatorContactSet& ContactSet(TInt aLinkId) const; + virtual CCreatorContactSet& ContactSet(TInt aLinkId); + +private: + void ConstructL(); + CContactLinkCacheImp(); + + RArray iEmptyLinks; + + RPointerArray iContactSets; + CCreatorContactSet* iDummyContactSet; +}; + +CContactLinkCacheImp* CContactLinkCacheImp::NewL() + { + CContactLinkCacheImp* self = new (ELeave) CContactLinkCacheImp(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +void CContactLinkCacheImp::ConstructL() + { + if( iDummyContactSet == 0 ) + iDummyContactSet = CCreatorContactSet::NewL(-1, 0); + } + +CContactLinkCacheImp::CContactLinkCacheImp() +: iDummyContactSet(0) + {} + +CContactLinkCacheImp::~CContactLinkCacheImp() + { + iEmptyLinks.Reset();// just in case... + iEmptyLinks.Close(); + + iContactSets.ResetAndDestroy(); + iContactSets.Close(); + delete iDummyContactSet; + } +void CContactLinkCacheImp::AppendL(CCreatorContactSet* aContactSet) + { + iContactSets.AppendL(aContactSet); + } +RArray CContactLinkCacheImp::ContactLinks(TInt aLinkId) + { + for( TInt i = 0; i < iContactSets.Count(); ++i ) + { + if( iContactSets[i]->LinkId() == aLinkId ) + { + return iContactSets[i]->ContactLinks(); + } + } + return iEmptyLinks; + } + +const RArray CContactLinkCacheImp::ContactLinks(TInt aLinkId) const + { + for( TInt i = 0; i < iContactSets.Count(); ++i ) + { + if( iContactSets[i]->LinkId() == aLinkId ) + { + return iContactSets[i]->ContactLinks(); + } + } + return iEmptyLinks; + } + + +const CCreatorContactSet& CContactLinkCacheImp::ContactSet(TInt aLinkId) const + { + for( TInt i = 0; i < iContactSets.Count(); ++i ) + { + if( iContactSets[i]->LinkId() == aLinkId ) + { + return *iContactSets[i]; + } + } + + return *iDummyContactSet; + } + +CCreatorContactSet& CContactLinkCacheImp::ContactSet(TInt aLinkId) + { + for( TInt i = 0; i < iContactSets.Count(); ++i ) + { + if( iContactSets[i]->LinkId() == aLinkId ) + { + return *iContactSets[i]; + } + } + + return *iDummyContactSet; + } + +RPointerArray& CContactLinkCacheImp::ContactSets() + { + return iContactSets; + } + +const RPointerArray& CContactLinkCacheImp::ContactSets() const + { + return iContactSets; + } + + +void ContactLinkCache::InitializeL() + { + if( iImp == 0 ) + { + iImp = CContactLinkCacheImp::NewL(); + } + } + +void ContactLinkCache::DestroyL() + { + delete iImp; + iImp = 0; + } + +MContactLinkCache* ContactLinkCache::Instance() + { + return iImp; + } + + + /*{ +public: + static void ; + static void DestructLD(); + + static MContactLinkCache* Instance(); + +private: + CContactLinkImp* iImp; +};*/ + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/src/creator_factory.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/src/creator_factory.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include "engine.h" +#include "creator_factory.h" + +//#include "creator_accesspoint.h" +#include "creator_phonebook.h" + +CCreatorPhonebookBase* TCreatorFactory::CreatePhoneBookL(CCreatorEngine* aEngine) +{ + return CCreatorPhonebook::NewL(aEngine); +} + +CCreatorModuleBaseParameters* TCreatorFactory::CreatePhoneBookParametersL() + { + return new(ELeave) CPhonebookParameters; + } +/* +CCreatorConnectionSettingsBase* TCreatorFactory::CreateConnectionSettingsL(CCreatorEngine* aEngine) +{ + return CCreatorAccessPoints::NewL(aEngine); +} + +CCreatorModuleBaseParameters* TCreatorFactory::CreateConnectionSettingsParametersL() + { + return new(ELeave) CAccessPointsParameters; + } +*/ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/src/creator_file.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/src/creator_file.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,829 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include "engine.h" +#include "enginewrapper.h" +#include "creator_file.h" +#include "creator_traces.h" + +using namespace ContentAccess; + +static const TInt KFilesFieldLength = 256; + +//_LIT(KCreatorFilesPrefixName, "CR_"); +//_LIT(KCreatorFilesPrefixFolderName, "CR_FLDR_"); + +//---------------------------------------------------------------------------- + +CFilesParameters::CFilesParameters() + { + LOGSTRING("Creator: CFilesParameters::CFilesParameters"); + iFullFilePath = HBufC::New(KFilesFieldLength); + } + +CFilesParameters::CFilesParameters( CFilesParameters& aCopy ) + { + LOGSTRING("Creator: CFilesParameters::CFilesParameters"); + iFullFilePath = HBufC::New(KFilesFieldLength); + iFullFilePath->Des().Copy( *aCopy.iFullFilePath ); + iFileCommand = aCopy.iFileCommand; + iEncrypt = aCopy.iEncrypt; + if ( aCopy.iPermission ) + { + TRAP_IGNORE( + iPermission = CDRMPermission::NewL(); + iPermission->DuplicateL( *aCopy.iPermission ); + ); + } + } + +CFilesParameters::~CFilesParameters() + { + LOGSTRING("Creator: CFilesParameters::~CFilesParameters"); + delete iFullFilePath; + delete iPermission; + } + +//---------------------------------------------------------------------------- + +CCreatorFiles* CCreatorFiles::NewL(CCreatorEngine* aEngine) + { + CCreatorFiles* self = CCreatorFiles::NewLC(aEngine); + CleanupStack::Pop(self); + return self; + } + +CCreatorFiles* CCreatorFiles::NewLC(CCreatorEngine* aEngine) + { + CCreatorFiles* self = new (ELeave) CCreatorFiles; + CleanupStack::PushL(self); + self->ConstructL(aEngine); + return self; + } + +CCreatorFiles::CCreatorFiles() : + iFs ( CEikonEnv::Static()->FsSession() ) + { + } + +void CCreatorFiles::ConstructL(CCreatorEngine* aEngine) + { + LOGSTRING("Creator: CCreatorFiles::ConstructL"); + + iEngine = aEngine; + + User::LeaveIfError( iApaLs.Connect() ); + + iFilePaths = new (ELeave) CDesCArrayFlat( 4 ); + + // Restore file id + CDictionaryFileStore* store = iEngine->FileStoreLC(); + User::LeaveIfNull( store ); + if ( store->IsPresentL( KUidDictionaryUidFiles ) ) + { + RDictionaryReadStream in; + in.OpenLC( *store, KUidDictionaryUidFiles ); + TRAPD( err, iFileId = in.ReadInt32L() ); + if ( err ) + { + iFileId = 1; + } + CleanupStack::PopAndDestroy(); // in + } + else + { + iFileId = 1; + } + CleanupStack::PopAndDestroy( store ); + } + +CCreatorFiles::~CCreatorFiles() + { + LOGSTRING("Creator: CCreatorFiles::~CCreatorFiles"); + + // this is done only once per file operation: + if ( iFilePaths && iFilePaths->Count() ) + { + TRAP_IGNORE( StorePathsForDeleteL( *iFilePaths ) ); + } + delete iFilePaths; + delete iParameters; + delete iUserParameters; + iApaLs.Close(); + } + +//---------------------------------------------------------------------------- + +void CCreatorFiles::QueryDialogClosedL(TBool aPositiveAction, TInt aUserData) + { + LOGSTRING("Creator: CCreatorFiles::QueryDialogClosedL"); + + if( aPositiveAction == EFalse ) + { + iEngine->ShutDownEnginesL(); + return; + } + + const TDesC* showText = &KSavingText; + TBool finished(EFalse); + TBool retval(ETrue); + switch(aUserData) + { + case ECreatorFilesDelete: + showText = &KDeletingText; + iEntriesToBeCreated = 1; + finished = ETrue; + break; + case ECreatorFilesStart: + { + // set a default directory (eg. c:\Nokia\Images\) + iEngine->SetDefaultPathForFileCommandL(iCommand, iDirectoryQueriedFromUser); + TBuf<50> promptText; + if (iCommand == ECmdCreateFileEntryEmptyFolder) + promptText.Copy( _L("Specify the folder path and name") ); + else + promptText.Copy( _L("Specify the directory") ); + + // show directory query dialog + retval = iEngine->GetEngineWrapper()->DirectoryQueryDialog(promptText, iDirectoryQueriedFromUser, this, ECreatorFilesGetDirectory ); + } + break; + case ECreatorFilesGetDirectory: + // check that the root folder is correct + if ( iDirectoryQueriedFromUser.Length() < 3 || BaflUtils::CheckFolder( iFs, iDirectoryQueriedFromUser.Left(3) ) != KErrNone ) + { + iEngine->GetEngineWrapper()->ShowErrorMessage(_L("Invalid path")); + retval = EFalse; + } + else + { + // check the directory contains a trailing backlash + if ( iDirectoryQueriedFromUser.Right(1) != _L("\\") ) + { + iDirectoryQueriedFromUser.Append(_L("\\")); + } + // copy the directory name to a class member + if ( iCommand == ECmdCreateFileEntryEmptyFolder ) + { + finished = ETrue; + } + else + { + retval = AskDRMDataFromUserL(); + } + } + break; + case ECreatorFilesAskDRMData: + if ( iDummy > 0 ) + { + iUserParameters->iEncrypt = ETrue; + } + if ( iDummy == 2 ) + { + iUserParameters->iPermission = CDRMPermission::NewL(); + CDRMPermission* perm = iUserParameters->iPermission; + perm->iTopLevel->iActiveConstraints = EConstraintNone; + perm->iPlay->iActiveConstraints = EConstraintNone; + perm->iDisplay->iActiveConstraints = EConstraintNone; + perm->iPrint->iActiveConstraints = EConstraintNone; + perm->iExecute->iActiveConstraints = EConstraintNone; + perm->iUniqueID = 0; + // DRM Combined Delivery + iDummy = 0; + retval = iEngine->GetEngineWrapper()->EntriesQueryDialog( &iDummy, _L("How many counts(0=unlimited)?"), ETrue, this, ECreatorFilesAskDRM_CD_Counts ); + } + else + { + finished = ETrue; + } + break; + case ECreatorFilesAskDRM_CD_Counts: + if ( iDummy > 0 ) + { + TInt count = iDummy; + CDRMPermission* perm = iUserParameters->iPermission; + // apply constraints to all permission types + // applied type will be selected by setting iAvailableRights + // when determining the file type + perm->iDisplay->iActiveConstraints |= EConstraintCounter; + perm->iDisplay->iCounter = count; + perm->iDisplay->iOriginalCounter = count; + + perm->iPlay->iActiveConstraints |= EConstraintCounter; + perm->iPlay->iCounter = count; + perm->iPlay->iOriginalCounter = count; + + perm->iPrint->iActiveConstraints |= EConstraintCounter; + perm->iPrint->iCounter = count; + perm->iPrint->iOriginalCounter = count; + + perm->iExecute->iActiveConstraints |= EConstraintCounter; + perm->iExecute->iCounter = count; + perm->iExecute->iOriginalCounter = count; + } + iDummy = 0; + retval = iEngine->GetEngineWrapper()->EntriesQueryDialog( &iDummy, _L("How many minutes until expire(0=unlimited)?"), ETrue, + this, ECreatorFilesAskDRM_CD_Minutes + ); + break; + case ECreatorFilesAskDRM_CD_Minutes: + if ( iDummy > 0 ) + { + TInt minutes = iDummy; + CDRMPermission* perm = iUserParameters->iPermission; + // apply constraints to all permission types + // applied type will be selected by setting iAvailableRights + // when determining the file type + perm->iDisplay->iActiveConstraints |= EConstraintInterval; + perm->iDisplay->iInterval = TTimeIntervalSeconds( 60 * minutes ); + perm->iDisplay->iIntervalStart = Time::NullTTime(); + + perm->iPlay->iActiveConstraints |= EConstraintInterval; + perm->iPlay->iInterval = TTimeIntervalSeconds( 60 * minutes ); + perm->iPlay->iIntervalStart = Time::NullTTime(); + + perm->iPrint->iActiveConstraints |= EConstraintInterval; + perm->iPrint->iInterval = TTimeIntervalSeconds( 60 * minutes ); + perm->iPrint->iIntervalStart = Time::NullTTime(); + + perm->iExecute->iActiveConstraints |= EConstraintInterval; + perm->iExecute->iInterval = TTimeIntervalSeconds( 60 * minutes ); + perm->iExecute->iIntervalStart = Time::NullTTime(); + } + finished = ETrue; + break; + default: + //some error + retval = EFalse; + break; + } + if( retval == EFalse ) + { + iEngine->ShutDownEnginesL(); + } + else if( finished ) + { + // add this command to command array + iEngine->AppendToCommandArrayL(iCommand, NULL, iEntriesToBeCreated); + // started exucuting commands + iEngine->ExecuteFirstCommandL( *showText ); + } + } + +//---------------------------------------------------------------------------- + +TBool CCreatorFiles::AskDataFromUserL(TInt aCommand) + { + LOGSTRING("Creator: CCreatorFiles::AskDataFromUserL"); + + CCreatorModuleBase::AskDataFromUserL( aCommand ); + + if ( aCommand == ECmdDeleteCreatorFiles ) + { + return iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all files created with Creator?"), this, ECreatorFilesDelete ); + } + + delete iUserParameters; + iUserParameters = NULL; + iUserParameters = new(ELeave) CFilesParameters(); + + iDirectoryQueriedFromUser.Copy( KNullDesC ); + + return iEngine->GetEngineWrapper()->EntriesQueryDialog(&iEntriesToBeCreated, _L("How many entries to create?"), EFalse, this, ECreatorFilesStart ); + } + + +//---------------------------------------------------------------------------- + +TInt CCreatorFiles::CreateFileEntryL(CFilesParameters *aParameters, TInt aCommand) + { + LOGSTRING("Creator: CCreatorFiles::CreateFileEntryL"); + + // clear any existing parameter definations + delete iParameters; + iParameters = NULL; + TFileName directoryToBeCreated; + + CFilesParameters* parameters = aParameters; + + if (!parameters) + { + if ( iUserParameters ) + { + iParameters = new (ELeave) CFilesParameters( *iUserParameters ); + // iUserParameters = NULL; + } + else + { + // random data needed if no predefined data available + iParameters = new (ELeave) CFilesParameters; + } + parameters = iParameters; + } + + TInt err = KErrNone; + + // if we just create directories + if ( aCommand == ECmdCreateFileEntryEmptyFolder) + { + // strip the last backslash from the path + if( iDirectoryQueriedFromUser.Length() > 0) + directoryToBeCreated = iDirectoryQueriedFromUser; + else if( parameters->iFullFilePath && parameters->iFullFilePath->Des().Length() > 0 ) + directoryToBeCreated = parameters->iFullFilePath->Des(); + else + return err; + + _LIT(KSlash, "\\"); + if( directoryToBeCreated.Right(1) == KSlash ) + directoryToBeCreated.SetLength ( directoryToBeCreated.Length() - 1 ); + + // generate a unique file name + err = CApaApplication::GenerateFileName( iFs, directoryToBeCreated); + if (err != KErrNone) + return err; + + // now append the backslah back + directoryToBeCreated.Append( _L("\\") ); + + // now create the new directory + err = iFs.MkDirAll( directoryToBeCreated ); + + // Add directoryToBeCreated to store + iFilePaths->AppendL( directoryToBeCreated ); + + LOGSTRING3("Creator: CCreatorFiles::CreateFileEntryL creating empty directory %S returns err", &directoryToBeCreated, err); + } + + else // files + { + LOGSTRING2("Creator: CCreatorFiles::CreateFileEntryL file id is %d", aCommand); + + // get source + TFileName fullSourcePath; + switch (aCommand) + { + case ECmdCreateFileEntryJPEG_25kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EJPEG_25kB ); break; } + case ECmdCreateFileEntryJPEG_200kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EJPEG_200kB ); break; } + case ECmdCreateFileEntryJPEG_500kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EJPEG_500kB ); break; } + case ECmdCreateFileEntryPNG_15kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EPNG_15kB ); break; } + case ECmdCreateFileEntryGIF_2kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EGIF_2kB ); break; } + case ECmdCreateFileEntryRNG_1kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::ERNG_1kB ); break; } + case ECmdCreateFileEntryMIDI_10kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EMIDI_10kB ); break; } + case ECmdCreateFileEntryWAV_20kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EWAVE_20kB ); break; } + case ECmdCreateFileEntryAMR_20kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EAMR_20kB ); break; } + case ECmdCreateFileEntryXLS_15kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EExcel_15kB ); break; } + case ECmdCreateFileEntryDOC_20kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EWord_20kB ); break; } + case ECmdCreateFileEntryPPT_40kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EPowerPoint_40kB ); break; } + case ECmdCreateFileEntryTXT_10kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EText_10kB ); break; } + case ECmdCreateFileEntryTXT_70kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EText_70kB ); break; } + case ECmdCreateFileEntry3GPP_70kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::E3GPP_70kB ); break; } + case ECmdCreateFileEntryMP3_250kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EMP3_250kB ); break; } + case ECmdCreateFileEntryAAC_100kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EAAC_100kB ); break; } + case ECmdCreateFileEntryRM_95kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::ERM_95kB ); break; } + case ECmdCreateFileEntryBMP_25kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EBMP_25kB ); break; } + case ECmdCreateFileEntryDeck_1kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::ESavedDeck_1kB ); break; } + case ECmdCreateFileEntryHTML_20kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EHTML_20kB ); break; } + case ECmdCreateFileEntryJAD_1kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EJAD_1kB ); break; } + case ECmdCreateFileEntryJAR_10kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EJAR_10kB ); break; } + case ECmdCreateFileEntryJP2_65kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EJP2_65kB ); break; } + case ECmdCreateFileEntryMP4_200kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EMP4_200kB ); break; } + case ECmdCreateFileEntryMXMF_40kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EMXMF_40kB ); break; } + case ECmdCreateFileEntryRAM_1kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::ERAM_1kB ); break; } + case ECmdCreateFileEntrySVG_15kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::ESVG_15kB ); break; } + case ECmdCreateFileEntrySWF_15kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::ESWF_15kB ); break; } + case ECmdCreateFileEntryTIF_25kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::ETIF_25kB ); break; } + case ECmdCreateFileEntryVCF_1kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EVCF_1kB ); break; } + case ECmdCreateFileEntryVCS_1kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EVCS_1kB ); break; } + case ECmdCreateFileEntrySISX_10kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::ESISX_10kB ); break; } + case ECmdCreateFileEntryWMA_50kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EWMA_50kB ); break; } + case ECmdCreateFileEntryWMV_200kB: { fullSourcePath = iEngine->TestDataPathL( CCreatorEngine::EWMV_200kB ); break; } + case ECmdCreateFileEntryEmptyFolder: { User::Panic(_L("EmptyFolder"), 801); break; } + default: { return KErrPathNotFound; } + } + + + // define the full target path + TFileName fullTargetPath; + + if ( parameters->iFullFilePath && parameters->iFullFilePath->Des().Length() > 3 ) + { + _LIT(KSlash, "\\"); + // check the path is ok + fullTargetPath = parameters->iFullFilePath->Des(); + + if(fullTargetPath.Right(1) == KSlash) + { + // Remove '\' from the end, because the filename check does not work with it: + fullTargetPath.SetLength ( fullTargetPath.Length() - 1 ); + } + + if (!iFs.IsValidName( fullTargetPath )) + User::Leave(KErrBadName); + + // target path = directory + the file name from source path + TParse parser; + parser.Set(fullSourcePath, NULL, NULL); + + // Add '\' to the end: + fullTargetPath.Append(KSlash); + // Add filename: + fullTargetPath.Append( parser.NameAndExt() ); + + LOGSTRING2("Creator: CCreatorFiles::CreateFileEntryL iFullFilePath used, fullTargetPath: %S", &fullTargetPath); + } + + else if ( iDirectoryQueriedFromUser.Length() > 0 ) + { + // target path = directory + the file name from source path + TParse parser; + parser.Set(fullSourcePath, NULL, NULL); + + fullTargetPath = iDirectoryQueriedFromUser; + fullTargetPath.Append( parser.NameAndExt() ); + + LOGSTRING2("Creator: CCreatorFiles::CreateFileEntryL iDirectoryQueriedFromUser used, fullTargetPath: %S", &fullTargetPath); + } + + else + { + LOGSTRING("Creator: CCreatorFiles::CreateFileEntryL leaving with KErrPathNotFound"); + User::Leave(KErrPathNotFound); + } + + TBool encrypt = parameters->iEncrypt; + if ( encrypt ) fullTargetPath.Append( KOma2DcfExtension ); + // check the target path has a unique filename ie we won't overwrite existing files + // also generates any missing directories + if ( BaflUtils::FileExists( iFs, fullTargetPath ) ) + { + GenerateFileNameL( fullTargetPath ); + } + User::LeaveIfError(CApaApplication::GenerateFileName( iFs, fullTargetPath ) ); + + if ( encrypt ) + { + EncryptFileL( fullSourcePath, fullTargetPath, parameters ); + } + else + { + // copy the file (synchronous function) + err = BaflUtils::CopyFile(iFs, fullSourcePath, fullTargetPath); + LOGSTRING4("Creator: CCreatorFiles::CreateFileEntryL copy %S to %S, err=%d", &fullSourcePath, &fullTargetPath, err); + } + + if (err != KErrNone) + User::Leave(err); // leave because copying failed + + // Add fullTargetPath to store + iFilePaths->AppendL( fullTargetPath ); + + // make sure that the file won't have a read only attribute + TEntry fileEntry; + iFs.Entry(fullTargetPath, fileEntry); + iFs.SetEntry(fullTargetPath, fileEntry.iModified, NULL, KEntryAttReadOnly); + + // clear variables + parameters->iFullFilePath->Des().Copy ( KNullDesC ); + } + + return err; + } + +//---------------------------------------------------------------------------- + +void CCreatorFiles::EncryptFileL( const TDesC& aInFileName, const TDesC& aOutFileName, CFilesParameters *aParameters ) + { + LOGSTRING("Creator: CCreatorFiles::EncryptFileL"); + TBuf8<64> mime; + SetMimeTypeL( aInFileName, mime, aParameters ); + CSupplier* supplier = CSupplier::NewLC(); + + CMetaDataArray* metaData = CMetaDataArray::NewLC(); + + // Tell the agent which MIME type to use for the encrypted data + metaData->AddL( KOmaImportMimeTypeField, mime ); + + if ( aParameters && aParameters->iPermission ) + { + // Combined Delivery file will be created + SetPermissionsL( metaData, aOutFileName, aParameters ); + } + + supplier->SetOutputDirectoryL( iDirectoryQueriedFromUser ); + + // The KOmaImportContentType is a OMA DRM agent specific MIME type which + // indicates that plain content is to be encrypted + CImportFile* importFile = supplier->ImportFileL( KOmaImportContentType, + *metaData, + aOutFileName ); + CleanupStack::PushL( importFile ); + + // Peek the source file size: + TInt fileLen( 0 ); + RFile file; + User::LeaveIfError( file.Open( iFs, aInFileName, EFileRead ) ); + CleanupClosePushL( file ); + User::LeaveIfError( file.Size( fileLen ) ); + CleanupStack::PopAndDestroy( &file ); + + // Read the source file to inmemory buffer + RFileReadStream rs; + User::LeaveIfError( rs.Open( iFs, + aInFileName, + EFileStream | EFileRead ) ); + CleanupClosePushL( rs ); + HBufC8* fileBuf = HBufC8::NewLC( fileLen ); + TPtr8 p = fileBuf->Des(); + rs.ReadL( p, fileLen ); + + // Start encryption + TInt err = importFile->WriteData( p ); + if ( err == KErrCANewFileHandleRequired ) + { + RFile file; + User::LeaveIfError( file.Create( iFs, aOutFileName, EFileWrite ) ); + CleanupClosePushL( file ); + User::LeaveIfError( importFile->ContinueWithNewOutputFile( file, aOutFileName ) ); + CleanupStack::PopAndDestroy( &file ); + } + else + { + User::LeaveIfError( err ); + } + User::LeaveIfError( importFile->WriteDataComplete() ); + CleanupStack::PopAndDestroy( fileBuf ); + CleanupStack::PopAndDestroy( &rs ); + CleanupStack::PopAndDestroy( importFile ); + CleanupStack::PopAndDestroy( metaData ); + CleanupStack::PopAndDestroy( supplier ); + } + +//---------------------------------------------------------------------------- + +void CCreatorFiles::SetPermissionsL( CMetaDataArray* aMetaData, const TDesC& aOutFileName, CFilesParameters *aParameters ) + { + LOGSTRING("Creator: CCreatorFiles::SetPermissionsL"); + CDRMRights* rights = CDRMRights::NewL(); + CleanupStack::PushL( rights ); + + HBufC8* cnturi = HBufC8::NewL( KMaxFileName ); + cnturi->Des().Copy( aOutFileName ); + + CDRMAsset* asset = CDRMAsset::NewLC(); + asset->iUid = cnturi; + // Set the asset to the rights class, it will duplicate the asset + rights->SetAssetL( *asset ); + CleanupStack::PopAndDestroy( asset ); + + rights->SetPermissionL( *aParameters->iPermission ); + + // Construct externalized presentation of the rights object + TInt rightsSize = 1024 *100; + HBufC8* rightBuf = HBufC8::NewLC( rightsSize ); + TPtr8 bptr = rightBuf->Des(); + bptr.SetLength( rightsSize ); + RMemWriteStream iWriteStream; + iWriteStream.Open( (TAny*)(rightBuf->Ptr() ), rightsSize ); + CleanupClosePushL( iWriteStream ); + iWriteStream << *rights; + iWriteStream.CommitL(); + TPtr8 rp = rightBuf->Des(); + + // Add rights to metadata + aMetaData->AddL( KOmaImportRightsField, rp ); + CleanupStack::PopAndDestroy( &iWriteStream ); + CleanupStack::PopAndDestroy( rightBuf ); + CleanupStack::PopAndDestroy( rights ); + } + +//---------------------------------------------------------------------------- + +void CCreatorFiles::SetMimeTypeL( const TDesC& aFileName, TDes8& aMime, CFilesParameters *aParameters ) + { + LOGSTRING("Creator: CCreatorFiles::SetMimeTypeL"); + TUid appUid; + TDataType dataType; + User::LeaveIfError( iApaLs.AppForDocument( aFileName, appUid, dataType ) ); + if ( dataType.Des().Length() ) + { + aMime.Copy( dataType.Des() ); + } + else + { + // set default mime, because it was not recognized by iApaLs + aMime.Copy( _L("text/plain") ); + } + + // set DRM permissions according the type of the file + if ( aParameters->iPermission ) + { + if ( dataType.Des().FindF( _L("image") ) > KErrNotFound ) + { + aParameters->iPermission->iAvailableRights = ERightsDisplay | ERightsPrint; + } + else if ( dataType.Des().FindF( _L("audio") ) > KErrNotFound || + dataType.Des().FindF( _L("video") ) > KErrNotFound || + dataType.Des().FindF( _L("tone") ) > KErrNotFound || // e.g. application/vnd.nokia.ringing-tone + dataType.Des().FindF( _L("realmedia") ) > KErrNotFound ) + { + // media files + aParameters->iPermission->iAvailableRights = ERightsPlay; + } + else if ( dataType.Des().FindF( _L("archive") ) > KErrNotFound || + dataType.Des().FindF( _L("x-sis") ) > KErrNotFound ) + { + // application/java-archive + // x-epoc/x-sisx-app + aParameters->iPermission->iAvailableRights = ERightsExecute; + } + else if ( dataType.Des().FindF( _L("application") ) > KErrNotFound || + dataType.Des().FindF( _L("text") ) > KErrNotFound ) + { + // application/msexcel + // application/msword + // text/plain + // etc. + aParameters->iPermission->iAvailableRights = ERightsDisplay | ERightsPrint; + } + else + { + // other filetype + aParameters->iPermission->iAvailableRights = ERightsDisplay; + } + } + } + +//---------------------------------------------------------------------------- + +TBool CCreatorFiles::AskDRMDataFromUserL() + { + LOGSTRING("Creator: CCreatorFiles::AskDRMDataFromUserL"); + // Encryption -dialog + CDesCArrayFlat* items = new(ELeave) CDesCArrayFlat(5); + CleanupStack::PushL(items); + + // Add entires to list + items->AppendL( _L("None") ); + items->AppendL( _L("DRM Forward Lock") ); + items->AppendL( _L("DRM Combined Delivery") ); + + + // create a popup list + iDummy = 0; + TBool retval = iEngine->GetEngineWrapper()->PopupListDialog(_L("Encryption"), items, &iDummy, this, ECreatorFilesAskDRMData ); + CleanupStack::PopAndDestroy( items ); + return retval; + } + +//---------------------------------------------------------------------------- +void CCreatorFiles::DeleteAllL() + { + LOGSTRING("Creator: CCreatorFiles::DeleteAllL"); + User::Leave( KErrNotSupported ); // will not be supported + } + +//---------------------------------------------------------------------------- +void CCreatorFiles::DeleteAllCreatedByCreatorL() + { + LOGSTRING("Creator: CCreatorFiles::DeleteAllCreatedByCreatorL"); + iFileId = 1; + CDictionaryFileStore* store = iEngine->FileStoreLC(); + User::LeaveIfNull( store ); + + if ( store->IsPresentL( KUidDictionaryUidFiles ) ) + { + RDictionaryReadStream in; + in.OpenLC( *store, KUidDictionaryUidFiles ); + CFileMan* fileMan = CFileMan::NewL( iFs ); + CleanupStack::PushL( fileMan ); + TFileName fullPath; + // ignore return value, don't update iFileId here: + TRAPD( err, in.ReadInt32L() ); + while ( !err ) + { + TInt len( KErrNotFound ); + TRAP( err, len = in.ReadInt8L() ); // will leave with KErrEof + if ( !err ) + { + TRAP( err, in.ReadL( fullPath, len ) ); + } + if ( !err ) + { + TEntry fileEntry; + iFs.Entry( fullPath, fileEntry ); + if ( fileEntry.IsDir() ) + { + fileMan->RmDir( fullPath ); // ignore return value + } + else + { + iFs.Delete( fullPath ); // ignore return value + } + } + } + CleanupStack::PopAndDestroy( fileMan ); + CleanupStack::PopAndDestroy( &in ); + + // files deleted, remove the Creator internal file registry + store->Remove( KUidDictionaryUidFiles ); + store->CommitL(); + } + CleanupStack::PopAndDestroy( store ); + } + +//---------------------------------------------------------------------------- +void CCreatorFiles::StorePathsForDeleteL( CDesCArray& aPaths ) + { + LOGSTRING("Creator: CCreatorFiles::StorePathsForDeleteL"); + CDictionaryFileStore* store = iEngine->FileStoreLC(); + User::LeaveIfNull( store ); + + // backup previous filepaths from store + // otherwise they would be overwritten when calling out.WriteL + CDesCArray* previousPaths = new (ELeave) CDesCArrayFlat( 4 ); + CleanupStack::PushL( previousPaths ); + + TFileName fullPath; + + if ( store->IsPresentL( KUidDictionaryUidFiles ) ) + { + RDictionaryReadStream in; + in.OpenLC( *store, KUidDictionaryUidFiles ); + // ignore return value, don't update iFileId here: + TRAPD( err, in.ReadInt32L() ); + while ( !err ) + { + TRAP( err, + TInt len = in.ReadInt8L(); // will leave with KErrEof + in.ReadL( fullPath, len ); + previousPaths->AppendL( fullPath ); + ); + } + CleanupStack::PopAndDestroy(); // in + } + + RDictionaryWriteStream out; + out.AssignLC( *store, KUidDictionaryUidFiles ); + + // write latest file id to store + out.WriteInt32L( iFileId ); + + // restore previous paths to store + for ( TInt i = 0; i < previousPaths->Count(); i++ ) + { + out.WriteInt8L( (*previousPaths)[i].Length() ); + out.WriteL( (*previousPaths)[i] ); + } + + // write new paths to store + for ( TInt i = 0; i < aPaths.Count(); i++ ) + { + out.WriteInt8L( aPaths[i].Length() ); + out.WriteL( aPaths[i] ); + } + + out.CommitL(); + CleanupStack::PopAndDestroy(); // out + + store->CommitL(); + CleanupStack::PopAndDestroy( previousPaths ); + CleanupStack::PopAndDestroy( store ); + } + +//---------------------------------------------------------------------------- +void CCreatorFiles::GenerateFileNameL( TFileName& aRootName ) + { + LOGSTRING("Creator: CCreatorFiles::GenerateFileNameL"); + if ( iFileId ) + { + TBuf<16> extension; + if ( iFileId < 10 ) + { + extension.Format( _L("(0%d)"), iFileId ); + } + else + { + extension.Format( _L("(%d)"), iFileId ); + } + aRootName.Insert( aRootName.Locate( '.' ), extension ); + } + iFileId++; + } + +// End of file diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/src/creator_fileelement.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/src/creator_fileelement.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,316 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +#include "creator_fileelement.h" +#include +#include +#include "creator_traces.h" +#include "creator_file.h" + +using namespace creatorfile; + +// 15 minutes per time zone, 60 seconds per minute +const TInt KSecondsPerTimeZone = 900; +const TInt KMinuteInMicroseconds = 60000000; +const TInt KTimeZoneIncrement = 15; + +/* + * + */ +CCreatorFileElement* CCreatorFileElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext ) + { + CCreatorFileElement* self = new (ELeave) CCreatorFileElement(aEngine); + CleanupStack::PushL(self); + self->ConstructL(aName, aContext); + CleanupStack::Pop(self); + return self; + } +/* + * + */ +CCreatorFileElement::CCreatorFileElement(CCreatorEngine* aEngine) +: +CCreatorScriptElement(aEngine) + { + iIsCommandElement = ETrue; + + TTime currUniversal; + TTime currLocal; + TInt64 result( 0 ); + currUniversal.UniversalTime(); + currLocal.HomeTime(); + result = currLocal.Int64() - currUniversal.Int64(); + result /= KMinuteInMicroseconds; + result /= KTimeZoneIncrement; + iTimeZone = I64INT( result ); + } +/* + * + */ +void CCreatorFileElement::ExecuteCommandL() + { + const CCreatorScriptAttribute* amountAttr = FindAttributeByName(KAmount); + TInt fileAmount = 1; + if( amountAttr ) + { + fileAmount = ConvertStrToIntL(amountAttr->Value()); + } + // Get 'fields' element + CCreatorScriptElement* fieldsElement = FindSubElement(KFields); + if( fieldsElement && fieldsElement->SubElements().Count() > 0) + { + // Get sub-elements + const RPointerArray& fields = fieldsElement->SubElements(); + // Create files, the amount of files is defined by fileAmount: + for( TInt cI = 0; cI < fileAmount; ++cI ) + { + CFilesParameters* param = new (ELeave) CFilesParameters; + CleanupStack::PushL( param ); + + for( TInt i = 0; i < fields.Count(); ++i ) + { + CCreatorScriptElement* field = fields[i]; + TPtrC elemName = field->Name(); + TPtrC elemContent = field->Content(); + + const CCreatorScriptAttribute* randomAttr = field->FindAttributeByName( KRandomLength ); + + if( elemName == KType ) + { + param->iFileCommand = GetFileCommandL(elemContent, randomAttr || elemContent.Length() == 0); + } + else if( elemName == KDirectory ) + { + delete param->iFullFilePath; + param->iFullFilePath = 0; + if( randomAttr == 0 && elemContent.Length() > 0 ) + { + param->iFullFilePath = elemContent.AllocL(); + } + else + { + TFileName defaultPath; + iEngine->SetDefaultPathForFileCommandL( param->iFileCommand, defaultPath ); + param->iFullFilePath = defaultPath.AllocL(); + } + } + else if ( elemName == KEncryption ) + { + ParseDRMElementsL( field, param ); + } + } + + if ( !param->iFileCommand ) + { + param->iFileCommand = ECmdCreateFileEntryEmptyFolder; + } + iEngine->AppendToCommandArrayL( param->iFileCommand, param); + CleanupStack::Pop( param ); + } + } + else + { + _LIT(KDummy, ""); + for( TInt cI = 0; cI < fileAmount; ++cI ) + { + CFilesParameters* param = new (ELeave) CFilesParameters; + CleanupStack::PushL(param); + delete param->iFullFilePath; + param->iFullFilePath = 0; + TFileName defaultPath; + param->iFileCommand = GetFileCommandL(KDummy, ETrue); + iEngine->SetDefaultPathForFileCommandL(param->iFileCommand, defaultPath); + param->iFullFilePath = defaultPath.AllocL(); + + iEngine->AppendToCommandArrayL(param->iFileCommand, param); + CleanupStack::Pop(param); + } + } + } + +TInt CCreatorFileElement::GetFileCommandL( const TDesC& aFileIdStr, TBool aRandom ) const + { + TInt mapCount = sizeof(FileMap) / sizeof(FileMapping); + + if( aRandom ) + { + return FileMap[iEngine->RandomNumber(0, mapCount-1)].CommandId(); + } + + for( TInt i = 0; i < mapCount; ++i ) + { + if( CompareIgnoreCase(FileMap[i].FileName(), aFileIdStr) == 0 ) + return FileMap[i].CommandId(); + } + LOGSTRING2("CCreatorFileElement::GetFileCommandL: Unknown file id: %S", &aFileIdStr); + User::Leave(KErrGeneral); + return 0; // Not reached, but disables compiler warning... + } + +void CCreatorFileElement::ParseDRMElementsL( CCreatorScriptElement* aField, CFilesParameters* aParam ) + { + const CCreatorScriptAttribute* encryptionTypeAttr = aField->FindAttributeByName( KType ); + if ( encryptionTypeAttr && encryptionTypeAttr->Value().Length() > 0 ) + { + aParam->iEncrypt = ETrue; + if ( encryptionTypeAttr->Value() == KDRMCD ) + { + delete aParam->iPermission; + aParam->iPermission = NULL; + // ownership transferred: + aParam->iPermission = CDRMPermission::NewL(); + } + else if ( encryptionTypeAttr->Value() != KDRMFL ) + { + // must be either KDRMCD or KDRMFL + User::Leave( KErrArgument ); + } + } + else + { + User::Leave( KErrArgument ); + } + + const RPointerArray& rights = aField->SubElements(); + + if ( encryptionTypeAttr->Value() == KDRMFL && rights.Count() ) + { + // Right definitions not allowed with DRM Forward Lock + // User::Leave( KErrArgument ); // Do not leave here + return; // Just omit rights definitions + } + + // parse right elements + CDRMPermission* drmPermission = aParam->iPermission; + for ( TInt r = 0; r < rights.Count(); r++ ) + { + const CCreatorScriptAttribute* rightAttr = rights[r]->FindAttributeByName( KType ); + if ( rightAttr->Value() == KDRMPlayRight && + !( drmPermission->iAvailableRights & ERightsPlay ) ) + { + drmPermission->iAvailableRights |= ERightsPlay; + ParseDRMConstraintsL( rights[r], drmPermission->iPlay ); + } + else if ( rightAttr->Value() == KDRMDisplayRight && + !( drmPermission->iAvailableRights & ERightsDisplay )) + { + drmPermission->iAvailableRights |= ERightsDisplay; + ParseDRMConstraintsL( rights[r], drmPermission->iDisplay ); + } + else if ( rightAttr->Value() == KDRMPrintRight && + !( drmPermission->iAvailableRights & ERightsPrint ) ) + { + drmPermission->iAvailableRights |= ERightsPrint; + ParseDRMConstraintsL( rights[r], drmPermission->iPrint ); + } + else if ( rightAttr->Value() == KDRMExecuteRight && + !( drmPermission->iAvailableRights & ERightsExecute ) ) + { + drmPermission->iAvailableRights |= ERightsExecute; + ParseDRMConstraintsL( rights[r], drmPermission->iExecute ); + } + } + } + +void CCreatorFileElement::ParseDRMConstraintsL( CCreatorScriptElement* aRight, CDRMConstraint* aConstraint ) + { + const RPointerArray& constraints = aRight->SubElements(); + for ( TInt c = 0; c < constraints.Count(); c++ ) + { + TPtrC elemName = constraints[c]->Name(); + TPtrC elemContent = constraints[c]->Content(); + if ( elemName == KDRMCount ) + { + TInt count = ConvertStrToIntL( elemContent ); + // apply count constraint + aConstraint->iActiveConstraints |= EConstraintCounter; + aConstraint->iCounter = count; + aConstraint->iOriginalCounter = count; + } + else if ( elemName == KDRMInterval ) + { + // apply interval constraint + aConstraint->iActiveConstraints |= EConstraintInterval; + aConstraint->iInterval = ParseTimeInterval( elemContent ); + aConstraint->iIntervalStart = Time::NullTTime(); + } + else if ( elemName == KDRMStartTime ) + { + // apply start time constraint + aConstraint->iActiveConstraints |= EConstraintStartTime; + TTimeIntervalSeconds offset( iTimeZone * KSecondsPerTimeZone ); + aConstraint->iStartTime = ConvertToDateTimeL( elemContent ) - offset; + } + else if ( elemName == KDRMEndTime ) + { + // apply end time constraint + aConstraint->iActiveConstraints |= EConstraintEndTime; + TTimeIntervalSeconds offset( iTimeZone * KSecondsPerTimeZone ); + aConstraint->iEndTime = ConvertToDateTimeL( elemContent ) - offset; + } + else if ( elemName == KDRMAccumulated ) + { + // apply accumulated time constraint + aConstraint->iActiveConstraints |= EConstraintAccumulated; + if ( aConstraint->iEndTime == Time::NullTTime() ) + { + aConstraint->iEndTime = Time::MaxTTime(); + } + if ( aConstraint->iStartTime == Time::NullTTime() ) + { + aConstraint->iStartTime = Time::MinTTime(); + } + aConstraint->iAccumulatedTime = ParseTimeInterval( elemContent ); + } + } + } + +TTimeIntervalSeconds CCreatorFileElement::ParseTimeInterval( TDesC& aTimeString ) + { + // Iso8601 format (P1Y2M3DT4H5M6S) to TimeIntervalSeconds + TLex lex; + TInt year = 0; + TInt month = 0; + TInt day = 0; + TInt hour = 0; + TInt minute = 0; + TInt second = 0; + + if (aTimeString.Length() > 0) + { + lex = aTimeString; + lex.Inc(); // skip 'P' + lex.Val(year); + lex.Inc(); + lex.Val(month); + lex.Inc(); + lex.Val(day); + lex.Inc(2); + lex.Val(hour); + lex.Inc(); + lex.Val(minute); + lex.Inc(); + lex.Val(second); + } + TTimeIntervalSeconds result( ( ( ( year * 365 + month * 30 + day ) * 24 + hour ) + * 60 + minute ) * 60 + second ); + return result; + } + +// End of file diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/src/creator_landmark.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/src/creator_landmark.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,502 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include +#include +#include + +#include "engine.h" +#include "enginewrapper.h" +#include "creator_landmark.h" +#include "creator_traces.h" + +_LIT(KAccommodation, "accommodation"); +_LIT(KBusiness, "business"); +_LIT(KCommunication, "communication"); +_LIT(KEducational, "educational"); +_LIT(KEntertainment, "entertainment"); +_LIT(KFoodAndBeverage, "food"); +_LIT(KGeographical, "geographical"); +_LIT(KOutdoor, "outdoor"); +_LIT(KPeople, "people"); +_LIT(KPublic, "public"); +_LIT(KReligious, "religious"); +_LIT(KShopping, "shopping"); +_LIT(KSightseeing, "sightseeing"); +_LIT(KSports, "sports"); +_LIT(KTransport, "transport"); + + +/** + * Class mapping the strings to global landmark categories + */ +class CategoryMapping +{ +public: + CategoryMapping(TUint aId, const TDesC& aCategoryStr) + : + iGlobalId(aId), + iStr(aCategoryStr) + {} + + TPosLmGlobalCategory iGlobalId; + const TDesC& iStr; +}; + +/** + * Global landmark categories + */ +CategoryMapping LandmarkCategories[] = { + CategoryMapping(3000, KAccommodation), // Accommodation + CategoryMapping(6000, KBusiness), // Business + CategoryMapping(9000, KCommunication), // Communication + CategoryMapping(12000, KEducational), // Educational institute + CategoryMapping(15000, KEntertainment), // Entertainment + CategoryMapping(18000, KFoodAndBeverage), // Food & Beverage + CategoryMapping(21000, KGeographical), // Geographical area + CategoryMapping(24000, KOutdoor), // Outdoor activities + CategoryMapping(27000, KPeople), // People + CategoryMapping(30000, KPublic), // Public service + CategoryMapping(33000, KReligious), // Religious places + CategoryMapping(36000, KShopping), // Shopping + CategoryMapping(39000, KSightseeing), // Sightseeing + CategoryMapping(42000, KSports), // Sports + CategoryMapping(45000, KTransport) // Transport +}; + +/** + * Return landmark global id + */ +TPosLmGlobalCategory CCreatorLandmarks::GetCategoryIdL(const TDesC& aCategoryStr) + { + TUint numOfCategories = sizeof(LandmarkCategories)/sizeof(CategoryMapping); + for( TUint i = 0; i < numOfCategories; ++i ) + { + if( LandmarkCategories[i].iStr == aCategoryStr ) + return LandmarkCategories[i].iGlobalId; + } + + return 0; + } + +/** + * + */ +CLandmarkParameters::CLandmarkParameters() + { + LOGSTRING("Creator: CLandmarkParameters::CLandmarkParameters"); + } + +/** + * + */ +CLandmarkParameters::~CLandmarkParameters() + { + LOGSTRING("Creator: CLandmarkParameters::~CLandmarkParameters"); + delete iName; + delete iStreet; + delete iCity; + delete iState; + delete iCountry; + delete iPostCode; + delete iDescription; + delete iPhonenumber; + delete iUrl; + iCategories.Close(); + } + +/** + * + */ +void CLandmarkParameters::SetRandomNameL(CCreatorEngine& aEngine) + { + TPtrC name(aEngine.RandomString(CCreatorEngine::ELandmarkName)); + delete iName; + iName = 0; + iName = HBufC::NewL(name.Length()); + iName->Des().Copy(name); + } + +/** + * + */ +void CLandmarkParameters::SetRandomUrlL(CCreatorEngine& aEngine) + { + _LIT(KUrlPrefix, "http://www."); + _LIT(KUrlPostfix, ".com"); + TPtrC company(aEngine.RandomString(CCreatorEngine::ECompany)); + delete iUrl; + iUrl = 0; + iUrl = HBufC::NewL(KUrlPrefix().Length()+company.Length()+KUrlPostfix().Length()); + iUrl->Des() = KUrlPrefix; + iUrl->Des().Append( company ); + iUrl->Des().Append( KUrlPostfix ); + } + +/** + * + */ +void CLandmarkParameters::AddRandomCategoryL(CCreatorEngine& aEngine) + { + TUint numOfCategories = sizeof(LandmarkCategories)/sizeof(CategoryMapping); + iCategories.AppendL(LandmarkCategories[aEngine.RandomNumber(0, numOfCategories-1)].iGlobalId); + } + +/** + * + */ +void CLandmarkParameters::SetRandomStreetL(CCreatorEngine& aEngine) + { + TPtrC street(aEngine.RandomString(CCreatorEngine::EAddress)); + delete iStreet; + iStreet = 0; + iStreet = HBufC::NewL(street.Length()); + iStreet->Des().Copy(street); + } + +/** + * + */ +void CLandmarkParameters::SetRandomCityL(CCreatorEngine& aEngine) + { + TPtrC city(aEngine.RandomString(CCreatorEngine::ECity)); + delete iCity; + iCity = 0; + iCity = HBufC::NewL(city.Length()); + iCity->Des().Copy(city); + } + +/** + * + */ +void CLandmarkParameters::SetRandomStateL(CCreatorEngine& aEngine) + { + TPtrC state(aEngine.RandomString(CCreatorEngine::EState)); + delete iState; + iState = 0; + iState = HBufC::NewL(state.Length()); + iState->Des().Copy(state); + } + +/** + * + */ +void CLandmarkParameters::SetRandomCountryL(CCreatorEngine& aEngine) + { + TPtrC country(aEngine.RandomString(CCreatorEngine::ECountry)); + delete iCountry; + iCountry = 0; + iCountry = HBufC::NewL(country.Length()); + iCountry->Des().Copy(country); + } + +/** + * + */ +void CLandmarkParameters::SetRandomPostCodeL(CCreatorEngine& aEngine) + { + TPtrC po(aEngine.RandomString(CCreatorEngine::EPostcode)); + delete iPostCode; + iPostCode = 0; + iPostCode = HBufC::NewL(po.Length()); + iPostCode->Des().Copy(po); + } + +/** + * + */ +void CLandmarkParameters::SetRandomLatitudeL(CCreatorEngine& aEngine) + { + iLatitude = aEngine.RandomNumber(-89, 89); // Degrees + TReal64 random = aEngine.RandomNumber(0, 9999); // Desimals + iLatitude += random / 10000.0; + } + +/** + * + */ +void CLandmarkParameters::SetRandomLongitudeL(CCreatorEngine& aEngine) + { + TInt minDegrees = -179; + TInt maxDegrees = 179; + TInt minDecimal = 0; + TInt maxDecimal = 9999; + TReal64 divider = 10000.0; + iLongitude = aEngine.RandomNumber(minDegrees, maxDegrees); // Degrees + TReal64 random = aEngine.RandomNumber(minDecimal, maxDecimal); + iLongitude += random / divider; + } + +/** + * + */ +void CLandmarkParameters::SetRandomPositionAccuracyL(CCreatorEngine& aEngine) + { + this->iPositionAccuracy = aEngine.RandomNumber(0,5); + } + +/** + * + */ +void CLandmarkParameters::SetRandomAltitudeL(CCreatorEngine& aEngine) + { + this->iAltitude = aEngine.RandomNumber(0,120); + } + +/** + * + */ +void CLandmarkParameters::SetRandomAltitudeAccuracyL(CCreatorEngine& aEngine) + { + this->iAltitudeAccuracy = aEngine.RandomNumber(0,5); + } + +/** + * + */ +void CLandmarkParameters::SetRandomDescriptionL(CCreatorEngine& aEngine) + { + delete iDescription; + iDescription = 0; + TPtrC desc(aEngine.RandomString(CCreatorEngine::ELandmarkDescription)); + iDescription = HBufC::NewL(desc.Length()); + iDescription->Des().Copy(desc); + } + +/** + * + */ +void CLandmarkParameters::SetRandomPhoneNumberL(CCreatorEngine& aEngine) + { + delete iPhonenumber; + iPhonenumber = 0; + TPtrC phone(aEngine.RandomString(CCreatorEngine::EPhoneNumber)); + iPhonenumber = HBufC::NewL(phone.Length()); + iPhonenumber->Des().Copy(phone); + } + +/** + * + */ +CCreatorLandmarks::CCreatorLandmarks() + { + } + +/** + * + */ +CCreatorLandmarks* CCreatorLandmarks::NewL(CCreatorEngine* aEngine) + { + CCreatorLandmarks* self = CCreatorLandmarks::NewLC(aEngine); + CleanupStack::Pop(); // self + return self; + } + +/** + * + */ +CCreatorLandmarks* CCreatorLandmarks::NewLC(CCreatorEngine* aEngine) + { + CCreatorLandmarks* self = new (ELeave) CCreatorLandmarks; + CleanupStack::PushL(self); + self->ConstructL(aEngine); + return self; + } + +/** + * + */ +void CCreatorLandmarks::ConstructL(CCreatorEngine* aEngine) + { + LOGSTRING("Creator: CCreatorLandmarks::ConstructL"); + iEngine = aEngine; + iLandmarkDb = CPosLandmarkDatabase::OpenL(); + if( iLandmarkDb->IsInitializingNeeded() ) + { + ExecuteAndDeleteLD(iLandmarkDb->InitializeL()); + } + } + +/** + * + */ +CCreatorLandmarks::~CCreatorLandmarks() + { + LOGSTRING("Creator: CCreatorLandmarks::~CCreatorLandmarks"); + if ( iEngine && iEntryIds.Count() ) + { + TRAP_IGNORE( iEngine->WriteEntryIdsToStoreL( iEntryIds, KUidDictionaryUidLandmarks ) ); + } + iEntryIds.Reset(); + iEntryIds.Close(); + + delete iLandmarkDb; + delete iLmOperation; + delete iParameters; + } + +/** + * + */ +TBool CCreatorLandmarks::AskDataFromUserL(TInt aCommand) + { + LOGSTRING("Creator: CCreatorLandmarks::AskDataFromUserL"); + + CCreatorModuleBase::AskDataFromUserL( aCommand ); + + if ( aCommand == ECmdDeleteLandmarks ) + { + return iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all Landmarks?"), this, ECreatorModuleDelete ); + } + else if ( aCommand == ECmdDeleteCreatorLandmarks ) + { + return iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all Landmarks created with Creator?"), this, ECreatorModuleDelete ); + } + return iEngine->GetEngineWrapper()->EntriesQueryDialog(&iEntriesToBeCreated, _L("How many landmarks to create?"), EFalse, this, ECreatorModuleStart ); + } + +/** + * Convert global category id to local category id + */ +TPosLmItemId CCreatorLandmarks::GetCategoryIdL( TPosLmGlobalCategory aGlobalCategoryID ) +{ + CPosLmCategoryManager* categoryManager = CPosLmCategoryManager::NewL( *iLandmarkDb ); + CleanupStack::PushL( categoryManager ); + + // Find ID of the given global category in given database + TPosLmItemId id = categoryManager->GetGlobalCategoryL( aGlobalCategoryID ); + CleanupStack::PopAndDestroy(); // categoryManager + return id; +} + +/** + * + */ +TInt CCreatorLandmarks::CreateLandmarkEntryL(CLandmarkParameters *aParameters) + { + LOGSTRING("Creator: CCreatorLandmarks::CreateLandmarkEntryL"); + TInt err = KErrNone; + // clear any existing parameter definations + delete iParameters; + iParameters = NULL; + + CLandmarkParameters* parameters = aParameters; + + // random data needed if no predefined data available + if (!parameters) + { + iParameters = new(ELeave) CLandmarkParameters; + parameters = iParameters; + + TBuf<160> company = iEngine->RandomString(CCreatorEngine::ECompany); + + parameters->SetRandomNameL(*iEngine); + parameters->SetRandomUrlL(*iEngine); + parameters->AddRandomCategoryL(*iEngine); + parameters->SetRandomStreetL(*iEngine); + parameters->SetRandomCityL(*iEngine); + parameters->SetRandomStateL(*iEngine); + parameters->SetRandomCountryL(*iEngine); + parameters->SetRandomPostCodeL(*iEngine); + parameters->SetRandomLatitudeL(*iEngine); + parameters->SetRandomLongitudeL(*iEngine); + parameters->SetRandomPositionAccuracyL(*iEngine); + parameters->SetRandomAltitudeL(*iEngine); + parameters->SetRandomAltitudeAccuracyL(*iEngine); + parameters->SetRandomDescriptionL(*iEngine); + parameters->SetRandomPhoneNumberL(*iEngine); + } + + CPosLandmark* newLandmark = CPosLandmark::NewLC(); + TCoordinate crd(parameters->iLatitude, parameters->iLongitude, parameters->iAltitude); + TLocality loc(crd, parameters->iPositionAccuracy, parameters->iAltitudeAccuracy); + newLandmark->SetPositionL(loc); + + // Add categories + for( TInt i = 0; i < parameters->iCategories.Count(); ++i ) + { + newLandmark->AddCategoryL(GetCategoryIdL(parameters->iCategories[i])); + } + if( parameters->iName ) + newLandmark->SetLandmarkNameL(parameters->iName->Des()); + if( parameters->iCountry ) + newLandmark->SetPositionFieldL(EPositionFieldCountry, parameters->iCountry->Des()); + if( parameters->iCity ) + newLandmark->SetPositionFieldL(EPositionFieldCity, parameters->iCity->Des()); + if( parameters->iPostCode ) + newLandmark->SetPositionFieldL(EPositionFieldPostalCode, parameters->iPostCode->Des()); + if( parameters->iState ) + newLandmark->SetPositionFieldL(EPositionFieldState, parameters->iState->Des()); + if( parameters->iStreet ) + newLandmark->SetPositionFieldL(EPositionFieldStreet, parameters->iStreet->Des()); + if( parameters->iPhonenumber ) + newLandmark->SetPositionFieldL(EPositionFieldBuildingTelephone, parameters->iPhonenumber->Des()); + if( parameters->iDescription ) + newLandmark->SetLandmarkDescriptionL(parameters->iDescription->Des()); + if( parameters->iUrl ) + newLandmark->SetPositionFieldL(EPositionFieldMediaLinksStart, parameters->iUrl->Des()); + + TRAP(err, iLandmarkDb->AddLandmarkL(*newLandmark)); + + // id has been generated, store it for being able to delete + // entries created only with Creator + iEntryIds.AppendL( newLandmark->LandmarkId() ); + + ExecuteAndDeleteLD(iLandmarkDb->CompactL()); + + CleanupStack::PopAndDestroy(newLandmark); + return err; + } + +//---------------------------------------------------------------------------- +void CCreatorLandmarks::DeleteAllL() + { + LOGSTRING("Creator: CCreatorLandmarks::DeleteAllL"); + ExecuteAndDeleteLD( iLandmarkDb->RemoveAllLandmarksL() ); + ExecuteAndDeleteLD( iLandmarkDb->CompactL() ); + + // reset must be done here, because iEntryIds is stored in destructor + iEntryIds.Reset(); + + // all entries deleted, remove the Landmarks related registry + iEngine->RemoveStoreL( KUidDictionaryUidLandmarks ); + } + +//---------------------------------------------------------------------------- +void CCreatorLandmarks::DeleteAllCreatedByCreatorL() + { + LOGSTRING("Creator: CCreatorLandmarks::DeleteAllCreatedByCreatorL"); + iEntryIds.Reset(); + + // fetch ids of entries created by Creator + iEngine->ReadEntryIdsFromStoreL( iEntryIds, KUidDictionaryUidLandmarks ); + + // delete entries + TRAP_IGNORE( + ExecuteAndDeleteLD( iLandmarkDb->RemoveLandmarksL( iEntryIds ) ); + ExecuteAndDeleteLD( iLandmarkDb->CompactL() ); + ); + + // reset must be done here, because iEntryIds is stored in destructor + iEntryIds.Reset(); + + // all entries deleted, remove the Landmarks related registry + iEngine->RemoveStoreL( KUidDictionaryUidLandmarks ); + } + + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/src/creator_landmarkelement.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/src/creator_landmarkelement.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,257 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +#include "creator_landmarkelement.h" +#include "creator_traces.h" +#include "creator_landmark.h" + +using namespace creatorlandmark; + +/* + * + */ +CCreatorLandmarkElement* CCreatorLandmarkElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext ) + { + CCreatorLandmarkElement* self = new (ELeave) CCreatorLandmarkElement(aEngine); + CleanupStack::PushL(self); + self->ConstructL(aName, aContext); + CleanupStack::Pop(self); + return self; + } +/* + * + */ +CCreatorLandmarkElement::CCreatorLandmarkElement(CCreatorEngine* aEngine) +: +CCreatorScriptElement(aEngine) + { + iIsCommandElement = ETrue; + } + +void CCreatorLandmarkElement::ExecuteCommandL() + { + const CCreatorScriptAttribute* amountAttr = FindAttributeByName(KAmount); + TInt lmAmount = 1; + if( amountAttr ) + { + lmAmount = ConvertStrToIntL(amountAttr->Value()); + } + // Get 'fields' element + CCreatorScriptElement* fieldsElement = FindSubElement(KFields); + if( fieldsElement && fieldsElement->SubElements().Count() > 0 ) + { + // Get sub-elements + const RPointerArray& fields = fieldsElement->SubElements(); + // Create note entries, the amount of entries is defined by noteAmount: + for( TInt cI = 0; cI < lmAmount; ++cI ) + { + CLandmarkParameters* param = new (ELeave) CLandmarkParameters; + CleanupStack::PushL(param); + + for( TInt i = 0; i < fields.Count(); ++i ) + { + CCreatorScriptElement* field = fields[i]; + TPtrC elemName = field->Name(); + TPtrC elemContent = field->Content(); + const CCreatorScriptAttribute* randomAttr = fields[i]->FindAttributeByName(KRandomLength); + TBool useRandom = EFalse; + if( randomAttr || elemContent.Length() == 0 ) + { + useRandom = ETrue; + } + + if( elemName == KName ) + { + if( useRandom ) + { + param->SetRandomNameL(*iEngine); + } + else + { + SetContentToTextParamL(param->iName, elemContent); + } + } + else if( elemName == KCategory ) + { + if( useRandom ) + { + param->AddRandomCategoryL(*iEngine); + } + else + { + TPosLmItemId categoryId = CCreatorLandmarks::GetCategoryIdL(elemContent); + if( categoryId > 0 ) + { + param->iCategories.AppendL(categoryId); + } + } + } + else if( elemName == KDescription ) + { + if( useRandom ) + { + param->SetRandomDescriptionL(*iEngine); + } + else + { + SetContentToTextParamL(param->iDescription, elemContent); + } + } + else if( elemName == KStreet ) + { + if( useRandom ) + { + param->SetRandomStreetL(*iEngine); + } + else + { + SetContentToTextParamL(param->iStreet, elemContent); + } + } + else if( elemName == KPostalcode ) + { + if( useRandom ) + { + param->SetRandomPostCodeL(*iEngine); + } + else + { + SetContentToTextParamL(param->iPostCode, elemContent); + } + } + else if( elemName == KCity ) + { + if( useRandom ) + { + param->SetRandomCityL(*iEngine); + } + else + { + SetContentToTextParamL(param->iCity, elemContent); + } + } + else if( elemName == KState ) + { + if( useRandom ) + { + param->SetRandomStateL(*iEngine); + } + else + { + SetContentToTextParamL(param->iState, elemContent); + } + } + else if( elemName == KCountry ) + { + if( useRandom ) + { + param->SetRandomCountryL(*iEngine); + } + else + { + SetContentToTextParamL(param->iCountry, elemContent); + } + } + else if( elemName == KPhonenumber ) + { + if( useRandom ) + { + param->SetRandomPhoneNumberL(*iEngine); + } + else + { + SetContentToTextParamL(param->iPhonenumber, elemContent); + } + } + else if( elemName == KUrl ) + { + if( useRandom ) + { + param->SetRandomUrlL(*iEngine); + } + else + { + SetContentToTextParamL(param->iUrl, elemContent); + } + } + else if( elemName == KLatitude ) + { + if( useRandom ) + { + param->SetRandomLatitudeL(*iEngine); + } + else + { + ConvertStrToReal64L(elemContent, param->iLatitude); + } + } + else if( elemName == KLongitude ) + { + if( useRandom ) + { + param->SetRandomLongitudeL(*iEngine); + } + else + { + ConvertStrToReal64L(elemContent, param->iLongitude); + } + } + else if( elemName == KPositionaccuracy ) + { + if( useRandom ) + { + param->SetRandomPositionAccuracyL(*iEngine); + } + else + { + param->iPositionAccuracy = ConvertStrToIntL(elemContent); + } + } + else if( elemName == KAltitude ) + { + if( useRandom ) + { + param->SetRandomAltitudeL(*iEngine); + } + else + { + ConvertStrToReal32L(elemContent, param->iAltitude); + } + } + else if( elemName == KAltitudeaccuracy ) + { + if( useRandom ) + { + param->SetRandomAltitudeAccuracyL(*iEngine); + } + else + { + param->iAltitudeAccuracy = ConvertStrToIntL(elemContent); + } + } + } + iEngine->AppendToCommandArrayL(ECmdCreateMiscEntryLandmarks, param); + CleanupStack::Pop(); // param + } + } + else + { + iEngine->AppendToCommandArrayL(ECmdCreateMiscEntryLandmarks, 0, lmAmount); + } + } diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/src/creator_log.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/src/creator_log.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,486 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +#include + +#include "engine.h" +#include "enginewrapper.h" +#include "creator_log.h" +#include "creator_traces.h" + +static const TInt KLogsFieldLength = 256; + +//_LIT(KCreatorLogsPrefixName, "CR_"); + +//---------------------------------------------------------------------------- + +CLogsParameters::CLogsParameters() + { + LOGSTRING("Creator: CLogsParameters::CLogsParameters"); + + iPhoneNumber = HBufC::New(KLogsFieldLength); + /*iMissedCallPhoneNumber = HBufC::New(KLogsFieldLength); + iReceivedCallPhoneNumber = HBufC::New(KLogsFieldLength); + iDialledNumberPhoneNumber = HBufC::New(KLogsFieldLength);*/ + } + +CLogsParameters::~CLogsParameters() + { + LOGSTRING("Creator: CLogsParameters::~CLogsParameters"); + + delete iPhoneNumber; + /*delete iDialledNumberPhoneNumber; + delete iReceivedCallPhoneNumber; + delete iMissedCallPhoneNumber;*/ + } + +//---------------------------------------------------------------------------- + +CCreatorLogs* CCreatorLogs::NewL(CCreatorEngine* aEngine) + { + CCreatorLogs* self = CCreatorLogs::NewLC(aEngine); + CleanupStack::Pop(self); + return self; + } + +CCreatorLogs* CCreatorLogs::NewLC(CCreatorEngine* aEngine) + { + CCreatorLogs* self = new (ELeave) CCreatorLogs; + CleanupStack::PushL(self); + self->ConstructL(aEngine); + return self; + } + +CCreatorLogs::CCreatorLogs() : CActive(0) + { + iEntriesToBeCreated = 1; + } + +void CCreatorLogs::ConstructL(CCreatorEngine* aEngine) + { + LOGSTRING("Creator: CCreatorLogs::ConstructL"); + + iEngine = aEngine; + + iLogClient = CLogClient::NewL(CEikonEnv::Static()->FsSession()); + iLogEvent = CLogEvent::NewL(); + + CActiveScheduler::Add(this); // needed by CActive + } + +CCreatorLogs::~CCreatorLogs() + { + LOGSTRING("Creator: CCreatorLogs::~CCreatorLogs"); + + Cancel(); //from CActive + + if ( iEngine && iEntryIds.Count() ) + { + TRAP_IGNORE( iEngine->WriteEntryIdsToStoreL( iEntryIds, KUidDictionaryUidLogs ) ); + } + iEntryIds.Reset(); + iEntryIds.Close(); + + delete iLogEvent; + delete iLogClient; + + if (iParameters) + delete iParameters; + } + +//---------------------------------------------------------------------------- + +void CCreatorLogs::QueryDialogClosedL(TBool aPositiveAction, TInt aUserData) + { + LOGSTRING("Creator: CCreatorModuleBase::QueryDialogClosedL"); + + if( aPositiveAction == EFalse ) + { + iEngine->ShutDownEnginesL(); + return; + } + + const TDesC* showText = &KSavingText; + TBool finished(EFalse); + TBool retval(ETrue); + switch(aUserData) + { + case ECreatorLogsDelete: + showText = &KDeletingText; + iEntriesToBeCreated = 1; + finished = ETrue; + break; + case ECreatorLogsStart: + finished = ETrue; + break; + default: + //some error + retval = EFalse; + break; + } + if( retval == EFalse ) + { + iEngine->ShutDownEnginesL(); + } + else if( finished ) + { + // add this command to command array + iEngine->AppendToCommandArrayL(iCommand, NULL, iEntriesToBeCreated); + // started exucuting commands + iEngine->ExecuteFirstCommandL( *showText ); + } + } + +//---------------------------------------------------------------------------- + +TBool CCreatorLogs::AskDataFromUserL(TInt aCommand) + { + LOGSTRING("Creator: CCreatorLogs::AskDataFromUserL"); + + iCommand = aCommand; + + if ( aCommand == ECmdDeleteLogs ) + { + return iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all log entries?"), this, ECreatorLogsDelete ); + } + else if ( aCommand == ECmdDeleteCreatorLogs ) + { + return iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all log entries created with Creator?"), this, ECreatorLogsDelete ); + } + return iEngine->GetEngineWrapper()->EntriesQueryDialog( &iEntriesToBeCreated, _L("How many entries to create?"), EFalse, this, ECreatorLogsStart ); + } + +//---------------------------------------------------------------------------- + +void CCreatorLogs::RunL() + { + LOGSTRING("Creator: CCreatorLogs::RunL"); + + // log writing finished, stop the async waiting + iLogWriteWait.AsyncStop(); + } + +//---------------------------------------------------------------------------- + +void CCreatorLogs::DoCancel() + { + } + +//---------------------------------------------------------------------------- + +TInt CCreatorLogs::CreateMissedCallEntryL(CLogsParameters *aParameters) + { + LOGSTRING("Creator: CCreatorLogs::CreateMissedCallEntryL"); + + // clear any existing parameter definations + delete iParameters; + iParameters = NULL; + + CLogsParameters* parameters = aParameters; + + // random data needed if no predefined data available + if (!parameters) + { + iParameters = new(ELeave) CLogsParameters; + parameters = iParameters; + + /*iParameters->iMissedCallPhoneNumber->Des().Zero(); + iParameters->iMissedCallPhoneNumber->Des().AppendNum( iEngine->RandomNumber(1000000, 9999999) ); + + iParameters->iMissedCallEventTime.UniversalTime(); + iParameters->iMissedCallEventTime -= TTimeIntervalMinutes( iEngine->RandomNumber(12000) );*/ + parameters->iPhoneNumber->Des().Zero(); + parameters->iPhoneNumber->Des().AppendNum( iEngine->RandomNumber(1000000, 9999999) ); + + parameters->iEventTime.UniversalTime(); + parameters->iEventTime -= TTimeIntervalMinutes( iEngine->RandomNumber(12000) ); + + } + + // defaults + iLogEvent->SetId( KLogNullId ); + iLogEvent->SetEventType( KNullUid ); + iLogEvent->SetRemoteParty( KNullDesC ); + iLogEvent->SetDirection( KNullDesC ); + iLogEvent->SetTime( Time::NullTTime() ); + iLogEvent->SetDurationType( KLogNullDurationType ); + iLogEvent->SetDuration( KLogNullDuration ); + iLogEvent->SetStatus( KNullDesC ); + iLogEvent->SetSubject( KNullDesC ); + iLogEvent->SetNumber( KNullDesC ); + iLogEvent->SetContact( KNullContactId ); + iLogEvent->SetLink( KLogNullLink ); + iLogEvent->SetDescription( KNullDesC ); + iLogEvent->SetFlags( KLogNullFlags ); + iLogEvent->SetEventType(KLogCallEventTypeUid); + iLogEvent->SetSubject(_L("A")); + + // set direction + TLogString missed; + iLogClient->GetString(missed, R_LOG_DIR_MISSED); + iLogEvent->SetDirection(missed); + + // set duration + iLogEvent->SetDurationType( KLogDurationNone ); + TLogDuration duration = 0; + iLogEvent->SetDuration(duration); + + // set the phone number + //iLogEvent->SetNumber( iParameters->iMissedCallPhoneNumber->Des() ); + iLogEvent->SetNumber( parameters->iPhoneNumber->Des() ); + + // set event time + //iLogEvent->SetTime( iParameters->iMissedCallEventTime ); + iLogEvent->SetTime( parameters->iEventTime ); + + // start writing + __ASSERT_ALWAYS(!IsActive(), User::Panic(_L("LogWriter"), 150)); + iLogClient->AddEvent(*iLogEvent, iStatus); + SetActive(); + + // wait till adding has finished + iLogWriteWait.Start(); + + // id has been generated, store it for being able to delete + // entries created only with Creator + TRAP_IGNORE( iEntryIds.AppendL( iLogEvent->Id() ) ); + + return iStatus.Int(); // should be KErrNone if writing was succesful + } + +//---------------------------------------------------------------------------- + +TInt CCreatorLogs::CreateReceivedCallEntryL(CLogsParameters *aParameters) + { + LOGSTRING("Creator: CCreatorLogs::CreateReceivedCallEntryL"); + + // clear any existing parameter definations + delete iParameters; + iParameters = NULL; + + CLogsParameters* parameters = aParameters; + + // random data needed if no predefined data available + if (!parameters) + { + iParameters = new(ELeave) CLogsParameters; + parameters = iParameters; + + /*iParameters->iReceivedCallPhoneNumber->Des().Zero(); + iParameters->iReceivedCallPhoneNumber->Des().AppendNum( iEngine->RandomNumber(1000000, 9999999) ); + + iParameters->iReceivedCallEventTime.UniversalTime(); + iParameters->iReceivedCallEventTime -= TTimeIntervalMinutes( iEngine->RandomNumber(12000) ); + + iParameters->iReceivedCallDuration = iEngine->RandomNumber(7200);*/ + parameters->iPhoneNumber->Des().Zero(); + parameters->iPhoneNumber->Des().AppendNum( iEngine->RandomNumber(1000000, 9999999) ); + + parameters->iEventTime.UniversalTime(); + parameters->iEventTime -= TTimeIntervalMinutes( iEngine->RandomNumber(12000) ); + + parameters->iDuration = iEngine->RandomNumber(7200); + } + + // defaults + iLogEvent->SetId( KLogNullId ); + iLogEvent->SetEventType( KNullUid ); + iLogEvent->SetRemoteParty( KNullDesC ); + iLogEvent->SetDirection( KNullDesC ); + iLogEvent->SetTime( Time::NullTTime() ); + iLogEvent->SetDurationType( KLogNullDurationType ); + iLogEvent->SetDuration( KLogNullDuration ); + iLogEvent->SetStatus( KNullDesC ); + iLogEvent->SetSubject( KNullDesC ); + iLogEvent->SetNumber( KNullDesC ); + iLogEvent->SetContact( KNullContactId ); + iLogEvent->SetLink( KLogNullLink ); + iLogEvent->SetDescription( KNullDesC ); + iLogEvent->SetFlags( KLogNullFlags ); + iLogEvent->SetEventType(KLogCallEventTypeUid); + iLogEvent->SetSubject(_L("A")); + + // set direction + TLogString incoming; + iLogClient->GetString(incoming, R_LOG_DIR_IN); + iLogEvent->SetDirection(incoming); + + // set duration + iLogEvent->SetDurationType( KLogDurationValid ); + //iLogEvent->SetDuration( iParameters->iReceivedCallDuration ); + iLogEvent->SetDuration( parameters->iDuration ); + + // set the phone number + //iLogEvent->SetNumber( iParameters->iReceivedCallPhoneNumber->Des() ); + iLogEvent->SetNumber( parameters->iPhoneNumber->Des() ); + + // set event time + //iLogEvent->SetTime( iParameters->iReceivedCallEventTime ); + iLogEvent->SetTime( parameters->iEventTime ); + + // start writing + __ASSERT_ALWAYS(!IsActive(), User::Panic(_L("LogWriter"), 151)); + iLogClient->AddEvent(*iLogEvent, iStatus); + SetActive(); + + // wait till adding has finished + iLogWriteWait.Start(); + + // id has been generated, store it for being able to delete + // entries created only with Creator + TRAP_IGNORE( iEntryIds.AppendL( iLogEvent->Id() ) ); + + return iStatus.Int(); // should be KErrNone if writing was succesful + } + +//---------------------------------------------------------------------------- + + +TInt CCreatorLogs::CreateDialledNumberEntryL(CLogsParameters *aParameters) + { + LOGSTRING("Creator: CCreatorLogs::CreateDialledNumberEntryL"); + + // clear any existing parameter definations + delete iParameters; + iParameters = NULL; + + CLogsParameters* parameters = aParameters; + + // random data needed if no predefined data available + if (!parameters) + { + iParameters = new(ELeave) CLogsParameters; + parameters = iParameters; + + /*iParameters->iDialledNumberPhoneNumber->Des().Zero(); + iParameters->iDialledNumberPhoneNumber->Des().AppendNum( iEngine->RandomNumber(1000000, 9999999) ); + + iParameters->iDialledNumberEventTime.UniversalTime(); + iParameters->iDialledNumberEventTime -= TTimeIntervalMinutes( iEngine->RandomNumber(12000) ); + + iParameters->iDialledNumberDuration = iEngine->RandomNumber(7200);*/ + parameters->iPhoneNumber->Des().Zero(); + parameters->iPhoneNumber->Des().AppendNum( iEngine->RandomNumber(1000000, 9999999) ); + + parameters->iEventTime.UniversalTime(); + parameters->iEventTime -= TTimeIntervalMinutes( iEngine->RandomNumber(12000) ); + + parameters->iDuration = iEngine->RandomNumber(7200); + + } + + // defaults + iLogEvent->SetId( KLogNullId ); + iLogEvent->SetEventType( KNullUid ); + iLogEvent->SetRemoteParty( KNullDesC ); + iLogEvent->SetDirection( KNullDesC ); + iLogEvent->SetTime( Time::NullTTime() ); + iLogEvent->SetDurationType( KLogNullDurationType ); + iLogEvent->SetDuration( KLogNullDuration ); + iLogEvent->SetStatus( KNullDesC ); + iLogEvent->SetSubject( KNullDesC ); + iLogEvent->SetNumber( KNullDesC ); + iLogEvent->SetContact( KNullContactId ); + iLogEvent->SetLink( KLogNullLink ); + iLogEvent->SetDescription( KNullDesC ); + iLogEvent->SetFlags( KLogNullFlags ); + iLogEvent->SetEventType(KLogCallEventTypeUid); + iLogEvent->SetSubject(_L("A")); + + // set direction + TLogString outgoing; + iLogClient->GetString(outgoing, R_LOG_DIR_OUT); + iLogEvent->SetDirection(outgoing); + + // set duration + iLogEvent->SetDurationType( KLogDurationValid ); + //iLogEvent->SetDuration( iParameters->iDialledNumberDuration ); + iLogEvent->SetDuration( parameters->iDuration ); + + // set the phone number + //iLogEvent->SetNumber( iParameters->iDialledNumberPhoneNumber->Des() ); + iLogEvent->SetNumber( parameters->iPhoneNumber->Des() ); + + // set event time + //iLogEvent->SetTime( iParameters->iDialledNumberEventTime ); + iLogEvent->SetTime( parameters->iEventTime ); + + // start writing + __ASSERT_ALWAYS(!IsActive(), User::Panic(_L("LogWriter"), 152)); + iLogClient->AddEvent(*iLogEvent, iStatus); + SetActive(); + + // wait till adding has finished + iLogWriteWait.Start(); + + // id has been generated, store it for being able to delete + // only entries created with Creator + TRAP_IGNORE( iEntryIds.AppendL( iLogEvent->Id() ) ); + + return iStatus.Int(); // should be KErrNone if writing was succesful + } + +//---------------------------------------------------------------------------- +void CCreatorLogs::DeleteAllL() + { + LOGSTRING("Creator: CCreatorLogs::DeleteAllL"); + iLogClient->ClearLog( TTime( Time::MaxTTime() ), iStatus ); + SetActive(); + + // wait till delete has finished + iLogWriteWait.Start(); + User::LeaveIfError( iStatus.Int() ); + + // reset must be done here, because iEntryIds is stored in destructor + iEntryIds.Reset(); + + // all entries deleted, remove the Logs related registry + iEngine->RemoveStoreL( KUidDictionaryUidLogs ); + } + +//---------------------------------------------------------------------------- +void CCreatorLogs::DeleteAllCreatedByCreatorL() + { + LOGSTRING("Creator: CCreatorLogs::DeleteAllCreatedByCreatorL"); + iEntryIds.Reset(); + + // fetch ids of entries created by Creator + iEngine->ReadEntryIdsFromStoreL( iEntryIds, KUidDictionaryUidLogs ); + + // delete entries + for ( TInt i = 0; i < iEntryIds.Count(); i++ ) + { + // This could be implemented with while loop + // with additional cancel flag. That would enable + // using CancelOp() and cancelling would be bit smoother. + // With this for loop implementation all entries will be + // deleted whether or not user cancels during logs operation. + + iLogClient->DeleteEvent( iEntryIds[i], iStatus ); + SetActive(); + // wait till delete has finished + iLogWriteWait.Start(); + } + + // reset must be done here, because iEntryIds is stored in destructor + iEntryIds.Reset(); + + // all entries deleted, remove the Logs related registry + iEngine->RemoveStoreL( KUidDictionaryUidLogs ); + } diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/src/creator_logelement.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/src/creator_logelement.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,171 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +#include "creator_logelement.h" +#include "creator_traces.h" +#include "creator_log.h" + +using namespace creatorlog; + +/* + * + */ +CCreatorLogElement* CCreatorLogElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext ) + { + CCreatorLogElement* self = new (ELeave) CCreatorLogElement(aEngine); + CleanupStack::PushL(self); + self->ConstructL(aName, aContext); + CleanupStack::Pop(self); + return self; + } +/* + * + */ +CCreatorLogElement::CCreatorLogElement(CCreatorEngine* aEngine) +: +CCreatorScriptElement(aEngine) + { + iIsCommandElement = ETrue; + } +/* + * + */ +void CCreatorLogElement::ExecuteCommandL() + { + const CCreatorScriptAttribute* amountAttr = FindAttributeByName(KAmount); + TInt logAmount = 1; + if( amountAttr ) + { + logAmount = ConvertStrToIntL(amountAttr->Value()); + } + // Get 'fields' element + CCreatorScriptElement* fieldsElement = FindSubElement(KFields); + if( fieldsElement && fieldsElement->SubElements().Count() > 0 ) + { + // Get sub-elements + const RPointerArray& fields = fieldsElement->SubElements(); + // Create log entries, the amount of entries is defined by logAmount: + for( TInt cI = 0; cI < logAmount; ++cI ) + { + TInt direction = -1; + CLogsParameters* param = new (ELeave) CLogsParameters; + CleanupStack::PushL(param); + + for( TInt i = 0; i < fields.Count(); ++i ) + { + CCreatorScriptElement* field = fields[i]; + TPtrC elemName = field->Name(); + TPtrC elemContent = field->Content(); + const CCreatorScriptAttribute* randomAttr = field->FindAttributeByName(KRandomLength); + const CCreatorScriptAttribute* increaseAttr = field->FindAttributeByName(KIncrease); + TBool increase( EFalse ); + if ( increaseAttr ) + { + increase = ConvertStrToBooleanL( increaseAttr->Value() ); + } + + if( elemName == KDirection ) + { + direction = GetLogCommandL(elemContent, randomAttr || elemContent.Length() == 0); + } + else if( elemName == KDuration ) + { + if( randomAttr || elemContent.Length() == 0 ) + { + param->iDuration = iEngine->RandomNumber(7200); + } + else + { + param->iDuration = ConvertStrToIntL(elemContent); + } + } + else if( elemName == KPhonenumber ) + { + if( randomAttr || elemContent.Length() == 0 ) + { + SetContentToTextParamL(param->iPhoneNumber, iEngine->RandomString(CCreatorEngine::EPhoneNumber)); + } + else + { + if ( increase ) + { + delete param->iPhoneNumber; + param->iPhoneNumber = NULL; + param->iPhoneNumber = HBufC::NewL( elemContent.Length() + 3 ); + IncreasePhoneNumL( elemContent, cI, param->iPhoneNumber ); + } + else + { + SetContentToTextParamL(param->iPhoneNumber, elemContent); + } + } + } + else if( elemName == KDatetime ) + { + if( randomAttr || elemContent.Length() == 0 ) + { + param->iEventTime = iEngine->RandomTime(iEngine->RandomDate(CCreatorEngine::EDatePast), CCreatorEngine::EDatePast); + } + else + { + param->iEventTime = ConvertToDateTimeL(elemContent); + } + } + } + + if( direction == -1 ) + { + direction = GetLogCommandL(KEmpty, ETrue); + } + iEngine->AppendToCommandArrayL(direction, param); + CleanupStack::Pop(); // param + } + } + else + { + for(TInt i = 0; i < logAmount; ++i ) + { + iEngine->AppendToCommandArrayL(GetLogCommandL(KEmpty, ETrue), 0, 1); + } + } + } + +TInt CCreatorLogElement::GetLogCommandL( const TDesC& aLogCmdStr, TBool aRandom ) const + { + if( aRandom ) + { + TInt commandArray[] = { + ECmdCreateLogEntryMissedCalls, + ECmdCreateLogEntryReceivedCalls, + ECmdCreateLogEntryDialledNumbers + }; + return commandArray[iEngine->RandomNumber(0, 2)]; + } + + if( CompareIgnoreCase(aLogCmdStr, KMissed) == 0 ) + return ECmdCreateLogEntryMissedCalls; + else if( CompareIgnoreCase(aLogCmdStr, KIn) == 0 ) + return ECmdCreateLogEntryReceivedCalls; + else if( CompareIgnoreCase(aLogCmdStr, KOut) == 0 ) + return ECmdCreateLogEntryDialledNumbers; + + LOGSTRING2("CCreatorLogElement::GetLogCommandL: Unknown log direction: %S", &aLogCmdStr); + User::Leave(KErrNotFound); + return -1; // Not reached, but disables compiler warning... + } diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/src/creator_mailbox.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/src/creator_mailbox.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,797 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include +#include + +#include "engine.h" +#include "enginewrapper.h" +#include "creator_mailbox.h" +#include "creator_traces.h" + +static const TInt KMailboxesFieldLength = 160; + +_LIT(KCreatorMailboxesPrefixName, "CR_"); + +_LIT(KDefaultIncomingServer, "mail.example.com"); +_LIT(KDefaultOutgoingServer, "smtp.example.com"); +_LIT(KInternet, "internet"); + + +//---------------------------------------------------------------------------- + +CMailboxesParameters::CMailboxesParameters() + { + LOGSTRING("Creator: CMailboxesParameters::CMailboxesParameters"); + + iIncomingPort = KUndef; + iOutgoingPort = KUndef; + iMaxEmailSize = KUndef; + iSyncRate = KUndef; + iAttachmentFetchSize = KUndef; + iAttachmentSizeLimit = KUndef; + iBodyTextSizeLimit = KUndef; + iAttachmentFetchSize = KUndef; + iInboxSyncLimit = -1; // -1 = All + iMailboxSyncLimit = -1; // -1 = All + iToCCIncludeLimit = KUndef; + iImapIdleTimeout = KUndef; + + /*iMailboxName = HBufC::New(KMailboxesFieldLength); + iAccessPoint = HBufC::New(KMailboxesFieldLength); + iMyMailAddress = HBufC::New(KMailboxesFieldLength); + iOutgoingMailServer = HBufC::New(KMailboxesFieldLength); + iUserName = HBufC::New(KMailboxesFieldLength); + iPassword = HBufC::New(KMailboxesFieldLength); + iIncomingMailServer = HBufC::New(KMailboxesFieldLength);*/ + } + +CMailboxesParameters::~CMailboxesParameters() + { + LOGSTRING("Creator: CMailboxesParameters::~CMailboxesParameters"); + + /*delete iIncomingMailServer; + delete iPassword; + delete iUserName; + delete iOutgoingMailServer; + delete iMyMailAddress; + delete iAccessPoint; + delete iMailboxName;*/ + + delete iMailboxName; + delete iIncomingLoginName; + delete iIncomingPassword; + delete iIncomingServerName; + delete iIncomingConnectionMethod; + delete iIncomingFolderPath; + delete iPathSeparator; + delete iOutgoingLoginName; + delete iOutgoingPassword; + delete iOutgoingServerName; + delete iOutgoingConnectionMethod; + delete iOwnEmailAddress; + delete iOwnEmailAlias; + delete iReceiptAddress; + delete iReplyToAddress; + } + +//---------------------------------------------------------------------------- + +CCreatorMailboxes* CCreatorMailboxes::NewL(CCreatorEngine* aEngine) + { + CCreatorMailboxes* self = CCreatorMailboxes::NewLC(aEngine); + CleanupStack::Pop(self); + return self; + } + +CCreatorMailboxes* CCreatorMailboxes::NewLC(CCreatorEngine* aEngine) + { + CCreatorMailboxes* self = new (ELeave) CCreatorMailboxes; + CleanupStack::PushL(self); + self->ConstructL(aEngine); + return self; + } + +CCreatorMailboxes::CCreatorMailboxes() + { + } + +void CCreatorMailboxes::ConstructL(CCreatorEngine* aEngine) + { + LOGSTRING("Creator: CCreatorMailboxes::ConstructL"); + + iEngine = aEngine; + } + +CCreatorMailboxes::~CCreatorMailboxes() + { + LOGSTRING("Creator: CCreatorMailboxes::~CCreatorMailboxes"); + if ( iEngine && iEntryIds.Count() ) + { + TRAP_IGNORE( iEngine->WriteEntryIdsToStoreL( iEntryIds, KUidDictionaryUidMailbox ) ); + } + iEntryIds.Reset(); + iEntryIds.Close(); + + if (iParameters) + delete iParameters; + } + +//---------------------------------------------------------------------------- + +TBool CCreatorMailboxes::AskDataFromUserL(TInt aCommand) + { + LOGSTRING("Creator: CCreatorMailboxes::AskDataFromUserL"); + + CCreatorModuleBase::AskDataFromUserL( aCommand );//ignore retval + + if ( aCommand == ECmdDeleteMailboxes ) + { + return iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all mailboxes?"), this, ECreatorModuleDelete ); + } + else if ( aCommand == ECmdDeleteCreatorMailboxes ) + { + return iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all mailboxes created with Creator?"), this, ECreatorModuleDelete ); + } + return iEngine->GetEngineWrapper()->EntriesQueryDialog( &iEntriesToBeCreated, _L("How many entries to create?"), EFalse, this, ECreatorModuleStart ); + } + + +//---------------------------------------------------------------------------- + +TInt CCreatorMailboxes::CreateMailboxEntryL(CMailboxesParameters *aParameters) + { + LOGSTRING("Creator: CCreatorMailboxes::CreateMailboxEntryL"); + + // clear any existing parameter definations + delete iParameters; + iParameters = NULL; + + CMailboxesParameters* parameters = aParameters; + + // random data needed if no predefined data available + if (!parameters) + { + iParameters = new(ELeave) CMailboxesParameters; + parameters = iParameters; + + TPtrC company(iEngine->RandomString(CCreatorEngine::ECompany)); + TPtrC firstName(iEngine->RandomString(CCreatorEngine::EFirstName)); + + delete parameters->iMailboxName; + parameters->iMailboxName = 0; + parameters->iMailboxName = HBufC::NewL(KMailboxesFieldLength); + parameters->iMailboxName->Des() = KCreatorMailboxesPrefixName; + parameters->iMailboxName->Des().Append( company ); + parameters->iMailboxName->Des().Append(_L(" #")); + parameters->iMailboxName->Des().AppendNum(iEngine->RandomNumber(1, 100)); + + delete parameters->iIncomingLoginName; + parameters->iIncomingLoginName = 0; + parameters->iIncomingLoginName = HBufC::NewL(KMailboxesFieldLength); + delete parameters->iOutgoingLoginName; + parameters->iOutgoingLoginName = 0; + parameters->iOutgoingLoginName = HBufC::NewL(KMailboxesFieldLength); + parameters->iIncomingLoginName->Des() = iEngine->RandomString(CCreatorEngine::EFirstName); + parameters->iIncomingLoginName->Des().LowerCase(); + parameters->iOutgoingLoginName->Des().Copy(parameters->iIncomingLoginName->Des()); + + delete parameters->iIncomingPassword; + parameters->iIncomingPassword = 0; + parameters->iIncomingPassword = HBufC::NewL(KMailboxesFieldLength); + delete parameters->iOutgoingPassword; + parameters->iOutgoingPassword = 0; + parameters->iOutgoingPassword = HBufC::NewL(KMailboxesFieldLength); + parameters->iIncomingPassword->Des() = iEngine->RandomString(CCreatorEngine::ESurname); + parameters->iIncomingPassword->Des().LowerCase(); + parameters->iOutgoingPassword->Des().Copy(parameters->iIncomingPassword->Des()); + + delete parameters->iIncomingServerName; + parameters->iIncomingServerName = 0; + parameters->iIncomingServerName = HBufC::NewL(KMailboxesFieldLength); + parameters->iIncomingServerName->Des() = _L("incoming."); + parameters->iIncomingServerName->Des().Append(company); + parameters->iIncomingServerName->Des().Append(_L(".com")); + parameters->iIncomingServerName->Des().LowerCase(); + + delete parameters->iIncomingConnectionMethod; + parameters->iIncomingConnectionMethod = 0; + parameters->iIncomingConnectionMethod = HBufC::NewL(KInternet().Length()); + parameters->iIncomingConnectionMethod->Des() = KInternet; // use always this one, if it's not found, default will be used instead + + delete parameters->iOutgoingServerName; + parameters->iOutgoingServerName = 0; + parameters->iOutgoingServerName = HBufC::NewL(KMailboxesFieldLength); + parameters->iOutgoingServerName->Des() = _L("smtp."); + parameters->iOutgoingServerName->Des().Append(company); + parameters->iOutgoingServerName->Des().Append(_L(".com")); + parameters->iOutgoingServerName->Des().LowerCase(); + + delete parameters->iOutgoingConnectionMethod; + parameters->iOutgoingConnectionMethod = 0; + parameters->iOutgoingConnectionMethod = HBufC::NewL(KInternet().Length()); + parameters->iOutgoingConnectionMethod->Des() = KInternet; // use always this one, if it's not found, default will be used instead + + delete parameters->iOwnEmailAddress; + parameters->iOwnEmailAddress = 0; + parameters->iOwnEmailAddress = iEngine->CreateEmailAddressLC(); + parameters->iOwnEmailAddress->Des().LowerCase(); + CleanupStack::Pop(); // parameters->iOwnEmailAddress + + delete parameters->iOwnEmailAlias; + parameters->iOwnEmailAlias = 0; + parameters->iOwnEmailAlias = HBufC::NewL(firstName.Length()); + parameters->iOwnEmailAlias->Des().Copy(firstName); + + delete parameters->iReceiptAddress; + parameters->iReceiptAddress = 0; + parameters->iReceiptAddress = iEngine->CreateEmailAddressLC(); + parameters->iReceiptAddress->Des().LowerCase(); + CleanupStack::Pop(); // parameters->iReceiptAddress + + delete parameters->iReplyToAddress; + parameters->iReplyToAddress = 0; + parameters->iReplyToAddress = iEngine->CreateEmailAddressLC(); + parameters->iReplyToAddress->Des().LowerCase(); + CleanupStack::Pop(); // parameters->iReplyToAddress + + parameters->iIncomingSSLWrapper = iEngine->RandomNumber(0, 1); + parameters->iIncomingSecureSockets = iEngine->RandomNumber(0, 1); + parameters->iAcknowledgeReceipts = iEngine->RandomNumber(0, 1); + parameters->iAutoSendOnConnect = iEngine->RandomNumber(0, 1); + parameters->iDeleteEmailsAtDisconnect = iEngine->RandomNumber(0, 1); + parameters->iImapIdleCommand = iEngine->RandomNumber(0, 1); + parameters->iMarkSeenInSync = iEngine->RandomNumber(0, 1); + parameters->iEnableExpungeMode = iEngine->RandomNumber(0, 1); + parameters->iUseApop = iEngine->RandomNumber(0, 1); + parameters->iDisconnectedUserMode = iEngine->RandomNumber(0, 1); + parameters->iOutgoingSSLWrapper = iEngine->RandomNumber(0, 1); + parameters->iOutgoingSecureSockets = iEngine->RandomNumber(0, 1); + parameters->iIncludeSignature = EFalse; + parameters->iAddVCard = EFalse; + parameters->iRequestReceipts = iEngine->RandomNumber(0, 1); + parameters->iSmtpAuth = iEngine->RandomNumber(0, 1); + + parameters->iIncomingPort = iEngine->RandomNumber(25, 500); + parameters->iAttachmentSizeLimit = iEngine->RandomNumber(1, KMaxTInt); + parameters->iBodyTextSizeLimit = iEngine->RandomNumber(1, KMaxTInt); + parameters->iAttachmentFetchSize = iEngine->RandomNumber(1, 40960); + parameters->iImapIdleTimeout = iEngine->RandomNumber(10, 2000); + parameters->iMaxEmailSize = iEngine->RandomNumber(1024, KMaxTInt); + parameters->iSyncRate = iEngine->RandomNumber(10, 500); + parameters->iInboxSyncLimit = iEngine->RandomNumber(-1, 256); + parameters->iMailboxSyncLimit = iEngine->RandomNumber(-1, 256); + parameters->iOutgoingPort = KDefaultSmtpPort; + parameters->iToCCIncludeLimit = iEngine->RandomNumber(0, 30); + + parameters->iGetEmailOptions = (CMailboxesParameters::TGetEmailOption) iEngine->RandomNumber(CMailboxesParameters::EUndef, CMailboxesParameters::EGetEmailOptionLast-1); + parameters->iSubscribeType = (TFolderSubscribeType) iEngine->RandomNumber(EUpdateNeither, EUpdateBoth); + parameters->iSyncType = (TFolderSyncType) iEngine->RandomNumber(EUseCombination, EUseRemote); + parameters->iSendCopyToSelf = (TImSMTPSendCopyToSelf) iEngine->RandomNumber(ESendNoCopy, ESendCopyAsBccRecipient); + parameters->iSendOption = (TImSMTPSendMessageOption) iEngine->RandomNumber(ESendMessageImmediately, ESendMessageOnRequest); + parameters->iMailboxType = (TMailboxType) iEngine->RandomNumber(EMailboxPOP3, EMailboxIMAP4); + } + + TInt err = KErrNone; + + // make sure we have some IMEI stored + if (iIMEI.Length() == 0) + { + TRAP(err, GetIMEIFromThePhoneL()); + } + + // init + CImImap4Settings* imap4Set = new(ELeave) CImImap4Settings; + CleanupStack::PushL(imap4Set); + CImPop3Settings* pop3Set = new(ELeave) CImPop3Settings; + CleanupStack::PushL(pop3Set); + CImSmtpSettings* smtpSet = new(ELeave) CImSmtpSettings; + CleanupStack::PushL(smtpSet); + CImIAPPreferences* outgoingIAPSet = CImIAPPreferences::NewLC(); + CImIAPPreferences* incomingIAPSet = CImIAPPreferences::NewLC(); + CEmailAccounts* account = CEmailAccounts::NewLC(); + + // Get SMTP settings: + PopulateSmtpSettingsL(*account, *smtpSet, *outgoingIAPSet, *parameters); + + // appending mailbox type to array to be able to use + // correct type when deleting mailboxes + iEntryIds.AppendL( parameters->iMailboxType ); + + if (parameters->iMailboxType == EMailboxIMAP4) + { + // Get IMAP settings: + PopulateImapSettingsL(*account, *imap4Set, *incomingIAPSet, *parameters); + TImapAccount imapAccountId = account->CreateImapAccountL(parameters->iMailboxName->Des(), *imap4Set, *incomingIAPSet, EFalse); + TSmtpAccount smtpAccountId = account->CreateSmtpAccountL(imapAccountId, *smtpSet, *outgoingIAPSet, EFalse); + account->SetDefaultSmtpAccountL(smtpAccountId); + + iEntryIds.AppendL( imapAccountId.iImapAccountId ); + iEntryIds.AppendL( imapAccountId.iImapService ); + iEntryIds.AppendL( imapAccountId.iSmtpService ); + iEntryIds.AppendL( smtpAccountId.iSmtpAccountId ); + iEntryIds.AppendL( smtpAccountId.iSmtpService ); + iEntryIds.AppendL( smtpAccountId.iRelatedService ); + + StoreIMEIToEntryL( imapAccountId.iImapService ); + StoreIMEIToEntryL( smtpAccountId.iSmtpService ); + } + else + { + // Get POP settings: + PopulatePopSettingsL(*account, *pop3Set, *incomingIAPSet, *parameters); + TPopAccount popAccountId = account->CreatePopAccountL(parameters->iMailboxName->Des(), *pop3Set, *incomingIAPSet, EFalse); + TSmtpAccount smtpAccountId = account->CreateSmtpAccountL(popAccountId, *smtpSet, *outgoingIAPSet, EFalse); + account->SetDefaultSmtpAccountL(smtpAccountId); + + iEntryIds.AppendL( popAccountId.iPopAccountId ); + iEntryIds.AppendL( popAccountId.iPopService ); + iEntryIds.AppendL( popAccountId.iSmtpService ); + iEntryIds.AppendL( smtpAccountId.iSmtpAccountId ); + iEntryIds.AppendL( smtpAccountId.iSmtpService ); + iEntryIds.AppendL( smtpAccountId.iRelatedService ); + + StoreIMEIToEntryL( popAccountId.iPopService ); + StoreIMEIToEntryL( smtpAccountId.iSmtpService ); + } + CleanupStack::PopAndDestroy(6); //imap4Set, pop3Set, smtpSet, outgoingIAPSet, incomingIAPSet, account + + return err; + } + +void CCreatorMailboxes::PopulateImapSettingsL( + CEmailAccounts& aEmailAccount, + CImImap4Settings& aImapSettings, + CImIAPPreferences& aIApSettings, + const CMailboxesParameters& aParameters ) + { + // Get default settings first: + aEmailAccount.PopulateDefaultImapSettingsL(aImapSettings, aIApSettings); + + TImIAPChoice iapChoice; + iapChoice.iIAP = 0; + if( aParameters.iIncomingConnectionMethod == 0 || + aParameters.iIncomingConnectionMethod->Des().Length() == 0 ) + { + TRAP_IGNORE( iapChoice.iIAP = iEngine->AccessPointNameToIdL( KInternet )); + } + else + { + TRAP_IGNORE( iapChoice.iIAP = iEngine->AccessPointNameToIdL( aParameters.iIncomingConnectionMethod->Des())); + } + iapChoice.iDialogPref = ECommDbDialogPrefDoNotPrompt; + aIApSettings.AddIAPL(iapChoice); + + TBuf8<256> buf8; + if( aParameters.iIncomingLoginName && aParameters.iIncomingLoginName->Length() > 0 ) + buf8.Copy(aParameters.iIncomingLoginName->Des()); + else + buf8.Copy(iEngine->RandomString(CCreatorEngine::EFirstName)); + aImapSettings.SetLoginNameL(buf8); //8 + + if( aParameters.iIncomingPassword && aParameters.iIncomingPassword->Length() > 0 ) + buf8.Copy(aParameters.iIncomingPassword->Des()); + else + buf8.Copy(iEngine->RandomString(CCreatorEngine::EFirstName)); + aImapSettings.SetPasswordL(buf8); //8 + + if( aParameters.iIncomingFolderPath && aParameters.iIncomingFolderPath->Length() > 0 ) + { + buf8.Copy(aParameters.iIncomingFolderPath->Des()); + aImapSettings.SetFolderPathL(buf8); + } + + if( aParameters.iPathSeparator && aParameters.iPathSeparator->Length() > 0 ) + aImapSettings.SetPathSeparator(aParameters.iIncomingFolderPath->Des()[0]); + + aImapSettings.SetDisconnectedUserMode(aParameters.iDisconnectedUserMode); + aImapSettings.SetSynchronise(aParameters.iSyncType); + aImapSettings.SetSubscribe(aParameters.iSubscribeType); + aImapSettings.SetAutoSendOnConnect(aParameters.iAutoSendOnConnect); + + if(aParameters.iMaxEmailSize != KUndef ) + aImapSettings.SetMaxEmailSize(aParameters.iMaxEmailSize); + + aImapSettings.SetDeleteEmailsWhenDisconnecting(aParameters.iDeleteEmailsAtDisconnect); + aImapSettings.SetAcknowledgeReceipts(aParameters.iAcknowledgeReceipts); + + if(aParameters.iGetEmailOptions == CMailboxesParameters::EGetBodyText ) + aImapSettings.SetGetMailOptions(EGetImap4EmailBodyText); + else if(aParameters.iGetEmailOptions == CMailboxesParameters::EGetBodyTextAndAttachments ) + aImapSettings.SetGetMailOptions(EGetImap4EmailBodyTextAndAttachments); + else if(aParameters.iGetEmailOptions == CMailboxesParameters::EGetAttachments ) + aImapSettings.SetGetMailOptions(EGetImap4EmailAttachments); + else if(aParameters.iGetEmailOptions == CMailboxesParameters::EGetBodyAlternativeText ) + aImapSettings.SetGetMailOptions(EGetImap4EmailBodyAlternativeText); + else + aImapSettings.SetGetMailOptions(EGetImap4EmailHeaders); // Default + + if( aParameters.iInboxSyncLimit != KUndef ) + aImapSettings.SetInboxSynchronisationLimit(aParameters.iInboxSyncLimit); + + if( aParameters.iMailboxSyncLimit != KUndef ) + aImapSettings.SetMailboxSynchronisationLimit(aParameters.iMailboxSyncLimit); + + aImapSettings.SetUpdatingSeenFlags(aParameters.iMarkSeenInSync); + + if( aParameters.iSyncRate != KUndef ) + aImapSettings.SetSyncRateL(aParameters.iSyncRate); + + if( aParameters.iAttachmentFetchSize != KUndef ) + aImapSettings.SetFetchSizeL(aParameters.iAttachmentFetchSize); + + aImapSettings.SetImapIdle(aParameters.iImapIdleCommand); + if( aParameters.iImapIdleTimeout != KUndef ) + aImapSettings.SetImapIdleTimeoutL(aParameters.iImapIdleTimeout); + + if( aParameters.iBodyTextSizeLimit != KUndef ) + aImapSettings.SetBodyTextSizeLimitL(aParameters.iBodyTextSizeLimit); + + if( aParameters.iAttachmentSizeLimit != KUndef ) + aImapSettings.SetAttachmentSizeLimitL(aParameters.iAttachmentSizeLimit); + +#if(!defined __SERIES60_30__ && !defined __SERIES60_31__) + aImapSettings.SetUseExpunge(aParameters.iEnableExpungeMode); +#endif + + if(aParameters.iIncomingServerName && aParameters.iIncomingServerName->Length() > 0 ) + aImapSettings.SetServerAddressL(aParameters.iIncomingServerName->Des()); + else + aImapSettings.SetServerAddressL(KDefaultIncomingServer); + + if( aParameters.iIncomingPort != KUndef ) + aImapSettings.SetPort(aParameters.iIncomingPort); + + aImapSettings.SetSecureSockets(aParameters.iIncomingSecureSockets); + aImapSettings.SetSSLWrapper(aParameters.iIncomingSSLWrapper); + } + +void CCreatorMailboxes::PopulatePopSettingsL( + CEmailAccounts& aEmailAccount, + CImPop3Settings& aPopSettings, + CImIAPPreferences& aIApSettings, + const CMailboxesParameters& aParameters ) + { + aEmailAccount.PopulateDefaultPopSettingsL(aPopSettings, aIApSettings); + + TImIAPChoice iapChoice; + iapChoice.iIAP = 0; + if( aParameters.iIncomingConnectionMethod == 0 || + aParameters.iIncomingConnectionMethod->Des().Length() == 0 ) + { + TRAP_IGNORE( iapChoice.iIAP = iEngine->AccessPointNameToIdL( KInternet )); + } + else + { + TRAP_IGNORE( iapChoice.iIAP = iEngine->AccessPointNameToIdL( aParameters.iIncomingConnectionMethod->Des() )); + } + iapChoice.iDialogPref = ECommDbDialogPrefDoNotPrompt; + aIApSettings.AddIAPL(iapChoice); + + TBuf8<256> buf8; + if( aParameters.iIncomingLoginName && aParameters.iIncomingLoginName->Length() > 0 ) + buf8.Copy(aParameters.iIncomingLoginName->Des()); + else + buf8.Copy(iEngine->RandomString(CCreatorEngine::EFirstName)); + aPopSettings.SetLoginNameL(buf8); //8 + + if( aParameters.iIncomingPassword && aParameters.iIncomingPassword->Length() > 0 ) + buf8.Copy(aParameters.iIncomingPassword->Des()); + else + buf8.Copy(iEngine->RandomString(CCreatorEngine::EFirstName)); + aPopSettings.SetPasswordL(buf8); //8 + + aPopSettings.SetAutoSendOnConnect( aParameters.iAutoSendOnConnect ); + aPopSettings.SetApop( aParameters.iUseApop ); + aPopSettings.SetDisconnectedUserMode( aParameters.iDisconnectedUserMode ); + aPopSettings.SetDeleteEmailsWhenDisconnecting( aParameters.iDeleteEmailsAtDisconnect ); + aPopSettings.SetAcknowledgeReceipts( aParameters.iAcknowledgeReceipts ); + + if( aParameters.iMaxEmailSize != KUndef ) + aPopSettings.SetMaxEmailSize(aParameters.iMaxEmailSize); + + if(aParameters.iGetEmailOptions != CMailboxesParameters::EGetHeaders && + aParameters.iGetEmailOptions != CMailboxesParameters::EUndef ) + { + aPopSettings.SetGetMailOptions(EGetPop3EmailMessages); + aPopSettings.SetPopulationLimitL( -1 ); // -1 = body and attachment + } + else + { + aPopSettings.SetGetMailOptions(EGetPop3EmailHeaders); // Default + aPopSettings.SetPopulationLimitL( -2 ); // -2 = headers only + } + + if( aParameters.iInboxSyncLimit != KUndef ) + { + aPopSettings.SetInboxSynchronisationLimit(aParameters.iInboxSyncLimit); + } + + if(aParameters.iIncomingServerName && aParameters.iIncomingServerName->Length() > 0 ) + aPopSettings.SetServerAddressL(aParameters.iIncomingServerName->Des()); + else + aPopSettings.SetServerAddressL(KDefaultIncomingServer); + + if( aParameters.iIncomingPort != KUndef ) + aPopSettings.SetPort(aParameters.iIncomingPort); + + aPopSettings.SetSecureSockets(aParameters.iIncomingSecureSockets); + aPopSettings.SetSSLWrapper(aParameters.iIncomingSSLWrapper); + } + +void CCreatorMailboxes::PopulateSmtpSettingsL( + CEmailAccounts& aEmailAccount, + CImSmtpSettings& aSmtpSettings, + CImIAPPreferences& aIApSettings, + const CMailboxesParameters& aParameters ) + { + // Get default settings first: + aEmailAccount.PopulateDefaultSmtpSettingsL(aSmtpSettings, aIApSettings); + TImIAPChoice iapChoice; + iapChoice.iIAP = 0; + if( aParameters.iOutgoingConnectionMethod == 0 || + aParameters.iOutgoingConnectionMethod->Des().Length() == 0 ) + { + TRAP_IGNORE( iapChoice.iIAP = iEngine->AccessPointNameToIdL( KInternet )); + } + else + { + TRAP_IGNORE( iapChoice.iIAP = iEngine->AccessPointNameToIdL( aParameters.iOutgoingConnectionMethod->Des() )); + } + iapChoice.iDialogPref = ECommDbDialogPrefDoNotPrompt; + aIApSettings.AddIAPL(iapChoice); + + // set SMTP preferences + if( aParameters.iOwnEmailAlias && aParameters.iOwnEmailAlias->Length() > 0 ) + aSmtpSettings.SetEmailAliasL(aParameters.iOwnEmailAlias->Des()); + + if( aParameters.iOwnEmailAddress && aParameters.iOwnEmailAddress->Length() > 0 ) + aSmtpSettings.SetEmailAddressL(aParameters.iOwnEmailAddress->Des()); + + if( aParameters.iReplyToAddress && aParameters.iReplyToAddress->Length() > 0 ) + aSmtpSettings.SetReplyToAddressL(aParameters.iReplyToAddress->Des()); + + if( aParameters.iReceiptAddress && aParameters.iReceiptAddress->Length() > 0 ) + aSmtpSettings.SetReceiptAddressL(aParameters.iReceiptAddress->Des()); + + aSmtpSettings.SetBodyEncoding(EMsgOutboxMIME); + aSmtpSettings.SetAddVCardToEmail(aParameters.iAddVCard); + aSmtpSettings.SetAddSignatureToEmail(aParameters.iIncludeSignature); + aSmtpSettings.SetRequestReceipts(aParameters.iRequestReceipts); + aSmtpSettings.SetSendCopyToSelf(aParameters.iSendCopyToSelf); + aSmtpSettings.SetSendMessageOption(aParameters.iSendOption); + + TBuf8<256> buf8; + if( aParameters.iOutgoingLoginName && aParameters.iOutgoingLoginName->Length() > 0 ) + { + buf8.Copy(aParameters.iOutgoingLoginName->Des()); + aSmtpSettings.SetLoginNameL(buf8); //8 + } + + if( aParameters.iOutgoingPassword && aParameters.iOutgoingPassword->Length() > 0) + { + buf8.Copy(aParameters.iOutgoingPassword->Des()); + aSmtpSettings.SetPasswordL(buf8); //8 + } + + aSmtpSettings.SetSMTPAuth(aParameters.iSmtpAuth); + if( aParameters.iToCCIncludeLimit != KUndef ) + aSmtpSettings.SetToCcIncludeLimitL(aParameters.iToCCIncludeLimit); + + if( aParameters.iOutgoingServerName && aParameters.iOutgoingServerName->Length() > 0 ) + aSmtpSettings.SetServerAddressL(aParameters.iOutgoingServerName->Des()); + else + aSmtpSettings.SetServerAddressL(KDefaultOutgoingServer); + + if( aParameters.iOutgoingPort != KUndef ) + aSmtpSettings.SetPort(aParameters.iOutgoingPort); + + aSmtpSettings.SetSecureSockets(aParameters.iOutgoingSecureSockets); + aSmtpSettings.SetSSLWrapper(aParameters.iOutgoingSSLWrapper); + } + +//---------------------------------------------------------------------------- + +void CCreatorMailboxes::StoreIMEIToEntryL(const TMsvId aMailboxId) + { + LOGSTRING("Creator: CCreatorMailboxes::StoreIMEIToEntryL"); + + CMsvSession* session = CMsvSession::OpenSyncL(*this); + CleanupStack::PushL(session); + + CMsvEntry* centry = session->GetEntryL(aMailboxId); + CleanupStack::PushL(centry); + + TMsvEntry tentry = centry->Entry(); + tentry.iDescription.Set(iIMEI); + centry->ChangeL(tentry); + + CleanupStack::PopAndDestroy(2); // centry, session + } + +//---------------------------------------------------------------------------- + +void CCreatorMailboxes::GetIMEIFromThePhoneL() + { + LOGSTRING("Creator: CCreatorMailboxes::GetIMEIFromThePhoneL"); + +#ifndef __WINS__ + + RTelServer telServer; + User::LeaveIfError( telServer.Connect() ); + CleanupClosePushL(telServer); + + TInt numPhones = 0; + User::LeaveIfError( telServer.EnumeratePhones( numPhones ) ); + if ( numPhones < 1 ) + { + User::Leave( KErrNotFound ); + } + RTelServer::TPhoneInfo info; + User::LeaveIfError( telServer.GetPhoneInfo( 0, info ) ); + RMobilePhone mobilePhone; + User::LeaveIfError( mobilePhone.Open( telServer, info.iName ) ); + CleanupClosePushL( mobilePhone ); + + //mobilePhone.Initialise(); + TUint32 identityCaps; + User::LeaveIfError( mobilePhone.GetIdentityCaps( identityCaps ) ); + + if ( identityCaps & RMobilePhone::KCapsGetSerialNumber ) + { + TRequestStatus status; + RMobilePhone::TMobilePhoneIdentityV1 mobilePhoneIdentity; + + mobilePhone.GetPhoneId( status, mobilePhoneIdentity ); + + User::WaitForRequest( status ); + User::LeaveIfError( status.Int() ); + + iIMEI.Copy( mobilePhoneIdentity.iSerialNumber ); + } + else + { + User::Leave( KErrNotSupported ); + } + + CleanupStack::PopAndDestroy( &mobilePhone ); + CleanupStack::PopAndDestroy( &telServer ); + +#else + + // use fixed IMEI for emulator + _LIT( KIMAEmulatorImei, "123456789012345" ); + iIMEI.Copy( KIMAEmulatorImei ); + +#endif // __WINS__ + + } + +//---------------------------------------------------------------------------- + +void CCreatorMailboxes::HandleSessionEventL(TMsvSessionEvent /*aEvent*/, TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/) // from MMsvSessionObserver + { + } + +//---------------------------------------------------------------------------- +void CCreatorMailboxes::DeleteAllL() + { + LOGSTRING("Creator: CCreatorMailboxes::DeleteAllL"); + + CEmailAccounts* accountMgr = CEmailAccounts::NewLC(); + + // Delete pop accounts + RArray popAccountsToDelete; + CleanupClosePushL( popAccountsToDelete ); + accountMgr->GetPopAccountsL( popAccountsToDelete ); + for ( TInt i = 0; i < popAccountsToDelete.Count(); i++ ) + { + accountMgr->DeletePopAccountL( popAccountsToDelete[i] ); + } + CleanupStack::PopAndDestroy( &popAccountsToDelete ); + + // Delete imap accounts + RArray imapAccountsToDelete; + CleanupClosePushL( imapAccountsToDelete ); + accountMgr->GetImapAccountsL( imapAccountsToDelete ); + for ( TInt i = 0; i < imapAccountsToDelete.Count(); i++ ) + { + accountMgr->DeleteImapAccountL( imapAccountsToDelete[i] ); + } + CleanupStack::PopAndDestroy( &imapAccountsToDelete ); + + // Delete smtp accounts + RArray smtpAccountsToDelete; + CleanupClosePushL( smtpAccountsToDelete ); + accountMgr->GetSmtpAccountsL( smtpAccountsToDelete ); + for ( TInt i = 0; i < smtpAccountsToDelete.Count(); i++ ) + { + accountMgr->DeleteSmtpAccountL( smtpAccountsToDelete[i] ); + } + CleanupStack::PopAndDestroy( &smtpAccountsToDelete ); + + iEntryIds.Reset(); + + // all entries deleted, remove the Mailbox related registry + iEngine->RemoveStoreL( KUidDictionaryUidMailbox ); + + CleanupStack::PopAndDestroy( accountMgr ); + } + +//---------------------------------------------------------------------------- +void CCreatorMailboxes::DeleteAllCreatedByCreatorL() + { + LOGSTRING("Creator: CCreatorMailboxes::DeleteAllCreatedByCreatorL"); + + iEntryIds.Reset(); + CEmailAccounts* accountMgr = CEmailAccounts::NewLC(); + + // fetch ids of entries created by Creator + iEngine->ReadEntryIdsFromStoreL( iEntryIds, KUidDictionaryUidMailbox ); + + TInt i(0); + while ( i < iEntryIds.Count() && iEntryIds.Count() > 6 ) + { + // there should be at least 7 items in the array: + // one for mailbox type + // 3 for imap OR pop ids + // 3 for smtp ids + + // delete entries + + TInt type = iEntryIds[i++]; // TMailboxType + if ( type == EMailboxPOP3 ) + { + TPopAccount popAccount; + popAccount.iPopAccountId = iEntryIds[i++]; + popAccount.iPopService = iEntryIds[i++]; + popAccount.iSmtpService = iEntryIds[i++]; + TRAP_IGNORE( accountMgr->DeletePopAccountL( popAccount ) ); + } + else if ( type == EMailboxIMAP4 ) + { + TImapAccount imapAccount; + imapAccount.iImapAccountId = iEntryIds[i++]; + imapAccount.iImapService = iEntryIds[i++]; + imapAccount.iImapService = iEntryIds[i++]; + TRAP_IGNORE( accountMgr->DeleteImapAccountL( imapAccount ) ); + } + else + { + // ignore unknown mailbox types + i +=3; + } + + // There should be one smtp service for each pop and imap service + TSmtpAccount smtpAccount; + smtpAccount.iSmtpAccountId = iEntryIds[i++]; + smtpAccount.iSmtpService = iEntryIds[i++]; + smtpAccount.iRelatedService = iEntryIds[i++]; + TRAP_IGNORE( accountMgr->DeleteSmtpAccountL( smtpAccount ) ); + } + + // reset must be done here, because iEntryIds is stored in destructor + iEntryIds.Reset(); + + // all entries deleted, remove the mailbox related registry + iEngine->RemoveStoreL( KUidDictionaryUidMailbox ); + + CleanupStack::PopAndDestroy( accountMgr ); + } +//---------------------------------------------------------------------------- + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/src/creator_mailboxelement.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/src/creator_mailboxelement.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,496 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +#include "creator_mailboxelement.h" +#include "creator_traces.h" +#include "creator_mailbox.h" + +using namespace creatormailbox; + +/* + * + */ +CCreatorMailboxElement* CCreatorMailboxElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext ) + { + CCreatorMailboxElement* self = new (ELeave) CCreatorMailboxElement(aEngine); + CleanupStack::PushL(self); + self->ConstructL(aName, aContext); + CleanupStack::Pop(self); + return self; + } +/* + * + */ +CCreatorMailboxElement::CCreatorMailboxElement(CCreatorEngine* aEngine) +: +CCreatorScriptElement(aEngine) + { + iIsCommandElement = ETrue; + } + +TBool CCreatorMailboxElement::SetIntegerParamL(const TDesC& aElemName, const TDesC& aElemContent, CMailboxesParameters* param, TBool aSetRandom ) + { + _LIT( KAll, "all"); + + if( aElemName == Kincomingport ) + { + if( aSetRandom ) + param->iIncomingPort = iEngine->RandomNumber(25, 500); + else + param->iIncomingPort = ConvertStrToIntL(aElemContent); + } + else if( aElemName == Kattachmentsizelimit ) + { + if( aSetRandom ) + param->iAttachmentSizeLimit = iEngine->RandomNumber(1, KMaxTInt); + else + param->iAttachmentSizeLimit = ConvertStrToIntL(aElemContent); + } + else if( aElemName == Kbodytextsizelimit ) + { + if( aSetRandom ) + param->iBodyTextSizeLimit = iEngine->RandomNumber(1, KMaxTInt); + else + param->iBodyTextSizeLimit = ConvertStrToIntL(aElemContent); + } + else if( aElemName == Kattachmentfetchsize ) + { + if( aSetRandom ) + param->iAttachmentFetchSize = iEngine->RandomNumber(1, 40960); + else + param->iAttachmentFetchSize = ConvertStrToIntL(aElemContent); + } + else if( aElemName == Kimapidletimeout ) + { + if( aSetRandom ) + param->iImapIdleTimeout = iEngine->RandomNumber(10, 2000); + else + param->iImapIdleTimeout = ConvertStrToIntL(aElemContent); + } + else if( aElemName == Kmaxemailsize ) + { + if( aSetRandom ) + param->iMaxEmailSize = iEngine->RandomNumber(1024, KMaxTInt); + else + param->iMaxEmailSize = ConvertStrToIntL(aElemContent); + } + else if( aElemName == Ksyncrate ) + { + if( aSetRandom ) + param->iSyncRate = iEngine->RandomNumber(10, 500); + else + param->iSyncRate = ConvertStrToIntL(aElemContent); + } + else if( aElemName == Kinboxsynclimit ) + { + if( aSetRandom ) + param->iInboxSyncLimit = iEngine->RandomNumber(-1, 256); + else if( CompareIgnoreCase(aElemContent, KAll) == 0 ) + param->iInboxSyncLimit = -1; + else + param->iInboxSyncLimit = ConvertStrToIntL(aElemContent); + } + else if( aElemName == Kmailboxsynclimit ) + { + if( aSetRandom ) + param->iMailboxSyncLimit = iEngine->RandomNumber(-1, 256); + else if( CompareIgnoreCase(aElemContent, KAll) == 0 ) + param->iMailboxSyncLimit = -1; + else + param->iMailboxSyncLimit = ConvertStrToIntL(aElemContent); + } + else if( aElemName == Koutgoingport ) + { + if( aSetRandom ) + param->iOutgoingPort = KDefaultSmtpPort; + else + param->iOutgoingPort = ConvertStrToIntL(aElemContent); + } + else if( aElemName == Ktoccincludelimit ) + { + if( aSetRandom ) + param->iToCCIncludeLimit = iEngine->RandomNumber(0, 30); + else + param->iToCCIncludeLimit = ConvertStrToIntL(aElemContent); + } + else + return EFalse; + + return ETrue; + } + +TBool CCreatorMailboxElement::GetBooleanValueL(const TDesC& aElemContent, TBool aSetRandom) + { + if( aSetRandom ) + return iEngine->RandomNumber(0,1) == 1; + + return ConvertStrToBooleanL(aElemContent); + } + +TBool CCreatorMailboxElement::SetBooleanParamL(const TDesC& aElemName, const TDesC& aElemContent, CMailboxesParameters* param, TBool aSetRandom ) + { + TBool val = GetBooleanValueL(aElemContent, aSetRandom); + if( aElemName == Kincomingsslwrapper ) + param->iIncomingSSLWrapper = val; + else if( aElemName == Kincomingsecuresockets ) + param->iIncomingSecureSockets = val; + else if( aElemName == Kacknowledgereceipts ) + param->iAcknowledgeReceipts = val; + else if( aElemName == Kautosendonconnect ) + param->iAutoSendOnConnect = val; + else if( aElemName == Kdeletemailsatdisconnect ) + param->iDeleteEmailsAtDisconnect = val; + else if( aElemName == Kimapidlecommand ) + param->iImapIdleCommand = val; + else if( aElemName == Kmarkseeninsync ) + param->iMarkSeenInSync = val; + else if( aElemName == Kenableexpungemode ) + param->iEnableExpungeMode = val; + else if( aElemName == Kuseapopsecurelogin ) + param->iUseApop = val; + else if( aElemName == Kdisconnectedusermode ) + param->iDisconnectedUserMode = val; + else if( aElemName == Koutgoingsslwrapper ) + param->iOutgoingSSLWrapper = val; + else if( aElemName == Koutgoingsecuresockets ) + param->iOutgoingSecureSockets = val; + else if( aElemName == Kincludesignature ) + param->iIncludeSignature = val; + else if( aElemName == Kaddvcard ) + param->iAddVCard = val; + else if( aElemName == Krequestreceipts ) + param->iRequestReceipts = val; + else if( aElemName == Ksmtpauth ) + param->iSmtpAuth = val; + else + return EFalse; + + return ETrue; + } + +TBool CCreatorMailboxElement::SetTextParamL(const TDesC& aElemName, const TDesC& aElemContent, CMailboxesParameters* param, TBool aSetRandom ) + { + _LIT(KIncomingSrvPrefix, "mail."); + _LIT(KOutgoingSrvPrefix, "smtp."); + _LIT(KSrvPostfix, ".com"); + _LIT(KDefaultConnMethod, "internet"); + + if( aElemName == Kname ) + { + if( aSetRandom ) + { + TPtrC company(iEngine->RandomString(CCreatorEngine::ECompany)); + SetContentToTextParamL(param->iMailboxName, company); + } + else + SetContentToTextParamL(param->iMailboxName, aElemContent); + } + else if( aElemName == Kincomingloginname ) + { + if( aSetRandom ) + { + TPtrC random(iEngine->RandomString(CCreatorEngine::EFirstName)); + SetContentToTextParamL(param->iIncomingLoginName, random); + param->iIncomingLoginName->Des().LowerCase(); + } + else + SetContentToTextParamL(param->iIncomingLoginName, aElemContent); + } + else if( aElemName == Kincomingpassword ) + { + if( aSetRandom ) + { + TPtrC random(iEngine->RandomString(CCreatorEngine::EFirstName)); + SetContentToTextParamL(param->iIncomingPassword, random); + param->iIncomingPassword->Des().LowerCase(); + } + else + SetContentToTextParamL(param->iIncomingPassword, aElemContent); + } + else if( aElemName == Kincomingservername ) + { + if( aSetRandom ) + { + TPtrC random(iEngine->RandomString(CCreatorEngine::ECompany)); + HBufC* srvName = HBufC::NewLC(KIncomingSrvPrefix().Length()+random.Length()+KSrvPostfix().Length()); + srvName->Des().Copy(KIncomingSrvPrefix); + srvName->Des().Append(random); + srvName->Des().Append(KSrvPostfix); + SetContentToTextParamL(param->iIncomingServerName, srvName->Des()); + CleanupStack::PopAndDestroy(); // srvName + } + else + SetContentToTextParamL(param->iIncomingServerName, aElemContent); + } + else if( aElemName == Kincomingconnectionmethod ) + { + if( aSetRandom ) + SetContentToTextParamL(param->iIncomingConnectionMethod, KDefaultConnMethod); + else + SetContentToTextParamL(param->iIncomingConnectionMethod, aElemContent); + } + else if( aElemName == Kincomingfolderpath ) + SetContentToTextParamL(param->iIncomingFolderPath, aElemContent); + else if( aElemName == Kpathseparator ) + SetContentToTextParamL(param->iPathSeparator, aElemContent); + else if( aElemName == Koutgoingloginname ) + { + if( aSetRandom ) + { + TPtrC random(iEngine->RandomString(CCreatorEngine::EFirstName)); + SetContentToTextParamL(param->iOutgoingLoginName, random); + param->iOutgoingLoginName->Des().LowerCase(); + } + else + SetContentToTextParamL(param->iOutgoingLoginName, aElemContent); + } + else if( aElemName == Koutgoingpassword ) + { + if( aSetRandom ) + { + TPtrC random(iEngine->RandomString(CCreatorEngine::EFirstName)); + SetContentToTextParamL(param->iOutgoingPassword, random); + param->iOutgoingPassword->Des().LowerCase(); + } + else + SetContentToTextParamL(param->iOutgoingPassword, aElemContent); + } + else if( aElemName == Koutgoingservername ) + { + if( aSetRandom ) + { + TPtrC random(iEngine->RandomString(CCreatorEngine::ECompany)); + HBufC* srvName = HBufC::NewLC(KOutgoingSrvPrefix().Length()+random.Length()+KSrvPostfix().Length()); + srvName->Des().Copy(KOutgoingSrvPrefix); + srvName->Des().Append(random); + srvName->Des().Append(KSrvPostfix); + SetContentToTextParamL(param->iOutgoingServerName, srvName->Des()); + CleanupStack::PopAndDestroy(); // srvName + } + else + SetContentToTextParamL(param->iOutgoingServerName, aElemContent); + } + else if( aElemName == Koutgoingconnectionmethod ) + { + if( aSetRandom ) + SetContentToTextParamL(param->iOutgoingConnectionMethod, KDefaultConnMethod); + else + SetContentToTextParamL(param->iOutgoingConnectionMethod, aElemContent); + } + else if( aElemName == Kownemail ) + { + if( aSetRandom ) + { + TDesC* email = iEngine->CreateEmailAddressLC(); + SetContentToTextParamL(param->iOwnEmailAddress, *email); + CleanupStack::PopAndDestroy(); // email + } + else + SetContentToTextParamL(param->iOwnEmailAddress, aElemContent); + } + else if( aElemName == Kemailalias ) + { + if( aSetRandom ) + { + _LIT(KSpace, " "); + TPtrC firstName(iEngine->RandomString(CCreatorEngine::EFirstName)); + TPtrC lastName(iEngine->RandomString(CCreatorEngine::ESurname)); + HBufC* alias = HBufC::NewLC(firstName.Length() + lastName.Length() + KSpace().Length()); + alias->Des().Copy(firstName); + alias->Des().Append(KSpace); + alias->Des().Append(lastName); + SetContentToTextParamL(param->iOwnEmailAlias, alias->Des()); + CleanupStack::PopAndDestroy(); // alias + } + else + SetContentToTextParamL(param->iOwnEmailAlias, aElemContent); + } + else if( aElemName == Kreceiptaddress ) + { + if( aSetRandom ) + { + TDesC* email = iEngine->CreateEmailAddressLC(); + SetContentToTextParamL(param->iReceiptAddress, *email); + CleanupStack::PopAndDestroy(); // email + } + else + SetContentToTextParamL(param->iReceiptAddress, aElemContent); + } + else if( aElemName == Kreplytoaddress ) + { + if( aSetRandom ) + { + TDesC* email = iEngine->CreateEmailAddressLC(); + SetContentToTextParamL(param->iReceiptAddress, *email); + CleanupStack::PopAndDestroy(); // email + } + else + SetContentToTextParamL(param->iReplyToAddress, aElemContent); + } + else + return EFalse; + + return ETrue; + } + +TBool CCreatorMailboxElement::SetEnumParamL(const TDesC& aElemName, const TDesC& aElemContent, CMailboxesParameters* param, TBool aSetRandom ) + { + // Get email options: + if( aElemName == Kgetemailoptions ) + { + if( aSetRandom ) + param->iGetEmailOptions = (CMailboxesParameters::TGetEmailOption) iEngine->RandomNumber( + CMailboxesParameters::EGetHeaders, + CMailboxesParameters::EGetEmailOptionLast-1); + else if( CompareIgnoreCase(aElemContent, Kgetheaders ) == 0 ) + param->iGetEmailOptions = CMailboxesParameters::EGetHeaders; + else if( CompareIgnoreCase(aElemContent, Kgetbodytext) == 0 ) + param->iGetEmailOptions = CMailboxesParameters::EGetBodyText; + else if( CompareIgnoreCase(aElemContent, Kgetbodytextandattachments) == 0 ) + param->iGetEmailOptions = CMailboxesParameters::EGetBodyTextAndAttachments; + else if( CompareIgnoreCase(aElemContent, Kgetattachments) == 0 ) + param->iGetEmailOptions = CMailboxesParameters::EGetAttachments; + else if( CompareIgnoreCase(aElemContent, Kgetbodyalternativetext) == 0 ) + param->iGetEmailOptions = CMailboxesParameters::EGetBodyAlternativeText; + else + param->iGetEmailOptions = CMailboxesParameters::EUndef; + } + + // Subscribe type: + else if( aElemName == Ksubscribetype ) + { + if( aSetRandom ) + param->iSubscribeType = (TFolderSubscribeType) iEngine->RandomNumber( EUpdateNeither, EUpdateBoth ); + else if( CompareIgnoreCase( aElemContent, Kupdatelocal) == 0 ) + param->iSubscribeType = EUpdateLocal; + else if( CompareIgnoreCase( aElemContent, Kupdateremote) == 0 ) + param->iSubscribeType = EUpdateRemote; + else if( CompareIgnoreCase( aElemContent, Kupdateboth) == 0 ) + param->iSubscribeType = EUpdateBoth; + else + param->iSubscribeType = EUpdateNeither; + } + + // Folder synchronization type: + else if( aElemName == Kfoldersynctype) + { + if( aSetRandom ) + param->iSyncType = (TFolderSyncType) iEngine->RandomNumber(EUseCombination, EUseRemote); + else if( CompareIgnoreCase( aElemContent, Kuselocal) == 0 ) + param->iSyncType = EUseLocal; + else if( CompareIgnoreCase( aElemContent, Kuseremote) == 0 ) + param->iSyncType = EUseRemote; + else + param->iSyncType = EUseCombination; + } + + // Send copy to self option: + else if( aElemName == Kcopytoself ) + { + if( aSetRandom ) + param->iSendCopyToSelf = (TImSMTPSendCopyToSelf) iEngine->RandomNumber(ESendNoCopy, ESendCopyAsBccRecipient); + else if( CompareIgnoreCase( aElemContent, Kto) == 0 ) + param->iSendCopyToSelf = ESendCopyAsToRecipient; + else if( CompareIgnoreCase( aElemContent, Kcc) == 0 ) + param->iSendCopyToSelf = ESendCopyAsCcRecipient; + else if( CompareIgnoreCase( aElemContent, Kbcc) == 0 ) + param->iSendCopyToSelf = ESendCopyAsBccRecipient; + else + param->iSendCopyToSelf = ESendNoCopy; + } + + // Send option: + else if( aElemName == Ksendoption ) + { + if( aSetRandom ) + param->iSendOption = (TImSMTPSendMessageOption) iEngine->RandomNumber(ESendMessageImmediately, ESendMessageOnRequest); + else if( CompareIgnoreCase( aElemContent, Konnextconnection) == 0 ) + param->iSendOption = ESendMessageOnNextConnection; + else if( CompareIgnoreCase( aElemContent, Konrequest) == 0 ) + param->iSendOption = ESendMessageOnRequest; + else + param->iSendOption = ESendMessageImmediately; + } + else + { + return EFalse; + } + return ETrue; + } + +void CCreatorMailboxElement::ExecuteCommandL() + { + const CCreatorScriptAttribute* amountAttr = FindAttributeByName(KAmount); + const CCreatorScriptAttribute* typeAttr = FindAttributeByName(KMailboxType); + TInt amount = 1; + if( amountAttr ) + { + amount = ConvertStrToIntL(amountAttr->Value()); + } + + TMailboxType mailboxType = EMailboxPOP3; + + if( typeAttr && CompareIgnoreCase(typeAttr->Value(), Kimap4) == 0 ) + { + mailboxType = EMailboxIMAP4; + } + + // Get 'fields' element + CCreatorScriptElement* fieldsElement = FindSubElement(KFields); + if( fieldsElement && fieldsElement->SubElements().Count() > 0) + { + // Get sub-elements + const RPointerArray& fields = fieldsElement->SubElements(); + // Create mailbox entries, the amount of entries is defined by amount: + for( TInt cI = 0; cI < amount; ++cI ) + { + CMailboxesParameters* param = new (ELeave) CMailboxesParameters; + CleanupStack::PushL(param); + + param->iMailboxType = mailboxType; + + for( TInt i = 0; i < fields.Count(); ++i ) + { + CCreatorScriptElement* field = fields[i]; + TPtrC elemName = field->Name(); + TPtrC elemContent = field->Content(); + const CCreatorScriptAttribute* randomAttr = fields[i]->FindAttributeByName(KRandomLength); + TBool useRandom = EFalse; + if( randomAttr || elemContent.Length() == 0 ) + { + useRandom = ETrue; + } + + if( SetTextParamL(elemName, elemContent, param, useRandom ) == EFalse && + SetBooleanParamL(elemName, elemContent, param, useRandom ) == EFalse && + SetIntegerParamL(elemName, elemContent, param, useRandom ) == EFalse && + SetEnumParamL(elemName, elemContent, param, useRandom ) ) + { + LOGSTRING2("CCreatorMailboxElement::ExecuteCommandL: Unknown mailbox field: %S", &elemName); + } + } + iEngine->AppendToCommandArrayL(ECmdCreateMessagingEntryMailboxes, param); + CleanupStack::Pop(); // param + } + } + else + { + iEngine->AppendToCommandArrayL(ECmdCreateMessagingEntryMailboxes, 0, amount); + } + } diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/src/creator_message.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/src/creator_message.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,1825 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include "engine.h" +#include "enginewrapper.h" + +#include "creator_message.h" +#include "creator_traces.h" +#include "creator_contactsetcache.h" +#include "creator_phonebook.h" +#include +#include +#include + +#include // for CleanupResetAndDestroyPushL + +//static const TInt KMessagesFieldLength = 1024; + +//_LIT(KCreatorMessagesPrefixName, "CR_"); +//_LIT(KCreatorMessagesPrefixFolderName, "CR_FLDR_"); + + +const TUid KUidBIOBusinessCardMsg = {0x10005531}; +_LIT(KEmpty, ""); + +//---------------------------------------------------------------------------- + +CMessagesParameters::CMessagesParameters() + { + LOGSTRING("Creator: CMessagesParameters::CMessagesParameters"); + + iSenderAddress = HBufC::New(128); + iRecipientAddress = HBufC::New(128); + iMessageSubject = HBufC::New(128); + iMessageBodyText = HBufC::New(10240); + TRAP_IGNORE(iAttachments = new(ELeave) CArrayFixFlat(64)); + iCreateAsUnread = ETrue; + } + +CMessagesParameters::~CMessagesParameters() + { + LOGSTRING("Creator: CMessagesParameters::~CMessagesParameters"); + + + delete iMessageBodyText; + delete iMessageSubject; + delete iRecipientAddress; + delete iSenderAddress; + delete iAttachments; + iAttachmentPaths.ResetAndDestroy(); + iAttachmentPaths.Close(); + iRecipientAddressArray.ResetAndDestroy(); + iRecipientAddressArray.Close(); + iRecipientLinkIds.Close(); + iSenderLinkIds.Close(); + } + +//---------------------------------------------------------------------------- + +CCreatorMessages* CCreatorMessages::NewL(CCreatorEngine* aEngine) + { + CCreatorMessages* self = CCreatorMessages::NewLC(aEngine); + CleanupStack::Pop(self); + return self; + } + +CCreatorMessages* CCreatorMessages::NewLC(CCreatorEngine* aEngine) + { + CCreatorMessages* self = new (ELeave) CCreatorMessages; + CleanupStack::PushL(self); + self->ConstructL(aEngine); + return self; + } + +CCreatorMessages::CCreatorMessages() + { + } + +void CCreatorMessages::ConstructL(CCreatorEngine* aEngine) + { + LOGSTRING("Creator: CCreatorMessages::ConstructL"); + iEngine = aEngine; + + TRAP_IGNORE(iAttachments = new(ELeave) CArrayFixFlat(64)); + iWaiter = CAsyncWaiter::NewL(); + } + +CCreatorMessages::~CCreatorMessages() + { + LOGSTRING("Creator: CCreatorMessages::~CCreatorMessages"); + + if ( iEngine && iEntryIds.Count() ) + { + TRAP_IGNORE( iEngine->WriteEntryIdsToStoreL( iEntryIds, KUidDictionaryUidMessages ) ); + } + iEntryIds.Reset(); + iEntryIds.Close(); + + delete iParameters; + delete iWaiter; + delete iTmpPhoneNumber; + delete iTmpEmail; + delete iAttachments; + + iRecipientArray.ResetAndDestroy(); + iRecipientArray.Close(); + iSenderArray.ResetAndDestroy(); + iSenderArray.Close(); + } + +//---------------------------------------------------------------------------- + +void CCreatorMessages::QueryDialogClosedL(TBool aPositiveAction, TInt aUserData) + { + LOGSTRING("Creator: CCreatorMessages::QueryDialogClosedL"); + + if( aPositiveAction == EFalse ) + { + iEngine->ShutDownEnginesL(); + return; + } + + const TDesC* showText = &KSavingText; + TBool finished(EFalse); + TBool retval(ETrue); + switch(aUserData) + { + case ECreatorMessagesDelete: + showText = &KDeletingText; + iEntriesToBeCreated = 1; + finished = ETrue; + break; + case ECreatorMessagesStart: + // message type query + retval = iEngine->GetEngineWrapper()->ListQueryDialog(_L("Message type"), R_MESSAGE_TYPE_QUERY, (TInt*) &iMessageType, this, ECreatorMessagesMessageType); + break; + case ECreatorMessagesMessageType: + retval = iEngine->GetEngineWrapper()->ListQueryDialog(_L("Folder type"), R_FOLDER_TYPE_QUERY, (TInt*) &iFolderType, this, ECreatorMessagesFolderType); + break; + case ECreatorMessagesFolderType: + // query create as unread + retval = iEngine->GetEngineWrapper()->ListQueryDialog(_L("Message status"), R_UNREAD_QUERY, (TInt*)&iCreateAsUnread, this, ECreatorMessagesMessageStatus); + break; + case ECreatorMessagesMessageStatus: + if( iMessageType == ESMS || iMessageType == EMMS || iMessageType == EEmail ) + { + iDefinedMessageLength = 100; + retval = iEngine->GetEngineWrapper()->EntriesQueryDialog(&iDefinedMessageLength, _L("Amount of characters in message body?"), ETrue, + this, ECreatorMessagesCharsInBody + ); + break; + } + else + { + iDefinedMessageLength = 0; + // goto query attachments ... :-) DO NOT break; + } + case ECreatorMessagesCharsInBody: + // query attachments + iAttachments->Reset(); + if( iMessageType == EMMS || iMessageType == EEmail) + { + retval = iEngine->GetEngineWrapper()->ListQueryDialog(_L("Choose attachment:"), R_ATTACHMENT_MULTI_SELECTION_QUERY, + iAttachments, this, ECreatorMessagesAttachment + ); + } + else if( iMessageType == EAMS ) + { + iAttachments->AppendL( TInt(0) ); + retval = iEngine->GetEngineWrapper()->ListQueryDialog(_L("Choose attachment:"), R_AMS_ATTACHMENT_SINGLE_SELECTION_QUERY, + &iAttachments->At(0), this, ECreatorMessagesAttachment + ); + } + else if( iMessageType == EIrMessage || iMessageType == EBTMessage ) + { + iAttachments->AppendL( TInt(0) ); + retval = iEngine->GetEngineWrapper()->ListQueryDialog(_L("Choose attachment:"), R_ATTACHMENT_SINGLE_SELECTION_QUERY, + &iAttachments->At(0), this, ECreatorMessagesAttachment + ); + } + else + { + finished = ETrue; + } + break; + case ECreatorMessagesAttachment: + finished = ETrue; + if(iMessageType== EMMS || iMessageType == EEmail) + { + // "none" is selected + if (iAttachments->At(0) == 0) + { + iAttachments->Reset(); + } + else // otherwise fix indexes + { + for (TInt i=0; iCount(); i++) + iAttachments->At(i)--; // decrease value by one + + } + } + break; + default: + //some error + retval = EFalse; + break; + } + if( retval == EFalse ) + { + iEngine->ShutDownEnginesL(); + } + else if( finished ) + { + // add this command to command array + iEngine->AppendToCommandArrayL(iCommand, NULL, iEntriesToBeCreated); + // started exucuting commands + iEngine->ExecuteFirstCommandL( *showText ); + } + } +//---------------------------------------------------------------------------- + +TBool CCreatorMessages::AskDataFromUserL(TInt aCommand) + { + LOGSTRING("Creator: CCreatorMessages::AskDataFromUserL"); + + CCreatorModuleBase::AskDataFromUserL(aCommand); + + if ( aCommand == ECmdDeleteMessages ) + { + return iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all messages?"), this, ECreatorMessagesDelete ); + } + else if ( aCommand == ECmdDeleteCreatorMessages ) + { + return iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all messages created with Creator?"), this, ECreatorMessagesDelete ); + } + + return iEngine->GetEngineWrapper()->EntriesQueryDialog( &iEntriesToBeCreated, _L("How many entries to create?"), EFalse, this, ECreatorMessagesStart ); + } + +//---------------------------------------------------------------------------- + +TInt CCreatorMessages::CreateRandomMessageEntryL(TInt aCommand) + { + LOGSTRING2("Creator: CCreatorMessages::CreateRandomMessageEntryL - Command: %d", aCommand); + + TInt err = KErrNone; + + iDefinedMessageLength = iEngine->RandomNumber(100, 300); + + + switch (aCommand) + { + case ECmdCreateRandomEntrySMSInbox: { iMessageType=ESMS; iFolderType=EInbox; err=CreateMessageEntryL(NULL); break;} + case ECmdCreateRandomEntrySMSDrafts: { iMessageType=ESMS; iFolderType=EDrafts; err=CreateMessageEntryL(NULL); break;} + case ECmdCreateRandomEntrySMSOutbox: { iMessageType=ESMS; iFolderType=EOutbox; err=CreateMessageEntryL(NULL); break;} + case ECmdCreateRandomEntrySMSSent: { iMessageType=ESMS; iFolderType=ESent; err=CreateMessageEntryL(NULL); break;} + + case ECmdCreateRandomEntryMMSInbox: { iMessageType=EMMS; iFolderType=EInbox; err=CreateMessageEntryL(NULL); break;} + case ECmdCreateRandomEntryMMSDrafts: { iMessageType=EMMS; iFolderType=EDrafts; err=CreateMessageEntryL(NULL); break;} + case ECmdCreateRandomEntryMMSOutbox: { iMessageType=EMMS; iFolderType=EOutbox; err=CreateMessageEntryL(NULL); break;} + case ECmdCreateRandomEntryMMSSent: { iMessageType=EMMS; iFolderType=ESent; err=CreateMessageEntryL(NULL); break;} + + case ECmdCreateRandomEntryEmailInbox: { iMessageType=EEmail; iFolderType=EInbox; err=CreateMessageEntryL(NULL); break;} + case ECmdCreateRandomEntryEmailDrafts: { iMessageType=EEmail; iFolderType=EDrafts; err=CreateMessageEntryL(NULL); break;} + case ECmdCreateRandomEntryEmailOutbox: { iMessageType=EEmail; iFolderType=EOutbox; err=CreateMessageEntryL(NULL); break;} + case ECmdCreateRandomEntryEmailSent: { iMessageType=EEmail; iFolderType=ESent; err=CreateMessageEntryL(NULL); break;} + + case ECmdCreateRandomEntryBIOInbox: { iMessageType=ESmartMessage; iFolderType=EInbox; err=CreateMessageEntryL(NULL); break;} + case ECmdCreateRandomEntryBIODrafts: { iMessageType=ESmartMessage; iFolderType=EDrafts; err=CreateMessageEntryL(NULL); break;} + case ECmdCreateRandomEntryBIOOutbox: { iMessageType=ESmartMessage; iFolderType=EOutbox; err=CreateMessageEntryL(NULL); break;} + case ECmdCreateRandomEntryBIOSent: { iMessageType=ESmartMessage; iFolderType=ESent; err=CreateMessageEntryL(NULL); break;} + + case ECmdCreateRandomEntryIRInbox: { iMessageType=EIrMessage; iFolderType=EInbox; iAttachments->Reset(); iAttachments->AppendL( iEngine->RandomNumber(CCreatorEngine::EJPEG_25kB, CCreatorEngine::LAST_FILE_ID-1) ); err=CreateMessageEntryL(NULL); break;} + case ECmdCreateRandomEntryIRDrafts: { iMessageType=EIrMessage; iFolderType=EDrafts; iAttachments->Reset(); iAttachments->AppendL( iEngine->RandomNumber(CCreatorEngine::EJPEG_25kB, CCreatorEngine::LAST_FILE_ID-1) ); err=CreateMessageEntryL(NULL); break;} + case ECmdCreateRandomEntryIROutbox: { iMessageType=EIrMessage; iFolderType=EOutbox; iAttachments->Reset(); iAttachments->AppendL( iEngine->RandomNumber(CCreatorEngine::EJPEG_25kB, CCreatorEngine::LAST_FILE_ID-1) ); err=CreateMessageEntryL(NULL); break;} + case ECmdCreateRandomEntryIRSent: { iMessageType=EIrMessage; iFolderType=ESent; iAttachments->Reset(); iAttachments->AppendL( iEngine->RandomNumber(CCreatorEngine::EJPEG_25kB, CCreatorEngine::LAST_FILE_ID-1) ); err=CreateMessageEntryL(NULL); break;} + + case ECmdCreateRandomEntryBTInbox: { iMessageType=EBTMessage; iFolderType=EInbox; iAttachments->Reset(); iAttachments->AppendL( iEngine->RandomNumber(CCreatorEngine::EJPEG_25kB, CCreatorEngine::LAST_FILE_ID-1) ); err=CreateMessageEntryL(NULL); break;} + case ECmdCreateRandomEntryBTDrafts: { iMessageType=EBTMessage; iFolderType=EDrafts; iAttachments->Reset(); iAttachments->AppendL( iEngine->RandomNumber(CCreatorEngine::EJPEG_25kB, CCreatorEngine::LAST_FILE_ID-1) ); err=CreateMessageEntryL(NULL); break;} + case ECmdCreateRandomEntryBTOutbox: { iMessageType=EBTMessage; iFolderType=EOutbox; iAttachments->Reset(); iAttachments->AppendL( iEngine->RandomNumber(CCreatorEngine::EJPEG_25kB, CCreatorEngine::LAST_FILE_ID-1) ); err=CreateMessageEntryL(NULL); break;} + case ECmdCreateRandomEntryBTSent: { iMessageType=EBTMessage; iFolderType=ESent; iAttachments->Reset(); iAttachments->AppendL( iEngine->RandomNumber(CCreatorEngine::EJPEG_25kB, CCreatorEngine::LAST_FILE_ID-1) ); err=CreateMessageEntryL(NULL); break;} + + case ECmdCreateRandomEntryAMSInbox: { iMessageType=EAMS; iFolderType=EInbox; iAttachments->Reset(); iAttachments->AppendL( CCreatorEngine::EMP3_250kB); err=CreateMessageEntryL(NULL); break;} + case ECmdCreateRandomEntryAMSDrafts: { iMessageType=EAMS; iFolderType=EDrafts; iAttachments->Reset(); iAttachments->AppendL( CCreatorEngine::EMP3_250kB); err=CreateMessageEntryL(NULL); break;} + case ECmdCreateRandomEntryAMSOutbox: { iMessageType=EAMS; iFolderType=EOutbox; iAttachments->Reset(); iAttachments->AppendL( CCreatorEngine::EMP3_250kB); err=CreateMessageEntryL(NULL); break;} + case ECmdCreateRandomEntryAMSSent: { iMessageType=EAMS; iFolderType=ESent; iAttachments->Reset(); iAttachments->AppendL( CCreatorEngine::EMP3_250kB); err=CreateMessageEntryL(NULL); break;} + + default: { User::Panic(_L("MessageCommand"), 901); break;} + } + + return err; + } + +//---------------------------------------------------------------------------- + +TInt CCreatorMessages::CreateMessageEntryL(CMessagesParameters *aParameters, TBool /*aTakeUserGivenParameters*/) + { + LOGSTRING("Creator: CCreatorMessages::CreateMessageEntryL"); + + delete iParameters; + iParameters = 0; + + CMessagesParameters* parameters = aParameters; + + // random data needed if no predefined data available + if (!parameters) + { + iParameters = new(ELeave) CMessagesParameters; + parameters = iParameters; + // check if values from ui needed + //if (aTakeUserGivenParameters) + // { + parameters->iMessageType = iMessageType; + parameters->iFolderType = iFolderType; + parameters->iDefinedMessageLength = iDefinedMessageLength; + parameters->iCreateAsUnread = iCreateAsUnread; + + for (TInt i=0; iCount(); i++) + parameters->iAttachments->AppendL(iAttachments->At(i)); + // } + //else + // { + // message length + // parameters->iDefinedMessageLength = iEngine->RandomNumber(100, 300); + // } + + if (parameters->iMessageType == EEmail) + { + parameters->iSenderAddress->Des().Copy( iEngine->RandomString(CCreatorEngine::EFirstName) ); + parameters->iSenderAddress->Des().Append( _L("@") ); + parameters->iSenderAddress->Des().Append( iEngine->RandomString(CCreatorEngine::ECompany) ); + parameters->iSenderAddress->Des().Append( _L(".com") ); + + parameters->iRecipientAddress->Des().Copy( iEngine->RandomString(CCreatorEngine::EFirstName) ); + parameters->iRecipientAddress->Des().Append( _L("@") ); + parameters->iRecipientAddress->Des().Append( iEngine->RandomString(CCreatorEngine::ECompany) ); + parameters->iRecipientAddress->Des().Append( _L(".net") ); + } + else if (parameters->iMessageType == EIrMessage || parameters->iMessageType == EBTMessage) + { + parameters->iSenderAddress->Des().Copy( iEngine->RandomString(CCreatorEngine::EFirstName) ); + parameters->iRecipientAddress->Des().Copy( iEngine->RandomString(CCreatorEngine::EFirstName) ); + } + else + { + parameters->iSenderAddress->Des().Copy( iEngine->RandomString(CCreatorEngine::EPhoneNumber) ); + parameters->iRecipientAddress->Des().Copy( iEngine->RandomString(CCreatorEngine::EPhoneNumber) ); + } + + // subject + parameters->iMessageSubject->Des() = iEngine->RandomString(CCreatorEngine::EMessageSubject); + + // message body + parameters->iMessageBodyText->Des().Copy(_L("")); + TPtrC randText = iEngine->RandomString(CCreatorEngine::EMessageText); + for (TInt i=0; iiDefinedMessageLength / randText.Length() +1; i++) + { + parameters->iMessageBodyText->Des().Append( randText ); + parameters->iMessageBodyText->Des().Append( _L(" ") ); + } + parameters->iMessageBodyText->Des() = parameters->iMessageBodyText->Des().Left(parameters->iDefinedMessageLength); + + // BIO message type (from bitsids.h) // TO-DO: add support for all BIO message types... + parameters->iBIOMessageType = KUidBIOBusinessCardMsg; + } + + + + TInt err = KErrNone; + + switch (parameters->iMessageType) + { + case ESMS: { err = CreateSMSEntryL(*parameters); break; } + case EMMS: { err = CreateMMSEntryL(*parameters); break; } + case EAMS: { err = CreateAMSEntryL(*parameters); break; } + case EEmail: { err = CreateEmailEntryL(*parameters); break; } + case ESmartMessage: { err = CreateSmartMessageEntryL(*parameters); break; } + case EIrMessage: { err = CreateObexEntryL( TUid::Uid(KUidMsgTypeIrTInt32), *parameters ); break; } + case EBTMessage: { err = CreateObexEntryL( TUid::Uid(KUidMsgTypeBtTInt32), *parameters ); break; } + default: { User::Panic(_L("MsgType"), 851); break;} + + } + + iSenderArray.ResetAndDestroy(); + iRecipientArray.ResetAndDestroy(); + return err; + } + +//---------------------------------------------------------------------------- + +TInt CCreatorMessages::CreateSMSEntryL(const CMessagesParameters& parameters) + { + LOGSTRING("Creator: CCreatorMessages::CreateSMSEntryL"); + + TInt err = KErrNone; + + + // init + CMsvSession* session = CMsvSession::OpenSyncL(*this); + CleanupStack::PushL(session); + CClientMtmRegistry* registry = CClientMtmRegistry::NewL(*session); + CleanupStack::PushL(registry); + + // get the client mtm and return if it isn't supported in the system + CSmsClientMtm* clientMtm = NULL; + TRAP(err, clientMtm = static_cast(registry->NewMtmL(KUidMsgTypeSMS))); + if (err || !clientMtm) + { + iEngine->GetEngineWrapper()->ShowErrorMessage(_L("SMS: Message type module not found")); + CleanupStack::PopAndDestroy(2); + User::Leave(KErrNotFound); + } + CleanupStack::PushL(clientMtm); + + // create a new object to access an existing entry + CMsvEntry* msvEntry = CMsvEntry::NewL(*session, KMsvGlobalInBoxIndexEntryId, TMsvSelectionOrdering()); + CleanupStack::PushL(msvEntry); + + // get default service + TMsvId defaultServiceId = 0; + TRAP(err, defaultServiceId = clientMtm->DefaultServiceL()); + if (err) + { + iEngine->GetEngineWrapper()->ShowErrorMessage(_L("SMS: Define a SMS centre first")); + CleanupStack::PopAndDestroy(2); + User::Leave(KErrNotFound); + } + + // set folder type + switch (parameters.iFolderType) + { + case EInbox: { msvEntry->SetEntryL(KMsvGlobalInBoxIndexEntryId); break; } + case EDrafts: { msvEntry->SetEntryL(KMsvDraftEntryId); break; } + case EOutbox: { msvEntry->SetEntryL(KMsvGlobalOutBoxIndexEntryId); break; } + case ESent: { msvEntry->SetEntryL(KMsvSentEntryId); break; } + default: { User::Panic(_L("Folder Type"), 871); break; } + } + + // mtm takes ownership of entry context + CleanupStack::Pop(msvEntry); + clientMtm->SetCurrentEntryL(msvEntry); + + // create a new message + clientMtm->CreateMessageL(defaultServiceId); + + // set the from field to sms header + // !!! This will cause CRASH + /*if (parameters.iFolderType == EInbox) + { + CSmsHeader* smsHeader = &clientMtm->SmsHeader(); + delete smsHeader; // <-- This will cause CRASH + smsHeader = NULL; + smsHeader = CSmsHeader::NewL(CSmsPDU::ESmsDeliver, clientMtm->Body()); + if( parameters.iSenderAddress ) + { + smsHeader->SetFromAddressL( parameters.iSenderAddress->Des() ); + } + else + { + smsHeader->SetFromAddressL(KEmpty); + } + } */ + + // set body + clientMtm->Body().Reset(); + clientMtm->Body().InsertL(0, parameters.iMessageBodyText->Des()); + + // get the entry of the message + TMsvEntry messageEntry = clientMtm->Entry().Entry(); + + // set the details field + if (parameters.iFolderType == EInbox) + { + SetSenderToEntryDetailsL(messageEntry, parameters, EFalse); + } + else + { + SetRecipientToEntryDetailsL(messageEntry, parameters, EFalse); + // Add all recipients to clientMtm + // iRecipientArray is up-to-date so don't call AddRecipientsL here + for( TInt i = 0; i < iRecipientArray.Count(); i++ ) + { + clientMtm->AddAddresseeL( iRecipientArray[i]->Des() ); + } + } + + // set the sending state for outbox message + // to avoid SMSMtmUI:15 panic in messages application + if (parameters.iFolderType == EOutbox ) + { + messageEntry.SetSendingState( KMsvSendStateWaiting ); + } + + // set the description field same as the first part of the message body + messageEntry.iDescription.Set( parameters.iMessageBodyText->Des().Left(KSmsDescriptionLength) ); + + // save the changes done above + clientMtm->Entry().ChangeL(messageEntry); + + // save the message + clientMtm->SaveMessageL(); + + // final fine tuning + messageEntry.SetAttachment(EFalse); + messageEntry.iDate.HomeTime(); + messageEntry.SetVisible(ETrue); + messageEntry.SetInPreparation(EFalse); + + if (parameters.iCreateAsUnread) + { + messageEntry.SetUnread(ETrue); + messageEntry.SetNew(ETrue); + } + else + { + messageEntry.SetUnread(EFalse); + messageEntry.SetNew(EFalse); + } + + messageEntry.SetComplete(ETrue); + messageEntry.iServiceId = defaultServiceId; + messageEntry.iRelatedId = 0; + clientMtm->Entry().ChangeL(messageEntry); + + // id has been generated, store it for being able to delete + // only entries created with Creator + iEntryIds.AppendL( messageEntry.Id() ); + + CleanupStack::PopAndDestroy(3); //session, registry, clientMtm + + return err; + + } + +//---------------------------------------------------------------------------- + +TInt CCreatorMessages::CreateMMSEntryL(const CMessagesParameters& parameters) + { + LOGSTRING("Creator: CCreatorMessages::CreateMMSEntryL"); + + TInt err = KErrNone; + + // init + CMsvSession* session = CMsvSession::OpenSyncL(*this); + CleanupStack::PushL(session); + CClientMtmRegistry* registry = CClientMtmRegistry::NewL(*session); + CleanupStack::PushL(registry); + + // get the client mtm and return if it isn't supported in the system + CMmsClientMtm* clientMtm = NULL; + TRAP(err, clientMtm = static_cast(registry->NewMtmL(KUidMsgTypeMultimedia))); + if (err || !clientMtm) + { + iEngine->GetEngineWrapper()->ShowErrorMessage(_L("MMS: Message type module not found")); + CleanupStack::PopAndDestroy(2); + User::Leave(KErrNotFound); + } + CleanupStack::PushL(clientMtm); + + // create a new object to access an existing entry + CMsvEntry* msvEntry = CMsvEntry::NewL(*session, KMsvGlobalInBoxIndexEntryId, TMsvSelectionOrdering()); + CleanupStack::PushL(msvEntry); + + // get default service + TMsvId defaultServiceId = 0; + TRAP(err, defaultServiceId = clientMtm->DefaultServiceL()); + if (err) + { + iEngine->GetEngineWrapper()->ShowErrorMessage(_L("MMS: Define MMS settings first")); + CleanupStack::PopAndDestroy(4); + User::Leave(KErrNotFound); + } + + // set folder type + switch (parameters.iFolderType) + { + case EInbox: { msvEntry->SetEntryL(KMsvGlobalInBoxIndexEntryId); break; } + case EDrafts: { msvEntry->SetEntryL(KMsvDraftEntryId); break; } + case EOutbox: { msvEntry->SetEntryL(KMsvGlobalOutBoxIndexEntryId); break; } + case ESent: { msvEntry->SetEntryL(KMsvSentEntryId); break; } + default: { User::Panic(_L("Folder Type"), 871); break; } + } + + // mtm takes ownership of entry context + CleanupStack::Pop(msvEntry); + clientMtm->SetCurrentEntryL(msvEntry); + + // create a new message + clientMtm->CreateMessageL(defaultServiceId); + + // set subject + clientMtm->SetSubjectL( parameters.iMessageSubject->Des() ); + + // set some mms defaults + clientMtm->SetMessageClass(EMmsClassPersonal); + clientMtm->SetExpiryInterval(86400); + clientMtm->SetDeliveryTimeInterval(3600); + clientMtm->SetMessagePriority(EMmsPriorityLow); + clientMtm->SetSenderVisibility(EMmsMaximumSenderVisibility); + clientMtm->SetDeliveryReport(EMmsDeliveryReportYes); + clientMtm->SetReadReply(EMmsReadReplyYes); + + // set the sender / addressee field + if (parameters.iFolderType == EInbox) + { + AddMtmSenderL(*clientMtm, parameters, EFalse); + } + + // Add all recipients to clientMtm + AddRecipientsL( *clientMtm, parameters, EFalse ); + + // get an access to the message store + CMsvStore* store = msvEntry->EditStoreL(); + CleanupStack::PushL(store); + + + // set body as an attachment + CMsvMimeHeaders* mimeHeaders = CMsvMimeHeaders::NewL(); + CleanupStack::PushL(mimeHeaders); + mimeHeaders->SetContentTypeL( _L8("text") ); + mimeHeaders->SetContentSubTypeL( _L8("plain") ); + mimeHeaders->SetMimeCharset( KMmsUtf8 ); + mimeHeaders->SetSuggestedFilenameL( _L("body.txt") ); + + MMsvAttachmentManager& attachMan = store->AttachmentManagerL(); + CMsvAttachment* attachmentInfo = CMsvAttachment::NewL(CMsvAttachment::EMsvFile); // ownership of attachmentInfo will be transferred + CleanupStack::PushL(attachmentInfo); + attachmentInfo->SetAttachmentNameL( _L("body.txt") ); + attachmentInfo->SetMimeTypeL( _L8("text/plain") ); + mimeHeaders->StoreL( *attachmentInfo ); + + RFile textFile; + + CAsyncWaiter* waiter = CAsyncWaiter::NewLC(); + attachMan.CreateAttachmentL(_L("body.txt"), textFile, attachmentInfo, waiter->iStatus ); + CleanupStack::Pop(); // waiter + CleanupStack::Pop(); // attachmentInfo + CleanupStack::PushL(waiter); + waiter->StartAndWait(); + CleanupStack::PopAndDestroy(waiter); + + HBufC8* tempBuf = CnvUtfConverter::ConvertFromUnicodeToUtf8L( parameters.iMessageBodyText->Des() ); + CleanupStack::PushL(tempBuf); + textFile.Write( tempBuf->Des() ); + textFile.Close(); + CleanupStack::PopAndDestroy(); //tempBuf + + CleanupStack::PopAndDestroy(); //mimeHeaders + + + // get the entry of the message + TMsvEntry messageEntry = clientMtm->Entry().Entry(); + + // set the details field + if (parameters.iFolderType == EInbox) + { + SetSenderToEntryDetailsL(messageEntry, parameters, EFalse); + } + else + { + SetRecipientToEntryDetailsL(messageEntry, parameters, EFalse); + } + + // set the description field same as the message subject + messageEntry.iDescription.Set( parameters.iMessageSubject->Des().Left(KSmsDescriptionLength) ); + + // save the changes done above + clientMtm->Entry().ChangeL(messageEntry); + + + // save the attachments + HandleAttachementsL(parameters, store, err ); +// for (TInt i=0; iCount(); i++) +// { +// TFileName sourceFileName = iEngine->TestDataPathL( (CCreatorEngine::TTestDataPath) parameters.iAttachments->At(i) ); +// +// TParse parser; +// parser.Set(sourceFileName, NULL, NULL); +// TFileName shortFileName = parser.NameAndExt(); +// +// // get the mime type +// RApaLsSession ls; +// User::LeaveIfError(ls.Connect()); +// CleanupClosePushL(ls); +// TUid appUid; +// TDataType dataType; +// ls.AppForDocument(sourceFileName, appUid, dataType); +// CleanupStack::PopAndDestroy(); //ls +// TPtrC8 mimeType = dataType.Des8(); +// +// // attachment settings +// MMsvAttachmentManager& attachMan = store->AttachmentManagerL(); +// CMsvAttachment* attachmentInfo = CMsvAttachment::NewL(CMsvAttachment::EMsvFile); // ownership of attachmentInfo will be transferred +// attachmentInfo->SetAttachmentNameL( shortFileName ); +// attachmentInfo->SetMimeTypeL( mimeType ); +// +// // save +// CAsyncWaiter* waiter = CAsyncWaiter::NewLC(); +// +// TRAP(err, attachMan.AddAttachmentL(sourceFileName, attachmentInfo, waiter->iStatus )); +// if (err == KErrNone) +// waiter->StartAndWait(); +// else +// LOGSTRING2("Creator: CCreatorMessages::CreateMMSEntryL failed to attach %S", &sourceFileName); +// +// CleanupStack::PopAndDestroy(waiter); +// } + + // save the changes made to the message store + store->CommitL(); + CleanupStack::PopAndDestroy(store); + + + // save the message + clientMtm->SaveMessageL(); + + // final fine tuning + messageEntry.SetAttachment(ETrue); + messageEntry.iDate.HomeTime(); + messageEntry.SetVisible(ETrue); + messageEntry.SetInPreparation(EFalse); + if (parameters.iCreateAsUnread) + { + messageEntry.SetUnread(ETrue); + messageEntry.SetNew(ETrue); + } + else + { + messageEntry.SetUnread(EFalse); + messageEntry.SetNew(EFalse); + } + messageEntry.SetComplete(ETrue); + messageEntry.iServiceId = defaultServiceId; + messageEntry.iRelatedId = 0; + + if (parameters.iFolderType == EDrafts) + messageEntry.SetReadOnly(EFalse); + else + messageEntry.SetReadOnly(ETrue); + + messageEntry.iMtmData1 = KMmsMessageMRetrieveConf | KMmsMessageMobileTerminated; + + clientMtm->Entry().ChangeL(messageEntry); + + // id has been generated, store it for being able to delete + // only entries created with Creator + iEntryIds.AppendL( messageEntry.Id() ); + + CleanupStack::PopAndDestroy(3); //session, registry, clientMtm + + + return err; + } + +//---------------------------------------------------------------------------- +void CCreatorMessages::HandleAttachementsL(const CMessagesParameters& parameters, CMsvStore* store, TInt err ) + { + // save the attachments (added with id's) + for (TInt i=0; iCount(); i++) + { + TFileName sourceFileName = iEngine->TestDataPathL( (CCreatorEngine::TTestDataPath) parameters.iAttachments->At(i) ); + HandleAttachementL(store, err, sourceFileName ); + + } + //Adding attachmentpaths + for (TInt i=0; iDes()); + HandleAttachementL(store, err, sourceFileName ); + } + } +//---------------------------------------------------------------------------- + +void CCreatorMessages::HandleAttachementL(CMsvStore* store, TInt err, TFileName& sourceFileName ) + { + TParse parser; + parser.Set(sourceFileName, NULL, NULL); + TFileName shortFileName = parser.NameAndExt(); + + // get the mime type + RApaLsSession ls; + User::LeaveIfError(ls.Connect()); + CleanupClosePushL(ls); + TUid appUid; + TDataType dataType; + ls.AppForDocument(sourceFileName, appUid, dataType); + CleanupStack::PopAndDestroy(); //ls + TPtrC8 mimeType = dataType.Des8(); + + // attachment settings + MMsvAttachmentManager& attachMan = store->AttachmentManagerL(); + CMsvAttachment* attachmentInfo = CMsvAttachment::NewL(CMsvAttachment::EMsvFile); // ownership of attachmentInfo will be transferred + CleanupStack::PushL(attachmentInfo); + attachmentInfo->SetAttachmentNameL( shortFileName ); + attachmentInfo->SetMimeTypeL( mimeType ); + + if ( mimeType == _L8("text/plain") ) + { + // CMsvMimeHeaders needs to be stored in case of text file + CMsvMimeHeaders* mimeHeaders = CMsvMimeHeaders::NewL(); + CleanupStack::PushL(mimeHeaders); + mimeHeaders->SetContentTypeL( _L8("text") ); + mimeHeaders->SetContentSubTypeL( _L8("plain") ); + mimeHeaders->SetMimeCharset( KMmsUtf8 ); + mimeHeaders->StoreL( *attachmentInfo ); + CleanupStack::PopAndDestroy( mimeHeaders ); + } + + // save + + CAsyncWaiter* waiter = CAsyncWaiter::NewLC(); + TRAP(err, attachMan.AddAttachmentL(sourceFileName, attachmentInfo, waiter->iStatus )); + if (err == KErrNone) + { + waiter->StartAndWait(); + CleanupStack::PopAndDestroy(waiter); + CleanupStack::Pop(); // attachmentInfo, the ownership is transferred + } + else + { + CleanupStack::PopAndDestroy(waiter); + CleanupStack::PopAndDestroy(); // attachmentInfo, ownership is not transferred (leave occurs) + LOGSTRING2("Creator: CCreatorMessages::HandleAttachementsL failed to attach %S", &sourceFileName); + } + } + //---------------------------------------------------------------------------- + +TInt CCreatorMessages::CreateAMSEntryL(const CMessagesParameters& parameters) + { + LOGSTRING("Creator: CCreatorMessages::CreateAMSEntryL"); + + TInt err = KErrNone; + + + // init + CMsvSession* session = CMsvSession::OpenSyncL(*this); + CleanupStack::PushL(session); + CClientMtmRegistry* registry = CClientMtmRegistry::NewL(*session); + CleanupStack::PushL(registry); + + // get the client mtm and return if it isn't supported in the system + CMmsClientMtm* clientMtm = NULL; + TRAP(err, clientMtm = static_cast(registry->NewMtmL(KUidMsgTypeMultimedia))); + if (err || !clientMtm) + { + iEngine->GetEngineWrapper()->ShowErrorMessage(_L("MMS: Message type module not found")); + CleanupStack::PopAndDestroy(2); + User::Leave(KErrNotFound); + } + CleanupStack::PushL(clientMtm); + + // create a new object to access an existing entry + CMsvEntry* msvEntry = CMsvEntry::NewL(*session, KMsvGlobalInBoxIndexEntryId, TMsvSelectionOrdering()); + CleanupStack::PushL(msvEntry); + + // get default service + TMsvId defaultServiceId = 0; + TRAP(err, defaultServiceId = clientMtm->DefaultServiceL()); + if (err) + { + iEngine->GetEngineWrapper()->ShowErrorMessage(_L("MMS: Define MMS settings first")); + CleanupStack::PopAndDestroy(2); + User::Leave(KErrNotFound); + } + + // set folder type + switch (parameters.iFolderType) + { + case EInbox: { msvEntry->SetEntryL(KMsvGlobalInBoxIndexEntryId); break; } + case EDrafts: { msvEntry->SetEntryL(KMsvDraftEntryId); break; } + case EOutbox: { msvEntry->SetEntryL(KMsvGlobalOutBoxIndexEntryId); break; } + case ESent: { msvEntry->SetEntryL(KMsvSentEntryId); break; } + default: { User::Panic(_L("Folder Type"), 871); break; } + } + + // mtm takes ownership of entry context + CleanupStack::Pop(msvEntry); + clientMtm->SetCurrentEntryL(msvEntry); + + // create a new message + clientMtm->CreateMessageL(defaultServiceId); + + // set subject + clientMtm->SetSubjectL(parameters.iMessageSubject->Des() ); + + // set some mms defaults + clientMtm->SetMessageClass(EMmsClassPersonal); + clientMtm->SetExpiryInterval(86400); + clientMtm->SetDeliveryTimeInterval(3600); + clientMtm->SetMessagePriority(EMmsPriorityLow); + clientMtm->SetSenderVisibility(EMmsMaximumSenderVisibility); + clientMtm->SetDeliveryReport(EMmsDeliveryReportYes); + clientMtm->SetReadReply(EMmsReadReplyYes); + + // set the sender / addressee field + if (parameters.iFolderType == EInbox) + { + AddMtmSenderL(*clientMtm, parameters, EFalse); + } + + // Add all recipients to clientMtm + AddRecipientsL( *clientMtm, parameters, EFalse ); + + + // get an access to the message store + CMsvStore* store = msvEntry->EditStoreL(); + CleanupStack::PushL(store); + + // get the entry of the message + TMsvEntry messageEntry = clientMtm->Entry().Entry(); + + // set the details field + if (parameters.iFolderType == EInbox) + { + SetSenderToEntryDetailsL(messageEntry, parameters, EFalse); + } + else + { + SetRecipientToEntryDetailsL(messageEntry, parameters, EFalse); + } + + // set the description field same as the message subject + messageEntry.iDescription.Set( parameters.iMessageSubject->Des().Left(KSmsDescriptionLength) ); + messageEntry.iBioType = KUidMsgSubTypeMmsAudioMsg.iUid; + + // save the changes done above + clientMtm->Entry().ChangeL(messageEntry); + + + TFileName sourceFileName = iEngine->TestDataPathL( CCreatorEngine::EAMR_20kB ); + TParse parser; + parser.Set(sourceFileName, NULL, NULL); + TFileName shortFileName = parser.NameAndExt(); + + // get the mime type + RApaLsSession ls; + User::LeaveIfError(ls.Connect()); + CleanupClosePushL(ls); + TUid appUid; + TDataType dataType; + ls.AppForDocument(sourceFileName, appUid, dataType); + CleanupStack::PopAndDestroy(); //ls + TPtrC8 mimeType = dataType.Des8(); + + // attachment settings + MMsvAttachmentManager& attachMan = store->AttachmentManagerL(); + CMsvAttachment* attachmentInfo = CMsvAttachment::NewL(CMsvAttachment::EMsvFile); // ownership of attachmentInfo will be transferred + attachmentInfo->SetAttachmentNameL( shortFileName ); + attachmentInfo->SetMimeTypeL( mimeType ); + + // save + CAsyncWaiter* waiter = CAsyncWaiter::NewLC(); + + TRAP(err, attachMan.AddAttachmentL(sourceFileName, attachmentInfo, waiter->iStatus )); + if (err == KErrNone) + waiter->StartAndWait(); + else + LOGSTRING2("Creator: CCreatorMessages::CreateAMSEntryL failed to attach %S", &sourceFileName); + + CleanupStack::PopAndDestroy(waiter); + + // save the changes made to the message store + store->CommitL(); + CleanupStack::PopAndDestroy(store); + + + // save the message + clientMtm->SaveMessageL(); + + // final fine tuning + messageEntry.SetAttachment(ETrue); + messageEntry.iDate.HomeTime(); + messageEntry.SetVisible(ETrue); + messageEntry.SetInPreparation(EFalse); + if (parameters.iCreateAsUnread) + { + messageEntry.SetUnread(ETrue); + messageEntry.SetNew(ETrue); + } + else + { + messageEntry.SetUnread(EFalse); + messageEntry.SetNew(EFalse); + } + messageEntry.SetComplete(ETrue); + messageEntry.iServiceId = defaultServiceId; + messageEntry.iRelatedId = 0; + + if (parameters.iFolderType == EDrafts) + messageEntry.SetReadOnly(EFalse); + else + messageEntry.SetReadOnly(ETrue); + + messageEntry.iMtmData1 = KMmsMessageMRetrieveConf | KMmsMessageMobileTerminated; + + clientMtm->Entry().ChangeL(messageEntry); + + // id has been generated, store it for being able to delete + // only entries created with Creator + iEntryIds.AppendL( messageEntry.Id() ); + + CleanupStack::PopAndDestroy(3); //session, registry, clientMtm + + + return err; + } + +//---------------------------------------------------------------------------- + +TInt CCreatorMessages::CreateEmailEntryL(const CMessagesParameters& parameters) + { + LOGSTRING("Creator: CCreatorMessages::CreateEmailEntryL"); + + TInt err = KErrNone; + + // init + CMsvSession* session = CMsvSession::OpenSyncL(*this); + CleanupStack::PushL(session); + CClientMtmRegistry* registry = CClientMtmRegistry::NewL(*session); + CleanupStack::PushL(registry); + + // get the client mtm and return if it isn't supported in the system + CSmtpClientMtm* clientMtm = NULL; + TRAP(err, clientMtm = static_cast(registry->NewMtmL(KUidMsgTypeSMTP))); + + if (err || !clientMtm) + { + iEngine->GetEngineWrapper()->ShowErrorMessage(_L("Email: Message type module not found")); + CleanupStack::PopAndDestroy(2); + User::Leave(KErrNotFound); + } + CleanupStack::PushL(clientMtm); + + // create a new object to access an existing entry + CMsvEntry* msvEntry = CMsvEntry::NewL(*session, KMsvGlobalInBoxIndexEntryId, TMsvSelectionOrdering()); + CleanupStack::PushL(msvEntry); + + // get default service + TMsvId defaultServiceId(0); + TRAP(err, defaultServiceId = clientMtm->DefaultServiceL()); + if (err) + { + iEngine->GetEngineWrapper()->ShowErrorMessage(_L("Email: Define a mailbox first")); + CleanupStack::PopAndDestroy(2); + User::Leave(KErrNotFound); + } + + // set folder type + switch (parameters.iFolderType) + { + case EInbox: { msvEntry->SetEntryL(KMsvGlobalInBoxIndexEntryId); break; } + case EDrafts: { msvEntry->SetEntryL(KMsvDraftEntryId); break; } + case EOutbox: { msvEntry->SetEntryL(KMsvGlobalOutBoxIndexEntryId); break; } + case ESent: { msvEntry->SetEntryL(KMsvSentEntryId); break; } + case EMailbox: { msvEntry->SetEntryL(iUserSelectedMailbox); break; } + default: { User::Panic(_L("Folder Type"), 871); break; } + } + + // mtm takes ownership of entry context + CleanupStack::Pop(msvEntry); + clientMtm->SetCurrentEntryL(msvEntry); + + // create a new message + clientMtm->CreateMessageL(defaultServiceId); + + // set subject + clientMtm->SetSubjectL( parameters.iMessageSubject->Des() ); + + // set body + clientMtm->Body().Reset(); + clientMtm->Body().InsertL(0, parameters.iMessageBodyText->Des()); + + // get the entry of the message + TMsvEntry messageEntry = clientMtm->Entry().Entry(); + + // set the address fields + if (parameters.iFolderType == EInbox) + { + AddSenderToMtmAddresseeL(*clientMtm, parameters, ETrue ); + SetSenderToEntryDetailsL(messageEntry, parameters, ETrue); + messageEntry.iMtm = KUidMsgTypeIMAP4; // or any other than KUidMsgTypeSMTP to display 'from' field instead of 'to' field + } + else + { + // Add all recipients to clientMtm + AddRecipientsL( *clientMtm, parameters, ETrue ); + SetRecipientToEntryDetailsL(messageEntry, parameters, EFalse); + } + + // set the description field same as the message subject + messageEntry.iDescription.Set( parameters.iMessageSubject->Des().Left(KSmsDescriptionLength) ); + + // save the changes done above + clientMtm->Entry().ChangeL(messageEntry); + + // get an access to the message store + CMsvStore* store = msvEntry->EditStoreL(); + CleanupStack::PushL(store); + + // save the attachments + HandleAttachementsL(parameters, store, err); +// for (TInt i=0; iCount(); i++) +// { +// TFileName sourceFileName = iEngine->TestDataPathL( (CCreatorEngine::TTestDataPath) parameters.iAttachments->At(i) ); +// +// TParse parser; +// parser.Set(sourceFileName, NULL, NULL); +// TFileName shortFileName = parser.NameAndExt(); +// +// // get the mime type +// RApaLsSession ls; +// User::LeaveIfError(ls.Connect()); +// CleanupClosePushL(ls); +// TUid appUid; +// TDataType dataType; +// ls.AppForDocument(sourceFileName, appUid, dataType); +// CleanupStack::PopAndDestroy(); //ls +// TPtrC8 mimeType = dataType.Des8(); +// +// // attachment settings +// MMsvAttachmentManager& attachMan = store->AttachmentManagerL(); +// CMsvAttachment* attachmentInfo = CMsvAttachment::NewL(CMsvAttachment::EMsvFile); // ownership of attachmentInfo will be transferred +// attachmentInfo->SetAttachmentNameL( shortFileName ); +// attachmentInfo->SetMimeTypeL( mimeType ); +// +// // save +// CAsyncWaiter* waiter = CAsyncWaiter::NewLC(); +// +// TRAP(err, attachMan.AddAttachmentL(sourceFileName, attachmentInfo, waiter->iStatus )); +// if (err == KErrNone) +// waiter->StartAndWait(); +// else +// LOGSTRING2("Creator: CCreatorMessages::CreateEmailEntryL failed to attach %S", &sourceFileName); +// +// CleanupStack::PopAndDestroy(waiter); +// } + + // save the changes made to the message store + store->CommitL(); + CleanupStack::PopAndDestroy(store); + + // save the message + clientMtm->SaveMessageL(); + + // final fine tuning + TMsvEmailEntry temailEntry = static_cast(messageEntry); + temailEntry.SetMessageFolderType(EFolderTypeUnknown); + temailEntry.SetDisconnectedOperation(ENoDisconnectedOperations); + temailEntry.SetEncrypted(EFalse); + temailEntry.SetSigned(EFalse); + temailEntry.SetVCard(EFalse); + temailEntry.SetVCalendar(EFalse); + temailEntry.SetReceipt(EFalse); + temailEntry.SetMHTMLEmail(EFalse); + temailEntry.SetBodyTextComplete(ETrue); + + if (parameters.iAttachments->Count() > 0) + temailEntry.SetAttachment(ETrue); + else + temailEntry.SetAttachment(EFalse); + + temailEntry.iDate.HomeTime(); + temailEntry.SetVisible(ETrue); + temailEntry.SetInPreparation(EFalse); + if (parameters.iCreateAsUnread) + { + temailEntry.SetUnread(ETrue); + temailEntry.SetNew(ETrue); + } + else + { + temailEntry.SetUnread(EFalse); + temailEntry.SetNew(EFalse); + } + temailEntry.SetComplete(ETrue); + temailEntry.iServiceId = defaultServiceId; + temailEntry.iRelatedId = 0; + + clientMtm->Entry().ChangeL(temailEntry); + + // reset email headers + CImHeader* header = CImHeader::NewLC(); + CMsvStore* msvStore = msvEntry->EditStoreL(); + CleanupStack::PushL(msvStore); + header->RestoreL(*msvStore); + header->SetSubjectL( parameters.iMessageSubject->Des() ); + if( iSenderArray.Count() == 0 ) + { + GetSendersL(iSenderArray, parameters, ETrue, KUndef ); + } + + if( iSenderArray.Count() > 0 ) + { + TInt rndNum = iEngine->RandomNumber( iSenderArray.Count() ); + header->SetFromL(iSenderArray[rndNum]->Des()); + } + else + { + header->SetFromL( parameters.iSenderAddress->Des() ); + } + if( parameters.iRecipientAddress->Length() > 0 ) + { + header->SetReceiptAddressL( parameters.iRecipientAddress->Des() ); + } + else if( parameters.iRecipientAddressArray.Count() > 0 ) + { + header->SetReceiptAddressL( parameters.iRecipientAddressArray[0]->Des()); + } + + header->StoreL( *msvStore ); + msvStore->CommitL(); + CleanupStack::PopAndDestroy(2); // msvStore, header + + // id has been generated, store it for being able to delete + // only entries created with Creator + iEntryIds.AppendL( messageEntry.Id() ); + + CleanupStack::PopAndDestroy(3); //session, registry, clientMtm + + return err; + } + +//---------------------------------------------------------------------------- + +TInt CCreatorMessages::CreateSmartMessageEntryL(const CMessagesParameters& parameters) + { + LOGSTRING("Creator: CCreatorMessages::CreateSmartMessageEntryL"); + + TInt err = KErrNone; + + // init + CMsvSession* session = CMsvSession::OpenSyncL(*this); + CleanupStack::PushL(session); + CClientMtmRegistry* registry = CClientMtmRegistry::NewL(*session); + CleanupStack::PushL(registry); + + // get the client mtm and return if it isn't supported in the system + CSmsClientMtm* clientMtm = NULL; + TRAP(err, clientMtm = static_cast(registry->NewMtmL(KUidMsgTypeSMS))); + if (err || !clientMtm) + { + iEngine->GetEngineWrapper()->ShowErrorMessage(_L("BIO: Message type module not found")); + CleanupStack::PopAndDestroy(2); + User::Leave(KErrNotFound); + } + CleanupStack::PushL(clientMtm); + + // create a new object to access an existing entry + CMsvEntry* msvEntry = CMsvEntry::NewL(*session, KMsvGlobalInBoxIndexEntryId, TMsvSelectionOrdering()); + CleanupStack::PushL(msvEntry); + + // get default service + TMsvId defaultServiceId = 0; + TRAP(err, defaultServiceId = clientMtm->DefaultServiceL()); + if (err) + { + iEngine->GetEngineWrapper()->ShowErrorMessage(_L("SMS: Define a SMS centre first")); + CleanupStack::PopAndDestroy(2); + User::Leave(KErrNotFound); + } + + // set folder type + switch (parameters.iFolderType) + { + case EInbox: { msvEntry->SetEntryL(KMsvGlobalInBoxIndexEntryId); break; } + case EDrafts: { msvEntry->SetEntryL(KMsvDraftEntryId); break; } + case EOutbox: { msvEntry->SetEntryL(KMsvGlobalOutBoxIndexEntryId); break; } + case ESent: { msvEntry->SetEntryL(KMsvSentEntryId); break; } + default: { User::Panic(_L("Folder Type"), 871); break; } + } + + // mtm takes ownership of entry context + CleanupStack::Pop(msvEntry); + clientMtm->SetCurrentEntryL(msvEntry); + + // create a new message + clientMtm->CreateMessageL(defaultServiceId); + + // set the from field to sms header + if (parameters.iFolderType == EInbox) + { + CSmsHeader* smsHeader = &clientMtm->SmsHeader(); + delete smsHeader; + smsHeader = NULL; + smsHeader = CSmsHeader::NewL(CSmsPDU::ESmsDeliver, clientMtm->Body()); + if( parameters.iSenderAddress ) + { + smsHeader->SetFromAddressL( parameters.iSenderAddress->Des() ); + } + else + { + smsHeader->SetFromAddressL(KEmpty); + } + } + + // set body, the BIO message itself + clientMtm->Body().Reset(); + clientMtm->Body().InsertL(0, _L("Business Card\nTester Mike\nThe Company Ltd.\nSoftware Engineer\ntel +358 66 1234567\n")); + + // get the entry of the message + TMsvEntry messageEntry = clientMtm->Entry().Entry(); + + // TO-DO: Add support for all BIO messages, currently just insert a business card message ... : + // set the message type + // parameters.iBIOMessageType ... + clientMtm->BioTypeChangedL(KUidBIOBusinessCardMsg); + messageEntry.iBioType = KUidBIOBusinessCardMsg.iUid; + + // set the details field + if (parameters.iFolderType == EInbox) + { + SetSenderToEntryDetailsL(messageEntry, parameters, EFalse); + } + else + { + SetRecipientToEntryDetailsL(messageEntry, parameters, EFalse); + } + + // set the subject line + messageEntry.iDescription.Set( parameters.iMessageSubject->Des().Left(KSmsDescriptionLength) ); + + // set correct MTM type + messageEntry.iMtm= KUidBIOMessageTypeMtm; + + // save the changes done above + clientMtm->Entry().ChangeL(messageEntry); + + // save the message + clientMtm->SaveMessageL(); + + // final fine tuning + messageEntry.SetAttachment(EFalse); + messageEntry.iDate.HomeTime(); + messageEntry.SetVisible(ETrue); + messageEntry.SetInPreparation(EFalse); + if (parameters.iCreateAsUnread) + { + messageEntry.SetUnread(ETrue); + messageEntry.SetNew(ETrue); + } + else + { + messageEntry.SetUnread(EFalse); + messageEntry.SetNew(EFalse); + } + messageEntry.SetComplete(ETrue); + messageEntry.iServiceId = defaultServiceId; + messageEntry.iRelatedId = 0; + clientMtm->Entry().ChangeL(messageEntry); + + // id has been generated, store it for being able to delete + // only entries created with Creator + iEntryIds.AppendL( messageEntry.Id() ); + + CleanupStack::PopAndDestroy(3); //session, registry, clientMtm + + + return err; + } + +//---------------------------------------------------------------------------- + +TInt CCreatorMessages::CreateObexEntryL(TUid aMtm, const CMessagesParameters& parameters) + { + LOGSTRING("Creator: CCreatorMessages::CreateObexEntryL"); + + TInt err = KErrNone; + + // init + CMsvSession* session = CMsvSession::OpenSyncL(*this); + CleanupStack::PushL(session); + CClientMtmRegistry* registry = CClientMtmRegistry::NewL(*session); + CleanupStack::PushL(registry); + + // get the client mtm and return if it isn't supported in the system + CObexClientMtm* clientMtm = NULL; + TRAP(err, clientMtm = static_cast(registry->NewMtmL(aMtm))); + if (err || !clientMtm) + { + iEngine->GetEngineWrapper()->ShowErrorMessage(_L("Obex: Message type module not found")); + CleanupStack::PopAndDestroy(2); + User::Leave(KErrNotFound); + } + CleanupStack::PushL(clientMtm); + + // create a new object to access an existing entry + CMsvEntry* msvEntry = CMsvEntry::NewL(*session, KMsvGlobalInBoxIndexEntryId, TMsvSelectionOrdering()); + CleanupStack::PushL(msvEntry); + + // define default service + TMsvId defaultServiceId = 0; + + // set folder type + switch (parameters.iFolderType) + { + case EInbox: { msvEntry->SetEntryL(KMsvGlobalInBoxIndexEntryId); break; } + case EDrafts: { msvEntry->SetEntryL(KMsvDraftEntryId); break; } + case EOutbox: { msvEntry->SetEntryL(KMsvGlobalOutBoxIndexEntryId); break; } + case ESent: { msvEntry->SetEntryL(KMsvSentEntryId); break; } + default: { User::Panic(_L("Folder Type"), 871); break; } + } + + // mtm takes ownership of entry context + CleanupStack::Pop(msvEntry); + clientMtm->SetCurrentEntryL(msvEntry); + + // create a new message + clientMtm->CreateMessageL(defaultServiceId); + + // get the entry of the message + TMsvEntry messageEntry = clientMtm->Entry().Entry(); + + // set subject + clientMtm->SetSubjectL( parameters.iMessageSubject->Des() ); + messageEntry.iDescription.Set( parameters.iMessageSubject->Des().Left(KSmsDescriptionLength) ); + + // set body, must be empty for obex messages + clientMtm->Body().Reset(); + + // set the details field and + if (parameters.iFolderType == EInbox) + { + SetSenderToEntryDetailsL(messageEntry, parameters, EFalse); + } + else + { + SetRecipientToEntryDetailsL(messageEntry, parameters, EFalse); + } + + // set mtm + messageEntry.iMtm = aMtm; + messageEntry.iType = KUidMsvMessageEntry; + messageEntry.iServiceId = KMsvUnknownServiceIndexEntryId; + + // save the changes done above + clientMtm->Entry().ChangeL(messageEntry); + + // save the message + clientMtm->SaveMessageL(); + + // final fine tuning + messageEntry.iDate.HomeTime(); + messageEntry.SetVisible(ETrue); + messageEntry.SetInPreparation(EFalse); + if (parameters.iCreateAsUnread) + { + messageEntry.SetUnread(ETrue); + messageEntry.SetNew(ETrue); + } + else + { + messageEntry.SetUnread(EFalse); + messageEntry.SetNew(EFalse); + } + messageEntry.SetComplete(ETrue); + clientMtm->Entry().ChangeL(messageEntry); + + // save the attachment + if (parameters.iAttachments->Count() >= 1) + { + // create a new entry for the attachment + TMsvEntry attachTEntry; + attachTEntry.iType = KUidMsvAttachmentEntry; + attachTEntry.iServiceId = KMsvUnknownServiceIndexEntryId; + attachTEntry.iMtm = KUidMsgTypeBt; //save as bt message + + msvEntry->CreateL(attachTEntry); + + CMsvEntry* attachEntry = session->GetEntryL(attachTEntry.Id()); + clientMtm->SetCurrentEntryL(attachEntry); + + // get source file + TFileName sourceFileName = iEngine->TestDataPathL( (CCreatorEngine::TTestDataPath) parameters.iAttachments->At(0) ); + + // get the mime type + RApaLsSession ls; + User::LeaveIfError(ls.Connect()); + CleanupClosePushL(ls); + TUid appUid; + TDataType mimeType; + ls.AppForDocument(sourceFileName, appUid, mimeType); + CleanupStack::PopAndDestroy(); //ls + + CAsyncWaiter* waiter = CAsyncWaiter::NewLC(); + + // add an attachment to the current message entry + TRAP(err, clientMtm->AddAttachmentL( sourceFileName, mimeType.Des8(), 0, waiter->iStatus )); + if (err == KErrNone) + waiter->StartAndWait(); + else + LOGSTRING2("Creator: CCreatorMessages::CreateObexEntryL failed to attach %S", &sourceFileName); + + CleanupStack::PopAndDestroy(waiter); + } + + // id has been generated, store it for being able to delete + // only entries created with Creator + iEntryIds.AppendL( messageEntry.Id() ); + + CleanupStack::PopAndDestroy(3); //session, registry, clientMtm + + + return err; + } + +//---------------------------------------------------------------------------- + +void CCreatorMessages::HandleSessionEventL(TMsvSessionEvent /*aEvent*/, TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/) // from MMsvSessionObserver + { + } + +//---------------------------------------------------------------------------- +void CCreatorMessages::SetSenderToEntryDetailsL(TMsvEntry& aMsgEntry, const CMessagesParameters& aParameters, TBool aUseEmailAddress) + { + // Only one sender allowed: + if( iSenderArray.Count() == 0 ) + { + GetSendersL(iSenderArray, aParameters, aUseEmailAddress, KUndef ); + } + if( iSenderArray.Count() > 0 ) + { + TInt rnd = iEngine->RandomNumber( iSenderArray.Count() ); + aMsgEntry.iDetails.Set( iSenderArray[rnd]->Des() ); + } + else + { + aMsgEntry.iDetails.Set(KEmpty); + } + } + +//---------------------------------------------------------------------------- +void CCreatorMessages::SetRecipientToEntryDetailsL(TMsvEntry& aMsgEntry, const CMessagesParameters& aParameters, TBool aUseEmailAddress) + { + // Only one sender allowed: + GetAllRecipientsL(iRecipientArray, aParameters, aUseEmailAddress); + if( iRecipientArray.Count() > 0 ) + { + const TDesC& temp = iRecipientArray[0]->Des(); + aMsgEntry.iDetails.Set( temp ); + } + else + { + aMsgEntry.iDetails.Set(KEmpty); + } + } + +//---------------------------------------------------------------------------- +void CCreatorMessages::AddSenderToMtmAddresseeL(CBaseMtm& aMtm, const CMessagesParameters& aParameters, TBool aUseEmailAddress ) + { + // Only one sender allowed: + if( iSenderArray.Count() == 0 ) + { + GetSendersL(iSenderArray, aParameters, aUseEmailAddress, 1 ); + } + + for( TInt i = 0; i < iSenderArray.Count(); ++i ) + { + aMtm.AddAddresseeL( iSenderArray[i]->Des() ); + } + } + +//---------------------------------------------------------------------------- +void CCreatorMessages::AddMtmSenderL(CMmsClientMtm& aMtm, const CMessagesParameters& aParameters, TBool aUseEmailAddress ) + { + // Only one sender allowed: + if( iSenderArray.Count() == 0 ) + { + GetSendersL(iSenderArray, aParameters, aUseEmailAddress, 1 ); + } + + if( iSenderArray.Count() > 0 ) + { + aMtm.SetSenderL( iSenderArray[0]->Des() ); + } + } + +//---------------------------------------------------------------------------- +void CCreatorMessages::GetSendersL(RPointerArray& aSenderArray, const CMessagesParameters& aParameters, TBool aUseEmailAddress, TInt aMaxNum ) + { + TInt counter = 0; + + if( counter < aMaxNum || aMaxNum == KUndef ) + { + if( aParameters.iSenderAddress && aParameters.iSenderAddress->Length() > 0 ) + { + HBufC* temp = HBufC::NewL(aParameters.iSenderAddress->Length()); + CleanupStack::PushL(temp); + temp->Des().Copy(aParameters.iSenderAddress->Des()); + aSenderArray.AppendL( temp ); + CleanupStack::Pop(); // temp + ++counter; + } + } + + if( counter < aMaxNum || aMaxNum == KUndef ) + { + RPointerArray tempArray; + CleanupResetAndDestroyPushL( tempArray ); + GetLinkedAddressesL(tempArray, aParameters.iSenderLinkIds, aUseEmailAddress, aParameters.iNumberOfExistingSenders); + for( TInt i = 0; i < tempArray.Count() && (counter < aMaxNum || aMaxNum == KUndef); ++i ) + { + HBufC* temp = tempArray[i]->AllocLC(); + aSenderArray.AppendL(temp); + CleanupStack::Pop(); // temp + ++counter; + } + CleanupStack::PopAndDestroy(); // tempArray + } + } + +//---------------------------------------------------------------------------- +void CCreatorMessages::AddRecipientsL(CBaseMtm& aMtm, const CMessagesParameters& aParameters, TBool aUseEmailAddress ) + { + GetAllRecipientsL(iRecipientArray, aParameters, aUseEmailAddress); + for( TInt i = 0; i < iRecipientArray.Count(); ++i ) + { + aMtm.AddAddresseeL( iRecipientArray[i]->Des() ); + } + } + +//---------------------------------------------------------------------------- +void CCreatorMessages::GetAllRecipientsL(RPointerArray& aRecipientArray, const CMessagesParameters& aParameters, TBool aUseEmailAddress ) + { + + // If iRecipientAddress is given, add it to the array: + if( aParameters.iRecipientAddress && aParameters.iRecipientAddress->Length() > 0 ) + { + HBufC* temp = HBufC::NewL(aParameters.iRecipientAddress->Length()); + CleanupStack::PushL(temp); + temp->Des().Copy(aParameters.iRecipientAddress->Des()); + aRecipientArray.AppendL( temp ); + CleanupStack::Pop(); // temp + } + + // Add all recipients listed in iRecipientAddressArray: + for( TInt i = 0; i < aParameters.iRecipientAddressArray.Count(); ++i ) + { + HBufC* temp = HBufC::NewL(aParameters.iRecipientAddressArray[i]->Length()); + CleanupStack::PushL(temp); + temp->Des().Copy(aParameters.iRecipientAddressArray[i]->Des()); + aRecipientArray.AppendL( temp ); + CleanupStack::Pop(); // temp + } + + // Get all linked addresses. + GetLinkedAddressesL(aRecipientArray, aParameters.iRecipientLinkIds, aUseEmailAddress, aParameters.iNumberOfExistingRecipients); + } + +/* + * Get all linked addresses. This method gets addresses that are linked with contact-set id and + * existing addresses from the contact database, if required. + */ +void CCreatorMessages::GetLinkedAddressesL( + RPointerArray& aAddressArray, + const RArray& aLinkIds, + TBool aUseEmailAddress, + TInt /*aNumOfExistingAddresses*/ ) + { + CCreatorPhonebook* phonebook = dynamic_cast(iEngine->GetPhonebook()); + User::LeaveIfNull( phonebook ); + CCreatorPhonebookWrapper* phonebookWrapper = phonebook->GetPhonebookWrapper(); + + for( TInt i = 0; i < aLinkIds.Count(); ++i ) + { + const CCreatorContactSet& set = ContactLinkCache::Instance()->ContactSet(aLinkIds[i].iLinkId); + const RArray links = set.ContactLinks();//ContactLinkCache::Instance()->ContactSets();//set.ContactLinks(); + TInt numberOfExplicitLinks = links.Count(); // Number of defined contacts in contact-set + for( TInt j = 0; j < numberOfExplicitLinks; ++j ) + { + TBuf<128> name; + TBuf<128> email; + TBuf<128> phoneNumber; + phonebookWrapper->GetContactDetailsL( links[j], name, phoneNumber, email ); + HBufC* address = ( aUseEmailAddress ? email.AllocLC() : phoneNumber.AllocLC() ); + aAddressArray.AppendL( address ); + CleanupStack::Pop( address ); + } + } + } + +//---------------------------------------------------------------------------- +void CCreatorMessages::DeleteAllL() + { + LOGSTRING("Creator: CCreatorMessages::DeleteAllL"); + DeleteAllMessagesL( EFalse ); + } + +//---------------------------------------------------------------------------- +void CCreatorMessages::DeleteAllMessagesL( TBool aOnlyCreatedWithCreator ) + { + LOGSTRING("Creator: CCreatorMessages::DeleteAllMessagesL"); + TInt err( KErrNone ); + + // init + CMsvSession* session = CMsvSession::OpenSyncL(*this); + CleanupStack::PushL( session ); + CClientMtmRegistry* registry = CClientMtmRegistry::NewL(*session); + CleanupStack::PushL( registry ); + + // get the client mtm and return if it isn't supported in the system + CSmsClientMtm* clientMtm( NULL ); + TRAP( err, clientMtm = static_cast( registry->NewMtmL( KUidMsgTypeSMS ) ) ); + if ( err || !clientMtm ) + { + iEngine->GetEngineWrapper()->ShowErrorMessage( _L( "SMS: Message type module not found" ) ); + CleanupStack::PopAndDestroy( 2 ); + User::Leave( KErrNotFound ); + } + CleanupStack::PushL( clientMtm ); + + TRAP_IGNORE( DeleteAllFromFolderL( KMsvGlobalInBoxIndexEntryId, session, clientMtm, aOnlyCreatedWithCreator ) ); + TRAP_IGNORE( DeleteAllFromFolderL( KMsvDraftEntryId, session, clientMtm, aOnlyCreatedWithCreator ) ); + TRAP_IGNORE( DeleteAllFromFolderL( KMsvGlobalOutBoxIndexEntryId, session, clientMtm, aOnlyCreatedWithCreator ) ); + TRAP_IGNORE( DeleteAllFromFolderL( KMsvSentEntryId, session, clientMtm, aOnlyCreatedWithCreator ) ); + + // reset must be done here, because iEntryIds is stored in destructor + iEntryIds.Reset(); + + // all entries deleted, remove the Messages related registry + iEngine->RemoveStoreL( KUidDictionaryUidMessages ); + + CleanupStack::PopAndDestroy( clientMtm ); + CleanupStack::PopAndDestroy( registry ); + CleanupStack::PopAndDestroy( session ); + } + +//---------------------------------------------------------------------------- +void CCreatorMessages::DeleteAllFromFolderL( const TMsvId aContext, + CMsvSession* aSession, + CSmsClientMtm* aClientMtm, + TBool aOnlyCreatedWithCreator ) + { + LOGSTRING("Creator: CCreatorMessages::DeleteAllFromFolderL"); + + TMsvSelectionOrdering sort; + sort.SetShowInvisibleEntries( ETrue ); + + CMsvEntry* inboxContext = CMsvEntry::NewL( *aSession, aContext, sort ); + CleanupStack::PushL( inboxContext ); + + CMsvEntrySelection* entries = inboxContext->ChildrenL(); + CleanupStack::PushL( entries ); + + TInt msgCount = entries->Count(); + for ( TInt i = 0; i < entries->Count(); i++) + { + TMsvId entryID = entries->At(i); + aClientMtm->SwitchCurrentEntryL( entryID ); + + if ( !aOnlyCreatedWithCreator || iEntryIds.Find( entryID ) != KErrNotFound ) + { + CMsvEntry* entry = aSession->GetEntryL( (*entries)[i] ); + CleanupStack::PushL( entry ); + + entry->DeleteL( entries->At(i) ); + CleanupStack::PopAndDestroy( entry ); + } + } + + CleanupStack::PopAndDestroy( entries ); + CleanupStack::PopAndDestroy( inboxContext ); + } + +//---------------------------------------------------------------------------- +void CCreatorMessages::DeleteAllCreatedByCreatorL() + { + LOGSTRING("Creator: CCreatorMessages::DeleteAllCreatedByCreatorL"); + + iEntryIds.Reset(); + + // fetch ids of entries created by Creator + iEngine->ReadEntryIdsFromStoreL( iEntryIds, KUidDictionaryUidMessages ); + + // delete them + DeleteAllMessagesL( ETrue ); + } + +CRecipientInfo::CRecipientInfo() + { + + } + +CRecipientInfo::~CRecipientInfo() + { + delete iPhoneNumber; + delete iEmailAddress; + } + +void CRecipientInfo::SetPhoneNumber(HBufC* aPhone) + { + delete iPhoneNumber; + iPhoneNumber = aPhone; + } + +void CRecipientInfo::SetEmailAddress(HBufC* aEmail) + { + delete iEmailAddress; + iEmailAddress = aEmail; + } + +const HBufC* CRecipientInfo::PhoneNumber() const + { + return iPhoneNumber; + } + +const HBufC* CRecipientInfo::EmailAddress() const + { + return iEmailAddress; + } diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/src/creator_messageelement.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/src/creator_messageelement.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,475 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +#include "creator_messageelement.h" +#include "creator_traces.h" +#include "creator_message.h" + +using namespace creatormsg; + +/* + * + */ +CCreatorMessageElement* CCreatorMessageElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext ) + { + CCreatorMessageElement* self = new (ELeave) CCreatorMessageElement(aEngine); + CleanupStack::PushL(self); + self->ConstructL(aName, aContext); + CleanupStack::Pop(self); + return self; + } +/* + * + */ +CCreatorMessageElement::CCreatorMessageElement(CCreatorEngine* aEngine) +: +CCreatorScriptElement(aEngine) + { + iIsCommandElement = ETrue; + } +/* + * Sets message type + */ +void CCreatorMessageElement::SetMessageTypeL(CMessagesParameters& aParameters, const TDesC& aMsgTypeStr ) const + { + if( CompareIgnoreCase(aMsgTypeStr, KSms) == 0 ) + { + aParameters.iMessageType = ESMS; + } + else if( CompareIgnoreCase(aMsgTypeStr, KMms) == 0 ) + { + aParameters.iMessageType = EMMS; + } + else if( CompareIgnoreCase(aMsgTypeStr, KAms) == 0 ) + { + aParameters.iMessageType = EAMS; + } + else if( CompareIgnoreCase(aMsgTypeStr, KEmail) == 0 ) + { + aParameters.iMessageType = EEmail; + } + else if( CompareIgnoreCase(aMsgTypeStr, KSmart) == 0 ) + { + aParameters.iMessageType = ESmartMessage; + } + else if( CompareIgnoreCase(aMsgTypeStr, KIr) == 0 ) + { + aParameters.iMessageType = EIrMessage; + } + else if( CompareIgnoreCase(aMsgTypeStr, KBt) == 0 ) + { + aParameters.iMessageType = EBTMessage; + } + else + { + LOGSTRING2("ERROR in CCreatorMessageElement::SetMessageTypeL: Unknown message type: %S", &aMsgTypeStr); + User::Leave(KErrGeneral); + } + } +/* + * Returns maximum length of the body text, when randomlength=max is used. + */ +TInt CCreatorMessageElement::GetMaxBodyLength( const TDesC& aMsgType ) const + { + TInt len = 0; + if( CompareIgnoreCase(aMsgType, KSms) == 0 ) + { + len = 160; + } + else if( CompareIgnoreCase(aMsgType, KMms) == 0 ) + { + len = 160; + } + else if( CompareIgnoreCase(aMsgType, KEmail) == 0 ) + { + len = 1024; + } + else + { + len = KUndef; + } + return len; + } +/* + * Returns random body text length + */ +TInt CCreatorMessageElement::GetRandomBodyLengthL(const TDesC& aRandomLenStr, const TDesC& aMsgType ) const + { + TInt len = 0; + if( aRandomLenStr == KMax ) + { + len = GetMaxBodyLength(aMsgType); + } + else if( aRandomLenStr == KDefault ) + { + len = KUndef; + } + else + { + len = ConvertStrToIntL(aRandomLenStr); + } + return len; + } + +/* + * Creates random message address (To/From) + * Returns phone number for SMS, MMS, AMS and Smart messages. + * Email address for others + */ +HBufC* CCreatorMessageElement::CreateMessageAddressLC(const TDesC& msgType) + { + HBufC* toAddr; + if( CompareIgnoreCase(msgType, KSms) == 0 || + CompareIgnoreCase(msgType, KMms) == 0 || + CompareIgnoreCase(msgType, KAms) == 0 || + CompareIgnoreCase(msgType, KSmart) == 0) + { + TPtrC temp = iEngine->RandomString(CCreatorEngine::EPhoneNumber); + toAddr = HBufC::NewL(temp.Length()); + CleanupStack::PushL(toAddr); + toAddr->Des().Copy(temp); + } + else + { + toAddr = iEngine->CreateEmailAddressLC(); + } + return toAddr; + } + +/* + * + */ +void CCreatorMessageElement::ExecuteCommandL() + { + LOGSTRING("Creator: CCreatorMessageElement::ExecuteCommandL"); + + // Find out the message type: + const CCreatorScriptAttribute* msgTypeAttr = this->FindAttributeByName(KType); + TPtrC msgType; + if( msgTypeAttr ) + { + msgType.Set(msgTypeAttr->Value()); + } + else + { + LOGSTRING("ERROR in CCreatorMessageElement::ExecuteCommandL: Type attribute is missing."); + User::Leave(KErrGeneral); // type is required attribute + } + + // Find out the amount of calendar entries: + const CCreatorScriptAttribute* msgAmountAttr = this->FindAttributeByName(KAmount); + TInt msgAmount = 1; + if( msgAmountAttr ) + { + msgAmount = ConvertStrToIntL(msgAmountAttr->Value()); + } + + // Get 'fields' element + CCreatorScriptElement* fieldsElement = FindSubElement(KFields); + if( fieldsElement && fieldsElement->SubElements().Count() > 0 ) + { + // Get sub-elements (i.e the message field elements) + const RPointerArray& fields = fieldsElement->SubElements(); + + // Create message entries, the amount of entries is defined by msgAmount: + for( TInt cI = 0; cI < msgAmount; ++cI ) + { + CMessagesParameters* param = new (ELeave) CMessagesParameters; + CleanupStack::PushL(param); + + // Message type: + if( msgTypeAttr ) + { + SetMessageTypeL(*param, msgTypeAttr->Value()); + } + + // Loop all the message field elements: + for( TInt i = 0; i < fields.Count(); ++i ) + { + CCreatorScriptElement* field = fields[i]; + TPtrC elemName = field->Name(); + TPtrC elemContent = field->Content(); + const RPointerArray& contactReferences = field->SubElements(); + const CCreatorScriptAttribute* randomAttr = field->FindAttributeByName(KRandomLength); + const CCreatorScriptAttribute* amountAttr = field->FindAttributeByName(KAmount); + const CCreatorScriptAttribute* increaseAttr = field->FindAttributeByName(KIncrease); + TBool increase( EFalse ); + if ( increaseAttr ) + { + increase = ConvertStrToBooleanL( increaseAttr->Value() ); + } + TInt fieldAmount = 1; + if( amountAttr ) + { + fieldAmount = ConvertStrToIntL(amountAttr->Value()); + } + + if( elemName == KTo ) + { + // Recipient ('to'-field) + for( TInt amountIndex = 0; amountIndex < fieldAmount; ++amountIndex ) + { + if( (randomAttr || elemContent.Length() == 0 ) && contactReferences.Count() == 0 ) + { + // Random content + HBufC* toAddr = CreateMessageAddressLC(msgType); + if( toAddr ) + { + param->iRecipientAddressArray.AppendL(toAddr); + CleanupStack::Pop(); // toAddr + } + } + else + { + if( elemContent.Length() > 0 && contactReferences.Count() == 0) + { + // Explicit recipient given + HBufC* recipient = HBufC::NewL( elemContent.Length() + 3 ); + CleanupStack::PushL(recipient); + if ( increase ) + { + IncreasePhoneNumL( elemContent, cI, recipient ); + } + else + { + recipient->Des().Copy(elemContent); + } + param->iRecipientAddressArray.AppendL(recipient); + CleanupStack::Pop(); // recipient + } + else + { + // Recipients specified with contact-set-references (if any) + for( TInt csI = 0; csI < contactReferences.Count(); ++csI ) + { + CCreatorScriptElement* contactSetRef = contactReferences[csI]; + AppendContactSetReferenceL(*contactSetRef, param->iRecipientLinkIds); + } + } + } + } + } + else if( elemName == KFrom ) + { + // Sender ('from'-field) + // Amount attribute for sender is ignored, because there can be only one sender + delete param->iSenderAddress; + param->iSenderAddress = 0; + if( (randomAttr || elemContent.Length() == 0 ) && contactReferences.Count() == 0 ) + { + // Get random address + param->iSenderAddress = CreateMessageAddressLC(msgType); + CleanupStack::Pop(); // param->iSenderAddress + } + else + { + if( elemContent.Length() > 0 && contactReferences.Count() == 0) + { + // Explicit sender address given + param->iSenderAddress = HBufC::NewL(elemContent.Length()); + if ( increase ) + { + IncreasePhoneNumL( elemContent, cI, param->iSenderAddress ); + } + else + { + param->iSenderAddress->Des().Copy(elemContent); + } + } + else + { + // Senders specified with contact-set-references (if any) + for( TInt csI = 0; csI < contactReferences.Count(); ++csI ) + { + CCreatorScriptElement* contactSetRef = contactReferences[csI]; + AppendContactSetReferenceL(*contactSetRef, param->iSenderLinkIds); + } + } + } + } + else if( elemName == KFolder ) + { + // Folder type + if( CompareIgnoreCase(elemContent, KSent) == 0 ) + { + param->iFolderType = ESent; + } + else if( CompareIgnoreCase(elemContent, KInbox) == 0 ) + { + param->iFolderType = EInbox; + } + else if( CompareIgnoreCase(elemContent, KOutbox) == 0 ) + { + param->iFolderType = EOutbox; + } + else if( CompareIgnoreCase(elemContent, KDraft) == 0 ) + { + param->iFolderType = EDrafts; + } + } + else if( elemName == KSubject ) + { + // Message subject + delete param->iMessageSubject; + param->iMessageSubject = 0; + + if( randomAttr || elemContent.Length() == 0 ) + { + // Random data should be used + TPtrC temp = iEngine->RandomString(CCreatorEngine::EMessageSubject); + param->iMessageSubject = HBufC::NewL(temp.Length()); + param->iMessageSubject->Des().Copy(temp); + } + else + { + param->iMessageSubject = HBufC::NewL(elemContent.Length()); + param->iMessageSubject->Des().Copy(elemContent); + } + } + else if( elemName == KText ) + { + // Body text + delete param->iMessageBodyText; + param->iMessageBodyText = 0; + + if( randomAttr || elemContent.Length() == 0 ) + { + // Put random text: + if( randomAttr && randomAttr->Value() != KDefault ) + { + // Get the random length + TInt len = GetRandomBodyLengthL(randomAttr->Value(), msgTypeAttr->Value()); + if( len != KUndef ) + { + param->iMessageBodyText = iEngine->CreateRandomStringLC(len); + CleanupStack::Pop(); // param->iMessageBodyText + } + } + else + { + // Use default random data + TPtrC temp = iEngine->RandomString(CCreatorEngine::EMessageText); + param->iMessageBodyText = HBufC::NewL(temp.Length()); + param->iMessageBodyText->Des().Copy(temp); + } + } + else + { + param->iMessageBodyText = HBufC::NewL(elemContent.Length()); + param->iMessageBodyText->Des().Copy(elemContent); + } + } + else if( elemName == KAttachmentId ) + { + // Attachment file id + for( TInt amountIndex = 0; amountIndex < fieldAmount; ++amountIndex ) + { + if( randomAttr || elemContent.Length() == 0) + { + //When type is AMS, attachement will be audio + if(param->iMessageType == EAMS) + { + param->iAttachments->AppendL(CCreatorEngine::EMP3_250kB); + } + //Otherwise attachement can be any file + else + { + //EJPEG_25kB is first (0) in the enum and LAST_FILE_ID is last in the enum, so real last item id is one before LAST_FILE_ID + param->iAttachments->AppendL( iEngine->RandomNumber(CCreatorEngine::EJPEG_25kB, CCreatorEngine::LAST_FILE_ID-1) ); + } + } + else + { + //When user has been set attechment by it self, we trust user selection (not validating value, e.g. if message is SMS and there is attachement) + TInt id = iEngine->GetAttachmentIdL(elemContent); + if( id != KUndef ) + { + param->iAttachments->AppendL( id ); + } + } + } + } + // Attachment file path handling + //E.g. C:\data\others\DOC-20kB.doc + else if( elemName == KAttachmentPath ) + { + // Attachment file id + for( TInt amountIndex = 0; amountIndex < fieldAmount; ++amountIndex ) + { + //Path is random, getting one of the files (not even using path attribute, but id with random) + if( randomAttr || elemContent.Length() == 0) + { + //EJPEG_25kB is first (0) in the enum and LAST_FILE_ID is last in the enum, so real last item id is one before LAST_FILE_ID + param->iAttachments->AppendL( iEngine->RandomNumber(CCreatorEngine::EJPEG_25kB, CCreatorEngine::LAST_FILE_ID -1) ); + } + //Otherwise adding attachement path as it is to paths. + else + { + //Adding Attachement file path + HBufC* elemData = elemContent.AllocLC(); + param->iAttachmentPaths.AppendL( elemData ); + CleanupStack::Pop(elemData); + } + } + } + else if ( elemName == KStatus ) + { + if( CompareIgnoreCase( elemContent, KNew ) == 0 ) + { + param->iCreateAsUnread = ETrue; + } + else if( CompareIgnoreCase( elemContent, KRead ) == 0 ) + { + param->iCreateAsUnread = EFalse; + } + } + } + iEngine->AppendToCommandArrayL(ECmdCreateMessagingEntryMessagesViaScript, param); + CleanupStack::Pop(); // param + } + } + else + { + for( TInt i = 0; i < msgAmount; ++i ) + { + TInt randMsg = 0; + if( msgType == KSms ) + randMsg = iEngine->RandomNumber(ECmdCreateRandomEntrySMSInbox, ECmdCreateRandomEntrySMSSent); + else if( msgType == KMms ) + randMsg = iEngine->RandomNumber(ECmdCreateRandomEntryMMSInbox, ECmdCreateRandomEntryMMSSent); + else if( msgType == KAms ) + randMsg = iEngine->RandomNumber(ECmdCreateRandomEntryAMSInbox, ECmdCreateRandomEntryAMSSent); + else if( msgType == KEmail ) + randMsg = iEngine->RandomNumber(ECmdCreateRandomEntryEmailInbox, ECmdCreateRandomEntryEmailSent); + else if( msgType == KSmart ) + randMsg = iEngine->RandomNumber(ECmdCreateRandomEntryBIOInbox, ECmdCreateRandomEntryBIOSent); + else if( msgType == KBt ) + randMsg = iEngine->RandomNumber(ECmdCreateRandomEntryBTInbox, ECmdCreateRandomEntryBTSent); + else if( msgType == KIr ) + randMsg = iEngine->RandomNumber(ECmdCreateRandomEntryIRInbox, ECmdCreateRandomEntryIRSent); + + if( randMsg > 0 ) + { + iEngine->AppendToCommandArrayL(randMsg, 0, 1); + } + } + } + } + +// End of file diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/src/creator_note.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/src/creator_note.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,146 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include "engine.h" +#include "enginewrapper.h" + +#include "creator_note.h" +#include "creator_traces.h" + +//---------------------------------------------------------------------------- + +CNotepadParameters::CNotepadParameters() + { + LOGSTRING("Creator: CNotepadParameters::CNotepadParameters"); + + iNoteText = HBufC::New(KNotepadFieldLength); + } + +CNotepadParameters::~CNotepadParameters() + { + LOGSTRING("Creator: CNotepadParameters::~CNotepadParameters"); + + delete iNoteText; + } + +//---------------------------------------------------------------------------- + +CCreatorNotepad* CCreatorNotepad::NewL(CCreatorEngine* aEngine) + { + CCreatorNotepad* self = CCreatorNotepad::NewLC(aEngine); + CleanupStack::Pop(self); + return self; + } + +CCreatorNotepad* CCreatorNotepad::NewLC(CCreatorEngine* aEngine) + { + CCreatorNotepad* self = new (ELeave) CCreatorNotepad; + CleanupStack::PushL(self); + self->ConstructL(aEngine); + return self; + } + +CCreatorNotepad::CCreatorNotepad() : iFs ( CEikonEnv::Static()->FsSession() ) + { + } + +void CCreatorNotepad::ConstructL(CCreatorEngine* aEngine) + { + LOGSTRING("Creator: CCreatorNotepad::ConstructL"); + + iEngine = aEngine; + iNotepadWrapper = CCreatorNotepadWrapper::NewL(); + } + +CCreatorNotepad::~CCreatorNotepad() + { + LOGSTRING("Creator: CCreatorNotepad::~CCreatorNotepad"); + + if (iParameters) + { + delete iParameters; + iParameters = NULL; + } + + if (iNotepadWrapper) + { + delete iNotepadWrapper; + iNotepadWrapper = NULL; + } + } + +//---------------------------------------------------------------------------- + +TBool CCreatorNotepad::AskDataFromUserL(TInt aCommand) + { + LOGSTRING("Creator: CCreatorNotepad::AskDataFromUserL"); + + CCreatorModuleBase::AskDataFromUserL(aCommand); + + if ( aCommand == ECmdDeleteNotes ) + { + return iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all Notes?"), this, ECreatorModuleDelete ); + } + + // By Creator not supported because + // note id is not available via Notepad API + + return iEngine->GetEngineWrapper()->EntriesQueryDialog( &iEntriesToBeCreated, _L("How many entries to create?"), EFalse, this, ECreatorModuleStart ); + } + + +//---------------------------------------------------------------------------- + +TInt CCreatorNotepad::CreateNoteEntryL(CNotepadParameters *aParameters) + { + LOGSTRING("Creator: CCreatorNotepad::CreateNoteEntryL"); + + // clear any existing parameter definations + delete iParameters; + iParameters = NULL; + + // random data needed if no predefined data available + if (!aParameters) + { + iParameters = new(ELeave) CNotepadParameters; + } + else + { + iParameters = aParameters; + } + + TPtr noteTextPtr = iParameters->iNoteText->Des(); + noteTextPtr.Copy( iEngine->RandomString(CCreatorEngine::EMessageText).Left( noteTextPtr.MaxLength() ) ); + + return iNotepadWrapper->CreateNoteL( noteTextPtr ); + } + +//---------------------------------------------------------------------------- +void CCreatorNotepad::DeleteAllL() + { + LOGSTRING("Creator: CCreatorNotepad::DeleteAllL"); + iNotepadWrapper->DeleteAllL(); + } + +//---------------------------------------------------------------------------- +void CCreatorNotepad::DeleteAllCreatedByCreatorL() + { + LOGSTRING("Creator: CCreatorNotepad::DeleteAllCreatedByCreatorL"); + // Not supported because note id is not available via Notepad API + User::Leave( KErrNotSupported ); + } diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/src/creator_noteelement.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/src/creator_noteelement.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,108 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +#include "creator_noteelement.h" +#include "creator_traces.h" +#include "creator_note.h" + +using namespace creatornote; + +/* + * + */ +CCreatorNoteElement* CCreatorNoteElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext ) + { + CCreatorNoteElement* self = new (ELeave) CCreatorNoteElement(aEngine); + CleanupStack::PushL(self); + self->ConstructL(aName, aContext); + CleanupStack::Pop(self); + return self; + } +/* + * + */ +CCreatorNoteElement::CCreatorNoteElement(CCreatorEngine* aEngine) +: +CCreatorScriptElement(aEngine) + { + iIsCommandElement = ETrue; + } + +void CCreatorNoteElement::ExecuteCommandL() + { + const CCreatorScriptAttribute* amountAttr = FindAttributeByName(KAmount); + TInt noteAmount = 1; + if( amountAttr ) + { + noteAmount = ConvertStrToIntL(amountAttr->Value()); + } + // Get 'fields' element + CCreatorScriptElement* fieldsElement = FindSubElement(KFields); + if( fieldsElement && fieldsElement->SubElements().Count() > 0) + { + // Get sub-elements + const RPointerArray& fields = fieldsElement->SubElements(); + // Create note entries, the amount of entries is defined by noteAmount: + for( TInt cI = 0; cI < noteAmount; ++cI ) + { + CNotepadParameters* param = new (ELeave) CNotepadParameters; + CleanupStack::PushL(param); + + for( TInt i = 0; i < fields.Count(); ++i ) + { + CCreatorScriptElement* field = fields[i]; + TPtrC elemName = field->Name(); + TPtrC elemContent = field->Content(); + const CCreatorScriptAttribute* randomAttr = fields[i]->FindAttributeByName(KRandomLength); + TBool useMax = EFalse; + if( randomAttr && randomAttr->Value() == KMax ) + { + useMax = ETrue; + } + + if( elemName == KText ) + { + if( randomAttr || elemContent.Length() == 0 ) + { + if( useMax ) + { + TDesC* temp = iEngine->CreateRandomStringLC(KNotepadFieldLength); + SetContentToTextParamL(param->iNoteText, *temp); + CleanupStack::PopAndDestroy(); // temp + } + else + { + SetContentToTextParamL(param->iNoteText, iEngine->RandomString(CCreatorEngine::EMessageText)); + } + } + else + { + SetContentToTextParamL(param->iNoteText, elemContent); + } + } + } + iEngine->AppendToCommandArrayL(ECmdCreateMiscEntryNotes, param); + CleanupStack::Pop(); // param + } + } + else + { + iEngine->AppendToCommandArrayL(ECmdCreateMiscEntryNotes, 0, noteAmount); + } + } diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/src/creator_notepadwrapper.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/src/creator_notepadwrapper.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,123 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include +#include "creator_notepadwrapper.h" + + /** + * Constructor + */ +CCreatorNotepadWrapper::CCreatorNotepadWrapper() + { + } + + /** + * Destructor + */ +CCreatorNotepadWrapper::~CCreatorNotepadWrapper() + { + + iNotepadApi = NULL; + + if(iNotesEditorPluginLoader) + { + iNotesEditorPluginLoader->unload(); + delete iNotesEditorPluginLoader; + iNotesEditorPluginLoader = NULL; + } + + if(iAgendaUtil) + { + delete iAgendaUtil; + iAgendaUtil = NULL; + } + } + + /** + * Two-Phased constructor + */ +CCreatorNotepadWrapper* CCreatorNotepadWrapper::NewL() + { + CCreatorNotepadWrapper* self = CCreatorNotepadWrapper::NewLC(); + CleanupStack::Pop(self); + return self; + } + + /** + * Two-Phased constructor + */ +CCreatorNotepadWrapper* CCreatorNotepadWrapper::NewLC() + { + CCreatorNotepadWrapper* self = new (ELeave) CCreatorNotepadWrapper; + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + + /** + * ConstructL() + */ + +void CCreatorNotepadWrapper::ConstructL() + { + iAgendaUtil = new AgendaUtil(); + + // iNotepadApi = new NotesEditor(iAgendaUtil); + + // Load notes editor plugin. + // Launch the notes editor using notes editor plugin api + QDir dir(NOTES_EDITOR_PLUGIN_PATH); + QString pluginName = dir.absoluteFilePath(NOTES_EDITOR_PLUGIN_NAME); + + QT_TRYCATCH_LEAVING( + // Create NotesEditor plugin loader object. + iNotesEditorPluginLoader = new QPluginLoader(pluginName); + + // Load the plugin + bool notesPluginLoaded = iNotesEditorPluginLoader->load(); + QObject *plugin = qobject_cast ( iNotesEditorPluginLoader->instance()); + + iNotepadApi = qobject_cast(plugin); + ); + + } + +TInt CCreatorNotepadWrapper::CreateNoteL( const TDesC& aText ) + { + User::LeaveIfNull(iNotepadApi); + + QString textNote = QString::fromUtf16( aText.Ptr(),aText.Length()); + iNotepadApi->edit(textNote,iAgendaUtil); + iNotepadApi->close(NotesEditorInterface::CloseWithSave, iAgendaUtil); + + return KErrNone; + } +void CCreatorNotepadWrapper::DeleteAllL() + { + + QList ael; + AgendaUtil::FilterFlags filter = AgendaUtil::FilterFlags(AgendaUtil::IncludeNotes); + + ael = iAgendaUtil->fetchAllEntries(filter); + for(int i=0 ; ideleteEntry(ael[i].id()); + } + + } + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/src/creator_phonebook.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/src/creator_phonebook.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,770 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include "engine.h" +#include "enginewrapper.h" +#include "creator_contactsetcache.h" + +#include "creator_phonebook.h" +#include "creator_traces.h" + +#include + +_LIT(KTempPath, "C:\\Data\\Creator\\"); + + +typedef struct { +TInt iFieldCode; +TInt iRandomType; +} DetailFieldInfo; +static const TInt RND_TYPE_UNDEF = -99; +DetailFieldInfo CreatorPbkMiscTextFields[] = { + {CCreatorPhonebookWrapper::EFirstName, (TInt) CCreatorEngine::EFirstName}, + {CCreatorPhonebookWrapper::EFirstNameReading, (TInt) CCreatorEngine::EFirstName}, + {CCreatorPhonebookWrapper::ELastName, (TInt) CCreatorEngine::ESurname}, + {CCreatorPhonebookWrapper::ELastNameReading, (TInt) CCreatorEngine::ESurname}, + {CCreatorPhonebookWrapper::ECompanyName, (TInt) CCreatorEngine::ECompany}, + {CCreatorPhonebookWrapper::EJobTitle, (TInt) CCreatorEngine::EJobTitle}, + {CCreatorPhonebookWrapper::EPrefix, (TInt) CCreatorEngine::EPrefix}, + {CCreatorPhonebookWrapper::ESuffix, (TInt) CCreatorEngine::ESuffix}, + {CCreatorPhonebookWrapper::ESecondName, (TInt) CCreatorEngine::EFirstName}, + {CCreatorPhonebookWrapper::EAddrLabelGen, (TInt) CCreatorEngine::EAddress}, + {CCreatorPhonebookWrapper::EAddrPoGen, (TInt) CCreatorEngine::EPobox}, + {CCreatorPhonebookWrapper::EAddrExtGen, (TInt) CCreatorEngine::EAddress}, + {CCreatorPhonebookWrapper::EAddrStreetGen, (TInt) CCreatorEngine::EAddress}, + {CCreatorPhonebookWrapper::EAddrLocalGen, (TInt) CCreatorEngine::ECity}, + {CCreatorPhonebookWrapper::EAddrRegionGen, (TInt) CCreatorEngine::EState}, + {CCreatorPhonebookWrapper::EAddrPostCodeGen, (TInt) CCreatorEngine::EPostcode}, + {CCreatorPhonebookWrapper::EAddrCountryGen, (TInt) CCreatorEngine::ECountry}, + {CCreatorPhonebookWrapper::EAddrLabelHome, (TInt) CCreatorEngine::EAddress}, + {CCreatorPhonebookWrapper::EAddrPoHome, (TInt) CCreatorEngine::EPobox}, + {CCreatorPhonebookWrapper::EAddrExtHome, (TInt) CCreatorEngine::EAddress}, + {CCreatorPhonebookWrapper::EAddrStreetHome, (TInt) CCreatorEngine::EAddress}, + {CCreatorPhonebookWrapper::EAddrLocalHome, (TInt) CCreatorEngine::ECity}, + {CCreatorPhonebookWrapper::EAddrRegionHome, (TInt) CCreatorEngine::EState}, + {CCreatorPhonebookWrapper::EAddrPostCodeHome, (TInt) CCreatorEngine::EPostcode}, + {CCreatorPhonebookWrapper::EAddrCountryHome, (TInt) CCreatorEngine::ECountry}, + {CCreatorPhonebookWrapper::EAddrLabelWork, (TInt) CCreatorEngine::EAddress}, + {CCreatorPhonebookWrapper::EAddrPoWork, (TInt) CCreatorEngine::EPobox}, + {CCreatorPhonebookWrapper::EAddrExtWork, (TInt) CCreatorEngine::EAddress}, + {CCreatorPhonebookWrapper::EAddrStreetWork, (TInt) CCreatorEngine::EAddress}, + {CCreatorPhonebookWrapper::EAddrLocalWork, (TInt) CCreatorEngine::ECity}, + {CCreatorPhonebookWrapper::EAddrRegionWork, (TInt) CCreatorEngine::EState}, + {CCreatorPhonebookWrapper::EAddrPostCodeWork, (TInt) CCreatorEngine::EPostcode}, + {CCreatorPhonebookWrapper::EAddrCountryWork, (TInt) CCreatorEngine::ECountry}, + {CCreatorPhonebookWrapper::EPoc, (TInt) CCreatorEngine::EPhoneNumber}, + {CCreatorPhonebookWrapper::ESwis, (TInt) CCreatorEngine::EPhoneNumber}, + {CCreatorPhonebookWrapper::ESip, (TInt) CCreatorEngine::EPhoneNumber}, + {CCreatorPhonebookWrapper::EDtmfString, (TInt) CCreatorEngine::EFirstName}, + {CCreatorPhonebookWrapper::ENote,(TInt) CCreatorEngine::EMemoText}, + {CCreatorPhonebookWrapper::EMiddleName, (TInt) CCreatorEngine::EFirstName}, + {CCreatorPhonebookWrapper::EDepartment, (TInt) CCreatorEngine::ECompany}, + {CCreatorPhonebookWrapper::EAsstName, (TInt) CCreatorEngine::EFirstName}, + {CCreatorPhonebookWrapper::ESpouse, (TInt) CCreatorEngine::EFirstName}, + {CCreatorPhonebookWrapper::EChildren, (TInt) CCreatorEngine::EFirstName}, + {CCreatorPhonebookWrapper::ESyncClass, RND_TYPE_UNDEF}, + {CCreatorPhonebookWrapper::ELocPrivacy, RND_TYPE_UNDEF}, + {CCreatorPhonebookWrapper::EGenLabel, (TInt) CCreatorEngine::EFirstName}, + {CCreatorPhonebookWrapper::EWVAddress, (TInt) CCreatorEngine::EPhoneNumber}, + {CCreatorPhonebookWrapper::ERingTone, RND_TYPE_UNDEF}, + {CCreatorPhonebookWrapper::EThumbnailPic, RND_TYPE_UNDEF}, + {CCreatorPhonebookWrapper::ECallerObjText, (TInt) CCreatorEngine::EFirstName} + }; + + +TInt CreatorPbkBinaryFields[] = { + CCreatorPhonebookWrapper::ECallerObjImg//, + //R_VPBK_FIELD_TYPE_THUMBNAILPATH + }; + +TInt CreatorPbkDateTimeFields[] = { + CCreatorPhonebookWrapper::EAnniversary + }; + +//---------------------------------------------------------------------------- +TInt CreatorPbkPhoneNumberFields[] = + { + CCreatorPhonebookWrapper::ELandPhoneGen, + CCreatorPhonebookWrapper::ELandPhoneHome, + CCreatorPhonebookWrapper::ELandPhoneWork, + CCreatorPhonebookWrapper::EMobilePhoneGen, + CCreatorPhonebookWrapper::EMobilePhoneHome, + CCreatorPhonebookWrapper::EMobilePhoneWork, + CCreatorPhonebookWrapper::EFaxNumberGen, + CCreatorPhonebookWrapper::EFaxNumberHome, + CCreatorPhonebookWrapper::EFaxNumberWork, + CCreatorPhonebookWrapper::EPagerNumber, + CCreatorPhonebookWrapper::EVideoNumberGen, + CCreatorPhonebookWrapper::EVideoNumberHome, + CCreatorPhonebookWrapper::EVideoNumberWork, + CCreatorPhonebookWrapper::EVoipGen, + CCreatorPhonebookWrapper::EVoipHome, + CCreatorPhonebookWrapper::EVoipWork, + CCreatorPhonebookWrapper::EAsstPhone, + CCreatorPhonebookWrapper::ECarPhone + }; + +TInt CreatorPbkUrlFields[] = + { + CCreatorPhonebookWrapper::EUrlGen, + CCreatorPhonebookWrapper::EUrlHome, + CCreatorPhonebookWrapper::EUrlWork + }; + +TInt CreatorPbkEmailFields[] = + { + CCreatorPhonebookWrapper::EEmailGen, + CCreatorPhonebookWrapper::EEmailHome, + CCreatorPhonebookWrapper::EEmailWork + }; + +CPhonebookParameters::CPhonebookParameters() + { + LOGSTRING("Creator: CPhonebookParameters::CVirtualPhonebookParameters"); + iGroupName = HBufC::New(KPhonebookFieldLength); + } + +CPhonebookParameters::~CPhonebookParameters() + { + LOGSTRING("Creator: CPhonebookParameters::~CPhonebookParameters"); + + delete iGroupName; + for( TCreatorContactFields::iterator it = iContactFields.begin(); it != iContactFields.end(); ++it) + { + HBufC* temp = (*it).second; + iContactFields.erase(it); + delete temp; + } + iLinkIds.Reset(); + iLinkIds.Close(); + } + +void CPhonebookParameters::ParseL(CCommandParser* /*parser*/, TParseParams /*aCase = 0*/) + { + } + +TInt CPhonebookParameters::ScriptLinkId() const + { + return iLinkId; + } + +void CPhonebookParameters::SetScriptLinkId(TInt aLinkId) + { + iLinkId = aLinkId; + } + + +//---------------------------------------------------------------------------- + +CCreatorPhonebook* CCreatorPhonebook::NewL(CCreatorEngine* aEngine) + { + CCreatorPhonebook* self = CCreatorPhonebook::NewLC(aEngine); + CleanupStack::Pop(self); + return self; + } + +CCreatorPhonebook* CCreatorPhonebook::NewLC(CCreatorEngine* aEngine) + { + CCreatorPhonebook* self = new (ELeave) CCreatorPhonebook(); + CleanupStack::PushL(self); + self->ConstructL(aEngine); + return self; + } + + +CCreatorPhonebook::CCreatorPhonebook() + { + iAddAllFields = EFalse; + } + +void CCreatorPhonebook::ConstructL(CCreatorEngine* aEngine) + { + LOGSTRING("Creator: CCreatorPhonebook::ConstructL"); + + iEngine = aEngine; + + iPhonebookWrapper = CCreatorPhonebookWrapper::NewL(); + + SetDefaultParameters(); + } + + +CCreatorPhonebook::~CCreatorPhonebook() + { + LOGSTRING("Creator: CCreatorPhonebook::~CCreatorPhonebook"); + + if ( iContactsToDelete.Count() ) + { + TRAP_IGNORE( StoreLinksForDeleteL( iContactsToDelete, KUidDictionaryUidContacts ) ); + } + if ( iContactGroupsToDelete.Count() ) + { + TRAP_IGNORE( StoreLinksForDeleteL( iContactGroupsToDelete, KUidDictionaryUidContactGroups ) ); + } + + if( iPhonebookWrapper ) + { + delete iPhonebookWrapper; + } + + if (iParameters) + { + delete iParameters; + } + + } + +//---------------------------------------------------------------------------- + +TInt CCreatorPhonebook::CreateContactEntryL(CCreatorModuleBaseParameters *aParameters) + { + TInt err = KErrNone; + delete iParameters; + iParameters = 0; + CPhonebookParameters* parameters = 0; + + if( aParameters == 0 ) + { + InitializeContactParamsL(); + parameters = iParameters; + } + else + { + parameters = (CPhonebookParameters*) aParameters; + } + + int numberOfFields = parameters->iContactFields.size(); + // create a new contact item + + TUint32 contactId = iPhonebookWrapper->CreateContactEntryL( parameters->iContactFields ); //wrapper should return contact id to store + iContactsToDelete.AppendL( contactId ); + + + // If this contact has a link id in script (i.e. belongs to a contact-set), we must cache the contact id: + if( parameters->ScriptLinkId() > 0 ) + { + RPointerArray& contactsets = ContactLinkCache::Instance()->ContactSets(); + TBool setFound(EFalse); + for(TInt i = 0; i < contactsets.Count(); ++i ) + { + if( contactsets[i]->LinkId() == parameters->ScriptLinkId() ) + { + if( contactId ) + { + contactsets[i]->AppendL( contactId ); + iContactLinkArray.AppendL( contactId ); + } + setFound = ETrue; + break; + } + } + if( !setFound ) + { + LOGSTRING2("Error: Contact set id %d not found.", parameters->ScriptLinkId()); + } + } + + return err; + } + + +//---------------------------------------------------------------------------- + + + +//---------------------------------------------------------------------------- + +void CCreatorPhonebook::DeleteAllL() + { + iPhonebookWrapper->DeleteAllL(); + } + +//---------------------------------------------------------------------------- +void CCreatorPhonebook::DeleteAllCreatedByCreatorL() + { + LOGSTRING("Creator: CCreatorPhonebook::DeleteAllCreatedByCreatorL"); + DeleteItemsCreatedWithCreatorL( KUidDictionaryUidContacts ); + } + +//---------------------------------------------------------------------------- +void CCreatorPhonebook::DeleteAllGroupsL() + { + LOGSTRING("Creator: CCreatorPhonebook::DeleteAllGroupsL"); + iPhonebookWrapper->DeleteAllGroupsL(); + } + +//---------------------------------------------------------------------------- +void CCreatorPhonebook::DeleteAllGroupsCreatedByCreatorL() + { + LOGSTRING("Creator: CCreatorPhonebook::DeleteAllGroupsCreatedByCreatorL"); + DeleteItemsCreatedWithCreatorL( KUidDictionaryUidContactGroups ); + } + +//---------------------------------------------------------------------------- +void CCreatorPhonebook::DeleteContactsL( RArray& aContactsToDelete, TUid aStoreUid ) + { + iPhonebookWrapper->DeleteContactsL( aContactsToDelete, aStoreUid ); + } + +//---------------------------------------------------------------------------- + + +void CCreatorPhonebook::DeleteItemsCreatedWithCreatorL( TUid aStoreUid ) + { + CDictionaryFileStore* store = iEngine->FileStoreLC(); + User::LeaveIfNull( store ); + + RArray contacts; + // backup previous contact links from store + // otherwise they would be overwritten when calling out.WriteL + TUint32 creatorLink; + if ( store->IsPresentL( aStoreUid ) ) + { + RDictionaryReadStream in; + in.OpenLC( *store, aStoreUid ); + TRAP_IGNORE( + do{ + creatorLink = in.ReadUint32L(); + contacts.AppendL( creatorLink ); + }while( creatorLink ); + ); + + CleanupStack::PopAndDestroy(); // in + } + + + iPhonebookWrapper->DeleteContactsL( contacts, aStoreUid ); + + store->Remove( aStoreUid ); + store->CommitL(); + + CleanupStack::PopAndDestroy( store ); + } + +//---------------------------------------------------------------------------- +void CCreatorPhonebook::DoDeleteItemsCreatedWithCreatorL( TUid /*aStoreUid*/, CDictionaryFileStore* /*aStore*/ ) + { + + } + +//---------------------------------------------------------------------------- +TBool CCreatorPhonebook::HasOtherThanGroupsL() + { + LOGSTRING("Creator: CCreatorPhonebook::HasOtherThanGroupsL"); + TBool result( EFalse ); + return result; + } + + +//---------------------------------------------------------------------------- + + +//---------------------------------------------------------------------------- +void CCreatorPhonebook::StoreLinksForDeleteL( RArray& aLinks, TUid aStoreUid ) + { + LOGSTRING("Creator: CCreatorPhonebook::StoreLinksForDeleteL"); + CDictionaryFileStore* store = iEngine->FileStoreLC(); + User::LeaveIfNull( store ); + + // backup previous contact links from store + // otherwise they would be overwritten when calling out.WriteL + TUint32 previousLink; + if ( store->IsPresentL( aStoreUid ) ) + { + RDictionaryReadStream in; + in.OpenLC( *store, aStoreUid ); + bool r = false; + TRAP_IGNORE( + do{ //iContactMngr->CreateLinksLC( in )) != NULL ) // will leave with KErrEof + previousLink = in.ReadUint32L(); + iPreviousDeleteLinks.AppendL( previousLink ); + if(previousLink) + { + r=true; + } + else + { + r=false; + } + }while(r==true); ); + + CleanupStack::PopAndDestroy(); // in + } + + RDictionaryWriteStream out; + out.AssignLC( *store, aStoreUid ); + + // restore previous links + for ( TInt i = 0; i < iPreviousDeleteLinks.Count(); i++ ) + { + out.WriteUint32L( iPreviousDeleteLinks[i] ); + } + + // write new links + for(int i=0; i < aLinks.Count(); i++) + { + out.WriteUint32L( aLinks[i] ); + } + out.CommitL(); + CleanupStack::PopAndDestroy(); // out + + store->CommitL(); + + CleanupStack::PopAndDestroy( store ); + } + +//---------------------------------------------------------------------------- +//---------------------------------------------------------------------------- + +void CCreatorPhonebook::InitializeContactParamsL() + { + LOGSTRING("Creator: CCreatorPhonebook::InitializeContactParamsL"); + + iParameters = new (ELeave) CPhonebookParameters; + + iParameters->iNumberOfPhoneNumberFields = iNumberOfPhoneNumberFields; + iParameters->iNumberOfURLFields = iNumberOfURLFields; + iParameters->iNumberOfEmailAddressFields = iNumberOfEmailAddressFields; + + TPtrC fname = iEngine->RandomString(CCreatorEngine::EFirstName); + TPtrC lname = iEngine->RandomString(CCreatorEngine::ESurname); + + + if( iAddAllFields ) + { + TInt textFieldCount = sizeof(CreatorPbkMiscTextFields) / sizeof(DetailFieldInfo); + for( TInt tfIndex = 0; tfIndex < textFieldCount; ++tfIndex ) + { + CCreatorContactField* field = CCreatorContactField::NewL(); + CleanupStack::PushL(field); + field->AddFieldToParamL( iEngine,iParameters, CreatorPbkMiscTextFields[tfIndex].iFieldCode, CreatorPbkMiscTextFields[tfIndex].iRandomType ); + CleanupStack::Pop(field); + } + + // Add binary fields: + + RFs& fs = CCoeEnv::Static()->FsSession(); + + TBuf srcPath; + iEngine->RandomPictureFileL(srcPath); + TBuf destPath(KTempPath); + + if(!BaflUtils::FolderExists( fs, destPath )) + { + BaflUtils::EnsurePathExistsL( fs, destPath ); + } + + TInt err=BaflUtils::CopyFile( fs, srcPath, destPath ); + + TParse temp; + temp.Set( srcPath,NULL,NULL ); + destPath.Append(temp.NameAndExt()); + TPtrC picture; + picture.Set(destPath); + CCreatorContactField* picturefield = CCreatorContactField::NewL(); + CleanupStack::PushL(picturefield); + picturefield->AddFieldToParamL( iParameters, CCreatorPhonebookWrapper::EThumbnailPic, picture ); + CleanupStack::Pop(picturefield); + // Add date-time fields: + TPtrC anniv; + TBuf<20> timeString; + TTime datetime = iEngine->RandomDate( CCreatorEngine::EDateFuture ); + _LIT(KDateString,"%D%M%Y%/0%1%/1%2%/2%3%/3"); + TRAP_IGNORE( datetime.FormatL(timeString, KDateString) ); + + anniv.Set(timeString); + + CCreatorContactField* fieldAnniv = CCreatorContactField::NewL(); + CleanupStack::PushL( fieldAnniv ); + fieldAnniv->AddFieldToParamL(iParameters,CCreatorPhonebookWrapper::EAnniversary, anniv ); + CleanupStack::Pop( fieldAnniv ); + //*************************************************************************** + + } + else + { + CCreatorContactField* field = CCreatorContactField::NewL(); + CleanupStack::PushL(field); + field->AddFieldToParamL( iParameters, CCreatorPhonebookWrapper::EFirstName, fname ); + field->AddFieldToParamL( iParameters, CCreatorPhonebookWrapper::ELastName, lname ); + CleanupStack::Pop(field); + } + + // Phone numbers: + TInt phoneFieldCount = sizeof(CreatorPbkPhoneNumberFields) / sizeof(TInt); + + TInt inc=0; + for( TInt i=0; i= phoneFieldCount ) + { + inc = 0; + } + + CCreatorContactField* field = CCreatorContactField::NewL(); + CleanupStack::PushL(field); + field->AddFieldToParamL(iEngine, iParameters, CreatorPbkPhoneNumberFields[inc] ); + CleanupStack::Pop(field); + + inc++; + } + + + + // URLs: + TInt urlFieldCount = sizeof(CreatorPbkUrlFields) / sizeof(TInt); + inc = 0; + for( TInt i=0; i= urlFieldCount ) + { + inc = 0; + } + + CCreatorContactField* field = CCreatorContactField::NewL(); + CleanupStack::PushL(field); + field->AddFieldToParamL(iEngine, iParameters, CreatorPbkUrlFields[inc] ); + CleanupStack::Pop(field); + inc++; + } + + // EMail addresses: + TInt emailFieldCount = sizeof(CreatorPbkEmailFields) / sizeof(TInt); + inc = 0; + for( int i=0; i= emailFieldCount ) + { + inc = 0; + } + CCreatorContactField* field = CCreatorContactField::NewL(); + CleanupStack::PushL(field); + field->AddFieldToParamL(iEngine, iParameters, CreatorPbkEmailFields[inc] ); + CleanupStack::Pop(field); + inc++; + } + + TestPrintOut(iParameters); + + } + +void CCreatorPhonebook::TestPrintOut(CPhonebookParameters* aParam) + { + LOGSTRING("Creator: CCreatorPhonebook::TestPrintOut"); + for( TCreatorContactFields::iterator it = aParam->iContactFields.begin(); it != aParam->iContactFields.end(); ++it) + { + HBufC* temp = (*it).second; + if(temp) + { + LOGSTRING3("Type: %d Content:%S ", (*it).first, &temp->Des() ); + } + } + } + +// Checks if the link is a group or not +TBool CCreatorPhonebook::IsContactGroupL( TUint32& /*aLink*/ ) + { + //not used right now + return EFalse; + } + + +TInt CCreatorPhonebook::CreateGroupEntryL(CCreatorModuleBaseParameters *aParameters) + { + LOGSTRING("Creator: CCreatorPhonebook::CreateGroupEntryL"); + TInt err = KErrNone; + + delete iParameters; + iParameters = 0; + + CPhonebookParameters* parameters = (CPhonebookParameters*) aParameters; + + if( !parameters ) + { + iParameters = new (ELeave) CPhonebookParameters; + iParameters->iContactsInGroup = iContactsInGroup; + iParameters->iGroupName->Des().Copy( iEngine->RandomString(CCreatorEngine::EGroupName) ); + iParameters->iGroupName->Des().Append( _L(" #") ); + iParameters->iGroupName->Des().AppendNum( iEngine->RandomNumber(1000, 9999) ); + parameters = iParameters; + } + + // create a new contact group + + TUint32 newGroupId = iPhonebookWrapper->CreateGroupEntryL( parameters->iGroupName ); + + // define amounts of contacts to be added to the group + TInt amountOfContactsToBeAdded = 0; + if (parameters->iContactsInGroup == KCreateRandomAmountOfGroups) + { + amountOfContactsToBeAdded = iEngine->RandomNumber(30); + } + else + { + amountOfContactsToBeAdded = parameters->iContactsInGroup; + } + + if( parameters->iLinkIds.Count() > 0 ) + { + for( TInt i = 0; i < parameters->iLinkIds.Count(); ++i ) + { + const CCreatorContactSet& set = ContactLinkCache::Instance()->ContactSet(parameters->iLinkIds[i].iLinkId); + + const RArray links = set.ContactLinks();//ContactLinkCache::Instance()->ContactSets();//set.ContactLinks(); + TInt numberOfExplicitLinks = links.Count(); // Number of defined contacts in contact-set + TInt numberOfExistingContacts = set.NumberOfExistingContacts(); // Number of existing contacts in contact-set + TInt maxAmount = numberOfExplicitLinks + numberOfExistingContacts; + + if( parameters->iLinkIds[i].iLinkAmount > 0 ) + maxAmount = parameters->iLinkIds[i].iLinkAmount; // Max amount is limited + + TInt addedMembers = 0; + + for( TInt j = 0; j < links.Count() && addedMembers < maxAmount; ++j ) + { + + addedMembers += iPhonebookWrapper->AddContactToGroup(newGroupId,links[j]); + + } + if( addedMembers < maxAmount ) + { + // Add existing contacts, withing the limits set by maxAmount: + amountOfContactsToBeAdded += maxAmount - addedMembers; + } + } + } + if( amountOfContactsToBeAdded > 0 ) + { + TInt addedContacts = iPhonebookWrapper->AddToGroup(newGroupId, amountOfContactsToBeAdded); + + } + + // store the link to contact, so that Creator is able to delete + // it when user requests deletion of contacts that were created with Creator + iContactGroupsToDelete.AppendL( newGroupId ); + + return err; + } + +//---------------------------------------------------------------------------- + +TInt CCreatorPhonebook::CreateSubscribedContactEntryL(CCreatorModuleBaseParameters* /*aParameters*/) + { + LOGSTRING("Creator: CCreatorPhonebook::CreateSubscribedContactEntryL"); + + return KErrNotSupported; + } + +//---------------------------------------------------------------------------- + +CCreatorContactField::CCreatorContactField() + { + } +CCreatorContactField::~CCreatorContactField() + { + } + +CCreatorContactField* CCreatorContactField::NewL() + { + CCreatorContactField* self = new (ELeave) CCreatorContactField(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } +void CCreatorContactField::ConstructL() + { + } + + +void CCreatorContactField::AddFieldToParamL( CCreatorEngine* aEngine, CPhonebookParameters* aParam, TInt aType, TInt aRand ) + { + HBufC* content = NULL; + if( aRand == KErrNotFound ) + { + TInt textFieldCount = sizeof(CreatorPbkPhoneNumberFields)/sizeof(TInt);; + for( TInt tfIndex = 0; tfIndex < textFieldCount; ++tfIndex ) + { + if( CreatorPbkPhoneNumberFields[tfIndex] == aType ) + { + content = aEngine->RandomString(CCreatorEngine::EPhoneNumber).AllocL(); + break; + } + } + + textFieldCount = sizeof(CreatorPbkUrlFields)/sizeof(TInt);; + for( TInt tfIndex = 0; tfIndex < textFieldCount; ++tfIndex ) + { + if( CreatorPbkUrlFields[tfIndex] == aType ) + { + content = aEngine->CreateHTTPUrlLC(); + CleanupStack::Pop(); + break; + } + } + textFieldCount = sizeof(CreatorPbkEmailFields)/sizeof(TInt);; + for( TInt tfIndex = 0; tfIndex < textFieldCount; ++tfIndex ) + { + if( CreatorPbkEmailFields[tfIndex] == aType ) + { + content = aEngine->CreateEmailAddressLC(); + CleanupStack::Pop(); + break; + } + } + + + //if there is textfield without specified random number + textFieldCount = sizeof(CreatorPbkMiscTextFields) / sizeof(DetailFieldInfo); + for( TInt tfIndex = 0; tfIndex < textFieldCount; ++tfIndex ) + { + if( CreatorPbkMiscTextFields[tfIndex].iFieldCode == aType && CreatorPbkMiscTextFields[tfIndex].iRandomType != RND_TYPE_UNDEF ) + { + TInt rand = CreatorPbkMiscTextFields[tfIndex].iRandomType; + content = aEngine->RandomString((CCreatorEngine::TRandomStringType) rand).AllocL(); + break; + } + } + } + + if( aRand != KErrNotFound && aRand != RND_TYPE_UNDEF ) + { + TInt textFieldCount = sizeof(CreatorPbkMiscTextFields) / sizeof(DetailFieldInfo); + for( TInt tfIndex = 0; tfIndex < textFieldCount; ++tfIndex ) + { + if( CreatorPbkMiscTextFields[tfIndex].iFieldCode == aType ) + { + content = aEngine->RandomString((CCreatorEngine::TRandomStringType) aRand).AllocL(); + } + } + } + + aParam->iContactFields.insert( TCreatorContactField(aType, content) ); + } + +void CCreatorContactField::AddFieldToParamL( CPhonebookParameters* aParam, TInt aType, TPtrC aContent ) + { + aParam->iContactFields.insert( TCreatorContactField(aType, aContent.AllocL()) ); + } + +//---------------------------------------------------------------------------- + +//---------------------------------------------------------------------------- + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/src/creator_phonebookapi.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/src/creator_phonebookapi.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,189 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "creator_phonebookapi.h" + +CCreatorPhonebookAPI::CCreatorPhonebookAPI () + { + mContactMngr = new QContactManager("symbian"); + } + +CCreatorPhonebookAPI::~CCreatorPhonebookAPI () + { + if( mContactMngr ) + { + delete mContactMngr; + mContactMngr = NULL; + } + } + +quint32 CCreatorPhonebookAPI::saveContact( const QList& list ) + { + // create a new contact item + QContact store; + quint32 id; + for(int i = 0 ; i < list.count() ; i++ ) + { + QContactDetail cntdetail = list.at(i); + store.saveDetail(&cntdetail); + } + /*foreach( QContactDetail cntdetail, list ) + { + store.saveDetail( &cntdetail ); + } + */ + mContactMngr->saveContact( &store ); + id = store.localId(); + return id; + } + +quint32 CCreatorPhonebookAPI::createGroup( const QString& groupName ) + { + QContact newGroup; + newGroup.setType(QContactType::TypeGroup); + QContactName newGroupName; + newGroupName.setCustomLabel( groupName ); + newGroup.saveDetail(&newGroupName); + mContactMngr->saveContact(&newGroup); + return newGroup.localId(); + } + +int CCreatorPhonebookAPI::numberOfContacts() + { + QList contacts = mContactMngr->contactIds(); + return contacts.count(); + + } + +bool CCreatorPhonebookAPI::IsContactGroupL( const QContact& contact ) + { + + if( contact.type() == QContactType::TypeGroup ) + { + return true; + } + return false; + } + +int CCreatorPhonebookAPI::addContactToGroup( QContactLocalId group, QContactLocalId contact ) + { + QContact newGroup = mContactMngr->contact( group ); + QContact contactLink = mContactMngr->contact( contact ); + int ret = 0; + if( contact && IsContactGroupL( contactLink ) == false ) + { + QList relationships = contactLink.relationships(QContactRelationship::HasMember); + if( !relationships.count() && contactLink.type() == QContactType::TypeContact ) //just for contacts that are not in relationship - not in group yet + { + QContactRelationship* contactRel = new QContactRelationship(); + contactRel->setRelationshipType(QContactRelationship::HasMember); + contactRel->setFirst(newGroup.id()); + contactRel->setSecond( contactLink.id() ); + mContactMngr->saveRelationship( contactRel ); + delete contactRel; + ret++; + } + } + return ret; + } +int CCreatorPhonebookAPI::addToGroup(QContactLocalId group, int amount) + { + QList contacts = mContactMngr->contactIds(); + int ret = 0; + int tmp = 0; + int cnt = 0; + + for( int i=0; cnt < amount && i < contacts.count() ; i++ ) + { + QContact contact = mContactMngr->contact( mContactMngr->contactIds().at(i) ); + if( contact.type() == QContactType::TypeContact ) + { + tmp = addContactToGroup(group,mContactMngr->contactIds().at(i)); + ret += tmp; + if(tmp) + { + cnt++; + tmp = 0; + } + } + } + return ret; + } + + +bool CCreatorPhonebookAPI::deleteAllContacts() + { + QList all = mContactMngr->contactIds(); + return deleteContacts( all ); + } + +bool CCreatorPhonebookAPI::deleteAllContacts( const QString& type ) + { + QList contactsToDelete; + QList contacts = mContactMngr->contactIds(); + foreach(QContactLocalId contactId, contacts) + { + QContact contact = mContactMngr->contact( contactId ); + if( contact.type() == type ) + { + contactsToDelete.append( contact.localId() ); + } + } + return deleteContacts( contactsToDelete ); + } + + +bool CCreatorPhonebookAPI::deleteContacts( const QList& list ) + { + QMap errorMap; + return mContactMngr->removeContacts( list, &errorMap ); + } + +QContact CCreatorPhonebookAPI::contact( const QContactLocalId& contactId ) + { + return mContactMngr->contact( contactId ); + } + +QString CCreatorPhonebookAPI::phoneNumber( const QContactLocalId& contactId ) + { + QString strNumber; + QContact contact = mContactMngr->contact( contactId ); + if( !contact.isEmpty() ) + { + QContactPhoneNumber phoneNumber = static_cast( contact.detail( QContactPhoneNumber::DefinitionName ) ); + strNumber = phoneNumber.number(); + } + return strNumber; + } + +bool CCreatorPhonebookAPI::contactDetails( const QContactLocalId& contactId, QString& name, QString& phoneNumber, QString& email ) + { + bool success(false); + QContact contact = mContactMngr->contact( contactId ); + if( !contact.isEmpty() ) + { + QContactPhoneNumber contactPhoneNumber = static_cast( contact.detail( QContactPhoneNumber::DefinitionName ) ); + phoneNumber = contactPhoneNumber.number(); + QContactEmailAddress contactEmailAddress = static_cast( contact.detail( QContactEmailAddress::DefinitionName ) ); + email = contactEmailAddress.emailAddress(); + QContactDisplayLabel contactDisplayLabel = static_cast( contact.detail( QContactDisplayLabel::DefinitionName ) ); + name = contactDisplayLabel.label(); + success = true; + } + return success; + } +// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/src/creator_phonebookbase.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/src/creator_phonebookbase.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,154 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "engine.h" +#include "enginewrapper.h" +#include "creator_phonebookbase.h" +#include "creator_traces.h" + +void CCreatorPhonebookBase::QueryDialogClosedL(TBool aPositiveAction, TInt aUserData) + { + LOGSTRING("Creator: CCreatorPhonebookBase::QueryDialogClosedL"); + + if(aPositiveAction == EFalse && aUserData!=ECreatorPhonebookGetContactFields && aUserData!=ECreatorPhonebookContactsAllFields ) + { + iEngine->ShutDownEnginesL(); + return; + } + + const TDesC* showText = &KSavingText; + TBool finished(EFalse); + TBool retval(ETrue); + switch(aUserData) + { + case ECreatorPhonebookDelete: + showText = &KDeletingText; + finished = ETrue; + iEntriesToBeCreated = 1; + break; + case ECreatorPhonebookStart: + if(iCommand == ECmdCreatePhoneBookEntryContacts ) + { + retval = iEngine->GetEngineWrapper()->ListQueryDialog(_L("Fields in contact"), R_CONTACT_CREATION_TYPE_QUERY, + &iDummy, this, ECreatorPhonebookGetContactFields ); + } + else + { + retval = iEngine->GetEngineWrapper()->ListQueryDialog(_L("Number of contacts "), R_GROUP_CREATION_TYPE_QUERY, + &iDummy, this, ECreatorPhonebookGetGroupFields ); + } + break; + case ECreatorPhonebookGetContactFields: + if(iDummy==0)// first item, use default fields + + { + iDefaultFieldsSelected = ETrue; + finished = ETrue; + } + else + { + retval = iEngine->GetEngineWrapper()->EntriesQueryDialog(&iNumberOfPhoneNumberFields, _L("Amount of phone number fields in one contact?"), + ETrue, this, ECreatorPhonebookGetPhoneNumbersCount + ); + } + break; + case ECreatorPhonebookGetPhoneNumbersCount: + retval = iEngine->GetEngineWrapper()->EntriesQueryDialog(&iNumberOfURLFields, _L("Amount of URL fields in one contact?"), + ETrue, this, ECreatorPhonebookGetUrlsCount + ); + break; + case ECreatorPhonebookGetUrlsCount: + retval = iEngine->GetEngineWrapper()->EntriesQueryDialog(&iNumberOfEmailAddressFields, _L("Amount of email fields in one contact?"), + ETrue, this, ECreatorPhonebookGetEmailsCount + ); + break; + case ECreatorPhonebookGetEmailsCount: + retval = iEngine->GetEngineWrapper()->YesNoQueryDialog(_L("Add all the other fields to contacts?"), this, ECreatorPhonebookContactsAllFields); + break; + case ECreatorPhonebookContactsAllFields: + iAddAllFields = aPositiveAction; + // finaly we have all informations from user, start engine + finished = ETrue; + break; + case ECreatorPhonebookGetGroupFields: + iContactsInGroup = KCreateRandomAmountOfGroups; + if(iDummy==0)// first item, use default fields + { + finished = ETrue; + } + else + { + retval = iEngine->GetEngineWrapper()->EntriesQueryDialog(&iContactsInGroup, _L("Amount of contacts in one group?"), + ETrue, this, ECreatorPhonebookGetContactsInGroup); + } + break; + case ECreatorPhonebookGetContactsInGroup: + // finaly we have all informations from user, start engine + finished = ETrue; + break; + default: + //some error + retval = EFalse; + break; + } + if( retval == EFalse ) + { + iEngine->ShutDownEnginesL(); + } + else if( finished ) + { + // add this command to command array + iEngine->AppendToCommandArrayL(iCommand, NULL, iEntriesToBeCreated); + // started exucuting commands + iEngine->ExecuteFirstCommandL( *showText ); + } + } + +TBool CCreatorPhonebookBase::AskDataFromUserL(TInt aCommand) + { + LOGSTRING("Creator: CCreatorPhonebookBase::AskDataFromUserL"); + iCommand = aCommand; + + if( aCommand == ECmdDeleteContacts ) + { + return iEngine->GetEngineWrapper()->YesNoQueryDialog(_L("Delete all contacts?"), this, ECreatorPhonebookDelete ); + } + if( aCommand == ECmdDeleteCreatorContacts ) + { + return iEngine->GetEngineWrapper()->YesNoQueryDialog(_L("Delete all contacts created with Creator?"), this, ECreatorPhonebookDelete ); + } + if( aCommand == ECmdDeleteContactGroups ) + { + return iEngine->GetEngineWrapper()->YesNoQueryDialog(_L("Delete all contact groups?"), this, ECreatorPhonebookDelete ); + } + if( aCommand == ECmdDeleteCreatorContactGroups ) + { + return iEngine->GetEngineWrapper()->YesNoQueryDialog(_L("Delete all contact groups created with Creator?"), this, ECreatorPhonebookDelete ); + } + // display queries + return iEngine->GetEngineWrapper()->EntriesQueryDialog( &iEntriesToBeCreated, _L("How many entries to create?"), EFalse, this, ECreatorPhonebookStart); // ask number of entries to create + } + + +void CCreatorPhonebookBase::SetDefaultParameters() + { + iNumberOfPhoneNumberFields = 1; + iNumberOfURLFields = 0; + iNumberOfEmailAddressFields = 0; + iContactsInGroup = 50; + iDefaultFieldsSelected = EFalse; + } diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/src/creator_phonebookwrapper.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/src/creator_phonebookwrapper.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,661 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include "engine.h" +#include "enginewrapper.h" +#include "creator_contactsetcache.h" + +#include "creator_phonebookwrapper.h" +#include "creator_traces.h" + +#include + +typedef struct { +TInt iFieldCode; +QString iDetail; +QString iFieldContext; +QString iFieldString; +} QDetailFieldInfo; +//static const TInt RND_TYPE_UNDEF = -99; +QDetailFieldInfo CreatorPbkTextFields[] = { + { (TInt)CCreatorPhonebookWrapper::EFirstName,(QContactName::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactName::FieldFirstName).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::ELastName,(QContactName::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactName::FieldLastName).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::ECompanyName,(QContactOrganization::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactOrganization::FieldName).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::EJobTitle,(QContactOrganization::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactOrganization::FieldTitle).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::EPrefix,(QContactName::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactName::FieldPrefix).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::ESuffix,(QContactName::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactName::FieldSuffix).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::EMiddleName,(QContactName::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactName::FieldMiddleName).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::EAddrStreetHome,(QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactAddress::FieldStreet).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::EAddrLocalHome,(QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactAddress::FieldLocality).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::EAddrRegionHome,(QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactAddress::FieldRegion).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::EAddrPostCodeHome,(QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactAddress::FieldPostcode).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::EAddrCountryHome,(QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactAddress::FieldCountry).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::EAddrStreetGen,(QContactAddress::DefinitionName).operator QString(), "", (QContactAddress::FieldStreet).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::EAddrLocalGen,(QContactAddress::DefinitionName).operator QString(), "", (QContactAddress::FieldLocality).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::EAddrRegionGen,(QContactAddress::DefinitionName).operator QString(), "", (QContactAddress::FieldRegion).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::EAddrPostCodeGen,(QContactAddress::DefinitionName).operator QString(), "", (QContactAddress::FieldPostcode).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::EAddrCountryGen,(QContactAddress::DefinitionName).operator QString(), "", (QContactAddress::FieldCountry).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::EAddrStreetWork,(QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactAddress::FieldStreet).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::EAddrLocalWork,(QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactAddress::FieldLocality).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::EAddrRegionWork,(QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactAddress::FieldRegion).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::EAddrPostCodeWork,(QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactAddress::FieldPostcode).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::EAddrCountryWork,(QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactAddress::FieldCountry).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::EMobilePhoneWork,(QContactPhoneNumber::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactPhoneNumber::SubTypeMobile).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::ELandPhoneWork,(QContactPhoneNumber::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactPhoneNumber::SubTypeLandline).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::ENote,(QContactNote::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactNote::FieldNote).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::EDepartment,(QContactOrganization::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactOrganization::FieldDepartment).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::EAsstName,(QContactOrganization::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactOrganization::FieldAssistantName).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::ESpouse,(QContactFamily::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactFamily::FieldSpouse).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::EChildren,(QContactFamily::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactFamily::FieldChildren).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::EGenLabel,(QContactName::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactName::FieldCustomLabel).operator QString()} + }; + + +typedef struct{ +TInt iFieldCode; +QString iFieldContext; +QString iFieldString; +}PhoneNumInfo; +PhoneNumInfo CreatorPhoneNumberFields[] = + { + { CCreatorPhonebookWrapper::ELandPhoneGen,"", "Landline"}, + { CCreatorPhonebookWrapper::ELandPhoneHome,"Home", "Landline"}, + { CCreatorPhonebookWrapper::ELandPhoneWork,"Work", "Landline"}, + { CCreatorPhonebookWrapper::EMobilePhoneGen,"","Mobile"}, + { CCreatorPhonebookWrapper::EMobilePhoneHome,"Home","Mobile"}, + { CCreatorPhonebookWrapper::EMobilePhoneWork,"Work", "Mobile"}, + { CCreatorPhonebookWrapper::EFaxNumberGen, "", "Facsimile"}, + { CCreatorPhonebookWrapper::EFaxNumberHome, "Home", "Facsimile"}, + { CCreatorPhonebookWrapper::EFaxNumberWork, "Work", "Facsimile"}, + { CCreatorPhonebookWrapper::EPagerNumber, "Work", "Pager"}, + { CCreatorPhonebookWrapper::EVideoNumberGen, "", "Video"}, + { CCreatorPhonebookWrapper::EVideoNumberHome, "Home", "Video"}, + { CCreatorPhonebookWrapper::EVideoNumberWork, "Work", "Video"}, //{ "Home", "Voice" },//{ "Work", "Voice" }, + { CCreatorPhonebookWrapper::EAsstPhone, "Work", "Assistant" }, + { CCreatorPhonebookWrapper::ECarPhone, "Home", "Car" } + }; + + +typedef struct{ + TInt iFieldCode; + QString iFieldContext; +}EmailInfo; +EmailInfo CreatorEmailFields[] = + { + {CCreatorPhonebookWrapper::EEmailGen,""}, + {CCreatorPhonebookWrapper::EEmailHome,(QContactDetail::ContextHome).operator QString()}, + {CCreatorPhonebookWrapper::EEmailWork,(QContactDetail::ContextWork).operator QString()} + }; + +typedef struct{ + TInt iFieldCode; + QString iFieldContext; +}UrlInfo; +UrlInfo CreatorUrlFields[] = + { + {CCreatorPhonebookWrapper::EUrlGen,""}, + {CCreatorPhonebookWrapper::EUrlHome,(QContactDetail::ContextHome).operator QString()}, + {CCreatorPhonebookWrapper::EUrlWork,(QContactDetail::ContextWork).operator QString()} + }; + +CCreatorPhonebookWrapper* CCreatorPhonebookWrapper::NewL() + { + CCreatorPhonebookWrapper* self = CCreatorPhonebookWrapper::NewLC(); + CleanupStack::Pop(self); + return self; + } + +CCreatorPhonebookWrapper* CCreatorPhonebookWrapper::NewLC() + { + CCreatorPhonebookWrapper* self = new (ELeave) CCreatorPhonebookWrapper(); + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + + +CCreatorPhonebookWrapper::CCreatorPhonebookWrapper() + { + } + +void CCreatorPhonebookWrapper::ConstructL() + { + LOGSTRING("Creator: CCreatorPhonebookWrapper::ConstructL"); + + QT_TRYCATCH_LEAVING( iPhonebookAPI = new CCreatorPhonebookAPI() ); + + } + + +CCreatorPhonebookWrapper::~CCreatorPhonebookWrapper() + { + LOGSTRING("Creator: CCreatorPhonebookWrapper::~CCreatorPhonebookWrapper"); + if( iPhonebookAPI ) + { + delete iPhonebookAPI; + iPhonebookAPI = NULL; + } + } + +//---------------------------------------------------------------------------- + +QList CCreatorPhonebookWrapper::CreateContactDetailsFromParameters( const TCreatorContactFields& aFields ) + { + QList contDetList; + QString content; + HBufC* temp; + TInt arraySize = sizeof(CreatorPbkTextFields)/sizeof(QDetailFieldInfo); + for (TInt i = 0; i < arraySize; i++) + { + TCreatorContactFields::const_iterator it = aFields.find(CreatorPbkTextFields[i].iFieldCode); + if( it != aFields.end() ) + { + temp = (*it).second; + content = QString::fromUtf16( temp->Des().Ptr(), temp->Length() ); + QContactDetail contactDetail = CreateContactDetail(contDetList, CreatorPbkTextFields[i].iDetail,CreatorPbkTextFields[i].iFieldContext,CreatorPbkTextFields[i].iFieldString, content ); + AddFieldToList( contDetList, contactDetail ); + } + } + arraySize = sizeof(CreatorPhoneNumberFields)/sizeof(PhoneNumInfo); + for (TInt i = 0; i < arraySize; i++) + { + TCreatorContactFields::const_iterator it = aFields.find(CreatorPhoneNumberFields[i].iFieldCode); + if( it != aFields.end() ) + { + temp = (*it).second; + content = QString::fromUtf16( temp->Des().Ptr(), temp->Length() ); + QContactDetail contactDetail = CreateContactDetail(contDetList, QContactPhoneNumber::DefinitionName ,CreatorPhoneNumberFields[i].iFieldContext,CreatorPhoneNumberFields[i].iFieldString, content ); + AddFieldToList( contDetList, contactDetail ); + } + } + + arraySize = sizeof(CreatorEmailFields)/sizeof(EmailInfo); + for (TInt i = 0; i < arraySize; i++) + { + TCreatorContactFields::const_iterator it = aFields.find(CreatorEmailFields[i].iFieldCode); + if( it != aFields.end() ) + { + temp = (*it).second; + content = QString::fromUtf16( temp->Des().Ptr(), temp->Length() ); + QContactDetail contactDetail = CreateContactDetail(contDetList, QContactEmailAddress::DefinitionName ,CreatorEmailFields[i].iFieldContext,"", content ); + AddFieldToList( contDetList, contactDetail ); + } + } + + arraySize = sizeof(CreatorUrlFields)/sizeof(UrlInfo); + for (TInt i = 0; i < arraySize; i++) + { + TCreatorContactFields::const_iterator it = aFields.find(CreatorUrlFields[i].iFieldCode); + if( it != aFields.end() ) + { + temp = (*it).second; + content = QString::fromUtf16( temp->Des().Ptr(), temp->Length() ); + QContactDetail contactDetail = CreateContactDetail(contDetList, QContactUrl::DefinitionName ,CreatorUrlFields[i].iFieldContext,"", content ); + AddFieldToList( contDetList, contactDetail ); + } + } + arraySize = sizeof(CreatorUrlFields)/sizeof(UrlInfo); + for (TInt i = 0; i < arraySize; i++) + { + TCreatorContactFields::const_iterator it = aFields.find(CreatorUrlFields[i].iFieldCode); + if( it != aFields.end() ) + { + temp = (*it).second; + content = QString::fromUtf16( temp->Des().Ptr(), temp->Length() ); + QContactDetail contactDetail = CreateContactDetail(contDetList, QContactUrl::DefinitionName ,CreatorUrlFields[i].iFieldContext,"", content ); + AddFieldToList( contDetList, contactDetail ); + } + } + + TCreatorContactFields::const_iterator it = aFields.find(CCreatorPhonebookWrapper::EThumbnailPic); + if( it != aFields.end() ) + { + temp = (*it).second; + if(temp) + { + content = QString::fromUtf16( temp->Des().Ptr(), temp->Length() ); + QContactDetail contactDetail = CreateContactDetail(contDetList, QContactAvatar::DefinitionName ,"","", content ); + AddFieldToList( contDetList, contactDetail ); + } + } + it = aFields.find(CCreatorPhonebookWrapper::EAnniversary); + if( it != aFields.end() ) + { + temp = (*it).second; + if(temp) + { + content = QString::fromUtf16( temp->Des().Ptr(), temp->Length() ); + QContactDetail contactDetail = CreateContactDetail(contDetList, QContactAnniversary::DefinitionName ,"","", content ); + AddFieldToList( contDetList, contactDetail ); + } + } + + return contDetList; + } +QContactDetail CCreatorPhonebookWrapper::CreateContactDetail( QList& aContactDetailList,QString aDetail, QString aFieldContext, QString aFieldString, QString aData ) + { + QContactDetail contactDetail; + + if( aDetail == QContactPhoneNumber::DefinitionName) + { + QContactPhoneNumber phoneNumber;// = contactDetail; + if(!aFieldContext.isEmpty()) + { + phoneNumber.setContexts(aFieldContext); + } + phoneNumber.setSubTypes(aFieldString); + //QString number = QString::fromUtf16(aData.Ptr(),aData.Length()); + phoneNumber.setNumber(aData); + return phoneNumber; + } + else if( aDetail == QContactName::DefinitionName ) //--Contact NAME----------------------------- + { + QContactName contactName; + for(int i = 0 ; i < aContactDetailList.count() ; i++ ) //go through all contact details to check if there is already Contact Name to set other details + { + if(aContactDetailList.at(i).definitionName() == QContactName::DefinitionName ) + { + contactName = aContactDetailList.at(i); + } + } + //QString name = QString::fromUtf16(aData.Ptr(),aData.Length()); + if(aFieldString == QContactName::FieldFirstName) + { + if(contactName.firstName().isEmpty()) + { + contactName.setFirstName( aData ); + } + } + else if(aFieldString == QContactName::FieldLastName) + { + if(contactName.lastName().isEmpty()) + { + contactName.setLastName( aData ); + } + } + else if(aFieldString == QContactName::FieldMiddleName) + { + if(contactName.middleName().isEmpty()) + { + contactName.setMiddleName( aData ); + } + } + else if(aFieldString == QContactName::FieldPrefix) + { + if(contactName.prefix().isEmpty()) + { + contactName.setPrefix( aData ); + } + } + else if(aFieldString == QContactName::FieldSuffix) + { + if(contactName.suffix().isEmpty()) + { + contactName.setSuffix( aData ); + } + } + else //QContactName::FieldCustomLabel: + { + if(contactName.customLabel().isEmpty()) + { + contactName.setCustomLabel( aData ); + } + } + return contactName; + } + else if( aDetail == QContactOrganization::DefinitionName ) //--Contact Company----------------------------- + { + QContactOrganization contactCompany; + + for(int i = 0 ; i < aContactDetailList.count() ; i++ ) //go through all contact details to check if there is already Contact Name to set other details + { + if(aContactDetailList.at(i).definitionName() == QContactOrganization::DefinitionName ) + { + contactCompany = aContactDetailList.at(i); + } + } + + //QString company = QString::fromUtf16(aData.Ptr(),aData.Length()); + if(aFieldString == QContactOrganization::FieldName) + { + if(contactCompany.name().isEmpty()) + { + contactCompany.setName( aData ); + } + } + if(aFieldString == QContactOrganization::FieldTitle) + { + if(contactCompany.title().isEmpty()) + { + contactCompany.setTitle( aData ); + } + } + if(aFieldString == QContactOrganization::FieldDepartment) + { + QStringList depList = contactCompany.department(); + depList.append(aData); + contactCompany.setDepartment(depList); + } + if(aFieldString == QContactOrganization::FieldAssistantName) + { + if(contactCompany.assistantName().isEmpty()) + { + contactCompany.setAssistantName( aData ); + } + } + return contactCompany; + } + else if( aDetail == QContactAddress::DefinitionName ) //--Contact Address----------------------------- + { + QContactAddress contactAddress; + + for(int i = 0 ; i < aContactDetailList.count() ; i++ ) //go through all contact details to check if there is already Contact Name to set other details + { + if(aContactDetailList.at(i).definitionName() == QContactAddress::DefinitionName && aContactDetailList.at(i).value(QContactDetail::FieldContext) == aFieldContext ) + { + contactAddress = aContactDetailList.at(i); + } + } + if( !aFieldContext.isEmpty() ) + { + contactAddress.setContexts( aFieldContext ); + } + //QString address = QString::fromUtf16(aData.Ptr(),aData.Length()); + if(aFieldString == QContactAddress::FieldStreet ) + { + if( contactAddress.street().isEmpty() ) + { + contactAddress.setStreet( aData ); + } + } + else if(aFieldString == QContactAddress::FieldLocality ) + { + if( contactAddress.locality().isEmpty() ) + { + contactAddress.setLocality( aData ); + } + } + else if(aFieldString == QContactAddress::FieldRegion ) + { + if( contactAddress.region().isEmpty() ) + { + contactAddress.setRegion( aData ); + } + } + else if(aFieldString == QContactAddress::FieldPostcode ) + { + if( contactAddress.postcode().isEmpty() ) + { + contactAddress.setPostcode( aData ); + } + } + else if(aFieldString == QContactAddress::FieldCountry ) + { + if( contactAddress.country().isEmpty() ) + { + contactAddress.setCountry( aData ); + } + } + else + { + return contactDetail; + } + return contactAddress; + } + else if( aDetail == QContactNote::DefinitionName ) //--Contact Note----------------------------- + { + QContactNote contactNote; + //QString note = QString::fromUtf16(aData.Ptr(),aData.Length()); + contactNote.setNote(aData); + return contactNote; + } + else if( aDetail == QContactFamily::DefinitionName ) //--Contact Family----------------------------- + { + QContactFamily contactFamily; + + for(int i = 0 ; i < aContactDetailList.count() ; i++ ) //go through all contact details to check if there is already Contact Name to set other details + { + if(aContactDetailList.at(i).definitionName() == QContactFamily::DefinitionName && aContactDetailList.at(i).value(QContactDetail::FieldContext) == aFieldContext ) + { + contactFamily = aContactDetailList.at(i); + } + } + + //QString familyData = QString::fromUtf16(aData.Ptr(),aData.Length()); + if(aFieldString == QContactFamily::FieldSpouse ) + { + if( contactFamily.spouse().isEmpty() ) + { + contactFamily.setSpouse( aData ); + } + } + if(aFieldString == QContactFamily::FieldChildren ) + { + QStringList children = contactFamily.children(); + children.append( aData ); + contactFamily.setChildren( children ); + } + + return contactFamily; + } + + if( aDetail == QContactAvatar::DefinitionName) //--Contact Picture----------------------------- + { + QContactAvatar contactAvatar; + QUrl imageUrl; + imageUrl.setUrl(aData); + contactAvatar.setImageUrl(imageUrl); + + return contactAvatar; + } + if( aDetail == QContactAnniversary::DefinitionName) //--Anniversary------------------------------ + { + QContactAnniversary contactAnniversary; + aData.replace(QChar('/'), QChar('-')); + QDate date = QDate::fromString(aData, "dd-MM-yyyy"); + //TTime datetime = aEngine->RandomDate( CCreatorEngine::EDateFuture ); + //date.setDate( datetime.DateTime().Year(),(int) (datetime.DateTime().Month()+1), datetime.DateTime().Day() ); + contactAnniversary.setOriginalDate( date ); + return contactAnniversary; + } + if( aDetail == QContactEmailAddress::DefinitionName) //--Email------------------------------------ + { + QContactEmailAddress email; + //QString emailAddr = QString::fromUtf16(aData.Ptr(),aData.Length()); + if( !aFieldContext.isEmpty() ) + { + email.setContexts( aFieldContext ); + } + email.setEmailAddress( aData ); + return email; + } + if( aDetail == QContactUrl::DefinitionName ) //--Url------------------------------------------- + { + QContactUrl url; + //QString urlStr = QString::fromUtf16(aData.Ptr(),aData.Length()); + if( !aFieldContext.isEmpty() ) + { + url.setContexts( aFieldContext ); + } + url.setUrl(aData); + return url; + } + if( aDetail == QContactBirthday::DefinitionName ) //--Birthday----------------------------------- + { + QContactBirthday birthday; + QDate date = QDate::fromString(aData); + //TTime datetime = aEngine->RandomDate( CCreatorEngine::EDatePast ); + //date.setDate( datetime.DateTime().Year(),(int) (datetime.DateTime().Month()+1), datetime.DateTime().Day() ); + birthday.setDate( date ); + return birthday; + } + + return contactDetail; + } + +void CCreatorPhonebookWrapper::AddFieldToList( QList& aDetailList, QContactDetail aDetail) + { + bool replace = false; + for(int i = 0 ; i< aDetailList.count() ; i++) //go through + { + if( !aDetail.isEmpty() && aDetail.definitionName() == aDetailList.at(i).definitionName() + && aDetail.definitionName() != QContactPhoneNumber::DefinitionName + && aDetail.definitionName() != QContactEmailAddress::DefinitionName + && aDetail.definitionName() != QContactUrl::DefinitionName ) + { + QString context = aDetail.value(QContactDetail::FieldContext); + bool isContextEmpty = context.isEmpty(); + if( isContextEmpty || ( aDetail.value(QContactDetail::FieldContext) == aDetailList.at(i).value(QContactDetail::FieldContext)) ) + { + //replace + aDetailList.replace(i,aDetail); + replace = true; + } + } + } + if(!replace) + { + if(!aDetail.isEmpty()) + { + aDetailList.append(aDetail); + } + } + + } + +TUint32 CCreatorPhonebookWrapper::CreateContactEntryL(const TCreatorContactFields& aFields) + { + QList list = CreateContactDetailsFromParameters( aFields ); + + return iPhonebookAPI->saveContact( list ); + } + + +//---------------------------------------------------------------------------- + + + +//---------------------------------------------------------------------------- + +void CCreatorPhonebookWrapper::DeleteAllL() + { + iPhonebookAPI->deleteAllContacts(); + } + +//---------------------------------------------------------------------------- +void CCreatorPhonebookWrapper::DeleteAllGroupsL() + { + LOGSTRING("Creator: CCreatorPhonebookWrapper::DeleteAllGroupsL"); + + iPhonebookAPI->deleteAllContacts( QContactType::TypeGroup ); + + } + +//---------------------------------------------------------------------------- +void CCreatorPhonebookWrapper::DeleteContactsL( RArray& aContactsToDelete, TUid aStoreUid ) + { + QList contacts; + for( TInt i = 0; i < aContactsToDelete.Count(); ++i ) + { + QContact contact = iPhonebookAPI->contact( QContactLocalId( aContactsToDelete[i] ) ); + if( (contact.type() == QContactType::TypeGroup && aStoreUid == KUidDictionaryUidContactGroups ) || (contact.type() != QContactType::TypeGroup && aStoreUid != KUidDictionaryUidContactGroups) ) + { + contacts.append( QContactLocalId( aContactsToDelete[i] ) ); + } + } + QMap errorMap; + iPhonebookAPI->deleteContacts( contacts ); + } + +//---------------------------------------------------------------------------- +TBool CCreatorPhonebookWrapper::HasOtherThanGroupsL() + { + LOGSTRING("Creator: CCreatorPhonebookWrapper::HasOtherThanGroupsL"); + TBool result( EFalse ); + return result; + } + + +TUint32 CCreatorPhonebookWrapper::CreateGroupEntryL( HBufC* aGroupName ) + { + TUint32 id = 0; + QString groupName = QString::fromUtf16( aGroupName->Des().Ptr(), aGroupName->Length() ); + + id = iPhonebookAPI->createGroup( groupName ); + + return id; + } +TInt CCreatorPhonebookWrapper::NumberOfContacts() + { + //return all stored contacts + return iPhonebookAPI->numberOfContacts(); + } + +TInt CCreatorPhonebookWrapper::AddContactToGroup( TUint32 aGroupId, TUint32 aContact ) + { + QContactLocalId group = QContactLocalId(aGroupId); + QContactLocalId contact = QContactLocalId(aContact); + + TInt ret = iPhonebookAPI->addContactToGroup(group, contact); + + return ret; + } +TInt CCreatorPhonebookWrapper::AddToGroup( TUint32 aGroupId, TInt aAmount ) + { + QContactLocalId group = QContactLocalId(aGroupId); + TInt ret = iPhonebookAPI->addToGroup( group, (int) aAmount ); + return ret; + } + + +//---------------------------------------------------------------------------- + +TInt CCreatorPhonebookWrapper::CreateSubscribedContactEntryL() + { + LOGSTRING("Creator: CCreatorPhonebookWrapper::CreateSubscribedContactEntryL"); + + return KErrNotSupported; + } + + +HBufC* CCreatorPhonebookWrapper::GetPhoneNumberL( TUint32 aContactId ) + { + QContactLocalId contact = QContactLocalId(aContactId); + QString phoneNumber = iPhonebookAPI->phoneNumber(contact); + HBufC *buf = HBufC::NewLC( phoneNumber.length() ); + buf->Des().Copy( phoneNumber.utf16() ); + CleanupStack::Pop( buf ); + return buf; + } + +TBool CCreatorPhonebookWrapper::GetContactDetailsL( TUint32 aContactId, TDes& aName, TDes& aPhoneNumber, TDes& aEmail ) + { + QString name; + QString phoneNumber; + QString email; + + QContactLocalId contact = QContactLocalId(aContactId); + bool success = iPhonebookAPI->contactDetails( contact, name, phoneNumber, email); + if( success ) + { + aName.Copy( name.utf16() ); + aPhoneNumber.Copy( phoneNumber.utf16() ); + aEmail.Copy( email.utf16() ); + } + return success ? ETrue : EFalse ; + } diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/src/creator_randomdataparser.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/src/creator_randomdataparser.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,325 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +#include +#include +#include +#include "creator_randomdataparser.h" +#include "creator_traces.h" + +// XML element names +_LIT(KRootElement, "creatordata"); +_LIT(KFirstName, "firstname"); +_LIT(KSurname, "surname"); +_LIT(KCompany, "company"); +_LIT(KAddress, "address"); +_LIT(KJobTitle, "jobtitle"); +_LIT(KPhoneNumber, "phonenumber"); +_LIT(KGroupName, "groupname"); +_LIT(KMeetingReason, "meetingreason"); +_LIT(KMeetingPlace, "meetingplace"); +_LIT(KMemoText, "memo"); +_LIT(KAnniversaryReason, "anniversary"); +_LIT(KToDoText, "todo"); +_LIT(KReminderText, "reminder"); +_LIT(KMessageSubject, "messagesubject"); +_LIT(KMessageText, "messagetext"); +_LIT(KCity, "city"); +_LIT(KCountry, "country"); +_LIT(KPostcode, "postcode"); +_LIT(KState, "state"); +_LIT(KPobox, "pobox"); +_LIT(KPrefix, "prefix"); +_LIT(KSuffix, "suffix"); +_LIT(KLandmarkName, "landmarkname"); +_LIT(KLandmarkDescription, "landmarkdescription"); + +using namespace Xml; + +CCreatorRandomDataParser::CCreatorRandomDataParser() + { + } + +void CCreatorRandomDataParser::ConstructL() + { + LOGSTRING("Creator: CCreatorRandomDataParser::ConstructL"); + iElementNameArray = new (ELeave) CDesCArrayFlat(32); + iElementNameArray->InsertL(EFirstName, KFirstName); + iElementNameArray->InsertL(ESurname, KSurname); + iElementNameArray->InsertL(ECompany, KCompany); + iElementNameArray->InsertL(EAddress, KAddress); + iElementNameArray->InsertL(EJobTitle, KJobTitle); + iElementNameArray->InsertL(EPhoneNumber, KPhoneNumber); + iElementNameArray->InsertL(EGroupName, KGroupName); + iElementNameArray->InsertL(EMeetingReason, KMeetingReason); + iElementNameArray->InsertL(EMeetingPlace, KMeetingPlace); + iElementNameArray->InsertL(EMemoText, KMemoText); + iElementNameArray->InsertL(EAnniversaryReason, KAnniversaryReason); + iElementNameArray->InsertL(EToDoText, KToDoText); + iElementNameArray->InsertL(EReminderText, KReminderText); + iElementNameArray->InsertL(EMessageSubject, KMessageSubject); + iElementNameArray->InsertL(EMessageText, KMessageText); + iElementNameArray->InsertL(ECity, KCity); + iElementNameArray->InsertL(ECountry, KCountry); + iElementNameArray->InsertL(EPostcode, KPostcode); + iElementNameArray->InsertL(EState, KState); + iElementNameArray->InsertL(EPobox, KPobox); + iElementNameArray->InsertL(EPrefix, KPrefix); + iElementNameArray->InsertL(ESuffix, KSuffix); + iElementNameArray->InsertL(ELandmarkName, KLandmarkName); + iElementNameArray->InsertL(ELandmarkDescription, KLandmarkDescription); + iContentData = HBufC::NewL(16); + iResultArray = new (ELeave) CDesCArrayFlat(16); + } + +CCreatorRandomDataParser* CCreatorRandomDataParser::NewL() + { + LOGSTRING("Creator: CCreatorRandomDataParser::NewL"); + CCreatorRandomDataParser* self = CCreatorRandomDataParser::NewLC(); + CleanupStack::Pop(); + return self; + } + +CCreatorRandomDataParser* CCreatorRandomDataParser::NewLC() + { + LOGSTRING("Creator: CCreatorRandomDataParser::NewLC"); + CCreatorRandomDataParser* self = new (ELeave) CCreatorRandomDataParser; + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +CCreatorRandomDataParser::~CCreatorRandomDataParser() + { + delete iParser; + delete iResultArray; + delete iContentData; + delete iElementNameArray; + } + +void CCreatorRandomDataParser::GetTextFileMode(RFile& aFile, TInt& aFileSize) + { + LOGSTRING("Creator: CCreatorRandomDataParser::GetTextFileMode"); + iScriptTextFormat = EFormatANSIASCII; + + // if we are working with text files, check the type first + TBuf8<4> BOM; + + // first check for UTF-16 + if (aFileSize >= 2 && aFile.Read(0, BOM, 2) == KErrNone) + { + if (BOM.Length()==2 && BOM[0]==0xFF && BOM[1]==0xFE) + { + iScriptTextFormat = EFormatUTF16LE; + aFileSize -= 2; + return; + } + else if (BOM.Length()==2 && BOM[0]==0xFE && BOM[1]==0xFF) + { + iScriptTextFormat = EFormatUTF16BE; + aFileSize -= 2; + return; + } + } + // then check for UTF-8 + if (aFileSize >= 3 && aFile.Read(0, BOM, 3) == KErrNone) + { + if (BOM.Length()==3 && BOM[0]==0xEF && BOM[1]==0xBB && BOM[2]==0xBF) + { + iScriptTextFormat = EFormatUTF8; + aFileSize -= 3; + return; + } + } + + // none of those, seek back to beginning + TInt pos(0); + aFile.Seek(ESeekStart, pos); + } + + + +CDesCArrayFlat* CCreatorRandomDataParser::ParseL(const TDesC& aFileName, const TRandomDataType aDataType) + { + LOGSTRING2("Creator: CCreatorRandomDataParser::ParseL: %S", &aFileName); + + iDataType = aDataType; + + // Create and start XML-parser + if( iParser == 0) + { + _LIT8(KXmlMimeType, "text/xml"); + iParser = CParser::NewL(KXmlMimeType, *this); + } + + RFs filesession; + CleanupClosePushL(filesession); + User::LeaveIfError( filesession.Connect() ); + + iResultArray->Reset(); + + Xml::ParseL(*iParser, filesession, aFileName); + + CleanupStack::PopAndDestroy(&filesession); // filesession + + CDesCArrayFlat* tempArray = new (ELeave) CDesCArrayFlat(8); + CleanupStack::PushL(tempArray); + for (TInt i = 0; i < iResultArray->MdcaCount(); i++) + { + tempArray->AppendL(iResultArray->MdcaPoint(i)); + } + CleanupStack::Pop(tempArray); + return tempArray; + } + +void CCreatorRandomDataParser::OnStartDocumentL(const Xml::RDocumentParameters& /*aDocParam*/, TInt aErrorCode) + { + LOGSTRING2("Creator: CCreatorRandomDataParser::OnStartDocumentL (Error code: %d)", aErrorCode); + User::LeaveIfError(aErrorCode); + iInsideRootElement = EFalse; + iContentParsingActive = EFalse; + } + +void CCreatorRandomDataParser::OnEndDocumentL(TInt aErrorCode) + { + LOGSTRING2("Creator: CCreatorRandomDataParser::OnEndDocumentL (Error code: %d)", aErrorCode); + User::LeaveIfError(aErrorCode); + } + +void CCreatorRandomDataParser::OnStartPrefixMappingL(const RString& /*aPrefix*/, + const RString& /*aUri*/, + TInt aErrorCode) + { + LOGSTRING2("Creator: CCreatorRandomDataParser::OnStartPrefixMappingL (Error code: %d)", aErrorCode); + User::LeaveIfError(aErrorCode); + } + +void CCreatorRandomDataParser::OnEndPrefixMappingL(const RString& /*aPrefix*/, TInt aErrorCode) + { + LOGSTRING2("Creator: CCreatorRandomDataParser::OnEndPrefixMappingL (Error code: %d)", aErrorCode); + User::LeaveIfError(aErrorCode); + } + +void CCreatorRandomDataParser::OnIgnorableWhiteSpaceL(const TDesC8& /*aBytes*/, TInt aErrorCode) + { + LOGSTRING2("Creator: CCreatorRandomDataParser::OnIgnorableWhiteSpaceL (Error code: %d)", aErrorCode); + User::LeaveIfError(aErrorCode); + } + +void CCreatorRandomDataParser::OnSkippedEntityL(const RString& /*aName*/, TInt aErrorCode) + { + LOGSTRING2("Creator: CCreatorRandomDataParser::OnSkippedEntityL (Error code: %d)", aErrorCode); + User::LeaveIfError(aErrorCode); + } + +void CCreatorRandomDataParser::OnProcessingInstructionL(const TDesC8& /*aTarget*/, + const TDesC8& /*aData*/, + TInt aErrorCode) + { + LOGSTRING2("Creator: CCreatorRandomDataParser::OnProcessingInstructionL (Error code: %d)", aErrorCode); + User::LeaveIfError(aErrorCode); + } + +void CCreatorRandomDataParser::OnError(TInt aErrorCode) + { + LOGSTRING2("Creator: CCreatorRandomDataParser::OnError: %d", aErrorCode); + + iLastError = aErrorCode; + } + +TAny* CCreatorRandomDataParser::GetExtendedInterface(const TInt32 aUid) + { + LOGSTRING2("Creator: CCreatorRandomDataParser::GetExtendedInterface (UID: %d)", aUid); + return this; + } + +void CCreatorRandomDataParser::OnStartElementL(const Xml::RTagInfo& aElement, + const Xml::RAttributeArray& /*aAttributes*/, + TInt aErrorCode) + { + LOGSTRING2("Creator: CCreatorRandomDataParser::OnStartElementL (Error code: %d)", aErrorCode); + User::LeaveIfError(aErrorCode); + + const TDesC8& elementName8 = aElement.LocalName().DesC(); + HBufC* elementName16 = Convert8BitTo16BitLC(elementName8); + if (iInsideRootElement || (elementName16->Des() == KRootElement)) + { + iInsideRootElement = ETrue; + } + if (iInsideRootElement && (elementName16->Des() == iElementNameArray->MdcaPoint(iDataType))) + { + iContentParsingActive = ETrue; + iContentData->Des().Zero(); + } + CleanupStack::PopAndDestroy(elementName16); + } + +void CCreatorRandomDataParser::OnEndElementL(const Xml::RTagInfo& aElement, TInt aErrorCode) + { + LOGSTRING2("Creator: CCreatorRandomDataParser::OnEndElementL (Error code: %d)", aErrorCode); + User::LeaveIfError(aErrorCode); + + const TDesC8& elementName8 = aElement.LocalName().DesC(); + HBufC* elementName16 = Convert8BitTo16BitLC(elementName8); + if (!iInsideRootElement || (elementName16->Des() == KRootElement)) + { + iInsideRootElement = EFalse; + } + CleanupStack::PopAndDestroy(elementName16); + + if (iContentParsingActive) + { + if (iContentData->Des().Length() > 0) + { + iResultArray->AppendL(*iContentData); + } + iContentParsingActive = EFalse; + } + } + +void CCreatorRandomDataParser::OnContentL(const TDesC8& aBytes, TInt aErrorCode) + { + LOGSTRING2("Creator: CCreatorRandomDataParser::OnContentL (Error code: %d)", aErrorCode); + User::LeaveIfError(aErrorCode); + + if (iContentParsingActive) + { + HBufC* data16 = Convert8BitTo16BitLC(aBytes); + TInt newLen = iContentData->Des().Length() + data16->Des().Length(); + iContentData = iContentData->ReAllocL(newLen); + iContentData->Des().Append(*data16); + CleanupStack::PopAndDestroy(data16); + } + } + +HBufC16* CCreatorRandomDataParser::Convert8BitTo16BitLC(const TDesC8& aInput) + { + LOGSTRING("Creator: CCreatorRandomDataParser::Convert8BitTo16BitLC"); + HBufC16* output = NULL; + + output = CnvUtfConverter::ConvertToUnicodeFromUtf8L(aInput); + + CleanupStack::PushL(output); + return output; + } + +TInt CCreatorRandomDataParser::GetError() const + { + return iLastError; + } diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/src/creator_scriptelement.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/src/creator_scriptelement.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,722 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +#include "creator_traces.h" +#include "creator_scriptelement.h" +#include +#include +#include // KMaxTelNumberSize + +using namespace Xml; + +CCreatorScriptElementCache* CCreatorScriptElementCache::NewL() +{ + CCreatorScriptElementCache* self = new (ELeave) CCreatorScriptElementCache; + CleanupStack::PushL(self); + + self->ConstructL(); + CleanupStack::Pop(); + return self; +} + +CCreatorScriptElementCache::CCreatorScriptElementCache() + { + + } + +void CCreatorScriptElementCache::ConstructL() + { + + } + +CCreatorScriptElementCache::~CCreatorScriptElementCache() + { + iElementCache.Reset(); + iElementCache.Close(); + } + +void CCreatorScriptElementCache::RemoveElements() + { + iElementCache.Reset(); + } + + +void CCreatorScriptElementCache::AddElementL(CCreatorScriptElement* aElement) + { + iElementCache.AppendL(aElement); + } + +/** + * + */ +CCreatorScriptAttribute* CCreatorScriptAttribute::NewLC(const TDesC& aName, const TDesC& aValue) + { + CCreatorScriptAttribute* self = new(ELeave) CCreatorScriptAttribute(); + CleanupStack::PushL(self); + self->ConstructL(aName, aValue); + return self; + } + +CCreatorScriptAttribute* CCreatorScriptAttribute::NewL(const TDesC& aName, const TDesC& aValue) + { + CCreatorScriptAttribute* self = CCreatorScriptAttribute::NewLC(aName, aValue); + CleanupStack::Pop(); // self + return self; + } + +CCreatorScriptAttribute::~CCreatorScriptAttribute() + { + delete iName; + delete iValue; + } + +TPtrC CCreatorScriptAttribute::Name() const + { + return iName->Des(); + } + +void CCreatorScriptAttribute::SetNameL(const TDesC& aName) + { + if( iName ) + { + delete iName; + iName = 0; + } + iName = HBufC::NewL(aName.Length()); + iName->Des() = aName; + } + +TPtrC CCreatorScriptAttribute::Value() const + { + return iValue->Des(); + } + +void CCreatorScriptAttribute::SetValueL(const TDesC& aValue) + { + if( iValue ) + { + delete iValue; + iValue = 0; + } + iValue = HBufC::NewL(aValue.Length()); + iValue->Des() = aValue; + } + +CCreatorScriptAttribute::CCreatorScriptAttribute() + { + } + +void CCreatorScriptAttribute::ConstructL(const TDesC& aName, const TDesC& aValue) + { + SetNameL(aName); + SetValueL(aValue); + } + +/** + * CCreatorScriptElement + */ + +CCreatorScriptElement* CCreatorScriptElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext) + { + CCreatorScriptElement* self = new (ELeave) CCreatorScriptElement(aEngine); + CleanupStack::PushL(self); + self->ConstructL(aName, aContext); + CleanupStack::Pop(); + return self; + } + +CCreatorScriptElement::~CCreatorScriptElement() + { + LOGSTRING("Creator: CCreatorScriptElement::~CCreatorScriptElement"); + iSubElements.ResetAndDestroy(); + iAttributes.ResetAndDestroy(); + iSubElements.Close(); + iAttributes.Close(); + iParameters.Reset(); + iParameters.Close(); + delete iName; + delete iContent; + delete iContext; + } + +RPointerArray const& CCreatorScriptElement::SubElements() const + { + return iSubElements; + } + +RPointerArray& CCreatorScriptElement::SubElements() + { + return iSubElements; + } + +CCreatorScriptElement* CCreatorScriptElement::SubElement(TInt aIndex) + { + return iSubElements[aIndex]; + } + +CCreatorScriptElement* CCreatorScriptElement::FindSubElement(const TDesC& aName) + { + for( TInt i = 0; i < iSubElements.Count(); ++i ) + { + if( iSubElements[i]->Name() == aName ) + { + return iSubElements[i]; + } + } + return 0; + } + +void CCreatorScriptElement::RemoveSubElements() + { + iSubElements.ResetAndDestroy(); + } + +void CCreatorScriptElement::RemoveSubElementL(TInt aIndex) + { + if( aIndex < iSubElements.Count()) + { + delete iSubElements[aIndex]; + iSubElements.Remove(aIndex); + } + else + { + User::Leave(KErrArgument); + } + } + +void CCreatorScriptElement::AddSubElementL(CCreatorScriptElement* aElem, TInt aIndex ) + { + if( aIndex == -1 || aIndex == iSubElements.Count() ) + { + iSubElements.AppendL(aElem); + } + else if( aIndex < iSubElements.Count()) + { + iSubElements.InsertL(aElem, aIndex); + } + else + { + User::Leave(KErrArgument); + } + } + +RPointerArray const& CCreatorScriptElement::Attributes() const + { + return iAttributes; + } + + + CCreatorScriptAttribute* CCreatorScriptElement::Attribute(TInt aIndex) + { + return iAttributes[aIndex]; + } + +void CCreatorScriptElement::RemoveAttributes() + { + iAttributes.ResetAndDestroy(); + } + + +void CCreatorScriptElement::RemoveAttributeL(TInt aIndex) + { + if( aIndex < iAttributes.Count()) + { + delete iAttributes[aIndex]; + iAttributes.Remove(aIndex); + } + else + { + User::Leave(KErrArgument); + } + } + +void CCreatorScriptElement::AddAttributeL(CCreatorScriptAttribute* aAttribute, TInt aIndex ) + { + if( aIndex == -1 || aIndex == iAttributes.Count() ) + { + iAttributes.AppendL(aAttribute); + } + else if( aIndex < iAttributes.Count()) + { + iAttributes.InsertL(aAttribute, aIndex); + } + else + { + User::Leave(KErrArgument); + } + } + +TPtrC CCreatorScriptElement::Name() const + { + if( iName ) + return iName->Des(); + return TPtrC(); + } + +void CCreatorScriptElement::SetNameL(const TDesC& aName) + { + if( iName ) + { + delete iName; + iName = 0; + } + iName = HBufC::NewL(aName.Length()); + iName->Des() = aName; + } + + +TPtrC CCreatorScriptElement::Content() const + { + if (iContent) + return iContent->Des(); + return TPtrC(); + } + +void CCreatorScriptElement::SetContentL(const TDesC& aContent) + { + if( iContent ) + { + delete iContent; + iContent = 0; + } + iContent = HBufC::NewL(aContent.Length()); + iContent->Des() = aContent; + } + +void CCreatorScriptElement::AppendContentL(const TDesC& aContent) + { + if( iContent == 0 ) + { + SetContentL(aContent); + return; + } + + iContent = iContent->ReAllocL(iContent->Length() + aContent.Length() ); + + TPtr ptr(iContent->Des()); + ptr += aContent; + } + +TPtrC CCreatorScriptElement::Context() const + { + if( iContext ) + return iContext->Des(); + return TPtrC(); + } + +void CCreatorScriptElement::SetContextL(const TDesC& aContext) + { + if( iContext ) + { + delete iContext; + iContext = 0; + } + iContext = HBufC::NewL(aContext.Length()); + iContext->Des() = aContext; + } + +const CCreatorScriptAttribute* CCreatorScriptElement::FindAttributeByName(const TDesC& aName) const + { + for( TInt i = 0; i < iAttributes.Count(); ++i ) + { + CCreatorScriptAttribute* attr = iAttributes[i]; + if( attr->Name() == aName ) + { + return attr; + } + } + return 0; + } + +CCreatorScriptAttribute* CCreatorScriptElement::FindAttributeByName(const TDesC& aName) + { + for( TInt i = 0; i < iAttributes.Count(); ++i ) + { + CCreatorScriptAttribute* attr = iAttributes[i]; + if( attr->Name() == aName ) + { + return attr; + } + } + return 0; + } + +TBool CCreatorScriptElement::IsCacheNeeded() + { + _LIT(KIDAttrName, "id"); + const CCreatorScriptAttribute* attr = FindAttributeByName(KIDAttrName); + return attr != 0; + } + +void CCreatorScriptElement::AddToCacheL(CCreatorScriptElementCache& aCache) + { + aCache.AddElementL(this); + } + +RPointerArray& CCreatorScriptElement::CommandParameters() + { + return iParameters; + } + +const RPointerArray& CCreatorScriptElement::CommandParameters() const + { + return iParameters; + } + +void CCreatorScriptElement::AddToCacheL() + { + } + +TBool CCreatorScriptElement::IsCommandElement() const + { + return iIsCommandElement; + } + +void CCreatorScriptElement::ExecuteCommandL() + { + + } + +TBool CCreatorScriptElement::IsRoot() const + { + _LIT(KRootName, "creatorscript"); + if(iName->Des() == KRootName) + return ETrue; + return EFalse; + } + +CCreatorScriptElement::CCreatorScriptElement(CCreatorEngine* aEngine) +: +iIsCommandElement(EFalse), +iIsRoot(EFalse), +iEngine(aEngine) + {} + +void CCreatorScriptElement::ConstructL(const TDesC& aName, const TDesC& aContext) + { + SetNameL(aName); + SetContextL(aContext); + } + +TBool CCreatorScriptElement::IsSubElementSupported(const CCreatorScriptElement& /*aElem*/) const + { + return ETrue; + } + +TBool CCreatorScriptElement::ConvertStrToBooleanL(const TDesC& aStr) const + { + TBool boolVal = EFalse; + _LIT(KYes, "yes"); + _LIT(KTrue, "true"); + if( CompareIgnoreCase(aStr, KYes) == 0 || + CompareIgnoreCase(aStr, KTrue) == 0 ) + { + boolVal = ETrue; + } + return boolVal; + } + +TInt CCreatorScriptElement::ConvertStrToIntL(const TDesC& aStr) const + { + TInt intVal = 0; + TLex lex(aStr); + TInt errorCode=lex.Val(intVal); + User::LeaveIfError(errorCode); + return intVal; + } + +TUint CCreatorScriptElement::ConvertStrToUintL(const TDesC& aStr) const + { + TUint uintVal = 0; + TLex lex(aStr); + TInt errorCode=lex.Val(uintVal); + User::LeaveIfError(errorCode); + return uintVal; + } +void CCreatorScriptElement::ConvertStrToReal64L(const TDesC& aStr, TReal64& aVal) const + { + TLex lex(aStr); + TInt errorCode=lex.Val(aVal); + User::LeaveIfError(errorCode); + } + +void CCreatorScriptElement::ConvertStrToReal32L(const TDesC& aStr, TReal32& aVal) const + { + TLex lex(aStr); + TInt errorCode=lex.Val(aVal); + User::LeaveIfError(errorCode); + } + +MCreatorRandomDataField::TRandomLengthType CCreatorScriptElement::ResolveRandomDataTypeL(const CCreatorScriptAttribute& aAttr, TInt& aRandomLen) const + { + TPtrC attrVal = aAttr.Value(); + if(attrVal == KMax ) + return MCreatorRandomDataField::ERandomLengthMax; + if(attrVal == KDefault) + return MCreatorRandomDataField::ERandomLengthDefault; + + // Let's see if the value is numeric: + TInt val = 0; + TLex lex(attrVal); + TInt errorCode=lex.Val(val); + if( errorCode == KErrNone ) + { + aRandomLen = val; + return MCreatorRandomDataField::ERandomLengthExplicit; + } + return MCreatorRandomDataField::ERandomLengthUndefined; + } + +void CCreatorScriptElement::AppendContactSetReferenceL( + const CCreatorScriptElement& aContactSetRefElem, + RArray& aLinkArray ) const + { + const TDesC& eName = aContactSetRefElem.Name(); + if( eName != KContactSetRef ) + return; + + const CCreatorScriptAttribute* linkIdAttr = aContactSetRefElem.FindAttributeByName(KId); + if( linkIdAttr ) + { + TInt linkId = ConvertStrToIntL(linkIdAttr->Value()); + if( linkId > 0 ) + { + TLinkIdParam linkParams; + // Add contact-set-reference id to links + linkParams.iLinkId = linkId; + linkParams.iLinkAmount = KUndef; // undefined + // Resolve maxamount: + const CCreatorScriptAttribute* maxAmount = aContactSetRefElem.FindAttributeByName(KMaxAmount); + if( maxAmount ) + { + TInt maxAmountVal = ConvertStrToIntL(maxAmount->Value()); + if( maxAmountVal > 0 ) + { + linkParams.iLinkAmount = maxAmountVal; + } + } + aLinkArray.AppendL(linkParams); + } + } + } + +TTime CCreatorScriptElement::ConvertToDateTimeL(const TDesC& aDtStr) const + { + _LIT(KDateFieldSeparator, "-"); + _LIT(KTimeFieldSeparator, ":"); + _LIT(KDateTimeSeparator, "T"); + _LIT(KTimeSuffix, "."); + _LIT(KDateSuffix, ":"); + // Format date-time string: + HBufC* formatted = HBufC::NewLC(aDtStr.Length()); + formatted->Des().Copy(aDtStr); + + TBool hasTimePart = EFalse; + TBool hasDateTimeSeparator = EFalse; + TInt pos = 0; + + // Date and month numbering starts from 0 in Symbian, so first + // we need to decrease the date and month by one. Script format is following: + // yyyy-mm-ddThh:mm:ss + // Remove also date field separators ('-') + while( (pos = formatted->Find(KDateFieldSeparator)) != KErrNotFound ) + { + // decrease month or date by one + + // First char. Can be zero also: + TInt newValue = 0; + const TPtrC& char1 = formatted->Des().Mid(pos+1).Left(1); + newValue = 10 * ConvertStrToIntL(char1); + // Next char: + const TPtrC& char2 = formatted->Des().Mid(pos+2).Left(1); + newValue += ConvertStrToIntL(char2); + + if( newValue > 0 ) + { + --newValue; + } + + _LIT(KTemp, "%d"); + HBufC* formatBuf = KTemp().AllocLC(); + HBufC* buf = 0; + if( newValue < 10 ) + buf = HBufC::NewLC(1); + else + buf = HBufC::NewLC(2); + + TPtr temp(buf->Des()); + temp.Format(*formatBuf, newValue); + if( newValue < 10 ) + { + formatted->Des()[pos+1] = TChar('0'); + formatted->Des()[pos+2] = buf->Des()[0]; + } + else + { + formatted->Des()[pos+1] = buf->Des()[0]; + formatted->Des()[pos+2] = buf->Des()[1]; + } + // Finally, delete the '-' separator: + formatted->Des().Delete(pos, 1); + CleanupStack::PopAndDestroy(2); + } + + while( (pos = formatted->Find(KTimeFieldSeparator)) != KErrNotFound ) + { + formatted->Des().Delete(pos, 1); + hasTimePart = ETrue; + } + + // Replace 'T' with ':': + if( (pos = formatted->Find(KDateTimeSeparator)) != KErrNotFound ) + { + formatted->Des().Replace(pos, 1, KDateSuffix); + hasDateTimeSeparator = ETrue; + } + + if( hasTimePart ) + formatted->Des().Append(KTimeSuffix); + else if( !hasDateTimeSeparator ) + formatted->Des().Append(KDateSuffix); + + + TTime ret; + ret.Set(*formatted); + CleanupStack::PopAndDestroy(); // formatted + return ret; + } + +TInt CCreatorScriptElement::CompareIgnoreCase(const TDesC& aStr1, const TDesC& aStr2 ) const + { + // Get default collation method: + TCollationMethod defaultCollationMethod = *Mem::CollationMethodByIndex(0); + + // Add ignore case flag: + defaultCollationMethod.iFlags |= TCollationMethod::EFoldCase; + + return aStr1.CompareF(aStr2); + } + +void CCreatorScriptElement::SetContentToTextParamL(HBufC*& aPtr, const TDesC& aContent ) + { + delete aPtr; + aPtr = 0; + aPtr = HBufC::NewL(aContent.Length()); + aPtr->Des().Copy(aContent); + } + +/** + * Increases phonenumber by aDelta. + */ +void CCreatorScriptElement::IncreasePhoneNumL( const TDesC& aOriginal, TInt aDelta, HBufC* aIncreased ) const + { + LOGSTRING("Creator: CCreatorMessageElement::IncreasePhoneNumL"); + __ASSERT_ALWAYS( aDelta >= 0, User::Panic( _L("IncreasePhoneNumL"), KErrArgument ) ); + + // special cases, that are handled: + // +9 -> +9, +10, +11... + // +3584098#99 -> +3584098#99, +3584098#100, +3584098#101... + // # -> #0, #1, #2... + // 123# -> 123#0, 123#1, 123#2... + // 099 -> 099, 100, 101... + + // find out if there are any special characters, like # p or *, in the original number + TInt startIndex( aOriginal.Length() -1 ); + while ( startIndex >= 0 && + aOriginal[startIndex] >= '0' && + aOriginal[startIndex] <= '9' ) + { + startIndex--; + } + startIndex++; + + // append original head that may contain any non number characters + aIncreased->Des().Append( aOriginal.Left( startIndex ) ); + + TBuf tailBuf; + if ( aOriginal.Length() > startIndex ) + { + tailBuf.Copy( aOriginal.Right( aOriginal.Length() -startIndex ) ); + } + + // parse the tail part of the original number + TInt64 intVal = 0; + if ( aOriginal.Length() > startIndex ) + { + TLex lex( tailBuf ); + User::LeaveIfError( lex.Val( intVal ) ); // this loses leading zeros + } + + // increase + intVal += aDelta; + + // restore leading zeros to tail, if any + TBuf resultTailNoZeros; + resultTailNoZeros.AppendNum( intVal ); + TInt tailLeadingZerosToRestore = tailBuf.Length() - resultTailNoZeros.Length(); + for ( TInt i = 0; i < tailLeadingZerosToRestore; i++ ) + { + aIncreased->Des().AppendNum( 0 ); + } + + // and finally, append the increased value as tail part of the result + aIncreased->Des().Append( resultTailNoZeros ); + } + +CCreatorScriptRoot* CCreatorScriptRoot::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext) + { + CCreatorScriptRoot* self = new (ELeave) CCreatorScriptRoot(aEngine); + CleanupStack::PushL(self); + self->ConstructL(aName, aContext); + CleanupStack::Pop(); + return self; + } +CCreatorScriptRoot::CCreatorScriptRoot(CCreatorEngine* aEngine) +: +CCreatorScriptElement(aEngine) + { + iIsRoot=ETrue; + } + + +CCreatorCalendarElementBase* CCreatorCalendarElementBase::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext) + { + CCreatorCalendarElementBase* self = new (ELeave) CCreatorCalendarElementBase(aEngine); + CleanupStack::PushL(self); + self->ConstructL(aName, aContext); + CleanupStack::Pop(); + return self; + } +CCreatorCalendarElementBase::CCreatorCalendarElementBase(CCreatorEngine* aEngine) +: +CCreatorScriptElement(aEngine) + { } + +CCreatorMessageElementBase* CCreatorMessageElementBase::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext) + { + CCreatorMessageElementBase* self = new (ELeave) CCreatorMessageElementBase(aEngine); + CleanupStack::PushL(self); + self->ConstructL(aName, aContext); + CleanupStack::Pop(); + return self; + } +CCreatorMessageElementBase::CCreatorMessageElementBase(CCreatorEngine* aEngine) +: +CCreatorScriptElement(aEngine) + { } diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/src/creator_scriptelementfactory.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/src/creator_scriptelementfactory.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,121 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +#include "creator_traces.h" +#include "creator_scriptelementfactory.h" +#include "creator_contactelement.h" +#include "creator_calendarelement.h" +#include "creator_messageelement.h" +#include "creator_fileelement.h" +//#include "creator_browserelement.h" +#include "creator_logelement.h" +//#include "creator_noteelement.h" +//#include "creator_impselement.h" +#include "creator_landmarkelement.h" +#include "creator_mailboxelement.h" +//#include "creator_connectionmethodelement.h" + +CCreatorScriptElement* TCreatorScriptElementFactory::CreateElementL(CCreatorEngine* aEngine, const TDesC& aElementName, const TDesC& aContext ) + { + LOGSTRING2("TCreatorScriptElementFactory::CreateElementL: %S", &aElementName); + + if( aContext.Length() >= KFields().Length() && + aContext.Right(KFields().Length()) == KFields) + { + // This is a field element under 'fields'. + return CCreatorScriptElement::NewL(aEngine, aElementName, aContext); + } + else if( aElementName == creatorcontact::KContact ) + { + return CCreatorContactElement::NewL(aEngine, aElementName, aContext); + } + else if( aElementName == creatorcontact::KContactSet) + { + return CCreatorContactSetElement::NewL(aEngine, aElementName, aContext); + } + else if( aElementName == creatorcontact::KContactGroup ) + { + return CCreatorContactGroupElement::NewL(aEngine, aElementName, aContext); + } + else if( aElementName == KFields) + { + return CCreatorScriptElement::NewL(aEngine, aElementName, aContext); + } + else if( aElementName == KScript ) + { + return CCreatorScriptRoot::NewL(aEngine, aElementName, aContext); + } + else if( aElementName == creatorcalendar::KCalendar ) + { + return CCreatorCalendarElement::NewL(aEngine, aElementName, aContext); + } + else if( aElementName == creatormsg::KMessage ) + { + return CCreatorMessageElement::NewL(aEngine, aElementName, aContext); + } + else if( aElementName == creatorfile::KFile ) + { + return CCreatorFileElement::NewL(aEngine, aElementName, aContext); + } + /* + else if( aElementName == creatorbrowser::KBookmark || + aElementName == creatorbrowser::KBookmarkFolder || + aElementName == creatorbrowser::KSavedPage || + aElementName == creatorbrowser::KSavedPageFolder ) + { + return CCreatorBrowserElement::NewL(aEngine, aElementName, aContext); + } + */ + else if( aElementName == creatorlog::KLog ) + { + return CCreatorLogElement::NewL(aEngine, aElementName, aContext); + } +/* + else if( aElementName == creatornote::KNote ) + { + return CCreatorNoteElement::NewL(aEngine, aElementName, aContext); + } +*/ +/* + #ifdef __PRESENCE + else if( aElementName == creatorimps::KImpsServer ) + { + return CCreatorImpsServerElement::NewL(aEngine, aElementName, aContext); + } + #endif // __PRESENCE +*/ + else if( aElementName == creatorlandmark::KLandmark ) + { + return CCreatorLandmarkElement::NewL(aEngine, aElementName, aContext); + } + else if( aElementName == creatormailbox::Kmailbox ) + { + return CCreatorMailboxElement::NewL(aEngine, aElementName, aContext); + } +/* + else if( aElementName == creatorconnectionmethod::KCm ) + { + return CCreatorConnectionMethodElement::NewL(aEngine, aElementName, aContext); + } +*/ + else + { + return CCreatorScriptElement::NewL(aEngine, aElementName, aContext); + } + } diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/src/creator_scriptentry.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/src/creator_scriptentry.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,682 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +#include +#include +#include + +#include "engine.h" +#include "enginewrapper.h" +#include "creator_traces.h" +#include "creator_factory.h" +#include "creator_scriptentry.h" + + + +const TInt KReadBufSize = 8192; + +// Creator random data file filter +_LIT(KRandomDataFileFilter, "*.creatordataxml"); + +// --------------------------------------------------------------------------- + + +CCommandParser* CCommandParser::NewL(CCreatorEngine* aEngine) + { + CCommandParser* self = CCommandParser::NewLC(aEngine); + CleanupStack::Pop(self); + return self; + } + +CCommandParser* CCommandParser::NewLC(CCreatorEngine* aEngine) + { + CCommandParser* self = new (ELeave) CCommandParser; + CleanupStack::PushL(self); + self->ConstructL(aEngine); + return self; + } + +CCommandParser::CCommandParser() + { + } + +void CCommandParser::ConstructL(CCreatorEngine* aEngine) + { + LOGSTRING("Creator: CCommandParser::ConstructL"); + + iEngine = aEngine; + + iReadBuf = HBufC8::NewL(KReadBufSize); + } + +CCommandParser::~CCommandParser() + { + LOGSTRING("Creator: CCommandParser::~CCommandParser"); + + if (iSearchArray){ + delete iSearchArray; + iSearchArray = NULL; + } + + if (iReadBuf) + delete iReadBuf; + } + +// --------------------------------------------------------------------------- + +void CCommandParser::QueryDialogClosedL(TBool aPositiveAction, TInt aUserData) + { + User::LeaveIfNull(iSearchArray); + + if( aUserData == EGetingScript ) + { + if(aPositiveAction) + { + iObserver->ScriptChosenL( ETrue, iSearchArray->MdcaPoint(iSelectedItem) ); + } + else + { + iObserver->ScriptChosenL( EFalse ); + } + } + else if( aUserData == EGetingRandomDataFile && iSearchArray->Count() ) + { + if(aPositiveAction) + { + TFileName fileName; + if (iSelectedItem == (iSearchArray->Count() - 1)) + { + // "default" (resource file) selected + fileName.Copy(KNullDesC); + } + else + { + // xml file selected + fileName.Copy(iSearchArray->MdcaPoint(iSelectedItem)); + } + iObserver->RandomDataFileChosenL( ETrue, fileName ); + } + else + { + iObserver->RandomDataFileChosenL( EFalse ); + } + } + } + +// --------------------------------------------------------------------------- +//#if(!defined __SERIES60_30__ && !defined __SERIES60_31__) +void CCommandParser::OpenScriptL() {} +TBool CCommandParser::OpenScriptL(MCommandParserObserver* aObserver) + { + LOGSTRING("Creator: CCommandParser::OpenScriptL"); + + User::LeaveIfNull( aObserver ); + iObserver = aObserver; + iSelectedItem = 0; + + TBool ret = EFalse; + + // init the search array + delete iSearchArray; + iSearchArray = NULL; + iSearchArray = new(ELeave) CDesCArrayFlat(20); + + // wait dialog + // TODO + //CAknGlobalNote* waitDialog = CAknGlobalNote::NewLC(); + //waitDialog->SetSoftkeys(R_AVKON_SOFTKEYS_CANCEL); + //TInt dialogId = waitDialog->ShowNoteL(EAknGlobalWaitNote, _L("Searching")); + + + // search all the .creator files from the phone + TInt err; + TRAP(err, FindFiles(_L("*.creatorxml"), _L("\\"))); + + TRAP(err, FindFiles(_L("*.creatorxml"), _L("\\system\\apps\\Creator\\"))); + + TRAP(err, FindFiles(_L("*.creatorxml"), _L("\\data\\"))); + TRAP(err, FindFilesRecursiveL(_L("*.creatorxml"), _L("\\data\\"))); + + TRAP(err, FindFiles(_L("*.creatorxml"), _L("\\documents\\"))); + TRAP(err, FindFilesRecursiveL(_L("*.creatorxml"), _L("\\documents\\"))); + + TRAP(err, FindFiles(_L("*.creatorxml"), _L("\\creator\\"))); + TRAP(err, FindFilesRecursiveL(_L("*.creatorxml"), _L("\\creator\\"))); + + TRAP(err, FindFiles(_L("*.creatorxml"), _L("\\scripts\\"))); + TRAP(err, FindFilesRecursiveL(_L("*.creatorxml"), _L("\\scripts\\"))); + + TRAP(err, FindFiles(_L("*.creatorxml"), _L("\\temp\\"))); + TRAP(err, FindFilesRecursiveL(_L("*.creatorxml"), _L("\\temp\\"))); + + TRAP(err, FindFiles(_L("*.creatorxml"), _L("\\system\\temp\\"))); + TRAP(err, FindFilesRecursiveL(_L("*.creatorxml"), _L("\\system\\temp\\"))); + + TRAP(err, FindFiles(_L("*.creatorxml"), _L("\\private\\20011383\\"))); + TRAP(err, FindFilesRecursiveL(_L("*.creatorxml"), _L("\\private\\20011383\\"))); + + TRAP(err, FindFilesRecursiveL(_L("*.creatorxml"), _L("\\private\\1000484b\\"))); + + + // remove the wait dialog + // TODO + //waitDialog->CancelNoteL(dialogId); + //CleanupStack::PopAndDestroy(); //waitDialog; + + + if ( iSearchArray->MdcaCount() > 0) + { + // create a file name array based on the iSearchArray + CDesCArray* fileNameArray = new(ELeave) CDesCArrayFlat(iSearchArray->MdcaCount()); + CleanupStack::PushL(fileNameArray); + + for (TInt i=0; iMdcaCount(); i++) + { + + TParse filename; // file name parser + filename.Set(iSearchArray->MdcaPoint(i), NULL, NULL); + + if ( filename.Drive()[0] == 'e' || filename.Drive()[0] == 'E') // MMC + { + TFileName nameMMC; + nameMMC.Append(filename.Name()); + nameMMC.Append(_L("\t0")); // MMC icon + fileNameArray->AppendL(nameMMC); + } + else + { + fileNameArray->AppendL(filename.Name()); + } + } + + ret = iEngine->GetEngineWrapper()->PopupListDialog(_L("Select script"), fileNameArray, &iSelectedItem, this, EGetingScript); + CleanupStack::PopAndDestroy(fileNameArray); + } + else // no scripts found from the search paths + { + iEngine->GetEngineWrapper()->ShowNote(_L("No scripts found")); + delete iSearchArray; + iSearchArray = NULL; + } + + + return ret; + } +/* +#else +// --------------------------------------------------------------------------- +void CCommandParser::OpenScriptL() + { + LOGSTRING("Creator: CCommandParser::OpenScriptL"); + + // init the search array + iSearchArray = new(ELeave) CDesCArrayFlat(500); + + // wait dialog + CAknGlobalNote* waitDialog = CAknGlobalNote::NewLC(); + waitDialog->SetSoftkeys(R_AVKON_SOFTKEYS_CANCEL); + TInt dialogId = waitDialog->ShowNoteL(EAknGlobalWaitNote, _L("Searching")); + + + // search all the .creator files from the phone + TInt err; + TRAP(err, FindFiles(_L("*.creator"), _L("\\"))); + + TRAP(err, FindFiles(_L("*.creator"), _L("\\system\\apps\\Creator\\"))); + + TRAP(err, FindFiles(_L("*.creator"), _L("\\data\\"))); + TRAP(err, FindFilesRecursiveL(_L("*.creator"), _L("\\data\\"))); + + TRAP(err, FindFiles(_L("*.creator"), _L("\\documents\\"))); + TRAP(err, FindFilesRecursiveL(_L("*.creator"), _L("\\documents\\"))); + + TRAP(err, FindFiles(_L("*.creator"), _L("\\creator\\"))); + TRAP(err, FindFilesRecursiveL(_L("*.creator"), _L("\\creator\\"))); + + TRAP(err, FindFiles(_L("*.creator"), _L("\\scripts\\"))); + TRAP(err, FindFilesRecursiveL(_L("*.creator"), _L("\\scripts\\"))); + + TRAP(err, FindFiles(_L("*.creator"), _L("\\temp\\"))); + TRAP(err, FindFilesRecursiveL(_L("*.creator"), _L("\\temp\\"))); + + TRAP(err, FindFiles(_L("*.creator"), _L("\\system\\temp\\"))); + TRAP(err, FindFilesRecursiveL(_L("*.creator"), _L("\\system\\temp\\"))); + + TRAP(err, FindFiles(_L("*.creator"), _L("\\private\\101FA751\\"))); + TRAP(err, FindFilesRecursiveL(_L("*.creator"), _L("\\private\\101FA751\\"))); + + TRAP(err, FindFilesRecursiveL(_L("*.creator"), _L("\\private\\1000484b\\"))); + + + // remove the wait dialog + waitDialog->CancelNoteL(dialogId); + CleanupStack::PopAndDestroy(); //waitDialog; + + + if ( iSearchArray->MdcaCount() > 0) + { + // create a file name array based on the iSearchArray + CDesCArray* fileNameArray = new(ELeave) CDesCArrayFlat(iSearchArray->MdcaCount()); + CleanupStack::PushL(fileNameArray); + + for (TInt i=0; iMdcaCount(); i++) + { + + TParse filename; // file name parser + filename.Set(iSearchArray->MdcaPoint(i), NULL, NULL); + + if ( filename.Drive()[0] == 'e' || filename.Drive()[0] == 'E') // MMC + { + TFileName nameMMC; + nameMMC.Append(filename.Name()); + nameMMC.Append(_L("\t0")); // MMC icon + fileNameArray->AppendL(nameMMC); + } + else + { + fileNameArray->AppendL(filename.Name()); + } + } + CleanupStack::Pop(fileNameArray); + + + // create a popup list + CAknSinglePopupMenuStyleListBox* listBox = new(ELeave) CAknSinglePopupMenuStyleListBox; + CleanupStack::PushL(listBox); + CAknPopupList* popupList = CAknPopupList::NewL( listBox, R_AVKON_SOFTKEYS_SELECT_CANCEL, AknPopupLayouts::EMenuWindow ); + CleanupStack::PushL(popupList); + popupList->SetTitleL(_L("Select script")); + listBox->ConstructL( popupList, EAknListBoxSelectionList|EAknListBoxLoopScrolling ); + listBox->CreateScrollBarFrameL( ETrue ); + listBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto); + listBox->Model()->SetItemTextArray( fileNameArray ); + listBox->Model()->SetOwnershipType( ELbmOwnsItemArray ); // !!! + listBox->HandleItemAdditionL(); + + + // define MMC icon + MAknsSkinInstance* skin = AknsUtils::SkinInstance(); + _LIT( KFLDMemoryCardUiBitmapFile, "z:aknmemorycardui.mbm" ); + CAknIconArray* iconArray = new( ELeave ) CAknIconArray( 1 ); + listBox->ItemDrawer()->ColumnData()->SetIconArray( iconArray ); + + TParse* fp = new(ELeave) TParse(); + fp->Set(KFLDMemoryCardUiBitmapFile, &KDC_APP_BITMAP_DIR, NULL); + TFileName resourceFileName( fp->FullName() ); + delete fp; + + CGulIcon* icon = AknsUtils::CreateGulIconL( skin, KAknsIIDQgnIndiMmcAdd, + resourceFileName, + EMbmAknmemorycarduiQgn_indi_mmc_add, + EMbmAknmemorycarduiQgn_indi_mmc_add_mask ); + CleanupStack::PushL( icon ); + iconArray->AppendL( icon ); + CleanupStack::Pop( icon ); + + + // execute dialog + TBool result = popupList->ExecuteLD(); + CleanupStack::Pop(); // popupList + + if ( result ) + { + // open the file for reading + RFile file; + User::LeaveIfError(file.Open(CEikonEnv::Static()->FsSession(), iSearchArray->MdcaPoint(listBox->CurrentItemIndex()), EFileRead)); + while (ReadLineFromFileL(file) == KErrNone) + { + iReadBuf->Des().Trim(); // delete leading and trailing white space + + if (iReadBuf->Length() < 5) // command too short, ignoring... + { + //CEikonEnv::Static()->InfoMsg(_L("Corrupted line")); + } + + // check it's a valid line: first char is A-Z and the line ends to ';' + else if (iReadBuf->Des()[0] >= 'A' && iReadBuf->Des()[0] <= 'Z' && iReadBuf->Des()[iReadBuf->Length()-1] == ';') + { + // this line is valid -> parse the command + ParseCommandFromDescriptorL(); + } + else + { + //CEikonEnv::Static()->InfoMsg(_L("Not a valid line")); + } + + } + + file.Close(); + + // show a note if there were no valid commands in the script + if (iEngine->CommandArrayCount() == 0) + { + CAknInformationNote* note = new(ELeave) CAknInformationNote; + note->ExecuteLD(_L("No valid commands in this script")); + } + + } + + CleanupStack::PopAndDestroy(); //listBox + } + + else // no scripts found from the search paths + { + CAknInformationNote* note = new (ELeave) CAknInformationNote; + note->ExecuteLD(_L("No scripts found")); + } + + + delete iSearchArray; + iSearchArray = NULL; + + } +#endif +*/ + +TBool CCommandParser::GetRandomDataFilenameL(MCommandParserObserver *aObserver) + { + LOGSTRING("Creator: CCommandParser::GetRandomDataFilenameL"); + TBool ret = EFalse; + + User::LeaveIfNull( aObserver ); + iObserver = aObserver; + iSelectedItem = 0; + + // init the search array + if (iSearchArray) + { + delete iSearchArray; + iSearchArray = NULL; + } + iSearchArray = new(ELeave) CDesCArrayFlat(500); + + /* TODO: + // wait dialog + CAknGlobalNote* waitDialog = CAknGlobalNote::NewLC(); + waitDialog->SetSoftkeys(R_AVKON_SOFTKEYS_CANCEL); + TInt dialogId = waitDialog->ShowNoteL(EAknGlobalWaitNote, _L("Searching")); + */ + + + // search all the creator random data files from the phone + TInt err; + TRAP(err, FindFiles(KRandomDataFileFilter, _L("\\"))); + + TRAP(err, FindFiles(KRandomDataFileFilter, _L("\\system\\apps\\Creator\\"))); + + TRAP(err, FindFiles(KRandomDataFileFilter, _L("\\data\\"))); + TRAP(err, FindFilesRecursiveL(KRandomDataFileFilter, _L("\\data\\"))); + + TRAP(err, FindFiles(KRandomDataFileFilter, _L("\\documents\\"))); + TRAP(err, FindFilesRecursiveL(KRandomDataFileFilter, _L("\\documents\\"))); + + TRAP(err, FindFiles(KRandomDataFileFilter, _L("\\creator\\"))); + TRAP(err, FindFilesRecursiveL(KRandomDataFileFilter, _L("\\creator\\"))); + + TRAP(err, FindFiles(KRandomDataFileFilter, _L("\\scripts\\"))); + TRAP(err, FindFilesRecursiveL(KRandomDataFileFilter, _L("\\scripts\\"))); + + TRAP(err, FindFiles(KRandomDataFileFilter, _L("\\temp\\"))); + TRAP(err, FindFilesRecursiveL(KRandomDataFileFilter, _L("\\temp\\"))); + + TRAP(err, FindFiles(KRandomDataFileFilter, _L("\\system\\temp\\"))); + TRAP(err, FindFilesRecursiveL(KRandomDataFileFilter, _L("\\system\\temp\\"))); + + TRAP(err, FindFiles(KRandomDataFileFilter, _L("\\private\\20011383\\"))); + TRAP(err, FindFilesRecursiveL(KRandomDataFileFilter, _L("\\private\\20011383\\"))); + + TRAP(err, FindFilesRecursiveL(KRandomDataFileFilter, _L("\\private\\1000484b\\"))); + + + // remove the wait dialog + // TODO + //waitDialog->CancelNoteL(dialogId); + //CleanupStack::PopAndDestroy(); //waitDialog; + + + if (iSearchArray->MdcaCount() > 0) + { + // create a file name array based on the iSearchArray + CDesCArray* fileNameArray = new(ELeave) CDesCArrayFlat(iSearchArray->MdcaCount() + 1); + CleanupStack::PushL(fileNameArray); + + for (TInt i=0; iMdcaCount(); i++) + { + + TParse filename; // file name parser + filename.Set(iSearchArray->MdcaPoint(i), NULL, NULL); + + if ( filename.Drive()[0] == 'e' || filename.Drive()[0] == 'E') // MMC + { + TFileName nameMMC; + nameMMC.Append(filename.Name()); + nameMMC.Append(_L("\t0")); // MMC icon + fileNameArray->AppendL(nameMMC); + } + else + { + fileNameArray->AppendL(filename.Name()); + } + } + + // add "default" (resource file) to list + fileNameArray->AppendL(_L("Default")); + + ret = iEngine->GetEngineWrapper()->PopupListDialog(_L("Select random data file"), fileNameArray, &iSelectedItem, this, EGetingRandomDataFile); + CleanupStack::PopAndDestroy(fileNameArray); + } + else // no random data files found from the search paths + { + iEngine->GetEngineWrapper()->ShowNote(_L("No random data files found")); + delete iSearchArray; + iSearchArray = NULL; + } + + return ret; + } + +TInt CCommandParser::FindFilesRecursiveL(const TDesC& aFileName, const TDesC& aPath) + { + return CreatorFileUtils::FindFilesRecursiveL(iSearchArray, aFileName, aPath); + } +TInt CreatorFileUtils::FindFilesRecursiveL(CDesCArrayFlat* aFileArray, const TDesC& aFileName, const TDesC& aPath) + { + TInt err = KErrNone; + CDirScan* scan = CDirScan::NewLC(CEikonEnv::Static()->FsSession()); + scan->SetScanDataL(aPath, KEntryAttDir, ESortNone); + CDir* dirEntries = NULL; + + for(;;) + { + TRAP(err, scan->NextL(dirEntries)); + if (!dirEntries || (err!=KErrNone)) + break; + + for (TInt i=0; iCount(); i++) + { + TFileName path(scan->FullPath()); + path.Append((*dirEntries)[i].iName); + path.Append(_L("\\")); + FindFiles(aFileArray, aFileName, path); + } + delete(dirEntries); + } + + CleanupStack::PopAndDestroy(scan); + return err; + } + +TInt CreatorFileUtils::FindFiles(CDesCArrayFlat* aFileArray, const TDesC& aFileName, const TDesC& aPath) + { + TFindFile fileFinder(CEikonEnv::Static()->FsSession()); + CDir* fileList; + TInt err = fileFinder.FindWildByDir(aFileName, aPath, fileList); + + while (err == KErrNone) + { + for (TInt i=0; iCount(); i++) + { + TParse fullentry; + fullentry.Set((*fileList)[i].iName, &fileFinder.File(), NULL); + + TRAP(err, aFileArray->AppendL(fullentry.FullName())); + } + + delete fileList; + err = fileFinder.FindWild(fileList); + } + return err; + } +// --------------------------------------------------------------------------- + +TInt CCommandParser::FindFiles(const TDesC& aFileName, const TDesC& aPath) + { + return CreatorFileUtils::FindFiles(iSearchArray, aFileName, aPath); + } + +// --------------------------------------------------------------------------- + +TInt CCommandParser::ReadLineFromFileL(RFile& aInputFile) + { + LOGSTRING("Creator: CCommandParser::ReadLineFromFile"); + + _LIT8(KImcvCRLF, "\r\n"); + + TInt err = KErrNone; + + // Read into the buffer + HBufC8* tempLine = HBufC8::NewLC(KReadBufSize); + TPtr8 buffer = tempLine->Des(); + + // clear the targer + iReadBuf->Des().Copy(_L("")); + + // Get the current file position + TInt filePos = 0; + aInputFile.Seek(ESeekCurrent, filePos); + + // Read the buffer + err = aInputFile.Read(buffer); + + //end of file? + TInt s = buffer.Length(); + if ( s == 0) + err = KErrEof; + + if (err == KErrNone) + { + // Copy to the lfcr and then set the file pointer to the point after that + TInt pos = buffer.Find(KImcvCRLF); + if ( pos != -1) + { + iReadBuf->Des().Justify(buffer, pos, ELeft, ' '); + filePos += (pos+2); + + // Set the file pointer back to after the lfcr + aInputFile.Seek(ESeekStart, filePos); + } + // Else fill the whole buffer + else + { + iReadBuf->Des().Copy(buffer); + } + } + + CleanupStack::PopAndDestroy(); // tempLine + return err; + } + +// --------------------------------------------------------------------------- + +void CCommandParser::StrParserL(HBufC*& aDestinationBuf, TUint aToken) + { + // store old position + iParserOldPosition = iParserPosition; + + // make sure we are not reading outside of buffer + if (iParserPosition >= iReadBuf->Length() - 1) + return; + + // read until asked token + do + { + iParserPosition++; + } + while (iReadBuf->Des()[iParserPosition] != aToken && iParserPosition < iReadBuf->Des().Length()-1); + + // calculate length of the destination buffer + TInt bufferLength = iParserPosition-iParserOldPosition-1; + + // reset the destination buffer + if (aDestinationBuf) + { + delete aDestinationBuf; + aDestinationBuf = NULL; + } + + // allocate memory for the destination buffer + aDestinationBuf = HBufC::NewL(bufferLength); + + // copy data from the read buffer to the destination buffer + aDestinationBuf->Des().Copy(iReadBuf->Des().Mid(iParserOldPosition+1, bufferLength)); + } + +// --------------------------------------------------------------------------- + +void CCommandParser::StrParserL(HBufC8*& aDestinationBuf, TUint aToken) + { + // store old position + iParserOldPosition = iParserPosition; + + // make sure we are not reading outside of buffer + if (iParserPosition >= iReadBuf->Length() - 1) + return; + + // read until asked token + do + { + iParserPosition++; + } + while (iReadBuf->Des()[iParserPosition] != aToken && iParserPosition < iReadBuf->Des().Length()-1); + + // calculate length of the destination buffer + TInt bufferLength = iParserPosition-iParserOldPosition-1; + + // reset the destination buffer + if (aDestinationBuf) + { + delete aDestinationBuf; + aDestinationBuf = NULL; + } + + // allocate memory for the destination buffer + aDestinationBuf = HBufC8::NewL(bufferLength); + + // copy data from the read buffer to the destination buffer + aDestinationBuf->Des().Copy(iReadBuf->Des().Mid(iParserOldPosition+1, bufferLength)); + } + +//---------------------------------------------------------------------------- + +void CCommandParser::HandleSessionEventL(TMsvSessionEvent /*aEvent*/, TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/) // from MMsvSessionObserver + { + } + +//---------------------------------------------------------------------------- + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/src/creator_scriptparser.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/src/creator_scriptparser.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,394 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +#include +#include +#include +#include "creator_scriptparser.h" +#include "creator_scriptelementfactory.h" +#include "creator_traces.h" + +using namespace Xml; + +CCreatorScriptParser::CCreatorScriptParser() +: iDefaultElement(TCreatorScriptElementInfo(TCreatorScriptElementInfo::EStatusUndefined, 0)) + { + } +void CCreatorScriptParser::ConstructL(CCreatorEngine* aEngine) + { + LOGSTRING("Creator: CCreatorScriptParser::ConstructL"); + iEngine = aEngine; + } + +CCreatorScriptParser* CCreatorScriptParser::NewL(CCreatorEngine* aEngine) + { + LOGSTRING("Creator: CCreatorScriptParser::NewL"); + CCreatorScriptParser* self = CCreatorScriptParser::NewLC(aEngine); + CleanupStack::Pop(); + return self; + } +CCreatorScriptParser* CCreatorScriptParser::NewLC(CCreatorEngine* aEngine) + { + LOGSTRING("Creator: CCreatorScriptParser::NewLC"); + CCreatorScriptParser* self = new (ELeave) CCreatorScriptParser; + CleanupStack::PushL(self); + self->ConstructL(aEngine); + return self; + } + +CCreatorScriptParser::~CCreatorScriptParser() + { + delete iParser; + if( iElementStack.Count() > 0 ) + { + delete iElementStack[0].iElement; + } + iElementStack.Reset(); + iElementStack.Close(); + } + +void CCreatorScriptParser::GetTextFileMode(RFile& aFile, TInt& aFileSize) + { + LOGSTRING("Creator: CCreatorScriptParser::GetTextFileMode"); + iScriptTextFormat = EFormatANSIASCII; + + // if we are working with text files, check the type first + TBuf8<4> BOM; + + // first check for UTF-16 + if (aFileSize >= 2 && aFile.Read(0, BOM, 2) == KErrNone) + { + if (BOM.Length()==2 && BOM[0]==0xFF && BOM[1]==0xFE) + { + iScriptTextFormat = EFormatUTF16LE; + aFileSize -= 2; + return; + } + else if (BOM.Length()==2 && BOM[0]==0xFE && BOM[1]==0xFF) + { + iScriptTextFormat = EFormatUTF16BE; + aFileSize -= 2; + return; + } + } + // then check for UTF-8 + if (aFileSize >= 3 && aFile.Read(0, BOM, 3) == KErrNone) + { + if (BOM.Length()==3 && BOM[0]==0xEF && BOM[1]==0xBB && BOM[2]==0xBF) + { + iScriptTextFormat = EFormatUTF8; + aFileSize -= 3; + return; + } + } + + // none of those, seek back to beginning + TInt pos(0); + aFile.Seek(ESeekStart, pos); + } + + + +void CCreatorScriptParser::ParseL(const TDesC& aFileName) + { + LOGSTRING2("Creator: CCreatorScriptParser::ParseL: %S", &aFileName); + // Create and start XML-parser + if( iParser == 0) + { + _LIT8(KXmlMimeType, "text/xml"); + iParser = CParser::NewL(KXmlMimeType, *this); + } + + RFs filesession; + CleanupClosePushL(filesession); + User::LeaveIfError( filesession.Connect() ); + Xml::ParseL(*iParser, filesession, aFileName); + + CleanupStack::PopAndDestroy(&filesession); // filesession + } + +void CCreatorScriptParser::ParseL(RFile& aFile) + { + LOGSTRING("Creator: CCreatorScriptParser::ParseL"); + TInt filesize = 0; + aFile.Size(filesize); + GetTextFileMode(aFile, filesize); + // Create and start XML-parser + if( iParser == 0) + { + _LIT8(KXmlMimeType, "text/xml"); + iParser = CParser::NewL(KXmlMimeType, *this); + } + Xml::ParseL(*iParser, aFile); + } + +void CCreatorScriptParser::OnStartDocumentL(const Xml::RDocumentParameters& aDocParam, TInt aErrorCode) + { + LOGSTRING2("Creator: CCreatorScriptParser::OnStartDocumentL (Error code: %d)", aErrorCode); + User::LeaveIfError(aErrorCode); + } + +void CCreatorScriptParser::OnEndDocumentL(TInt aErrorCode) + { + LOGSTRING2("Creator: CCreatorScriptParser::OnEndDocumentL (Error code: %d)", aErrorCode); + User::LeaveIfError(aErrorCode); + iEngine->SortCommands(); + } + +void CCreatorScriptParser::OnStartPrefixMappingL( const RString& /*aPrefix*/, + const RString& /*aUri*/, + TInt aErrorCode) + { + LOGSTRING2("Creator: CCreatorScriptParser::OnStartPrefixMappingL (Error code: %d)", aErrorCode); + User::LeaveIfError(aErrorCode); + } + +void CCreatorScriptParser::OnEndPrefixMappingL(const RString& /*aPrefix*/, TInt aErrorCode) + { + LOGSTRING2("Creator: CCreatorScriptParser::OnEndPrefixMappingL (Error code: %d)", aErrorCode); + User::LeaveIfError(aErrorCode); + } +void CCreatorScriptParser::OnIgnorableWhiteSpaceL(const TDesC8& /*aBytes*/, TInt aErrorCode) + { + LOGSTRING2("Creator: CCreatorScriptParser::OnIgnorableWhiteSpaceL (Error code: %d)", aErrorCode); + User::LeaveIfError(aErrorCode); + } +void CCreatorScriptParser::OnSkippedEntityL(const RString& /*aName*/, TInt aErrorCode) + { + LOGSTRING2("Creator: CCreatorScriptParser::OnSkippedEntityL (Error code: %d)", aErrorCode); + User::LeaveIfError(aErrorCode); + } +void CCreatorScriptParser::OnProcessingInstructionL( const TDesC8& /*aTarget*/, + const TDesC8& /*aData*/, + TInt aErrorCode) + { + LOGSTRING2("Creator: CCreatorScriptParser::OnProcessingInstructionL (Error code: %d)", aErrorCode); + User::LeaveIfError(aErrorCode); + } +void CCreatorScriptParser::OnError(TInt aErrorCode) + { + LOGSTRING2("Creator: CCreatorScriptParser::OnError: %d", aErrorCode); + + iLastError = aErrorCode; + + // Delete all elements from the stack: + while(iElementStack.Count() > 0 ) + { + TCreatorScriptElementInfo previousElem = LastElementInfo(); + delete previousElem.iElement; + previousElem.iElement = 0; + iElementStack.Remove(iElementStack.Count()-1); + } + } +TAny* CCreatorScriptParser::GetExtendedInterface(const TInt32 aUid) + { + LOGSTRING2("Creator: CCreatorScriptParser::GetExtendedInterface (UID: %d)", aUid); + return this; + } + +const TCreatorScriptElementInfo& CCreatorScriptParser::LastElementInfo() const +{ + LOGSTRING("Creator: CCreatorScriptParser::LastElementInfo"); + if(iElementStack.Count() > 0) + { + return iElementStack[iElementStack.Count()-1]; + } + return iDefaultElement; +} + +/** + * Create an element and add attributes to it. + */ +void CCreatorScriptParser::OnStartElementL( const RTagInfo& aElement, + const RAttributeArray& aAttributes, + TInt aErrorCode) + { + LOGSTRING2("Creator: CCreatorScriptParser::OnStartElementL (Error code: %d)", aErrorCode); + User::LeaveIfError(aErrorCode); + const TDesC8& elementName8 = aElement.LocalName().DesC(); + HBufC* elementName16 = Convert8BitTo16BitLC(elementName8); + + const TCreatorScriptElementInfo& context = LastElementInfo(); + + CCreatorScriptElement* element = 0; + if( context.iElement ) + { + HBufC* fullContext = HBufC::NewL( + context.iElement->Context().Length() + + context.iElement->Name().Length() + + 2); + CleanupStack::PushL(fullContext); + if(context.iElement->Context() != KNullDesC && + context.iElement->Context().Length() > 0 ) + { + fullContext->Des().Copy(context.iElement->Context()); + _LIT(KContextSeparator, "::"); + fullContext->Des().Append(TPtrC(KContextSeparator)); + } + const TDesC& parentName = context.iElement->Name(); + if(parentName.Length() > 0 ) + { + fullContext->Des().Append(parentName); + } + element = TCreatorScriptElementFactory::CreateElementL( iEngine, + elementName16->Des(), + fullContext->Des()); + CleanupStack::PopAndDestroy(fullContext); // fullContext + } + else + { + element = TCreatorScriptElementFactory::CreateElementL(iEngine, elementName16->Des()); + } + + CleanupStack::PopAndDestroy(elementName16); + CleanupStack::PushL(element); + + if( element == 0 ) + { + // Add NULL pointer to stack. Otherwise the stack would go out of sync. in ::OnEndElement(). + TCreatorScriptElementInfo info(TCreatorScriptElementInfo::EStatusParsing, element); + iElementStack.AppendL(info); + CleanupStack::Pop(element); + return; + } + + // Add attributes to the element: + TInt attrCount = aAttributes.Count(); + for(TInt i = 0; i < attrCount; ++i) + { + const RAttribute& attribute = aAttributes[i]; + const RTagInfo& nameInfo = attribute.Attribute(); + const TDesC8& attrName8 = nameInfo.LocalName().DesC(); + const TDesC8& value8 = attribute.Value().DesC(); + // Convert data to 16 bit: + HBufC* attrName16 = Convert8BitTo16BitLC(attrName8); + HBufC* value16 = Convert8BitTo16BitLC(value8); + CCreatorScriptAttribute* scriptAttr = CCreatorScriptAttribute::NewLC(attrName16->Des(), value16->Des()); + element->AddAttributeL(scriptAttr); + CleanupStack::Pop(scriptAttr); + CleanupStack::PopAndDestroy(value16); + CleanupStack::PopAndDestroy(attrName16); + } + + // Save element to the stack: + TCreatorScriptElementInfo info(TCreatorScriptElementInfo::EStatusParsing, element); + iElementStack.AppendL(info); + CleanupStack::Pop(element); + } + +/** + * Executes the command if needed. Also caches the element for future use, if needed. + */ +void CCreatorScriptParser::OnEndElementL(const RTagInfo& /*aElement*/, TInt aErrorCode) + { + LOGSTRING2("Creator: CCreatorScriptParser::OnEndElementL (Error code: %d)", aErrorCode); + User::LeaveIfError(aErrorCode); + + if( iElementStack.Count() == 0 ) + { + return; + } + // Get element from the stack: + TCreatorScriptElementInfo elementInfo = LastElementInfo(); + + if( elementInfo.iElement == 0 ) + { + // Remove element from the stack: + iElementStack.Remove(iElementStack.Count()-1); + return; + } + + // Execute the command if this is a command element: + if( elementInfo.iElement->IsCommandElement() ) + { + elementInfo.iElement->ExecuteCommandL(); + } + + // Remove element from the stack: + iElementStack.Remove(iElementStack.Count()-1); + + // Get the previous element from the stack: + if( iElementStack.Count() > 0 ) + { + TCreatorScriptElementInfo previousElem = LastElementInfo(); + + if( previousElem.iElement->IsRoot() ) + { + // This element is not a sub-element (except of the root element, of course). + if( elementInfo.iElement->IsCacheNeeded() ) + { + // Add element to the cache, since it will be needed in future. + elementInfo.iElement->AddToCacheL(); + } + //else + // { + // Not needed anymore, so element can be deleted: + delete elementInfo.iElement; + elementInfo.iElement = 0; + // } + } + else + { + // There is a parent element (other than root), so we add this element + // as a sub-element fot it. + previousElem.iElement->AddSubElementL(elementInfo.iElement); + } + } + else + { + // Delete root element, which will delete recursively all sub-elements: + delete elementInfo.iElement; + elementInfo.iElement = 0; + } + } + +/** + * Add content to element. + */ +void CCreatorScriptParser::OnContentL(const TDesC8& aBytes, TInt aErrorCode) + { + LOGSTRING2("Creator: CCreatorScriptParser::OnContentL (Error code: %d)", aErrorCode); + User::LeaveIfError(aErrorCode); + if( iElementStack.Count() > 0 ) + { + HBufC* contentData = Convert8BitTo16BitLC(aBytes); + TCreatorScriptElementInfo elementInfo = iElementStack[iElementStack.Count()-1]; + if( elementInfo.iElement ) + { + elementInfo.iElement->AppendContentL(*contentData); + } + CleanupStack::PopAndDestroy(contentData); + } + } + +HBufC16* CCreatorScriptParser::Convert8BitTo16BitLC(const TDesC8& aInput) + { + LOGSTRING("Creator: CCreatorScriptParser::Convert8BitTo16BitLC"); + HBufC16* output = NULL; + + output = CnvUtfConverter::ConvertToUnicodeFromUtf8L(aInput); + + CleanupStack::PushL(output); + return output; + } + +TInt CCreatorScriptParser::GetError() const +{ + return iLastError; +} diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/engine/src/creator_wepsecuritysettings.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/engine/src/creator_wepsecuritysettings.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,145 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +#include "creator_traces.h" +#include "creator_wepsecuritysettings.h" +#include +//#include +#include + +//#include +//#include +//#include + + + +//---------------------------------------------------------------------------- + +CCreatorWEPSecuritySettings* CCreatorWEPSecuritySettings::NewL() + { + CCreatorWEPSecuritySettings* self = CCreatorWEPSecuritySettings::NewLC(); + CleanupStack::Pop(self); + return self; + } + +CCreatorWEPSecuritySettings* CCreatorWEPSecuritySettings::NewLC() + { + CCreatorWEPSecuritySettings* self = new (ELeave) CCreatorWEPSecuritySettings; + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +CCreatorWEPSecuritySettings::CCreatorWEPSecuritySettings() + { + } + +void CCreatorWEPSecuritySettings::ConstructL() + { + LOGSTRING("Creator: CCreatorWEPSecuritySettings::ConstructL"); + } + +CCreatorWEPSecuritySettings::~CCreatorWEPSecuritySettings() + { + LOGSTRING("Creator: CCreatorWEPSecuritySettings::~CCreatorWEPSecuritySettings"); + + + } + + + +//---------------------------------------------------------------------------- + + + +// --------------------------------------------------------- +// CWEPSecuritySettingsImpl::SaveL +// --------------------------------------------------------- +// +void CCreatorWEPSecuritySettings::SaveL( TUint32 /*aIapId*/, + CCommsDatabase& /*aCommsDb*/ ) const + { + /* + // Data of the key + TBuf8 iKeyData[KMaxNumberofKeys]; + + CCommsDbTableView* wLanServiceTable; + + // Caller MUST initiate a transaction, WE WILL NOT. + + wLanServiceTable = aCommsDb.OpenViewMatchingUintLC( + TPtrC( WLAN_SERVICE ), TPtrC( WLAN_SERVICE_ID ), aIapId ); + TInt errorCode = wLanServiceTable->GotoFirstRecord(); + + if ( errorCode == KErrNone ) + { + wLanServiceTable->UpdateRecord(); + } + else + { + TUint32 dummyUid( 0 ); //was KUidNone + User::LeaveIfError( wLanServiceTable->InsertRecord( dummyUid ) ); + + // Save link to LAN service + wLanServiceTable->WriteUintL( TPtrC( WLAN_SERVICE_ID ), aIapId ); + } + + // Save index of key in use + wLanServiceTable->WriteUintL( TPtrC( WLAN_WEP_INDEX ), + ( TUint32& ) iKeyInUse ); + + // Save index of key in use + wLanServiceTable->WriteUintL( TPtrC( NU_WLAN_AUTHENTICATION_MODE ), + ( TUint32& ) iAuthentication ); + + // Save first WEP key + wLanServiceTable->WriteTextL( TPtrC( NU_WLAN_WEP_KEY1 ), + iKeyData[KFirstKey] ); + + // Save second WEP key + wLanServiceTable->WriteTextL( TPtrC( NU_WLAN_WEP_KEY2 ), + iKeyData[KSecondKey] ); + + // Save third WEP key + wLanServiceTable->WriteTextL( TPtrC( NU_WLAN_WEP_KEY3 ), + iKeyData[KThirdKey] ); + + // Save fourth WEP key + wLanServiceTable->WriteTextL( TPtrC( NU_WLAN_WEP_KEY4 ), + iKeyData[KFourthKey] ); + + // Save the format of the keys + wLanServiceTable->WriteUintL( TPtrC( WLAN_WEP_KEY1_FORMAT ), + ( TUint32& ) iKeyFormat[KFirstKey] ); + + wLanServiceTable->WriteUintL( TPtrC( WLAN_WEP_KEY2_FORMAT ), + ( TUint32& ) iKeyFormat[KSecondKey] ); + + wLanServiceTable->WriteUintL( TPtrC( WLAN_WEP_KEY3_FORMAT ), + ( TUint32& ) iKeyFormat[KThirdKey] ); + + wLanServiceTable->WriteUintL( TPtrC( WLAN_WEP_KEY4_FORMAT ), + ( TUint32& ) iKeyFormat[KFourthKey] ); + + wLanServiceTable->PutRecordChanges(); + + CleanupStack::PopAndDestroy( wLanServiceTable ); // wLanServiceTable + */ + } + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/files/3GPP-70kB.dat Binary file utilityapps/creator/files/3GPP-70kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/files/AAC-100kB.dat Binary file utilityapps/creator/files/AAC-100kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/files/AMR-20kB.dat Binary file utilityapps/creator/files/AMR-20kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/files/BMP-25kB.dat Binary file utilityapps/creator/files/BMP-25kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/files/DOC-20kB.dat Binary file utilityapps/creator/files/DOC-20kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/files/Deck-1kB.dat Binary file utilityapps/creator/files/Deck-1kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/files/GIF-2kB.dat Binary file utilityapps/creator/files/GIF-2kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/files/HTML-20kB.dat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/files/HTML-20kB.dat Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,378 @@ + +
    +My HTML page +
    + +

    My HTML page

    + +
  • item 1
  • +
  • item 2
  • +
  • item 3
  • +
  • item 4
  • + +

    + COPYRIGHT LICENSE +

    + + NOKIA CORPORATION END-USER SOFTWARE AGREEMENT FOR + CARBIDE.C++ AND ASSOCIATED ON-DEVICE APPLICATIONS + +

    + +This Software Agreement ("Agreement") is between You (either an +individual or an entity), the End User, and Nokia Corporation +("Nokia"). The Agreement authorizes You to use the Software specified +in Clause 1 below, which may be stored on a CD-ROM, sent to You by +electronic mail, or downloaded from Nokia's Web pages or Servers or +from other sources under the terms and conditions set forth below. +This is an agreement on end-user rights and not an agreement for sale. +Nokia continues to own the copy of the Software and the physical media +contained in the sales package and any other copy that You are +authorized to make pursuant to this Agreement. + +Read this Agreement carefully before installing, downloading, or using +the Software. By clicking on the "I Accept" button while installing, +downloading, and/or using the Software, You agree to the terms and +conditions of this Agreement. If You do not agree to all of the terms +and conditions of this Agreement, promptly click the "Decline" or +"I Do Not Accept" button, cancel the installation or downloading, or +destroy or return the Software and accompanying documentation to +Nokia. YOU AGREE THAT YOUR USE OF THE SOFTWARE ACKNOWLEDGES THAT YOU +HAVE READ THIS AGREEMENT, UNDERSTAND IT, AND AGREE TO BE BOUND BY ITS +TERMS AND CONDITIONS. + +

    + +

    + COPYRIGHT LICENSE +

    + NOKIA CORPORATION END-USER SOFTWARE AGREEMENT FOR + CARBIDE.C++ AND ASSOCIATED ON-DEVICE APPLICATIONS +

    +This Software Agreement ("Agreement") is between You (either an +individual or an entity), the End User, and Nokia Corporation +("Nokia"). The Agreement authorizes You to use the Software specified +in Clause 1 below, which may be stored on a CD-ROM, sent to You by +electronic mail, or downloaded from Nokia's Web pages or Servers or +from other sources under the terms and conditions set forth below. +This is an agreement on end-user rights and not an agreement for sale. +Nokia continues to own the copy of the Software and the physical media +contained in the sales package and any other copy that You are +authorized to make pursuant to this Agreement. + +Read this Agreement carefully before installing, downloading, or using +the Software. By clicking on the "I Accept" button while installing, +downloading, and/or using the Software, You agree to the terms and +conditions of this Agreement. If You do not agree to all of the terms +and conditions of this Agreement, promptly click the "Decline" or +"I Do Not Accept" button, cancel the installation or downloading, or +destroy or return the Software and accompanying documentation to +Nokia. YOU AGREE THAT YOUR USE OF THE SOFTWARE ACKNOWLEDGES THAT YOU +HAVE READ THIS AGREEMENT, UNDERSTAND IT, AND AGREE TO BE BOUND BY ITS +TERMS AND CONDITIONS. + +

    + +

    + COPYRIGHT LICENSE +

    + NOKIA CORPORATION END-USER SOFTWARE AGREEMENT FOR + CARBIDE.C++ AND ASSOCIATED ON-DEVICE APPLICATIONS +

    +This Software Agreement ("Agreement") is between You (either an +individual or an entity), the End User, and Nokia Corporation +("Nokia"). The Agreement authorizes You to use the Software specified +in Clause 1 below, which may be stored on a CD-ROM, sent to You by +electronic mail, or downloaded from Nokia's Web pages or Servers or +from other sources under the terms and conditions set forth below. +This is an agreement on end-user rights and not an agreement for sale. +Nokia continues to own the copy of the Software and the physical media +contained in the sales package and any other copy that You are +authorized to make pursuant to this Agreement. + +Read this Agreement carefully before installing, downloading, or using +the Software. By clicking on the "I Accept" button while installing, +downloading, and/or using the Software, You agree to the terms and +conditions of this Agreement. If You do not agree to all of the terms +and conditions of this Agreement, promptly click the "Decline" or +"I Do Not Accept" button, cancel the installation or downloading, or +destroy or return the Software and accompanying documentation to +Nokia. YOU AGREE THAT YOUR USE OF THE SOFTWARE ACKNOWLEDGES THAT YOU +HAVE READ THIS AGREEMENT, UNDERSTAND IT, AND AGREE TO BE BOUND BY ITS +TERMS AND CONDITIONS. + +

    + +

    + COPYRIGHT LICENSE +

    + NOKIA CORPORATION END-USER SOFTWARE AGREEMENT FOR + CARBIDE.C++ AND ASSOCIATED ON-DEVICE APPLICATIONS +

    +This Software Agreement ("Agreement") is between You (either an +individual or an entity), the End User, and Nokia Corporation +("Nokia"). The Agreement authorizes You to use the Software specified +in Clause 1 below, which may be stored on a CD-ROM, sent to You by +electronic mail, or downloaded from Nokia's Web pages or Servers or +from other sources under the terms and conditions set forth below. +This is an agreement on end-user rights and not an agreement for sale. +Nokia continues to own the copy of the Software and the physical media +contained in the sales package and any other copy that You are +authorized to make pursuant to this Agreement. + +Read this Agreement carefully before installing, downloading, or using +the Software. By clicking on the "I Accept" button while installing, +downloading, and/or using the Software, You agree to the terms and +conditions of this Agreement. If You do not agree to all of the terms +and conditions of this Agreement, promptly click the "Decline" or +"I Do Not Accept" button, cancel the installation or downloading, or +destroy or return the Software and accompanying documentation to +Nokia. YOU AGREE THAT YOUR USE OF THE SOFTWARE ACKNOWLEDGES THAT YOU +HAVE READ THIS AGREEMENT, UNDERSTAND IT, AND AGREE TO BE BOUND BY ITS +TERMS AND CONDITIONS. + +

    + +

    + COPYRIGHT LICENSE +

    + NOKIA CORPORATION END-USER SOFTWARE AGREEMENT FOR + CARBIDE.C++ AND ASSOCIATED ON-DEVICE APPLICATIONS +

    +This Software Agreement ("Agreement") is between You (either an +individual or an entity), the End User, and Nokia Corporation +("Nokia"). The Agreement authorizes You to use the Software specified +in Clause 1 below, which may be stored on a CD-ROM, sent to You by +electronic mail, or downloaded from Nokia's Web pages or Servers or +from other sources under the terms and conditions set forth below. +This is an agreement on end-user rights and not an agreement for sale. +Nokia continues to own the copy of the Software and the physical media +contained in the sales package and any other copy that You are +authorized to make pursuant to this Agreement. + +Read this Agreement carefully before installing, downloading, or using +the Software. By clicking on the "I Accept" button while installing, +downloading, and/or using the Software, You agree to the terms and +conditions of this Agreement. If You do not agree to all of the terms +and conditions of this Agreement, promptly click the "Decline" or +"I Do Not Accept" button, cancel the installation or downloading, or +destroy or return the Software and accompanying documentation to +Nokia. YOU AGREE THAT YOUR USE OF THE SOFTWARE ACKNOWLEDGES THAT YOU +HAVE READ THIS AGREEMENT, UNDERSTAND IT, AND AGREE TO BE BOUND BY ITS +TERMS AND CONDITIONS. + +

    + +

    + COPYRIGHT LICENSE +

    + NOKIA CORPORATION END-USER SOFTWARE AGREEMENT FOR + CARBIDE.C++ AND ASSOCIATED ON-DEVICE APPLICATIONS +

    +This Software Agreement ("Agreement") is between You (either an +individual or an entity), the End User, and Nokia Corporation +("Nokia"). The Agreement authorizes You to use the Software specified +in Clause 1 below, which may be stored on a CD-ROM, sent to You by +electronic mail, or downloaded from Nokia's Web pages or Servers or +from other sources under the terms and conditions set forth below. +This is an agreement on end-user rights and not an agreement for sale. +Nokia continues to own the copy of the Software and the physical media +contained in the sales package and any other copy that You are +authorized to make pursuant to this Agreement. + +Read this Agreement carefully before installing, downloading, or using +the Software. By clicking on the "I Accept" button while installing, +downloading, and/or using the Software, You agree to the terms and +conditions of this Agreement. If You do not agree to all of the terms +and conditions of this Agreement, promptly click the "Decline" or +"I Do Not Accept" button, cancel the installation or downloading, or +destroy or return the Software and accompanying documentation to +Nokia. YOU AGREE THAT YOUR USE OF THE SOFTWARE ACKNOWLEDGES THAT YOU +HAVE READ THIS AGREEMENT, UNDERSTAND IT, AND AGREE TO BE BOUND BY ITS +TERMS AND CONDITIONS. + +

    + +

    + COPYRIGHT LICENSE +

    + NOKIA CORPORATION END-USER SOFTWARE AGREEMENT FOR + CARBIDE.C++ AND ASSOCIATED ON-DEVICE APPLICATIONS +

    +This Software Agreement ("Agreement") is between You (either an +individual or an entity), the End User, and Nokia Corporation +("Nokia"). The Agreement authorizes You to use the Software specified +in Clause 1 below, which may be stored on a CD-ROM, sent to You by +electronic mail, or downloaded from Nokia's Web pages or Servers or +from other sources under the terms and conditions set forth below. +This is an agreement on end-user rights and not an agreement for sale. +Nokia continues to own the copy of the Software and the physical media +contained in the sales package and any other copy that You are +authorized to make pursuant to this Agreement. + +Read this Agreement carefully before installing, downloading, or using +the Software. By clicking on the "I Accept" button while installing, +downloading, and/or using the Software, You agree to the terms and +conditions of this Agreement. If You do not agree to all of the terms +and conditions of this Agreement, promptly click the "Decline" or +"I Do Not Accept" button, cancel the installation or downloading, or +destroy or return the Software and accompanying documentation to +Nokia. YOU AGREE THAT YOUR USE OF THE SOFTWARE ACKNOWLEDGES THAT YOU +HAVE READ THIS AGREEMENT, UNDERSTAND IT, AND AGREE TO BE BOUND BY ITS +TERMS AND CONDITIONS. + +

    + +

    + COPYRIGHT LICENSE +

    + NOKIA CORPORATION END-USER SOFTWARE AGREEMENT FOR + CARBIDE.C++ AND ASSOCIATED ON-DEVICE APPLICATIONS +

    +This Software Agreement ("Agreement") is between You (either an +individual or an entity), the End User, and Nokia Corporation +("Nokia"). The Agreement authorizes You to use the Software specified +in Clause 1 below, which may be stored on a CD-ROM, sent to You by +electronic mail, or downloaded from Nokia's Web pages or Servers or +from other sources under the terms and conditions set forth below. +This is an agreement on end-user rights and not an agreement for sale. +Nokia continues to own the copy of the Software and the physical media +contained in the sales package and any other copy that You are +authorized to make pursuant to this Agreement. + +Read this Agreement carefully before installing, downloading, or using +the Software. By clicking on the "I Accept" button while installing, +downloading, and/or using the Software, You agree to the terms and +conditions of this Agreement. If You do not agree to all of the terms +and conditions of this Agreement, promptly click the "Decline" or +"I Do Not Accept" button, cancel the installation or downloading, or +destroy or return the Software and accompanying documentation to +Nokia. YOU AGREE THAT YOUR USE OF THE SOFTWARE ACKNOWLEDGES THAT YOU +HAVE READ THIS AGREEMENT, UNDERSTAND IT, AND AGREE TO BE BOUND BY ITS +TERMS AND CONDITIONS. + +

    + +

    + COPYRIGHT LICENSE +

    + NOKIA CORPORATION END-USER SOFTWARE AGREEMENT FOR + CARBIDE.C++ AND ASSOCIATED ON-DEVICE APPLICATIONS +

    +This Software Agreement ("Agreement") is between You (either an +individual or an entity), the End User, and Nokia Corporation +("Nokia"). The Agreement authorizes You to use the Software specified +in Clause 1 below, which may be stored on a CD-ROM, sent to You by +electronic mail, or downloaded from Nokia's Web pages or Servers or +from other sources under the terms and conditions set forth below. +This is an agreement on end-user rights and not an agreement for sale. +Nokia continues to own the copy of the Software and the physical media +contained in the sales package and any other copy that You are +authorized to make pursuant to this Agreement. + +Read this Agreement carefully before installing, downloading, or using +the Software. By clicking on the "I Accept" button while installing, +downloading, and/or using the Software, You agree to the terms and +conditions of this Agreement. If You do not agree to all of the terms +and conditions of this Agreement, promptly click the "Decline" or +"I Do Not Accept" button, cancel the installation or downloading, or +destroy or return the Software and accompanying documentation to +Nokia. YOU AGREE THAT YOUR USE OF THE SOFTWARE ACKNOWLEDGES THAT YOU +HAVE READ THIS AGREEMENT, UNDERSTAND IT, AND AGREE TO BE BOUND BY ITS +TERMS AND CONDITIONS. + +

    + +

    + COPYRIGHT LICENSE +

    + NOKIA CORPORATION END-USER SOFTWARE AGREEMENT FOR + CARBIDE.C++ AND ASSOCIATED ON-DEVICE APPLICATIONS +

    +This Software Agreement ("Agreement") is between You (either an +individual or an entity), the End User, and Nokia Corporation +("Nokia"). The Agreement authorizes You to use the Software specified +in Clause 1 below, which may be stored on a CD-ROM, sent to You by +electronic mail, or downloaded from Nokia's Web pages or Servers or +from other sources under the terms and conditions set forth below. +This is an agreement on end-user rights and not an agreement for sale. +Nokia continues to own the copy of the Software and the physical media +contained in the sales package and any other copy that You are +authorized to make pursuant to this Agreement. + +Read this Agreement carefully before installing, downloading, or using +the Software. By clicking on the "I Accept" button while installing, +downloading, and/or using the Software, You agree to the terms and +conditions of this Agreement. If You do not agree to all of the terms +and conditions of this Agreement, promptly click the "Decline" or +"I Do Not Accept" button, cancel the installation or downloading, or +destroy or return the Software and accompanying documentation to +Nokia. YOU AGREE THAT YOUR USE OF THE SOFTWARE ACKNOWLEDGES THAT YOU +HAVE READ THIS AGREEMENT, UNDERSTAND IT, AND AGREE TO BE BOUND BY ITS +TERMS AND CONDITIONS. + +

    + +

    + COPYRIGHT LICENSE +

    + NOKIA CORPORATION END-USER SOFTWARE AGREEMENT FOR + CARBIDE.C++ AND ASSOCIATED ON-DEVICE APPLICATIONS +

    +This Software Agreement ("Agreement") is between You (either an +individual or an entity), the End User, and Nokia Corporation +("Nokia"). The Agreement authorizes You to use the Software specified +in Clause 1 below, which may be stored on a CD-ROM, sent to You by +electronic mail, or downloaded from Nokia's Web pages or Servers or +from other sources under the terms and conditions set forth below. +This is an agreement on end-user rights and not an agreement for sale. +Nokia continues to own the copy of the Software and the physical media +contained in the sales package and any other copy that You are +authorized to make pursuant to this Agreement. + +Read this Agreement carefully before installing, downloading, or using +the Software. By clicking on the "I Accept" button while installing, +downloading, and/or using the Software, You agree to the terms and +conditions of this Agreement. If You do not agree to all of the terms +and conditions of this Agreement, promptly click the "Decline" or +"I Do Not Accept" button, cancel the installation or downloading, or +destroy or return the Software and accompanying documentation to +Nokia. YOU AGREE THAT YOUR USE OF THE SOFTWARE ACKNOWLEDGES THAT YOU +HAVE READ THIS AGREEMENT, UNDERSTAND IT, AND AGREE TO BE BOUND BY ITS +TERMS AND CONDITIONS. + +

    + +

    + COPYRIGHT LICENSE +

    + NOKIA CORPORATION END-USER SOFTWARE AGREEMENT FOR + CARBIDE.C++ AND ASSOCIATED ON-DEVICE APPLICATIONS +

    +This Software Agreement ("Agreement") is between You (either an +individual or an entity), the End User, and Nokia Corporation +("Nokia"). The Agreement authorizes You to use the Software specified +in Clause 1 below, which may be stored on a CD-ROM, sent to You by +electronic mail, or downloaded from Nokia's Web pages or Servers or +from other sources under the terms and conditions set forth below. +This is an agreement on end-user rights and not an agreement for sale. +Nokia continues to own the copy of the Software and the physical media +contained in the sales package and any other copy that You are +authorized to make pursuant to this Agreement. + +Read this Agreement carefully before installing, downloading, or using +the Software. By clicking on the "I Accept" button while installing, +downloading, and/or using the Software, You agree to the terms and +conditions of this Agreement. If You do not agree to all of the terms +and conditions of this Agreement, promptly click the "Decline" or +"I Do Not Accept" button, cancel the installation or downloading, or +destroy or return the Software and accompanying documentation to +Nokia. YOU AGREE THAT YOUR USE OF THE SOFTWARE ACKNOWLEDGES THAT YOU +HAVE READ THIS AGREEMENT, UNDERSTAND IT, AND AGREE TO BE BOUND BY ITS +TERMS AND CONDITIONS. + +

    + + + + \ No newline at end of file diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/files/JAD-1kB.dat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/files/JAD-1kB.dat Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,7 @@ +MIDlet-1: HelloWorld, , helloworld.HelloWorld +MIDlet-Icon: \HelloWorld.png +MIDlet-Jar-Size: 6817 +MIDlet-Jar-URL: HelloWorld.jar +MIDlet-Name: HelloWorld +MIDlet-Vendor: My Vendor +MIDlet-Version: 1.0 diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/files/JAR-10kB.dat Binary file utilityapps/creator/files/JAR-10kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/files/JP2-65kB.dat Binary file utilityapps/creator/files/JP2-65kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/files/JPEG-200kB.dat Binary file utilityapps/creator/files/JPEG-200kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/files/JPEG-25kB.dat Binary file utilityapps/creator/files/JPEG-25kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/files/JPEG-500kB.dat Binary file utilityapps/creator/files/JPEG-500kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/files/MIDI-10kB.dat Binary file utilityapps/creator/files/MIDI-10kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/files/MP3-250kB.dat Binary file utilityapps/creator/files/MP3-250kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/files/MP4-200kB.dat Binary file utilityapps/creator/files/MP4-200kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/files/MXMF-40kB.dat Binary file utilityapps/creator/files/MXMF-40kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/files/PNG-15kB.dat Binary file utilityapps/creator/files/PNG-15kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/files/PPT-40kB.dat Binary file utilityapps/creator/files/PPT-40kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/files/RAM-1kB.dat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/files/RAM-1kB.dat Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,1 @@ +rtsp://nokia.com \ No newline at end of file diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/files/RM-95kB.dat Binary file utilityapps/creator/files/RM-95kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/files/RNG-1kB.dat Binary file utilityapps/creator/files/RNG-1kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/files/SISX-10kB.dat Binary file utilityapps/creator/files/SISX-10kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/files/SVG-15kB.dat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/files/SVG-15kB.dat Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/files/SWF-15kB.dat Binary file utilityapps/creator/files/SWF-15kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/files/TIF-25kB.dat Binary file utilityapps/creator/files/TIF-25kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/files/TXT-10kB.dat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/files/TXT-10kB.dat Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,19 @@ +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... \ No newline at end of file diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/files/TXT-70kB.dat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/files/TXT-70kB.dat Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,147 @@ +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing.Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... TestiTesting... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing..ing... Testing... + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Te. Testing... Testing... Testing... Testing... Testing... Testing... Testing... + + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... + + +Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... Testing... ng... .. \ No newline at end of file diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/files/VCF-1kB.dat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/files/VCF-1kB.dat Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,17 @@ +BEGIN:VCARD +VERSION:2.1 +N:Smith;John +FN:John Smith +ORG:Firm +TITLE:Boss +NOTE;ENCODING=QUOTED-PRINTABLE:Liirum larum.=0D=0A +TEL;WORK;VOICE:132456798 +TEL;HOME;VOICE:654654987 +TEL;CELL;VOICE:0400654987654 +TEL;WORK;FAX:2321654987987 +ADR;WORK:;;Firmstreet 1;New City;Sawo;00000;Finland +LABEL;WORK;ENCODING=QUOTED-PRINTABLE:Firmstreet 1=0D=0ANew City, Sawo 00000=0D=0AFinland +URL;WORK:http://www.nokia.com +EMAIL;PREF;INTERNET:John.Smith@firm.com +REV:20080306T115812Z +END:VCARD diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/files/VCS-1kB.dat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/files/VCS-1kB.dat Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,15 @@ +BEGIN:VCALENDAR +PRODID:-//Microsoft Corporation//Outlook 11.0 MIMEDIR//EN +VERSION:1.0 +BEGIN:VEVENT +DTSTART:20080306T060000Z +DTEND:20080306T070000Z +LOCATION;ENCODING=QUOTED-PRINTABLE:Meeting room +UID:040000008200E00074C5B7101A82E00800000000000CEF7E917FC8010000000000000000100 + 000008AA6A7A7250C0A4E97153769E69DD064 +DESCRIPTION;ENCODING=QUOTED-PRINTABLE:Remember to bring laptop and document= +ation=0D=0A +SUMMARY;ENCODING=QUOTED-PRINTABLE:Meeting with BOSS +PRIORITY:3 +END:VEVENT +END:VCALENDAR diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/files/WAV-20kB.dat Binary file utilityapps/creator/files/WAV-20kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/files/WMA-50kB.dat Binary file utilityapps/creator/files/WMA-50kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/files/WMV-200kB.dat Binary file utilityapps/creator/files/WMV-200kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/files/XLS-15kB.dat Binary file utilityapps/creator/files/XLS-15kB.dat has changed diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/files/backup_registration.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/files/backup_registration.xml Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,8 @@ + + + + + + + + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/icons/Creator_application_icon_svgt.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/icons/Creator_application_icon_svgt.svg Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,491 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/icons/qgn_menu_creator.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/icons/qgn_menu_creator.svg Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/inc/engine.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/inc/engine.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,588 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef __CREATORENGINE_H__ +#define __CREATORENGINE_H__ + +// INCLUDES +#include +#include +#include +#include +#include +#include + +//#include +#include +#include +#include +//#include +#include +#include +#include //TFrameInfo + +#include "creator.hrh" +#include "creator_std.h" +#include "creator_randomdataparser.h" + +//class CCreatorAppUi; +class TCommand; +class CCreatorBrowser; +class CCreatorCalendarBase; +class CCreatorNotepad; +class CCreatorLogs; +//class CCreatorAccessPoints; +class CCreatorMailboxes; +class CCreatorIMPS; +class CCreatorFiles; +class CCreatorMessages; +class CCreatorLandmarks; +class MCreatorModuleBase; +class CCreatorPhonebookBase; +class CCreatorModuleBaseParameters; +//class CCreatorConnectionSettingsBase; +class CDictionaryFileStore; +class CImageDecoder; +class CFbsBitmap; +class CBitmapScaler; +class CCommandParser; +class EngineWrapper; +class CCreatorCmdScriptRun; + +static const TUid KUidCreatorApp = {0x20011383}; + +enum TListQueryId + { + R_GROUP_CREATION_TYPE_QUERY, + R_CONTACT_CREATION_TYPE_QUERY, + R_MESSAGE_TYPE_QUERY, + R_FOLDER_TYPE_QUERY, + R_UNREAD_QUERY, + R_ATTACHMENT_MULTI_SELECTION_QUERY, + R_AMS_ATTACHMENT_SINGLE_SELECTION_QUERY, + R_ATTACHMENT_SINGLE_SELECTION_QUERY + }; + +/* + * Interface for UI dialogs + */ +class MUIObserver + { +public: + /** + * Called when some dialog in UI is closed + * + * @since S60 10.1 + * @param aPositiveAction ETrue if "Ok", "Yes" or other "positive" button was pressed + * @param aUserData number that was passed to UI before dialog was opened + * @return None. + */ + virtual void QueryDialogClosedL(TBool aPositiveAction, TInt aUserData) = 0; + + }; + +/* + * Interface for CCommandParser + */ +class MCommandParserObserver + { +public: + /** + * Called when CCommandParser user has choosen script file + * + * @since S60 10.1 + * @param aSuccess ETrue if "Ok", "Yes" or other "positive" button was pressed + * @param aFileName filename chosen by user + * @return None. + */ + virtual void ScriptChosenL(TBool aSuccess, const TDesC& aFileName = KNullDesC) = 0; + + /** + * Called when CCommandParser user has choosen random data file + * + * @since S60 10.1 + * @param aSuccess ETrue if "Ok", "Yes" or other "positive" button was pressed + * @param aFileName filename chosen by user + * @return None. + */ + virtual void RandomDataFileChosenL(TBool aSuccess, const TDesC& aFileName = KNullDesC) = 0; + }; + +/** + * Device memory information + */ +class TMemoryDetails + { +public: + + TBuf<16> iFree; + TBuf<16> iSize; + TChar iDriveLetter; + + TBuf<16> iRamFree; + TBuf<16> iRomFree; + + TBool iENotAvailable; + + TBuf<16> iRamSize; + TBuf<16> iRomSize; + }; +// Common constant for undefined integer value: +const TInt KUndef = KErrNotFound; + +class CCreatorEngine : public CActive, public MUIObserver, public MCommandParserObserver + { +enum ECreatorEngineState{ + ECreatorEngineDeleteAllEntries, + ECreatorEngineDeleteAllCreatorEntries, +}; +public: + + enum TRandomStringType + { + EFirstName = 0, + ESurname, + ECompany, + EAddress, + EJobTitle, + EPhoneNumber, + EGroupName, + EMeetingReason, + EMeetingPlace, + EMemoText, + EAnniversaryReason, + EToDoText, + EReminderText, + EMessageSubject, + EMessageText, + ECity, + ECountry, + EPostcode, + EState, + EPobox, + EPrefix, + ESuffix, + ELandmarkName, + ELandmarkDescription + }; + + +// note! changing order will cause regression in other modules + + enum TTestDataPath + { + EJPEG_25kB = 0, + EJPEG_200kB, + EJPEG_500kB, + EPNG_15kB, + EGIF_2kB, + ERNG_1kB, + EMIDI_10kB, + EWAVE_20kB, + EAMR_20kB, + EExcel_15kB, + EWord_20kB, + EPowerPoint_40kB, + EText_10kB, + EText_70kB, + E3GPP_70kB, + EMP3_250kB, + EAAC_100kB, + ERM_95kB, + EBMP_25kB, + EHTML_20kB, + EJAD_1kB, + EJAR_10kB, + EJP2_65kB, + EMP4_200kB, + EMXMF_40kB, + ERAM_1kB, + ESVG_15kB, + ESWF_15kB, + ETIF_25kB, + EVCF_1kB, + EVCS_1kB, + ESISX_10kB, + EWMA_50kB, + EWMV_200kB, + ESavedDeck_1kB, + LAST_FILE_ID//When you add new items to enum, add them before last item, so random number generations does not need to be updated also + }; + + enum TRandomDateType + { + EDatePast, + EDateFuture + }; + +public: + /** + * Constructor: NewL + */ + static CCreatorEngine* NewL(EngineWrapper *aEngineWrapper); + /** + * Constructor: NewLC + */ + static CCreatorEngine* NewLC(EngineWrapper *aEngineWrapper); + ~CCreatorEngine(); + + inline const RPointerArray& GetMemoryDetailsList(){ return iMemoryDetailsList; }; + inline const TMemoryDetails& GetMemoryDetails(){ return iMemoryDetails; }; + inline EngineWrapper* GetEngineWrapper(){ return iEngineWrapper; }; + inline CCreatorPhonebookBase* GetPhonebook(){ return iPhonebook; }; + +private: + CCreatorEngine(); + /** + * EPOC default constructor for performing 2nd stage construction + */ + void ConstructL(EngineWrapper *aEngineWrapper); + + void RequestMemoryDetails(); + TBool MMC_OK() const; + void Init(); + void RunL(); + TInt RunError(TInt aError); + void DoCancel(); + + void ExecuteCommand(); + void StartEnginesL(); + void CheckForMoreCommandsL(); + + TBool IsDeleteCommand( TInt aCommand ); + + TInt ReadRandomDataL(const TRandomStringType aRandomStringType, + const TInt aResourceId, + const TDesC& aFilename, + const CCreatorRandomDataParser::TRandomDataType aRandomDataType); + void GenerateSourceImageFileL( const TTestDataPath aFileType, const TDesC& aFileName ); + void GenereteSourceTextFileL( const TDesC& aFileName, TInt aSize ); + +public: // from MUIObserver + /** + * Called when some dialog in UI is closed + * + * @since S60 10.1 + * @param aPositiveAction ETrue if "Ok", "Yes" or other "positive" button was pressed + * @param aUserData number that was passed to UI before dialog was opened + * @return ?description + */ + virtual void QueryDialogClosedL(TBool aPositiveAction, TInt aUserData); + +public: // from MCommandParserObserver + /** + * Called when CCommandParser user has choosen script file + * + * @since S60 10.1 + * @param aSuccess ETrue if "Ok", "Yes" or other "positive" button was pressed + * @param aFileName filename chosen by user + * @return None. + */ + virtual void ScriptChosenL(TBool aSuccess, const TDesC& aFileName = KNullDesC); + + /** + * Called when CCommandParser user has choosen random data file + * + * @since S60 10.1 + * @param aSuccess ETrue if "Ok", "Yes" or other "positive" button was pressed + * @param aFileName filename chosen by user + * @return None. + */ + virtual void RandomDataFileChosenL(TBool aSuccess, const TDesC& aFileName = KNullDesC); + +public: + void ExecuteOptionsMenuCommandL(TInt aCommand); + void RunScriptL(); + TInt RunScriptL(const TDesC& aScriptFile); + void ShutDownEnginesL(); + void ExecuteFirstCommandL(const TDesC& aText); + + void AppendToCommandArrayL(TInt aCommand, CCreatorModuleBaseParameters* aParameters, TInt aNumberOfEntries = 1); + TInt CommandArrayCount(); + + TPtrC TestDataPathL(enum TTestDataPath aTestDataPath); + TPtrC RandomSoundFileL(); // Returns temporary path, which will be removed on shutdown + void RandomPictureFileL(TDes& aPath); // aPath temporary path, which will be removed on shutdown + TPtrC CreateRandomSoundFileL(); // Copies file to new location and returns the new path + TPtrC CreateSoundFileL(TTestDataPath aId); // Copies file to new location and returns the new path + + void CopyFileL(const TFileName& aSourceFile, const TFileName& aTargetFile, TBool aOverwrite = EFalse ); + /* + * Gets attacment file id based on the file id string + * @return Attachment file id + * @param aAttachmentIdStr Attachment file id string + */ + TInt GetAttachmentIdL( const TDesC& aAttachmentIdStr ) const; + + TUint32 GetDefaultIAPL(); + TUint32 AccessPointNameToIdL(const TDesC& aAPName, TBool aAnyIfNotFound = EFalse ); + + TPtrC RandomString(enum TRandomStringType aRandomStringType); + TInt RandomNumber(TInt aRange); + TInt RandomNumber(TInt aMin, TInt aMax); + TTime RandomDate(TRandomDateType type, TInt aMinDays = 0, TInt aMaxDays = 360 ); + TTime RandomDate(TTime baseTime, TRandomDateType type, TInt aMinDays = 0, TInt aMaxDays = 360); + TTime RandomTime(TTime baseTime, TRandomDateType type, TInt aMinHours=0, TInt aMaxHours=24, TInt aMinMinutes=0, TInt aMaxMinutes=60 ); + CDesCArrayFlat* SoundFilesL(); + CDesCArrayFlat* PictureFilesL(); + + HBufC* CreateEmailAddressLC(); + HBufC* CreateHTTPUrlLC(); + HBufC* CreateRandomStringLC(TInt aStrLen); + + HBufC* CreateEmailAddressLC( + const TDesC& firstname, + const TDesC& lastname, + const TDesC& domain, + const TDesC& country ) const; + + HBufC* CreateUrlLC( + const TDesC& protocol, + const TDesC& prefix, + const TDesC& domain, + const TDesC& country) const; + + void SetDefaultPathForFileCommandL(TInt aCommand, TFileName& aPath); + + TBool GetRandomDataL(); + TBool GetRandomDataFromFileL(const TDesC& aFilename); + void CancelComplete(); + CDictionaryFileStore* FileStoreLC(); + void ReadEntryIdsFromStoreL( RArray& aEntryIds, const TUid aModuleUid ); + void WriteEntryIdsToStoreL( RArray& aEntryIds, const TUid aModuleUid ); + void ReadEntryIdsFromStoreL( RArray& aEntryIds, const TUid aModuleUid ); + void WriteEntryIdsToStoreL( RArray& aEntryIds, const TUid aModuleUid ); + void RemoveStoreL( const TUid aModuleUid ); + void ProgressDialogCancelledL(); + + void SortCommands(); + +private: + // needed by the engine itself + RTimer iTimer; + CEikonEnv* iEnv; + //CCreatorAppUi* iAppUi; + TInt iCurrentEntry; + TInt iFailedCommands; + + CDesCArrayFlat* iSoundFileArray; + CDesCArrayFlat* iPictureFileArray; + CCommandArray* iCommandArray; + RPointerArray iParameterArray; + // progress bar + //CAknProgressDialog* iProgressDialog; + //CEikProgressInfo* iProgressInfo; + + // for the random data generator + TInt64 iSeed; + + class TStringArrayPtr + { + public: + TStringArrayPtr(TRandomStringType aType, CDesCArray* aPtr) + { + iStringType = aType; + iArrayPtr = aPtr; + }; + TRandomStringType iStringType; + CDesCArray* iArrayPtr; + }; + + RArray iStringArrays; + + // modules + CCreatorBrowser* iBrowser; + CCreatorCalendarBase* iCalendar; + CCreatorPhonebookBase* iPhonebook; + CCreatorNotepad* iNotepad; + CCreatorLogs* iLogs; +// CCreatorConnectionSettingsBase* iAccessPoints; + CCreatorMailboxes* iMailboxes; + CCreatorIMPS* iIMPS; + CCreatorFiles* iFiles; + CCreatorMessages* iMessages; + CCreatorLandmarks* iLandmarks; + CCreatorCmdScriptRun* iCmdScriptRun; + CCommandParser* iCommandParser; + + // options menu command home module + MCreatorModuleBase* iUsedOptionsMenuModule; + + HBufC* iTempPath; + + RPointerArray iAllocatedFilePaths; + TBool iUserCancelled; + + // For generating missing bitmaps + HBufC8* iBitmapData; + CFbsBitmap* iBitmap; + CFbsBitmap* iScaledBitmap; + CImageDecoder* iDecoder; + TFrameInfo iFrameinfo; + CImageEncoder* iEncoder; + CFrameImageData* iFrameImageData; + CBitmapScaler* iScaler; + + EngineWrapper* iEngineWrapper; // Enginewrapper that is used for communicating between QT and Symbian + TMemoryDetails iMemoryDetails; + + RPointerArray iMemoryDetailsList; + + TInt iResourceFileId; + + HBufC* iCommandLineScriptName; + HBufC* iCommandLineRandomDataFileName; + }; + +// this class contains a command which will be executed +class TCommand + { +public: + TInt iCommandId; + CCreatorModuleBaseParameters* iParameters; +public: + TCommand(TInt aCommandId, CCreatorModuleBaseParameters* aParameters); + ~TCommand(); + + }; + + +// utility class for waiting for asychronous requests +class CAsyncWaiter : public CActive + { +public: + static CAsyncWaiter* NewL( TInt aPriority = EPriorityStandard ); + static CAsyncWaiter* NewLC( TInt aPriority = EPriorityStandard ); + ~CAsyncWaiter(); + + void StartAndWait(); + TInt Result() const; + +private: + CAsyncWaiter( TInt aPriority ); + + // from CActive + void RunL(); + void DoCancel(); + +private: + CActiveSchedulerWait iWait; + TInt iError; + }; + + +/* + * Maps file id string (file name) to TTestDataPath (file id) and TCreatorIds (command id) + */ +// File ids: + + _LIT(K3GPP_70KB, "3GPP-70kB"); + _LIT(KAAC_100KB, "AAC-100kB"); + _LIT(KAMR_20KB, "AMR-20kB"); + _LIT(KXLS_15KB, "XLS-15kB"); + _LIT(KGIF_2KB, "GIF-2kB"); + _LIT(KJPEG_200KB, "JPEG-200kB"); + _LIT(KJPEG_25KB, "JPEG-25kB"); + _LIT(KJPEG_500KB, "JPEG-500kB"); + _LIT(KMIDI_10KB, "MIDI-10kB"); + _LIT(KMP3_250KB, "MP3-250kB"); + _LIT(KPNG_15KB, "PNG-15kB"); + _LIT(KPPT_40KB, "PPT-40kB"); + _LIT(KRM_95KB, "RM-95kB"); + _LIT(KRNG_1KB, "RNG-1kB"); + _LIT(KTXT_10KB, "TXT-10kB"); + _LIT(KTXT_70KB, "TXT-70kB"); + _LIT(KWAV_20KB, "WAV-20kB"); + _LIT(KDOC_20KB, "DOC-20kB"); + _LIT(KSWF_15KB, "SWF-15kB"); + _LIT(KJAD_1KB, "JAD-1kB"); + _LIT(KJAR_10KB, "JAR-10kB"); + _LIT(KTIF_25KB, "TIF-25kB"); + _LIT(KMXMF_40KB, "MXMF-40kB"); + _LIT(KBMP_25KB, "BMP-25kB"); + _LIT(KJP2_25KB, "JP2-25kB"); + _LIT(KSVG_15KB, "SVG-15kB"); + _LIT(KHTML_20KB, "HTML-20kB"); + _LIT(KVCF_1KB, "VCF-1kB"); + _LIT(KVCS_1KB, "VCS-1kB"); + _LIT(KMP4_200KB, "MP4-200kB"); + _LIT(KSISX_10KB, "SISX-10kB"); + _LIT(KRAM_1KB, "RAM-1kB"); + _LIT(KDECK_1KB, "DECK-1kB"); + _LIT(KWMA_50KB, "WMA-50kB"); + _LIT(KWMV_200KB, "WMV-200kB"); + +class FileMapping + { + public: + FileMapping(const TDesC& aFileName, TInt aFileId, TInt aCommandId ); + const TDesC& FileName() const; + TInt FileId() const; + TInt CommandId() const; + + private: + const TDesC& iFileName; + TInt iFileId; + TInt iCommandId; + }; + + /* + * This table contains the string <-> TTestDataPath mappings for the file types + */ + static FileMapping FileMap[] = + { + + FileMapping(K3GPP_70KB, CCreatorEngine::E3GPP_70kB, ECmdCreateFileEntry3GPP_70kB), + FileMapping(KAAC_100KB, CCreatorEngine::EAAC_100kB, ECmdCreateFileEntryAAC_100kB), + FileMapping(KAMR_20KB, CCreatorEngine::EAMR_20kB, ECmdCreateFileEntryAMR_20kB), + FileMapping(KXLS_15KB, CCreatorEngine::EExcel_15kB, ECmdCreateFileEntryXLS_15kB), + FileMapping(KGIF_2KB, CCreatorEngine::EGIF_2kB, ECmdCreateFileEntryGIF_2kB), + FileMapping(KJPEG_200KB, CCreatorEngine::EJPEG_200kB, ECmdCreateFileEntryJPEG_200kB), + FileMapping(KJPEG_25KB, CCreatorEngine::EJPEG_25kB, ECmdCreateFileEntryJPEG_25kB), + FileMapping(KJPEG_500KB, CCreatorEngine::EJPEG_500kB, ECmdCreateFileEntryJPEG_500kB), + FileMapping(KMIDI_10KB, CCreatorEngine::EMIDI_10kB, ECmdCreateFileEntryMIDI_10kB), + FileMapping(KMP3_250KB, CCreatorEngine::EMP3_250kB, ECmdCreateFileEntryMP3_250kB), + FileMapping(KPNG_15KB, CCreatorEngine::EPNG_15kB, ECmdCreateFileEntryPNG_15kB), + FileMapping(KPPT_40KB, CCreatorEngine::EPowerPoint_40kB, ECmdCreateFileEntryPPT_40kB), + FileMapping(KRM_95KB, CCreatorEngine::ERM_95kB, ECmdCreateFileEntryRM_95kB), + FileMapping(KRNG_1KB, CCreatorEngine::ERNG_1kB, ECmdCreateFileEntryRNG_1kB), + FileMapping(KTXT_10KB, CCreatorEngine::EText_10kB, ECmdCreateFileEntryTXT_10kB), + FileMapping(KTXT_70KB, CCreatorEngine::EText_70kB, ECmdCreateFileEntryTXT_70kB), + FileMapping(KWAV_20KB, CCreatorEngine::EWAVE_20kB, ECmdCreateFileEntryWAV_20kB), + FileMapping(KDOC_20KB, CCreatorEngine::EWord_20kB, ECmdCreateFileEntryDOC_20kB), + FileMapping(KBMP_25KB, CCreatorEngine::EBMP_25kB, ECmdCreateFileEntryBMP_25kB), + FileMapping(KDECK_1KB, CCreatorEngine::ESavedDeck_1kB, ECmdCreateFileEntryDeck_1kB), + FileMapping(KHTML_20KB, CCreatorEngine::EHTML_20kB, ECmdCreateFileEntryHTML_20kB), + FileMapping(KJAD_1KB, CCreatorEngine::EJAD_1kB, ECmdCreateFileEntryJAD_1kB), + FileMapping(KJAR_10KB, CCreatorEngine::EJAR_10kB, ECmdCreateFileEntryJAR_10kB), + FileMapping(KJP2_25KB, CCreatorEngine::EJP2_65kB, ECmdCreateFileEntryJP2_65kB), + FileMapping(KMP4_200KB, CCreatorEngine::EMP4_200kB, ECmdCreateFileEntryMP4_200kB), + FileMapping(KMXMF_40KB, CCreatorEngine::EMXMF_40kB, ECmdCreateFileEntryMXMF_40kB), + FileMapping(KRAM_1KB, CCreatorEngine::ERAM_1kB, ECmdCreateFileEntryRAM_1kB), + FileMapping(KSVG_15KB, CCreatorEngine::ESVG_15kB, ECmdCreateFileEntrySVG_15kB), + FileMapping(KSWF_15KB, CCreatorEngine::ESWF_15kB, ECmdCreateFileEntrySWF_15kB), + FileMapping(KTIF_25KB, CCreatorEngine::ETIF_25kB, ECmdCreateFileEntryTIF_25kB), + FileMapping(KVCF_1KB, CCreatorEngine::EVCF_1kB, ECmdCreateFileEntryVCF_1kB), + FileMapping(KVCS_1KB, CCreatorEngine::EVCS_1kB, ECmdCreateFileEntryVCS_1kB), + FileMapping(KSISX_10KB, CCreatorEngine::ESISX_10kB, ECmdCreateFileEntrySISX_10kB), + FileMapping(KWMA_50KB, CCreatorEngine::EWMA_50kB, ECmdCreateFileEntryWMA_50kB), + FileMapping(KWMV_200KB, CCreatorEngine::EWMV_200kB, ECmdCreateFileEntryWMV_200kB) + }; + +#endif // __CREATORENGINE_H__ + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/inc/enginewrapper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/inc/enginewrapper.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,168 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef ENGINEWRAPPER_H +#define ENGINEWRAPPER_H + +#include +#include +#include +#include + +#include // for iProgressNote signal connect + + +class MainView; +class MemoryDetails; +class HbProgressDialog; +class HbPopup; +class HbCommonNote; +class HbAction; + + +/** + * class that is used for communicating between Symbian and Qt code. + */ +class EngineWrapper : public QObject + { + Q_OBJECT + +public: + + /** + * Constructor + */ + EngineWrapper(); + + /** + * Destructor + */ + ~EngineWrapper(); + + /** + * Initializes Engine Wrapper + * @return true if engine was started successfully + */ + bool init(); + + /** + * Get memory details + */ + MemoryDetails GetMemoryDetails(); + + /** + * Get memory details list + */ + QList GetMemoryDetailsList(); + +public: + + /* Functions that are called from UI */ + bool ExecuteOptionsMenuCommand(int commandId); + + +public: + + /* Functions that are called from engine: */ + + /** + * uses Notifications class to show error message + */ + void ShowErrorMessage(const TDesC& aErrorMessage); + + /** + * uses Notifications class to show progressbar + */ + void ShowProgressBar(const TDesC& aPrompt, int aMax); + + /** + * uses Notifications class to show user note + */ + void ShowNote(const TDesC& aNoteMessage, TInt aResourceId = 0); + + /** + * increments shown progressbar's value + */ + void IncrementProgressbarValue(); + + /** + * closes progressbar + */ + void CloseProgressbar(); + + /** + * Create entries query dialog + */ + TBool EntriesQueryDialog(TInt* aNumberOfEntries, const TDesC& aPrompt, TBool aAcceptsZero, MUIObserver* aObserver, TInt aUserData); + + /** + * Create time query dialog + */ + TBool TimeQueryDialog(TTime* aTime, const TDesC& aPrompt, MUIObserver* aObserver, TInt aUserData); + + /** + * Create yes or no query dialog + */ + TBool YesNoQueryDialog(const TDesC& aPrompt, MUIObserver* aObserver, int userData); + + /** + * Popup list dialog for selecting item from dialog list + */ + TBool PopupListDialog(const TDesC& aPrompt, const CDesCArray* aFileNameArray, TInt* aIndex, MUIObserver* aObserver, TInt aUserData); + + /** + * Directory query dialog + */ + TBool DirectoryQueryDialog(const TDesC& aPrompt, TDes& aDirectory, MUIObserver* aObserver, TInt aUserData); + + /** + * Create list query single-selection dialog + */ + TBool ListQueryDialog(const TDesC& aPrompt, TListQueryId aId, TInt* aSeletedItem, MUIObserver* aObserver, TInt aUserData); + + /** + * Create list query multi-selection dialog + */ + TBool ListQueryDialog(const TDesC& aPrompt, TListQueryId aId, CArrayFixFlat* aSelectedItems, MUIObserver* aObserver, TInt aUserData); + + + /** + * Close application when started from command line for script run. + */ + void CloseCreatorApp(); + +private slots: + + /** + * progress dialog cancelled + */ + void ProgressDialogCancelled(); + +private: + + + /* Creator engine */ + CCreatorEngine* iEngine; + + /* progress dialog that is shown */ + HbProgressDialog* iProgressDialog; + + MCreatorModuleBase *iModule; +}; + +#endif //ENGINEWRAPPER_H diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/inc/mainview.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/inc/mainview.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,201 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef MAINVIEW_H +#define MAINVIEW_H + +#include +#include + +class HbMainWindow; +class HbApplication; +class HbAction; +class QSignalMapper; + +class MemoryDetails +{ +public: + QString mFree; + QString mSize; + QString mDriveLetter; + + QString mRamFree; + bool mENotAvailable; + QString mRamSize; +}; + +/** + * Class that implements the main view of Creator + */ +class MainView : public HbView +{ + Q_OBJECT + +public: + + /** + * Constructor + */ + MainView(HbMainWindow &mainWindow); + + /** + * Destructor + */ + ~MainView(); + + /** + * Initializes Engine Wrapper + * @param app application class of Creator + */ + void init(HbApplication &app); + + /** + * Call application exit from engine. + */ + static void closeApp(); + +private: + + /** + * Creates menu + */ + void createMenu(HbApplication &app); + + /** + * Creates memory info text to UI + */ + void createMemoryInfoText(); + +private slots: + + + /** + * Shows about pop-up + */ + void showAboutPopup(); + /** + * calls engine wrapper to complete service request, specified with commandId. + */ + void executeMenuCommand(int cmd); + +private: + + /* Main window of Creator */ + HbMainWindow &mMainWindow; + + + /* Engine Wrapper */ + EngineWrapper mEngineWrapper; + + /* Actions that are used in toolbars and menus */ + HbAction* mActionRunScript; + HbAction* mActionCalendarAppointments; + HbAction* mActionCalendarEvents; + HbAction* mActionCalendarAnniversaries; + HbAction* mActionCalendarTodos; + HbAction* mActionCalendarReminders; + HbAction* mActionBrowserBookmark; + HbAction* mActionBrowserBmarkFolder; + HbAction* mActionLogsMissedCalls; + HbAction* mActionLogsReceivedCalls; + HbAction* mActionLogsDialledNumbers; + HbAction* mActionMessageMailboxes; + HbAction* mActionMessages; + HbAction* mActionFilesJpeg25; + HbAction* mActionFilesJpeg200; + HbAction* mActionFilesJpeg500; + HbAction* mActionFilesPng15; + HbAction* mActionFilesGif2; + HbAction* mActionFilesBmp25; + HbAction* mActionFilesJp265; + HbAction* mActionFilesSvg15; + HbAction* mActionFilesTif25; + HbAction* mActionFilesRng1; + HbAction* mActionFilesMidi10; + HbAction* mActionFilesWave20; + HbAction* mActionFilesAmr20; + HbAction* mActionFilesExcel15; + HbAction* mActionFilesWord20; + HbAction* mActionFilesPPoint40; + HbAction* mActionFilesText10; + HbAction* mActionFilesText70; + HbAction* mActionFilesHtml20; + HbAction* mActionFilesMxmf40; + HbAction* mActionFilesRam1; + HbAction* mActionFilesJad1; + HbAction* mActionFilesJar10; + HbAction* mActionFilesVcf1; + HbAction* mActionFilesVcs1; + HbAction* mActionFilesSisx10; + HbAction* mActionFiles3Gpp70; + HbAction* mActionFilesMp3250; + HbAction* mActionFilesAAC100; + HbAction* mActionFilesSwf15; + HbAction* mActionFilesMp4200; + HbAction* mActionFilesRm95; + HbAction* mActionFilesWma50; + HbAction* mActionFilesWmv200; + HbAction* mActionPhonebookContacts; + HbAction* mActionPhonebookGroups; + HbAction* mActionBrowserSavedPages; + HbAction* mActionBrowserSavedPageFolders; + HbAction* mActionFilesEmptyFolder; + HbAction* mActionMiscConnection; + HbAction* mActionMiscImps; + HbAction* mActionMiscNotes; + HbAction* mActionMiscLandmarks; + HbAction* mActionAbout; + HbAction* mActionExit; + HbAction* mActionDeleteAllItems; + HbAction* mActionDeleteCreatorItems; + HbAction* mActionSelectRandomFile; + HbAction* mActionDeleteCalAllItems; + HbAction* mActionDeleteCalCreatorItems; + HbAction* mActionDeleteBookmarkAllItems; + HbAction* mActionDeleteBookmarkCreatorItems; + HbAction* mActionDeleteBookmarkFolderAllItems; + HbAction* mActionDeleteBookmarkFolderCreatorItems; + HbAction* mActionDeleteSavedPagesAllItems; + HbAction* mActionDeleteSavedPagesCreatorItems; + HbAction* mActionDeleteSavedPagesFolderAllItems; + HbAction* mActionDeleteSavedPagesFolderCreatorItems; + HbAction* mActionDeleteFiles; + HbAction* mActionDeleteLogsAll; + HbAction* mActionDeleteLogsByCreator; + HbAction* mActionDeleteMessagesAll; + HbAction* mActionDeleteMessagesByCreator; + HbAction* mActionDeleteConnMethsAll; + HbAction* mActionDeleteConnMethsByCreator; + HbAction* mActionDeleteImpsAll; + HbAction* mActionDeleteImpsByCreator; + HbAction* mActionDeleteNotes; + HbAction* mActionDeleteLandmarksAll; + HbAction* mActionDeleteLandmarksByCreator; + HbAction* mActionDeleteContactsAll; + HbAction* mActionDeleteContactsByCreator; + HbAction* mActionDeleteContactGroupsAll; + HbAction* mActionDeleteContactGroupsByCreator; + + + MemoryDetails mMemoryDetails; + QList mMemoryDetailsList; + // signal mapper + QSignalMapper *mSm; +}; + +#endif // MAINVIEW_H diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/inc/notifications.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/inc/notifications.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,149 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef NOTIFICATIONS_H_ +#define NOTIFICATIONS_H_ + +#include +#include +#include + +#include "engine.h" + +#include + +class HbProgressDialog; +class HbPopup; + +class Notifications : public HbPopup + { + + Q_OBJECT + +public: + /** + * shows massage box + */ + static void showMessageBox(HbMessageBox::MessageBoxType type, const QString &text, const QString &label, int timeout ); + + /** + * shows about box + */ + static void about(); + + /** + * shows error message + */ + static void error(const QString& errorMessage); + + /** + * to shows progressbar + */ + static HbProgressDialog* showProgressBar(const QString& text, int max); + + /** + * shows global HbGlobalCommonNote type note + */ + static void showGlobalNote(const QString& text, HbMessageBox::MessageBoxType type, int timeout = 1000 ); + }; + +class CreatorDialog +{ + Q_DISABLE_COPY(CreatorDialog) +protected: + CreatorDialog(MUIObserver* observer, int userData) throw(std::exception) : mObserver(observer), mUserData(userData) + { + if(!mObserver) + throw std::invalid_argument("module cannot be the null!"); + }; +protected: + virtual void NotifyObserver(TBool aPositiveAction) + { + TRAPD( err, mObserver->QueryDialogClosedL(aPositiveAction, mUserData) ); + if(err) + { + Notifications::error( QString("Symbian Leave: %1 ").arg(err) ); + } + } + +protected: + MUIObserver* mObserver; + int mUserData; +}; + +class CreatorYesNoDialog : public HbMessageBox, public CreatorDialog +{ + Q_DISABLE_COPY(CreatorYesNoDialog) + Q_OBJECT +public: + static void launch(const QString& text, const QString& label, MUIObserver* observer, int userData) throw( std::exception ); +protected: + CreatorYesNoDialog(MUIObserver* observer, int userData); +protected slots: + void DialogClosed(HbAction*); +}; + +class CreatorInputDialog : public HbInputDialog, public CreatorDialog +{ + Q_DISABLE_COPY(CreatorInputDialog) + Q_OBJECT +public: + static void launch(const QString& label, int* value, bool acceptZero, MUIObserver* observer, int userData) throw( std::exception ); + static void launch(const QString& label, TDes& value, MUIObserver* observer, int userData) throw( std::exception ); +protected: + CreatorInputDialog(int* value, MUIObserver* observer, int userData); + CreatorInputDialog(TDes& value, MUIObserver* observer, int userData); +protected slots: + void DialogClosed(HbAction*); +private: + int *mIntValue; + TDes& mStrValue; + TBuf<1> mDummy; +}; + +class CreatorSelectionDialog : public HbSelectionDialog, public CreatorDialog +{ + Q_DISABLE_COPY(CreatorSelectionDialog) + Q_OBJECT +public: + static void launch(const QString& label, const QStringList& items, TInt* selectedItem, MUIObserver* observer, int userData) throw( std::exception ); + static void launch(const QString& label, const QStringList& items, CArrayFixFlat* aSelectedItems, MUIObserver* observer, int userData) throw( std::exception ); +protected: + CreatorSelectionDialog(TInt* selectedItem, MUIObserver* observer, int userData) throw( std::exception ); + CreatorSelectionDialog(CArrayFixFlat* aSelectedItems, MUIObserver* observer, int userData) throw( std::exception ); +protected slots: + void DialogClosed(HbAction*); +private: + TInt* mSelectedItem; + CArrayFixFlat* mSelectedItems; +}; + +class CreatorDateTimeDialog : public HbDialog, public CreatorDialog +{ + Q_DISABLE_COPY(CreatorDateTimeDialog) + Q_OBJECT +public: + static void launch(const QString& label, TTime* value, MUIObserver* observer, int userData) throw( std::exception ); +protected: + CreatorDateTimeDialog(TTime* value, MUIObserver* observer, int userData); +protected slots: + void DialogClosed(HbAction*); +private: + TTime *mValue; +}; +#endif // NOTIFICATIONS_H_ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/rom/creator.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/rom/creator.iby Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef __CREATOR_IBY__ +#define __CREATOR_IBY__ + +S60_APP_EXE(Creator) +S60_APP_RESOURCE(Creator) +S60_APP_RESOURCE(datacreator) +SCALABLE_IMAGE(APP_BITMAP_DIR,APP_BITMAP_DIR,Creator) + +data=ZPRIVATE\10003a3f\import\APPS\Creator_reg.RSC Private\10003a3f\import\Apps\Creator_reg.rsc +//#ifdef S60_UPGRADABLE_APP_REG_RSC +// S60_UPGRADABLE_APP_REG_RSC(Creator) +//#else +// S60_APP_AIF_RSC(Creator) +//#endif + +data=ZPRIVATE\20011383\backup_registration.xml private\20011383\backup_registration.xml +data=ZSYSTEM\Install\Creator_stub.sis \system\install\Creator_stub.sis + +// test files (remove largest files if running out of ROM space): +data=ZPRIVATE\20011383\3GPP-70kB.3gpp private\20011383\3GPP-70kB.3gpp +data=ZPRIVATE\20011383\AAC-100kB.aac private\20011383\AAC-100kB.aac +data=ZPRIVATE\20011383\AMR-20kB.amr private\20011383\AMR-20kB.amr +data=ZPRIVATE\20011383\Deck-1kB.saveddeck private\20011383\Deck-1kB.saveddeck +data=ZPRIVATE\20011383\DOC-20kB.doc private\20011383\DOC-20kB.doc +data=ZPRIVATE\20011383\HTML-20kB.html private\20011383\HTML-20kB.html +data=ZPRIVATE\20011383\JAD-1kB.jad private\20011383\JAD-1kB.jad +data=ZPRIVATE\20011383\JAR-10kB.jar private\20011383\JAR-10kB.jar +data=ZPRIVATE\20011383\JP2-65kB.jp2 private\20011383\JP2-65kB.jp2 +data=ZPRIVATE\20011383\MIDI-10kB.mid private\20011383\MIDI-10kB.mid +data=ZPRIVATE\20011383\MP3-250kB.mp3 private\20011383\MP3-250kB.mp3 +data=ZPRIVATE\20011383\MP4-200kB.mp4 private\20011383\MP4-200kB.mp4 +data=ZPRIVATE\20011383\MXMF-40kB.mxmf private\20011383\MXMF-40kB.mxmf +data=ZPRIVATE\20011383\PNG-15kB.png private\20011383\PNG-15kB.png +data=ZPRIVATE\20011383\PPT-40kB.ppt private\20011383\PPT-40kB.ppt +data=ZPRIVATE\20011383\RAM-1kB.ram private\20011383\RAM-1kB.ram +data=ZPRIVATE\20011383\RM-95kB.rm private\20011383\RM-95kB.rm +data=ZPRIVATE\20011383\RNG-1kB.rng private\20011383\RNG-1kB.rng +data=ZPRIVATE\20011383\SVG-15kB.svg private\20011383\SVG-15kB.svg +data=ZPRIVATE\20011383\SWF-15kB.swf private\20011383\SWF-15kB.swf +data=ZPRIVATE\20011383\TIF-25kB.tif private\20011383\TIF-25kB.tif +data=ZPRIVATE\20011383\VCF-1kB.vcf private\20011383\VCF-1kB.vcf +data=ZPRIVATE\20011383\VCS-1kB.vcs private\20011383\VCS-1kB.vcs +data=ZPRIVATE\20011383\WAV-20kB.wav private\20011383\WAV-20kB.wav +data=ZPRIVATE\20011383\XLS-15kB.xls private\20011383\XLS-15kB.xls +data=ZPRIVATE\20011383\SISX-10kB.sisx private\20011383\SISX-10kB.sisx +data=ZPRIVATE\20011383\WMA-50kB.wma private\20011383\WMA-50kB.wma +data=ZPRIVATE\20011383\WMV-200kB.wmv private\20011383\WMV-200kB.wmv + +#endif // __CREATOR_IBY__ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/scripts/browserEx.creatorxml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/scripts/browserEx.creatorxml Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,48 @@ + + + + + + + Creator bookmark + http://example.net + User + passwd + + + + + + + + + + + + + + + + + Creator bookmarks + + + + + + + Creator saved pages + + + + + + + Creator saved page + + + + + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/scripts/calendarEx.creatorxml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/scripts/calendarEx.creatorxml Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,103 @@ + + + + + + + + + + + + Project meeting + Let's have a bi-weekly project meeting. Welcome everyone! + Meeting room 1 + 2008-03-27T13:02:57 + 2008-03-27T16:15:00 + weekly + 2 + 2008-03-27 + 2009-03-27 + + + + + John Doe + john.doe@example.net + + + + + + + + + + + + + + + + + + Jane + + + + + + + + + + + Appointment with Jane + 2008-02-29T14:00:00 + 2008-02-29T15:00:00 + + + + + + + + + + + Tech Days + Annual tech days, let's have fun! + 2008-05-01 + 2008-05-03 + + + + + + + Remember to buy Lotto! + 2008-02-28T18:00:00 + 2008-02-28T18:00:00 + + + + + + + + + + + + + + + Should do something...? + 2008-02-29T10:00:00 + 2008-02-29T12:00:00 + + + + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/scripts/connectionmethodEx.creatorxml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/scripts/connectionmethodEx.creatorxml Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,54 @@ + + + + + + CR_Example + GPRS + http://wap.example.net + connectionoriented + ipv4 + john + no + doe + no + 10.10.10.101 + 255.255.255.0 + 10.10.10.102 + no + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/scripts/contactEx.creatorxml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/scripts/contactEx.creatorxml Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + John + Smith + +35800101010101 + 00101010102 + john.smith@example.com + Mr. + + + + + + + + + + + + + + + ExampleCompany Ltd. + Software Designer + + + + + + + + + + + + + + + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/scripts/creator.xsd --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/scripts/creator.xsd Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,1187 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + There are three different contact related elements: contact, contact-set and contactgroup. The contact element describes one + contact in a database. The contact can be defined explicitly by giving the contact fields and their data, or it can just define the fields to be + used and let the Creator fill the fields with random data. There can also be several same type of fields, for example multiple emailwork fields. + + When contact is defined without fields sub-element, a contact with all fields containing default length random data is created. + + + + + + + + + + + + + + + + + + + + + The contact-set element can be used to bind multiple contacts together and linking them to contactgroups, messages and + calendars. When contact-set is used as a link target it must have a unique id attribute. See example usage of contact-set in + contactEx.creatorxml. + + + + + + + + + + + Amount of members in the group. Indicates how many existing contacts should be taken to the set. + + + + + + + + + + The contactgroup element describes one contact group that should be created to the device's database. + + + + + + + + + + + + + + + + + + + + Note: If alarmtime element is not set, alarm is set as not active and if alarmtime is set, alarm is set to active. + Note: If recurrentfrequency is not set, or set to not-repeated recurrentinterval will be skipped, even if set. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Note: If type is not set, a directory will be created. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Data can have following format: -nn.nnnn - nn.nnnn, where positive latitude means north and negative south, zero + point is Equator. + + + + + + + Data can have following format: -nn.nnnn - nn.nnnn, where positive longitude means east and negative west, zero + point is Prime Meridian. + + + + + + + + Data can have following format: -nn.nnnn - nn.nnnn, where zero point is sea level. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Root element of a Creator script. The sub-elements can be thought as 'commands', e.g. one contact element with explicitly + defined fields create one contact to the database of the device. + + + + + + + + + + Declares the script version. Can be used to indicate the evolution of each script. + + + + + + + Declares the schema version used when designing a script file. This version information must be in sync with the schema used. Schema version is defined + at the beginning of the creator.xsd file in comment block. + + + + + + + \ No newline at end of file diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/scripts/filesEx.creatorxml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/scripts/filesEx.creatorxml Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,60 @@ + + + + + + + + JPEG-25kB + c:\data\images + + + + + + + MIDI-10kB + c:\data\Sounds + + + + + + + + + 3GPP-70kB + c:\data\Videos + + + + + P0Y0M0DT0H21M1S + + 2 + + + + + + + + + GIF-2kB + c:\data\Images + + + + + P0Y0M0DT1H30M0S + + 2008-09-26T13:49:57 + 2009-03-27T16:15:00 + + + + + + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/scripts/impsEx.creatorxml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/scripts/impsEx.creatorxml Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,17 @@ + + + + + + + Creator_test_imps + + + + + + + + \ No newline at end of file diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/scripts/landmarkEx.creatorxml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/scripts/landmarkEx.creatorxml Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,52 @@ + + + + + + + CreatorExample + accommodation + business + communication + educational + entertainment + food + geographical + outdoor + people + public + religious + shopping + sightseeing + sports + transport + This is an example landmark! + Landmark street 1 + 00445 + Landmark City + Landmark State + Landmark Country + 111222333 + http://www.example.net + -76.0023 + 98.1002 + 2 + -4.1 + 3 + + + + + + + + + + + + + + + \ No newline at end of file diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/scripts/logEx.creatorxml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/scripts/logEx.creatorxml Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,45 @@ + + + + + + + missed + 2008-03-25T13:11:21 + 1115555554112 + + + + + + + in + 2008-03-24T10:21:56 + 11155554112 + 241 + + + + + + + out + 2008-03-22T12:01:06 + 0555554555 + 445 + + + + + + + + + + + + + + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/scripts/mailboxEx.creatorxml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/scripts/mailboxEx.creatorxml Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,35 @@ + + + + + + cr_pop mail + + + yes + no + no + + + + + + + + cr_imap4 mail + creator@example.net + cc + yes + yes + creator + creator + cr_mail.example.net + no + no + no + getbodytextandattachments + + + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/scripts/messagesEx.creatorxml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/scripts/messagesEx.creatorxml Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + inbox + This is an example SMS created by Creator. + new + + + + + + + sent + Good music! + new + MP3-250kB + + + + + + + + + inbox + + + new + JPEG-200kB + + + + + + 123456 + inbox + This is an example SMS created by Creator. + new + + + + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/scripts/notepadEx.creatorxml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/scripts/notepadEx.creatorxml Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,27 @@ + + + + + + + This is a Creator example note! + + + + + + + + + + + + + + + + + + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/sis/Creator_stub.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/sis/Creator_stub.pkg Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,71 @@ +; +; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; + + +; Language - standard language definitions +&EN + +; Standard SIS file header +#{"Creator"},(0x20011383),1,0,0 + +; Non-localised vendor name +:"Nokia Corporation" + +; Localised vendor names +%{"Nokia Corporation"} + +; normal stuff: +""-"z:\sys\bin\creator.exe" +""-"z:\resource\apps\creator.mif" +""-"z:\resource\apps\creator.rsc" +""-"z:\resource\apps\datacreator.rsc" +""-"z:\private\10003a3f\import\apps\creator_reg.rsc" +""-"z:\private\20011383\backup_registration.xml" + +; test data: +""-"z:\private\20011383\3GPP-70kB.3gpp" +""-"z:\private\20011383\AAC-100kB.aac" +""-"z:\private\20011383\AMR-20kB.amr" +""-"z:\private\20011383\BMP-25kB.bmp" +""-"z:\private\20011383\Deck-1kB.saveddeck" +""-"z:\private\20011383\DOC-20kB.doc" +""-"z:\private\20011383\GIF-2kB.gif" +""-"z:\private\20011383\HTML-20kB.html" +""-"z:\private\20011383\JAD-1kB.jad" +""-"z:\private\20011383\JAR-10kB.jar" +""-"z:\private\20011383\JP2-65kB.jp2" +""-"z:\private\20011383\JPEG-200kB.jpg" +""-"z:\private\20011383\JPEG-25kB.jpg" +""-"z:\private\20011383\JPEG-500kB.jpg" +""-"z:\private\20011383\MIDI-10kB.mid" +""-"z:\private\20011383\MP3-250kB.mp3" +""-"z:\private\20011383\MP4-200kB.mp4" +""-"z:\private\20011383\MXMF-40kB.mxmf" +""-"z:\private\20011383\PNG-15kB.png" +""-"z:\private\20011383\PPT-40kB.ppt" +""-"z:\private\20011383\RAM-1kB.ram" +""-"z:\private\20011383\RM-95kB.rm" +""-"z:\private\20011383\RNG-1kB.rng" +""-"z:\private\20011383\SVG-15kB.svg" +""-"z:\private\20011383\SWF-15kB.swf" +""-"z:\private\20011383\TIF-25kB.tif" +""-"z:\private\20011383\TXT-10kB.txt" +""-"z:\private\20011383\TXT-70kB.txt" +""-"z:\private\20011383\VCF-1kB.vcf" +""-"z:\private\20011383\VCS-1kB.vcs" +""-"z:\private\20011383\WAV-20kB.wav" +""-"z:\private\20011383\XLS-15kB.xls" +""-"z:\private\20011383\SISX-10kB.sisx" diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/src/engine.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/src/engine.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,2610 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include +#include +#include + +#include + +#include + +#include "mainview.h" +#include "engine.h" +#include "enginewrapper.h" + + +#include //For Math + +#include "creator_scriptentry.h" +#include "creator_modulebase.h" +//#include "creator_browser.h" +#include "creator_calendar.h" +#include "creator_phonebookbase.h" +#include "creator_note.h" +#include "creator_log.h" +//#include "creator_connectionmethodbase.h" +#include "creator_mailbox.h" +//#include "creator_imps.h" +#include "creator_message.h" +#include "creator_landmark.h" + + +#include "creator_traces.h" +#include "creator_factory.h" +#include "creator_scriptparser.h" +#include "creator_file.h" +#include "creator_cmdscriptrun.h" +#include "creator_contactsetcache.h" + +#include +#include +#include +#include + +_LIT(KTempPathDrive, "d"); +_LIT(KTempPath, ":\\Creator\\"); +const TInt KRegisterDrive = EDriveC; +_LIT(KRegisterFileName, "creator_created_items.dat"); +_LIT(KResourceFileName, "z:\\Resource\\apps\\datacreator.RSC"); + + +// --------------------------------------------------------------------------- + +CCreatorEngine* CCreatorEngine::NewL(EngineWrapper *aEngineWrapper) + { + CCreatorEngine* self = CCreatorEngine::NewLC(aEngineWrapper); + CleanupStack::Pop(); // self; + return self; + } + +// --------------------------------------------------------------------------- + +CCreatorEngine* CCreatorEngine::NewLC(EngineWrapper *aEngineWrapper) + { + CCreatorEngine* self = new (ELeave) CCreatorEngine(); + CleanupStack::PushL(self); + self->ConstructL(aEngineWrapper); + return self; + } + +// --------------------------------------------------------------------------- + +CCreatorEngine::CCreatorEngine() +: +CActive(0) +{} + +// --------------------------------------------------------------------------- + +void CCreatorEngine::ConstructL(EngineWrapper *aEngineWrapper) + { + LOGSTRING("Creator: CCreatorEngine::ConstructL"); + + iEngineWrapper = aEngineWrapper; + iMemoryDetails.iENotAvailable = EFalse; + RequestMemoryDetails(); + iEnv = CEikonEnv::Static(); + // add second resource file to use for creator random data generation: + iResourceFileId = iEnv->AddResourceFileL(KResourceFileName); + User::LeaveIfError(iTimer.CreateLocal()); + + // these are needed by the random data generator + TTime now; + now.HomeTime(); + iSeed=now.Int64(); + + iTempPath = HBufC::NewL(KTempPathDrive().Length() + KTempPath().Length()); + iTempPath->Des().Copy(KTempPathDrive); + iTempPath->Des().Append(KTempPath); + + iCmdScriptRun = CCreatorCmdScriptRun::NewL(this); + + GetRandomDataFromFileL(KNullDesC); + + CActiveScheduler::Add(this); + + } + +// --------------------------------------------------------------------------- + +CCreatorEngine::~CCreatorEngine() + { + LOGSTRING("Creator: CCreatorEngine::~CCreatorEngine"); + + Cancel(); + + for( TInt i = 0; i < iStringArrays.Count(); ++i ) + { + delete iStringArrays[i].iArrayPtr; + } + iStringArrays.Close(); + iAllocatedFilePaths.ResetAndDestroy(); + iAllocatedFilePaths.Close(); + iTimer.Close(); + + + iEnv->DeleteResourceFile(iResourceFileId); + + iMemoryDetailsList.Reset(); + delete iPictureFileArray; + delete iSoundFileArray; + delete iTempPath; + delete iFrameImageData; + delete iEncoder; + delete iScaler; + delete iDecoder; + delete iScaledBitmap; + delete iBitmap; + delete iBitmapData; + + delete iCmdScriptRun; + iCmdScriptRun = NULL; + + delete iCommandParser; + } + +void CCreatorEngine::CopyFileL(const TFileName& aSourceFile, const TFileName& aTargetFile, TBool aOverwrite ) + { + if( !aOverwrite && ConeUtils::FileExists(aTargetFile)) + { + // File already exists + return; + } + + // Make sure that the path exists. Creates the directory if it does not exist already: + ConeUtils::EnsurePathExistsL(aTargetFile); + User::LeaveIfError(BaflUtils::CopyFile(CEikonEnv::Static()->FsSession(), aSourceFile, aTargetFile)); + } + +// --------------------------------------------------------------------------- + +void CCreatorEngine::RequestMemoryDetails() + { + + TDriveList dl; + // variables for memory and disk handling + TVolumeInfo vinfo; + + //************************************************************************* + + //************************************************************************* + // get an access to file server + RFs& fsSession = CEikonEnv::Static()->FsSession(); + + fsSession.DriveList(dl); + + for(TInt driveNum = EDriveC; driveNum <= EDriveZ ; driveNum ++ ) + { + if( dl[driveNum] ) + { + TMemoryDetails *memDet = new TMemoryDetails; + if(fsSession.Volume(vinfo, driveNum) == KErrNone) + { + memDet->iFree.Num(TInt64(vinfo.iFree/1024)); + memDet->iSize.Num(TInt64(vinfo.iSize/1024)); + } + else + { + memDet->iFree.Num( 0 ); + memDet->iSize.Num( 0 ); + } + User::LeaveIfError(fsSession.DriveToChar(driveNum,memDet->iDriveLetter)); + iMemoryDetailsList.AppendL( memDet ); + } + } + + // available work memory + TMemoryInfoV1Buf memory; + UserHal::MemoryInfo(memory); + TInt64 freeMemBytes=(TInt64)(memory().iFreeRamInBytes); + TInt64 sizeMemBytes=(TInt64)(memory().iTotalRamInBytes); + TInt64 sizeWorkMemBytes = sizeMemBytes; + TInt64 sizeRomBytes = (TInt64)(memory().iTotalRomInBytes); + iMemoryDetails.iRamFree.Num(TInt64(freeMemBytes/1024)); + iMemoryDetails.iRamSize.Num(TInt64(sizeWorkMemBytes/1024)); + iMemoryDetails.iRomSize.Num(TInt64(sizeRomBytes/1024)); + } + +// --------------------------------------------------------------------------- + +TBool CCreatorEngine::MMC_OK() const + { + TBool MMCstatus = EFalse; + + TDriveNumber eDrive=EDriveE; + TVolumeInfo vinfo; + TInt err = CEikonEnv::Static()->FsSession().Volume(vinfo, eDrive); + // check if we can access the E-drive: + if ( err == KErrNone) + { + MMCstatus = ETrue; + } + else + { + MMCstatus = EFalse; + } + + // returns ETrue if MMC working properly + return MMCstatus; + } + +// --------------------------------------------------------------------------- + +void CCreatorEngine::ExecuteFirstCommandL(const TDesC& aText) + { + LOGSTRING("Creator: CCreatorEngine::ExecuteFirstCommand"); + + if( !iCommandArray->Count()) + { + ShutDownEnginesL(); + return; + } + + // show a progress dialog + iEngineWrapper->ShowProgressBar(aText, CommandArrayCount()); + + iFailedCommands = 0; + + // starts executing commands + ExecuteCommand(); + + + } + +// --------------------------------------------------------------------------- + +void CCreatorEngine::ExecuteCommand() + { + LOGSTRING("Creator: CCreatorEngine::ExecuteCommand"); + + // make sure the engine isn't active, should never happen + __ASSERT_ALWAYS(!IsActive(), User::Panic(_L("IsActive"), 500)); + + // execute a command after a very short delay (75ms) + iTimer.After(iStatus, 75); + SetActive(); + } + +// --------------------------------------------------------------------------- + +void CCreatorEngine::RunL() + { + LOGSTRING("Creator: CCreatorEngine::RunL"); + LOGSTRING2("Creator: CCreatorEngine::RunL iCommandId=%d", iCommandArray->At(iCurrentEntry).iCommandId); + + if ( iUserCancelled ) + { + return; + } + + if (!iCommandArray->At(iCurrentEntry).iParameters) + { + LOGSTRING("Creator: CCreatorEngine::RunL - iParameters==NULL !"); + } + + // launch a command + + TCreatorIds cmd = (TCreatorIds)iCommandArray->At(iCurrentEntry).iCommandId; + switch( cmd ) + { +/* + case ECmdCreateBrowserBookmarkEntries: { iBrowser->CreateBookmarkEntryL(reinterpret_cast(iCommandArray->At(iCurrentEntry).iParameters)); } break; + case ECmdCreateBrowserBookmarkFolderEntries: { iBrowser->CreateBookmarkFolderEntryL(reinterpret_cast(iCommandArray->At(iCurrentEntry).iParameters)); } break; + case ECmdCreateBrowserSavedPageEntries: { iBrowser->CreateSavedDeckEntryL(reinterpret_cast(iCommandArray->At(iCurrentEntry).iParameters)); } break; + case ECmdCreateBrowserSavedPageFolderEntries: { iBrowser->CreateSavedDeckFolderEntryL(reinterpret_cast(iCommandArray->At(iCurrentEntry).iParameters)); } break; +*/ + case ECmdCreateCalendarEntryAppointments: { iCalendar->CreateAppointmentEntryL(iCommandArray->At(iCurrentEntry).iParameters); } break; + case ECmdCreateCalendarEntryEvents: { iCalendar->CreateEventEntryL(iCommandArray->At(iCurrentEntry).iParameters); } break; + case ECmdCreateCalendarEntryAnniversaries: { iCalendar->CreateAnniversaryEntryL(iCommandArray->At(iCurrentEntry).iParameters); } break; + case ECmdCreateCalendarEntryToDos: { iCalendar->CreateTodoEntryL(iCommandArray->At(iCurrentEntry).iParameters); } break; + case ECmdCreateCalendarEntryReminders: { iCalendar->CreateReminderEntryL(iCommandArray->At(iCurrentEntry).iParameters); } break; + + + case ECmdCreatePhoneBookEntryContacts: { iPhonebook->CreateContactEntryL(iCommandArray->At(iCurrentEntry).iParameters) ; } break; + case ECmdCreatePhoneBookEntryGroups: { iPhonebook->CreateGroupEntryL(iCommandArray->At(iCurrentEntry).iParameters) ; } break; + case ECmdCreatePhoneBookEntrySubscribedContacts: { iPhonebook->CreateSubscribedContactEntryL(iCommandArray->At(iCurrentEntry).iParameters) ; } break; + + case ECmdCreateMiscEntryNotes: { iNotepad->CreateNoteEntryL(reinterpret_cast(iCommandArray->At(iCurrentEntry).iParameters)); } break; + + case ECmdCreateLogEntryMissedCalls: { iLogs->CreateMissedCallEntryL(reinterpret_cast(iCommandArray->At(iCurrentEntry).iParameters)); } break; + case ECmdCreateLogEntryReceivedCalls: { iLogs->CreateReceivedCallEntryL(reinterpret_cast(iCommandArray->At(iCurrentEntry).iParameters)); } break; + case ECmdCreateLogEntryDialledNumbers: { iLogs->CreateDialledNumberEntryL(reinterpret_cast(iCommandArray->At(iCurrentEntry).iParameters)); } break; +/* + case ECmdCreateMiscEntryAccessPoints: { iAccessPoints->CreateConnectionSettingsEntryL(iCommandArray->At(iCurrentEntry).iParameters); } break; + case ECmdDeleteIAPs: { iAccessPoints->DeleteAllL(); } break; + case ECmdDeleteCreatorIAPs: { iAccessPoints->DeleteAllCreatedByCreatorL(); } break; +*/ + case ECmdCreateMiscEntryLandmarks: { iLandmarks->CreateLandmarkEntryL(reinterpret_cast(iCommandArray->At(iCurrentEntry).iParameters)); } break; + + case ECmdCreateMessagingEntryMailboxes: { iMailboxes->CreateMailboxEntryL(reinterpret_cast(iCommandArray->At(iCurrentEntry).iParameters)); } break; +/* + #ifdef __PRESENCE + case ECmdCreateMiscEntryIMPSServers: { iIMPS->CreateIMPSServerEntryL(reinterpret_cast(iCommandArray->At(iCurrentEntry).iParameters)); } break; + #endif +*/ + case ECmdCreateMessagingEntryMessages: { iMessages->CreateMessageEntryL(reinterpret_cast(iCommandArray->At(iCurrentEntry).iParameters), ETrue); } break; + case ECmdCreateMessagingEntryMessagesViaScript: { iMessages->CreateMessageEntryL(reinterpret_cast(iCommandArray->At(iCurrentEntry).iParameters)); } break; + + case ECmdCreateRandomEntrySMSInbox: + case ECmdCreateRandomEntrySMSDrafts: + case ECmdCreateRandomEntrySMSOutbox: + case ECmdCreateRandomEntrySMSSent: + case ECmdCreateRandomEntryMMSInbox: + case ECmdCreateRandomEntryMMSDrafts: + case ECmdCreateRandomEntryMMSOutbox: + case ECmdCreateRandomEntryMMSSent: + case ECmdCreateRandomEntryAMSInbox: + case ECmdCreateRandomEntryAMSDrafts: + case ECmdCreateRandomEntryAMSOutbox: + case ECmdCreateRandomEntryAMSSent: + case ECmdCreateRandomEntryEmailInbox: + case ECmdCreateRandomEntryEmailDrafts: + case ECmdCreateRandomEntryEmailOutbox: + case ECmdCreateRandomEntryEmailSent: + case ECmdCreateRandomEntryBIOInbox: + case ECmdCreateRandomEntryBIODrafts: + case ECmdCreateRandomEntryBIOOutbox: + case ECmdCreateRandomEntryBIOSent: + case ECmdCreateRandomEntryIRInbox: + case ECmdCreateRandomEntryIRDrafts: + case ECmdCreateRandomEntryIROutbox: + case ECmdCreateRandomEntryIRSent: + case ECmdCreateRandomEntryBTInbox: + case ECmdCreateRandomEntryBTDrafts: + case ECmdCreateRandomEntryBTOutbox: + case ECmdCreateRandomEntryBTSent: + { iMessages->CreateRandomMessageEntryL(iCommandArray->At(iCurrentEntry).iCommandId); } break; + + case ECmdCreateFileEntryEmptyFolder: + case ECmdCreateFileEntry3GPP_70kB: + case ECmdCreateFileEntryAAC_100kB: + case ECmdCreateFileEntryAMR_20kB: + case ECmdCreateFileEntryBMP_25kB: + case ECmdCreateFileEntryDeck_1kB: + case ECmdCreateFileEntryDOC_20kB: + case ECmdCreateFileEntryGIF_2kB: + case ECmdCreateFileEntryHTML_20kB: + case ECmdCreateFileEntryJAD_1kB: + case ECmdCreateFileEntryJAR_10kB: + case ECmdCreateFileEntryJP2_65kB: + case ECmdCreateFileEntryJPEG_200kB: + case ECmdCreateFileEntryJPEG_25kB: + case ECmdCreateFileEntryJPEG_500kB: + case ECmdCreateFileEntryMIDI_10kB: + case ECmdCreateFileEntryMP3_250kB: + case ECmdCreateFileEntryMP4_200kB: + case ECmdCreateFileEntryMXMF_40kB: + case ECmdCreateFileEntryPNG_15kB: + case ECmdCreateFileEntryPPT_40kB: + case ECmdCreateFileEntryRAM_1kB: + case ECmdCreateFileEntryRM_95kB: + case ECmdCreateFileEntryRNG_1kB: + case ECmdCreateFileEntrySVG_15kB: + case ECmdCreateFileEntrySWF_15kB: + case ECmdCreateFileEntryTIF_25kB: + case ECmdCreateFileEntryTXT_10kB: + case ECmdCreateFileEntryTXT_70kB: + case ECmdCreateFileEntryVCF_1kB: + case ECmdCreateFileEntryVCS_1kB: + case ECmdCreateFileEntryWAV_20kB: + case ECmdCreateFileEntryXLS_15kB: + case ECmdCreateFileEntrySISX_10kB: + case ECmdCreateFileEntryWMA_50kB: + case ECmdCreateFileEntryWMV_200kB: + { iFiles->CreateFileEntryL( reinterpret_cast(iCommandArray->At(iCurrentEntry).iParameters), iCommandArray->At(iCurrentEntry).iCommandId ); } break; + case ECmdDeleteContacts: + { + iPhonebook->DeleteAllL(); + break; + } + case ECmdDeleteContactGroups: + { + iPhonebook->DeleteAllGroupsL(); + break; + } + case ECmdDeleteCreatorContacts: + { + iPhonebook->DeleteAllCreatedByCreatorL(); + break; + } + case ECmdDeleteCreatorContactGroups: + { + iPhonebook->DeleteAllGroupsCreatedByCreatorL(); + break; + } + case ECmdDeleteCalendarEntries: + { + iCalendar->DeleteAllL(); + break; + } + case ECmdDeleteCreatorCalendarEntries: + { + iCalendar->DeleteAllCreatedByCreatorL(); + break; + } + case ECmdDeleteLogs: + { + iLogs->DeleteAllL(); + break; + } + case ECmdDeleteCreatorLogs: + { + iLogs->DeleteAllCreatedByCreatorL(); + break; + } + case ECmdDeleteMessages: + { + iMessages->DeleteAllL(); + break; + } + case ECmdDeleteCreatorMessages: + { + iMessages->DeleteAllCreatedByCreatorL(); + break; + } + case ECmdDeleteLandmarks: + { + iLandmarks->DeleteAllL(); + break; + } + case ECmdDeleteCreatorLandmarks: + { + iLandmarks->DeleteAllCreatedByCreatorL(); + break; + } + case ECmdDeleteMailboxes: + { + iMailboxes->DeleteAllL(); + break; + } + case ECmdDeleteCreatorMailboxes: + { + iMailboxes->DeleteAllCreatedByCreatorL(); + break; + } + + case ECmdDeleteNotes: + { + iNotepad->DeleteAllL(); + break; + } + + case ECmdDeleteIMPSs: + { +// iIMPS->DeleteAllL(); + break; + } + case ECmdDeleteCreatorIMPSs: + { +// iIMPS->DeleteAllCreatedByCreatorL(); + break; + } +/* + case ECmdDeleteBrowserBookmarks: + { + iBrowser->DeleteAllBookmarksL(); + break; + } + case ECmdDeleteCreatorBrowserBookmarks: + { + iBrowser->DeleteAllBookmarksCreatedByCreatorL(); + break; + } + case ECmdDeleteBrowserBookmarkFolders: + { + iBrowser->DeleteAllBookmarkFoldersL(); + break; + } + case ECmdDeleteCreatorBrowserBookmarkFolders: + { + iBrowser->DeleteAllBookmarkFoldersCreatedByCreatorL(); + break; + } + case ECmdDeleteBrowserSavedPages: + { + iBrowser->DeleteAllSavedPagesL(); + break; + } + case ECmdDeleteCreatorBrowserSavedPages: + { + iBrowser->DeleteAllSavedPagesCreatedByCreatorL(); + break; + } + case ECmdDeleteBrowserSavedPageFolders: + { + iBrowser->DeleteAllSavedPageFoldersL(); + break; + } + case ECmdDeleteCreatorBrowserSavedPageFolders: + { + iBrowser->DeleteAllSavedPageFoldersCreatedByCreatorL(); + break; + } +*/ + case ECmdDeleteCreatorFiles: + { + iFiles->DeleteAllCreatedByCreatorL(); + break; + } + default: + User::Panic (_L("ExecuteOptionsMenuCommandL"), 205); + break; + } + + TRAP_IGNORE( CheckForMoreCommandsL() ); + + } + +CDesCArrayFlat* CCreatorEngine::PictureFilesL() + { + if( iPictureFileArray == 0 ) + { + _LIT(KImageFile, "JPEG*.jpg"); + _LIT(KImageFileDir, "C:\\Data\\"); + _LIT(KImageFileDir2, "Z:\\Data\\"); + iPictureFileArray = new (ELeave) CDesCArrayFlat(8); + TInt err = CreatorFileUtils::FindFilesRecursiveL(iPictureFileArray, KImageFile, KImageFileDir); + if( iPictureFileArray->Count() == 0 ) + { + err = CreatorFileUtils::FindFilesRecursiveL(iPictureFileArray, KImageFile, KImageFileDir2); + } + } + return iPictureFileArray; + } + +CDesCArrayFlat* CCreatorEngine::SoundFilesL() + { + if( iSoundFileArray == 0 ) + { + _LIT(KSoundFile, "*.aac"); + _LIT(KSoundFileDir, "Z:\\data\\Sounds\\"); + iSoundFileArray = new (ELeave) CDesCArrayFlat(8); + TInt err = CreatorFileUtils::FindFilesRecursiveL(iSoundFileArray, KSoundFile, KSoundFileDir); + } + return iSoundFileArray; + } +// --------------------------------------------------------------------------- + +TInt CCreatorEngine::RunError(TInt aError) + { + LOGSTRING2("Creator: CCreatorEngine::RunError %d", aError); + + iFailedCommands++; + + _LIT(KMessage, "Command error %d"); + TBuf<128> noteMsg; + noteMsg.Format(KMessage, aError); +// iEnv->InfoMsg(noteMsg); + iEngineWrapper->ShowNote(noteMsg); + TRAP_IGNORE( CheckForMoreCommandsL() ); + + return KErrNone; + } + +// --------------------------------------------------------------------------- + +void CCreatorEngine::CheckForMoreCommandsL() + { + LOGSTRING("Creator: CCreatorEngine::CheckForMoreCommandsL"); + if ( iUserCancelled ) + { + return; + } + // update the progress bar + //iProgressInfo->IncrementAndDraw(1); + iEngineWrapper->IncrementProgressbarValue(); + + // check if we have more commands to be executed + if (iCurrentEntry >= CommandArrayCount() - 1) + { + LOGSTRING("Creator: CCreatorEngine::CheckForMoreCommandsL all done"); + + // all done, free resources and show a note + ShutDownEnginesL(); + + //iProgressDialog->ProcessFinishedL(); + + // remove the progress dialog from the screen + iEngineWrapper->CloseProgressbar(); + + if (iFailedCommands == 0) + { + iEngineWrapper->ShowNote(_L("Done")); + } + else + { + _LIT(KMessage, "Done, %d commands failed"); + TBuf<128> noteMsg; + noteMsg.Format(KMessage, iFailedCommands); + iEngineWrapper->ShowNote(noteMsg); + } + + iCmdScriptRun->RunScriptDone(); + + } + else + { + // maintain requests + iCurrentEntry++; + + LOGSTRING2("Creator: CCreatorEngine::CheckForMoreCommandsL iCurrentEntry=%d", iCurrentEntry); + + ExecuteCommand(); + } + } + +// --------------------------------------------------------------------------- +void CCreatorEngine::SortCommands() + { + TKeyArrayFix iBufKey(_FOFF(TCommand, iCommandId),ECmpTInt); + iCommandArray->Sort(iBufKey); + } +// --------------------------------------------------------------------------- + +// This callback function is called when cancel button of the progress bar was pressed + +void CCreatorEngine::ProgressDialogCancelledL() + { + LOGSTRING("Creator: CCreatorEngine::ProgressDialogCancelledL"); + + iUserCancelled = ETrue; + // cancel the active object, command executer + Cancel(); + + // delete parameters from the command array, otherwise there might be memory leaks + for (TInt i=iCurrentEntry; iAt(i).iParameters ) + { + delete iCommandArray->At(i).iParameters; + iCommandArray->At(i).iParameters = NULL; + } + } + + if ( iDecoder ) + { + iDecoder->Cancel(); + // CancelComplete() will be called from GenerateSourceImageFileL + } + else if ( iScaler ) + { + iScaler->Cancel(); + // CancelComplete() will be called from GenerateSourceImageFileL + } + else if ( iEncoder ) + { + iEncoder->Cancel(); + // CancelComplete() will be called from GenerateSourceImageFileL + } + else + { + // free resources and show a note + ShutDownEnginesL(); + iEngineWrapper->ShowNote(_L("Cancelled")); + } + + } + +// --------------------------------------------------------------------------- + +void CCreatorEngine::StartEnginesL() + { + LOGSTRING("Creator: CCreatorEngine::StartEnginesL"); + + // reset user cancel flag + iUserCancelled = EFalse; + + // start from the beginning + iCurrentEntry = 0; + + // init the command array + __ASSERT_ALWAYS(!iCommandArray, User::Panic(_L("iCommandArray"), 701)); + iCommandArray = new(ELeave) CCommandArray(10000); + + // init all modules here + TInt err(KErrNone); +// TRAP(err, iBrowser = CCreatorBrowser::NewL(this)); + TRAP(err, iCalendar = CCreatorInterimCalendar::NewL(this)); + TRAP(err, iPhonebook = (CCreatorPhonebookBase*)TCreatorFactory::CreatePhoneBookL(this)); + TRAP(err, iNotepad = CCreatorNotepad::NewL(this)); + TRAP(err, iLogs = CCreatorLogs::NewL(this)); +// TRAP(err, iAccessPoints = (CCreatorConnectionSettingsBase*)TCreatorFactory::CreateConnectionSettingsL(this)); + TRAP(err, iMailboxes = CCreatorMailboxes::NewL(this)); + TRAP(err, iFiles = CCreatorFiles::NewL(this)); + TRAP(err, iMessages = CCreatorMessages::NewL(this)); + TRAP(err, iLandmarks = CCreatorLandmarks::NewL(this)); + ContactLinkCache::InitializeL(); +/* + #ifdef __PRESENCE + TRAP(err, iIMPS = CCreatorIMPS::NewL(this)); + #endif +*/ + + + // ... + // ... + // ... + + } +// --------------------------------------------------------------------------- + +void CCreatorEngine::ShutDownEnginesL() + { + LOGSTRING("Creator: CCreatorEngine::ShutDownEnginesL"); + + + // delete all modules here and free resources which aren't anymore needed + +/* + #ifdef __PRESENCE + delete iIMPS; + iIMPS = NULL; + #endif +*/ + delete iMessages; + iMessages = NULL; + delete iFiles; + iFiles = NULL; + delete iMailboxes; + iMailboxes = NULL; + // delete iAccessPoints; +// iAccessPoints = NULL; + delete iLogs; + iLogs = NULL; + delete iNotepad; + iNotepad = NULL; + delete iPhonebook; + iPhonebook = NULL; + delete iCalendar; + iCalendar = NULL; + // delete iBrowser; + // iBrowser = NULL; + delete iLandmarks; + iLandmarks = NULL; + + ContactLinkCache::DestroyL(); + // now delete the command array + delete iCommandArray; + iCommandArray = NULL; + + // delete parameter array + iParameterArray.ResetAndDestroy(); + iParameterArray.Close(); + + if(iCommandParser) + { + delete iCommandParser; + iCommandParser = NULL; + } + + + // clear temp drive + CFileMan* fileMan = CFileMan::NewL( iEnv->FsSession() ); + CleanupStack::PushL( fileMan ); + fileMan->RmDir( iTempPath->Des() ); + CleanupStack::PopAndDestroy(); //fileMan + } + +// --------------------------------------------------------------------------- + +void CCreatorEngine::DoCancel() + { + LOGSTRING("Creator: CCreatorEngine::DoCancel"); + + iTimer.Cancel(); + } + +void CCreatorEngine::ScriptChosenL( TBool aSuccess, const TDesC& aFileName ) + { + if( aSuccess ) + { + // open the file for reading + RFile scriptFile; + User::LeaveIfError( scriptFile.Open( iEnv->FsSession(), aFileName, EFileRead ) ); + CleanupClosePushL(scriptFile); + + + // wait dialog + /* TODO + CAknGlobalNote* waitDialog = CAknGlobalNote::NewLC(); + waitDialog->SetSoftkeys( R_AVKON_SOFTKEYS_CANCEL ); + TInt dialogId = waitDialog->ShowNoteL( EAknGlobalWaitNote, _L("Parsing") ); + */ + TInt parseErr( KErrNone ); + CCreatorScriptParser* scriptParser = CCreatorScriptParser::NewLC(this); + scriptParser->ParseL(scriptFile); + parseErr = scriptParser->GetError(); + CleanupStack::PopAndDestroy( scriptParser ); + + CleanupStack::PopAndDestroy( &scriptFile ); + + //waitDialog->CancelNoteL( dialogId ); + //CleanupStack::PopAndDestroy( waitDialog ); + + if(parseErr != KErrNone) + { + // show error note + _LIT(KErrMsg, "Parser error: %d"); + TBuf<32> msgBuf; + msgBuf.Format(KErrMsg, parseErr); + iEngineWrapper->ShowErrorMessage(msgBuf); + ShutDownEnginesL(); + return; + } + } + + // start executing commands if commands in the command array + if (CommandArrayCount() > 0) + { + ExecuteFirstCommandL( KSavingText ); + } + else + { + ShutDownEnginesL(); + } + } +// --------------------------------------------------------------------------- + +void CCreatorEngine::RunScriptL() + { + LOGSTRING("Creator: CCreatorEngine::RunScriptL"); + + // startup modules (also inits the command array): + StartEnginesL(); + + // use the command parser module to init the command array from a script file + delete iCommandParser; + iCommandParser = NULL; + iCommandParser = CCommandParser::NewL(this); + TBool ret = EFalse; + TRAPD(err, ret = iCommandParser->OpenScriptL( this ) ); + if( err != KErrNone || ret == EFalse) + { + ShutDownEnginesL(); + User::LeaveIfError(err); + } + } + +// --------------------------------------------------------------------------- + +TInt CCreatorEngine::RunScriptL(const TDesC& aScriptFile) + { + LOGSTRING("Creator: CCreatorEngine::RunScriptL"); + + // startup modules (also inits the command array): + StartEnginesL(); + + RFile scriptFile; + if (scriptFile.Open(CEikonEnv::Static()->FsSession(), aScriptFile, EFileRead) != KErrNone) + { + ShutDownEnginesL(); + return KErrNotFound; // file error + } + + CleanupClosePushL(scriptFile); + CCreatorScriptParser* scriptParser = CCreatorScriptParser::NewLC(this); + scriptParser->ParseL(scriptFile); + TInt err = scriptParser->GetError(); + CleanupStack::PopAndDestroy(); //scriptParser + CleanupStack::Pop(); // scriptFile + scriptFile.Close(); + + if (err != KErrNone) + { + ShutDownEnginesL(); + return KErrCorrupt; // parser error + } + + // start executing commands if commands in the command array + if (CommandArrayCount() > 0) + { + ExecuteFirstCommandL( KSavingText ); + return KErrNone; // executing commands is started + } + else + { + ShutDownEnginesL(); + return KErrCompletion; // nothing to do + } + } + +// --------------------------------------------------------------------------- +void CCreatorEngine::QueryDialogClosedL( TBool aPositiveAction, TInt aUserData ) + { + LOGSTRING("Creator: CCreatorEngine::QueryDialogClosedL"); + + if( aPositiveAction == EFalse ) + { + ShutDownEnginesL(); + return; + } + + switch(aUserData) + { + case ECreatorEngineDeleteAllEntries: + AppendToCommandArrayL( ECmdDeleteContacts, NULL, 1 ); + AppendToCommandArrayL( ECmdDeleteContactGroups, NULL, 1 ); + AppendToCommandArrayL( ECmdDeleteCalendarEntries, NULL, 1 ); + //AppendToCommandArrayL( ECmdDeleteBrowserBookmarks, NULL, 1 ); + //AppendToCommandArrayL( ECmdDeleteBrowserBookmarkFolders, NULL, 1 ); + //AppendToCommandArrayL( ECmdDeleteBrowserSavedPages, NULL, 1 ); + //AppendToCommandArrayL( ECmdDeleteBrowserSavedPageFolders, NULL, 1 ); + AppendToCommandArrayL( ECmdDeleteLogs, NULL, 1 ); + AppendToCommandArrayL( ECmdDeleteMessages, NULL, 1 ); + //AppendToCommandArrayL( ECmdDeleteIAPs, NULL, 1 ); + //AppendToCommandArrayL( ECmdDeleteIMPSs, NULL, 1 ); + AppendToCommandArrayL( ECmdDeleteNotes, NULL, 1 ); + AppendToCommandArrayL( ECmdDeleteLandmarks, NULL, 1 ); + AppendToCommandArrayL( ECmdDeleteCreatorFiles, NULL, 1 ); + + // started exucuting delete commands + ExecuteFirstCommandL( KDeletingText ); + break; + case ECreatorEngineDeleteAllCreatorEntries: + AppendToCommandArrayL( ECmdDeleteCreatorContacts, NULL, 1 ); + AppendToCommandArrayL( ECmdDeleteCreatorContactGroups, NULL, 1 ); + AppendToCommandArrayL( ECmdDeleteCreatorCalendarEntries, NULL, 1 ); + /* + AppendToCommandArrayL( ECmdDeleteCreatorBrowserBookmarks, NULL, 1 ); + AppendToCommandArrayL( ECmdDeleteCreatorBrowserBookmarkFolders, NULL, 1 ); + AppendToCommandArrayL( ECmdDeleteCreatorBrowserSavedPages, NULL, 1 ); + AppendToCommandArrayL( ECmdDeleteCreatorBrowserSavedPageFolders, NULL, 1 ); + */ + AppendToCommandArrayL( ECmdDeleteCreatorFiles, NULL, 1 ); + AppendToCommandArrayL( ECmdDeleteCreatorLogs, NULL, 1 ); + AppendToCommandArrayL( ECmdDeleteCreatorMessages, NULL, 1 ); + //AppendToCommandArrayL( ECmdDeleteCreatorIAPs, NULL, 1 ); + //AppendToCommandArrayL( ECmdDeleteCreatorIMPSs, NULL, 1 ); + AppendToCommandArrayL( ECmdDeleteCreatorLandmarks, NULL, 1 ); + + // started exucuting delete commands + ExecuteFirstCommandL( KDeletingText ); + break; + default: + //some error + ShutDownEnginesL(); + break; + } + } + +// --------------------------------------------------------------------------- + +void CCreatorEngine::ExecuteOptionsMenuCommandL(TInt aCommand) + { + LOGSTRING("Creator: CCreatorEngine::ExecuteOptionsMenuCommandL"); + + // startup modules (also inits the command array): + StartEnginesL(); + + // set the home module + switch(aCommand) + { +/* + case ECmdCreateBrowserBookmarkEntries: + case ECmdCreateBrowserBookmarkFolderEntries: + case ECmdCreateBrowserSavedPageEntries: + case ECmdCreateBrowserSavedPageFolderEntries: + case ECmdDeleteBrowserBookmarks: + case ECmdDeleteBrowserBookmarkFolders: + case ECmdDeleteBrowserSavedPages: + case ECmdDeleteBrowserSavedPageFolders: + case ECmdDeleteCreatorBrowserBookmarks: + case ECmdDeleteCreatorBrowserBookmarkFolders: + case ECmdDeleteCreatorBrowserSavedPages: + case ECmdDeleteCreatorBrowserSavedPageFolders: + { + iUsedOptionsMenuModule = iBrowser; + } + break; +*/ + case ECmdCreateCalendarEntryAppointments: + case ECmdCreateCalendarEntryEvents: + case ECmdCreateCalendarEntryAnniversaries: + case ECmdCreateCalendarEntryToDos: + case ECmdCreateCalendarEntryReminders: + case ECmdDeleteCalendarEntries: + case ECmdDeleteCreatorCalendarEntries: + { + iUsedOptionsMenuModule = iCalendar; + } + break; + + case ECmdCreatePhoneBookEntryContacts: + case ECmdCreatePhoneBookEntryGroups: + case ECmdCreatePhoneBookEntrySubscribedContacts: + case ECmdDeleteContacts: + case ECmdDeleteCreatorContacts: + case ECmdDeleteContactGroups: + case ECmdDeleteCreatorContactGroups: + { + iUsedOptionsMenuModule = iPhonebook; + } + break; + + case ECmdCreateMiscEntryNotes: + case ECmdDeleteNotes: + { + iUsedOptionsMenuModule = iNotepad; + } + break; + + case ECmdCreateLogEntryMissedCalls: + case ECmdCreateLogEntryReceivedCalls: + case ECmdCreateLogEntryDialledNumbers: + case ECmdDeleteLogs: + case ECmdDeleteCreatorLogs: + { + iUsedOptionsMenuModule = iLogs; + } + break; +/* + case ECmdCreateMiscEntryAccessPoints: + case ECmdDeleteIAPs: + case ECmdDeleteCreatorIAPs: + { + iUsedOptionsMenuModule = iAccessPoints; + } + break; +*/ + case ECmdCreateMessagingEntryMailboxes: + case ECmdDeleteMailboxes: + case ECmdDeleteCreatorMailboxes: + { + iUsedOptionsMenuModule = iMailboxes; + } + break; +/* + #ifdef __PRESENCE + case ECmdCreateMiscEntryIMPSServers: + case ECmdDeleteIMPSs: + case ECmdDeleteCreatorIMPSs: + { + iUsedOptionsMenuModule = iIMPS; + } + break; + #endif +*/ + case ECmdCreateFileEntryEmptyFolder: + case ECmdCreateFileEntry3GPP_70kB: + case ECmdCreateFileEntryAAC_100kB: + case ECmdCreateFileEntryAMR_20kB: + case ECmdCreateFileEntryBMP_25kB: + case ECmdCreateFileEntryDeck_1kB: + case ECmdCreateFileEntryDOC_20kB: + case ECmdCreateFileEntryGIF_2kB: + case ECmdCreateFileEntryHTML_20kB: + case ECmdCreateFileEntryJAD_1kB: + case ECmdCreateFileEntryJAR_10kB: + case ECmdCreateFileEntryJP2_65kB: + case ECmdCreateFileEntryJPEG_200kB: + case ECmdCreateFileEntryJPEG_25kB: + case ECmdCreateFileEntryJPEG_500kB: + case ECmdCreateFileEntryMIDI_10kB: + case ECmdCreateFileEntryMP3_250kB: + case ECmdCreateFileEntryMP4_200kB: + case ECmdCreateFileEntryMXMF_40kB: + case ECmdCreateFileEntryPNG_15kB: + case ECmdCreateFileEntryPPT_40kB: + case ECmdCreateFileEntryRAM_1kB: + case ECmdCreateFileEntryRM_95kB: + case ECmdCreateFileEntryRNG_1kB: + case ECmdCreateFileEntrySVG_15kB: + case ECmdCreateFileEntrySWF_15kB: + case ECmdCreateFileEntryTIF_25kB: + case ECmdCreateFileEntryTXT_10kB: + case ECmdCreateFileEntryTXT_70kB: + case ECmdCreateFileEntryVCF_1kB: + case ECmdCreateFileEntryVCS_1kB: + case ECmdCreateFileEntryWAV_20kB: + case ECmdCreateFileEntryXLS_15kB: + case ECmdCreateFileEntrySISX_10kB: + case ECmdCreateFileEntryWMA_50kB: + case ECmdCreateFileEntryWMV_200kB: + case ECmdDeleteCreatorFiles: + + { + iUsedOptionsMenuModule = iFiles; + } + break; + + + case ECmdCreateMessagingEntryMessages: + case ECmdDeleteMessages: + case ECmdDeleteCreatorMessages: + { + iUsedOptionsMenuModule = iMessages; + } + break; + + case ECmdCreateMiscEntryLandmarks: + case ECmdDeleteLandmarks: + case ECmdDeleteCreatorLandmarks: + { + iUsedOptionsMenuModule = iLandmarks; + } + break; + case ECmdDeleteAllEntries: + case ECmdDeleteAllCreatorEntries: + { + break; + } + default: + User::Panic (_L("ExecuteOptionsMenuCommandL"), 201); + break; + } + + + //If it's a delete command, asking do you really want to delete + if( IsDeleteCommand( aCommand ) ) + { + if ( aCommand == ECmdDeleteAllEntries ) + { + if ( !iEngineWrapper->YesNoQueryDialog( _L("Delete all entries?"), this, ECreatorEngineDeleteAllEntries) ) + { + // cancelled, free resources + ShutDownEnginesL(); + } + } + else if ( aCommand == ECmdDeleteAllCreatorEntries ) + { + if ( !iEngineWrapper->YesNoQueryDialog( _L("Delete all entries created with Creator?"), this, ECreatorEngineDeleteAllCreatorEntries ) ) + { + // cancelled, free resources + ShutDownEnginesL(); + } + } + else if ( !iUsedOptionsMenuModule->AskDataFromUserL( aCommand ) ) + { + // cancelled or error, free resources + ShutDownEnginesL(); + } + } + + // ask user data, if query accepted start processing... + else if (!iUsedOptionsMenuModule->AskDataFromUserL(aCommand)) + { + // cancelled or error, free resources + ShutDownEnginesL(); + } + } + + + +TBool CCreatorEngine::IsDeleteCommand(TInt aCommand) + { + LOGSTRING("Creator: CCreatorEngine::IsDeleteCommand"); + + switch(aCommand) + { + //Add supported delete command here + case ECmdDeleteAllEntries: + case ECmdDeleteAllCreatorEntries: + case ECmdDeleteEntries: + case ECmdDeleteContacts: + case ECmdDeleteCreatorContacts: + case ECmdDeleteContactGroups: + case ECmdDeleteCreatorContactGroups: + case ECmdDeleteCalendarEntries: + case ECmdDeleteCreatorCalendarEntries: + case ECmdDeleteBrowserBookmarks: + case ECmdDeleteCreatorBrowserBookmarks: + case ECmdDeleteBrowserBookmarkFolders: + case ECmdDeleteCreatorBrowserBookmarkFolders: + case ECmdDeleteBrowserSavedPages: + case ECmdDeleteCreatorBrowserSavedPages: + case ECmdDeleteBrowserSavedPageFolders: + case ECmdDeleteCreatorBrowserSavedPageFolders: + case ECmdDeleteCreatorFiles: + case ECmdDeleteLogs: + case ECmdDeleteCreatorLogs: + case ECmdDeleteMessages: + case ECmdDeleteCreatorMessages: + case ECmdDeleteMailboxes: + case ECmdDeleteCreatorMailboxes: + case ECmdDeleteIAPs: + case ECmdDeleteCreatorIAPs: + case ECmdDeleteIMPSs: + case ECmdDeleteCreatorIMPSs: + case ECmdDeleteNotes: + case ECmdDeleteLandmarks: + case ECmdDeleteCreatorLandmarks: + { + return ETrue; + } + default: + { + return EFalse; + } + } + + } +// --------------------------------------------------------------------------- +void CCreatorEngine::RandomDataFileChosenL( TBool aSuccess, const TDesC& aFileName ) + { + if( aSuccess ) + { + GetRandomDataFromFileL( aFileName ); + } + } + +// --------------------------------------------------------------------------- + +TBool CCreatorEngine::GetRandomDataL() + { + delete iCommandParser; + iCommandParser = NULL; + iCommandParser = CCommandParser::NewL( this ); + return iCommandParser->GetRandomDataFilenameL( this ); + } + +// --------------------------------------------------------------------------- + +TBool CCreatorEngine::GetRandomDataFromFileL(const TDesC& aFilename) + { + // wait dialog + // TODO + //CAknGlobalNote* waitDialog = CAknGlobalNote::NewLC(); + //waitDialog->SetSoftkeys(R_AVKON_SOFTKEYS_CANCEL); + //TInt dialogId = waitDialog->ShowNoteL(EAknGlobalWaitNote, _L("Reading random data")); + + for (TInt i = 0; i < iStringArrays.Count(); ++i) + { + delete iStringArrays[i].iArrayPtr; + } + iStringArrays.Reset(); + + TBool errorDetected = EFalse; + + // NOTE: These must be exactly in same order as in enumeration: + + if (ReadRandomDataL(EFirstName, R_DATA_FIRSTNAMES, aFilename, CCreatorRandomDataParser::EFirstName) != KErrNone) + { + errorDetected = ETrue; + } + if (ReadRandomDataL(ESurname, R_DATA_SURNAMES, aFilename, CCreatorRandomDataParser::ESurname) != KErrNone) + { + errorDetected = ETrue; + } + if (ReadRandomDataL(ECompany, R_DATA_COMPANIES, aFilename, CCreatorRandomDataParser::ECompany) != KErrNone) + { + errorDetected = ETrue; + } + if (ReadRandomDataL(EAddress, R_DATA_ADDRESSES, aFilename, CCreatorRandomDataParser::EAddress) != KErrNone) + { + errorDetected = ETrue; + } + if (ReadRandomDataL(EJobTitle, R_DATA_JOBTITLES, aFilename, CCreatorRandomDataParser::EJobTitle) != KErrNone) + { + errorDetected = ETrue; + } + if (ReadRandomDataL(EPhoneNumber, R_DATA_PHONENUMBERS, aFilename, CCreatorRandomDataParser::EPhoneNumber) != KErrNone) + { + errorDetected = ETrue; + } + if (ReadRandomDataL(EGroupName, R_DATA_GROUPNAMES, aFilename, CCreatorRandomDataParser::EGroupName) != KErrNone) + { + errorDetected = ETrue; + } + if (ReadRandomDataL(EMeetingReason, R_DATA_MEETINGREASONS, aFilename, CCreatorRandomDataParser::EMeetingReason) != KErrNone) + { + errorDetected = ETrue; + } + if (ReadRandomDataL(EMeetingPlace, R_DATA_MEETINGPLACES, aFilename, CCreatorRandomDataParser::EMeetingPlace) != KErrNone) + { + errorDetected = ETrue; + } + if (ReadRandomDataL(EMemoText, R_DATA_MEMOS, aFilename, CCreatorRandomDataParser::EMemoText) != KErrNone) + { + errorDetected = ETrue; + } + if (ReadRandomDataL(EAnniversaryReason, R_DATA_ANNIVERSARIES, aFilename, CCreatorRandomDataParser::EAnniversaryReason) != KErrNone) + { + errorDetected = ETrue; + } + if (ReadRandomDataL(EToDoText, R_DATA_TODOS, aFilename, CCreatorRandomDataParser::EToDoText) != KErrNone) + { + errorDetected = ETrue; + } + if (ReadRandomDataL(EReminderText, R_DATA_REMINDERS, aFilename, CCreatorRandomDataParser::EReminderText) != KErrNone) + { + errorDetected = ETrue; + } + if (ReadRandomDataL(EMessageSubject, R_DATA_MESSAGESUBJECTS, aFilename, CCreatorRandomDataParser::EMessageSubject) != KErrNone) + { + errorDetected = ETrue; + } + if (ReadRandomDataL(EMessageText, R_DATA_MESSAGETEXTS, aFilename, CCreatorRandomDataParser::EMessageText) != KErrNone) + { + errorDetected = ETrue; + } + if (ReadRandomDataL(ECity, R_DATA_CITIES, aFilename, CCreatorRandomDataParser::ECity) != KErrNone) + { + errorDetected = ETrue; + } + if (ReadRandomDataL(ECountry, R_DATA_COUNTRIES, aFilename, CCreatorRandomDataParser::ECountry) != KErrNone) + { + errorDetected = ETrue; + } + if (ReadRandomDataL(EPostcode, R_DATA_POSTCODES, aFilename, CCreatorRandomDataParser::EPostcode) != KErrNone) + { + errorDetected = ETrue; + } + if (ReadRandomDataL(EState, R_DATA_STATES, aFilename, CCreatorRandomDataParser::EState) != KErrNone) + { + errorDetected = ETrue; + } + if (ReadRandomDataL(EPobox, R_DATA_POBOXES, aFilename, CCreatorRandomDataParser::EPobox) != KErrNone) + { + errorDetected = ETrue; + } + if (ReadRandomDataL(EPrefix, R_DATA_PREFIXES, aFilename, CCreatorRandomDataParser::EPrefix) != KErrNone) + { + errorDetected = ETrue; + } + if (ReadRandomDataL(ESuffix, R_DATA_SUFFIXES, aFilename, CCreatorRandomDataParser::ESuffix) != KErrNone) + { + errorDetected = ETrue; + } + if (ReadRandomDataL(ELandmarkName, R_DATA_LANDMARK_NAMES, aFilename, CCreatorRandomDataParser::ELandmarkName) != KErrNone) + { + errorDetected = ETrue; + } + if (ReadRandomDataL(ELandmarkDescription, R_DATA_LANDMARK_DESCRIPTIONS, aFilename, CCreatorRandomDataParser::ELandmarkDescription) != KErrNone) + { + errorDetected = ETrue; + } + + // remove the wait dialog + //waitDialog->CancelNoteL(dialogId); + //CleanupStack::PopAndDestroy(waitDialog); + + if (errorDetected) + { + iEngineWrapper->ShowNote(_L("Error in reading random data.")); + } + return !errorDetected; + } + +// --------------------------------------------------------------------------- + +TInt CCreatorEngine::ReadRandomDataL(const TRandomStringType aRandomStringType, + const TInt aResourceId, + const TDesC& aFilename, + const CCreatorRandomDataParser::TRandomDataType aRandomDataType) + { + TInt error = KErrNone; + if (aFilename == KNullDesC) + { + iStringArrays.AppendL(TStringArrayPtr(aRandomStringType, iEnv->ReadDesCArrayResourceL(aResourceId))); + } + else + { + CCreatorRandomDataParser* dataParser = CCreatorRandomDataParser::NewLC(); + CDesCArrayFlat* array = NULL; + + TRAP(error, array = dataParser->ParseL(aFilename, aRandomDataType)); + if (error == KErrNone) + { + error = dataParser->GetError(); + } + if ((error == KErrNone) && (array->MdcaCount() > 0)) + { + iStringArrays.AppendL(TStringArrayPtr(aRandomStringType, array)); + } + else + { + if (array) + { + array->Reset(); + delete array; + } + iStringArrays.AppendL(TStringArrayPtr(aRandomStringType, iEnv->ReadDesCArrayResourceL(aResourceId))); + } + CleanupStack::PopAndDestroy(dataParser); + } + return error; + } + +// --------------------------------------------------------------------------- + +void CCreatorEngine::AppendToCommandArrayL(TInt aCommand, CCreatorModuleBaseParameters* aParameters, TInt aNumberOfEntries) + { + LOGSTRING("Creator: CCreatorEngine::AppendToCommandArrayL"); + iParameterArray.AppendL(aParameters); + + for (TInt i=0; iAppendL( TCommand(aCommand, aParameters) ); + } + +// --------------------------------------------------------------------------- + +TInt CCreatorEngine::CommandArrayCount() + { + TInt count(0); + + if (iCommandArray) + count = iCommandArray->Count(); + + LOGSTRING2("Creator: CCreatorEngine::CommandArrayCount returns %d", count); + + return count; + } + +// --------------------------------------------------------------------------- + +//returs fileid by its name, eg. 1 in +TInt CCreatorEngine::GetAttachmentIdL( const TDesC& aAttachmentIdStr ) const + { + TInt mapCount = sizeof(FileMap) / sizeof(FileMapping); + + for( TInt i = 0; i < mapCount; ++i ) + { + if( FileMap[i].FileName() == aAttachmentIdStr ) + return FileMap[i].FileId(); + } + LOGSTRING2("CCreatorEngine::GetAttachmentIdL: Unknown attachment file id: %s", &aAttachmentIdStr); + User::Leave(KErrGeneral); + return KErrNotFound; // Not reached, but disables a compiler warning + } + +// --------------------------------------------------------------------------- + +// returns a random string from the resource files +TPtrC CCreatorEngine::TestDataPathL (enum TTestDataPath aTestDataPath ) + { + LOGSTRING("Creator: CCreatorEngine::TestDataPathL"); + + static TFileName filePath; + + switch (aTestDataPath ) + { + case ESavedDeck_1kB: + { + filePath.Copy (_L("Deck-1kB.saveddeck") ); + } + break; + + case EJPEG_25kB: + { + filePath.Copy (_L("JPEG-25kB.jpg") ); + } + break; + + case EJPEG_200kB: + { + filePath.Copy (_L("JPEG-200kB.jpg") ); + } + break; + + case EJPEG_500kB: + { + filePath.Copy (_L("JPEG-500kB.jpg") ); + } + break; + + case EPNG_15kB: + { + filePath.Copy (_L("PNG-15kB.png") ); + } + break; + + case EGIF_2kB: + { + filePath.Copy (_L("GIF-2kB.gif") ); + } + break; + + case ERNG_1kB: + { + filePath.Copy (_L("RNG-1kB.rng") ); + } + break; + + case EMIDI_10kB: + { + filePath.Copy (_L("MIDI-10kB.mid") ); + } + break; + + case EWAVE_20kB: + { + filePath.Copy (_L("WAV-20kB.wav") ); + } + break; + + case EAMR_20kB: + { + filePath.Copy (_L("AMR-20kB.amr") ); + } + break; + + case EExcel_15kB: + { + filePath.Copy (_L("XLS-15kB.xls") ); + } + break; + + case EWord_20kB: + { + filePath.Copy (_L("DOC-20kB.doc") ); + } + break; + + case EPowerPoint_40kB: + { + filePath.Copy (_L("PPT-40kB.ppt") ); + } + break; + + case EText_10kB: + { + filePath.Copy (_L("TXT-10kB.txt") ); + } + break; + + case EText_70kB: + { + filePath.Copy (_L("TXT-70kB.txt") ); + } + break; + + case E3GPP_70kB: + { + filePath.Copy (_L("3GPP-70kB.3gpp") ); + } + break; + + case EMP3_250kB: + { + filePath.Copy (_L("MP3-250kB.mp3") ); + } + break; + + case EAAC_100kB: + { + filePath.Copy (_L("AAC-100kB.aac") ); + } + break; + + case ERM_95kB: + { + filePath.Copy (_L("RM-95kB.rm") ); + } + break; + + case EBMP_25kB: + { + filePath.Copy (_L("BMP-25kB.bmp") ); + } + break; + case EHTML_20kB: + { + filePath.Copy (_L("HTML-20kB.html") ); + } + break; + case EJAD_1kB: + { + filePath.Copy (_L("JAD-1kB.jad") ); + } + break; + case EJAR_10kB: + { + filePath.Copy (_L("JAR-10kB.jar") ); + } + break; + case EJP2_65kB: + { + filePath.Copy (_L("JP2-65kB.jp2") ); + } + break; + case EMP4_200kB: + { + filePath.Copy (_L("MP4-200kB.mp4") ); + } + break; + case EMXMF_40kB: + { + filePath.Copy (_L("MXMF-40kB.mxmf") ); + } + break; + case ERAM_1kB: + { + filePath.Copy (_L("RAM-1kB.ram") ); + } + break; + case ESVG_15kB: + { + filePath.Copy (_L("SVG-15kB.svg") ); + } + break; + case ESWF_15kB: + { + filePath.Copy (_L("SWF-15kB.swf") ); + } + break; + case ETIF_25kB: + { + filePath.Copy (_L("TIF-25kB.tif") ); + } + break; + case EVCF_1kB: + { + filePath.Copy (_L("VCF-1kB.vcf") ); + } + break; + case EVCS_1kB: + { + filePath.Copy (_L("VCS-1kB.vcs") ); + } + break; + case ESISX_10kB: + { + filePath.Copy (_L("SISX-10kB.sisx") ); + } + break; + case EWMA_50kB: + { + filePath.Copy (_L("WMA-50kB.wma") ); + } + break; + case EWMV_200kB: + { + filePath.Copy (_L("WMV-200kB.wmv") ); + } + break; + + default: + User::Panic (_L("Test data"), 401 ); + break; + } + + TFileName fullTargetPath; + fullTargetPath.Copy( iTempPath->Des() ); + fullTargetPath.Append( filePath ); + if (ConeUtils::FileExists(fullTargetPath)) + { + // No need to copy, if the file already exists. + LOGSTRING2("Creator: CCreatorEngine::TestDataPathL %S already exists", &fullTargetPath); + return fullTargetPath; + } + + // Define the path where the testdata can be retrieved + // get the data from the private directory in secure platform + TFileName fullAppPath = iEnv->EikAppUi()->Application()->AppFullName(); + TChar driveLetter = fullAppPath[0]; + TInt driveNumber; + + iEnv->FsSession().CharToDrive(driveLetter, driveNumber); + iEnv->FsSession().SetSessionToPrivate( driveNumber ); // "\\private\\20011383\\" + + + // check the file exists + if (!ConeUtils::FileExists(filePath)) + { + LOGSTRING2("Creator: CCreatorEngine::TestDataPathL %S not found", &filePath); + + TInt generatingError( KErrNone ); + + // The file could be on C drive + iEnv->FsSession().SetSessionToPrivate( KRegisterDrive ); + + if ( !ConeUtils::FileExists( filePath ) ) + { + // The file is not on C drive, see if we can generate it + + // Make sure that the private path of this app in c-drive exists + iEnv->FsSession().CreatePrivatePath( KRegisterDrive ); + + TFileName privatePath; + iEnv->FsSession().PrivatePath( privatePath ); + privatePath.Append( filePath ); + TChar privateDriveChar; + iEnv->FsSession().DriveToChar( KRegisterDrive, privateDriveChar ); + TFileName fullPrivatePath; // full path of a file to be generated + fullPrivatePath.Append( privateDriveChar ); + fullPrivatePath.Append( ':' ); + fullPrivatePath.Append( privatePath ); + + switch ( aTestDataPath ) + { + case EJPEG_25kB: + case EJPEG_200kB: + case EJPEG_500kB: + case EBMP_25kB: + case EGIF_2kB: + { + TRAP( generatingError, GenerateSourceImageFileL( aTestDataPath, fullPrivatePath ) ); + // GenerateSourceImageFileL calls TestDataPathL -> private session points to z + // change it back to KRegisterDrive, because generated source file is there + // and we need to copy it at the end of this function. + iEnv->FsSession().SetSessionToPrivate( KRegisterDrive ); + break; + } + case EText_10kB: + { + TRAP( generatingError, GenereteSourceTextFileL( fullPrivatePath, 10000 ) ); + // GenerateSourceImageFileL calls TestDataPathL -> private session points to z + // change it back to KRegisterDrive, because generated source file is there + // and we need to copy it at the end of this function. + iEnv->FsSession().SetSessionToPrivate( KRegisterDrive ); + break; + } + case EText_70kB: + { + TRAP( generatingError, GenereteSourceTextFileL( fullPrivatePath, 70000 ) ); + break; + } + default: + { + generatingError = KErrNotSupported; + break; + } + } + } + + if ( iUserCancelled ) + { + LOGSTRING("Creator: CCreatorEngine::TestDataPathL iUserCancelled" ); + User::Leave( KErrCancel ); + } + + if ( generatingError ) + { + // Generating the file failed + + // cancel the dialog + //iProgressDialog->ProcessFinishedL(); + //DialogDismissedL(EAknSoftkeyBack); + + // remove the progress dialog from the screen + iEngineWrapper->CloseProgressbar(); + + + // show error note + iEngineWrapper->ShowNote(_L("Test data missing")); + + User::Leave(KErrPathNotFound); + } + } + + // now copy the data to D-drive to make the file public + iEnv->FsSession().MkDirAll( iTempPath->Des() ); + TInt copyErr = BaflUtils::CopyFile(iEnv->FsSession(), filePath, fullTargetPath); + LOGSTRING4("Creator: CCreatorEngine::TestDataPathL copy %S to %S returns=%d", &filePath, &fullTargetPath, copyErr); + + // make sure that the file won't have a read only attribute + TEntry fileEntry; + iEnv->FsSession().Entry(fullTargetPath, fileEntry); + iEnv->FsSession().SetEntry(fullTargetPath, fileEntry.iModified, NULL, KEntryAttReadOnly); + + filePath = fullTargetPath; // change the reference to the temp path + return filePath; + } + + +// --------------------------------------------------------------------------- + + + +// a method to return a default Internet Access Point +TUint32 CCreatorEngine::GetDefaultIAPL() + { + LOGSTRING("Creator: CCreatorEngine::GetDefaultIAPL"); + + TUint32 lIAPid = 1; // Default value + + CCommsDatabase* cDatabase = CCommsDatabase::NewL(); + CleanupStack::PushL(cDatabase); + + CCommsDbTableView* tableView = cDatabase->OpenTableLC(TPtrC(IAP)); + + TInt errorCode = tableView->GotoFirstRecord(); + + if ( errorCode == KErrNone ) + { + TUint32 iValue; + tableView->ReadUintL(TPtrC(COMMDB_ID),iValue); + lIAPid = iValue; + } + + CleanupStack::PopAndDestroy(2); // cDatabase,tableView + + return lIAPid; + } + +// --------------------------------------------------------------------------- + +TUint32 CCreatorEngine::AccessPointNameToIdL(const TDesC& /*aAPName*/, TBool /*aAnyIfNotFound*/ ) + { + LOGSTRING("Creator: CCreatorEngine::AccessPointNameToIdL"); + // Accespoint impl moved from engine to accespoint implementations for supporting 3.0-3.1 and 3.2-> + //return iAccessPoints->AccessPointNameToIdL(aAPName, aAnyIfNotFound ); + return 0; + } + +static CCreatorEngine::TTestDataPath SoundFiles[] = { + CCreatorEngine::EMIDI_10kB, + CCreatorEngine::EWAVE_20kB, + CCreatorEngine::EMP3_250kB, + CCreatorEngine::EAAC_100kB + }; + +static CCreatorEngine::TTestDataPath PictureFiles[] = + { + CCreatorEngine::EJPEG_25kB, + CCreatorEngine::EJPEG_200kB, + CCreatorEngine::EJPEG_500kB, + CCreatorEngine::EPNG_15kB, + CCreatorEngine::EGIF_2kB + }; + +TPtrC CCreatorEngine::CreateSoundFileL(TTestDataPath aId) +{ + TPtrC tempPath(TestDataPathL(aId)); + // Copy file to permanent location: + TParse parser; + parser.Set(tempPath, NULL, NULL); + TPtrC fileName(parser.NameAndExt()); + HBufC* fullTargetPath = HBufC::NewLC( KMaxFileName ); + fullTargetPath->Des().Copy( PathInfo::PhoneMemoryRootPath() ); + fullTargetPath->Des().Append( PathInfo::DigitalSoundsPath() ); + + fullTargetPath->Des().Append(fileName); + CopyFileL(tempPath, *fullTargetPath); + iAllocatedFilePaths.AppendL(fullTargetPath); + CleanupStack::Pop(); // fullTargetPath + return fullTargetPath->Des(); +} +TPtrC CCreatorEngine::CreateRandomSoundFileL() +{ + TInt numOfFiles = sizeof(SoundFiles) / sizeof(TTestDataPath); + return CreateSoundFileL(SoundFiles[RandomNumber(0, numOfFiles-1)]); +} +TPtrC CCreatorEngine::RandomSoundFileL() +{ + TInt numOfFiles = sizeof(SoundFiles) / sizeof(TTestDataPath); + return TestDataPathL(SoundFiles[RandomNumber(0, numOfFiles-1)]); +} + +void CCreatorEngine::RandomPictureFileL(TDes& aPath) +{ + TInt numOfFiles = sizeof(PictureFiles) / sizeof(TTestDataPath); + aPath = TestDataPathL(PictureFiles[RandomNumber(0, numOfFiles-1)]); +} +// --------------------------------------------------------------------------- + +// returns a random string from the resource files +TPtrC CCreatorEngine::RandomString(enum TRandomStringType aRandomStringType) + { + LOGSTRING("Creator: CCreatorEngine::RandomString"); + + // Let's see if the array is OK and the string arrays are in correct order: + if( ((TInt) aRandomStringType) < iStringArrays.Count() && + iStringArrays[aRandomStringType].iStringType == aRandomStringType) + { + TInt rand = (TInt) (iStringArrays[aRandomStringType].iArrayPtr->Count() * Math::FRand(iSeed)); + return (*iStringArrays[aRandomStringType].iArrayPtr)[rand]; + } + + // Now let's loop the arrays and try to find one with the type: + for( TInt i = 0; i < iStringArrays.Count(); ++i ) + { + if( iStringArrays[i].iStringType == aRandomStringType ) + { + TInt rand = (TInt) (iStringArrays[i].iArrayPtr->Count() * Math::FRand(iSeed)); + return (*iStringArrays[i].iArrayPtr)[rand]; + } + } + + User::Panic (_L("Random string"), 402); + return NULL; + } + +// --------------------------------------------------------------------------- + +// returns a random number +TInt CCreatorEngine::RandomNumber(TInt aRange) + { + LOGSTRING2("Creator: CCreatorEngine::RandomNumber aRange=%d", aRange); + + return (TInt) (aRange*Math::FRand(iSeed)); + } + +// --------------------------------------------------------------------------- + +// returns a random number +TInt CCreatorEngine::RandomNumber(TInt aMin, TInt aMax) + { + LOGSTRING3("Creator: CCreatorEngine::RandomNumber aMin=%d aMax=%d", aMin, aMax); + + TInt range = (aMax > aMin ? aMax - aMin : aMin - aMax) + 1; + TInt random = (TInt) (range*Math::FRand(iSeed)); + + random = (random % range) + aMin; + + if (random > aMax) + random = aMax; + else if (random < aMin) + random = aMin; + + return random; + } + +TTime CCreatorEngine::RandomTime(TTime baseTime, TRandomDateType type, TInt aMinHours, TInt aMaxHours, TInt aMinMinutes, TInt aMaxMinutes ) + { + TInt randomHours = RandomNumber(aMinHours, aMaxHours); + TInt randomMinutes = RandomNumber(aMinMinutes, aMaxMinutes); + + switch( type ) + { + case EDatePast: + return (baseTime - TTimeIntervalHours(randomHours)) - TTimeIntervalMinutes(randomMinutes); + case EDateFuture: + return (baseTime + TTimeIntervalHours(randomHours)) + TTimeIntervalMinutes(randomMinutes); + default: + break; + } + return baseTime; + } + +TTime CCreatorEngine::RandomDate(TTime baseTime, TRandomDateType type, TInt aMinDays, TInt aMaxDays) + { + TInt random = RandomNumber(aMinDays, aMaxDays); + + switch( type ) + { + case EDatePast: + return baseTime - TTimeIntervalDays(random); + case EDateFuture: + return baseTime + TTimeIntervalDays(random); + default: + break; + } + + return baseTime; + } + +TTime CCreatorEngine::RandomDate(TRandomDateType type, TInt aMinDays, TInt aMaxDays) + { + TTime time; + // Set to current time: + time.HomeTime(); + return RandomDate(time, type, aMinDays, aMaxDays); + } + +HBufC* CCreatorEngine::CreateEmailAddressLC() + { + _LIT(KCountry, "com"); + return CreateEmailAddressLC(RandomString(EFirstName), RandomString(ESurname), RandomString(ECompany), KCountry); + } + +HBufC* CCreatorEngine::CreateHTTPUrlLC() + { + _LIT(KProtocol, "http://"); + _LIT(KPrefix, "www"); + _LIT(KCountry, "com"); + return CreateUrlLC(KProtocol, KPrefix, RandomString(ECompany), KCountry); + } + +HBufC* CCreatorEngine::CreateRandomStringLC(TInt aStrLen) + { + TInt minAscii = 65; + TInt maxAscii = 90; + HBufC* str = HBufC::NewL(aStrLen); + CleanupStack::PushL(str); + for( TInt i = 0; i < aStrLen; ++i ) + { + TInt random = RandomNumber(minAscii, maxAscii); + TChar randomChar = TChar((TUint) random); + str->Des().Append(randomChar); + } + return str; + } + +HBufC* CCreatorEngine::CreateEmailAddressLC( + const TDesC& firstname, + const TDesC& lastname, + const TDesC& domain, + const TDesC& country ) const + { + HBufC* email = HBufC::New(firstname.Length() + lastname.Length() + domain.Length() + country.Length() + 3); + CleanupStack::PushL(email); + _LIT(KEmailAddr, "%S.%S@%S.%S"); + email->Des().Format(KEmailAddr, &firstname, &lastname, &domain, &country); + return email; + } + +HBufC* CCreatorEngine::CreateUrlLC( + const TDesC& protocol, + const TDesC& prefix, + const TDesC& domain, + const TDesC& country) const + { + HBufC* url = HBufC::New(protocol.Size() + prefix.Size() + domain.Size() + country.Size() + 2); + CleanupStack::PushL(url); + _LIT(KUrl, "%S%S.%S.%S"); + url->Des().Format(KUrl, &protocol, &prefix, &domain, &country); + return url; + } +// --------------------------------------------------------------------------- + +void CCreatorEngine::SetDefaultPathForFileCommandL(TInt aCommand, TFileName& aPath) + { + aPath.Copy( PathInfo::PhoneMemoryRootPath() ); + switch (aCommand) + { + case ECmdCreateFileEntryJPEG_25kB: + case ECmdCreateFileEntryJPEG_200kB: + case ECmdCreateFileEntryJPEG_500kB: + case ECmdCreateFileEntryPNG_15kB: + case ECmdCreateFileEntryGIF_2kB: + case ECmdCreateFileEntryBMP_25kB: + case ECmdCreateFileEntrySVG_15kB: + case ECmdCreateFileEntryTIF_25kB: + case ECmdCreateFileEntryJP2_65kB: + + { aPath.Append( PathInfo::ImagesPath() ); break; } + + case ECmdCreateFileEntryRNG_1kB: + { aPath.Append( PathInfo::SimpleSoundsPath() ); break; } + + case ECmdCreateFileEntryMIDI_10kB: + case ECmdCreateFileEntryWAV_20kB: + case ECmdCreateFileEntryAMR_20kB: + case ECmdCreateFileEntryMP3_250kB: + case ECmdCreateFileEntryAAC_100kB: + case ECmdCreateFileEntryWMA_50kB: + { aPath.Append( PathInfo::DigitalSoundsPath() ); break; } + + case ECmdCreateFileEntry3GPP_70kB: + case ECmdCreateFileEntryRM_95kB: + case ECmdCreateFileEntryMP4_200kB: + case ECmdCreateFileEntryWMV_200kB: + + { aPath.Append( PathInfo::VideosPath() ); break; } + + case ECmdCreateFileEntryEmptyFolder: + { aPath.Append( _L("MyFolder\\") ); break; } + + default: + { aPath.Append( PathInfo::OthersPath() ); break; } + + } + } + + +// --------------------------------------------------------------------------- + +void CCreatorEngine::CancelComplete() + { + LOGSTRING("Creator: CCreatorEngine::CancelComplete"); + // free resources and show a note + TRAP_IGNORE( ShutDownEnginesL() ); + + TRAP_IGNORE(iEngineWrapper->ShowNote(_L("Cancelled"))); + + } + +// --------------------------------------------------------------------------- + +TCommand::TCommand(TInt aCommandId, CCreatorModuleBaseParameters* aParameters) + { + iCommandId = aCommandId; + iParameters = aParameters; + } + +// --------------------------------------------------------------------------- + +TCommand::~TCommand() + { + } + +// --------------------------------------------------------------------------- + +CAsyncWaiter* CAsyncWaiter::NewL(TInt aPriority) + { + CAsyncWaiter* self = new(ELeave) CAsyncWaiter(aPriority); + return self; + } + +CAsyncWaiter* CAsyncWaiter::NewLC(TInt aPriority) + { + CAsyncWaiter* self = new(ELeave) CAsyncWaiter(aPriority); + CleanupStack::PushL(self); + return self; + } + +CAsyncWaiter::CAsyncWaiter(TInt aPriority) : CActive(aPriority) + { + CActiveScheduler::Add(this); + } + +CAsyncWaiter::~CAsyncWaiter() + { + Cancel(); + } + +void CAsyncWaiter::StartAndWait() + { + LOGSTRING("Creator: CAsyncWaiter::StartAndWait"); + iStatus = KRequestPending; + SetActive(); + iWait.Start(); + } + +TInt CAsyncWaiter::Result() const + { + return iError; + } + +void CAsyncWaiter::RunL() + { + LOGSTRING("Creator: CAsyncWaiter::RunL"); + + iError = iStatus.Int(); + //CAknEnv::StopSchedulerWaitWithBusyMessage( iWait ); + iWait.AsyncStop(); + } + +void CAsyncWaiter::DoCancel() + { + LOGSTRING("Creator: CAsyncWaiter::DoCancel"); + + iError = KErrCancel; + if( iStatus == KRequestPending ) + { + TRequestStatus* s=&iStatus; + User::RequestComplete( s, KErrCancel ); + } + iWait.AsyncStop(); + //CAknEnv::StopSchedulerWaitWithBusyMessage( iWait ); + } + +FileMapping::FileMapping( const TDesC& aAttName, TInt aAttId, TInt aCommandId ) + : + iFileName(aAttName), + iFileId(aAttId), + iCommandId(aCommandId) + {} + + const TDesC& FileMapping::FileName() const + { + return iFileName; + } + + TInt FileMapping::FileId() const + { + return iFileId; + } + + TInt FileMapping::CommandId() const + { + return iCommandId; + } + +// --------------------------------------------------------------------------- +CDictionaryFileStore* CCreatorEngine::FileStoreLC() + { + LOGSTRING("Creator: CCreatorEngine::FileStoreLC"); + CDictionaryFileStore* store; + + // make sure that the private path of this app in c-drive exists + CEikonEnv::Static()->FsSession().CreatePrivatePath( KRegisterDrive ); // c:\\private\\20011383\\ + + // handle register always in the private directory + User::LeaveIfError( CEikonEnv::Static()->FsSession().SetSessionToPrivate( KRegisterDrive ) ); + store = CDictionaryFileStore::OpenLC( CEikonEnv::Static()->FsSession(), KRegisterFileName, KUidCreatorApp ); + return store; + } + +// --------------------------------------------------------------------------- +void CCreatorEngine::ReadEntryIdsFromStoreL( RArray& aEntryIds, const TUid aModuleUid ) + { + LOGSTRING("Creator: CCreatorEngine::ReadEntryIdsFromStoreL"); + CDictionaryFileStore* store = FileStoreLC(); + User::LeaveIfNull( store ); + if ( store->IsPresentL( aModuleUid ) ) + { + RDictionaryReadStream in; + in.OpenLC( *store, aModuleUid ); + TFileName fullPath; + TInt err( KErrNone ); + TInt id( KErrNotFound ); + while ( !err ) + { + TRAP( err, id = in.ReadInt32L() ); // will leave with KErrEof + if ( !err ) + { + aEntryIds.AppendL( id ); + } + } + CleanupStack::PopAndDestroy( &in ); + } + CleanupStack::PopAndDestroy( store ); + } + +// --------------------------------------------------------------------------- +void CCreatorEngine::WriteEntryIdsToStoreL( RArray& aEntryIds, const TUid aModuleUid ) + { + LOGSTRING("Creator: CCreatorEngine::WriteEntryIdsToStoreL"); + CDictionaryFileStore* store = FileStoreLC(); + User::LeaveIfNull( store ); + + // backup previous ids from store + // otherwise they would be overwritten when calling out.WriteL + RArray previousIds; + CleanupClosePushL( previousIds ); + + if ( store->IsPresentL( aModuleUid ) ) + { + RDictionaryReadStream in; + in.OpenLC( *store, aModuleUid ); + TInt err( KErrNone ); + TInt id( KErrNotFound ); + while ( !err ) + { + TRAP( err, id = in.ReadInt32L() ); // will leave with KErrEof + if ( !err ) + { + previousIds.AppendL( id ); + } + } + CleanupStack::PopAndDestroy( &in ); + } + + RDictionaryWriteStream out; + out.AssignLC( *store, aModuleUid ); + + // restore previous ids to store + for ( TInt i = 0; i < previousIds.Count(); i++ ) + { + out.WriteInt32L( previousIds[i] ); + } + + // write new ids to store + for ( TInt i = 0; i < aEntryIds.Count(); i++ ) + { + out.WriteInt32L( aEntryIds[i] ); + } + + out.CommitL(); + CleanupStack::PopAndDestroy( &out ); + + store->CommitL(); + CleanupStack::PopAndDestroy( &previousIds ); + CleanupStack::PopAndDestroy( store ); + } + +// --------------------------------------------------------------------------- +void CCreatorEngine::ReadEntryIdsFromStoreL( RArray& aEntryIds, const TUid aModuleUid ) + { + LOGSTRING("Creator: CCreatorEngine::ReadEntryIdsFromStoreL"); + CDictionaryFileStore* store = FileStoreLC(); + User::LeaveIfNull( store ); + if ( store->IsPresentL( aModuleUid ) ) + { + RDictionaryReadStream in; + in.OpenLC( *store, aModuleUid ); + TFileName fullPath; + TInt err( KErrNone ); + TUint32 id( KErrNone ); + while ( !err ) + { + TRAP( err, id = in.ReadUint32L() ); // will leave with KErrEof + if ( !err ) + { + aEntryIds.AppendL( id ); + } + } + CleanupStack::PopAndDestroy( &in ); + } + CleanupStack::PopAndDestroy( store ); + } + +// --------------------------------------------------------------------------- +void CCreatorEngine::WriteEntryIdsToStoreL( RArray& aEntryIds, const TUid aModuleUid ) + { + LOGSTRING("Creator: CCreatorEngine::WriteEntryIdsToStoreL"); + CDictionaryFileStore* store = FileStoreLC(); + User::LeaveIfNull( store ); + + // backup previous ids from store + // otherwise they would be overwritten when calling out.WriteL + RArray previousIds; + CleanupClosePushL( previousIds ); + + if ( store->IsPresentL( aModuleUid ) ) + { + RDictionaryReadStream in; + in.OpenLC( *store, aModuleUid ); + TInt err( KErrNone ); + TUint32 id( KErrNone ); + while ( !err ) + { + TRAP( err, id = in.ReadUint32L() ); // will leave with KErrEof + if ( !err ) + { + previousIds.AppendL( id ); + } + } + CleanupStack::PopAndDestroy( &in ); + } + + RDictionaryWriteStream out; + out.AssignLC( *store, aModuleUid ); + + // restore previous ids to store + for ( TInt i = 0; i < previousIds.Count(); i++ ) + { + out.WriteUint32L( previousIds[i] ); + } + + // write new ids to store + for ( TInt i = 0; i < aEntryIds.Count(); i++ ) + { + out.WriteUint32L( aEntryIds[i] ); + } + + out.CommitL(); + CleanupStack::PopAndDestroy( &out ); + + store->CommitL(); + CleanupStack::PopAndDestroy( &previousIds ); + CleanupStack::PopAndDestroy( store ); + } + +// --------------------------------------------------------------------------- +void CCreatorEngine::RemoveStoreL( const TUid aModuleUid ) + { + LOGSTRING("Creator: CCreatorEngine::RemoveStoreL"); + CDictionaryFileStore* store = FileStoreLC(); + User::LeaveIfNull( store ); + if ( store->IsPresentL( aModuleUid ) ) + { + // entries of this module should be deleted by now, + // remove the Creator internal registry for this module + store->Remove( aModuleUid ); + store->CommitL(); + } + CleanupStack::PopAndDestroy( store ); + } + +//---------------------------------------------------------------------------- +void CCreatorEngine::GenerateSourceImageFileL( + const CCreatorEngine::TTestDataPath aFileType, + const TDesC& aFileName ) + { + LOGSTRING("Creator: CCreatorEngine::GenerateSourceImageFileL"); + + // Peek file size + RFile file; + TInt fileSize( 0 ); + // Using png file as the source file + TFileName fileName = TestDataPathL( CCreatorEngine::EPNG_15kB ); + User::LeaveIfError( file.Open( iEnv->FsSession(), + fileName, + EFileRead | EFileShareAny ) ); + CleanupClosePushL( file ); + User::LeaveIfError( file.Size( fileSize ) ); + CleanupStack::PopAndDestroy( &file ); + + // Using heap variables, because bitmaps + // may reserve large amount of memory. + + // Read data from the file + RFileReadStream ws; + User::LeaveIfError( ws.Open( iEnv->FsSession(), + fileName, + EFileStream | EFileRead | EFileShareAny ) ); + CleanupClosePushL( ws ); + delete iBitmapData; + iBitmapData = NULL; + iBitmapData = HBufC8::NewL( fileSize ); + TPtr8 dataPtr = iBitmapData->Des(); + ws.ReadL( dataPtr, fileSize ); + CleanupStack::PopAndDestroy( &ws ); + + // Create decoder for the data + delete iDecoder; + iDecoder = NULL; + iDecoder = CImageDecoder::DataNewL( iEnv->FsSession(), dataPtr ); + iFrameinfo = iDecoder->FrameInfo(); + + // Create bitmap handle for the source image + iBitmap = new (ELeave) CFbsBitmap(); + User::LeaveIfError( iBitmap->Create( iFrameinfo.iFrameCoordsInPixels.Size(), EColor16M ) ); + + // Convert the data from the file into bitmap format (inmemory) + CAsyncWaiter* waiter = CAsyncWaiter::NewLC(); + iDecoder->Convert( &waiter->iStatus, *iBitmap ); + waiter->StartAndWait(); + delete iDecoder; + iDecoder = NULL; + delete iBitmapData; + iBitmapData = NULL; + if ( iUserCancelled ) + { + CancelComplete(); + User::Leave( KErrCancel ); + } + User::LeaveIfError( waiter->Result() ); + + // Define the target dimensions and image quality + // so that the generated file size will match required size. + // Quality and scaling factors are defined experimentally. + delete iScaler; + iScaler = NULL; + iScaler = CBitmapScaler::NewL(); + iScaledBitmap = new (ELeave) CFbsBitmap(); + // use original size as base + TSize scaledSize( iFrameinfo.iFrameCoordsInPixels.Size() ); + delete iFrameImageData; + iFrameImageData = NULL; + iFrameImageData = CFrameImageData::NewL(); + TBuf8<64> mimeType; + TJpegImageData* jpegImageData( NULL ); + TBmpImageData* bmpImageData( NULL ); + switch ( aFileType ) + { + case CCreatorEngine::EJPEG_25kB: + // QualityFactor = 93 and size factor = 2 -> 25kB jpeg file + mimeType.Copy( _L8("image/jpeg") ); + jpegImageData = new (ELeave) TJpegImageData; + // Set some format specific data + jpegImageData->iSampleScheme = TJpegImageData::EColor444; + jpegImageData->iQualityFactor = 93; // 0..100 + // ownership passed to iFrameImageData after AppendImageData + User::LeaveIfError( iFrameImageData->AppendImageData( jpegImageData ) ); + scaledSize.iHeight *= 2; + scaledSize.iWidth *= 2; + break; + case CCreatorEngine::EJPEG_200kB: + { + mimeType.Copy( _L8("image/jpeg") ); + jpegImageData = new (ELeave) TJpegImageData; + // Set some format specific data + jpegImageData->iSampleScheme = TJpegImageData::EColor444; +#ifdef __WINS__ + // QualityFactor = 95 and size factor = 7 -> 196kB jpeg file + jpegImageData->iQualityFactor = 95; // 0..100 + scaledSize.iHeight *= 7; + scaledSize.iWidth *= 7; +#else + // In hw the image compression seems to work + // more efficiently. Need to set greater values. + jpegImageData->iQualityFactor = 100; // 0..100 + scaledSize.iHeight *= 7; + scaledSize.iWidth *= 7; + // 100, 7, 7 -> 213kB +#endif + // ownership passed to iFrameImageData after AppendImageData + User::LeaveIfError( iFrameImageData->AppendImageData( jpegImageData ) ); + break; + } + case CCreatorEngine::EJPEG_500kB: + { + mimeType.Copy( _L8("image/jpeg") ); + jpegImageData = new (ELeave) TJpegImageData; + // Set some format specific data + jpegImageData->iSampleScheme = TJpegImageData::EColor444; +#ifdef __WINS__ + // QualityFactor = 99 and size factor = 8 -> 514kB jpeg file + jpegImageData->iQualityFactor = 99; // 0..100 + scaledSize.iHeight *= 8; + scaledSize.iWidth *= 8; +#else + // In hw the image compression seems to work + // more efficiently. Need to set greater values. + jpegImageData->iQualityFactor = 100; // 0..100 + scaledSize.iHeight *= 13; + scaledSize.iWidth *= 13; + // 100, 13, 13 -> 535kB +#endif + // ownership passed to iFrameImageData after AppendImageData + User::LeaveIfError( iFrameImageData->AppendImageData( jpegImageData ) ); + break; + } + case CCreatorEngine::EBMP_25kB: + { + // bit depyh 8 and 11/10 size factor -> 25kB bmp + mimeType.Copy( _L8("image/bmp") ); + bmpImageData = new (ELeave) TBmpImageData; + bmpImageData->iBitsPerPixel = 8; + // ownership passed to iFrameImageData after AppendImageData + User::LeaveIfError( iFrameImageData->AppendImageData( bmpImageData ) ); + scaledSize.iHeight *= 11; + scaledSize.iWidth *= 11; + scaledSize.iHeight /= 10; + scaledSize.iWidth /= 10; + break; + } + case CCreatorEngine::EGIF_2kB: + { + // size factor 1/2 -> 2560B gif + mimeType.Copy( _L8("image/gif") ); + // GIF encoder is not configurable, only the size matters here + scaledSize.iHeight /= 2; + scaledSize.iWidth /= 2; + break; + } + default: break; + } + + // Scale to reach target size + User::LeaveIfError( iScaledBitmap->Create( scaledSize, EColor16M ) ); + iScaler->Scale( &waiter->iStatus, *iBitmap, *iScaledBitmap ); + waiter->StartAndWait(); + delete iBitmap; + iBitmap = NULL; + delete iScaler; + iScaler = NULL; + if ( iUserCancelled ) + { + CancelComplete(); + User::Leave( KErrCancel ); + } + User::LeaveIfError( waiter->Result() ); + + // Encode to target format + delete iEncoder; + iEncoder = NULL; + // Creating CImageEncoder opens the target file + iEncoder = CImageEncoder::FileNewL( iEnv->FsSession(), aFileName, mimeType ); + + // Do the conversion to target format, this will write to the file + iEncoder->Convert( &waiter->iStatus, *iScaledBitmap, iFrameImageData ); + waiter->StartAndWait(); + delete iEncoder; + iEncoder = NULL; + delete iFrameImageData; + iFrameImageData = NULL; + delete iScaledBitmap; + iScaledBitmap = NULL; + if ( iUserCancelled ) + { + CancelComplete(); + User::Leave( KErrCancel ); + } + User::LeaveIfError( waiter->Result() ); + CleanupStack::PopAndDestroy( waiter ); + } + +//---------------------------------------------------------------------------- +void CCreatorEngine::GenereteSourceTextFileL( const TDesC& aFileName, TInt aSize ) + { + LOGSTRING("Creator: CCreatorEngine::GenereteSourceTextFileL"); + RFile txtFile; + _LIT8( KTestContent, "Testing... "); + _LIT8( KTestContentCRLF, "\r\n"); + txtFile.Create( iEnv->FsSession(), + aFileName, + EFileStreamText | EFileWrite | EFileShareAny ); + CleanupClosePushL( txtFile ); + for ( TInt i = 1; i*KTestContent().Length() < aSize; i++ ) + { + User::LeaveIfError( txtFile.Write( KTestContent ) ); + if ( !( i % 10 ) ) // linefeed for every 10th + { + User::LeaveIfError( txtFile.Write( KTestContentCRLF ) ); + } + } + CleanupStack::PopAndDestroy( &txtFile ); + } + +//---------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/src/enginewrapper.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/src/enginewrapper.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,377 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include +#include +#include + +#include +#include + +#include +#include + +#include "creator.hrh" // for command ids +#include "notifications.h" +#include "enginewrapper.h" +#include "engine.h" +#include "mainview.h" + + + +// --------------------------------------------------------------------------- + +EngineWrapper::EngineWrapper() +: iEngine(0), iProgressDialog(0) +{ +} + +// --------------------------------------------------------------------------- + +EngineWrapper::~EngineWrapper() +{ + if (iEngine != 0) { + delete iEngine; + iEngine = NULL; + } + if (iProgressDialog != 0) { + delete iProgressDialog; + iProgressDialog = NULL; + } +} + +// --------------------------------------------------------------------------- + +bool EngineWrapper::init() +{ + TRAPD(err, iEngine = CCreatorEngine::NewL(this)); + if(err != KErrNone) { + return false; + } + else { + return true; + } +} + +// --------------------------------------------------------------------------- + +QList EngineWrapper::GetMemoryDetailsList() + { + RPointerArray tMemDetList = iEngine->GetMemoryDetailsList(); + QList memDetList; + MemoryDetails memDet; + for(int i=0; iiFree.Ptr(), temp->iFree.Length() ); + QString size = QString::fromUtf16( temp->iSize.Ptr(), temp->iSize.Length() ); + QChar drive(temp->iDriveLetter.GetUpperCase()); + memDet.mFree = free; //QString((QChar*)tMemDetList[i]->iFree.Ptr(), tMemDetList[i]->iFree.Length()); + memDet.mSize = size; //QString((QChar*) tMemDetList[i]->iSize.Ptr(), tMemDetList[i]->iSize.Length()); + memDet.mDriveLetter = QString(drive); + + //memDetList[i].mDriveLetter = QString::fromUtf8( (char *) &tMemDetList[i]->iDriveLetter, (int) sizeof( char ) ); + memDetList.append( memDet ); + } + return memDetList; + } + +MemoryDetails EngineWrapper::GetMemoryDetails() +{ + + TMemoryDetails tMemoryDetails = iEngine->GetMemoryDetails(); + MemoryDetails memoryDetails; + + // Convert TMemoryDetails to MemoryDetails + memoryDetails.mRamFree = QString::fromUtf16( tMemoryDetails.iRamFree.Ptr(), tMemoryDetails.iRamFree.Length() ); + memoryDetails.mRamSize = QString::fromUtf16( tMemoryDetails.iRamSize.Ptr(), tMemoryDetails.iRamSize.Length() ); + + return memoryDetails; +} + + +// --------------------------------------------------------------------------- + +void EngineWrapper::ShowErrorMessage(const TDesC& aErrorMessage) +{ + QString errorMessage((QChar*)aErrorMessage.Ptr(),aErrorMessage.Length()); + Notifications::error(errorMessage); + +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::ShowNote(const TDesC& aNoteMessage, TInt /*aResourceId*/) +{ + QString note((QChar*)aNoteMessage.Ptr(),aNoteMessage.Length()); + Notifications::showGlobalNote(note, HbMessageBox::MessageTypeInformation, 1000); +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::ShowProgressBar(const TDesC& aPrompt, int aMax) +{ + QString text((QChar*)aPrompt.Ptr(), aPrompt.Length()); + CloseProgressbar(); + iProgressDialog = Notifications::showProgressBar(text, aMax); + connect(iProgressDialog, SIGNAL(cancelled()), this, SLOT(ProgressDialogCancelled())); +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::IncrementProgressbarValue() +{ + if(iProgressDialog) + iProgressDialog->setProgressValue(iProgressDialog->progressValue() + 1); +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::CloseProgressbar() +{ + if(iProgressDialog){ + disconnect(iProgressDialog, SIGNAL(cancelled()), this, SLOT(ProgressDialogCancelled())); + delete iProgressDialog; + iProgressDialog = NULL; + } +} + +// --------------------------------------------------------------------------- + +TBool EngineWrapper::EntriesQueryDialog(TInt* aNumberOfEntries, const TDesC& aPrompt, TBool aAcceptsZero, MUIObserver* observer, int userData) + { + QString text((QChar*)aPrompt.Ptr(), aPrompt.Length()); + TBool success(EFalse); + try{ + CreatorInputDialog::launch(text, aNumberOfEntries, aAcceptsZero ? true : false, observer, userData); + success = ETrue; + } + catch (std::exception& e) + { + Notifications::error( QString("exception: ")+e.what() ); + } + return success; + } + +// --------------------------------------------------------------------------- + +TBool EngineWrapper::TimeQueryDialog(TTime* aTime, const TDesC& aPrompt, MUIObserver* observer, int userData) + { + QString text((QChar*)aPrompt.Ptr(), aPrompt.Length()); + TBool success(EFalse); + try{ + CreatorDateTimeDialog::launch(text, aTime, observer, userData); + success = ETrue; + } + catch (std::exception& e) + { + Notifications::error( QString("exception: ")+e.what() ); + } + return success; + } + +TBool EngineWrapper::YesNoQueryDialog(const TDesC& aPrompt, MUIObserver* observer, int userData) +{ + QString text((QChar*)aPrompt.Ptr(), aPrompt.Length()); + TBool success(EFalse); + try{ + CreatorYesNoDialog::launch(text, "", observer, userData); + success = ETrue; + } + catch (std::exception& e) + { + Notifications::error( QString("exception: ")+e.what() ); + } + return success; +} + +// --------------------------------------------------------------------------- + +bool EngineWrapper::ExecuteOptionsMenuCommand(int commandId) +{ + TInt err = KErrNone; + if (commandId == ECmdCreateFromFile) { + TRAP(err, iEngine->RunScriptL()); + } + else if (commandId == ECmdSelectRandomDataFile) { + TBool ret = EFalse; + TRAP(err, ret = iEngine->GetRandomDataL()); + if ( err != KErrNone || ret == EFalse ) { + Notifications::error("Error in getting random data."); + return false; + } + } + else { + TRAP(err, iEngine->ExecuteOptionsMenuCommandL(commandId)); + } + // error handling + if(err != KErrNone) { + return false; + } + else { + return true; + } +} + +// --------------------------------------------------------------------------- + +TBool EngineWrapper::PopupListDialog(const TDesC& aPrompt, const CDesCArray* aFileNameArray, TInt* aIndex, MUIObserver* aObserver, TInt aUserData) +{ + QString text((QChar*)aPrompt.Ptr(), aPrompt.Length()); + QStringList itemList; + + for (int i = 0; i < aFileNameArray->Count(); i++) { + itemList.append(QString::fromUtf16( + aFileNameArray->MdcaPoint(i).Ptr(), + aFileNameArray->MdcaPoint(i).Length())); + } + TBool success(EFalse); + try{ + CreatorSelectionDialog::launch(text, itemList, aIndex, aObserver, aUserData); + success = ETrue; + } + catch (std::exception& e) + { + Notifications::error( QString("exception: ")+e.what() ); + } + return success; +} + +// --------------------------------------------------------------------------- + +TBool EngineWrapper::DirectoryQueryDialog(const TDesC& aPrompt, TDes& aDirectory, MUIObserver* aObserver, TInt aUserData) +{ + QString text((QChar*)aPrompt.Ptr(), aPrompt.Length()); + TBool success(EFalse); + try{ + CreatorInputDialog::launch(text, aDirectory, aObserver, aUserData); + success = ETrue; + } + catch (std::exception& e) + { + Notifications::error( QString("exception: ")+e.what() ); + } + return success; +} + + +// --------------------------------------------------------------------------- + +void EngineWrapper::ProgressDialogCancelled() +{ + TRAPD(err, iEngine->ProgressDialogCancelledL()); + // error handling + if(err != KErrNone) { + Notifications::error("Error in operation cancel."); + } + // disconnect & delete iProgressDialog to free memory + disconnect(iProgressDialog, SIGNAL(cancelled()), this, SLOT(ProgressDialogCancelled())); + iProgressDialog->deleteLater(); + iProgressDialog = NULL; +} + +// --------------------------------------------------------------------------- + +TBool EngineWrapper::ListQueryDialog(const TDesC& aPrompt, TListQueryId aId, TInt* aIndex, MUIObserver* aObserver, TInt aUserData) +{ + bool ret = false; + QString text((QChar*)aPrompt.Ptr(), aPrompt.Length()); + QStringList itemList; + + switch (aId) { + case R_CONTACT_CREATION_TYPE_QUERY: { + itemList << "Default fields" << "Define..."; + break; + } + case R_GROUP_CREATION_TYPE_QUERY: { + itemList << "Random" << "Define..."; + break; + } + case R_MESSAGE_TYPE_QUERY: { + itemList << "SMS" << "MMS" << "AMS" << "Email" << "Smart Message" << "IR Message" << "BT Message"; + break; + } + case R_FOLDER_TYPE_QUERY: { + itemList << "Inbox" << "Drafts" << "Outbox" << "Sent"; + break; + } + case R_UNREAD_QUERY: { + itemList << "Read" << "New"; + break; + } + case R_ATTACHMENT_MULTI_SELECTION_QUERY: { + Notifications::error("Not supported resource id."); + break; + } + case R_AMS_ATTACHMENT_SINGLE_SELECTION_QUERY: { + itemList << "AMR 20kB"; + break; + } + case R_ATTACHMENT_SINGLE_SELECTION_QUERY: { + itemList << "JPEG 25kB" << "JPEG 300kB" << "JPEG 500kB" << "PNG 15kB" << "GIF 2kB" << "RNG 1kB" + << "MIDI 10kB" << "WAVE 20kB" << "AMR 20kB" << "Excel 15kB" << "Word 20kB" << "PowerPoint 40kB" + << "Text 10kB" << "Text 70kB" << "3GPP 70kB" << "MP3 250kB" << "AAC 100kB" << "RM 95kB"; + break; + } + default: { + Notifications::error("Error in resource id."); + return ret; + } + } + TBool success(EFalse); + try{ + CreatorSelectionDialog::launch(text, itemList, aIndex, aObserver, aUserData); + success = ETrue; + } + catch (std::exception& e) + { + Notifications::error( QString("exception: ")+e.what() ); + } + return success; +} + +TBool EngineWrapper::ListQueryDialog(const TDesC& aPrompt, TListQueryId aId, CArrayFixFlat* aSelectedItems, MUIObserver* aObserver, TInt aUserData) +{ + TBool success(EFalse); + QStringList itemList; + QString text((QChar*)aPrompt.Ptr(), aPrompt.Length()); + if (aId == R_ATTACHMENT_MULTI_SELECTION_QUERY) { + itemList << "None" << "JPEG 25kB" << "JPEG 300kB" << "JPEG 500kB" << "PNG 15kB" << "GIF 2kB" << "RNG 1kB" + << "MIDI 10kB" << "WAVE 20kB" << "AMR 20kB" << "Excel 15kB" << "Word 20kB" << "PowerPoint 40kB" + << "Text 10kB" << "Text 70kB" << "3GPP 70kB" << "MP3 250kB" << "AAC 100kB" << "RM 95kB"; + } + else{ + Notifications::error("Error in resource id."); + return EFalse; + } + + try{ + CreatorSelectionDialog::launch(text, itemList, aSelectedItems, aObserver, aUserData); + success = ETrue; + } + catch (std::exception& e) + { + Notifications::error( QString("exception: ")+e.what() ); + } + return success; +} + +void EngineWrapper::CloseCreatorApp() +{ + MainView::closeApp(); +} diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/src/main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/src/main.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include +#include +#include + +#include "mainview.h" +#include "enginewrapper.h" + +int main(int argc, char *argv[]) +{ + + + + HbApplication app(argc, argv); + HbMainWindow mainWindow; + + //Create main view + MainView* view = new MainView(mainWindow); + + //initialize main view + view->init(app); + + // Add View to main window and reveal it. + mainWindow.addView(view); + mainWindow.show(); + + int result = app.exec(); + + return result; +} + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/src/mainview.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/src/mainview.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,659 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "notifications.h" +#include "enginewrapper.h" +#include "mainview.h" +#include "hbtoolbar.h" +#include "creator.hrh" // for command ids + +// --------------------------------------------------------------------------- + +MainView::MainView(HbMainWindow &mainWindow): + mMainWindow(mainWindow) +{ +} + +// --------------------------------------------------------------------------- + +MainView::~MainView() +{ + delete mSm; +} + +// --------------------------------------------------------------------------- + +void MainView::init(HbApplication &app) +{ + mEngineWrapper.init(); + this->setTitle("Creator"); + createMenu(app); + createMemoryInfoText(); +} + +void MainView::createMenu(HbApplication& app) +{ + HbMenu* menu = this->menu(); + + // signal mapper for identifying the different command actions + // in executeCommand() handler function: + mSm = new QSignalMapper(this); + connect(mSm, SIGNAL(mapped(int)), this, SLOT(executeMenuCommand(int))); + + if (menu != NULL) { + + // Run script menu item: + mActionRunScript = menu->addAction("Run script"); + connect(mActionRunScript, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionRunScript, ECmdCreateFromFile); + + // Calendar sub-menu items: + HbMenu* calendarSubMenu = new HbMenu("Calendar"); + menu->addMenu(calendarSubMenu); + mActionCalendarAppointments = calendarSubMenu->addAction("Appointments"); + mActionCalendarEvents = calendarSubMenu->addAction("Events"); + mActionCalendarAnniversaries = calendarSubMenu->addAction("Anniversaries"); + mActionCalendarTodos = calendarSubMenu->addAction("Todos"); + mActionCalendarReminders = calendarSubMenu->addAction("Reminders"); + + connect(mActionCalendarAppointments, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionCalendarAppointments, ECmdCreateCalendarEntryAppointments); + + connect(mActionCalendarEvents, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionCalendarEvents, ECmdCreateCalendarEntryEvents); + + connect(mActionCalendarAnniversaries, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionCalendarAnniversaries, ECmdCreateCalendarEntryAnniversaries); + + connect(mActionCalendarTodos, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionCalendarTodos, ECmdCreateCalendarEntryToDos); + + connect(mActionCalendarReminders, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionCalendarReminders, ECmdCreateCalendarEntryReminders); +/* + // Browser sub-menu items: + HbMenu* browserSubMenu = new HbMenu("Browser"); + menu->addMenu(browserSubMenu); + mActionBrowserBookmark = browserSubMenu->addAction("Bookmarks"); + mActionBrowserBmarkFolder = browserSubMenu->addAction("Bookmark folders"); + mActionBrowserSavedPages = browserSubMenu->addAction("Saved pages"); + mActionBrowserSavedPageFolders = browserSubMenu->addAction("Saved page folders"); + + connect(mActionBrowserBookmark, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionBrowserBookmark, ECmdCreateBrowserBookmarkEntries); + + connect(mActionBrowserBmarkFolder, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionBrowserBmarkFolder, ECmdCreateBrowserBookmarkFolderEntries); + + connect(mActionBrowserSavedPages, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionBrowserSavedPages, ECmdCreateBrowserSavedPageEntries); + + connect(mActionBrowserSavedPageFolders, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionBrowserSavedPageFolders, ECmdCreateBrowserSavedPageFolderEntries); +*/ + // Files sub-menu items: + HbMenu* filesSubMenu = new HbMenu("Files"); + menu->addMenu(filesSubMenu); + + mActionFilesEmptyFolder = filesSubMenu->addAction("Empty folder"); + + connect(mActionFilesEmptyFolder, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionFilesEmptyFolder, ECmdCreateFileEntryEmptyFolder); + + mActionFilesJpeg25 = filesSubMenu->addAction("JPEG 25kB"); + connect(mActionFilesJpeg25, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionFilesJpeg25, ECmdCreateFileEntryJPEG_25kB); + + mActionFilesJpeg200 = filesSubMenu->addAction("JPEG 200kB"); + connect(mActionFilesJpeg200, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionFilesJpeg200, ECmdCreateFileEntryJPEG_200kB); + + mActionFilesJpeg500 = filesSubMenu->addAction("JPEG 500kB"); + connect(mActionFilesJpeg500, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionFilesJpeg500, ECmdCreateFileEntryJPEG_500kB); + + mActionFilesPng15 = filesSubMenu->addAction("PNG 15kB"); + connect(mActionFilesPng15, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionFilesPng15, ECmdCreateFileEntryPNG_15kB); + + mActionFilesGif2 = filesSubMenu->addAction("GIF 2kB"); + connect(mActionFilesGif2, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionFilesGif2, ECmdCreateFileEntryGIF_2kB); + + mActionFilesBmp25 = filesSubMenu->addAction("BMP 25kB"); + connect(mActionFilesBmp25, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionFilesBmp25, ECmdCreateFileEntryBMP_25kB); + + mActionFilesJp265 = filesSubMenu->addAction("JP2 65kB"); + connect(mActionFilesJp265, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionFilesJp265, ECmdCreateFileEntryJP2_65kB); + + mActionFilesSvg15 = filesSubMenu->addAction("SVG 15kB"); + connect(mActionFilesSvg15, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionFilesSvg15, ECmdCreateFileEntrySVG_15kB); + + mActionFilesTif25 = filesSubMenu->addAction("TIF 25kB"); + connect(mActionFilesTif25, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionFilesTif25, ECmdCreateFileEntryTIF_25kB); + + mActionFilesRng1 = filesSubMenu->addAction("RNG 1kB"); + connect(mActionFilesRng1, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionFilesRng1, ECmdCreateFileEntryRNG_1kB); + + mActionFilesMidi10 = filesSubMenu->addAction("MIDI 10kB"); + connect(mActionFilesMidi10, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionFilesMidi10, ECmdCreateFileEntryMIDI_10kB); + + mActionFilesWave20 = filesSubMenu->addAction("WAVE 20kB"); + connect(mActionFilesWave20, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionFilesWave20, ECmdCreateFileEntryWAV_20kB); + + mActionFilesAmr20 = filesSubMenu->addAction("AMR 20kB"); + connect(mActionFilesAmr20, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionFilesAmr20, ECmdCreateFileEntryAMR_20kB); + + mActionFilesExcel15 = filesSubMenu->addAction("Excel 15kB"); + connect(mActionFilesExcel15, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionFilesExcel15, ECmdCreateFileEntryXLS_15kB); + + mActionFilesWord20 = filesSubMenu->addAction("Word 20kB"); + connect(mActionFilesWord20, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionFilesWord20, ECmdCreateFileEntryDOC_20kB); + + mActionFilesPPoint40 = filesSubMenu->addAction("PowerPoint 40kB"); + connect(mActionFilesPPoint40, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionFilesPPoint40, ECmdCreateFileEntryPPT_40kB); + + mActionFilesText10 = filesSubMenu->addAction("Text 10kB"); + connect(mActionFilesText10, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionFilesText10, ECmdCreateFileEntryTXT_10kB); + + mActionFilesText70 = filesSubMenu->addAction("Text 70kB"); + connect(mActionFilesText70, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionFilesText70, ECmdCreateFileEntryTXT_70kB); + + mActionFilesHtml20 = filesSubMenu->addAction("HTML 20kB"); + connect(mActionFilesHtml20, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionFilesHtml20, ECmdCreateFileEntryHTML_20kB); + + mActionFilesMxmf40 = filesSubMenu->addAction("MXMF 40kB"); + connect(mActionFilesMxmf40, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionFilesMxmf40, ECmdCreateFileEntryMXMF_40kB); + + mActionFilesRam1 = filesSubMenu->addAction("RAM 1kB"); + connect(mActionFilesRam1, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionFilesRam1, ECmdCreateFileEntryRAM_1kB); + + mActionFilesJad1 = filesSubMenu->addAction("JAD 1kB"); + connect(mActionFilesJad1, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionFilesJad1, ECmdCreateFileEntryJAD_1kB); + + mActionFilesJar10 = filesSubMenu->addAction("JAR 10kB"); + connect(mActionFilesJar10, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionFilesJar10, ECmdCreateFileEntryJAR_10kB); + + mActionFilesVcf1 = filesSubMenu->addAction("VCF 1kB"); + connect(mActionFilesVcf1, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionFilesVcf1, ECmdCreateFileEntryVCF_1kB); + + mActionFilesVcs1 = filesSubMenu->addAction("VCS 1kB"); + connect(mActionFilesVcs1, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionFilesVcs1, ECmdCreateFileEntryVCS_1kB); + + mActionFilesSisx10 = filesSubMenu->addAction("SISX 10kB"); + connect(mActionFilesSisx10, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionFilesSisx10, ECmdCreateFileEntrySISX_10kB); + + mActionFiles3Gpp70 = filesSubMenu->addAction("3GPP 70kB"); + connect(mActionFiles3Gpp70, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionFiles3Gpp70, ECmdCreateFileEntry3GPP_70kB); + + mActionFilesMp3250 = filesSubMenu->addAction("MP3 250kB"); + connect(mActionFilesMp3250, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionFilesMp3250, ECmdCreateFileEntryMP3_250kB); + + mActionFilesAAC100 = filesSubMenu->addAction("AAC 100kB"); + connect(mActionFilesAAC100, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionFilesAAC100, ECmdCreateFileEntryAAC_100kB); + + mActionFilesSwf15 = filesSubMenu->addAction("SWF 15kB"); + connect(mActionFilesSwf15, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionFilesSwf15, ECmdCreateFileEntrySWF_15kB); + + mActionFilesMp4200 = filesSubMenu->addAction("MP4 200kB"); + connect(mActionFilesMp4200, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionFilesMp4200, ECmdCreateFileEntryMP4_200kB); + + mActionFilesRm95 = filesSubMenu->addAction("RM 95kB"); + connect(mActionFilesRm95, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionFilesRm95, ECmdCreateFileEntryRM_95kB); + + mActionFilesWma50 = filesSubMenu->addAction("WMA 50kB"); + connect(mActionFilesWma50, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionFilesWma50, ECmdCreateFileEntryWMA_50kB); + + mActionFilesWmv200 = filesSubMenu->addAction("WMV 200kB"); + connect(mActionFilesWmv200, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionFilesWmv200, ECmdCreateFileEntryWMV_200kB); + + // Logs sub-menu items: + HbMenu* logsSubMenu = new HbMenu("Logs"); + menu->addMenu(logsSubMenu); + + mActionLogsMissedCalls = logsSubMenu->addAction("Missed calls"); + connect(mActionLogsMissedCalls, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionLogsMissedCalls, ECmdCreateLogEntryMissedCalls); + + mActionLogsReceivedCalls = logsSubMenu->addAction("Received calls"); + connect(mActionLogsReceivedCalls, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionLogsReceivedCalls, ECmdCreateLogEntryReceivedCalls); + + mActionLogsDialledNumbers = logsSubMenu->addAction("Dialled numbers"); + connect(mActionLogsDialledNumbers, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionLogsDialledNumbers, ECmdCreateLogEntryDialledNumbers); + + // Messaging sub-menu items: + HbMenu* messageSubMenu = new HbMenu("Messaging"); + menu->addMenu(messageSubMenu); + + mActionMessageMailboxes = messageSubMenu->addAction("Mailboxes"); + connect(mActionMessageMailboxes, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionMessageMailboxes, ECmdCreateMessagingEntryMailboxes); + + mActionMessages = messageSubMenu->addAction("Messages"); + connect(mActionMessages, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionMessages, ECmdCreateMessagingEntryMessages); + + // Misc sub-menu items: + HbMenu* miscSubMenu = new HbMenu("Misc"); + menu->addMenu(miscSubMenu); + + //mActionMiscConnection = miscSubMenu->addAction("Connection methods"); + //mActionMiscImps = miscSubMenu->addAction("IMPS servers"); + mActionMiscNotes = miscSubMenu->addAction("Notes"); + //mActionMiscLandmarks = miscSubMenu->addAction("Landmarks"); +/* + connect(mActionMiscConnection, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionMiscConnection, ECmdCreateMiscEntryAccessPoints); + + connect(mActionMiscImps, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionMiscImps, ECmdCreateMiscEntryIMPSServers); +*/ + connect(mActionMiscNotes, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionMiscNotes, ECmdCreateMiscEntryNotes); +/* + connect(mActionMiscLandmarks, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionMiscLandmarks, ECmdCreateMiscEntryLandmarks); +*/ + // Phonebook sub-menu items: + HbMenu* phonebookSubMenu = new HbMenu("Phonebook"); + menu->addMenu(phonebookSubMenu); + + mActionPhonebookContacts = phonebookSubMenu->addAction("Contacts"); + connect(mActionPhonebookContacts, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionPhonebookContacts, ECmdCreatePhoneBookEntryContacts); + + mActionPhonebookGroups = phonebookSubMenu->addAction("Groups"); + connect(mActionPhonebookGroups, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionPhonebookGroups, ECmdCreatePhoneBookEntryGroups); + + // Delete sub-menu items: + HbMenu* deleteSubMenu = new HbMenu("Delete"); + menu->addMenu(deleteSubMenu); + + HbMenu* deleteAllSubMenu = new HbMenu("All items"); + deleteSubMenu->addMenu(deleteAllSubMenu); + + mActionDeleteAllItems = deleteAllSubMenu->addAction("All"); + connect(mActionDeleteAllItems, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionDeleteAllItems, ECmdDeleteAllEntries); + + mActionDeleteCreatorItems = deleteAllSubMenu->addAction("By Creator"); + connect(mActionDeleteCreatorItems, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionDeleteCreatorItems, ECmdDeleteAllCreatorEntries); + + HbMenu* deleteCalendarSubMenu = new HbMenu("Calendar entries"); + deleteSubMenu->addMenu(deleteCalendarSubMenu); + + mActionDeleteCalAllItems = deleteCalendarSubMenu->addAction("All"); + connect(mActionDeleteCalAllItems, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionDeleteCalAllItems, ECmdDeleteCalendarEntries); + + mActionDeleteCalCreatorItems = deleteCalendarSubMenu->addAction("By Creator"); + connect(mActionDeleteCalCreatorItems, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionDeleteCalCreatorItems, ECmdDeleteCreatorCalendarEntries); +/* + HbMenu* deleteBookmarksSubMenu = new HbMenu("Br bookmarks"); + deleteSubMenu->addMenu(deleteBookmarksSubMenu); + + mActionDeleteBookmarkAllItems = deleteBookmarksSubMenu->addAction("All"); + connect(mActionDeleteBookmarkAllItems, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionDeleteBookmarkAllItems, ECmdDeleteBrowserBookmarks); + + mActionDeleteBookmarkCreatorItems = deleteBookmarksSubMenu->addAction("By Creator"); + connect(mActionDeleteBookmarkCreatorItems, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionDeleteBookmarkCreatorItems, ECmdDeleteCreatorBrowserBookmarks); + + HbMenu* deleteBookmarkFoldersSubMenu = new HbMenu("Br bookmark folders"); + deleteSubMenu->addMenu(deleteBookmarkFoldersSubMenu); + + mActionDeleteBookmarkFolderAllItems = deleteBookmarkFoldersSubMenu->addAction("All"); + connect(mActionDeleteBookmarkFolderAllItems, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionDeleteBookmarkFolderAllItems, ECmdDeleteBrowserBookmarkFolders); + + mActionDeleteBookmarkFolderCreatorItems = deleteBookmarkFoldersSubMenu->addAction("By Creator"); + connect(mActionDeleteBookmarkFolderCreatorItems, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionDeleteBookmarkFolderCreatorItems, ECmdDeleteCreatorBrowserBookmarkFolders); + + HbMenu* deleteSavedPagesSubMenu = new HbMenu("Br saved pages"); + deleteSubMenu->addMenu(deleteSavedPagesSubMenu); + + mActionDeleteSavedPagesAllItems = deleteSavedPagesSubMenu->addAction("All"); + connect(mActionDeleteSavedPagesAllItems, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionDeleteSavedPagesAllItems, ECmdDeleteBrowserSavedPages); + + mActionDeleteSavedPagesCreatorItems = deleteSavedPagesSubMenu->addAction("By Creator"); + connect(mActionDeleteSavedPagesCreatorItems, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionDeleteSavedPagesCreatorItems, ECmdDeleteCreatorBrowserSavedPages); + + HbMenu* deleteSavedPagesFolderSubMenu = new HbMenu("Br saved page folders"); + deleteSubMenu->addMenu(deleteSavedPagesFolderSubMenu); + + mActionDeleteSavedPagesFolderAllItems = deleteSavedPagesFolderSubMenu->addAction("All"); + connect(mActionDeleteSavedPagesFolderAllItems, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionDeleteSavedPagesFolderAllItems, ECmdDeleteBrowserSavedPageFolders); + + mActionDeleteSavedPagesFolderCreatorItems = deleteSavedPagesFolderSubMenu->addAction("By Creator"); + connect(mActionDeleteSavedPagesFolderCreatorItems, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionDeleteSavedPagesFolderCreatorItems, ECmdDeleteCreatorBrowserSavedPageFolders); +*/ + HbMenu* deleteFilesSubMenu = new HbMenu("Files"); + deleteSubMenu->addMenu(deleteFilesSubMenu); + + mActionDeleteFiles = deleteFilesSubMenu->addAction("By Creator"); + connect(mActionDeleteFiles, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionDeleteFiles, ECmdDeleteCreatorFiles); + + HbMenu* deleteLogsSubMenu = new HbMenu("Logs"); + deleteSubMenu->addMenu(deleteLogsSubMenu); + + mActionDeleteLogsAll = deleteLogsSubMenu->addAction("All"); + connect(mActionDeleteLogsAll, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionDeleteLogsAll, ECmdDeleteLogs); + + mActionDeleteLogsByCreator = deleteLogsSubMenu->addAction("By Creator"); + connect(mActionDeleteLogsByCreator, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionDeleteLogsByCreator, ECmdDeleteCreatorLogs); + + HbMenu* deleteMessagesSubMenu = new HbMenu("Messages"); + deleteSubMenu->addMenu(deleteMessagesSubMenu); + + mActionDeleteMessagesAll = deleteMessagesSubMenu->addAction("All"); + connect(mActionDeleteMessagesAll, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionDeleteMessagesAll, ECmdDeleteMessages); + + mActionDeleteMessagesByCreator = deleteMessagesSubMenu->addAction("By Creator"); + connect(mActionDeleteMessagesByCreator, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionDeleteMessagesByCreator, ECmdDeleteCreatorMessages); +/* + HbMenu* deleteConnMethsSubMenu = new HbMenu("Connection methods"); + deleteSubMenu->addMenu(deleteConnMethsSubMenu); + + mActionDeleteConnMethsAll = deleteConnMethsSubMenu->addAction("All"); + connect(mActionDeleteConnMethsAll, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionDeleteConnMethsAll, ECmdDeleteMessages); + + mActionDeleteConnMethsByCreator = deleteConnMethsSubMenu->addAction("By Creator"); + connect(mActionDeleteConnMethsByCreator, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionDeleteConnMethsByCreator, ECmdDeleteCreatorMessages); + + HbMenu* deleteImpsSubMenu = new HbMenu("IMPS servers"); + deleteSubMenu->addMenu(deleteImpsSubMenu); + + mActionDeleteImpsAll = deleteImpsSubMenu->addAction("All"); + connect(mActionDeleteImpsAll, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionDeleteImpsAll, ECmdDeleteIMPSs); + + mActionDeleteImpsByCreator = deleteImpsSubMenu->addAction("By Creator"); + connect(mActionDeleteImpsByCreator, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionDeleteImpsByCreator, ECmdDeleteCreatorIMPSs); +*/ + HbMenu* deleteNotesSubMenu = new HbMenu("Notes"); + deleteSubMenu->addMenu(deleteNotesSubMenu); + + mActionDeleteNotes = deleteNotesSubMenu->addAction("All"); + connect(mActionDeleteNotes, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionDeleteNotes, ECmdDeleteNotes); +/* + HbMenu* deleteLandmarksSubMenu = new HbMenu("Landmarks"); + deleteSubMenu->addMenu(deleteLandmarksSubMenu); + + mActionDeleteLandmarksAll = deleteLandmarksSubMenu->addAction("All"); + connect(mActionDeleteLandmarksAll, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionDeleteLandmarksAll, ECmdDeleteLandmarks); + + mActionDeleteLandmarksByCreator = deleteLandmarksSubMenu->addAction("By Creator"); + connect(mActionDeleteLandmarksByCreator, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionDeleteLandmarksByCreator, ECmdDeleteCreatorLandmarks); +*/ + HbMenu* deleteContactsSubMenu = new HbMenu("Contacts"); + deleteSubMenu->addMenu(deleteContactsSubMenu); + + mActionDeleteContactsAll = deleteContactsSubMenu->addAction("All"); + connect(mActionDeleteContactsAll, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionDeleteContactsAll, ECmdDeleteContacts); + + mActionDeleteContactsByCreator = deleteContactsSubMenu->addAction("By Creator"); + connect(mActionDeleteContactsByCreator, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionDeleteContactsByCreator, ECmdDeleteCreatorContacts); + + HbMenu* deleteContactGroupsSubMenu = new HbMenu("Contact groups"); + deleteSubMenu->addMenu(deleteContactGroupsSubMenu); + + mActionDeleteContactGroupsAll = deleteContactGroupsSubMenu->addAction("All"); + connect(mActionDeleteContactGroupsAll, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionDeleteContactGroupsAll, ECmdDeleteContactGroups); + + mActionDeleteContactGroupsByCreator = deleteContactGroupsSubMenu->addAction("By Creator"); + connect(mActionDeleteContactGroupsByCreator, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionDeleteContactGroupsByCreator, ECmdDeleteCreatorContactGroups); +/* + // select random data file: + mActionSelectRandomFile = menu->addAction("Select random data file"); + connect(mActionSelectRandomFile, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mActionSelectRandomFile, ECmdSelectRandomDataFile); +*/ + // About & exit menu items: + mActionAbout = menu->addAction("About Creator"); + connect(mActionAbout, SIGNAL( triggered() ), this, SLOT( showAboutPopup() ) ); + + mActionExit = menu->addAction("Exit"); + connect(mActionExit, SIGNAL(triggered()), &app, SLOT( quit() ) ); + + this->setMenu(menu); + } +} + +// --------------------------------------------------------------------------- + +void MainView::createMemoryInfoText() +{ + QGraphicsLinearLayout* layout = new QGraphicsLinearLayout(Qt::Vertical, this); + + // get memory details from engine; + mMemoryDetails = mEngineWrapper.GetMemoryDetails(); + + QList memDet = mEngineWrapper.GetMemoryDetailsList(); + + if (layout != NULL) + { + HbLabel* edit = new HbLabel(this); + //HbTextEdit* edit = new HbTextEdit(this); + if(edit != NULL) + { + QString text = QString("

    Free RAM Memory:
    %1 of %2 kB").arg(mMemoryDetails.mRamFree).arg(mMemoryDetails.mRamSize); + //QString text = QString("\n\nFree RAM Memory:\n %1 of %2 kB").arg(mMemoryDetails.mRamFree).arg(mMemoryDetails.mRamSize); + for(int i=0 ; i < memDet.count() ; i++ ) + { + text += QString("

    Free %1: Memory:
    %2 of %3 kB").arg(memDet[i].mDriveLetter).arg(memDet[i].mFree).arg(memDet[i].mSize);//text += QString("\n\nFree %1: Memory:\n %2 of %3 kB").arg(memDet[i].mDriveLetter).arg(memDet[i].mFree).arg(memDet[i].mSize); + } + edit->setTextWrapping(Hb::TextWordWrap); + edit->setHtml(text); + //edit->setPlainText(text); + + //edit->setReadOnly(true); + //edit->setCursorHidden(true); + edit->setAttribute(Qt::WA_InputMethodEnabled, false); + layout->addItem(edit); + layout->setContentsMargins(5, 5, 5, 5); + this->setLayout(layout); + } + + } + +} + + +// --------------------------------------------------------------------------- + +void MainView::showAboutPopup() +{ + Notifications::about(); + +} + +// --------------------------------------------------------------------------- + +void MainView::executeMenuCommand(int cmd) +{ + switch (cmd) { + case ECmdCreateFromFile: + case ECmdCreateCalendarEntryAppointments: + case ECmdCreateCalendarEntryEvents: + case ECmdCreateCalendarEntryAnniversaries: + case ECmdCreateCalendarEntryToDos: + case ECmdCreateCalendarEntryReminders: + case ECmdCreateBrowserBookmarkEntries: + case ECmdCreateBrowserBookmarkFolderEntries: + case ECmdCreateBrowserSavedPageEntries: + case ECmdCreateBrowserSavedPageFolderEntries: + case ECmdCreateFileEntryEmptyFolder: + case ECmdCreateFileEntry3GPP_70kB: + case ECmdCreateFileEntryAAC_100kB: + case ECmdCreateFileEntryAMR_20kB: + case ECmdCreateFileEntryBMP_25kB: + case ECmdCreateFileEntryDeck_1kB: + case ECmdCreateFileEntryDOC_20kB: + case ECmdCreateFileEntryGIF_2kB: + case ECmdCreateFileEntryHTML_20kB: + case ECmdCreateFileEntryJAD_1kB: + case ECmdCreateFileEntryJAR_10kB: + case ECmdCreateFileEntryJP2_65kB: + case ECmdCreateFileEntryJPEG_200kB: + case ECmdCreateFileEntryJPEG_25kB: + case ECmdCreateFileEntryJPEG_500kB: + case ECmdCreateFileEntryMIDI_10kB: + case ECmdCreateFileEntryMP3_250kB: + case ECmdCreateFileEntryMP4_200kB: + case ECmdCreateFileEntryMXMF_40kB: + case ECmdCreateFileEntryPNG_15kB: + case ECmdCreateFileEntryPPT_40kB: + case ECmdCreateFileEntryRAM_1kB: + case ECmdCreateFileEntryRM_95kB: + case ECmdCreateFileEntryRNG_1kB: + case ECmdCreateFileEntrySVG_15kB: + case ECmdCreateFileEntrySWF_15kB: + case ECmdCreateFileEntryTIF_25kB: + case ECmdCreateFileEntryTXT_10kB: + case ECmdCreateFileEntryTXT_70kB: + case ECmdCreateFileEntryVCF_1kB: + case ECmdCreateFileEntryVCS_1kB: + case ECmdCreateFileEntryWAV_20kB: + case ECmdCreateFileEntryXLS_15kB: + case ECmdCreateFileEntrySISX_10kB: + case ECmdCreateFileEntryWMA_50kB: + case ECmdCreateFileEntryWMV_200kB: + case ECmdCreateLogEntryMissedCalls: + case ECmdCreateLogEntryReceivedCalls: + case ECmdCreateLogEntryDialledNumbers: + case ECmdCreateMessagingEntryMailboxes: + case ECmdCreateMessagingEntryMessages: + case ECmdCreateMiscEntryAccessPoints: + case ECmdCreateMiscEntryIMPSServers: + case ECmdCreateMiscEntryNotes: + case ECmdCreateMiscEntryLandmarks: + case ECmdCreatePhoneBookEntryContacts: + case ECmdCreatePhoneBookEntryGroups: + case ECmdDeleteAllEntries: + case ECmdDeleteAllCreatorEntries: + case ECmdDeleteContacts: + case ECmdDeleteCreatorContacts: + case ECmdDeleteContactGroups: + case ECmdDeleteCreatorContactGroups: + case ECmdDeleteCalendarEntries: + case ECmdDeleteCreatorCalendarEntries: + case ECmdDeleteBrowserBookmarks: + case ECmdDeleteCreatorBrowserBookmarks: + case ECmdDeleteBrowserBookmarkFolders: + case ECmdDeleteCreatorBrowserBookmarkFolders: + case ECmdDeleteBrowserSavedPages: + case ECmdDeleteCreatorBrowserSavedPages: + case ECmdDeleteBrowserSavedPageFolders: + case ECmdDeleteCreatorBrowserSavedPageFolders: + case ECmdDeleteCreatorFiles: + case ECmdDeleteLogs: + case ECmdDeleteCreatorLogs: + case ECmdDeleteMessages: + case ECmdDeleteCreatorMessages: + case ECmdDeleteMailboxes: + case ECmdDeleteCreatorMailboxes: + case ECmdDeleteIAPs: + case ECmdDeleteCreatorIAPs: + case ECmdDeleteIMPSs: + case ECmdDeleteCreatorIMPSs: + case ECmdDeleteNotes: + case ECmdDeleteLandmarks: + case ECmdDeleteCreatorLandmarks: + case ECmdSelectRandomDataFile: { + mEngineWrapper.ExecuteOptionsMenuCommand(cmd); + break; + } + default: { + Notifications::error(QString("Unsupported command: %1").arg(cmd)); + break; + } + } +} + +void MainView::closeApp() +{ + qApp->quit(); +} + +// --------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/creator/src/notifications.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/creator/src/notifications.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,308 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "notifications.h" + +// --------------------------------------------------------------------------- + +void Notifications::showMessageBox(HbMessageBox::MessageBoxType type, const QString &text, const QString &label, int timeout ) +{ + HbMessageBox *messageBox = new HbMessageBox(type); + messageBox->setText(text); + messageBox->setStandardButtons( HbMessageBox::Ok ); + if(label.length()) + { + HbLabel *header = new HbLabel(label, messageBox); + messageBox->setHeadingWidget(header); + } + messageBox->setAttribute(Qt::WA_DeleteOnClose); + messageBox->setTimeout(timeout); + messageBox->open(); +} + +// --------------------------------------------------------------------------- + +void Notifications::about() +{ + showMessageBox(HbMessageBox::MessageTypeInformation, + "Version 6.1.2 - September 9th 2010. Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. Licensed under Eclipse Public License v1.0.", + "About Creator", + HbPopup::NoTimeout + ); +} + +// --------------------------------------------------------------------------- + +void Notifications::error(const QString& errorMessage) +{ + showMessageBox(HbMessageBox::MessageTypeWarning, errorMessage, QString("Error"), 3000); +} + + +// --------------------------------------------------------------------------- + +HbProgressDialog* Notifications::showProgressBar(const QString& text, int max) +{ + HbProgressDialog *note = new HbProgressDialog(HbProgressDialog::ProgressDialog); + note->setText(text); + note->setMaximum(max); + note->setAutoClose(false); + note->show(); + return note; + +} + +// --------------------------------------------------------------------------- + +void Notifications::showGlobalNote(const QString& text, HbMessageBox::MessageBoxType type, int timeout) +{ + showMessageBox(type, text, QString("Creator"), timeout); +} + + +// --------------------------------------------------------------------------- + +CreatorYesNoDialog::CreatorYesNoDialog(MUIObserver* observer, int userData) : + HbMessageBox(HbMessageBox::MessageTypeQuestion, NULL), + CreatorDialog(observer, userData) +{ +} + +void CreatorYesNoDialog::launch(const QString& text, const QString& label, MUIObserver* observer, int userData) throw(std::exception) +{ + CreatorYesNoDialog* dlg = new CreatorYesNoDialog(observer, userData); + dlg->setStandardButtons( HbMessageBox::Yes | HbMessageBox::No ); + dlg->setText(text); + if(label.length()) + dlg->setHeadingWidget(new HbLabel(label, dlg)); + dlg->setAttribute(Qt::WA_DeleteOnClose); + dlg->setTimeout(HbPopup::NoTimeout); + dlg->open(dlg, SLOT(DialogClosed(HbAction*))); +} + +void CreatorYesNoDialog::DialogClosed(HbAction *action) +{ + TBool PositiveAction(EFalse); + if(action && (action->softKeyRole()==QAction::PositiveSoftKey || !action->text().compare("yes", Qt::CaseInsensitive))){ + PositiveAction = ETrue; + } + NotifyObserver(PositiveAction); +} + +CreatorInputDialog::CreatorInputDialog(int* value, MUIObserver* module, int userData) : + HbInputDialog(NULL), + CreatorDialog(module, userData), + mIntValue(value), + mStrValue(mDummy)// will not be used +{ + if(!value) + throw std::invalid_argument("value cannot be the null!"); +} + +CreatorInputDialog::CreatorInputDialog(TDes& value, MUIObserver* module, int userData) : + HbInputDialog(NULL), + CreatorDialog(module, userData), + mIntValue(NULL), + mStrValue(value) +{ +} + +void CreatorInputDialog::launch(const QString& label, int* value, bool acceptsZero, MUIObserver* observer, int userData) throw( std::exception ) +{ + CreatorInputDialog* dlg = new CreatorInputDialog(value, observer, userData); + dlg->setPromptText(label); + dlg->setInputMode(IntInput); + HbValidator *validator = new HbValidator(dlg); + QString tmp; + if (acceptsZero == false) { + tmp.append("^[1-9]{1}\\d{0,4}"); + } + else { + tmp.append("^[0-9]{1,5}"); + } + + QRegExp rxBasic(tmp); + validator->addField(new QRegExpValidator(rxBasic, 0), ""); + dlg->setValidator(validator); + dlg->setValue(QVariant(*value)); + dlg->lineEdit()->setSelection(0, dlg->value().toString().length()); + dlg->setAttribute(Qt::WA_DeleteOnClose); + dlg->open(dlg, SLOT(DialogClosed(HbAction*))); +} + +void CreatorInputDialog::launch(const QString& label, TDes& value, MUIObserver* observer, int userData) throw( std::exception ) +{ + CreatorInputDialog* dlg = new CreatorInputDialog(value, observer, userData); + dlg->setPromptText(label); + dlg->lineEdit()->setMaxLength(value.MaxLength()); + dlg->setValue(QString::fromUtf16(value.Ptr(), value.Length())); + dlg->lineEdit()->setSelection(0, dlg->value().toString().length()); + dlg->setInputMode(TextInput); + dlg->setAttribute(Qt::WA_DeleteOnClose); + dlg->open(dlg, SLOT(DialogClosed(HbAction*))); +} + +void CreatorInputDialog::DialogClosed(HbAction *action) +{ + TBool PositiveAction(EFalse); + if(action && (action->softKeyRole()==QAction::PositiveSoftKey || !action->text().compare("ok", Qt::CaseInsensitive))){ + bool ok = true; + if( inputMode() == IntInput ) + *mIntValue = value().toInt(&ok); + else if( inputMode() == TextInput && mStrValue.MaxLength() >= value().toString().length() ) + mStrValue.Copy(value().toString().utf16()); + else + ok = false; + PositiveAction = ok ? ETrue : EFalse; + } + NotifyObserver(PositiveAction); +} + +CreatorSelectionDialog::CreatorSelectionDialog(int* selectedItem, MUIObserver* observer, int userData) throw(std::exception) : + HbSelectionDialog(NULL), + CreatorDialog(observer, userData), + mSelectedItem(selectedItem), + mSelectedItems(NULL) +{ + if(!mSelectedItem) + throw std::invalid_argument("selectedItem cannot be null!"); +} + +CreatorSelectionDialog::CreatorSelectionDialog(CArrayFixFlat* selectedItems, MUIObserver* observer, int userData) throw(std::exception) : + HbSelectionDialog(NULL), + CreatorDialog(observer, userData), + mSelectedItem(NULL), + mSelectedItems(selectedItems) +{ + if(!mSelectedItems) + throw std::invalid_argument("selectedItems cannot be null!"); +} + +void CreatorSelectionDialog::launch(const QString& label, const QStringList& items, int* selectedItem, MUIObserver* observer, int userData) throw(std::exception) +{ + CreatorSelectionDialog* dlg = new CreatorSelectionDialog(selectedItem, observer, userData); + if(label.length()) + dlg->setHeadingWidget(new HbLabel(label, dlg)); + dlg->setStringItems(items); + dlg->setSelectionMode(HbAbstractItemView::SingleSelection); + dlg->setSelectedItems(QList()); + dlg->setAttribute(Qt::WA_DeleteOnClose); + dlg->open(dlg, SLOT(DialogClosed(HbAction*))); +} + +void CreatorSelectionDialog::launch(const QString& label, const QStringList& items, CArrayFixFlat* selectedItems, MUIObserver* observer, int userData) throw(std::exception) +{ + CreatorSelectionDialog* dlg = new CreatorSelectionDialog(selectedItems, observer, userData); + if(label.length()) + dlg->setHeadingWidget(new HbLabel(label, dlg)); + dlg->setStringItems(items); + dlg->setSelectionMode(HbAbstractItemView::MultiSelection); + dlg->setAttribute(Qt::WA_DeleteOnClose); + dlg->open(dlg, SLOT(DialogClosed(HbAction*))); +} + +void CreatorSelectionDialog::DialogClosed(HbAction *action) +{ + TBool PositiveAction(EFalse); + //CreatorSelectionDialog* dlg = qobject_cast(sender()); + if(!action || (action && action->softKeyRole()==QAction::SelectSoftKey) || (action && !action->text().compare("ok", Qt::CaseInsensitive))){ + if(selectedItems().count()){ + try{ + if( selectionMode() == HbAbstractItemView::SingleSelection && mSelectedItem){ + bool ok(false); + *mSelectedItem = selectedItems().at(0).toInt(&ok); + if(!ok) + throw std::invalid_argument("cannot obtain selected item!"); + } + if( selectionMode() == HbAbstractItemView::MultiSelection && mSelectedItems){ + QList items = selectedItems(); + foreach( QVariant item, items){ + QT_TRAP_THROWING( mSelectedItems->AppendL( item.toInt() ) ); + } + } + PositiveAction = ETrue; + } + catch (std::exception& e){ + Notifications::error( QString("exception: ")+e.what() ); + } + } + } + NotifyObserver(PositiveAction); +} + +CreatorDateTimeDialog::CreatorDateTimeDialog(TTime* value, MUIObserver* observer, int userData) : + HbDialog(NULL), + CreatorDialog(observer, userData), + mValue(value) +{ +} + +void CreatorDateTimeDialog::launch(const QString& label, TTime* value, MUIObserver* observer, int userData) throw( std::exception ) +{ + CreatorDateTimeDialog* dlg = new CreatorDateTimeDialog(value, observer, userData); + if(!value) + throw std::invalid_argument("value cannot be the null!"); + if(label.length()) + dlg->setHeadingWidget( new HbLabel(label, dlg) ); + + // TTime to QDate + TBuf<20> timeString; + _LIT(KDateString,"%D%M%Y%/0%1%/1%2%/2%3%/3"); + TRAP_IGNORE( value->FormatL(timeString, KDateString) ); + QString temp = QString::fromUtf16(timeString.Ptr(), timeString.Length()); + temp.replace(QChar('/'), QChar('-')); + QDate date = QDate::fromString(temp, "dd-MM-yyyy"); + HbDateTimePicker* widget = new HbDateTimePicker( date, dlg ); + dlg->setContentWidget( widget ); + dlg->addAction(new HbAction("Ok", dlg)); + dlg->addAction(new HbAction("Cancel", dlg)); + dlg->setModal(true); // Dialog is modal + dlg->setAttribute(Qt::WA_DeleteOnClose); + dlg->setTimeout(HbPopup::NoTimeout); + dlg->open(dlg, SLOT(DialogClosed(HbAction*))); +} + +void CreatorDateTimeDialog::DialogClosed(HbAction *action) +{ + TBool PositiveAction(EFalse); + if(action && (action->softKeyRole()==QAction::PositiveSoftKey || !action->text().compare("ok", Qt::CaseInsensitive))){ + QString str = qobject_cast(contentWidget())->date().toString(Qt::ISODate); + str.remove('-'); + str += ":000000";// 0h 0m 0s + TBuf<30> dateTimeString(str.utf16()); + mValue->Set(dateTimeString); + PositiveAction = ETrue; + } + NotifyObserver(PositiveAction); +} +//End of File diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/engine/FB.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/engine/FB.hrh Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,294 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef FILEBROWSER_HRH +#define FILEBROWSER_HRH + +enum TFileBrowserCommandIds + { + EFileBrowserCmdFile = 1, + EFileBrowserCmdFileBack, + EFileBrowserCmdFileOpen, + EFileBrowserCmdFileOpenApparc, + EFileBrowserCmdFileOpenDocHandlerEmbed, + EFileBrowserCmdFileOpenDocHandlerStandAlone, + EFileBrowserCmdFileOpenFileService, + EFileBrowserCmdFileOpenDrive, + EFileBrowserCmdFileOpenDirectory, + EFileBrowserCmdFileView, + EFileBrowserCmdFileViewText, + EFileBrowserCmdFileViewHex, + EFileBrowserCmdFileEdit, + EFileBrowserCmdFileEditText, + EFileBrowserCmdFileEditHex, + EFileBrowserCmdFileSearch, + EFileBrowserCmdFileSendTo, + EFileBrowserCmdFileNew, + EFileBrowserCmdFileNewFile, + EFileBrowserCmdFileNewDirectory, + EFileBrowserCmdFileDelete, + EFileBrowserCmdFileRename, + EFileBrowserCmdFileTouch, + EFileBrowserCmdFileProperties, + EFileBrowserCmdFileChecksums, + EFileBrowserCmdFileChecksumsMD5, + EFileBrowserCmdFileChecksumsMD2, + EFileBrowserCmdFileChecksumsSHA1, + EFileBrowserCmdFileSetAttributes, + EFileBrowserCmdFileCompress, + EFileBrowserCmdFileDecompress, + EFileBrowserCmdEdit, + EFileBrowserCmdSnapShot, + EFileBrowserCmdEditCut, + EFileBrowserCmdEditCopy, + EFileBrowserCmdEditPaste, + EFileBrowserCmdEditCopyToFolder, + EFileBrowserCmdEditMoveToFolder, + EFileBrowserCmdEditSelect, + EFileBrowserCmdEditUnselect, + EFileBrowserCmdEditSelectAll, + EFileBrowserCmdEditUnselectAll, + EFileBrowserCmdView, + EFileBrowserCmdViewSort, + EFileBrowserCmdViewSortByName, + EFileBrowserCmdViewSortByExtension, + EFileBrowserCmdViewSortByDate, + EFileBrowserCmdViewSortBySize, + EFileBrowserCmdViewOrder, + EFileBrowserCmdViewOrderAscending, + EFileBrowserCmdViewOrderDescending, + EFileBrowserCmdViewFilterEntries, + EFileBrowserCmdViewRefresh, + EFileBrowserCmdDiskAdmin, + EFileBrowserCmdDiskAdminSetDrivePassword, + EFileBrowserCmdDiskAdminUnlockDrive, + EFileBrowserCmdDiskAdminClearDrivePassword, + EFileBrowserCmdDiskAdminEraseDrivePassword, + EFileBrowserCmdDiskAdminFormatDrive, + EFileBrowserCmdDiskAdminQuickFormatDrive, + EFileBrowserCmdDiskAdminCheckDisk, + EFileBrowserCmdDiskAdminScanDrive, + EFileBrowserCmdDiskAdminSetDriveName, + EFileBrowserCmdDiskAdminSetDriveVolumeLabel, + EFileBrowserCmdDiskAdminEraseMBR, + EFileBrowserCmdDiskAdminDrivePartition, + EFileBrowserCmdDiskAdminEjectDrive, + EFileBrowserCmdDiskAdminDismountFileSystem, + EFileBrowserCmdTools, + EFileBrowserCmdToolsAllFiles, + EFileBrowserCmdToolsAvkonIconCache, + EFileBrowserCmdToolsAvkonIconCacheEnable, + EFileBrowserCmdToolsAvkonIconCacheDisable, + EFileBrowserCmdToolsDisableExtErrors, + EFileBrowserCmdToolsEditDataTypes, + EFileBrowserCmdToolsEnableExtErrors, + EFileBrowserCmdToolsErrorSimulate, + EFileBrowserCmdToolsErrorSimulateLeave, + EFileBrowserCmdToolsErrorSimulatePanic, + EFileBrowserCmdToolsErrorSimulateException, + EFileBrowserCmdToolsLocalConnectivity, + EFileBrowserCmdToolsLocalConnectivityActivateInfrared, + EFileBrowserCmdToolsLocalConnectivityLaunchBTUI, + EFileBrowserCmdToolsLocalConnectivityLaunchUSBUI, + EFileBrowserCmdToolsInstalledApps, + EFileBrowserCmdToolsOpenFiles, + EFileBrowserCmdToolsMsgAttachments, + EFileBrowserCmdToolsMsgAttachmentsInbox, + EFileBrowserCmdToolsMsgAttachmentsDrafts, + EFileBrowserCmdToolsMsgAttachmentsSentItems, + EFileBrowserCmdToolsMsgAttachmentsOutbox, + EFileBrowserCmdToolsMsgStoreWalk, + EFileBrowserCmdToolsSecureBackup, + EFileBrowserCmdToolsSecureBackupStartBackup, + EFileBrowserCmdToolsSecureBackupStartRestore, + EFileBrowserCmdToolsSecureBackupStop, + EFileBrowserCmdToolsSetDebugMask, + EFileBrowserCmdToolsMemoryInfo, + EFileBrowserCmdSettings, + EFileBrowserCmdAbout, + EFileBrowserCmdSettingsChange, + EFileBrowserCmdSettingsExit, + EFileBrowserCmdSettingsBack, + EFileBrowserSettingItemList, + EFileBrowserCmdDataTypesChangeMapping, + EFileBrowserCmdDataTypesSetDefaultMapping, + EFileBrowserCmdDataTypesRefresh, + EFileBrowserCmdDataTypesExit, + EFileBrowserCmdDataTypesBack, + EFileBrowserDataTypesList, + EFileBrowserProgressNote, + EFileBrowserWaitNote, + EFileBrowserAttributeEditorSetArchive, + EFileBrowserAttributeEditorSetHidden, + EFileBrowserAttributeEditorSetReadOnly, + EFileBrowserAttributeEditorSetSystem, + EFileBrowserAttributeEditorSetRecurse, + EFileBrowserSearchQuerySearchDir, + EFileBrowserSearchQueryWildCards, + EFileBrowserSearchQueryTextInFile, + EFileBrowserSearchQueryMinSize, + EFileBrowserSearchQueryMaxSize, + EFileBrowserSearchQueryMinDate, + EFileBrowserSearchQueryMaxDate, + EFileBrowserSearchQueryRecurse, + EFileBrowserCmdFileEditorViewAsText, + EFileBrowserCmdFileEditorViewAsHex, + EFileBrowserCmdFileEditorSave, + EFileBrowserCmdFileEditorSaveAs, + EFileBrowserCmdFileEditorSaveFormat, + EFileBrowserCmdFileEditorSaveFormatANSIASCII, + EFileBrowserCmdFileEditorSaveFormatUTF8, + EFileBrowserCmdFileEditorSaveFormatUTF16LE, + EFileBrowserCmdFileEditorSaveFormatUTF16BE, + EFileBrowserCmdFileEditorEditAsText, + EFileBrowserCmdFileEditorEditAsHex, + EFileBrowserCmdFileEditorExit, + EFileBrowserFileOpCommandAttribs, + EFileBrowserFileOpCommandCopy, + EFileBrowserFileOpCommandMove, + EFileBrowserFileOpCommandRename, + EFileBrowserFileOpCommandDelete, + EFileBrowserFileOpCommandDriveSnapShot + }; + +enum TFileBrowserFixedIconIds + { + EFixedIconMarking = 0, + EFixedIconEmpty, + EFixedIconPhoneMemory, + EFixedIconMemoryCard, + EFixedIconMemoryCardDisabled, + EFixedIconFolder, + EFixedIconFolderSub, + EFixedIconFolderCurrent, + EFixedIconListLength // this should be last + }; + +enum TFileBrowserEntryOverwriteActions + { + EFileActionOverwriteAll = 0, + EFileActionSkipAllExisting, + EFileActionGenerateUniqueFilenames, + EFileActionQueryPostFix + }; + +enum TFileBrowserSecureBackupState + { + ESecureBackupStateFull = 0, + ESecureBackupStatePartial + }; + +enum TFileBrowserSecureBackupType + { + ESecureBackupTypeBase = 0, + ESecureBackupTypeIncremental + }; + +enum TFileBrowserDataTypePriorities + { + EDataTypePriorityMaximum = 0, + EDataTypePriorityHigh, + EDataTypePriorityNormal, + EDataTypePriorityLow, + EDataTypePriorityLastResort + }; + +enum TFileBrowserCommonFileActions + { + ECommonFileActionViewAsTextHex = 0, + ECommonFileActionOpenWithApparc, + ECommonFileActionOpenWithDocHandlerEmbed + }; + +enum TFileBrowserSettingListTabs + { + ETabGeneral = 0, + ETabFileOps + }; + +enum TFileBrowserSettingListIds + { + ESettingListDisplayModeSelection = 0, + ESettingListFileViewModeSelection, + ESettingListShowSubdirectoryInfoSelection, + ESettingListShowAssociatedIconsSelection, + ESettingListRememberLastPathSelection, + ESettingListRememberFolderSelection, + ESettingListEnableToolbar, + + ESettingListSupportNetworkDrivesSelection, + ESettingListBypassPlatformSecuritySelection, + ESettingListRemoveFileLocksSelection, + ESettingListIgnoreProtectionsAttsSelection, + ESettingListRemoveROMWriteProtectionSelection + }; + +enum TFileBrowserSettingDisplayModes + { + EDisplayModeFullScreen = 0, + EDisplayModeNormal + }; + +enum TFileBrowserSettingFileViewModes + { + EFileViewModeSimple = 0, + EFileViewModeExtended + }; + +enum TFileBrowserFileEditorModes + { + EFileEditorViewAsText = 0, + EFileEditorViewAsHex, + EFileEditorEditAsText, + EFileEditorEditAsHex + }; + +enum + { + EFileViewerDialogControl = 0x5FEC + }; + +enum + { + EFileEditorDialogId = 1 + }; + +enum TFileBrowserCmdFileChecksums + { + EFileChecksumsMD5 = 0, + EFileChecksumsMD2, + EFileChecksumsSHA1 + }; + +enum TListingMode + { + ENormalEntries = 0, + ESearchResults, + EOpenFiles, + EMsgAttachmentsInbox, + EMsgAttachmentsDrafts, + EMsgAttachmentsSentItems, + EMsgAttachmentsOutbox + }; + +enum TClipBoardMode + { + EClipBoardModeCut = 0, + EClipBoardModeCopy + }; + +#endif // FILEBROWSER_HRH diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/engine/FBFileOps.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/engine/FBFileOps.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,1164 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +// INCLUDE FILES +#include "FBFileOps.h" +#include "FBFileUtils.h" +#include "engine.h" +#include "FBTraces.h" + +#ifndef FILEBROWSER_LITE + #include "FBFileOpClient.h" +#endif + +#include +#include +#include +#include + +const TInt KSecureBackupStartDelay = 750000; +const TInt KSecureBackupLoopDelay = 100000; +const TInt KSecureBackupEndDelay = 200000; +const TInt KMaxFileLockAttempts = 3; + + +// ================= MEMBER FUNCTIONS ======================= + +CFileBrowserFileOps* CFileBrowserFileOps::NewL(CEngine* aEngine) + { + CFileBrowserFileOps* self = new(ELeave) CFileBrowserFileOps(aEngine); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +// -------------------------------------------------------------------------------------------- + +CFileBrowserFileOps::CFileBrowserFileOps(CEngine* aEngine) : iEngine(aEngine) + { + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileOps::ConstructL() + { + iRecursiveState = EFileOpInvalid; + iSecureBackUpActive = EFalse; + iFileCommandActivatedSecureBackup = EFalse; + + User::LeaveIfError(iFs.Connect()); + iFileMan = CFileMan::NewL( iFs, this ); + } + +// -------------------------------------------------------------------------------------------- + +CFileBrowserFileOps::~CFileBrowserFileOps() + { + if (iSBEClient) + delete iSBEClient; + + #ifndef FILEBROWSER_LITE + if (iFileOpClient) + delete iFileOpClient; + #endif + + delete iFileMan; + iFs.Close(); + } + +// -------------------------------------------------------------------------------------------- + +TInt CFileBrowserFileOps::ActivateSecureBackUpViaFileOp() + { + iFileManObserverResult = MFileManObserver::EContinue; + // if already activate by a file command, return ok + if (iFileCommandActivatedSecureBackup) + return KErrNone; + else + { + // if secure backup is already active, disable it first, because it may in wrong state + if (iSecureBackUpActive) + DeActivateSecureBackUp(); + } + + // try to activate full secure backup + TInt err = ActivateSecureBackUp(conn::EBURBackupFull, conn::EBackupBase); + + if (err == KErrNone) + iFileCommandActivatedSecureBackup = ETrue; + + return err; + } + +// -------------------------------------------------------------------------------------------- + +TInt CFileBrowserFileOps::DeActivateSecureBackUpViaFileOp() + { + TInt err(KErrGeneral); + iFileManObserverResult = MFileManObserver::EContinue; + + // if activate by a file command, try to reactivate it + if (iFileCommandActivatedSecureBackup) + { + err = DeActivateSecureBackUp(); + + // even if it fails, forget the state + iFileCommandActivatedSecureBackup = EFalse; + } + + return err; + } + +// -------------------------------------------------------------------------------------------- + +TInt CFileBrowserFileOps::ActivateSecureBackUp(conn::TBURPartType aPartType, conn::TBackupIncType aBackupIncType) + { + iFileManObserverResult = MFileManObserver::EContinue; + // check for invalid parameters + if (aPartType == conn::EBURNormal || aBackupIncType == conn::ENoBackup) + User::Panic(_L("Inv.Usage.SE"), 532); + + TInt err(KErrNone); + + if (!iSBEClient) + { + TRAP(err, iSBEClient = conn::CSBEClient::NewL()); + if (err != KErrNone) + return err; + } + + TDriveList driveList; + err = iFs.DriveList(driveList); + + if (err == KErrNone) + { + // make sure that the application has a system status to prevent getting shut down events + iEngine->EikonEnv()->SetSystem(ETrue); + + // activating secure back up removes locks from files which respect this fuctionality + TRAP(err, iSBEClient->SetBURModeL(driveList, aPartType, aBackupIncType)); + + if (err == KErrNone) + { + iSecureBackUpActive = ETrue; + User::After(KSecureBackupStartDelay); // a short delay to wait to activate + } + } + + return err; + } + +// -------------------------------------------------------------------------------------------- + +TInt CFileBrowserFileOps::DeActivateSecureBackUp() + { + TInt err(KErrNone); + + if (!iSBEClient) + { + TRAP(err, iSBEClient = conn::CSBEClient::NewL()); + if (err != KErrNone) + return err; + + // make sure that the application has a system status + iEngine->EikonEnv()->SetSystem(ETrue); + } + + TDriveList driveList; + err = iFs.DriveList(driveList); + + if (err == KErrNone) + { + // deactivate secure backup + TRAP(err, iSBEClient->SetBURModeL(driveList, conn::EBURNormal, conn::ENoBackup)); + + User::After(KSecureBackupEndDelay); // a short delay to wait to deactivate + + // system status not needed anymore + iEngine->EikonEnv()->SetSystem(EFalse); + } + + iSecureBackUpActive = EFalse; + + return err; + } + +// -------------------------------------------------------------------------------------------- + +TInt CFileBrowserFileOps::DoFindEntries(const TDesC& aFileName, const TDesC& aPath) + { + TFindFile fileFinder(iFs); + CDir* dir; + TInt err = fileFinder.FindWildByPath(aFileName, &aPath, dir); + + while (err == KErrNone && iFileManObserverResult != MFileManObserver::ECancel) + { + for (TInt i=0; iCount(); i++) + { + TEntry entry = (*dir)[i]; + + if (entry.iName.Length() && aPath.Length()) + { + // parse the entry + TParse parsedName; + parsedName.Set(entry.iName, &fileFinder.File(), NULL); + + if (parsedName.Drive().Length() && aPath.Length() && parsedName.Drive()[0] == aPath[0]) + { + // get full source path + TFileName fullSourcePath = parsedName.FullName(); + if (entry.IsDir()) + fullSourcePath.Append(_L("\\")); + + // call the file operation command + switch(iRecursiveState) + { + case EFileOpAttribs: + { + // the same attribs command can be given for both directories and files + FileOpAttribs(fullSourcePath, iUint1, iUint2, iTime1, iUint3); + } + break; + + case EFileOpCopy: + { + // calculate length of new entries added to the original source path + TUint newEntriesLength = fullSourcePath.Length() - iBuf1.Length(); + + // get pointer description to the rightmost data + TPtr16 newEntriesPtr = fullSourcePath.RightTPtr(newEntriesLength); + + // generate target path + TFileName fullTargetPath = iBuf2; + fullTargetPath.Append(newEntriesPtr); + + if (entry.IsDir()) + { + // if it is a directory entry, just create it based on the entry's attributes + FileOpMkDirAll(fullTargetPath, entry.iAtt); + } + else + { + // ensure that root target folder exists + BaflUtils::EnsurePathExistsL(iFs, iBuf2); + // otherwise copy the file + FileOpCopy(fullSourcePath, fullTargetPath, iUint1); + } + } + break; + + case EFileOpDelete: + { + if (entry.IsDir()) + { + // for directories call rmdir + FileOpRmDir(fullSourcePath, iUint1); + } + else + { + // for files call the normal file deletion operation + FileOpDeleteFile(fullSourcePath, iUint1); + } + } + break; + + default: + User::Panic (_L("FileOpRecurs"), 775); + break; + } + } + } + if ( iFileManObserverResult == MFileManObserver::ECancel ) break; + } + + delete dir; + dir = NULL; + if ( iFileManObserverResult != MFileManObserver::ECancel ) + { + err = fileFinder.FindWild(dir); + } + } + + return err; + } + +// -------------------------------------------------------------------------------------------- + +TInt CFileBrowserFileOps::DoFindEntriesRecursiveL(const TDesC& aFileName, const TDesC& aPath) + { + TInt err(KErrNone); + + // it is logical to scan upwards when deleting and changing attributes + CDirScan::TScanDirection scanDirection = CDirScan::EScanUpTree; + + // when copying files, it is more logical to move downwards + if (iRecursiveState == EFileOpCopy) + scanDirection = CDirScan::EScanDownTree; + + + CDirScan* scan = CDirScan::NewLC(iFs); + scan->SetScanDataL(aPath, KEntryAttDir|KEntryAttMatchMask, ESortByName | EAscending | EDirsFirst, scanDirection); + CDir* dir = NULL; + + for(;;) + { + TRAP(err, scan->NextL(dir)); + if (!dir || (err != KErrNone)) + break; + + for (TInt i=0; iCount(); i++) + { + TEntry entry = (*dir)[i]; + + if (entry.IsDir()) + { + TFileName path(scan->FullPath()); + + if (path.Length()) + { + path.Append(entry.iName); + path.Append(_L("\\")); + // test path.Left(iBuf2.Length()).Compare(iBuf2) - to prevent never ending recursive copy (in case of copy folder under itself) + if( !(iRecursiveState == EFileOpCopy && !path.Left(iBuf2.Length()).Compare(iBuf2)) ) + { + DoFindEntries(aFileName, path); + } + } + } + if ( iFileManObserverResult == MFileManObserver::ECancel ) + { + break; + } + } + delete(dir); + if ( iFileManObserverResult == MFileManObserver::ECancel ) + { + break; + } + } + + CleanupStack::PopAndDestroy(scan); + return err; + } + +// -------------------------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------- + +TInt CFileBrowserFileOps::Copy(const TFileEntry& aSourceEntry, const TDesC& aTargetFullName, TUint aSwitch, TBool aDeleteSource) + { + iOperationError = KErrNone; + iFileManObserverResult = MFileManObserver::EContinue; + + TFileName sourcePath = aSourceEntry.iPath; + sourcePath.Append(aSourceEntry.iEntry.iName); + + TInt err(KErrNone); + + if (aSourceEntry.iEntry.IsDir() && (aSwitch & CFileMan::ERecurse)) + { + // find all files recursively and run the operation for them + iRecursiveState = EFileOpCopy; + sourcePath.Append(_L("\\")); + + TFileName targetPath = aTargetFullName; + targetPath.Append(_L("\\")); + + // remove the recursion flag because we will implement our own recursion + TUint newSwitch(aSwitch); + newSwitch &= ~CFileMan::ERecurse; + + iBuf1.Copy(sourcePath); + iBuf2.Copy(targetPath); + iUint1 = newSwitch; + + TRAP(err, DoFindEntries(_L("*"), sourcePath)); // entries under current directory entry + if ( iFileManObserverResult != MFileManObserver::ECancel ) + { + TRAP(err, DoFindEntriesRecursiveL(_L("*"), sourcePath)); // recursively under directories of current directory entry + } + // ensure that target folder exists in case of copying empty folder + BaflUtils::EnsurePathExistsL(iFs, targetPath); + // a path has a trailing backslash so it needs to be removed before the call + err = FileOpAttribs(targetPath.Left(targetPath.Length()-1), aSourceEntry.iEntry.iAtt, 0, 0, 0); + } + + else if (aSourceEntry.iEntry.IsDir()) + { + TFileName targetPath = aTargetFullName; + targetPath.Append(_L("\\")); + + // just create a directory based on the file attributes of the source directory + err = FileOpMkDirAll(targetPath, aSourceEntry.iEntry.iAtt); + } + + else + { + // remove a recursion flag if present (this should never happen, but some extra error checking) + if (aSwitch & CFileMan::ERecurse) + aSwitch &= ~CFileMan::ERecurse; + + // do the operation for a file entry + err = FileOpCopy(sourcePath, aTargetFullName, aSwitch); + } + + + // delete source if needed and copy succeeded without any errors (== move operation) + if ( aDeleteSource && iOperationError == KErrNone && + iFileManObserverResult != MFileManObserver::ECancel ) + { + err = Delete(aSourceEntry, aSwitch); + } + + if ( !iOperationError && iFileManObserverResult == MFileManObserver::ECancel ) + { + iOperationError = KErrCancel; + } + + return iOperationError; + } + +// -------------------------------------------------------------------------------------------- + +TInt CFileBrowserFileOps::FileOpCopy(const TDesC& aSourceFullName, const TDesC& aTargetFullName, TUint aSwitch) + { + TInt err = DoFileOpCopy(aSourceFullName, aTargetFullName, aSwitch); + + // if locked, unlock the file and retry + if (iEngine->Settings().iRemoveFileLocks && err == KErrInUse) + { + // try to remove the file lock by activating secure backup mode + if (ActivateSecureBackUpViaFileOp() == KErrNone) + { + // try the operation several times + for (TInt i=0; iSettings().iIgnoreProtectionsAtts && err == KErrAccessDenied && BaflUtils::FileExists(iFs, aTargetFullName)) + { + if (FileOpDeleteFile(aTargetFullName, 0) == KErrNone) + { + err = DoFileOpCopy(aSourceFullName, aTargetFullName, aSwitch); + } + } + + // if the file already exists, it is not an error + if (err == KErrAlreadyExists) + err = KErrNone; + + + // if copying from a ROM drive, remove the writing protection flag + if (iEngine->Settings().iRemoveROMWriteProrection && err == KErrNone && aSourceFullName.Length() > 3 && (aSourceFullName[0]=='z' || aSourceFullName[0]=='Z')) + { + FileOpAttribs(aTargetFullName, 0, KEntryAttReadOnly, 0, 0); + } + + + // remember the "lowest" error + if (err < iOperationError) + iOperationError = err; + + LOGSTRING4("FileBrowser: FileOpCopy %S -> %S, err=%d", &aSourceFullName, &aTargetFullName, err); + + return err; + } + +// -------------------------------------------------------------------------------------------- + +TInt CFileBrowserFileOps::DoFileOpCopy(const TDesC& aSourceFullName, const TDesC& aTargetFullName, TUint aSwitch) + { + #ifndef FILEBROWSER_LITE + if (iEngine->Settings().iBypassPlatformSecurity) + { + if (!iFileOpClient) + iFileOpClient = CFBFileOpClient::NewL(); + + return iFileOpClient->Copy(aSourceFullName, aTargetFullName, aSwitch); + } + else + { + #endif + //CAsyncWaiter* waiter = CAsyncWaiter::NewLC(); + //TInt result = iFileMan->Copy( aSourceFullName, aTargetFullName, aSwitch, waiter->iStatus ); + //waiter->StartAndWait(); + //if ( !result ) result = waiter->Result(); + //CleanupStack::PopAndDestroy( waiter ); + TInt result = iFileMan->Copy( aSourceFullName, aTargetFullName, aSwitch ); + return result; + #ifndef FILEBROWSER_LITE + } + #endif + } + +// -------------------------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------- + +TInt CFileBrowserFileOps::Rename(const TFileEntry& aSourceEntry, const TDesC& aNew, TUint aSwitch) + { + iOperationError = KErrNone; + iFileManObserverResult = MFileManObserver::EContinue; + + TFileName sourcePath = aSourceEntry.iPath; + sourcePath.Append(aSourceEntry.iEntry.iName); + + if (aSourceEntry.iEntry.IsDir()) + { + // do the operation for a directory entry + FileOpRename(sourcePath, aNew, aSwitch); + } + else + { + // do the operation for a file + FileOpRename(sourcePath, aNew, aSwitch); + } + + return iOperationError; + } + +// -------------------------------------------------------------------------------------------- + +TInt CFileBrowserFileOps::FileOpRename(const TDesC& aName, const TDesC& aNew, TUint aSwitch) + { + TBool setBackROFlag(EFalse); + + TInt err = DoFileOpRename(aName, aNew, aSwitch); + + // if locked, unlock the file and retry + if (iEngine->Settings().iRemoveFileLocks && err == KErrInUse) + { + // try to remove the file lock by activating secure backup mode + if (ActivateSecureBackUpViaFileOp() == KErrNone) + { + // try the operation several times + for (TInt i=0; iSettings().iIgnoreProtectionsAtts && err == KErrAccessDenied) + { + // remove write protection and try again + if (FileOpAttribs(aName, 0, KEntryAttReadOnly, 0, 0) == KErrNone) + { + err = DoFileOpRename(aName, aNew, aSwitch); + + setBackROFlag = ETrue; + } + } + + // if still access denied, then try to remove the target path and try again + if (iEngine->Settings().iIgnoreProtectionsAtts && err == KErrAccessDenied && BaflUtils::FileExists(iFs, aNew)) + { + if (FileOpDeleteFile(aNew, 0) == KErrNone) + { + err = DoFileOpRename(aName, aNew, aSwitch); + } + } + + // set back the read only flag + if (setBackROFlag) + FileOpAttribs(aName, KEntryAttReadOnly, 0, 0, 0); + + + // remember the "lowest" error + if (err < iOperationError) + iOperationError = err; + + LOGSTRING3("FileBrowser: FileOpRename %S, err=%d", &aName, err); + + return err; + } + +// -------------------------------------------------------------------------------------------- + +TInt CFileBrowserFileOps::DoFileOpRename(const TDesC& aName, const TDesC& aNew, TUint aSwitch) + { + #ifndef FILEBROWSER_LITE + if (iEngine->Settings().iBypassPlatformSecurity) + { + if (!iFileOpClient) + iFileOpClient = CFBFileOpClient::NewL(); + + return iFileOpClient->Rename(aName, aNew, aSwitch); + } + else + { + #endif + return iFileMan->Rename(aName, aNew, aSwitch); + #ifndef FILEBROWSER_LITE + } + #endif + } + +// -------------------------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------- + +TInt CFileBrowserFileOps::Attribs(const TFileEntry& aSourceEntry, TUint aSetMask, TUint aClearMask, const TTime& aTime, TUint aSwitch) + { + iOperationError = KErrNone; + iFileManObserverResult = MFileManObserver::EContinue; + + TFileName sourcePath = aSourceEntry.iPath; + sourcePath.Append(aSourceEntry.iEntry.iName); + + TInt err(KErrNone); + + if (aSourceEntry.iEntry.IsDir() && (aSwitch & CFileMan::ERecurse)) + { + // do the operation for a current directory entry + err = FileOpAttribs(sourcePath, aSetMask, aClearMask, aTime, 0); + + // find all files recursively and run the operation for them + iRecursiveState = EFileOpAttribs; + sourcePath.Append(_L("\\")); + + iBuf1.Copy(sourcePath); + iUint1 = aSetMask; + iUint2 = aClearMask; + iTime1 = aTime; + iUint3 = 0; + + TRAP(err, DoFindEntriesRecursiveL(_L("*"), sourcePath)); // recursively under directories of current directory entry + TRAP(err, DoFindEntries(_L("*"), sourcePath)); // entries under current directory entry + } + + else if (aSourceEntry.iEntry.IsDir()) + { + //sourcePath.Append(_L("\\")); // <-- do not apply! + + // do the operation for a directory entry + err = FileOpAttribs(sourcePath, aSetMask, aClearMask, aTime, 0); + } + + else + { + // do the operation for a file entry + err = FileOpAttribs(sourcePath, aSetMask, aClearMask, aTime, 0); + } + + return iOperationError; + } + +// -------------------------------------------------------------------------------------------- + +TInt CFileBrowserFileOps::FileOpAttribs(const TDesC& aName, TUint aSetMask, TUint aClearMask, const TTime& aTime, TUint aSwitch) + { + TInt err = DoFileOpAttribs(aName, aSetMask, aClearMask, aTime, aSwitch); + + // if locked, unlock the file and retry + if (iEngine->Settings().iRemoveFileLocks && err == KErrInUse) + { + // try to remove the file lock by activating secure backup mode + if (ActivateSecureBackUpViaFileOp() == KErrNone) + { + // try the operation several times + for (TInt i=0; iSettings().iBypassPlatformSecurity) + { + if (!iFileOpClient) + iFileOpClient = CFBFileOpClient::NewL(); + + return iFileOpClient->Attribs(aName, aSetMask, aClearMask, aTime, aSwitch); + } + else + { + #endif + return iFileMan->Attribs(aName, aSetMask, aClearMask, aTime, aSwitch); + #ifndef FILEBROWSER_LITE + } + #endif + } + +// -------------------------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------- + +TInt CFileBrowserFileOps::Delete(const TFileEntry& aSourceEntry, TUint aSwitch) + { + iOperationError = KErrNone; + iFileManObserverResult = MFileManObserver::EContinue; + + TFileName sourcePath = aSourceEntry.iPath; + sourcePath.Append(aSourceEntry.iEntry.iName); + + TInt err(KErrNone); + + if (aSourceEntry.iEntry.IsDir() && (aSwitch & CFileMan::ERecurse)) + { + // find all files recursively and run the operation for them + iRecursiveState = EFileOpDelete; + sourcePath.Append(_L("\\")); + + iBuf1.Copy(sourcePath); + iUint1 = 0; + + TRAP(err, DoFindEntriesRecursiveL(_L("*"), sourcePath)); // recursively under directories of current directory entry + if ( iFileManObserverResult != MFileManObserver::ECancel ) + { + TRAP(err, DoFindEntries(_L("*"), sourcePath)); // entries under current directory entry + } + + if ( iFileManObserverResult != MFileManObserver::ECancel ) + { + // do the operation for a current directory entry as well + err = FileOpRmDir(sourcePath, 0); + } + } + + else if (aSourceEntry.iEntry.IsDir()) + { + sourcePath.Append(_L("\\")); + + // do the operation for a directory entry + err = FileOpRmDir(sourcePath, 0); + } + + else + { + // do the operation for a file entry + err = FileOpDeleteFile(sourcePath, 0); + } + if ( !iOperationError && iFileManObserverResult == MFileManObserver::ECancel ) + { + iOperationError = KErrCancel; + } + return iOperationError; + } + +// -------------------------------------------------------------------------------------------- + +TInt CFileBrowserFileOps::FileOpDeleteFile(const TDesC& aName, TUint aSwitch) + { + TInt err = DoFileOpDeleteFile(aName, aSwitch); + + // if locked, unlock the file and retry + if (iEngine->Settings().iRemoveFileLocks && err == KErrInUse) + { + // try to remove the file lock by activating secure backup mode + if (ActivateSecureBackUpViaFileOp() == KErrNone) + { + // try the operation several times + for (TInt i=0; iSettings().iIgnoreProtectionsAtts && (err == KErrAccessDenied || err == KErrNotFound)) + { + // remove protections and try again + if (FileOpAttribs(aName, 0, KEntryAttReadOnly|KEntryAttSystem|KEntryAttHidden, 0, 0) == KErrNone) + { + err = DoFileOpDeleteFile(aName, aSwitch); + } + } + + // remember the "lowest" error + if (err < iOperationError) + iOperationError = err; + + LOGSTRING3("FileBrowser: FileOpDeleteFile %S, err=%d", &aName, err); + + return err; + } + +// -------------------------------------------------------------------------------------------- + +TInt CFileBrowserFileOps::DoFileOpDeleteFile(const TDesC& aName, TUint aSwitch) + { + #ifndef FILEBROWSER_LITE + if (iEngine->Settings().iBypassPlatformSecurity) + { + if (!iFileOpClient) + iFileOpClient = CFBFileOpClient::NewL(); + + return iFileOpClient->Delete(aName, aSwitch); + } + else + { + #endif +// CAsyncWaiter* waiter = CAsyncWaiter::NewLC(); +// TInt result = iFileMan->Delete( aName, aSwitch, waiter->iStatus ); +// waiter->StartAndWait(); +// if ( iFileManObserverResult == MFileManObserver::ECancel ) result = KErrCancel; +// if ( !result ) result = waiter->Result(); +// CleanupStack::PopAndDestroy( waiter ); + TInt result = iFileMan->Delete( aName, aSwitch ); + return result; + #ifndef FILEBROWSER_LITE + } + #endif + } + +// -------------------------------------------------------------------------------------------- + +TInt CFileBrowserFileOps::FileOpRmDir(const TDesC& aName, TUint aSwitch) + { + TInt err = DoFileOpRmDir(aName, aSwitch); + + // if write protected or system directory, remove protections and retry + if (iEngine->Settings().iIgnoreProtectionsAtts && (err == KErrAccessDenied || err == KErrInUse)) + { + // remove protections and try again + if (FileOpAttribs(aName.Left(aName.Length()-1), 0, KEntryAttReadOnly|KEntryAttSystem|KEntryAttHidden, 0, 0) == KErrNone) + { + err = DoFileOpRmDir(aName, aSwitch); + } + } + + // remember the "lowest" error + if (err < iOperationError) + iOperationError = err; + + LOGSTRING3("FileBrowser: FileOpRmDir %S, err=%d", &aName, err); + + return err; + } + +// -------------------------------------------------------------------------------------------- + +TInt CFileBrowserFileOps::DoFileOpRmDir(const TDesC& aDirName, TUint aSwitch) + { + #ifndef FILEBROWSER_LITE + if (iEngine->Settings().iBypassPlatformSecurity) + { + if (!iFileOpClient) + iFileOpClient = CFBFileOpClient::NewL(); + + return iFileOpClient->RmDir(aDirName, aSwitch); + } + else + { + #endif + if ( aSwitch & CFileMan::ERecurse ) + { +// CAsyncWaiter* waiter = CAsyncWaiter::NewLC(); +// TInt result = iFileMan->RmDir( aDirName, waiter->iStatus ); +// waiter->StartAndWait(); +// if ( iFileManObserverResult == MFileManObserver::ECancel ) result = KErrCancel; +// if ( !result ) result = waiter->Result(); +// CleanupStack::PopAndDestroy( waiter); + TInt result = iFileMan->RmDir( aDirName ); + return result; + } + else + return iFs.RmDir(aDirName); + #ifndef FILEBROWSER_LITE + } + #endif + } + +// -------------------------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------- + +TInt CFileBrowserFileOps::MkDirAll(const TDesC& aPath, TInt aSetAtts, TBool aQuickOperation) + { + iFileManObserverResult = MFileManObserver::EContinue; + if (aQuickOperation) + return DoFileOpMkDirAll(aPath); + else + return FileOpMkDirAll(aPath, aSetAtts); + } + +// -------------------------------------------------------------------------------------------- + +TInt CFileBrowserFileOps::FileOpMkDirAll(const TDesC& aPath, TInt aSetAtts) + { + TInt err = DoFileOpMkDirAll(aPath); + + // if the directory already exists, it is not an error + if (err == KErrAlreadyExists) + err = KErrNone; + + + // set attributes for directory just created + if (aSetAtts > 0 && err == KErrNone && aPath.Length() > 3) + { + // a path has a trailing backslash so it needs to be removed before the call + err = FileOpAttribs(aPath.Left(aPath.Length()-1), aSetAtts, 0, 0, 0); + } + + + // remember the "lowest" error + if (err < iOperationError) + iOperationError = err; + + LOGSTRING3("FileBrowser: FileOpMkDirAll %S, err=%d", &aPath, err); + + return err; + } + +// -------------------------------------------------------------------------------------------- + +TInt CFileBrowserFileOps::DoFileOpMkDirAll(const TDesC& aPath) + { + #ifndef FILEBROWSER_LITE + if (iEngine->Settings().iBypassPlatformSecurity) + { + if (!iFileOpClient) + iFileOpClient = CFBFileOpClient::NewL(); + + return iFileOpClient->MkDirAll(aPath); + } + else + { + #endif + return iFs.MkDirAll(aPath); + #ifndef FILEBROWSER_LITE + } + #endif + } + +// -------------------------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------- + +TInt CFileBrowserFileOps::CreateEmptyFile(const TDesC& aName) + { + return DoFileOpCreateEmptyFile(aName); + } + +// -------------------------------------------------------------------------------------------- + +TInt CFileBrowserFileOps::FileOpCreateEmptyFile(const TDesC& aName) + { + TInt err = DoFileOpCreateEmptyFile(aName); + + // remember the "lowest" error + if (err < iOperationError) + iOperationError = err; + + LOGSTRING3("FileBrowser: FileOpCreateEmptyFile %S, err=%d", &aName, err); + + return err; + } + +// -------------------------------------------------------------------------------------------- + +TInt CFileBrowserFileOps::DoFileOpCreateEmptyFile(const TDesC& aName) + { + #ifndef FILEBROWSER_LITE + if (iEngine->Settings().iBypassPlatformSecurity) + { + if (!iFileOpClient) + iFileOpClient = CFBFileOpClient::NewL(); + + return iFileOpClient->CreateEmptyFile(aName); + } + else + { + #endif + TInt err(KErrNone); + + RFile newFile; + err = newFile.Create(iFs, aName, EFileShareExclusive); + if (err == KErrNone) + err = newFile.Flush(); + newFile.Close(); + + return err; + #ifndef FILEBROWSER_LITE + } + #endif + } + +// -------------------------------------------------------------------------------------------- + +TInt CFileBrowserFileOps::DriveSnapShot(TChar aSourceDriveLetter, TChar aTargetDriveLetter) + { + TInt err(KErrNone); + iFileManObserverResult = MFileManObserver::EContinue; + + // remember old settings and force them to be true for this operation + TBool currentRemoveFileLocksValue = iEngine->Settings().iRemoveFileLocks; + TBool currentIgnoreProtectionAttsValue = iEngine->Settings().iIgnoreProtectionsAtts; + TBool currentRemoveROMWriteProrection = iEngine->Settings().iRemoveROMWriteProrection; + iEngine->Settings().iRemoveFileLocks = ETrue; + iEngine->Settings().iIgnoreProtectionsAtts = ETrue; + iEngine->Settings().iRemoveROMWriteProrection = ETrue; + + + TFileName sourceDir; + sourceDir.Append(aSourceDriveLetter); + sourceDir.Append(_L(":")); + + _LIT(KTargetDir, "%c:\\SnapShot_%c_drive"); + TFileName targetDir; + targetDir.Format(KTargetDir, TUint(aTargetDriveLetter), TUint(aSourceDriveLetter)); + + // remove any existing content, first get TEntry + TEntry entry; + err = iFs.Entry(targetDir, entry); + + // entry directory exists, delete it + if (err == KErrNone && entry.IsDir()) + { + TFileName targetRoot; + targetRoot.Append(aTargetDriveLetter); + targetRoot.Append(_L(":\\")); + + TFileEntry targetEntry; + targetEntry.iPath = targetRoot; + targetEntry.iEntry = entry; + + err = Delete(targetEntry, CFileMan::ERecurse); + } + + // do not care if removing succeeded or not, just continue with copying + TEntry fakeEntry; + fakeEntry.iAtt |= KEntryAttDir; + + TFileEntry sourceEntry; + sourceEntry.iPath = sourceDir; + sourceEntry.iEntry = fakeEntry; + + err = Copy(sourceEntry, targetDir, CFileMan::ERecurse|CFileMan::EOverWrite); + + + // restore back settings + iEngine->Settings().iRemoveFileLocks = currentRemoveFileLocksValue; + iEngine->Settings().iIgnoreProtectionsAtts = currentIgnoreProtectionAttsValue; + iEngine->Settings().iRemoveROMWriteProrection = currentRemoveROMWriteProrection; + + + return iOperationError; + } + +// -------------------------------------------------------------------------------------------- + +TInt CFileBrowserFileOps::EraseMBR(TUint aDriveNumber) + { + #ifndef FILEBROWSER_LITE + + if (!iFileOpClient) + iFileOpClient = CFBFileOpClient::NewL(); + + return iFileOpClient->EraseMBR(aDriveNumber); + + #else + return KErrNotSupported; + #endif + } + +// -------------------------------------------------------------------------------------------- + +TInt CFileBrowserFileOps::PartitionDrive(TUint aDriveNumber, TUint aNumberOfPartitions) + { + #ifndef FILEBROWSER_LITE + + if (!iFileOpClient) + iFileOpClient = CFBFileOpClient::NewL(); + + return iFileOpClient->PartitionDrive(aDriveNumber, aNumberOfPartitions); + + #else + return KErrNotSupported + #endif + } + +// -------------------------------------------------------------------------------------------- + +MFileManObserver::TControl CFileBrowserFileOps::NotifyFileManStarted() + { + return iFileManObserverResult; + } + +// -------------------------------------------------------------------------------------------- + +MFileManObserver::TControl CFileBrowserFileOps::NotifyFileManOperation() + { + return iFileManObserverResult; + } +// -------------------------------------------------------------------------------------------- + +MFileManObserver::TControl CFileBrowserFileOps::NotifyFileManEnded() + { + return iFileManObserverResult; + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileOps::CancelOp() + { +#ifndef FILEBROWSER_LITE + + if ( iEngine->Settings().iBypassPlatformSecurity ) + { + if ( !iFileOpClient ) + iFileOpClient = CFBFileOpClient::NewL(); + + iFileOpClient->CancelOp(); + } + + // we need this information even when using iFileOpClient + // to be able to not execute aggregate operations + iFileManObserverResult = MFileManObserver::ECancel; + +#else + iFileManObserverResult = MFileManObserver::ECancel; +#endif + } + +// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/engine/FBFileOps.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/engine/FBFileOps.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,133 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef FILEBROWSER_FILEOPS_H +#define FILEBROWSER_FILEOPS_H + +// INCLUDES +#include +#include +#include + +// FORWARD DECLARATIONS +class TFileEntry; +class CFBFileOpClient; +class CFileMan; +class CEngine; +class CSBEClient; + + +class CFileBrowserFileOps : public CBase, + public MFileManObserver + { +private: + enum TRecursiveOperation + { + EFileOpInvalid = -1, + EFileOpCopy, + EFileOpMove, + EFileOpRename, + EFileOpAttribs, + EFileOpDelete, + EFileOpMkDirAll, + EFileOpCreateEmptyFile, + EFileOpEraseMBR, + EFileOpPartitionDrive + }; +public: + static CFileBrowserFileOps* NewL(CEngine* aEngine); + ~CFileBrowserFileOps(); + +public: // From MFileManObserver + + TControl NotifyFileManStarted(); + TControl NotifyFileManOperation(); + TControl NotifyFileManEnded(); + +private: + CFileBrowserFileOps(CEngine* aEngine); + void ConstructL(); + +public: + TInt ActivateSecureBackUpViaFileOp(); + TInt DeActivateSecureBackUpViaFileOp(); + TInt ActivateSecureBackUp(conn::TBURPartType aPartType=conn::EBURBackupFull, conn::TBackupIncType aBackupIncType=conn::EBackupBase); + TInt DeActivateSecureBackUp(); + TInt Copy(const TFileEntry& aSourceEntry, const TDesC& aTargetFullName, TUint aSwitch=CFileMan::EOverWrite, TBool aDeleteSource=EFalse); + TInt Rename(const TFileEntry& aSourceEntry, const TDesC& aNew, TUint aSwitch=CFileMan::EOverWrite); + TInt Attribs(const TFileEntry& aSourceEntry, TUint aSetMask, TUint aClearMask, const TTime& aTime, TUint aSwitch=0); + TInt Delete(const TFileEntry& aSourceEntry, TUint aSwitch=0); + TInt MkDirAll(const TDesC& aPath, TInt aSetAtts=0, TBool aQuickOperation=EFalse); + TInt CreateEmptyFile(const TDesC& aName); + TInt DriveSnapShot(TChar aSourceDriveLetter, TChar aTargetDriveLetter); + TInt EraseMBR(TUint aDriveNumber); + TInt PartitionDrive(TUint aDriveNumber, TUint aNumberOfPartitions); + void CancelOp(); + +private: + TInt DoFindEntries(const TDesC& aFileName, const TDesC& aPath); + TInt DoFindEntriesRecursiveL(const TDesC& aFileName, const TDesC& aPath); + + TInt FileOpCopy(const TDesC& aSourceFullName, const TDesC& aTargetFullName, TUint aSwitch); + TInt DoFileOpCopy(const TDesC& aSourceFullName, const TDesC& aTargetFullName, TUint aSwitch); + + TInt FileOpRename(const TDesC& aName, const TDesC& aNew, TUint aSwitch); + TInt DoFileOpRename(const TDesC& aName, const TDesC& aNew, TUint aSwitch); + + TInt FileOpAttribs(const TDesC& aName, TUint aSetMask, TUint aClearMask, const TTime& aTime, TUint aSwitch); + TInt DoFileOpAttribs(const TDesC& aName, TUint aSetMask, TUint aClearMask, const TTime& aTime, TUint aSwitch); + + TInt FileOpDeleteFile(const TDesC& aName, TUint aSwitch); + TInt DoFileOpDeleteFile(const TDesC& aName, TUint aSwitch); + + TInt FileOpRmDir(const TDesC& aDirName, TUint aSwitch); + TInt DoFileOpRmDir(const TDesC& aDirName, TUint aSwitch); + + TInt FileOpMkDirAll(const TDesC& aPath, TInt aSetAtts=0); + TInt DoFileOpMkDirAll(const TDesC& aPath); + + TInt FileOpCreateEmptyFile(const TDesC& aName); + TInt DoFileOpCreateEmptyFile(const TDesC& aName); + +public: + inline TBool SecureBackUpActive() { return iSecureBackUpActive; } + inline TBool FileCommandActivatedSecureBackup() { return iFileCommandActivatedSecureBackup; } + +private: + TInt iRecursiveState; + CEngine* iEngine; + CFBFileOpClient* iFileOpClient; + CFileMan* iFileMan; + RFs iFs; + TInt iOperationError; + conn::CSBEClient* iSBEClient; + TBool iSecureBackUpActive; + TBool iFileCommandActivatedSecureBackup; + + TFileName iBuf1; + TFileName iBuf2; + TUint iUint1; + TUint iUint2; + TUint iUint3; + TTime iTime1; + MFileManObserver::TControl iFileManObserverResult; + }; + +#endif + +// End of File + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/engine/FBFileUtils.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/engine/FBFileUtils.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,4200 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +// INCLUDE FILES +#include "FBFileUtils.h" +#include "FBFileOps.h" +#include "engine.h" +#include "FB.hrh" +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +//#include +//#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +//#include +#include +#if (!defined __SERIES60_30__ && !defined __SERIES60_31__) +#include +#endif // !defined __SERIES60_30__ && !defined __SERIES60_31__ + +#ifndef __SERIES60_30__ +// #include +#endif + +//_LIT(KGZipExt, ".gz"); +_LIT8(KFileNewLine, "\r\n"); +const TInt KForcedFormatTimeout = 1000000; + +// copied from coreapplicationuisdomainpskeys.h +const TUid KPSUidCoreApplicationUIs = { 0x101F8767 }; +const TUint32 KCoreAppUIsMmcRemovedWithoutEject = 0x00000109; +enum TCoreAppUIsMmcRemovedWithoutEject + { + ECoreAppUIsEjectCommandUsedUninitialized = 0, + ECoreAppUIsEjectCommandNotUsed, + ECoreAppUIsEjectCommandUsed, + ECoreAppUIsEjectCommandUsedToDrive // Low 16-bits contain this value and high 16-bits TDriveNumber to eject + }; +const TInt KDriveLetterStringLength = 3; // e.g. C:\ + +// ================= MEMBER FUNCTIONS ======================= + +CFileBrowserFileUtils* CFileBrowserFileUtils::NewL(CEngine* aEngine) + { + CFileBrowserFileUtils* self = new(ELeave) CFileBrowserFileUtils(aEngine); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +// -------------------------------------------------------------------------------------------- + +CFileBrowserFileUtils::CFileBrowserFileUtils(CEngine* aEngine) : CActive(EPriorityStandard), iEngine(aEngine) + { + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::ConstructL() + { + User::LeaveIfError(iTimer.CreateLocal()); + User::LeaveIfError(iFs.Connect()); + User::LeaveIfError(iTz.Connect()); + + iState = EIdle; + iListingMode = ENormalEntries; + + iSortMode = EFileBrowserCmdViewSortByName; + iOrderMode = EFileBrowserCmdViewOrderAscending; + iCurrentPath = KNullDesC; + + iFileOps = CFileBrowserFileOps::NewL(iEngine); + + iDriveEntryList = new(ELeave) CDriveEntryList(8); + iFileEntryList = new(ELeave) CFileEntryList(64); + iFindFileEntryList = new(ELeave) CFileEntryList(64); + iAppIconList = new(ELeave) CAppIconList(16); + iClipBoardList = new(ELeave) CFileEntryList(64); + iCurrentSelectionList = new(ELeave) CFileEntryList(64); + + iDocHandler = CDocumentHandler::NewL(); +// iDocHandler->SetExitObserver(this); + + // set defaults to the search settings + iSearchAttributes.iSearchDir = KNullDesC; + iSearchAttributes.iWildCards = _L("*.jpg"); + iSearchAttributes.iTextInFile = KNullDesC; + iSearchAttributes.iMinSize = 0; + iSearchAttributes.iMaxSize = 999999999; + iSearchAttributes.iMinDate = TDateTime(1980, EJanuary, 0,0,0,0,0); + iSearchAttributes.iMaxDate = TDateTime(2060, EDecember, 30,0,0,0,0); + iSearchAttributes.iRecurse = ETrue; + + // init the command array + iCommandArray = new(ELeave) CCommandArray(64); + + // get current path from settings + if (iEngine->Settings().iRememberLastPath) + { + TFileName settingPath = iEngine->Settings().iLastPath; + if (BaflUtils::PathExists(iFs, settingPath)) + iCurrentPath = settingPath; + + if (iCurrentPath != KNullDesC) + GetDriveListL(); + } + + CActiveScheduler::Add(this); + } + +// -------------------------------------------------------------------------------------------- + +CFileBrowserFileUtils::~CFileBrowserFileUtils() + { + Cancel(); + + // save current path from settings + if (iEngine->Settings().iRememberLastPath) + { + iEngine->Settings().iLastPath = iCurrentPath; + TRAP_IGNORE(iEngine->SaveSettingsL(EFalse)); + } + +// if (iWaitDialog) +// TRAP_IGNORE(iWaitDialog->ProcessFinishedL()); +// +// if (iProgressDialog) +// TRAP_IGNORE(iProgressDialog->ProcessFinishedL()); + + delete iFileOps; + + delete iDocHandler; + +// if (iOpenFileService) +// delete iOpenFileService; + + delete iCurrentSelectionList; + delete iClipBoardList; + delete iAppIconList; + delete iFindFileEntryList; + delete iFileEntryList; + delete iDriveEntryList; + + delete iFileMan; + + if (iCommandArray) + { + ResetCommandArray(); + delete iCommandArray; + } + + iTz.Close(); + iFs.Close(); + iTimer.Close(); + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::DoCancel() + { + iTimer.Cancel(); + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::StartExecutingCommandsL(const TDesC& aLabel) + { + if (iCommandArray->Count() >= 2) + { + // init progress bar +// iProgressDialog = new(ELeave) CAknProgressDialog((reinterpret_cast(&iProgressDialog)), ETrue); +// iProgressDialog->SetCallback(this); +// iProgressDialog->PrepareLC(R_GENERAL_PROGRESS_NOTE); +// iProgressDialog->SetCurrentLabelL( EAknCtNote, aLabel ); +// iProgressInfo = iProgressDialog->GetProgressInfoL(); +// iProgressInfo->SetFinalValue( CommandArrayCount() ); +// iProgressDialog->RunLD(); +// iProgressDialog->MakeVisible( ETrue ); + iEngine->FileBrowserUI()->ShowProgressDialog(aLabel, 0, CommandArrayCount()); + isProgressDialog = ETrue; + } + else if (iCommandArray->Count() >= 1) + { + // init wait dialog +// iWaitDialog = new(ELeave) CAknWaitDialog((reinterpret_cast(&iWaitDialog)), ETrue); +// iWaitDialog->SetCallback(this); +// iWaitDialog->PrepareLC(R_GENERAL_WAIT_NOTE); +// iWaitDialog->SetTextL( aLabel ); +// iWaitDialog->RunLD(); + iEngine->FileBrowserUI()->ShowWaitDialog(aLabel); + isWaitDialog = ETrue; + } + else + { + // no commands, just do nothing + return; + } + + + // start with the first operation + iCurrentEntry = 0; + iSucceededOperations = 0; + iFailedOperations = 0; + + // starts executing commands + ExecuteCommand(); + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::ExecuteCommand() + { + // make sure the engine isn't active, should never happen + __ASSERT_ALWAYS(!IsActive(), User::Panic(_L("FileUtils:IsActive"), 333)); + + // execute a command after a very short delay (25ms) + if (isWaitDialog) + { + iEngine->FileBrowserUI()->ProcessEvents(); + } + if (isProgressDialog) + { + TInt newValue = iCurrentEntry; + iEngine->FileBrowserUI()->SetProgressValue(newValue); + } + iTimer.After(iStatus, 25); + SetActive(); + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::RunL() + { + TInt err(KErrNone); + TInt currentCommand = iCommandArray->At(iCurrentEntry).iCommandId; + + // execute a command from the queue + switch(currentCommand) + { + case EFileBrowserFileOpCommandAttribs: + { + CCommandParamsAttribs* params = static_cast(iCommandArray->At(iCurrentEntry).iParameters); + err = iFileOps->Attribs(params->iSourceEntry, params->iSetMask, params->iClearMask, params->iTime, params->iSwitch); + } + break; + + case EFileBrowserFileOpCommandCopy: + { + CCommandParamsCopyOrMove* params = static_cast(iCommandArray->At(iCurrentEntry).iParameters); + err = iFileOps->Copy(params->iSourceEntry, params->iTargetPath, params->iSwitch); + } + break; + + case EFileBrowserFileOpCommandMove: + { + CCommandParamsCopyOrMove* params = static_cast(iCommandArray->At(iCurrentEntry).iParameters); + err = iFileOps->Copy(params->iSourceEntry, params->iTargetPath, params->iSwitch, ETrue); + } + break; + + case EFileBrowserFileOpCommandRename: + { + CCommandParamsRename* params = static_cast(iCommandArray->At(iCurrentEntry).iParameters); + err = iFileOps->Rename(params->iSourceEntry, params->iTargetPath, params->iSwitch); + } + break; + + case EFileBrowserFileOpCommandDelete: + { + CCommandParamsDelete* params = static_cast(iCommandArray->At(iCurrentEntry).iParameters); + err = iFileOps->Delete(params->iSourceEntry, params->iSwitch); + } + break; + + case EFileBrowserFileOpCommandDriveSnapShot: + { + CCommandParamsDriveSnapShot* params = static_cast(iCommandArray->At(iCurrentEntry).iParameters); + err = iFileOps->DriveSnapShot(params->iSourceDriveLetter, params->iTargetDriveLetter); + } + break; + + default: + User::Panic (_L("Unknown command"), 400); + break; + } + + + if (err == KErrNone) + { + iSucceededOperations++; + } + else if ( err != KErrCancel ) + { + iFailedOperations++; + } + + iLastError = err; + + // check for more commands in queue + TRAP_IGNORE( CheckForMoreCommandsL() ); + } + +// --------------------------------------------------------------------------- + +TInt CFileBrowserFileUtils::RunError(TInt aError) + { + _LIT(KMessage, "Command error %d"); + TBuf<128> noteMsg; + noteMsg.Format(KMessage, aError); + + iEngine->EikonEnv()->InfoMsg(noteMsg); + + TRAP_IGNORE( CheckForMoreCommandsL() ); + + return KErrNone; + } + +// --------------------------------------------------------------------------- + +void CFileBrowserFileUtils::CheckForMoreCommandsL() + { + //LOGSTRING("Creator: CCreatorEngine::CheckForMoreCommandsL"); + + // update the progress bar +// if (iProgressInfo) +// iProgressInfo->IncrementAndDraw(1); + + // check if we have more commands to be executed + if (iCurrentEntry >= CommandArrayCount() - 1) + { + //LOGSTRING("Creator: CCreatorEngine::CheckForMoreCommandsL all done"); + + // all done, free resources + ResetCommandArray(); + + // deactive secure backup if it was activated by a file command + iFileOps->DeActivateSecureBackUpViaFileOp(); + + // dismiss any wait/progress dialogs + if (isWaitDialog) + { + iEngine->FileBrowserUI()->CancelWaitDialog(); + isWaitDialog = EFalse; + } + if (isProgressDialog) + { + iEngine->FileBrowserUI()->CancelProgressDialog(); + isProgressDialog = EFalse; + } +// if (iWaitDialog) +// { +// TRAP_IGNORE(iWaitDialog->ProcessFinishedL()); +// iWaitDialog = NULL; +// } +// if (iProgressDialog) +// { +// TRAP_IGNORE(iProgressDialog->ProcessFinishedL()); +// iProgressDialog = NULL; +// } + + + // show result note + if ( iSucceededOperations == 0 && iFailedOperations == 0 ) + { + // single operation cancelled -> show nothing + } + else if (iSucceededOperations == 1 && iFailedOperations == 0) + { + _LIT(KMessage, "Operation succeeded"); + iEngine->FileBrowserUI()->ShowConfirmationNote(KMessage); + } + else if (iSucceededOperations > 0 && iFailedOperations == 0) + { + _LIT(KMessage, "%d operations succeeded"); + TBuf<128> noteMsg; + noteMsg.Format(KMessage, iSucceededOperations); + iEngine->FileBrowserUI()->ShowConfirmationNote(noteMsg); + } + else if (iSucceededOperations == 0 && iFailedOperations > 1) + { + _LIT(KMessage, "%d operations failed"); + TBuf<128> noteMsg; + noteMsg.Format(KMessage, iFailedOperations); + + iEngine->FileBrowserUI()->ShowErrorNote(noteMsg); + } + else if (iSucceededOperations > 0 && iFailedOperations > 0) + { + _LIT(KMessage, "%d operations succeeded, %d failed"); + TBuf<128> noteMsg; + noteMsg.Format(KMessage, iSucceededOperations, iFailedOperations); + + iEngine->FileBrowserUI()->ShowInformationNote(noteMsg, _L("")); + } + else + { + iEngine->FileBrowserUI()->ShowErrorNote(ResolveErrorMessage(iLastError)); + } + + RefreshViewL(); + iEngine->FileBrowserUI()->NotifyModelHasChanged(); + + } + else + { + // maintain requests + iCurrentEntry++; + + //LOGSTRING2("Creator: CCreatorEngine::CheckForMoreCommandsL iCurrentEntry=%d", iCurrentEntry); + + ExecuteCommand(); + } + } +// -------------------------------------------------------------------------------------------- + +// This callback function is called when cancel button of the progress bar was pressed +void CFileBrowserFileUtils::DialogDismissedL(/*TInt aButtonId*/) + { +// iProgressDialog = NULL; +// iProgressInfo = NULL; +// iWaitDialog = NULL; + + // check if cancel button was pressed +// if (aButtonId == EAknSoftkeyCancel) +// { + // cancel the active object, command executer + Cancel(); + + iFileOps->CancelOp(); + + ResetCommandArray(); + + isProgressDialog = EFalse; + + iEngine->FileBrowserUI()->ShowInformationNote(_L("Cancelled"), _L("")); +// } + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::AppendToCommandArrayL(TInt aCommand, CCommandParamsBase* aParameters) + { + if (iCommandArray) + iCommandArray->AppendL( TCommand(aCommand, aParameters) ); + else + User::Leave(KErrNotReady); + } + +// -------------------------------------------------------------------------------------------- + +TInt CFileBrowserFileUtils::CommandArrayCount() const + { + TInt count(0); + + if (iCommandArray) + count = iCommandArray->Count(); + + return count; + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::ResetCommandArray() + { + // delete params first + for (TInt i=0; iAt(i).iParameters ) + { + delete iCommandArray->At(i).iParameters; + iCommandArray->At(i).iParameters = NULL; + } + } + + // reset the entries + iCommandArray->Reset(); + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::HandleSettingsChangeL() + { + // TODO + +// if (iEngine->FileListContainer()) +// { +// iEngine->FileListContainer()->SetScreenLayoutL(iEngine->Settings().iDisplayMode); +// iEngine->FileListContainer()->CreateListBoxL(iEngine->Settings().iFileViewMode); + //iEngine->FileListContainer()->SetNaviPaneTextL(iCurrentPath); + RefreshViewL(); +// } + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::SetSortModeL(TInt aSortMode) + { + iSortMode = aSortMode; + RefreshViewL(); + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::SetOrderModeL(TInt aOrderMode) + { + iOrderMode = aOrderMode; + RefreshViewL(); + } + +// -------------------------------------------------------------------------------------------- + +TKeyResponse CFileBrowserFileUtils::HandleOfferKeyEventL(const TKeyEvent& /*aKeyEvent*/, TEventCode /*aType*/) + { + // TODO + /* + if(aType != EEventKey) + return EKeyWasNotConsumed; + + TBool shiftKeyPressed = (aKeyEvent.iModifiers & EModifierShift) || + (aKeyEvent.iModifiers & EModifierLeftShift) || + (aKeyEvent.iModifiers & EModifierRightShift); + TBool controlKeyPressed = (aKeyEvent.iModifiers & EModifierCtrl) || + (aKeyEvent.iModifiers & EModifierRightCtrl); + + // handle left arrow key press + if (aKeyEvent.iCode == EKeyLeftArrow) + { + MoveUpOneLevelL(); + return EKeyWasConsumed; + } + + // handle right arrow key press + else if (aKeyEvent.iCode == EKeyRightArrow) + { + if (IsDriveListViewActive() && iDriveEntryList->Count() > 0) + { + MoveDownToDirectoryL(); + return EKeyWasConsumed; + } + else if (iFileEntryList->Count() > 0) + { + MoveDownToDirectoryL(); + return EKeyWasConsumed; + } + } + + // skip OK/Enter keys when shift or ctrl is pressed because those are needed by the listbox + else if ((aKeyEvent.iCode == EKeyOK || aKeyEvent.iCode == EKeyEnter) && (shiftKeyPressed || controlKeyPressed)) + { + return EKeyWasNotConsumed; + } + + // handle OK/Enter keys + else if (aKeyEvent.iCode == EKeyOK || aKeyEvent.iCode == EKeyEnter) + { + if (IsDriveListViewActive() && iDriveEntryList->Count() > 0) + { + MoveDownToDirectoryL(); + return EKeyWasConsumed; + } + else if (iFileEntryList->Count() > 0) + { + TFileEntry fileEntry = iFileEntryList->At(iEngine->FileListContainer()->CurrentListBoxItemIndex()); + + if (fileEntry.iEntry.IsDir()) + MoveDownToDirectoryL(); + else + OpenCommonFileActionQueryL(); + + return EKeyWasConsumed; + } + } + + // handle Delete/Backspace keys + else if (!iEngine->FileListContainer()->SearchField() && (aKeyEvent.iCode == EKeyBackspace || aKeyEvent.iCode == EKeyDelete) && + !iEngine->FileUtils()->IsCurrentDriveReadOnly() && !iEngine->FileUtils()->IsDriveListViewActive()) + { + DeleteL(); + return EKeyWasConsumed; + } + */ + return EKeyWasNotConsumed; + } +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::RefreshViewL() + { +// if (iEngine->FileListContainer()) +// { +// +// // make sure that the search field is disabled +// iEngine->FileListContainer()->DisableSearchFieldL(); + + // read directory listing + GenerateDirectoryDataL(); + +// // set an icon array +// iEngine->FileListContainer()->SetListBoxIconArrayL(GenerateIconArrayL()); +// +// // set text items +// iEngine->FileListContainer()->SetListBoxTextArrayL(GenerateItemTextArrayL()); +// } + } + +// -------------------------------------------------------------------------------------------- + +//CAknIconArray* CFileBrowserFileUtils::GenerateIconArrayL(TBool aGenerateNewBasicIconArray) +// { +// // TODO +// +// CAknIconArray* iconArray = NULL; +// +// if (aGenerateNewBasicIconArray) +// { +// iconArray = new(ELeave) CAknIconArray(16); +// } +// else +// { +// if (iEngine->FileListContainer()) +// iconArray = iEngine->FileListContainer()->ListBoxIconArrayL(); +// +// if (!iconArray) +// iconArray = new(ELeave) CAknIconArray(16); +// } +// +// +// CleanupStack::PushL(iconArray); +// +// // generate basic items if not already existing +// if (iconArray->Count() < EFixedIconListLength) +// { +// // reset arrays +// iconArray->Reset(); +// iAppIconList->Reset(); +// +// // get default control color +// TRgb defaultColor; +// defaultColor = iEngine->EikonEnv()->Color(EColorControlText); +// +// // create a color icon of the marking indicator +// CFbsBitmap* markBitmap = NULL; +// CFbsBitmap* markBitmapMask = NULL; +// +// AknsUtils::CreateColorIconL(AknsUtils::SkinInstance(), +// KAknsIIDQgnIndiMarkedAdd, +// KAknsIIDQsnIconColors, +// EAknsCIQsnIconColorsCG13, +// markBitmap, +// markBitmapMask, +// AknIconUtils::AvkonIconFileName(), +// EMbmAvkonQgn_indi_marked_add, +// EMbmAvkonQgn_indi_marked_add_mask, +// defaultColor +// ); +// +// // 0 marking indicator +// CGulIcon* markIcon = CGulIcon::NewL(markBitmap, markBitmapMask); +// iconArray->AppendL(markIcon); +// +// // 1 empty +// AppendGulIconToIconArrayL(iconArray, AknIconUtils::AvkonIconFileName(), +// EMbmAvkonQgn_prop_empty, EMbmAvkonQgn_prop_empty_mask, KAknsIIDQgnPropEmpty); +// // 2 phone memory +// AppendGulIconToIconArrayL(iconArray, AknIconUtils::AvkonIconFileName(), +// EMbmAvkonQgn_prop_phone_memc, EMbmAvkonQgn_prop_phone_memc_mask, KAknsIIDQgnPropPhoneMemc); +// // 3 memory card +// AppendGulIconToIconArrayL(iconArray, KMemoryCardUiBitmapFile, +// EMbmAknmemorycarduiQgn_prop_mmc_memc, EMbmAknmemorycarduiQgn_prop_mmc_memc_mask, KAknsIIDQgnPropMmcMemc); +// // 4 memory card disabled +// AppendGulIconToIconArrayL(iconArray, KMemoryCardUiBitmapFile, +// EMbmAknmemorycarduiQgn_prop_mmc_non, EMbmAknmemorycarduiQgn_prop_mmc_non_mask, KAknsIIDQgnPropMmcNon); +// // 5 folder +// AppendGulIconToIconArrayL(iconArray, AknIconUtils::AvkonIconFileName(), +// EMbmAvkonQgn_prop_folder_small, EMbmAvkonQgn_prop_folder_small_mask, KAknsIIDQgnPropFolderSmall); +// // 6 folder with subfolders +// AppendGulIconToIconArrayL(iconArray, AknIconUtils::AvkonIconFileName(), +// EMbmAvkonQgn_prop_folder_sub_small, EMbmAvkonQgn_prop_folder_sub_small_mask, KAknsIIDQgnPropFolderSubSmall); +// // 7 current folder +// AppendGulIconToIconArrayL(iconArray, AknIconUtils::AvkonIconFileName(), +// EMbmAvkonQgn_prop_folder_current, EMbmAvkonQgn_prop_folder_current_mask, KAknsIIDQgnPropFolderCurrent); +// } +// +// // append custom icons if not in drive list view and setting is enabled +// if (!aGenerateNewBasicIconArray && !IsDriveListViewActive() && iEngine->Settings().iShowAssociatedIcons) +// { +// // init id counter +// TInt idCounter(EFixedIconListLength + iAppIconList->Count()); +// +// // loop all items in the file list +// for (TInt i=0; iCount(); i++) +// { +// TFileEntry& fileEntry = iFileEntryList->At(i); +// +// // just check for normal files +// if (!fileEntry.iEntry.IsDir()) +// { +// TUid appUid = GetAppUid(fileEntry); +// TInt iconId = AppIconIdForUid(appUid); +// +// if (appUid != KNullUid && iconId == KErrNotFound) +// { +// // icon not found from the icon array, generate it +// CFbsBitmap* bitmap = NULL; +// CFbsBitmap* mask = NULL; +// CGulIcon* appIcon = NULL; +// +// TRAPD(err, +// AknsUtils::CreateAppIconLC(AknsUtils::SkinInstance(), appUid, EAknsAppIconTypeList, bitmap, mask); +// appIcon = CGulIcon::NewL(bitmap, mask); +// CleanupStack::Pop(2); //bitmap, mask +// ); +// +// if (err == KErrNone) +// { +// TAppIcon appIconEntry; +// appIconEntry.iId = idCounter; +// appIconEntry.iUid = appUid; +// +// appIcon->SetBitmapsOwnedExternally(EFalse); +// iconArray->AppendL(appIcon); +// iAppIconList->AppendL(appIconEntry); +// +// fileEntry.iIconId = idCounter; +// +// idCounter++; +// } +// else +// { +// delete bitmap; +// delete mask; +// +// TAppIcon appIconEntry; +// appIconEntry.iId = EFixedIconEmpty; +// appIconEntry.iUid = appUid; +// +// iAppIconList->AppendL(appIconEntry); +// } +// } +// +// else if (appUid != KNullUid && iconId >= 0) +// { +// // we already have already generated an icon for this uid, use it +// fileEntry.iIconId = iconId; +// } +// } +// } +// } +// +// CleanupStack::Pop(); //iconArray +// return iconArray; +// +// } +// +// -------------------------------------------------------------------------------------------- + +//void CFileBrowserFileUtils::AppendGulIconToIconArrayL(CAknIconArray* aIconArray, const TDesC& aIconFile, TInt aIconId, TInt aMaskId, const TAknsItemID aAknsItemId) +// { +// CGulIcon* icon = AknsUtils::CreateGulIconL( +// AknsUtils::SkinInstance(), +// aAknsItemId, +// aIconFile, +// aIconId, +// aMaskId); +// CleanupStack::PushL(icon); +// +// icon->SetBitmapsOwnedExternally(EFalse); +// aIconArray->AppendL(icon); +// +// CleanupStack::Pop(); //icon +// } + +// -------------------------------------------------------------------------------------------- + +TInt CFileBrowserFileUtils::AppIconIdForUid(TUid aUid) + { + TInt result(KErrNotFound); + + for (TInt i=0; iCount(); i++) + { + if (iAppIconList->At(i).iUid == aUid) + { + result = iAppIconList->At(i).iId; + break; + } + } + + return result; + } + +// -------------------------------------------------------------------------------------------- + +TUid CFileBrowserFileUtils::GetAppUid(const TFileEntry &aFileEntry) + { + TFileName fullPath; + fullPath.Copy(aFileEntry.iPath); + fullPath.Append(aFileEntry.iEntry.iName); + + TParse parsedName; + parsedName.Set(fullPath, NULL, NULL); + + // this will boost performance in \sys\bin folder + if (parsedName.Ext().CompareF(_L(".dll")) == 0 || parsedName.Ext().CompareF(_L(".rsc")) == 0) + return KNullUid; + + TInt err1(KErrNone), err2(KErrNone); + TUid appUid; + TDataType dataType; + TBool isProgram; + + err1 = iEngine->LsSession().AppForDocument(fullPath, appUid, dataType); + err2 = iEngine->LsSession().IsProgram(fullPath, isProgram); + + if (err1 == KErrNone && err2 == KErrNone) + { + if (isProgram) + { + // get the real app Uid from the app list + TApaAppInfo appInfo; + iEngine->LsSession().GetAllApps(); + + while (iEngine->LsSession().GetNextApp(appInfo) == KErrNone) + { + if (fullPath.CompareF(appInfo.iFullName) == 0) + return appInfo.iUid; + } + } + else + { + // return the app Uid associated for it + return appUid; + } + } + + return KNullUid; + } + +// -------------------------------------------------------------------------------------------- + +CFileEntryList* CFileBrowserFileUtils::FileEntries() const +{ + return iFileEntryList; +} + +// -------------------------------------------------------------------------------------------- + +CDriveEntryList* CFileBrowserFileUtils::DriveEntries() const +{ + return iDriveEntryList; +} + +// -------------------------------------------------------------------------------------------- + +TFileName CFileBrowserFileUtils::ResolveErrorMessage(TInt aErrCode) + { + TPtrC buf; + CTextResolver* textResolver = CTextResolver::NewLC(*iEngine->EikonEnv()); + buf.Set(textResolver->ResolveErrorString(aErrCode, CTextResolver::ECtxNoCtxNoSeparator)); + + TFileName errorMessage; + errorMessage.Copy(buf); + + CleanupStack::PopAndDestroy(); //textResolver + return errorMessage; + } + +//// -------------------------------------------------------------------------------------------- +// +//CDesCArray* CFileBrowserFileUtils::GenerateItemTextArrayL() +// { +// iTextArray = new(ELeave) CDesCArrayFlat(64); +//// CleanupStack::PushL(textArray); +// +// if (IsDriveListViewActive()) +// { +// _LIT(KSimpleDriveEntry, "%d\t%c: <%S>\t\t"); +// _LIT(KExtendedDriveEntry, "%d\t%c: <%S>\t%LD / %LD kB\t"); +// +// for (TInt i=0; iCount(); i++) +// { +// TFileName textEntry; +// TDriveEntry driveEntry = iDriveEntryList->At(i); +// +// if (iEngine->Settings().iFileViewMode == EFileViewModeSimple) +// { +// textEntry.Format(KSimpleDriveEntry, driveEntry.iIconId, TUint(driveEntry.iLetter), &driveEntry.iMediaTypeDesc); +// } +// else if (iEngine->Settings().iFileViewMode == EFileViewModeExtended) +// { +// textEntry.Format(KExtendedDriveEntry, driveEntry.iIconId, TUint(driveEntry.iLetter), &driveEntry.iMediaTypeDesc, driveEntry.iVolumeInfo.iFree/1024, driveEntry.iVolumeInfo.iSize/1024); +// } +// +// iTextArray->AppendL(textEntry); +// } +// } +// +// else +// { +// _LIT(KSimpleFileEntry, "%d\t%S\t\t"); +// _LIT(KExtendedFileEntry, "%d\t%S\t%S\t"); +// +// for (TInt i=0; iCount(); i++) +// { +// TFileName textEntry; +// TFileEntry fileEntry = iFileEntryList->At(i); +// +// // format text line entries +// if (iEngine->Settings().iFileViewMode == EFileViewModeSimple) +// { +// textEntry.Format(KSimpleFileEntry, fileEntry.iIconId, &fileEntry.iEntry.iName); +// } +// else if (iEngine->Settings().iFileViewMode == EFileViewModeExtended) +// { +// TBuf<128> extraData; +// +// // append entry date +// TTime entryModified = fileEntry.iEntry.iModified; +// if ( iTz.ConvertToLocalTime( entryModified ) == KErrNone ) +// { +// entryModified = fileEntry.iEntry.iModified; +// } +// +// _LIT(KCurrentDate,"%D%M%*Y%/0%1%/1%2%/2%3%/3 %-B%:0%J%:1%T%:2%S%:3%+B"); +// entryModified.FormatL(extraData, KCurrentDate); +// +// // for a directory append number of entries and for a file the file size +// if (fileEntry.iEntry.IsDir() && fileEntry.iDirEntries >= 0) +// { +// extraData.Append(_L(" - ")); +// extraData.AppendNum(fileEntry.iDirEntries); +// +// if (fileEntry.iDirEntries == 1) +// extraData.Append(_L(" entry")); +// else +// extraData.Append(_L(" entries")); +// } +// +// // normal file entry +// else if (!fileEntry.iEntry.IsDir()) +// { +// extraData.Append(_L(" - ")); +// +// if (fileEntry.iEntry.iSize < 1024) +// { +// extraData.AppendNum(fileEntry.iEntry.iSize); +// extraData.Append(_L(" B")); +// } +// else if (fileEntry.iEntry.iSize < 1024*1024) +// { +// TReal sizeKB = (TReal)fileEntry.iEntry.iSize / 1024; +// extraData.AppendNum(sizeKB, TRealFormat(KDefaultRealWidth, 1)); +// extraData.Append(_L(" kB")); +// } +// else +// { +// TReal sizeMB = (TReal)fileEntry.iEntry.iSize / (1024*1024); +// extraData.AppendNum(sizeMB, TRealFormat(KDefaultRealWidth, 1)); +// extraData.Append(_L(" MB")); +// } +// } +// +// // append attribute flags if any +// TBuf<4> atts; +// if (fileEntry.iEntry.IsArchive()) +// atts.Append(_L("A")); +// if (fileEntry.iEntry.IsHidden()) +// atts.Append(_L("H")); +// if (fileEntry.iEntry.IsReadOnly()) +// atts.Append(_L("R")); +// if (fileEntry.iEntry.IsSystem()) +// atts.Append(_L("S")); +// +// if (atts.Length() > 0) +// { +// extraData.Append(_L(" - [")); +// extraData.Append(atts); +// extraData.Append(_L("]")); +// } +// +// // format +// textEntry.Format(KExtendedFileEntry, fileEntry.iIconId, &fileEntry.iEntry.iName, &extraData); +// } +// +// iTextArray->AppendL(textEntry); +// } +// } +// +//// CleanupStack::Pop(); //textArray +// return iTextArray; +// } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::GenerateDirectoryDataL() + { + if (iListingMode == ENormalEntries) + { + if (IsDriveListViewActive()) + GetDriveListL(); + else + GetDirectoryListingL(); + } + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::GetDriveListL() + { + TDriveList driveList; + + // get drive listing depending of the support for network drives + if (iEngine->Settings().iSupportNetworkDrives) + { + #ifndef __SERIES60_30__ + #ifndef __SERIES60_31__ + User::LeaveIfError(iFs.DriveList(driveList, KDriveAttAll)); + #endif + #else + User::LeaveIfError(iFs.DriveList(driveList)); + #endif + } + else + { + User::LeaveIfError(iFs.DriveList(driveList)); + } + + iDriveEntryList->Reset(); + + for (TInt i=0; iCount(); + } + + iDriveEntryList->AppendL(driveEntry); + } + } + + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::GetDirectoryListingL() + { + iFileEntryList->Reset(); + + TInt sortMode(ESortByName); + if (iSortMode == EFileBrowserCmdViewSortByExtension) + sortMode = ESortByExt; + else if (iSortMode == EFileBrowserCmdViewSortBySize) + sortMode = ESortBySize; + else if (iSortMode == EFileBrowserCmdViewSortByDate) + sortMode = ESortByDate; + + TInt orderMode(EAscending); + if (iOrderMode == EFileBrowserCmdViewOrderDescending) + orderMode = EDescending; + + CDir* dir = NULL; + if (iFs.GetDir(iCurrentPath, KEntryAttMatchMask, sortMode | orderMode | EDirsFirst, dir) == KErrNone) + { + CleanupStack::PushL(dir); + + for (TInt i=0; iCount(); i++) + { + TFileEntry fileEntry; + fileEntry.iPath = iCurrentPath; + fileEntry.iEntry = (*dir)[i]; + fileEntry.iDirEntries = KErrNotFound; + fileEntry.iIconId = EFixedIconEmpty; + + if ( iPrevFolderName != KNullDesC && iPrevFolderName == fileEntry.iEntry.iName ) + { + iPrevFolderIndex = i; + } + + // check for directory entries + if (fileEntry.iEntry.IsDir()) + { + fileEntry.iIconId = EFixedIconFolder; + + TFileName subPath = fileEntry.iPath; + subPath.Append(fileEntry.iEntry.iName); + subPath.Append(_L("\\")); + + // get number of entries in this directory if extended info about sub directories enabled + if (iEngine->Settings().iShowSubDirectoryInfo && iEngine->Settings().iFileViewMode == EFileViewModeExtended) + { + CDir* subDir = NULL; + if (iFs.GetDir(subPath, KEntryAttMatchMask, ESortNone | EDirsFirst, subDir) == KErrNone) + { + fileEntry.iDirEntries = subDir->Count(); + delete subDir; + } + } + + // apply subfolder icon for known directories (speed improvement) + if (subPath[0]=='Z' && (subPath.CompareF(_L("Z:\\data\\"))==0 || subPath.CompareF(_L("Z:\\Nokia\\"))==0 + || subPath.Compare(_L("Z:\\private\\"))==0 || subPath.Compare(_L("Z:\\resource\\"))==0 + || subPath.Compare(_L("Z:\\sys\\"))==0 || subPath.Compare(_L("Z:\\system\\"))==0)) + { + fileEntry.iIconId = EFixedIconFolderSub; + } + else if (subPath[0]=='Z' && (subPath.CompareF(_L("Z:\\sys\\bin\\"))==0)) + { + // normal folder icon for these ones + fileEntry.iIconId = EFixedIconFolder; + } + else + { + // check if this folder has subdirectories + CDir* subDir = NULL; + if (iFs.GetDir(subPath, KEntryAttDir|KEntryAttMatchMask, ESortNone | EDirsFirst, subDir) == KErrNone) + { + for (TInt j=0; jCount(); j++) + { + TEntry entry = (*subDir)[j]; + + if (entry.IsDir()) + { + fileEntry.iIconId = EFixedIconFolderSub; + break; + } + } + + delete subDir; + } + } + } + + iFileEntryList->AppendL(fileEntry); + } + + CleanupStack::PopAndDestroy(); //dir + } + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::MoveUpOneLevelL() + { + iPrevFolderIndex = KErrNotFound; + iPrevFolderName.Zero(); + + // change back to normal mode or move up + if (iListingMode != ENormalEntries) + { + iListingMode = ENormalEntries; + } + else + { + // do nothing if displaying drive list view + if (IsDriveListViewActive()) + return; + + if (iCurrentPath.Length() <= KDriveLetterStringLength) + { + if ( iCurrentPath.Length() > 0 ) + { + iPrevFolderName.Append( iCurrentPath[0] ); + } + // move to drive list view if the current path is already short enough + iCurrentPath = KNullDesC; + } + else + { + // move one directory up + TInt marker(iCurrentPath.Length()); + + // find second last dir marker + for (TInt i=iCurrentPath.Length()-2; i>=0; i--) + { + if (iCurrentPath[i] == '\\') + { + marker = i; + break; + } + + } + + // update iPrevDir with the directory name that we just left + iPrevFolderName.Copy( iCurrentPath.RightTPtr( iCurrentPath.Length() - marker - 1 ) ); + iPrevFolderName.Delete( iPrevFolderName.Length() -1, 2 ); // remove extra '\\' + + iCurrentPath = iCurrentPath.LeftTPtr(marker+1); + } + } + +// if (iEngine->FileListContainer()) +// { + //iEngine->FileListContainer()->DisableSearchFieldL(); + //iEngine->FileListContainer()->ListBox()->ClearSelection(); + //iEngine->FileListContainer()->ListBox()->SetCurrentItemIndex(0); + //iEngine->FileListContainer()->SetNaviPaneTextL(iCurrentPath); +// } + + // update view + RefreshViewL(); + + if (iEngine->Settings().iRememberFolderSelection + //&& iEngine->FileListContainer() + && iPrevFolderIndex > KErrNotFound ) + { + +// TInt visibleItems = iEngine->FileListContainer()->ListBox()->Rect().Height() / +// iEngine->FileListContainer()->ListBox()->ItemHeight() +// - 1; // for the title row +// +// // By default, the selected item would be the last visible item on the listbox. +// // We want the selected item be displayed at the middle of the listbox, so we +// // select one of the successor items first to scroll down a bit +// iEngine->FileListContainer()->ListBox()->SetCurrentItemIndex( +// Min( iEngine->FileListContainer()->ListBox()->Model()->ItemTextArray()->MdcaCount() -1, +// iPrevFolderIndex + visibleItems / 2 ) ); +// +// // ...and after that we select the the correct item. +// iEngine->FileListContainer()->ListBox()->SetCurrentItemIndex( iPrevFolderIndex ); + + // update view + RefreshViewL(); + } + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::MoveDownToDirectoryL(TInt aIndex) + { + + // change back to normal mode + if (iListingMode != ENormalEntries) + { + iListingMode = ENormalEntries; + } + + if (aIndex >= 0) + { + TBool needsRefresh(EFalse); + + if (IsDriveListViewActive()) + { + // currently in a drive list view, move to root of selected drive + if (iDriveEntryList->Count() > aIndex) + { + TDriveEntry driveEntry = iDriveEntryList->At(aIndex); + + iCurrentPath.Append(driveEntry.iLetter); + iCurrentPath.Append(_L(":\\")); + + needsRefresh = ETrue; + } + } + else + { + // otherwise just append the new directory + if (iFileEntryList->Count() > aIndex) + { + TFileEntry fileEntry = iFileEntryList->At(aIndex); + + if (fileEntry.iEntry.IsDir()) + { + iCurrentPath.Copy(fileEntry.iPath); + iCurrentPath.Append(fileEntry.iEntry.iName); + iCurrentPath.Append(_L("\\")); + + needsRefresh = ETrue; + } + } + } + + if (needsRefresh /*&& iEngine->FileListContainer()*/) + { + //iEngine->FileListContainer()->DisableSearchFieldL(); + //iEngine->FileListContainer()->ListBox()->ClearSelection(); + //iEngine->FileListContainer()->ListBox()->SetCurrentItemIndex(0); + //iEngine->FileListContainer()->SetNaviPaneTextL(iCurrentPath); + + // update view + RefreshViewL(); + } + } + } + +// -------------------------------------------------------------------------------------------- + +TBool CFileBrowserFileUtils::IsCurrentDriveReadOnly() + { + if (iListingMode !=ENormalEntries || iCurrentPath.Length() < 2) + return EFalse; + else + { + for (TInt i=0; iCount(); i++) + { + TDriveEntry driveEntry = iDriveEntryList->At(i); + + if (driveEntry.iLetter == iCurrentPath[0]) + { + if (driveEntry.iVolumeInfo.iDrive.iMediaAtt == KMediaAttWriteProtected || driveEntry.iVolumeInfo.iDrive.iMediaAtt == KMediaAttLocked || driveEntry.iVolumeInfo.iDrive.iDriveAtt == KDriveAbsent) + return ETrue; + else + return EFalse; + } + } + } + + return EFalse; + } + +// -------------------------------------------------------------------------------------------- + +TBool CFileBrowserFileUtils::IsItemDirectory(TInt aCurrentItemIndex) + { + if (aCurrentItemIndex < 0) + { + return EFalse; + } + else + { + if (iFileEntryList->Count() > aCurrentItemIndex) + { + TFileEntry fileEntry = iFileEntryList->At(aCurrentItemIndex) ; + return fileEntry.iEntry.IsDir(); + } + else + { + return EFalse; + } + } + } + +// -------------------------------------------------------------------------------------------- + +TInt CFileBrowserFileUtils::SetSelectedItemsOrCurrentItemL(const CArrayFix* selectionIndexes, + CFileEntryList* aFileEntryList) + { + aFileEntryList->Reset(); + + // by default use selected items + if (selectionIndexes && selectionIndexes->Count() > 0) + { + TInt ref(0); + TKeyArrayFix key(0, ECmpTUint16); + TInt index(0); + + for (TInt i=0; iCount(); i++) + { + ref = i; + + if (selectionIndexes->Find(ref, key, index) == 0) + { + aFileEntryList->AppendL(iFileEntryList->At(i)); + } + } + } + return aFileEntryList->Count(); + } + +// -------------------------------------------------------------------------------------------- + +TInt CFileBrowserFileUtils::ClipboardCutL(const CArrayFix* aSelectionIndices) + { + + iClipBoardMode = EClipBoardModeCut; + TInt operations = SetSelectedItemsOrCurrentItemL(aSelectionIndices, iClipBoardList); + return operations; + } + +// -------------------------------------------------------------------------------------------- + +TInt CFileBrowserFileUtils::ClipboardCopyL(const CArrayFix* aSelectionIndices) + { + iClipBoardMode = EClipBoardModeCopy; + TInt operations = SetSelectedItemsOrCurrentItemL(aSelectionIndices, iClipBoardList); + return operations; + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::ClipboardPasteL(const TOverwriteOptions &aOverwriteOptions) + { + if (iClipBoardMode == EClipBoardModeCut) + { + DoCopyToFolderL(iClipBoardList, iCurrentPath, aOverwriteOptions, ETrue ); + iClipBoardList->Reset(); + } + else if (iClipBoardMode == EClipBoardModeCopy) + { + DoCopyToFolderL(iClipBoardList, iCurrentPath, aOverwriteOptions, EFalse); + } + } + +// -------------------------------------------------------------------------------------------- + +TInt CFileBrowserFileUtils::SetCurrentSelection(const CArrayFix* aSelectionIndices) + { + TInt operations = SetSelectedItemsOrCurrentItemL(aSelectionIndices, iCurrentSelectionList); + return operations; + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::CopyToFolderL(const TFileName &aTargetDir, + const TOverwriteOptions &aOverwriteOptions, + TBool aMove) + { + + // TFileName destinationFolder; + + // generate an icon array + // CAknIconArray* iconArray = GenerateIconArrayL(ETrue); + // CleanupStack::PushL(iconArray); + + // run folder selection dialog + // CFileBrowserDestinationFolderSelectionDlg* dlg = CFileBrowserDestinationFolderSelectionDlg::NewL(destinationFolder, iDriveEntryList, iconArray); + + // do the file operations + //DoCopyToFolderL(entryList, aTargetDir, aOverwriteOptions, aMove); + DoCopyToFolderL(iCurrentSelectionList, aTargetDir, aOverwriteOptions, aMove); + + // CleanupStack::Pop(); //iconArray + } + +// -------------------------------------------------------------------------------------------- + +TBool CFileBrowserFileUtils::IsDestinationEntriesExists(const TDesC& aTargetDir) + { + TBool someEntryExists(EFalse); + if (iCurrentSelectionList && iCurrentSelectionList->Count() > 0) + { + // check if some destination entries also exists + for (TInt i=0; iCount(); i++) + { + TFileEntry fileEntry = iCurrentSelectionList->At(i); + + TFileName targetEntry = aTargetDir; + targetEntry.Append(fileEntry.iEntry.iName); + + if (fileEntry.iEntry.IsDir()) + { + targetEntry.Append(_L("\\")); + + if (BaflUtils::PathExists(iFs, targetEntry)) + { + someEntryExists = ETrue; + break; + } + } + else + { + if (BaflUtils::FileExists(iFs, targetEntry)) + { + someEntryExists = ETrue; + break; + } + } + } + } + return someEntryExists; + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::DoCopyToFolderL(CFileEntryList* aEntryList, + const TDesC& aTargetDir, + const TOverwriteOptions &aOverwriteOptions, + TBool aDeleteSource) + { + if (aEntryList && aEntryList->Count() > 0) + { + if (aOverwriteOptions.iDoFileOperations) + { + // set correct command id depending if we are copying or moving + TInt commandId(EFileBrowserFileOpCommandCopy); + if (aDeleteSource) + commandId = EFileBrowserFileOpCommandMove; + + // do the file operations for each entry + for (TInt i=0; iCount(); i++) + { + TFileEntry fileEntry = aEntryList->At(i); + + TFileName targetEntry = aTargetDir; + targetEntry.Append(fileEntry.iEntry.iName); + + if (aOverwriteOptions.iQueryIndex == EFileActionGenerateUniqueFilenames) + { + CApaApplication::GenerateFileName(iFs, targetEntry); + } + else if (aOverwriteOptions.iQueryIndex == EFileActionQueryPostFix) + { + targetEntry.Append(aOverwriteOptions.iPostFix); + } + + + // append the new command to the command array + if (fileEntry.iEntry.IsDir()) + { + AppendToCommandArrayL(commandId, + new(ELeave)CCommandParamsCopyOrMove(fileEntry, targetEntry, aOverwriteOptions.iOverWriteFlags|CFileMan::ERecurse) + ); + } + else + { + AppendToCommandArrayL(commandId, + new(ELeave)CCommandParamsCopyOrMove(fileEntry, targetEntry, aOverwriteOptions.iOverWriteFlags) + ); + } + + } + } + } + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::DeleteL() + { + // do the file operations for each entry + for (TInt i=0; iCount(); i++) + { + TFileEntry fileEntry = iCurrentSelectionList->At(i); + + // append the new command to the command array + if (fileEntry.iEntry.IsDir()) + { + AppendToCommandArrayL(EFileBrowserFileOpCommandDelete, + new(ELeave)CCommandParamsDelete(fileEntry, CFileMan::ERecurse) + ); + } + else + { + AppendToCommandArrayL(EFileBrowserFileOpCommandDelete, + new(ELeave)CCommandParamsDelete(fileEntry, 0) + ); + } + + } + } + + +// -------------------------------------------------------------------------------------------- + +TBool CFileBrowserFileUtils::SelectionHasDirs() +{ + TBool isDir(EFalse); + + // check if any directories and ask recursion + for (TInt i=0; iCount(); i++) + { + TFileEntry fileEntry = iCurrentSelectionList->At(i); + + if (fileEntry.iEntry.IsDir()) + { + isDir = ETrue; + break; + } + } + return isDir; +} + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::TouchL(TBool aRecurse) + { + // now go through all entries + for (TInt i=0; iCount(); i++) + { + TFileEntry fileEntry = iCurrentSelectionList->At(i); + + // touch to current time + TTime now; + now.UniversalTime(); + + + // append the new command to the command array + if (fileEntry.iEntry.IsDir() && aRecurse) + { + AppendToCommandArrayL(EFileBrowserFileOpCommandAttribs, + new(ELeave)CCommandParamsAttribs(fileEntry, NULL, NULL, now, CFileMan::ERecurse) + ); + } + else + { + AppendToCommandArrayL(EFileBrowserFileOpCommandAttribs, + new(ELeave)CCommandParamsAttribs(fileEntry, NULL, NULL, now, 0) + ); + } + } + } + +TBool CFileBrowserFileUtils::TargetExists(const TInt aIndex, const TFileName &newName) + { + TBool alreadyExists(EFalse); + if (iFileEntryList->Count() > aIndex && aIndex >= 0) + { + + TFileEntry fileEntry = iFileEntryList->At(aIndex); + TFileName targetEntry = fileEntry.iPath; + targetEntry.Append(newName); + if (fileEntry.iEntry.IsDir()) + { + //targetEntry.Append(_L("\\")); + alreadyExists = BaflUtils::PathExists(iFs, targetEntry); + } + else + { + alreadyExists = BaflUtils::FileExists(iFs, targetEntry); + } + } + return alreadyExists; + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::RenameL(const TInt aIndex, const TFileName &newName) + { + if (iFileEntryList->Count() > aIndex && aIndex >= 0) + { + TFileEntry fileEntry = iFileEntryList->At(aIndex); + + TFileName targetEntry = fileEntry.iPath; + targetEntry.Append(newName); + + // append the new command to the command array + AppendToCommandArrayL(EFileBrowserFileOpCommandRename, + new(ELeave)CCommandParamsRename(fileEntry, targetEntry, CFileMan::EOverWrite) + ); + } + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::SetAttributesL(TUint &aSetAttMask, TUint &aClearAttMask, TBool &aRecurse) + { + for (TInt i=0; iCount(); i++) + { + TFileEntry fileEntry = iCurrentSelectionList->At(i); + + // append the new command to the command array + if (fileEntry.iEntry.IsDir() && aRecurse) + { + AppendToCommandArrayL(EFileBrowserFileOpCommandAttribs, + new(ELeave)CCommandParamsAttribs(fileEntry, aSetAttMask, aClearAttMask, fileEntry.iEntry.iModified, CFileMan::ERecurse) + ); + } + else + { + AppendToCommandArrayL(EFileBrowserFileOpCommandAttribs, + new(ELeave)CCommandParamsAttribs(fileEntry, aSetAttMask, aClearAttMask, fileEntry.iEntry.iModified, 0) + ); + } + } + + // execute all operations + StartExecutingCommandsL(_L("Changing attributes")); + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::SearchL() + { +// iEngine->FileListContainer()->SetScreenLayoutL(EDisplayModeNormal); +// iEngine->FileListContainer()->SetNaviPaneTextL(KNullDesC); +// +// iEngine->FileListContainer()->SetScreenLayoutL(iEngine->Settings().iDisplayMode); +// iEngine->FileListContainer()->SetNaviPaneTextL(iCurrentPath); +// + iEngine->FileBrowserUI()->ShowWaitDialog(_L("Searching")); + iFileEntryList->Reset(); + + // if search dir is empty, find from all drives + if (iSearchAttributes.iSearchDir == KNullDesC) + { + for (TInt i=0; iCount(); i++) + { + TDriveEntry driveEntry = iDriveEntryList->At(i); + + TBuf<10> driveRoot; + driveRoot.Append(driveEntry.iLetter); + driveRoot.Append(_L(":\\")); + + DoSearchFiles(iSearchAttributes.iWildCards, driveRoot); + + if (iSearchAttributes.iRecurse) + DoSearchFilesRecursiveL(iSearchAttributes.iWildCards, driveRoot); + } + + } + + // otherwise just search from the selected directory + else + { + DoSearchFiles(iSearchAttributes.iWildCards, iSearchAttributes.iSearchDir); + + if (iSearchAttributes.iRecurse) + DoSearchFilesRecursiveL(iSearchAttributes.iWildCards, iSearchAttributes.iSearchDir); + } + + iEngine->FileBrowserUI()->CancelWaitDialog(); + + iListingMode = ESearchResults; + RefreshViewL(); + } + +// -------------------------------------------------------------------------------------------- + +TInt CFileBrowserFileUtils::DoSearchFiles(const TDesC& aFileName, const TDesC& aPath) + { + TFindFile fileFinder(iFs); + CDir* dir; + TInt err = fileFinder.FindWildByPath(aFileName, &aPath, dir); + iEngine->FileBrowserUI()->ProcessEvents(); + + while (err == KErrNone && iAllowProcessing) + { + iEngine->FileBrowserUI()->ProcessEvents(); + for (TInt i=0; iCount(); i++) + { + TEntry entry = (*dir)[i]; + + TTime entryModified = entry.iModified; + // convert from universal time + if ( iTz.ConvertToLocalTime( entryModified ) == KErrNone ) + { + entryModified = entry.iModified; + } + if ((entry.IsDir() && entryModified >= iSearchAttributes.iMinDate && entryModified <= iSearchAttributes.iMaxDate) || + (!entry.IsDir() &&entry.iSize >= iSearchAttributes.iMinSize && entry.iSize <= iSearchAttributes.iMaxSize && + entryModified >= iSearchAttributes.iMinDate && entryModified <= iSearchAttributes.iMaxDate)) + { + TParse parsedName; + parsedName.Set(entry.iName, &fileFinder.File(), NULL); + + if (parsedName.Drive().Length() && aPath.Length() && parsedName.Drive()[0] == aPath[0]) + { + TFileEntry fileEntry; + fileEntry.iPath = parsedName.DriveAndPath(); + fileEntry.iEntry = entry; + fileEntry.iDirEntries = KErrNotFound; + + TBool appendToArray(EFalse); + + // append directories always + if (entry.IsDir() && !iSearchAttributes.iTextInFile.Length()) + { + fileEntry.iIconId = EFixedIconFolder; + appendToArray = ETrue; + } + + // normal file + else + { + fileEntry.iIconId = EFixedIconEmpty; + + // check if a string needs to be found inside the file + if (iSearchAttributes.iTextInFile.Length()) + { + // currently only 8-bit searching, so convert from 16-bit + TBuf8<256> searchText; + searchText.Copy(iSearchAttributes.iTextInFile); + + // specify buffer size and create a buffer + const TInt KReadBufSize = 1024*1024; + HBufC8* buffer = HBufC8::NewLC(KReadBufSize); + TPtr8 bufferPtr = buffer->Des(); + + // open the file for reading + RFile file; + if (file.Open(iFs, parsedName.FullName(), EFileRead) == KErrNone) + { + TInt currentPos(0); + + for (;;) + { + // read from the file + file.Read(currentPos, bufferPtr, KReadBufSize); + + // stop looping if the read buffer isn't long enough + if (bufferPtr.Length() < searchText.Length()) + { + break; + } + + // try to find the text + if (bufferPtr.FindF(searchText) >= 0) + { + // match found! + appendToArray = ETrue; + break; + } + + // calculate the next position + currentPos += KReadBufSize - searchText.Length(); + } + + file.Close(); + } + + CleanupStack::PopAndDestroy(); //buffer + } + else + { + appendToArray = ETrue; + } + } + + if (appendToArray) + TRAP(err, iFileEntryList->AppendL(fileEntry)); + } + } + } + + delete dir; + err = fileFinder.FindWild(dir); + } + + return err; + } + +// -------------------------------------------------------------------------------------------- + +TInt CFileBrowserFileUtils::DoSearchFilesRecursiveL(const TDesC& aFileName, const TDesC& aPath) + { + TInt err(KErrNone); + CDirScan* scan = CDirScan::NewLC(iFs); + scan->SetScanDataL(aPath, KEntryAttDir|KEntryAttMatchMask, ESortByName | EAscending | EDirsFirst); + CDir* dir = NULL; + + for(;;) + { + TRAP(err, scan->NextL(dir)); + if (!dir || (err != KErrNone)) + break; + + for (TInt i=0; iCount(); i++) + { + TEntry entry = (*dir)[i]; + + if (entry.IsDir()) + { + TFileName path(scan->FullPath()); + + if (path.Length()) + { + path.Append(entry.iName); + path.Append(_L("\\")); + DoSearchFiles(aFileName, path); + } + } + } + delete(dir); + } + + CleanupStack::PopAndDestroy(scan); + return err; + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::NewFileL(const TFileName &aNewFileName) + { + TFileName fullPath = iCurrentPath; + fullPath.Append(aNewFileName); + + TParse nameParser; + User::LeaveIfError(nameParser.SetNoWild(fullPath, NULL, NULL)); + + // do not try to recreate the file if it already exists + if (BaflUtils::PathExists(iFs, nameParser.DriveAndPath())) + { + User::LeaveIfError(iFileOps->CreateEmptyFile(fullPath)); + } + else + { + User::Leave(KErrAlreadyExists); + } + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::NewDirectoryL(const TFileName &aNewDirectoryName) + { + TFileName fullPath = iCurrentPath; + fullPath.Append(aNewDirectoryName); + fullPath.Append(_L("\\")); + + User::LeaveIfError(iFileOps->MkDirAll(fullPath, 0, ETrue)); + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::SendToL() + { +// CFileEntryList* entries = new(ELeave) CFileEntryList(32); +// GetSelectedItemsOrCurrentItemL(entries); +// CleanupStack::PushL(entries); +// +// TInt operations(0); +// +// CSendUi* sendUi = CSendUi::NewL(); +// CleanupStack::PushL(sendUi); +// CMessageData* messageData = CMessageData::NewL(); +// CleanupStack::PushL(messageData); +// +// for (TInt i=0; iCount(); i++) +// { +// TFileEntry fileEntry = entries->At(i); +// +// // only supported for normal file entries +// if (!fileEntry.iEntry.IsDir()) +// { +// TFileName fullPath = fileEntry.iPath; +// fullPath.Append(fileEntry.iEntry.iName); +// +// messageData->AppendAttachmentL(fullPath); +// operations++; +// +// } +// } +// +// if (operations > 0) +// { +// sendUi->ShowQueryAndSendL(messageData, TSendingCapabilities(0, 0, TSendingCapabilities::ESupportsAttachments)); +// +// // I guess this note is not needed.. +//// _LIT(KMessage, "%d entries sent"); +//// TFileName noteMsg; +//// noteMsg.Format(KMessage, operations); +//// +//// iEngine->FileBrowserUI()->ShowConfirmationNote(noteMsg); +// } +// else +// { +// _LIT(KMessage, "Nothing to send"); +// iEngine->FileBrowserUI()->ShowInformationNote(KMessage, _L("")); +// } +// +// CleanupStack::PopAndDestroy(3); // entries, sendUi, messageData + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::CompressL() + { +// CFileEntryList* entries = new(ELeave) CFileEntryList(16); +// GetSelectedItemsOrCurrentItemL(entries); +// CleanupStack::PushL(entries); +// +// for (TInt i=0; iCount(); i++) +// { +// TFileEntry fileEntry = entries->At(i); +// +// TFileName sourceEntry = fileEntry.iPath; +// sourceEntry.Append(fileEntry.iEntry.iName); +// +// TFileName targetEntry = sourceEntry; +// targetEntry.Append(KGZipExt); +// +// TFileName targetEntryShort; +// targetEntryShort.Copy(fileEntry.iEntry.iName); +// targetEntryShort.Append(KGZipExt); +// +// if (BaflUtils::FileExists(iFs, targetEntry)) +// { +// _LIT(KMessage, "%S already exists"); +// TFileName noteMsg; +// noteMsg.Format(KMessage, &targetEntryShort); +// +// iEngine->FileBrowserUI()->ShowInformationNote(noteMsg, _L("")); +// } +// else +// { +// TRAPD(err, +// RFile inputFile; +// User::LeaveIfError(inputFile.Open(iFs, sourceEntry, EFileStream | EFileRead | EFileShareAny)); +// CleanupClosePushL(inputFile); +// +// CEZFileToGZip* gZip = CEZFileToGZip::NewLC(iFs, targetEntry, inputFile); +// +// while (gZip->DeflateL()) +// ; +// +// CleanupStack::PopAndDestroy(2); //inputFile, gZip +// ); +// +// if (err == KErrNone) +// { +// _LIT(KMessage, "%S created succesfully"); +// TFileName noteMsg; +// noteMsg.Format(KMessage, &targetEntryShort); +// +// iEngine->FileBrowserUI()->ShowConfirmationNote(noteMsg); +// } +// else +// { +// _LIT(KMessage, "Unable to create %S"); +// TFileName noteMsg; +// noteMsg.Format(KMessage, &targetEntryShort); +// +// iEngine->FileBrowserUI()->ShowErrorNote(noteMsg); +// } +// +// RefreshViewL(); +// } +// } +// +// CleanupStack::PopAndDestroy(); //entries + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::DecompressL() + { +// CFileEntryList* entries = new(ELeave) CFileEntryList(16); +// GetSelectedItemsOrCurrentItemL(entries); +// CleanupStack::PushL(entries); +// +// for (TInt i=0; iCount(); i++) +// { +// TFileEntry fileEntry = entries->At(i); +// +// TFileName sourceEntry = fileEntry.iPath; +// sourceEntry.Append(fileEntry.iEntry.iName); +// +// TFileName targetEntry; +// TFileName targetEntryShort; +// +// TInt sourceNameLen = fileEntry.iEntry.iName.Length(); +// TInt gZipExtLen = KGZipExt().Length(); +// +// if (sourceNameLen > gZipExtLen && sourceEntry.Right(gZipExtLen).CompareF(KGZipExt) == 0) +// { +// targetEntry = sourceEntry.Left(sourceEntry.Length() - gZipExtLen); +// targetEntryShort = fileEntry.iEntry.iName.Left(sourceNameLen - gZipExtLen); +// +// if (BaflUtils::FileExists(iFs, targetEntry)) +// { +// _LIT(KMessage, "%S already exists"); +// TFileName noteMsg; +// noteMsg.Format(KMessage, &targetEntryShort); +// +// iEngine->FileBrowserUI()->ShowInformationNote(noteMsg, _L("")); +// } +// else +// { +// TRAPD(err, +// RFile outputFile; +// User::LeaveIfError(outputFile.Create(iFs, targetEntry, EFileStream | EFileWrite | EFileShareExclusive)); +// CleanupClosePushL(outputFile); +// +// CEZGZipToFile* gZip = CEZGZipToFile::NewLC(iFs, sourceEntry, outputFile); +// +// while (gZip->InflateL()) +// ; +// +// CleanupStack::PopAndDestroy(2); //outputFile, gZip +// ); +// +// if (err == KErrNone) +// { +// _LIT(KMessage, "%S decompressed succesfully"); +// TFileName noteMsg; +// noteMsg.Format(KMessage, &fileEntry.iEntry.iName); +// +// iEngine->FileBrowserUI()->ShowConfirmationNote(noteMsg); +// } +// else +// { +// _LIT(KMessage, "Unable to decompress %S"); +// TFileName noteMsg; +// noteMsg.Format(KMessage, &fileEntry.iEntry.iName); +// +// iEngine->FileBrowserUI()->ShowErrorNote(noteMsg); +// } +// +// RefreshViewL(); +// } +// } +// else +// { +// _LIT(KMessage, "%S does not have %S extension"); +// TFileName noteMsg; +// noteMsg.Format(KMessage, &fileEntry.iEntry.iName, &KGZipExt); +// +// iEngine->FileBrowserUI()->ShowInformationNote(noteMsg, _L("")); +// } +// } +// +// CleanupStack::PopAndDestroy(); //entries + } + +// -------------------------------------------------------------------------------------------- + +TInt CFileBrowserFileUtils::GetFilesCount(const TFileName &aFullPath) + { + iFindFileEntryList->Reset(); + + SetAllowProcessing(ETrue); + DoFindFiles(_L("*"), aFullPath); + DoFindFilesRecursiveL(_L("*"), aFullPath); + SetAllowProcessing(EFalse); + + TInt filesCount = iFindFileEntryList->Count(); + + iFindFileEntryList->Reset(); + + return filesCount; + } + +// -------------------------------------------------------------------------------------------- + +TInt CFileBrowserFileUtils::GetFilesCountAndSize(const TFileName &aFullPath, TInt64 &aSize) + { + iFindFileEntryList->Reset(); + + SetAllowProcessing(ETrue); + DoFindFiles(_L("*"), aFullPath); + DoFindFilesRecursiveL(_L("*"), aFullPath); + SetAllowProcessing(EFalse); + + // number of files + TInt filesCount = iFindFileEntryList->Count(); + + // size + TInt64 size(0); + for (TInt i=0; iCount(); i++) + { + TFileEntry fileEntry = iFindFileEntryList->At(i); + size += fileEntry.iEntry.iSize; + } + aSize = size; + + iFindFileEntryList->Reset(); + + return filesCount; + } + +// -------------------------------------------------------------------------------------------- + +TInt CFileBrowserFileUtils::GetEntriesCount(const TFileName &aFullPath) + { + // number of entries + CDir* subDir = NULL; + TInt entriesCount = -1; + if (iFs.GetDir(aFullPath, KEntryAttMatchMask, ESortNone | EDirsFirst, subDir) == KErrNone) + { + entriesCount = subDir->Count(); + } + return entriesCount; + } + +// -------------------------------------------------------------------------------------------- + +TFileName CFileBrowserFileUtils::GetMimeType(const TFileName &aFullPath) + { + // mime type + TDataType dataType; + TUid appUid; + TBuf<128> mimeTypeBuf; + if (iEngine->LsSession().AppForDocument(aFullPath, appUid, dataType) == KErrNone) + { + mimeTypeBuf.Copy(dataType.Des8()); + if (mimeTypeBuf == KNullDesC) + mimeTypeBuf.Copy(_L("N/A")); + } + return mimeTypeBuf; + } + +// -------------------------------------------------------------------------------------------- + +TFileName CFileBrowserFileUtils::GetOpenWith(const TFileName &aFullPath) + { + // opens with + TDataType dataType; + TUid appUid; + TApaAppInfo appInfo; + TFileName opensWithBuf; + if (iEngine->LsSession().AppForDocument(aFullPath, appUid, dataType) == KErrNone) + { + if (iEngine->LsSession().GetAppInfo(appInfo, appUid) == KErrNone) + { + _LIT(KOpensWithFormat, "%S (0x%08X)"); + opensWithBuf.Format(KOpensWithFormat, &appInfo.iCaption, appInfo.iUid); + } + } + return opensWithBuf; + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::OpenWithApparcL(const TFileName &aFileName) + { + + TFileName fullPath = aFileName; + TInt err1(KErrNone), err2(KErrNone); + TUid appUid; + TDataType dataType; + TBool isProgram; + + + err1 = iEngine->LsSession().AppForDocument(fullPath, appUid, dataType); + err2 = iEngine->LsSession().IsProgram(fullPath, isProgram); + + if (err1 == KErrNone && err2 == KErrNone) + { + if (appUid != KNullUid) + { + // found an app, run using it + TApaTaskList taskList(CEikonEnv::Static()->WsSession()); + TApaTask task = (taskList.FindApp(appUid)); + if (task.Exists()) + { + User::LeaveIfError(task.SwitchOpenFile(fullPath)); + task.BringToForeground(); + } + else + { + TThreadId id; + iEngine->LsSession().StartDocument(fullPath, appUid, id, RApaLsSession::ESwitchFiles); + } + } + else if (isProgram) + { + LaunchProgramL(fullPath); + } + } + //} + } + +// -------------------------------------------------------------------------------------------- + +//void CFileBrowserFileUtils::HandleServerAppExit(TInt aReason) +// { +// if (iOpenFileService) +// { +// delete iOpenFileService; +// iOpenFileService = NULL; +// } +// MAknServerAppExitObserver::HandleServerAppExit(aReason); +// } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::OpenWithDocHandlerL(const TFileName &aFileName, TBool aEmbed) + { + TFileName fullPath = aFileName; + RFile sharableFile; + iDocHandler->OpenTempFileL(fullPath, sharableFile); + CleanupClosePushL(sharableFile); + TDataType dataType; + if (aEmbed) + { + iDocHandler->OpenFileEmbeddedL(sharableFile, dataType); + } + else + { + iDocHandler->OpenFileL(sharableFile, dataType); + } + CleanupStack::PopAndDestroy(); //sharableFile + // } + } + + // -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::OpenWithFileServiceL(TInt aCurrentItemIndex) + { + if (iFileEntryList->Count() > aCurrentItemIndex && aCurrentItemIndex >= 0) + { + TFileEntry fileEntry = iFileEntryList->At(aCurrentItemIndex); + + TFileName fullPath = fileEntry.iPath; + fullPath.Append(fileEntry.iEntry.iName); + +// TBool itemSelected(EFalse); + RFile sharableFile; +// TUid appUidExtracted; + + TRAPD(err, + + // use doc handler to get a sharable file handle + iDocHandler->OpenTempFileL(fullPath, sharableFile); + CleanupClosePushL(sharableFile); + + // find the data type + TDataRecognitionResult dataType; + User::LeaveIfError(iEngine->LsSession().RecognizeData(sharableFile, dataType)); + + // get all apps that support OpenFileService for this datatype + CApaAppServiceInfoArray* apps = iEngine->LsSession().GetServiceImplementationsLC(KOpenServiceUid, dataType.iDataType); + TArray appServiceInfos = apps->Array(); + + if (appServiceInfos.Count() > 0) + { + // build an array of the app names + CDesCArray* names = new (ELeave) CDesCArrayFlat(16); + CleanupStack::PushL(names); + for (TInt ii=0; iiLsSession().GetAppInfo(appInfo, appUid) == KErrNone) + { + names->AppendL(appInfo.iCaption); + } + else + { + TBuf<10> buf; + buf.Format(_L("0x%08x"), appUid); + names->AppendL(buf); + } + } + + // use a list query to select the app +// TInt index(0); +// CAknListQueryDialog* dlg = new(ELeave) CAknListQueryDialog(&index); +// dlg->PrepareLC(R_APP_SELECTION_QUERY); +// dlg->SetItemTextArray(names); +// dlg->SetOwnershipType(ELbmDoesNotOwnItemArray); +// +// if(dlg->RunLD()) +// { +// // extract the chosen UID +// appUidExtracted = appServiceInfos[index].Uid(); +// itemSelected = ETrue; +// } + + CleanupStack::PopAndDestroy(); // names + } + +// if (itemSelected) +// { +// // start OpenFileService for the selected app +// CAiwGenericParamList& paramList = iDocHandler->InParamListL(); +// (void)paramList; +// if (iOpenFileService) +// { +// delete iOpenFileService; +// iOpenFileService = NULL; +// } +// +// iOpenFileService = CAknOpenFileService::NewL(appUidExtracted, sharableFile, this, ¶mList); +// } + + CleanupStack::PopAndDestroy(2); // sharableFile, apps + + ); // TRAPD + + if (err != KErrNone) + { + _LIT(KMessage, "No file service available for %S"); + TFileName noteMsg; + noteMsg.Format(KMessage, &fileEntry.iEntry.iName); + + iEngine->FileBrowserUI()->ShowInformationNote(noteMsg, _L("")); + } + } + } + +// -------------------------------------------------------------------------------------------- + +TBool CFileBrowserFileUtils::FileExists(const TDesC& aPath) + { + return BaflUtils::FileExists(iFs, aPath); + } + +// -------------------------------------------------------------------------------------------- + +TInt CFileBrowserFileUtils::LaunchProgramL(const TDesC& aPath) + { + CApaCommandLine* commandLine = CApaCommandLine::NewLC(); + commandLine->SetExecutableNameL(aPath); + commandLine->SetCommandL(EApaCommandRun); + TInt err = iEngine->LsSession().StartApp(*commandLine); + CleanupStack::PopAndDestroy(); //commandLine + return err; + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::MemoryInfoPopupL() + { + _LIT(KUsedBytesEntry, "Used: %S bytes\n"); + _LIT(KFreeBytesEntry, "Free: %S bytes\n"); + _LIT(KSizeBytesEntry, "Size: %S bytes\n"); + + HBufC* messageBuf = HBufC::NewLC(2048); + TPtr messagePtr = messageBuf->Des(); + TBuf<128> entryLine; + + // RAM + TMemoryInfoV1Buf ramMemory; + UserHal::MemoryInfo(ramMemory); + messagePtr.Append(_L("RAM\n")); + + // used + TBuf<32> usedBuf; + usedBuf.AppendNum(ramMemory().iMaxFreeRamInBytes-ramMemory().iFreeRamInBytes, TRealFormat(KDefaultRealWidth, 0)); + entryLine.Format(KUsedBytesEntry, &usedBuf); + messagePtr.Append(entryLine); + + // free + TBuf<32> freeBuf; + freeBuf.AppendNum(ramMemory().iFreeRamInBytes, TRealFormat(KDefaultRealWidth, 0)); + entryLine.Format(KFreeBytesEntry, &freeBuf); + messagePtr.Append(entryLine); + + // size + TBuf<32> sizeBuf; + sizeBuf.AppendNum(ramMemory().iMaxFreeRamInBytes, TRealFormat(KDefaultRealWidth, 0)); + entryLine.Format(KSizeBytesEntry, &sizeBuf); + messagePtr.Append(entryLine); + + // All drives + for (TInt i=0; iCount(); i++) + { + TDriveEntry driveEntry = iDriveEntryList->At(i); + + messagePtr.Append(_L("\n")); + messagePtr.Append(driveEntry.iLetter); + messagePtr.Append(_L(":\n")); + + // used + TBuf<32> usedBuf; + usedBuf.AppendNum(driveEntry.iVolumeInfo.iSize-driveEntry.iVolumeInfo.iFree, TRealFormat(KDefaultRealWidth, 0)); + entryLine.Format(KUsedBytesEntry, &usedBuf); + messagePtr.Append(entryLine); + + // free + TBuf<32> freeBuf; + freeBuf.AppendNum(driveEntry.iVolumeInfo.iFree, TRealFormat(KDefaultRealWidth, 0)); + entryLine.Format(KFreeBytesEntry, &freeBuf); + messagePtr.Append(entryLine); + + // size + TBuf<32> sizeBuf; + sizeBuf.AppendNum(driveEntry.iVolumeInfo.iSize, TRealFormat(KDefaultRealWidth, 0)); + entryLine.Format(KSizeBytesEntry, &sizeBuf); + messagePtr.Append(entryLine); + } + +// CAknMessageQueryDialog* dialog = new(ELeave) CAknMessageQueryDialog; +// dialog->PrepareLC(R_MEMORYINFO_DIALOG); +// dialog->SetMessageTextL(messagePtr); +// dialog->RunLD(); + + CleanupStack::PopAndDestroy(); //messageBuf + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::ShowFileCheckSumsL(TInt aCurrentItemIndex, TInt aType) + { + if (iFileEntryList->Count() > aCurrentItemIndex && aCurrentItemIndex >= 0) + { + TFileEntry fileEntry = iFileEntryList->At(aCurrentItemIndex); + TFileName fullPath = fileEntry.iPath; + fullPath.Append(fileEntry.iEntry.iName); + + // try to open the file for reading + RFile fileP; + User::LeaveIfError(fileP.Open(iEngine->EikonEnv()->FsSession(), + fullPath, + EFileRead|EFileShareReadersOnly)); + + CleanupClosePushL(fileP); + + TBuf<128> checkSum; + HBufC* messageBuf = HBufC::NewLC(2048); + TPtr messagePtr = messageBuf->Des(); + + // get MD5 checksum + if (aType == EFileChecksumsMD5) + { + CMD5* md5 = CMD5::NewL(); + CleanupStack::PushL(md5); + HBufC8* md5Buf = MessageDigestInHexLC(md5, fileP); + checkSum.Copy(*md5Buf); + messagePtr.Append(_L("MD5\n")); + messagePtr.Append(checkSum); + CleanupStack::PopAndDestroy(2); // md5, md5Buf + } + + // get MD2 checksum + else if (aType == EFileChecksumsMD2) + { + CMD2* md2 = CMD2::NewL(); + CleanupStack::PushL(md2); + HBufC8* md2Buf = MessageDigestInHexLC(md2, fileP); + checkSum.Copy(*md2Buf); + messagePtr.Append(_L("MD2\n")); + messagePtr.Append(checkSum); + CleanupStack::PopAndDestroy(2); // md2, md2Buf + } + + // get SHA-1 checksum + else if (aType == EFileChecksumsSHA1) + { + CSHA1* sha1 = CSHA1::NewL(); + CleanupStack::PushL(sha1); + HBufC8* sha1Buf = MessageDigestInHexLC(sha1, fileP); + checkSum.Copy(*sha1Buf); + messagePtr.Append(_L("SHA-1\n")); + messagePtr.Append(checkSum); + CleanupStack::PopAndDestroy(2); // sha1, sha1Buf + } + + else + { + User::Panic(_L("Inv.CS.Type"), 723); + } + + // show dialog + iEngine->FileBrowserUI()->ShowInformationNote(messagePtr, fileEntry.iEntry.iName); + + CleanupStack::PopAndDestroy(2); // messageBuf, fileP + } + } + +// -------------------------------------------------------------------------------------------- + +HBufC8* CFileBrowserFileUtils::MessageDigestInHexLC(CMessageDigest* aMD, RFile& aFile) + { + // seek to file start + TInt startPos(0); + aFile.Seek(ESeekStart, startPos); + + // create result buffer + HBufC8* result = HBufC8::NewLC(128); + + const TInt KBufSize(1024); + TInt fileSize(0); + TInt fileOffset(0); + + // get file size + aFile.Size(fileSize); + + HBufC8* buf = HBufC8::NewMaxLC(KBufSize); + TPtr8 bufPtr(buf->Des()); + + // read to buffer + while (fileOffset < fileSize - KBufSize) + { + aFile.Read(bufPtr, KBufSize); + aMD->Hash(bufPtr); + fileOffset += bufPtr.Length(); + } + + aFile.Read(bufPtr, fileSize - fileOffset); + bufPtr.SetLength(fileSize - fileOffset); + + // get final message digest + TPtrC8 hashedSig(aMD->Final(bufPtr)); + + // change size of the result buffer + result->ReAllocL(hashedSig.Length() * 2); + TPtr8 resultPtr = result->Des(); + + // convert to hex format + for (TInt i=0; iSettings().iBypassPlatformSecurity) + { + TInt err(KErrNone); + + if (aEnable) + { + // make sure that the directory exists + iFileOps->MkDirAll(KErrRdPath); + + // create the file + err = iFileOps->CreateEmptyFile(KErrRdPath); + } + else + { + // get TEntry of ErrRd + TEntry entry; + err = iFs.Entry(KErrRdPath, entry); + + if (err == KErrNone) + { + TFileEntry fileEntry; + fileEntry.iPath = KErrRdDir; + fileEntry.iEntry = entry; + + err = iFileOps->Delete(fileEntry); + } + } + + // update view + RefreshViewL(); + + if (err == KErrNone) + { + iEngine->FileBrowserUI()->ShowConfirmationNote(_L("State changed")); + } + else + { + iEngine->FileBrowserUI()->ShowErrorNote(_L("Cannot change the state")); + } + } + else + { + iEngine->FileBrowserUI()->ShowInformationNote(_L("Enable \"bypass platform security\" from the settings first"), _L("")); + } + #else + aEnable = aEnable; + iEngine->FileBrowserUI()->ShowInformationNote(_L("Not supported in lite version"), _L("")); + #endif + } + +// -------------------------------------------------------------------------------------------- + +//void CFileBrowserFileUtils::EnableAvkonIconCacheL(TBool aEnable) +// { +//#ifndef __SERIES60_30__ +// if (AknIconConfig::EnableAknIconSrvCache(aEnable) == KErrNone) +// { +// iEngine->FileBrowserUI()->ShowConfirmationNote(_L("State changed")); +// } +// else +// { +// iEngine->FileBrowserUI()->ShowErrorNote(_L("Unknown error occured")); +// } +// #else +// aEnable = aEnable; +// iEngine->FileBrowserUI()->ShowInformationNote(_L("Not supported in S60 3.0"), _L("")); +// #endif +// +// } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::SimulateLeaveL(TInt aLeaveCode) + { + User::Leave(aLeaveCode); + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::SimulatePanicL(const TDesC& aPanicCategory, TInt aPanicCode) + { + User::Panic(aPanicCategory, aPanicCode); + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::SimulateExceptionL(TInt aExceptionCode) + { + User::RaiseException((TExcType)aExceptionCode); + } + +// -------------------------------------------------------------------------------------------- + +TUint32 CFileBrowserFileUtils::GetDebugMask() + { + return UserSvr::DebugMask(); + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::SetDebugMaskL(TUint32 aDbgMask) + { + User::SetDebugMask(aDbgMask); + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::WriteAllAppsL() + { + _LIT(KAllAppsFileName, "AllApps.txt"); + TFileName allAppsPath = PathInfo::PhoneMemoryRootPath(); + allAppsPath.Append(KAllAppsFileName); + + RFile file; + if (file.Replace(iFs, allAppsPath, EFileWrite) == KErrNone) + { + CleanupClosePushL(file); + + CDesC8Array* appsArray = new(ELeave) CDesC8ArrayFlat(192); + CleanupStack::PushL(appsArray); + + TBuf8 fileEntry; + TBuf8 appFullPath; + _LIT8(KAppEntryFormat, "%S (0x%08X)%S"); + TApaAppInfo appInfo; + + iEngine->LsSession().GetAllApps(); + + while (iEngine->LsSession().GetNextApp(appInfo) == KErrNone) + { + appFullPath.Copy(appInfo.iFullName); + fileEntry.Format(KAppEntryFormat, &appFullPath, appInfo.iUid, &KFileNewLine); + appsArray->AppendL(fileEntry); + } + + appsArray->Sort(); + + for (TInt i=0; iCount(); i++) + { + file.Write(appsArray->MdcaPoint(i)); + } + + CleanupStack::PopAndDestroy(2); //appsArray, file + + _LIT(KMessage, "App list written to %S"); + TFileName noteMsg; + noteMsg.Format(KMessage, &allAppsPath); + + iEngine->FileBrowserUI()->ShowConfirmationNote(noteMsg, ETrue); // NoTimeout + } + else + { + _LIT(KMessage, "Failed writing to %S"); + TFileName noteMsg; + noteMsg.Format(KMessage, &allAppsPath); + + iEngine->FileBrowserUI()->ShowErrorNote(noteMsg, ETrue); // NoTimeout + } + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::WriteAllFilesL() + { + _LIT(KAllFilesFileName, "AllFiles.txt"); + TFileName allFilesPath = PathInfo::PhoneMemoryRootPath(); + allFilesPath.Append(KAllFilesFileName); + + RFile file; + if (file.Replace(iFs, allFilesPath, EFileWrite) == KErrNone) + { + CleanupClosePushL(file); + iFindFileEntryList->Reset(); + + iEngine->FileBrowserUI()->ShowWaitDialog(_L("Generating")); + + for (TInt i=0; iCount(); i++) + { + TDriveEntry driveEntry = iDriveEntryList->At(i); + + TBuf<10> driveRoot; + driveRoot.Append(driveEntry.iLetter); + driveRoot.Append(_L(":\\")); + + // current dir + DoFindFiles(_L("*"), driveRoot); + + // recurse into sub directories + DoFindFilesRecursiveL(_L("*"), driveRoot); + } + + // write entries + TBuf8 writeBuf; + for (TInt i=0; iCount(); i++) + { + TFileEntry fileEntry = iFindFileEntryList->At(i); + + writeBuf.Copy(fileEntry.iPath); + writeBuf.Append(fileEntry.iEntry.iName); + writeBuf.Append(_L(",")); + writeBuf.AppendNum(fileEntry.iEntry.iSize); + writeBuf.Append(_L(" B")); + +// // date +// TTime entryModified = fileEntry.iEntry.iModified; +// // convert from universal time +// if ( iTz.ConvertToLocalTime( entryModified ) == KErrNone ) +// { +// entryModified = fileEntry.iEntry.iModified; // use universal time +// } +// +// _LIT(KDateFormat, "%D%M%Y%/0%1%/1%2%/2%3%/3"); +// TBuf<32> dateBuf; +// entryModified.FormatL(dateBuf, KDateFormat); +// writeBuf.Append(dateBuf); +// +// writeBuf.Append(_L(" ")); +// // time +// _LIT(KTimeFormat, "%-B%:0%J%:1%T%:2%S%:3%+B"); +// TBuf<32> timeBuf; +// entryModified.FormatL(timeBuf, KTimeFormat); +// writeBuf.Append(timeBuf); +// + writeBuf.Append(KFileNewLine); + file.Write(writeBuf); + } + + iEngine->FileBrowserUI()->CancelWaitDialog(); + + CleanupStack::PopAndDestroy(); //file + iFindFileEntryList->Reset(); + + _LIT(KMessage, "File list written to %S"); + TFileName noteMsg; + noteMsg.Format(KMessage, &allFilesPath); + + iEngine->FileBrowserUI()->ShowConfirmationNote(noteMsg, EFalse); // NoTimeout + } + else + { + _LIT(KMessage, "Failed writing to %S"); + TFileName noteMsg; + noteMsg.Format(KMessage, &allFilesPath); + + iEngine->FileBrowserUI()->ShowErrorNote(noteMsg, ETrue); // NoTimeout + } + } + +// -------------------------------------------------------------------------------------------- + +TInt CFileBrowserFileUtils::DoFindFiles(const TDesC& aFileName, const TDesC& aPath) + { + TFindFile fileFinder(iFs); + CDir* dir; + TInt err = fileFinder.FindWildByPath(aFileName, &aPath, dir); + + while (err == KErrNone && iAllowProcessing) + { + iEngine->FileBrowserUI()->ProcessEvents(); + for (TInt i=0; iCount(); i++) + { + TEntry entry = (*dir)[i]; + + // ignore any directory entries + if (!entry.IsDir() && entry.iName.Length() && aPath.Length()) + { + TParse parsedName; + parsedName.Set(entry.iName, &fileFinder.File(), NULL); + + if (parsedName.Drive().Length() && aPath.Length() && parsedName.Drive()[0] == aPath[0]) + { + TFileEntry fileEntry; + fileEntry.iPath = parsedName.DriveAndPath(); + fileEntry.iEntry = entry; + fileEntry.iDirEntries = KErrNotFound; + fileEntry.iIconId = EFixedIconEmpty; + + TRAP(err, iFindFileEntryList->AppendL(fileEntry)); + } + } + } + + delete dir; + dir = NULL; + err = fileFinder.FindWild(dir); + } + + return err; + } + +// -------------------------------------------------------------------------------------------- + +TInt CFileBrowserFileUtils::DoFindFilesRecursiveL(const TDesC& aFileName, const TDesC& aPath) + { + TInt err(KErrNone); + CDirScan* scan = CDirScan::NewLC(iFs); + scan->SetScanDataL(aPath, KEntryAttDir|KEntryAttMatchMask, ESortByName | EAscending | EDirsFirst); + CDir* dir = NULL; + + for(;;) + { + TRAP(err, scan->NextL(dir)); + if (!dir || (err != KErrNone)) + break; + + for (TInt i=0; iCount(); i++) + { + TEntry entry = (*dir)[i]; + + if (entry.IsDir()) + { + TFileName path(scan->FullPath()); + + if (path.Length()) + { + path.Append(entry.iName); + path.Append(_L("\\")); + DoFindFiles(aFileName, path); + } + } + } + delete(dir); + } + + CleanupStack::PopAndDestroy(scan); + return err; + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::ListOpenFilesL() + { + iFileEntryList->Reset(); + + CFileList* dir = NULL; + TOpenFileScan fileScan(iFs); + fileScan.NextL(dir); + + while (dir) + { + for (TInt i=0; iCount(); i++) + { + TEntry entry = (*dir)[i]; + TFileName fullPath; + + // TOpenFileScan does not return drive letters for the entries, so try to guess it + if (entry.iName.Length() > 2 && entry.iName[1] != ':') + { + for (TInt i=0; iCount(); i++) + { + TDriveEntry driveEntry = iDriveEntryList->At(i); + + TFileName guessPath; + guessPath.Append(driveEntry.iLetter); + guessPath.Append(_L(":")); + guessPath.Append(entry.iName); + + // check if the file exists + if (BaflUtils::FileExists(iFs, guessPath)) + { + // if it's on read only drive, then take it or check if it's really in use + TBool readOnlyDrive(ETrue); + BaflUtils::DiskIsReadOnly(iFs, guessPath, readOnlyDrive); + + if (readOnlyDrive || iFs.SetEntry(guessPath, entry.iModified, NULL, NULL) == KErrInUse) + { + fullPath = guessPath; + break; + } + } + } + } + else + { + fullPath = entry.iName; + } + + TParse nameParser; + if (fullPath.Length() && nameParser.SetNoWild(fullPath, NULL, NULL) == KErrNone) + { + entry.iName = nameParser.NameAndExt(); + + TFileEntry fileEntry; + fileEntry.iPath = nameParser.DriveAndPath(); + fileEntry.iEntry = entry; + fileEntry.iDirEntries = KErrNotFound; + fileEntry.iIconId = EFixedIconEmpty; + + iFileEntryList->AppendL(fileEntry); + } + } + + delete dir; + dir = NULL; + fileScan.NextL(dir); + } + + TInt operations = iFileEntryList->Count(); + + iListingMode = EOpenFiles; + // TODO + //iEngine->FileListContainer()->ListBox()->SetCurrentItemIndex(0); + RefreshViewL(); + + _LIT(KMessage, "%d open files found"); + TFileName noteMsg; + noteMsg.Format(KMessage, operations); + + iEngine->FileBrowserUI()->ShowInformationNote(noteMsg, _L("")); + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::ListMessageAttachmentsL(TInt aType) + { + iFileEntryList->Reset(); + + CMsvSession* session = CMsvSession::OpenSyncL(*this); + CleanupStack::PushL(session); + + CMsvEntry* context = NULL; + + if (aType == EFileBrowserCmdToolsMsgAttachmentsInbox) + context = session->GetEntryL(KMsvGlobalInBoxIndexEntryId); + else if (aType == EFileBrowserCmdToolsMsgAttachmentsDrafts) + context = session->GetEntryL(KMsvDraftEntryId); + else if (aType == EFileBrowserCmdToolsMsgAttachmentsSentItems) + context = session->GetEntryL(KMsvSentEntryId); + else if (aType == EFileBrowserCmdToolsMsgAttachmentsOutbox) + context = session->GetEntryL(KMsvGlobalOutBoxIndexEntryId); + else + User::Panic(_L("MsgAtt.Mode"), 100); + + CleanupStack::PushL(context); + + CDesCArray* attPaths = new(ELeave) CDesCArrayFlat(128); + CleanupStack::PushL(attPaths); + + // read attachment paths + ReadAttachmentPathsRecursiveL(session, context, attPaths); + + // create file entries of the paths + for (TInt i=0; iMdcaCount(); i++) + { + TFileEntry fileEntry; + TEntry entry; + TParse nameParser; + + if (attPaths->MdcaPoint(i).Length() && + nameParser.SetNoWild(attPaths->MdcaPoint(i), NULL, NULL) == KErrNone && + iFs.Entry(attPaths->MdcaPoint(i), entry) == KErrNone) + { + TFileEntry fileEntry; + fileEntry.iPath = nameParser.DriveAndPath(); + fileEntry.iEntry = entry; + fileEntry.iDirEntries = KErrNotFound; + fileEntry.iIconId = EFixedIconEmpty; + + iFileEntryList->AppendL(fileEntry); + } + } + + CleanupStack::PopAndDestroy(3); //session, context, attPaths + + TInt operations = iFileEntryList->Count(); + + if (aType == EFileBrowserCmdToolsMsgAttachmentsInbox) + iListingMode = EMsgAttachmentsInbox; + else if (aType == EFileBrowserCmdToolsMsgAttachmentsDrafts) + iListingMode = EMsgAttachmentsDrafts; + else if (aType == EFileBrowserCmdToolsMsgAttachmentsSentItems) + iListingMode = EMsgAttachmentsSentItems; + else if (aType == EFileBrowserCmdToolsMsgAttachmentsOutbox) + iListingMode = EMsgAttachmentsOutbox; + + // TODO + //iEngine->FileListContainer()->ListBox()->SetCurrentItemIndex(0); + RefreshViewL(); + + _LIT(KMessage, "%d files found"); + TFileName noteMsg; + noteMsg.Format(KMessage, operations); + + iEngine->FileBrowserUI()->ShowInformationNote(noteMsg, _L("")); + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::ReadAttachmentPathsRecursiveL(CMsvSession* aSession, CMsvEntry* aContext, CDesCArray* aAttPaths) + { + CMsvEntrySelection* entrySelection = aContext->ChildrenL(); + CleanupStack::PushL(entrySelection); + + for (TInt i=0; iCount(); i++) + { + CMsvEntry* entry = aSession->GetEntryL((*entrySelection)[i]); + CleanupStack::PushL(entry); + + CMsvStore* store = NULL; + TRAPD(err, store = entry->ReadStoreL()); + + if (err == KErrNone) + { + CleanupStack::PushL(store); + + for (TInt j=0; jAttachmentManagerL().AttachmentCount(); j++) + { + CMsvAttachment* attachment = store->AttachmentManagerL().GetAttachmentInfoL(j); + CleanupStack::PushL(attachment); + + aAttPaths->AppendL(attachment->FilePath()); + + CleanupStack::PopAndDestroy(); //attachment + } + CleanupStack::PopAndDestroy(); // store + } + + // recurse into children + if (entry->Count() > 0) + { + ReadAttachmentPathsRecursiveL(aSession, entry, aAttPaths); + } + + CleanupStack::PopAndDestroy(); // entry + } + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::WriteMsgStoreWalkL() + { + _LIT(KAllAppsFileName, "MsgStoreWalk.txt"); + TFileName allAppsPath = PathInfo::PhoneMemoryRootPath(); + allAppsPath.Append(KAllAppsFileName); + + if (iMsgStoreWalkFile.Replace(iFs, allAppsPath, EFileWrite) == KErrNone) + { + CMsvSession* session = CMsvSession::OpenSyncL(*this); + CleanupStack::PushL(session); + + CMsvEntry* context = session->GetEntryL(KMsvRootIndexEntryId); + CleanupStack::PushL(context); + + iMsgStoreWalkFile.Write(_L8("id service_id related_id type mtm date size error biotype mtmdata1 mtmdata2 mtmdata3 description details\r\n\r\n")); + + // write details about the root entry + DoWriteMessageEntryInfoL(context, iMsgStoreWalkFile, 0); + + // get and write info recursively + TInt level(1); + WriteMessageEntryInfoRecursiveL(session, context, iMsgStoreWalkFile, level); + + CleanupStack::PopAndDestroy(2); //session, context + + iMsgStoreWalkFile.Flush(); + iMsgStoreWalkFile.Close(); + + _LIT(KMessage, "Msg. store walk written to %S"); + TFileName noteMsg; + noteMsg.Format(KMessage, &allAppsPath); + + iEngine->FileBrowserUI()->ShowConfirmationNote(noteMsg, ETrue); // NoTimeout + } + else + { + _LIT(KMessage, "Failed writing to %S"); + TFileName noteMsg; + noteMsg.Format(KMessage, &allAppsPath); + + iEngine->FileBrowserUI()->ShowErrorNote(noteMsg, ETrue); // NoTimeout + } + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::WriteMessageEntryInfoRecursiveL(CMsvSession* aSession, CMsvEntry* aContext, RFile& aFile, TInt& aLevel) + { + CMsvEntrySelection* entrySelection = aContext->ChildrenL(); + CleanupStack::PushL(entrySelection); + + for (TInt i=0; iCount(); i++) + { + CMsvEntry* entry = aSession->GetEntryL((*entrySelection)[i]); + CleanupStack::PushL(entry); + + DoWriteMessageEntryInfoL(entry, aFile, aLevel); + + // recurse into children + if (entry->Count() > 0) + { + aLevel++; + WriteMessageEntryInfoRecursiveL(aSession, entry, aFile, aLevel); + aLevel--; + } + + CleanupStack::PopAndDestroy(); // entry + } + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::DoWriteMessageEntryInfoL(CMsvEntry* aContext, RFile& aFile, TInt aLevel) + { + TMsvEntry messageEntry = aContext->Entry(); + + for (TInt j=0; j desc; + desc.Copy(messageEntry.iDescription); + + TBuf8<256> details; + details.Copy(messageEntry.iDetails); + + _LIT8(KLine, "-> %d %d %d %d %d %Ld %d %d %d %d %d %d %S %S\r\n"); + TBuf8<1024> buf; + buf.Format(KLine, messageEntry.Id(), messageEntry.iServiceId, messageEntry.iRelatedId, messageEntry.iType.iUid, + messageEntry.iMtm.iUid, messageEntry.iDate.Int64(), messageEntry.iSize, messageEntry.iError, messageEntry.iBioType, + messageEntry.iMtmData1, messageEntry.iMtmData2, messageEntry.iMtmData3, &desc, &details); + + aFile.Write(buf); + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::HandleSessionEventL(TMsvSessionEvent /*aEvent*/, TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/) + { + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::FileEditorL(TInt aCurrentItemIndex, TInt /*aType*/) + { + // TODO + // just get current item + //TInt currentItemIndex = iEngine->QueryCurrentItemIndex(); + + if (iFileEntryList->Count() > aCurrentItemIndex && aCurrentItemIndex >= 0) + { + TFileEntry fileEntry = iFileEntryList->At(aCurrentItemIndex); + + // only valid for files + if (!fileEntry.iEntry.IsDir()) + { + TFileName fullPath = fileEntry.iPath; + fullPath.Append(fileEntry.iEntry.iName); + +// iEngine->FileListContainer()->SetNaviPaneTextL(fileEntry.iEntry.iName); +// +// TInt editorMode(0); +// +// if (aType == EFileBrowserCmdFileViewText) +// editorMode = EFileEditorViewAsText; +// else if (aType == EFileBrowserCmdFileViewHex) +// editorMode = EFileEditorViewAsHex; +// else if (aType == EFileBrowserCmdFileEditText) +// editorMode = EFileEditorEditAsText; +// else if (aType == EFileBrowserCmdFileEditHex) +// editorMode = EFileEditorEditAsHex; +// else +// User::Panic(_L("Inv.Ed.Mode"), 843); +// +// // launch dialog +// CFileBrowserFileEditorDlg* dlg = CFileBrowserFileEditorDlg::NewL(fullPath, editorMode); +// dlg->RunDlgLD(); +// +// iEngine->FileListContainer()->SetNaviPaneTextL(iCurrentPath); +// +// if (aType == EFileBrowserCmdFileEditText || aType == EFileBrowserCmdFileEditHex) +// { +// RefreshViewL(); +// } + } + } + } + +// -------------------------------------------------------------------------------------------- + +TBool CFileBrowserFileUtils::DriveSnapShotPossible() + { +// // TODO +// // check that E-drive is available +// TBool EDriveIsOK(EFalse); +// +// for (TInt i=0; iCount(); i++) +// { +// TDriveEntry driveEntry = iDriveEntryList->At(i); +// +// if (driveEntry.iNumber == EDriveE) +// { +// if (driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttLocked || driveEntry.iVolumeInfo.iDrive.iDriveAtt & KDriveAbsent) +// EDriveIsOK = EFalse; +// else +// EDriveIsOK = ETrue; +// } +// } +// +// if (!EDriveIsOK) +// return EFalse; +// +// // get current item +// TInt currentItemIndex = iEngine->QueryCurrentItemIndex(); +// +// if (iDriveEntryList->Count() > currentItemIndex && currentItemIndex >= 0) +// { +// TDriveEntry driveEntry = iDriveEntryList->At(currentItemIndex); +// +// // drive snapshot not possible when E-drive is highlighted, since that's where we are copying +// if (driveEntry.iNumber == EDriveE) +// return EFalse; +// else +// return ETrue; +// } + return EFalse; + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::DriveSnapShotL() + { +// if (iEngine->Settings().iBypassPlatformSecurity) +// { +// // get current item +// TInt currentItemIndex = iEngine->QueryCurrentItemIndex(); +// +// if (iDriveEntryList->Count() > currentItemIndex && currentItemIndex >= 0) +// { +// TDriveEntry driveEntry = iDriveEntryList->At(currentItemIndex); +// +// TChar sourceDriveLetter = driveEntry.iLetter; +// TChar targetDriveLetter = 'E'; // hardcoded drive letter, could be better if would be queried from the user +// +// // append to the command array +// AppendToCommandArrayL(EFileBrowserFileOpCommandDriveSnapShot, +// new(ELeave)CCommandParamsDriveSnapShot(sourceDriveLetter, targetDriveLetter) +// ); +// +// // execute the operation +// StartExecutingCommandsL(_L("Copying")); +// } +// } +// else +// { +// iEngine->FileBrowserUI()->ShowInformationNote(_L("Enable \"bypass platform security\" from the settings first"), _L("")); +// } + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::SetDrivePasswordL(TInt aIndex, + const TFileName &aOldPassword, + const TFileName &aNewPassword) + { + if (iDriveEntryList->Count() > aIndex && aIndex >= 0) + { + TMediaPassword oldPassword; + TMediaPassword newPassword; + + TDriveEntry driveEntry = iDriveEntryList->At(aIndex); + + ConvertCharsToPwd(aOldPassword, oldPassword); + ConvertCharsToPwd(aNewPassword, newPassword); + + // set the password, does not actually lock the drive + User::LeaveIfError(iFs.LockDrive(driveEntry.iNumber, oldPassword, newPassword, ETrue)); + } + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::UnlockDriveL(TInt aIndex, const TFileName &aOldPassword) + { + if (iDriveEntryList->Count() > aIndex && aIndex >= 0) + { + TDriveEntry driveEntry = iDriveEntryList->At(aIndex); + + TMediaPassword oldPassword; + ConvertCharsToPwd(aOldPassword, oldPassword); + + // unlock the drive + User::LeaveIfError(iFs.UnlockDrive(driveEntry.iNumber, oldPassword, ETrue)); + } + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::ClearDrivePasswordL(TInt aIndex, const TFileName &aOldPassword) + { + if (iDriveEntryList->Count() > aIndex && aIndex >= 0) + { + TDriveEntry driveEntry = iDriveEntryList->At(aIndex); + + TMediaPassword oldPassword; + + ConvertCharsToPwd(aOldPassword, oldPassword); + + // clear the password from the drive + User::LeaveIfError(iFs.ClearPassword(driveEntry.iNumber, oldPassword)); + } + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::EraseDrivePasswordL(TInt aIndex) + { + if (iDriveEntryList->Count() > aIndex && aIndex >= 0) + { + TDriveEntry driveEntry = iDriveEntryList->At(aIndex); + + // erase the password from the drive + User::LeaveIfError(iFs.ErasePassword(driveEntry.iNumber)); + } + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::FormatDriveL(TInt aIndex, TBool aQuickFormat) + { + if (iDriveEntryList->Count() > aIndex && aIndex >= 0) + { + TDriveEntry driveEntry = iDriveEntryList->At(aIndex); + + TInt err(KErrNone); + TInt formatCount(0); + + TBuf<10> driveRoot; + driveRoot.Append(driveEntry.iLetter); + driveRoot.Append(_L(":")); + + TUint formatMode(0); + if (aQuickFormat) + formatMode = ESpecialFormat|EQuickFormat; + else + formatMode = ESpecialFormat|EFullFormat; + + // set as system application to prevent getting shut down events + iEngine->EikonEnv()->SetSystem(ETrue); + + // first close any open applications + CBaBackupSessionWrapper* BSWrapper = CBaBackupSessionWrapper::NewL(); + CleanupStack::PushL(BSWrapper); + + TBackupOperationAttributes atts(MBackupObserver::EReleaseLockNoAccess, MBackupOperationObserver::EStart); + BSWrapper->NotifyBackupOperationL(atts); + + CAsyncWaiter* waiter = CAsyncWaiter::NewLC(); + BSWrapper->CloseAll( MBackupObserver::EReleaseLockNoAccess, waiter->iStatus ); + waiter->StartAndWait(); + CleanupStack::PopAndDestroy(); //waiter + + // some delay to make sure all applications have been closed + User::After(1000000); + + // format the drive + RFormat format; + err = format.Open(iFs, driveRoot, formatMode, formatCount); + + // Forced format for locked card + if ( err == KErrLocked ) + { + // Erase password and try again + err = iFs.ErasePassword( driveEntry.iNumber ); + if ( !err ) + { + err = format.Open(iFs, driveRoot, formatMode, formatCount); + } + } + + if( err != KErrNone && err != KErrLocked ) + { +// CAknQueryDialog* lockQuery = CAknQueryDialog::NewL(); +// if ( lockQuery->ExecuteLD(R_GENERAL_CONFIRMATION_QUERY, _L("Memory card in use by other application. Proceed anyway?"))) + // TODO Dialog should be opened in UI part + if (iEngine->FileBrowserUI()->ShowConfirmationQuery(_L("Memory card in use by other application. Proceed anyway?"))) + { + // If format could not be started, someone is still keeping + // files open on media. Let's try to dismount file system, then + // remount with own extension embedded and try again. + + TFullName fsName; + err = iFs.FileSystemName( fsName, driveEntry.iNumber ); + + if ( err == KErrNone && fsName.Length() > 0 ) + { + // Prevent SysAp shutting down applications + RProperty::Set( + KPSUidCoreApplicationUIs, + KCoreAppUIsMmcRemovedWithoutEject, + ECoreAppUIsEjectCommandUsed ); + + TRequestStatus stat; + iFs.NotifyDismount( driveEntry.iNumber, stat, EFsDismountForceDismount ); + User::WaitForRequest( stat ); + + // Unfortunately, at the moment we have to wait until clients have received + // notification about card dismount. Otherwise at least causes problems with + // theme selected from card. In future clients should use new notify-API. + User::After( KForcedFormatTimeout ); + + // Let's set priority higher than normally. This is done to decrease the chance + // that someone reopens files on memory card after mandatory file system + // remounting hence preventing formatting again. + TThreadPriority priority( RThread().Priority() ); + RThread().SetPriority( EPriorityAbsoluteHigh ); + + // Mount file system back... + err = iFs.MountFileSystem( fsName, driveEntry.iNumber ); + err = format.Open(iFs, driveRoot, formatMode, formatCount); + RThread().SetPriority( priority ); + } + } + } + + + if (err == KErrNone) + { + // needs to be implemented with active objects + // CAknProgressDialog* dlg = new(ELeave) CAknProgressDialog(formatCount, 1, 1, NULL); + // dlg->SetTone(CAknNoteDialog::ENoTone); + // dlg->ExecuteLD(R_FORMAT_PROGRESS_NOTE); + + while (formatCount && err == KErrNone) + { + err = format.Next(formatCount); + } + } + + format.Close(); + + // restart closed applications + TBackupOperationAttributes atts2(MBackupObserver::ETakeLock, MBackupOperationObserver::EEnd); + BSWrapper->NotifyBackupOperationL(atts2); + BSWrapper->RestartAll(); + CleanupStack::PopAndDestroy(); //BSWrapper + + // system status not needed anymore + iEngine->EikonEnv()->SetSystem(EFalse); + + + if (err == KErrNone) + { + iEngine->FileBrowserUI()->ShowConfirmationNote(_L("Format succeeded")); + } + else if (err == KErrNotSupported) + { + iEngine->FileBrowserUI()->ShowErrorNote(_L("Not supported for this drive")); + } + else + { + iEngine->FileBrowserUI()->ShowErrorNote(ResolveErrorMessage(err)); + } + + RefreshViewL(); + } + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::EraseMBRL(TInt aIndex) + { + // TODO + #ifndef FILEBROWSER_LITE + if (iEngine->Settings().iBypassPlatformSecurity) + { + if (iDriveEntryList->Count() > aIndex && aIndex >= 0) + { + TDriveEntry driveEntry = iDriveEntryList->At(aIndex); + + TInt err(KErrNone); + + iEngine->FileBrowserUI()->ShowInformationNote(_L("Please wait, this may take 30 seconds"), _L("")); + + // set as system application to prevent getting shut down events + iEngine->EikonEnv()->SetSystem(ETrue); + + // first close any open applications + CBaBackupSessionWrapper* BSWrapper = CBaBackupSessionWrapper::NewL(); + CleanupStack::PushL(BSWrapper); + + TBackupOperationAttributes atts(MBackupObserver::EReleaseLockNoAccess, MBackupOperationObserver::EStart); + BSWrapper->NotifyBackupOperationL(atts); + + CAsyncWaiter* waiter = CAsyncWaiter::NewLC(); + BSWrapper->CloseAll( MBackupObserver::EReleaseLockNoAccess, waiter->iStatus ); + waiter->StartAndWait(); + CleanupStack::PopAndDestroy(); //waiter + + // some delay to make sure all applications have been closed + User::After(1000000); + + + // do the erase MBR operation + err = iFileOps->EraseMBR(driveEntry.iNumber); + + + // restart closed applications + TBackupOperationAttributes atts2(MBackupObserver::ETakeLock, MBackupOperationObserver::EEnd); + BSWrapper->NotifyBackupOperationL(atts2); + BSWrapper->RestartAll(); + CleanupStack::PopAndDestroy(); //BSWrapper + + // system status not needed anymore + iEngine->EikonEnv()->SetSystem(EFalse); + + + if (err == KErrNone) + { + iEngine->FileBrowserUI()->ShowConfirmationNote(_L("Erase MBR succeeded")); + } + else if (err == KErrNotSupported) + { + iEngine->FileBrowserUI()->ShowErrorNote(_L("Not supported for this drive")); + } + else + { + iEngine->FileBrowserUI()->ShowErrorNote(ResolveErrorMessage(err)); + } + + RefreshViewL(); + } + } + else + { + iEngine->FileBrowserUI()->ShowInformationNote(_L("Enable \"bypass platform security\" from the settings first"), _L("")); + } + #else + iEngine->FileBrowserUI()->ShowInformationNote(_L("Not supported in lite version"), _L("")); + #endif + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::PartitionDriveL(TInt aIndex, TBool aEraseMBR, TInt aAmountOfPartitions) + { + // TODO + #ifndef FILEBROWSER_LITE + if (iEngine->Settings().iBypassPlatformSecurity) + { + if (iDriveEntryList->Count() > aIndex && aIndex >= 0) + { + TDriveEntry driveEntry = iDriveEntryList->At(aIndex); + + TInt err(KErrNone); + + iEngine->FileBrowserUI()->ShowInformationNote(_L("Please wait, this may take 30 seconds"), _L("")); + + // set as system application to prevent getting shut down events + iEngine->EikonEnv()->SetSystem(ETrue); + + // first close any open applications + CBaBackupSessionWrapper* BSWrapper = CBaBackupSessionWrapper::NewL(); + CleanupStack::PushL(BSWrapper); + + TBackupOperationAttributes atts(MBackupObserver::EReleaseLockNoAccess, MBackupOperationObserver::EStart); + BSWrapper->NotifyBackupOperationL(atts); + + CAsyncWaiter* waiter = CAsyncWaiter::NewLC(); + BSWrapper->CloseAll( MBackupObserver::EReleaseLockNoAccess, waiter->iStatus ); + waiter->StartAndWait(); + CleanupStack::PopAndDestroy(); //waiter + + // some delay to make sure all applications have been closed + User::After(1000000); + + // do the erase operation + if (aEraseMBR) + { + err = iFileOps->EraseMBR(driveEntry.iNumber); + + if (err != KErrNone) + { + iEngine->FileBrowserUI()->ShowErrorNote(_L("Erase MBR failed")); + } + + User::After(500000); + } + + + // do the partition operation + err = iFileOps->PartitionDrive(driveEntry.iNumber, aAmountOfPartitions); + + + // restart closed applications + TBackupOperationAttributes atts2(MBackupObserver::ETakeLock, MBackupOperationObserver::EEnd); + BSWrapper->NotifyBackupOperationL(atts2); + BSWrapper->RestartAll(); + CleanupStack::PopAndDestroy(); //BSWrapper + + // system status not needed anymore + iEngine->EikonEnv()->SetSystem(EFalse); + + + if (err == KErrNone) + { + iEngine->FileBrowserUI()->ShowConfirmationNote(_L("Partition succeeded")); + } + else if (err == KErrNotSupported) + { + iEngine->FileBrowserUI()->ShowErrorNote(_L("Not supported for this drive")); + } + else + { + iEngine->FileBrowserUI()->ShowErrorNote(ResolveErrorMessage(err)); + } + + RefreshViewL(); + } + } + else + { + iEngine->FileBrowserUI()->ShowInformationNote(_L("Enable \"bypass platform security\" from the settings first"), _L("")); + } + #else + iEngine->FileBrowserUI()->ShowInformationNote(_L("Not supported in lite version"), _L("")); + #endif + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::CheckDiskL(TInt aIndex) + { + if (iDriveEntryList->Count() > aIndex && aIndex >= 0) + { + TDriveEntry driveEntry = iDriveEntryList->At(aIndex); + + TBuf<10> driveRoot; + driveRoot.Append(driveEntry.iLetter); + driveRoot.Append(_L(":")); + + // check disk + TInt err = iFs.CheckDisk(driveRoot); + + if (err == KErrNone) + { + iEngine->FileBrowserUI()->ShowConfirmationNote(_L("Integrity of the disk is ok")); + } + else if (err == KErrNotReady) + { + iEngine->FileBrowserUI()->ShowInformationNote(_L("Disk is empty"), _L("")); + } + else if (err == KErrNotSupported) + { + iEngine->FileBrowserUI()->ShowErrorNote(_L("Not supported for this drive")); + } + else + { + iEngine->FileBrowserUI()->ShowErrorNote(_L("Disk is corrupted")); + } + + RefreshViewL(); + } + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::ScanDriveL(TInt aIndex) + { + if (iDriveEntryList->Count() > aIndex && aIndex >= 0) + { + TDriveEntry driveEntry = iDriveEntryList->At(aIndex); + + TBuf<10> driveRoot; + driveRoot.Append(driveEntry.iLetter); + driveRoot.Append(_L(":")); + + // scan disk + User::LeaveIfError(iFs.ScanDrive(driveRoot)); + } + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::GetDriveName(TInt aIndex, TFileName &aDriveName) + { + if (iDriveEntryList->Count() > aIndex && aIndex >= 0) + { + TDriveEntry driveEntry = iDriveEntryList->At(aIndex); + + // get existing drive name + iFs.GetDriveName(driveEntry.iNumber, aDriveName); + } + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::SetDriveNameL(TInt aIndex, const TFileName &aDriveName) + { + if (iDriveEntryList->Count() > aIndex && aIndex >= 0) + { + TDriveEntry driveEntry = iDriveEntryList->At(aIndex); + + // set drive name + User::LeaveIfError(iFs.SetDriveName(driveEntry.iNumber, aDriveName)); + } + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::GetDriveVolumeLabel(TInt aIndex, TFileName &aVolumeLabel) + { + if (iDriveEntryList->Count() > aIndex && aIndex >= 0) + { + TDriveEntry driveEntry = iDriveEntryList->At(aIndex); + + // get existing volume label + aVolumeLabel.Copy(driveEntry.iVolumeInfo.iName); + } + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::SetDriveVolumeLabelL(TInt aIndex, const TFileName &aVolumeLabel) + { + if (iDriveEntryList->Count() > aIndex && aIndex >= 0) + { + TDriveEntry driveEntry = iDriveEntryList->At(aIndex); + + // set volume label + User::LeaveIfError(iFs.SetVolumeLabel(aVolumeLabel, driveEntry.iNumber)); + } + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::EjectDriveL(TInt aIndex) + { + if (iDriveEntryList->Count() > aIndex && aIndex >= 0) + { + TDriveEntry driveEntry = iDriveEntryList->At(aIndex); + + TInt err(KErrNone); + + // get current filesystem name + TFileName fileSystemName; + User::LeaveIfError(iFs.FileSystemName(fileSystemName, driveEntry.iNumber)); + + // Prevent SysAp shutting down applications + RProperty::Set( + KPSUidCoreApplicationUIs, + KCoreAppUIsMmcRemovedWithoutEject, + ECoreAppUIsEjectCommandUsed ); + + // dismount the file system + User::LeaveIfError(iFs.DismountFileSystem(fileSystemName, driveEntry.iNumber)); + + // remount the file system + err = iFs.MountFileSystem(fileSystemName, driveEntry.iNumber); + + if (err == KErrInUse) + { + // try to remount after a while if locked + User::After(1000000); + err = iFs.MountFileSystem(fileSystemName, driveEntry.iNumber); + } + User::LeaveIfError(err); + } + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::DismountFileSystemL(TInt aIndex) + { + if (iDriveEntryList->Count() > aIndex && aIndex >= 0) + { + TDriveEntry driveEntry = iDriveEntryList->At(aIndex); + + // get current filesystem name + TFileName fileSystemName; + User::LeaveIfError(iFs.FileSystemName(fileSystemName, driveEntry.iNumber)); + + // Prevent SysAp shutting down applications + RProperty::Set( + KPSUidCoreApplicationUIs, + KCoreAppUIsMmcRemovedWithoutEject, + ECoreAppUIsEjectCommandUsed ); + + // dismount the file system + User::LeaveIfError(iFs.DismountFileSystem(fileSystemName, driveEntry.iNumber)); + } + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::ConvertCharsToPwd(const TDesC& aWord, TDes8& aConverted) const + { + aConverted.FillZ(aConverted.MaxLength()); + aConverted.Zero(); + + if (aWord.Length()) + { + aConverted.Copy( (TUint8*)(&aWord[0]), aWord.Size() ); + } + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::EditDataTypesL() + { + // TODO + /* + iEngine->FileListContainer()->SetScreenLayoutL(EDisplayModeNormal); + iEngine->FileListContainer()->SetNaviPaneTextL(KNullDesC); + + CFileBrowserDataTypesDlg* dlg = CFileBrowserDataTypesDlg::NewL(); + dlg->RunQueryLD(); + + iEngine->FileListContainer()->SetScreenLayoutL(iEngine->Settings().iDisplayMode); + iEngine->FileListContainer()->SetNaviPaneTextL(iCurrentPath); + */ + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::SecureBackupL(TInt aType) + { + TInt err(KErrNone); + TInt showStatus(EFalse); + + if (aType == EFileBrowserCmdToolsSecureBackupStartBackup || aType == EFileBrowserCmdToolsSecureBackupStartRestore) + { +// TInt queryIndexState(0); +// TInt queryIndexType(0); + +// CAknListQueryDialog* listQueryDlgState = new(ELeave) CAknListQueryDialog(&queryIndexState); +// if (listQueryDlgState->ExecuteLD(R_SECUREBACKUP_STATE_QUERY)) +// { +// +// CAknListQueryDialog* listQueryDlgType = new(ELeave) CAknListQueryDialog(&queryIndexType); +// if (listQueryDlgType->ExecuteLD(R_SECUREBACKUP_TYPE_QUERY)) +// { +// conn::TBURPartType partType = conn::EBURNormal; +// conn::TBackupIncType backupIncType = conn::ENoBackup; +// +// if (aType == EFileBrowserCmdToolsSecureBackupStartBackup) +// { +// if (queryIndexState == ESecureBackupStateFull) +// partType = conn::EBURBackupFull; +// else if (queryIndexState == ESecureBackupStatePartial) +// partType = conn::EBURBackupPartial; +// } +// else if (aType == EFileBrowserCmdToolsSecureBackupStartRestore) +// { +// if (queryIndexState == ESecureBackupStateFull) +// partType = conn::EBURRestoreFull; +// else if (queryIndexState == ESecureBackupStatePartial) +// partType = conn::EBURRestorePartial; +// } +// +// if (queryIndexType == ESecureBackupTypeBase) +// backupIncType = conn::EBackupBase; +// else if (queryIndexType == ESecureBackupTypeIncremental) +// backupIncType = conn::EBackupIncrement; +// +// // start secure backup +// err = iFileOps->ActivateSecureBackUp(partType, backupIncType); +// showStatus = ETrue; +// } +// } + } + + else if (aType == EFileBrowserCmdToolsSecureBackupStop) + { + err = iFileOps->DeActivateSecureBackUp(); + showStatus = ETrue; + } + + else + User::Panic(_L("Sec.br.mode"), 101); + + + if (showStatus) + { + if (err == KErrNone) + { + iEngine->FileBrowserUI()->ShowConfirmationNote(_L("Succeeded")); + } + else + { + iEngine->FileBrowserUI()->ShowErrorNote(ResolveErrorMessage(err)); + } + } + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFileUtils::OpenCommonFileActionQueryL(TInt aCurrentItemIndex) + { + // TODO + // just get current item +// TInt currentItemIndex = iEngine->QueryCurrentItemIndex(); + + if (iFileEntryList->Count() > aCurrentItemIndex && aCurrentItemIndex >= 0) + { +// TInt queryIndex(0); +// +// CAknListQueryDialog* listQueryDlg = new(ELeave) CAknListQueryDialog(&queryIndex); +// +// if (listQueryDlg->ExecuteLD(R_COMMON_FILE_ACTION_QUERY)) +// { +// if (queryIndex == ECommonFileActionViewAsTextHex) +// { +// TFileEntry fileEntry = iFileEntryList->At(aCurrentItemIndex); +// +// TFileName fullPath = fileEntry.iPath; +// fullPath.Append(fileEntry.iEntry.iName); +// +// TInt viewerType(EFileBrowserCmdFileViewHex); +// +// // check from mime type if it's text +// TDataType dataType; +// TUid appUid; +// if (iEngine->LsSession().AppForDocument(fullPath, appUid, dataType) == KErrNone) +// { +// TBuf<128> mimeTypeBuf; +// mimeTypeBuf.Copy(dataType.Des8()); +// if (mimeTypeBuf == KNullDesC) +// mimeTypeBuf.Copy(_L("N/A")); +// +// if (mimeTypeBuf.CompareF(_L("text/plain")) == 0) +// viewerType = EFileBrowserCmdFileViewText; +// } +// +// FileEditorL(viewerType); +// } +// +// else if (queryIndex == ECommonFileActionOpenWithApparc) +// { +// // TODO +// //OpenWithApparcL(); +// } +// +// else if (queryIndex == ECommonFileActionOpenWithDocHandlerEmbed) +// { +// // TODO +// //OpenWithDocHandlerL(ETrue); +// } +// +// else +// User::Panic(_L("Unk.Com.Act"), 221); +// } + } + } + +// -------------------------------------------------------------------------------------------- + +// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/engine/FBFileUtils.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/engine/FBFileUtils.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,413 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef FILEBROWSER_FILEUTILS_H +#define FILEBROWSER_FILEUTILS_H + +// INCLUDES +#include +#include +#include +#include +#include +#include +#include +#include "FB.hrh" + +_LIT(KIRAppPath, "z:\\sys\\bin\\irapp.exe"); +_LIT(KBTAppPath, "z:\\sys\\bin\\btui.exe"); +_LIT(KUSBAppPath, "z:\\sys\\bin\\usbclasschangeui.exe"); +_LIT(KErrRdPath, "c:\\resource\\ErrRd"); +_LIT(KErrRdDir, "c:\\resource\\"); + + +// FORWARD DECLARATIONS +class CEngine; +class CFileBrowserFileOps; +class CDocumentHandler; +class CEikProgressInfo; +class CFBFileOpClient; +class CEikProgressInfo; +class CMessageDigest; + +// CLASS DECLARATIONS + +class TSearchAttributes + { +public: + TFileName iSearchDir; + TFileName iWildCards; + TFileName iTextInFile; + TUint iMinSize; + TUint iMaxSize; + TTime iMinDate; + TTime iMaxDate; + TBool iRecurse; + TBool iDefaultWildCard; + }; + +class TDriveEntry + { +public: + TChar iLetter; + TInt iNumber; + TVolumeInfo iVolumeInfo; + TBuf<64> iMediaTypeDesc; + TBuf<128> iAttributesDesc; + TInt iIconId; + }; + +class TFileEntry + { +public: + TFileName iFullName; + TFileName iPath; + TEntry iEntry; + TInt iDirEntries; + TInt iIconId; + }; + +class TAppIcon + { +public: + TInt iId; + TUid iUid; + }; + +typedef CArrayFixSeg CDriveEntryList; +typedef CArrayFixSeg CFileEntryList; +typedef CArrayFixSeg CAppIconList; + +class TSearchResults + { +public: + TInt iNumberOfFoundFiles; + //CFileEntryList iFoundFilesList; + }; + +class TOverwriteOptions + { +public: + TBool iDoFileOperations/*(ETrue)*/; + TInt iQueryIndex/*(0)*/; + TFileName iPostFix; + TInt iOverWriteFlags/* = CFileMan::EOverWrite*/; + }; + +class CCommandParamsBase : public CBase + { + }; + +class CCommandParamsAttribs : public CCommandParamsBase + { +public: + TFileEntry iSourceEntry; + TUint iSetMask; + TUint iClearMask; + TTime iTime; + TUint iSwitch; +public: + CCommandParamsAttribs(const TFileEntry& aSourceEntry, TUint aSetMask, TUint aClearMask, const TTime& aTime, TUint aSwitch) : iSourceEntry(aSourceEntry), iSetMask(aSetMask), iClearMask(aClearMask), iTime(aTime), iSwitch(aSwitch) {} + }; + +class CCommandParamsCopyOrMove : public CCommandParamsBase + { +public: + TFileEntry iSourceEntry; + TFileName iTargetPath; + TUint iSwitch; +public: + CCommandParamsCopyOrMove(const TFileEntry& aSourceEntry, const TDesC& aTargetPath, TUint aSwitch) : iSourceEntry(aSourceEntry), iTargetPath(aTargetPath), iSwitch(aSwitch) {} + }; + +class CCommandParamsRename : public CCommandParamsBase + { +public: + TFileEntry iSourceEntry; + TFileName iTargetPath; + TUint iSwitch; +public: + CCommandParamsRename(const TFileEntry& aSourceEntry, const TDesC& aTargetPath, TUint aSwitch) : iSourceEntry(aSourceEntry), iTargetPath(aTargetPath), iSwitch(aSwitch) {} + }; + +class CCommandParamsDelete : public CCommandParamsBase + { +public: + TFileEntry iSourceEntry; + TUint iSwitch; +public: + CCommandParamsDelete(const TFileEntry& aSourceEntry, TUint aSwitch) : iSourceEntry(aSourceEntry), iSwitch(aSwitch) {} + }; + +class CCommandParamsDriveSnapShot : public CCommandParamsBase + { +public: + TInt iSourceDriveLetter; + TInt iTargetDriveLetter; +public: + CCommandParamsDriveSnapShot(TChar aSourceDriveLetter, TChar aTargetDriveLetter) : iSourceDriveLetter(aSourceDriveLetter), iTargetDriveLetter(aTargetDriveLetter) {} + }; + +class TCommand + { +public: + TInt iCommandId; + CCommandParamsBase* iParameters; +public: + TCommand(TInt aCommandId, CCommandParamsBase* aParameters) : iCommandId(aCommandId), iParameters(aParameters) {} + }; + +typedef CArrayFixSeg CCommandArray; + + + +class CFileBrowserFileUtils : public CActive, public MMsvSessionObserver + { +private: + enum TState // active object states + { + EIdle = 0, // do nothing + }; + +// enum TClipBoardMode +// { +// EClipBoardModeCut = 0, +// EClipBoardModeCopy +// }; + +public: + static CFileBrowserFileUtils* NewL(CEngine* aEngine); + ~CFileBrowserFileUtils(); + +private: + CFileBrowserFileUtils(CEngine* aEngine); + void ConstructL(); + +private: // from CActive + void RunL(); + TInt RunError(TInt aError); + void DoCancel(); + +private: // from MMsvSessionObserver + void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3); + +public: //from MProgressDialogCallback + void DialogDismissedL(/*TInt aButtonId*/); + +public: // command handling + void StartExecutingCommandsL(const TDesC& aLabel); +private: // command handling + void ExecuteCommand(); + void CheckForMoreCommandsL(); + void AppendToCommandArrayL(TInt aCommand, CCommandParamsBase* aParameters); + TInt CommandArrayCount() const; + void ResetCommandArray(); + +private: // misc functionality + void GenerateDirectoryDataL(); + void GetDriveListL(); + void GetDirectoryListingL(); +// CAknIconArray* GenerateIconArrayL(TBool aGenerateNewBasicIconArray=EFalse); +// void AppendGulIconToIconArrayL(CAknIconArray* aIconArray, const TDesC& aIconFile, TInt aIconId, TInt aMaskId, const TAknsItemID aAknsItemId); + TInt AppIconIdForUid(TUid aUid); + TUid GetAppUid(const TFileEntry &aFileEntry); +// CDesCArray* GenerateItemTextArrayL(); +// TInt GetSelectedItemsOrCurrentItemL(CFileEntryList* aFileEntryList); + TInt SetSelectedItemsOrCurrentItemL(const CArrayFix* selectionIndexes, + CFileEntryList* aFileEntryList); + +// TBool IsDestinationEntriesExists(const CFileEntryList* aEntryList, const TDesC& aTargetDir); + void DoCopyToFolderL(CFileEntryList* aEntryList, const TDesC& aTargetDir, const TOverwriteOptions &aOverwriteOptions, TBool aDeleteSource); + TInt DoSearchFiles(const TDesC& aFileName, const TDesC& aPath); + TInt DoSearchFilesRecursiveL(const TDesC& aFileName, const TDesC& aPath); + TInt DoFindFiles(const TDesC& aFileName, const TDesC& aPath); + TInt DoFindFilesRecursiveL(const TDesC& aFileName, const TDesC& aPath); + void ReadAttachmentPathsRecursiveL(CMsvSession* aSession, CMsvEntry* aContext, CDesCArray* aAttPaths); + void WriteMessageEntryInfoRecursiveL(CMsvSession* aSession, CMsvEntry* aContext, RFile& aFile, TInt& aLevel); + void DoWriteMessageEntryInfoL(CMsvEntry* aContext, RFile& aFile, TInt aLevel); + void ConvertCharsToPwd(const TDesC& aWord, TDes8& aConverted) const; + HBufC8* MessageDigestInHexLC(CMessageDigest* aMD, RFile& aFile); + void OpenCommonFileActionQueryL(TInt aCurrentItemIndex); + +public: // public interfaces + TKeyResponse HandleOfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType); + void HandleSettingsChangeL(); + void SetSortModeL(TInt aSortMode); + void SetOrderModeL(TInt aOrderMode); + void RefreshViewL(); + TBool IsCurrentDriveReadOnly(); + TBool IsItemDirectory(TInt aCurrentItemIndex); + void MoveUpOneLevelL(); + void MoveDownToDirectoryL(TInt aIndex); + TInt ClipboardCutL(const CArrayFix* aSelectionIndices); + TInt ClipboardCopyL(const CArrayFix* aSelectionIndices); + void ClipboardPasteL(const TOverwriteOptions &aOverwriteOptions); + TInt SetCurrentSelection(const CArrayFix* aSelectionIndices); + void CopyToFolderL(const TFileName &, const TOverwriteOptions &, TBool aMove=EFalse); + void DeleteL(); + TBool SelectionHasDirs(); + void TouchL(TBool aRecurse); + void RenameL(const TInt aIndex, const TFileName &newName); + void SetAttributesL(TUint &aSetAttMask, TUint &aClearAttMask, TBool &aRecurse); + void SearchL(); + void NewFileL(const TFileName &aNewFileName); + void NewDirectoryL(const TFileName &aNewDirectoryName); + void SendToL(); + void CompressL(); + void DecompressL(); + TInt GetFilesCount(const TFileName &aDriveRoot); + TInt GetFilesCountAndSize(const TFileName &aFullPath, TInt64 &aSize); + TInt GetEntriesCount(const TFileName &aFullPath); + TFileName GetMimeType(const TFileName &aFullPath); + TFileName GetOpenWith(const TFileName &aFullPath); + void OpenWithApparcL(const TFileName &); + void OpenWithDocHandlerL(const TFileName &, TBool); + void OpenWithFileServiceL(TInt aCurrentItemIndex); + TBool FileExists(const TDesC& aPath); + TInt LaunchProgramL(const TDesC& aPath); + void MemoryInfoPopupL(); + void ShowFileCheckSumsL(TInt aCurrentItemIndex, TInt aType); + void SetErrRdL(TBool aEnable); +// void EnableAvkonIconCacheL(TBool aEnable); + void SimulateLeaveL(TInt aLeaveCode); + void SimulatePanicL(const TDesC& aPanicCategory, TInt aPanicCode); + void SimulateExceptionL(TInt aExceptionCode); + TUint32 GetDebugMask(); + void SetDebugMaskL(TUint32 aDbgMask); + void WriteAllAppsL(); + void WriteAllFilesL(); + void ListOpenFilesL(); + void ListMessageAttachmentsL(TInt aType); + void WriteMsgStoreWalkL(); + void FileEditorL(TInt aCurrentItemIndex, TInt aType); + void SetDrivePasswordL(TInt aIndex, const TFileName &aOldPassword, const TFileName &aNewPassword); + void UnlockDriveL(TInt aIndex, const TFileName &aOldPassword); + void ClearDrivePasswordL(TInt aIndex, const TFileName &aOldPassword); + void EraseDrivePasswordL(TInt aIndex); + void FormatDriveL(TInt aIndex, TBool aQuickFormat); + void CheckDiskL(TInt aIndex); + void ScanDriveL(TInt aIndex); + void SetDriveNameL(TInt aIndex, const TFileName &aDriveName); + void SetDriveVolumeLabelL(TInt aIndex, const TFileName &aVolumeLabel); + void EjectDriveL(TInt aIndex); + void DismountFileSystemL(TInt aIndex); + void EraseMBRL(TInt aIndex); + void PartitionDriveL(TInt aIndex, TBool aEraseMBR, TInt aAmountOfPartitions); + TBool DriveSnapShotPossible(); + void DriveSnapShotL(); + void EditDataTypesL(); + void SecureBackupL(TInt aType); + + TBool IsDestinationEntriesExists(const TDesC& aTargetDir); + TBool TargetExists(const TInt aIndex, const TFileName &newName); + void GetDriveName(TInt aIndex, TFileName &aDriveName); + void GetDriveVolumeLabel(TInt aIndex, TFileName &aVolumeLabel); + + CFileEntryList* FileEntries() const; + CDriveEntryList* DriveEntries() const; + + TFileName ResolveErrorMessage(TInt aErrCode); + +public: + inline TInt SortMode() { return iSortMode; } + inline TInt OrderMode() { return iOrderMode; } + inline CFileEntryList* ClipBoardList() { return iClipBoardList; } + inline CFileEntryList* CurrentSelectionList() { return iCurrentSelectionList; } + inline TBool IsDriveListViewActive() { return iCurrentPath==KNullDesC && iListingMode==ENormalEntries; } + inline TBool IsNormalModeActive() { return iListingMode==ENormalEntries; } + inline TListingMode ListingMode() { return iListingMode; } + inline TFileName CurrentPath() { return iCurrentPath; } + + inline TSearchAttributes GetSearchAttributes(){ return iSearchAttributes; }; + inline void ChangeAttributes(const TSearchAttributes &attributes) { iSearchAttributes = attributes; }; + inline TSearchResults SearchResults(){ return iFileSearchResults; }; + inline CFileEntryList* FoundFiles() { return iFileEntryList; }; + inline void SetAllowProcessing(TBool aAllowProcessing) { iAllowProcessing = aAllowProcessing; } + TClipBoardMode GetClipBoardMode() { return iClipBoardMode; } + +private: + TState iState; + CEngine* iEngine; + CFileBrowserFileOps* iFileOps; + + TBool isWaitDialog; + TBool isProgressDialog; + + //CEikProgressInfo* iProgressInfo; + CCommandArray* iCommandArray; + TInt iCurrentEntry; + TInt iSucceededOperations; + TInt iFailedOperations; + TInt iLastError; + RTimer iTimer; + RFs iFs; + TListingMode iListingMode; + CFileMan* iFileMan; + TInt iViewMode; + TFileName iCurrentPath; + TInt iSortMode; + TInt iOrderMode; +// TInt iClipboardMode; + CDesCArray* iClipboardPaths; + CDriveEntryList* iDriveEntryList; + CFileEntryList* iFileEntryList; + CFileEntryList* iFindFileEntryList; + CAppIconList* iAppIconList; + TClipBoardMode iClipBoardMode; + CFileEntryList* iClipBoardList; + CFileEntryList* iCurrentSelectionList; + TSearchAttributes iSearchAttributes; + CDocumentHandler* iDocHandler; + + RFile iMsgStoreWalkFile; + TInt iPrevFolderIndex; + TFileName iPrevFolderName; + RTz iTz; + TSearchResults iFileSearchResults; + CDesCArray* iTextArray; + TBool iAllowProcessing; + }; + + +// utility class for waiting for asychronous requests +class CAsyncWaiter : public CActive + { +public: + static CAsyncWaiter* NewL( TInt aPriority = EPriorityStandard ); + static CAsyncWaiter* NewLC( TInt aPriority = EPriorityStandard ); + ~CAsyncWaiter(); + + void StartAndWait(); + TInt Result() const; + +private: + CAsyncWaiter( TInt aPriority ); + + // from CActive + void RunL(); + void DoCancel(); + +private: + CActiveSchedulerWait iWait; + TInt iError; + }; + + +#endif + +// End of File + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/engine/FBFolderSelector.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/engine/FBFolderSelector.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,619 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "FBFolderSelector.h" +#include "FBFileUtils.h" +#include "FB.hrh" +#include "FBStd.h" + +#if (!defined __SERIES60_30__ && !defined __SERIES60_31__) +#include +#endif // !defined __SERIES60_30__ && !defined __SERIES60_31__ + +// ===================================== MEMBER FUNCTIONS ===================================== + +CFileBrowserFolderSelector *CFileBrowserFolderSelector::NewL( + TDes& aReturnPath, + MFolderSelectorUI *aFolderSelectorUI) + { + CFileBrowserFolderSelector* self = new(ELeave) CFileBrowserFolderSelector(aReturnPath, + aFolderSelectorUI); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// -------------------------------------------------------------------------------------------- + +CFileBrowserFolderSelector::~CFileBrowserFolderSelector() + { + delete iFileEntryList; + delete iDriveEntryList; + + iFs.Close(); + + //iEikonEnv->InfoMsgCancel(); + } + +// -------------------------------------------------------------------------------------------- + +CFileBrowserFolderSelector::CFileBrowserFolderSelector(TDes& aReturnPath, MFolderSelectorUI *aFolderSelectorUI) : + iReturnPath(aReturnPath), + iFolderSelectorUI(aFolderSelectorUI) + { + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFolderSelector::ConstructL() + { + User::LeaveIfError( iFs.Connect() ); + iDriveEntryList = new(ELeave) CDriveEntryList(8); + iFileEntryList = new(ELeave) CFileEntryList(32); + iCurrentPath = KNullDesC; + + //iIsDragging = EFalse; + //EnableDragEvents(); + + // get only writeable drives + GetDriveListL(); + } + +// -------------------------------------------------------------------------------------------- + +/* +void CFileBrowserFolderSelector::HandlePointerEventL(const TPointerEvent &aPointerEvent) + { + // detect direction of dragging by comparing the start and finish points + + if (aPointerEvent.iType == TPointerEvent::EButton1Down) + { + iDragStartPoint = aPointerEvent.iPosition; + iIsDragging = EFalse; + } + else if (aPointerEvent.iType == TPointerEvent::EDrag) + { + iIsDragging = ETrue; + + return; + } + else if (aPointerEvent.iType == TPointerEvent::EButton1Up) + { + if (iIsDragging) + { + const TInt KDelta = iDragStartPoint.iX - aPointerEvent.iPosition.iX; + const TInt KThreshold = 30; + + if (KDelta < -KThreshold) // dragging to right + { + // "emulate" right key press + + TKeyEvent keyEvent; + keyEvent.iCode = EKeyRightArrow; + keyEvent.iModifiers = 0; + + TEventCode type = EEventKey; + + OfferKeyEventL(keyEvent, type); + + return; + } + else if (KDelta > KThreshold) // dragging to left + { + // "emulate" left key press + + TKeyEvent keyEvent; + keyEvent.iCode = EKeyLeftArrow; + keyEvent.iModifiers = 0; + + TEventCode type = EEventKey; + + OfferKeyEventL(keyEvent, type); + + return; + } + } + iIsDragging = EFalse; + } + else + { + iIsDragging = EFalse; + } + + CAknListQueryDialog::HandlePointerEventL(aPointerEvent); + } +*/ + +// -------------------------------------------------------------------------------------------- + +TKeyResponse CFileBrowserFolderSelector::OfferKeyEventL(const TKeyEvent& /*aKeyEvent*/, TEventCode /*aType*/) + { +// if(aType != EEventKey) +// return EKeyWasNotConsumed; + +// if (aKeyEvent.iCode == EKeyLeftArrow && !IsDriveListViewActive()) +// { +// MoveUpOneLevelL(); +// return EKeyWasConsumed; +// } +// else if (aKeyEvent.iCode == EKeyRightArrow && ((ListBox()->CurrentItemIndex() > 0 && !IsDriveListViewActive()) || IsDriveListViewActive())) +// { +// MoveDownToDirectoryL(); +// return EKeyWasConsumed; +// } +// else if (aKeyEvent.iCode == EKeyOK || aKeyEvent.iCode == EKeyEnter) +// { +// if (IsDriveListViewActive()) +// { +// MoveDownToDirectoryL(); +// return EKeyWasConsumed; +// } +// else if (ListBox()->CurrentItemIndex() == 0) +// { +// TryExitL(EAknSoftkeyOk); +// return EKeyWasConsumed; +// } +// else if (ListBox()->CurrentItemIndex() > 0) +// { +// MoveDownToDirectoryL(); +// return EKeyWasConsumed; +// } +// } +// +// TKeyResponse result = CAknDialog::OfferKeyEventL(aKeyEvent, aType); +// +// // update LSK label +// if (!IsDriveListViewActive()) +// { +// if (ListBox()->CurrentItemIndex() == 0) +// { +// ButtonGroupContainer().SetCommandL(0, EAknSoftkeyOk, iLSKActionText); +// ButtonGroupContainer().DrawNow(); +// } +// else +// { +// ButtonGroupContainer().SetCommandL(0, EAknSoftkeyOk, _L("Open dir")); +// ButtonGroupContainer().DrawNow(); +// } +// } +// +// return result; + return TKeyResponse(); + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFolderSelector::PreLayoutDynInitL() + { +// CAknListQueryDialog::PreLayoutDynInitL(); + +// static_cast(ListBox())->ItemDrawer()->ColumnData()->EnableMarqueeL(ETrue); + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFolderSelector::PostLayoutDynInitL() + { +// CAknListQueryDialog::PostLayoutDynInitL(); + + //w SetIconArrayL(static_cast*>(iIconArray)); + + RefreshViewL(); + } + +// -------------------------------------------------------------------------------------------- + +TBool CFileBrowserFolderSelector::OkToExitL(TInt /*aButtonId*/) + { +// if (aButtonId == GetLeftCBAShortKeyPress()) +// { +// if (IsDriveListViewActive()) +// { +// MoveDownToDirectoryL(); +// return EFalse; +// } +// else if (ListBox()->CurrentItemIndex() == 0) +// { +// // close the dialog +// iReturnPath = iCurrentPath; +// return ETrue; +// } +// else if (ListBox()->CurrentItemIndex() > 0) +// { +// MoveDownToDirectoryL(); +// return EFalse; +// } +// else +// return EFalse; +// } +// else if (aButtonId == GetRightCBAShortKeyPress()) +// { +// return ETrue; +// } +// else +// { +// return EFalse; +// } + return ETrue; + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFolderSelector::MoveUpOneLevelL() + { + if (iCurrentPath.Length() <= 3) + { + // move to drive list view is the current path is already short enough + iCurrentPath = KNullDesC; + } + else + { + // move one directory up + TInt marker(iCurrentPath.Length()); + + // find second last dir marker + for (TInt i=iCurrentPath.Length()-2; i>=0; i--) + { + if (iCurrentPath[i] == '\\') + { + marker = i; + break; + } + + } + iCurrentPath = iCurrentPath.LeftTPtr(marker+1); + } + + // update view + RefreshViewL(); + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFolderSelector::MoveDownToDirectoryL(TInt index) + { + if (index >= 0) + { + if (IsDriveListViewActive()) + { + // currently in a drive list view, move to root of selected drive + if (iDriveEntryList->Count() > index) + { + TDriveEntry driveEntry = iDriveEntryList->At(index); + + iCurrentPath.Append(driveEntry.iLetter); + iCurrentPath.Append(_L(":\\")); + } + } + else + { + // append the new directory + if (index >= 0 && index < iFileEntryList->Count()) + { + TFileEntry fileEntry = iFileEntryList->At(index); + + if (fileEntry.iEntry.IsDir()) + { + iCurrentPath.Append(fileEntry.iEntry.iName); + iCurrentPath.Append(_L("\\")); + } + } + } + + // update view + RefreshViewL(); + } + } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFolderSelector::RefreshViewL() + { + if (IsDriveListViewActive()) + { + GetDriveListL(); + } + else + { + GetFileListL(); + } + iFolderSelectorUI->InformFolderSelectionChanged(); + + // TODO +// if (iCurrentPath == KNullDesC) +// iEikonEnv->InfoMsgWithDuration(_L("<- up dir down dir ->"), TTimeIntervalMicroSeconds32(KMaxTInt)); +// else +// iEikonEnv->InfoMsgWithDuration(iCurrentPath, TTimeIntervalMicroSeconds32(KMaxTInt)); + +// SetItemTextArray(textArray); +// SetOwnershipType(ELbmOwnsItemArray); +// ListBox()->HandleItemAdditionL(); +// Layout(); +// ListBox()->SetCurrentItemIndex(0); +// DrawDeferred(); + } + +// -------------------------------------------------------------------------------------------- + +//TBool CFileBrowserFolderSelector::RunCopyDlgLD() +// { +// iLSKActionText.Copy(_L("Copy")); +// return ExecuteLD(1/*R_COPY_TO_FOLDER_SELECTION_QUERY*/); +// } + +//// -------------------------------------------------------------------------------------------- + +//TBool CFileBrowserFolderSelector::RunMoveDlgLD() +// { +// iLSKActionText.Copy(_L("Move")); +// return ExecuteLD(1/*R_MOVE_TO_FOLDER_SELECTION_QUERY*/); +// } + +//// -------------------------------------------------------------------------------------------- + +//TInt CAknQueryDialog::GetLeftCBAShortKeyPress() +// { +// return TInt16(0xffff & TInt16(ButtonGroupContainer().ButtonGroup()->CommandId(0))); +// } + +//// -------------------------------------------------------------------------------------------- + +//TInt CAknQueryDialog::GetRightCBAShortKeyPress() +// { +// return TInt16(0xffff & TInt16(ButtonGroupContainer().ButtonGroup()->CommandId(2))); +// } + +// -------------------------------------------------------------------------------------------- + +void CFileBrowserFolderSelector::GetDriveListL() + { + TDriveList driveList; + + // get drive listing depending of the support for network drives + if (true/*TODO iEngine->Settings().iSupportNetworkDrives*/) + { + #ifndef __SERIES60_30__ + #ifndef __SERIES60_31__ + User::LeaveIfError(iFs.DriveList(driveList, KDriveAttAll)); + #endif + #else + User::LeaveIfError(iFs.DriveList(driveList)); + #endif + } + else + { + User::LeaveIfError(iFs.DriveList(driveList)); + } + + iDriveEntryList->Reset(); + + //TDriveEntry driveEntry; + for (TInt i=0; iCount(); +// } + + if (driveEntry.iVolumeInfo.iDrive.iMediaAtt != KMediaAttWriteProtected + && driveEntry.iVolumeInfo.iDrive.iMediaAtt != KMediaAttLocked + && driveEntry.iVolumeInfo.iDrive.iDriveAtt != KDriveAbsent) + { + iDriveEntryList->AppendL(driveEntry); + } + } + } + } + +void CFileBrowserFolderSelector::GetFileListL() + { + iFileEntryList->Reset(); + + CDir* dir = NULL; + if (iFs.GetDir(iCurrentPath, KEntryAttDir|KEntryAttMatchMask, ESortByName | EAscending | EDirsFirst, dir) == KErrNone) + { + CleanupStack::PushL(dir); + + for (TInt i=0; iCount(); i++) + { + TFileEntry fileEntry; + fileEntry.iPath = iCurrentPath; + fileEntry.iEntry = (*dir)[i]; + fileEntry.iDirEntries = KErrNotFound; + fileEntry.iIconId = EFixedIconEmpty; + + // check for directory entries + if (fileEntry.iEntry.IsDir()) + { + fileEntry.iIconId = EFixedIconFolder; + + TFileName subPath = fileEntry.iPath; + subPath.Append(fileEntry.iEntry.iName); + subPath.Append(_L("\\")); + + // check if any sub directories + CDir* subDir = NULL; + if (iFs.GetDir(subPath, KEntryAttDir|KEntryAttMatchMask, ESortNone | EDirsFirst, subDir) == KErrNone) + { + fileEntry.iDirEntries = subDir->Count(); + + for (TInt j=0; jCount(); j++) + { + TEntry entry = (*subDir)[j]; + + if (entry.IsDir()) + { + fileEntry.iIconId = EFixedIconFolderSub; + break; + } + } + + delete subDir; + } + iFileEntryList->AppendL(fileEntry); + } + } + + CleanupStack::PopAndDestroy(); //dir + } + } + +// -------------------------------------------------------------------------------------------- + +// End of File + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/engine/FBFolderSelector.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/engine/FBFolderSelector.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,93 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef FILEBROWSER_FILEDLGS_H +#define FILEBROWSER_FILEDLGS_H + +#include "FBFileUtils.h" + +#include +#include +#include +#include + +/** + * Interface to communicate UI with + */ +class MFolderSelectorUI +{ +public: + /** + * Shows info message with text +// * @param A aText text to be shown in message body. +// * @param A aTitle text to be shown in message title. + * @return None. + */ + virtual void InformFolderSelectionChanged() = 0; +}; + +/** + * Backend class for destination folder selection dialog + */ +class CFileBrowserFolderSelector : public CBase + { +public: + static CFileBrowserFolderSelector *NewL(TDes& aReturnPath, MFolderSelectorUI *); + virtual ~CFileBrowserFolderSelector(); + + inline TFileName CurrentPath() const { return iCurrentPath; } + inline TBool IsDriveListViewActive() const { return iCurrentPath==KNullDesC; } + inline const CDriveEntryList *DriveEntryList() { return iDriveEntryList; } + inline const CFileEntryList *FileEntryList() {return iFileEntryList; } + + void MoveDownToDirectoryL(TInt index); + void MoveUpOneLevelL(); + +private: // Constructors + CFileBrowserFolderSelector(TDes& aReturnPath, MFolderSelectorUI *); + void ConstructL(); + +protected: // From CEikDialog + TKeyResponse OfferKeyEventL(const TKeyEvent &aKeyEvent, TEventCode aType); + void PreLayoutDynInitL(); + void PostLayoutDynInitL(); + TBool OkToExitL(TInt aButtonId); + +protected: // From CCoeControl + //void HandlePointerEventL(const TPointerEvent &aPointerEvent); + +private: // New methods + void RefreshViewL(); + + void GetDriveListL(); + void GetFileListL(); + +private: // Data + TInt iSelectedIndex; + TBuf<16> iLSKActionText; + TDes &iReturnPath; + RFs iFs; + CDriveEntryList *iDriveEntryList; + CFileEntryList *iFileEntryList; + TFileName iCurrentPath; + MFolderSelectorUI *iFolderSelectorUI; + }; + +#endif + +// End of File + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/engine/FBStd.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/engine/FBStd.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef FILEBROWSER_STD_H +#define FILEBROWSER_STD_H + +#include +#include +#include + +LOCAL_C inline TBool IsQHD(const TSize& aSize) { return ((aSize.iWidth==640 && aSize.iHeight==360) || (aSize.iWidth==360 && aSize.iHeight==640)); } + +#endif + +// End of File + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/engine/FBTraces.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/engine/FBTraces.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,102 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef FILEBROWSER_TRACES_H +#define FILEBROWSER_TRACES_H + +#include + + +// --------------------------------------------------------------------------- +// You can change these logging method values below! Recompile the application to take changes effect. + + // logging methods + // 0 = No logging + // 1 = Flogger + // 2 = RDebug + // 3 = Flogger and RDebug + + #ifndef _DEBUG + + // Logging method for UREL/release builds: + #define FILEBROWSER_LOGGING_METHOD 0 + + #else + + // Logging method for UDEB/debug builds: + #define FILEBROWSER_LOGGING_METHOD 2 + + #endif + + + +// --------------------------------------------------------------------------- +// Do not make any changes to lines below... + + #if FILEBROWSER_LOGGING_METHOD == 1 || FILEBROWSER_LOGGING_METHOD == 3 + + #include + _LIT(KLogFolder,"Launcher"); + _LIT(KLogFile,"Launcher_Trace.txt"); + + #endif + + #if FILEBROWSER_LOGGING_METHOD == 2 || FILEBROWSER_LOGGING_METHOD == 3 + + #include + + #endif + + + #if FILEBROWSER_LOGGING_METHOD == 0 + + #define LOGTEXT(AAA) + #define LOGSTRING(AAA) + #define LOGSTRING2(AAA,BBB) + #define LOGSTRING3(AAA,BBB,CCC) + #define LOGSTRING4(AAA,BBB,CCC,DDD) + + + #elif FILEBROWSER_LOGGING_METHOD == 1 + + #define LOGTEXT(AAA) RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend, AAA) + #define LOGSTRING(AAA) do { _LIT(tempLogDes,AAA); RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend,tempLogDes()); } while (0) + #define LOGSTRING2(AAA,BBB) do { _LIT(tempLogDes,AAA); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB); } while (0) + #define LOGSTRING3(AAA,BBB,CCC) do { _LIT(tempLogDes,AAA); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB,CCC); } while (0) + #define LOGSTRING4(AAA,BBB,CCC,DDD) do { _LIT(tempLogDes,AAA); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB,CCC,DDD); } while (0) + + #elif FILEBROWSER_LOGGING_METHOD == 2 + + #define LOGTEXT(AAA) RDebug::Print(AAA) + #define LOGSTRING(AAA) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes); } while (0) + #define LOGSTRING2(AAA,BBB) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB); } while (0) + #define LOGSTRING3(AAA,BBB,CCC) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC); } while (0) + #define LOGSTRING4(AAA,BBB,CCC,DDD) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC, DDD); } while (0) + + #elif FILEBROWSER_LOGGING_METHOD == 3 + + #define LOGTEXT(AAA) RDebug::Print(AAA); RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend, AAA) + #define LOGSTRING(AAA) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes); RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend,tempLogDes()); } while (0) + #define LOGSTRING2(AAA,BBB) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB); } while (0) + #define LOGSTRING3(AAA,BBB,CCC) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB,CCC); } while (0) + #define LOGSTRING4(AAA,BBB,CCC,DDD) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC, DDD); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB,CCC,DDD); } while (0) + + #endif + +// --------------------------------------------------------------------------- + +#endif diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/engine/engine.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/engine/engine.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,427 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +// INCLUDE FILES + +#include "engine.h" + +//#include "FBApp.h" +#include "FB.hrh" +#include "FBFileUtils.h" +#include "FBStd.h" +//#include + +#include +#include +#include +#include +#include + +// CONSTANTS +// UID of the application +const TUid KUidFileBrowser = { 0x102828D6 }; + +const TInt KSettingsDrive = EDriveC; +_LIT(KSettingsFileName, "filebrowser_settings.ini"); + +// ===================================== MEMBER FUNCTIONS ===================================== + +CEngine* CEngine::NewL(MFileBrowserUI *aFileBrowserUI) + { + CEngine* self = new(ELeave) CEngine; + CleanupStack::PushL(self); + self->ConstructL(aFileBrowserUI); + CleanupStack::Pop(); + return self; + } + +// -------------------------------------------------------------------------------------------- + +CEngine::CEngine() + : iFileUtils(NULL) + { + } + +// -------------------------------------------------------------------------------------------- + +void CEngine::ConstructL(MFileBrowserUI *aFileBrowserUI) + { + iFileBrowserUI = aFileBrowserUI; + iEnv = CEikonEnv::Static(); + User::LeaveIfError(iLs.Connect()); + } + +// -------------------------------------------------------------------------------------------- + +CEngine::~CEngine() + { + if (iFileUtils != NULL) + delete iFileUtils; + + iLs.Close(); + } + +// --------------------------------------------------------------------------- + +void CEngine::ActivateEngineL() + { + TRAP_IGNORE( LoadSettingsL() ); + + iFileUtils = CFileBrowserFileUtils::NewL(this); + } + +// --------------------------------------------------------------------------- + +void CEngine::DeActivateEngineL() + { + } + +// --------------------------------------------------------------------------- + +void CEngine::LoadDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, TInt& aValue) + { + if (aDicFS->IsPresentL(aUid)) + { + RDictionaryReadStream in; + in.OpenLC(*aDicFS, aUid); + aValue = in.ReadInt16L(); + CleanupStack::PopAndDestroy(); // in + } + } + +// --------------------------------------------------------------------------- + +void CEngine::LoadDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, TDes& aValue) + { + if (aDicFS->IsPresentL(aUid)) + { + RDictionaryReadStream in; + in.OpenLC(*aDicFS, aUid); + TInt bufLength = in.ReadInt16L(); // get length of descriptor + in.ReadL(aValue, bufLength); // get the descriptor itself + CleanupStack::PopAndDestroy(); // in + } + } + +// --------------------------------------------------------------------------- + +void CEngine::SaveDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, const TInt& aValue) + { + RDictionaryWriteStream out; + out.AssignLC(*aDicFS, aUid); + out.WriteInt16L(aValue); + out.CommitL(); + CleanupStack::PopAndDestroy(1);// out + } + +// --------------------------------------------------------------------------- + +void CEngine::SaveDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, const TDes& aValue) + { + RDictionaryWriteStream out; + out.AssignLC(*aDicFS, aUid); + out.WriteInt16L(aValue.Length()); // write length of the descriptor + out.WriteL(aValue, aValue.Length()); // write the descriptor itself + out.CommitL(); + CleanupStack::PopAndDestroy(1);// out + } + +// -------------------------------------------------------------------------------------------- + +void CEngine::LoadSettingsL() + { + const TSize screenSize = iEnv->ScreenDevice()->SizeInPixels(); + + // set defaults + iSettings.iDisplayMode = EDisplayModeFullScreen; + iSettings.iFileViewMode = IsQHD(screenSize) ? EFileViewModeExtended : EFileViewModeSimple; + iSettings.iShowSubDirectoryInfo = EFalse; + iSettings.iShowAssociatedIcons = EFalse; + iSettings.iRememberLastPath = EFalse; + iSettings.iLastPath = KNullDesC; + iSettings.iRememberFolderSelection = ETrue; +//#if 0 // TODO +//#if(!defined __SERIES60_30__ && !defined __SERIES60_31__ && !defined __S60_32__) +// if ( AknLayoutUtils::PenEnabled() ) +// { +// iSettings.iEnableToolbar = ETrue; +// } +// else +// { +// iSettings.iEnableToolbar = EFalse; +// } +//#else +// iSettings.iEnableToolbar = EFalse; +//#endif +//#endif // TODO + + iSettings.iSupportNetworkDrives = EFalse; + iSettings.iBypassPlatformSecurity = EFalse; + iSettings.iRemoveFileLocks = ETrue; + iSettings.iIgnoreProtectionsAtts = ETrue; + iSettings.iRemoveROMWriteProrection = ETrue; + + // build specific defaults +#if(!defined __SERIES60_30__ && !defined __SERIES60_31__) + iSettings.iSupportNetworkDrives = ETrue; +#endif + + + // make sure that the private path of this app in c-drive exists + iEnv->FsSession().CreatePrivatePath( KSettingsDrive ); // c:\\private\\102828d6\\ + + // handle settings always in the private directory + if (iEnv->FsSession().SetSessionToPrivate( KSettingsDrive ) == KErrNone) + { + // open or create a dictionary file store + CDictionaryFileStore* settingsStore = CDictionaryFileStore::OpenLC(iEnv->FsSession(), KSettingsFileName, KUidFileBrowser); + + LoadDFSValueL(settingsStore, KFBSettingDisplayMode, iSettings.iDisplayMode); + LoadDFSValueL(settingsStore, KFBSettingFileViewMode, iSettings.iFileViewMode); + LoadDFSValueL(settingsStore, KFBSettingShowSubDirectoryInfo, iSettings.iShowSubDirectoryInfo); + LoadDFSValueL(settingsStore, KFBSettingShowAssociatedIcons, iSettings.iShowAssociatedIcons); + LoadDFSValueL(settingsStore, KFBSettingRememberLastPath, iSettings.iRememberLastPath); + LoadDFSValueL(settingsStore, KFBSettingLastPath, iSettings.iLastPath); + LoadDFSValueL(settingsStore, KFBSettingFolderSelection, iSettings.iRememberFolderSelection); + LoadDFSValueL(settingsStore, KFBSettingEnableToolbar, iSettings.iEnableToolbar); + + LoadDFSValueL(settingsStore, KFBSettingSupportNetworkDrives, iSettings.iSupportNetworkDrives); + LoadDFSValueL(settingsStore, KFBSettingBypassPlatformSecurity, iSettings.iBypassPlatformSecurity); + LoadDFSValueL(settingsStore, KFBSettingRemoveFileLocks, iSettings.iRemoveFileLocks); + LoadDFSValueL(settingsStore, KFBSettingIgnoreProtectionsAtts, iSettings.iIgnoreProtectionsAtts); + LoadDFSValueL(settingsStore, KFBSettingRemoveROMWriteProtection, iSettings.iRemoveROMWriteProrection); + + CleanupStack::PopAndDestroy(); // settingsStore + } + } + +// -------------------------------------------------------------------------------------------- + +void CEngine::SaveSettingsL(TBool aNotifyModules) + { + // handle settings always in c:\\private\\102828d6\\ + if (iEnv->FsSession().SetSessionToPrivate( KSettingsDrive ) == KErrNone) + { + // delete existing store to make sure that it is clean and not eg corrupted + if (BaflUtils::FileExists(iEnv->FsSession(), KSettingsFileName)) + { + iEnv->FsSession().Delete(KSettingsFileName); + } + + // create a dictionary file store + CDictionaryFileStore* settingsStore = CDictionaryFileStore::OpenLC(iEnv->FsSession(), KSettingsFileName, KUidFileBrowser); + + SaveDFSValueL(settingsStore, KFBSettingDisplayMode, iSettings.iDisplayMode); + SaveDFSValueL(settingsStore, KFBSettingFileViewMode, iSettings.iFileViewMode); + SaveDFSValueL(settingsStore, KFBSettingShowSubDirectoryInfo, iSettings.iShowSubDirectoryInfo); + SaveDFSValueL(settingsStore, KFBSettingShowAssociatedIcons, iSettings.iShowAssociatedIcons); + SaveDFSValueL(settingsStore, KFBSettingRememberLastPath, iSettings.iRememberLastPath); + SaveDFSValueL(settingsStore, KFBSettingLastPath, iSettings.iLastPath); + SaveDFSValueL(settingsStore, KFBSettingFolderSelection, iSettings.iRememberFolderSelection); + SaveDFSValueL(settingsStore, KFBSettingEnableToolbar, iSettings.iEnableToolbar); + + SaveDFSValueL(settingsStore, KFBSettingSupportNetworkDrives, iSettings.iSupportNetworkDrives); + SaveDFSValueL(settingsStore, KFBSettingBypassPlatformSecurity, iSettings.iBypassPlatformSecurity); + SaveDFSValueL(settingsStore, KFBSettingRemoveFileLocks, iSettings.iRemoveFileLocks); + SaveDFSValueL(settingsStore, KFBSettingIgnoreProtectionsAtts, iSettings.iIgnoreProtectionsAtts); + SaveDFSValueL(settingsStore, KFBSettingRemoveROMWriteProtection, iSettings.iRemoveROMWriteProrection); + + settingsStore->CommitL(); + CleanupStack::PopAndDestroy(); // settingsStore + } + + // update changes to modules + if (aNotifyModules) + { + //iScreenCapture->HandleSettingsChangeL(); + if (iFileUtils != NULL) + { + iFileUtils->HandleSettingsChangeL(); + } + //iFileListContainer->HandleSettingsChangeL(); + } + } + +// -------------------------------------------------------------------------------------------- + +TInt CEngine::LaunchSettingsDialogL() + { + TInt retValue = KErrNone; + // TODO: + // set to normal mode + //iFileListContainer->SetScreenLayoutL(EDisplayModeNormal); + //iFileListContainer->DeleteNaviPane(); + //iFileListContainer->HideToolbar(); + + // launch the dialog and save settings + //CFileBrowserSettingViewDlg* dlg = CFileBrowserSettingViewDlg::NewL(iSettings); + //TInt retValue = dlg->ExecuteLD(R_FILEBROWSER_SETTINGS_DIALOG); + //FileListContainer()->CreateEmptyNaviPaneLabelL(); + TRAP_IGNORE(SaveSettingsL()); + return retValue; + } + +// -------------------------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------- + +CAsyncWaiter* CAsyncWaiter::NewL(TInt aPriority) + { + CAsyncWaiter* self = new(ELeave) CAsyncWaiter(aPriority); + return self; + } + +CAsyncWaiter* CAsyncWaiter::NewLC(TInt aPriority) + { + CAsyncWaiter* self = new(ELeave) CAsyncWaiter(aPriority); + CleanupStack::PushL(self); + return self; + } + +CAsyncWaiter::CAsyncWaiter(TInt aPriority) : CActive(aPriority) + { + CActiveScheduler::Add(this); + } + +CAsyncWaiter::~CAsyncWaiter() + { + Cancel(); + } + +void CAsyncWaiter::StartAndWait() + { + iStatus = KRequestPending; + SetActive(); + iWait.Start(); + } + +TInt CAsyncWaiter::Result() const + { + return iError; + } + +void CAsyncWaiter::RunL() + { + iError = iStatus.Int(); + //CAknEnv::StopSchedulerWaitWithBusyMessage( iWait ); + iWait.AsyncStop(); + } + +void CAsyncWaiter::DoCancel() + { + iError = KErrCancel; + if( iStatus == KRequestPending ) + { + TRequestStatus* s=&iStatus; + User::RequestComplete( s, KErrCancel ); + } + + //CAknEnv::StopSchedulerWaitWithBusyMessage( iWait ); + iWait.AsyncStop(); + } + +// -------------------------------------------------------------------------------------------- + +void CEngine::OpenWithApparcL(const TFileName &aFileName) + { + if (iFileUtils != NULL) + { + iFileUtils->OpenWithApparcL(aFileName); + } + } + +// -------------------------------------------------------------------------------------------- + +void CEngine::OpenWithDocHandlerL(const TFileName &aFileName, TBool aEmbed) + { + if (iFileUtils != NULL) + { + iFileUtils->OpenWithDocHandlerL(aFileName, aEmbed); + } + } + +// -------------------------------------------------------------------------------------------- + +//TInt CEngine::QueryCurrentItemIndex() +// { +// return iFileBrowserUI->QueryCurrentItemIndex(); +// } + +// -------------------------------------------------------------------------------------------- + +TSearchAttributes CEngine::GetSearchAttributes() + { + if (iFileUtils != NULL) + { + return iFileUtils->GetSearchAttributes(); + } + else + { + return TSearchAttributes(); + } + } + +// -------------------------------------------------------------------------------------------- + +void CEngine::ChangeAttributes(const TSearchAttributes &attributes) + { + if (iFileUtils != NULL) + { + iFileUtils->ChangeAttributes(attributes); + } + } + +// -------------------------------------------------------------------------------------------- + +TSearchResults CEngine::SearchResults() + { + if (iFileUtils != NULL) + { + return iFileUtils->SearchResults(); + } + else + { + return TSearchResults(); + } + } + +// -------------------------------------------------------------------------------------------- + +CFileEntryList* CEngine::FoundFiles() + { + if (iFileUtils != NULL) + { + return iFileUtils->FoundFiles(); + } + else + { + return NULL; + } + } + +// -------------------------------------------------------------------------------------------- + +void CEngine::SearchL() + { + if (iFileUtils != NULL) + { + TRAP_IGNORE(iFileUtils->SearchL()); + } + } + +// -------------------------------------------------------------------------------------------- + +// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/engine/engine.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/engine/engine.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,222 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef __ENGINE_H__ +#define __ENGINE_H__ + +// INCLUDES +#include +#include +#include + +#include "FBFileUtils.h" + +// setting keys (do not change uids of existing keys to maintain compatibility to older versions!) +const TUid KFBSettingDisplayMode = { 0x00 }; +const TUid KFBSettingFileViewMode = { 0x01 }; +const TUid KFBSettingShowSubDirectoryInfo = { 0x02 }; +const TUid KFBSettingShowAssociatedIcons = { 0x03 }; +const TUid KFBSettingRememberLastPath = { 0x04 }; +const TUid KFBSettingLastPath = { 0x05 }; + +const TUid KFBSettingSupportNetworkDrives = { 0x06 }; +const TUid KFBSettingBypassPlatformSecurity = { 0x07 }; +const TUid KFBSettingRemoveFileLocks = { 0x08 }; +const TUid KFBSettingIgnoreProtectionsAtts = { 0x09 }; +const TUid KFBSettingRemoveROMWriteProtection = { 0x0A }; + +const TUid KFBSettingFolderSelection = { 0x0B }; +const TUid KFBSettingEnableToolbar = { 0x0C }; + + +// FORWARD DECLARATIONS +class CFileBrowserFileListContainer; +class CFileBrowserScreenCapture; +class CFileBrowserFileUtils; +class CEikonEnv; +class CDictionaryFileStore; +class MFileBrowserUI; + +// CLASS DECLARATIONS + +class TFileBrowserSettings + { +public: + TInt iDisplayMode; + TInt iFileViewMode; + TBool iShowSubDirectoryInfo; + TBool iShowAssociatedIcons; + TBool iRememberLastPath; + TFileName iLastPath; + TBool iRememberFolderSelection; + TBool iEnableToolbar; + + TBool iSupportNetworkDrives; + TBool iBypassPlatformSecurity; + TBool iRemoveFileLocks; + TBool iIgnoreProtectionsAtts; + TBool iRemoveROMWriteProrection; + }; + +// INFERFACE FOR COMMUNICATION WITH UI + +class MFileBrowserUI +{ +public: +// /** +// * Method from getting current index +// * @return current index. +// */ +// virtual TInt QueryCurrentItemIndex() = 0; + + /** + * Shows info message with text + * @param A aText text to be shown in message body. + * @param A aTitle text to be shown in message title. + * @return None. + */ + virtual void ShowInformationNote(const TDesC &aDescText, const TDesC &aDescTitle) = 0; + + /** + * Shows error message with error text + * @param aText An error text to be shown in message. + * @return None. + */ + virtual void ShowErrorNote(const TDesC& aText, TBool aNoTimeout = EFalse) = 0; + + /** + * Shows confirmation message with text + * @param aText An text to be shown in message. + * @return None. + */ + virtual void ShowConfirmationNote(const TDesC& aText, TBool aNoTimeout = EFalse) = 0; + + /** + * Shows progress bar with text + * @param aText A text to be shown at top of the progress bar. + * @param aMinimum A minimum progress bar value. + * @param aMaximum A maximum progress bar value. + * @return None. + */ + virtual void ShowProgressDialog(const TDesC& aDescText, TInt aMinimum, TInt aMaximum ) = 0; + + /** + * Cancel progress dialog + * @return None. + */ + virtual void CancelProgressDialog() = 0; + + /** + * Set progress dialog value + * @param aValue A vaule to be shown at top of the progress dialog. + */ + virtual void SetProgressValue(TInt aValue) = 0; +// +// /** +// * Sets progress bar value +// * @param aValue A value between min and max value of the progress bar range +// * @return None. +// */ +// virtual void SetProgressBarValue(TInt aValue) = 0; +// +// /** +// * Hides progress bar +// * @return None. +// */ +// virtual void HideProgressBar() = 0; +// + /** + * Shows wait dialog with text + * @param aText A text to be shown at top of the wait bar. + * @return None. + */ + virtual void ShowWaitDialog(const TDesC& aText) = 0; + + /** + * Cancel wait dialog + * @return None. + */ + virtual void CancelWaitDialog() = 0; + + /** + * Processes all pending events to allow wait/progresa dialog to update itself + * @return None. + */ + virtual void ProcessEvents() = 0; + + /** + * Shows confirmation dialog + * @param aFileName String contaning file name and path + * @return ETrue if user pressed OK button, otherwise EFalse. + */ + virtual TBool ShowConfirmationQuery(const TDesC& aDescText) = 0; + + /** + * Notify wrapping model data has changed + */ + virtual void NotifyModelHasChanged() = 0; + +}; + +class CEngine : public CBase + { +public: + static CEngine* NewL(MFileBrowserUI *aFileBrowserUI); + ~CEngine(); + +private: + CEngine(); + void ConstructL(MFileBrowserUI *aFileBrowserUI); + void LoadSettingsL(); + void LoadDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, TInt& aValue); + void LoadDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, TDes& aValue); + void SaveDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, const TInt& aValue); + void SaveDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, const TDes& aValue); + +public: + void ActivateEngineL(); + void DeActivateEngineL(); + void SaveSettingsL(TBool aNotifyModules=ETrue); + TInt LaunchSettingsDialogL(); + inline TFileBrowserSettings& Settings() { return iSettings; } + inline CEikonEnv* EikonEnv() { return iEnv; } + inline RApaLsSession& LsSession() { return iLs; } + inline CFileBrowserScreenCapture* ScreenCapture() { return iScreenCapture; } + inline CFileBrowserFileUtils* FileUtils() { return iFileUtils; } + inline MFileBrowserUI* FileBrowserUI() { return iFileBrowserUI; } + + void OpenWithApparcL(const TFileName &); + void OpenWithDocHandlerL(const TFileName &, TBool); +// TInt QueryCurrentItemIndex(); + TSearchAttributes GetSearchAttributes(); + void ChangeAttributes(const TSearchAttributes &); + TSearchResults SearchResults(); + CFileEntryList* FoundFiles(); + void SearchL(); + +private: + MFileBrowserUI *iFileBrowserUI; + CFileBrowserScreenCapture *iScreenCapture; + CFileBrowserFileUtils *iFileUtils; + CEikonEnv* iEnv; + TFileBrowserSettings iSettings; + RApaLsSession iLs; + TBool iIsHashKeySelectionInUse; + }; + + +#endif // __ENGINE_H__ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/filebrowser.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/filebrowser.pro Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,23 @@ +# +# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# +# + +TEMPLATE = subdirs + +DEFINES += QT_NO_DEBUG_OUTPUT QT_NO_WARNING_OUTPUT QT_NO_DEBUG + +SUBDIRS = group \ + ui diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/fileopclient/BWINS/FileBrowserFileOpClientU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/fileopclient/BWINS/FileBrowserFileOpClientU.DEF Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,14 @@ +EXPORTS + ??1CFBFileOpClient@@UAE@XZ @ 1 NONAME ; CFBFileOpClient::~CFBFileOpClient(void) + ?Attribs@CFBFileOpClient@@QAEHABVTDesC16@@IIABVTTime@@I@Z @ 2 NONAME ; int CFBFileOpClient::Attribs(class TDesC16 const &, unsigned int, unsigned int, class TTime const &, unsigned int) + ?Copy@CFBFileOpClient@@QAEHABVTDesC16@@0I@Z @ 3 NONAME ; int CFBFileOpClient::Copy(class TDesC16 const &, class TDesC16 const &, unsigned int) + ?CreateEmptyFile@CFBFileOpClient@@QAEHABVTDesC16@@@Z @ 4 NONAME ; int CFBFileOpClient::CreateEmptyFile(class TDesC16 const &) + ?Delete@CFBFileOpClient@@QAEHABVTDesC16@@I@Z @ 5 NONAME ; int CFBFileOpClient::Delete(class TDesC16 const &, unsigned int) + ?EraseMBR@CFBFileOpClient@@QAEHI@Z @ 6 NONAME ; int CFBFileOpClient::EraseMBR(unsigned int) + ?MkDirAll@CFBFileOpClient@@QAEHABVTDesC16@@@Z @ 7 NONAME ; int CFBFileOpClient::MkDirAll(class TDesC16 const &) + ?NewL@CFBFileOpClient@@SAPAV1@XZ @ 8 NONAME ; class CFBFileOpClient * CFBFileOpClient::NewL(void) + ?PartitionDrive@CFBFileOpClient@@QAEHII@Z @ 9 NONAME ; int CFBFileOpClient::PartitionDrive(unsigned int, unsigned int) + ?Rename@CFBFileOpClient@@QAEHABVTDesC16@@0I@Z @ 10 NONAME ; int CFBFileOpClient::Rename(class TDesC16 const &, class TDesC16 const &, unsigned int) + ?RmDir@CFBFileOpClient@@QAEHABVTDesC16@@I@Z @ 11 NONAME ; int CFBFileOpClient::RmDir(class TDesC16 const &, unsigned int) + ?CancelOp@CFBFileOpClient@@QAEXXZ @ 12 NONAME ; void CFBFileOpClient::CancelOp(void) + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/fileopclient/eabi/FileBrowserFileOpClientu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/fileopclient/eabi/FileBrowserFileOpClientu.def Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,20 @@ +EXPORTS + _ZN15CFBFileOpClient14PartitionDriveEjj @ 1 NONAME + _ZN15CFBFileOpClient15CreateEmptyFileERK7TDesC16 @ 2 NONAME + _ZN15CFBFileOpClient4CopyERK7TDesC16S2_j @ 3 NONAME + _ZN15CFBFileOpClient4NewLEv @ 4 NONAME + _ZN15CFBFileOpClient5RmDirERK7TDesC16j @ 5 NONAME + _ZN15CFBFileOpClient6DeleteERK7TDesC16j @ 6 NONAME + _ZN15CFBFileOpClient6RenameERK7TDesC16S2_j @ 7 NONAME + _ZN15CFBFileOpClient7AttribsERK7TDesC16jjRK5TTimej @ 8 NONAME + _ZN15CFBFileOpClient8EraseMBREj @ 9 NONAME + _ZN15CFBFileOpClient8MkDirAllERK7TDesC16 @ 10 NONAME + _ZN15CFBFileOpClientD0Ev @ 11 NONAME + _ZN15CFBFileOpClientD1Ev @ 12 NONAME + _ZN15CFBFileOpClientD2Ev @ 13 NONAME + _ZTI15CFBFileOpClient @ 14 NONAME ; ## + _ZTV15CFBFileOpClient @ 15 NONAME ; ## + _ZN15CFBFileOpClient8CancelOpEv @ 16 NONAME + _ZTI18CAsyncWaiterClient @ 17 NONAME ; ## + _ZTV18CAsyncWaiterClient @ 18 NONAME ; ## + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/fileopclient/group/FBFileOpClient.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/fileopclient/group/FBFileOpClient.mmp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include +#include + + +TARGET FileBrowserFileOpClient.dll +TARGETTYPE dll + +CAPABILITY CAP_GENERAL_DLL + +SMPSAFE + +UID 0x102828D7 +VENDORID VID_DEFAULT + + +USERINCLUDE ../inc +SOURCEPATH ../src +OS_LAYER_SYSTEMINCLUDE + + +SOURCE FBFileOpClient.cpp + +LIBRARY euser.lib diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/fileopclient/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/fileopclient/group/bld.inf Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,20 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +PRJ_MMPFILES +FBFileOpClient.mmp diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/fileopclient/inc/FBFileOpClient.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/fileopclient/inc/FBFileOpClient.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,108 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef __FBFILEOPCLIENT_H__ +#define __FBFILEOPCLIENT_H__ + +// INCLUDES +#include +#include +#include "FBFileOpClientServer.h" // TFileOpArgs + +// FORWARD DECLARATIONS + +// CLASS DECLARATIONS + +class RFBFileOpServerSession : public RSessionBase + { +public: + TInt Connect(); + + void Copy(const TDesC& aSourceFullName, const TDesC& aTargetFullName, TUint aSwitch, TRequestStatus& aStatus); + TInt Rename(const TDesC& anOld, const TDesC& aNew, TUint aSwitch); + TInt Attribs(const TDesC& aName, TUint aSetMask, TUint aClearMask, const TTime& aTime, TUint aSwitch); + void RmDir(const TDesC& aDirName, TUint aSwitch, TRequestStatus& aStatus); + void Delete(const TDesC& aName, TUint aSwitch, TRequestStatus& aStatus); + TInt MkDirAll(const TDesC& aPath); + TInt CreateEmptyFile(const TDesC& aName); + TInt EraseMBR(TUint aDriveNumber); + TInt PartitionDrive(TUint aDriveNumber, TUint aNumberOfPartitions); + TInt CancelOp(); + +private: + TVersion Version() const; + TPckgBuf iPckgBuf; + }; + + +class CFBFileOpClient : public CBase + { +public: + IMPORT_C static CFBFileOpClient* NewL(); + IMPORT_C ~CFBFileOpClient(); + IMPORT_C TInt Copy(const TDesC& aSourceFullName, const TDesC& aTargetFullName, TUint aSwitch); + IMPORT_C TInt Rename(const TDesC& anOld, const TDesC& aNew, TUint aSwitch); + IMPORT_C TInt Attribs(const TDesC& aName, TUint aSetMask, TUint aClearMask, const TTime& aTime, TUint aSwitch); + IMPORT_C TInt RmDir(const TDesC& aDirName, TUint aSwitch); + IMPORT_C TInt Delete(const TDesC& aName, TUint aSwitch); + IMPORT_C TInt MkDirAll(const TDesC& aPath); + IMPORT_C TInt CreateEmptyFile(const TDesC& aName); + IMPORT_C TInt EraseMBR(TUint aDriveNumber); + IMPORT_C TInt PartitionDrive(TUint aDriveNumber, TUint aNumberOfPartitions); + IMPORT_C void CancelOp(); + +private: + CFBFileOpClient(); + void ConstructL(); + + private : + RFBFileOpServerSession iFBFileOpServerSession; + }; + + +/** + * Similar class as CAsyncWaiter defined in FBUtils.h, except + * CAsyncWaiterClient uses iWait.AsyncStop() instead of + * CAknEnv::StopSchedulerWaitWithBusyMessage( iWait ) + * to stop the nested loop. This class can be utilized + * if CAknEnv is not running. + */ +class CAsyncWaiterClient : public CActive + { +public: + static CAsyncWaiterClient* NewL( TInt aPriority = EPriorityStandard ); + static CAsyncWaiterClient* NewLC( TInt aPriority = EPriorityStandard ); + ~CAsyncWaiterClient(); + + void StartAndWait(); + TInt Result() const; + +private: + CAsyncWaiterClient( TInt aPriority ); + + // from CActive + void RunL(); + void DoCancel(); + +private: + CActiveSchedulerWait iWait; + TInt iError; + }; + +#endif + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/fileopclient/inc/FBFileOpClientServer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/fileopclient/inc/FBFileOpClientServer.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef __FBCLIENTSERVER_H__ +#define __FBCLIENTSERVER_H__ + +#include + +const TUint KCopyServMajorVersionNumber = 1; +const TUint KCopyServMinorVersionNumber = 0; +const TUint KCopyServBuildVersionNumber = 0; + +_LIT(KMyServerName, "FileBrowserFileOpServer"); +_LIT(KMyServerImg, "FileBrowserFileOpServer"); // EXE name +const TUid KServerUid3 = {0x102828D8}; + +enum TFileOpMessages + { + EFileOpCopy, + EFileOpRename, + EFileOpAttribs, + EFileOpRmDir, + EFileOpDelete, + EFileOpMkDirAll, + EFileOpCreateEmptyFile, + EFileOpEraseMBR, + EFileOpPartitionDrive, + EFileOpCancel + }; + +class TFileOpArgs + { +public: + TFileName iBuf1; + TFileName iBuf2; + TUint iUint1; + TUint iUint2; + TUint iUint3; + TTime iTime1; + }; + +#endif \ No newline at end of file diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/fileopclient/src/FBFileOpClient.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/fileopclient/src/FBFileOpClient.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,481 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +// needed for client interface +#include "FBFileOpClient.h" + +const TUint KDefaultMessageSlots=4; + +// -------------------------------------------------------------------------------------------- + +static TInt StartServer() +// +// Start the server process. Simultaneous launching +// of two such processes should be detected when the second one attempts to +// create the server object, failing with KErrAlreadyExists. +// + { + const TUidType serverUid(KNullUid,KNullUid,KServerUid3); + RProcess server; + TInt r=server.Create(KMyServerImg,KNullDesC,serverUid); + if (r!=KErrNone) + return r; + TRequestStatus stat; + server.Rendezvous(stat); + if (stat!=KRequestPending) + server.Kill(0); // abort startup + else + server.Resume(); // logon OK - start the server + User::WaitForRequest(stat); // wait for start or death + // we can't use the 'exit reason' if the server panicked as this + // is the panic 'reason' and may be '0' which cannot be distinguished + // from KErrNone + r=(server.ExitType()==EExitPanic) ? KErrGeneral : stat.Int(); + server.Close(); + return r; + } + +// -------------------------------------------------------------------------------------------- + +TVersion RFBFileOpServerSession::Version(void) const + { + return(TVersion(KCopyServMajorVersionNumber,KCopyServMinorVersionNumber,KCopyServBuildVersionNumber)); + } + +// -------------------------------------------------------------------------------------------- + +TInt RFBFileOpServerSession::Connect() +// +// Connect to the server, attempting to start it if necessary +// + { + TInt retry=2; + for (;;) + { + TInt r=CreateSession(KMyServerName,Version(),KDefaultMessageSlots); + if (r!=KErrNotFound && r!=KErrServerTerminated) + return r; + if (--retry==0) + return r; + r=StartServer(); + if (r!=KErrNone && r!=KErrAlreadyExists) + return r; + } + } + +// -------------------------------------------------------------------------------------------- + +void RFBFileOpServerSession::Copy(const TDesC& aSourceFullName, const TDesC& aTargetFullName, TUint aSwitch, TRequestStatus& aStatus) + { + TFileOpArgs argsStruct = TFileOpArgs(); + argsStruct.iBuf1.Copy(aSourceFullName); + argsStruct.iBuf2.Copy(aTargetFullName); + argsStruct.iUint1 = aSwitch; + + iPckgBuf = argsStruct; + TIpcArgs args(&iPckgBuf); + SendReceive(EFileOpCopy, args, aStatus); + } + +// -------------------------------------------------------------------------------------------- + +TInt RFBFileOpServerSession::Rename(const TDesC& anOld, const TDesC& aNew, TUint aSwitch) + { + TFileOpArgs argsStruct = TFileOpArgs(); + argsStruct.iBuf1.Copy(anOld); + argsStruct.iBuf2.Copy(aNew); + argsStruct.iUint1 = aSwitch; + + TPckgBuf pckgBuf; + pckgBuf = argsStruct; + TIpcArgs args(&pckgBuf); + return SendReceive(EFileOpRename, args); + } + +// -------------------------------------------------------------------------------------------- + +TInt RFBFileOpServerSession::Attribs(const TDesC& aName, TUint aSetMask, TUint aClearMask, const TTime& aTime, TUint aSwitch) + { + TFileOpArgs argsStruct = TFileOpArgs(); + argsStruct.iBuf1.Copy(aName); + argsStruct.iUint1 = aSetMask; + argsStruct.iUint2 = aClearMask; + argsStruct.iTime1 = aTime; + argsStruct.iUint3 = aSwitch; + + TPckgBuf pckgBuf; + pckgBuf = argsStruct; + TIpcArgs args(&pckgBuf); + return SendReceive(EFileOpAttribs, args); + } + +// -------------------------------------------------------------------------------------------- + +void RFBFileOpServerSession::RmDir( const TDesC& aDirName, + TUint aSwitch, + TRequestStatus& aStatus ) + { + TFileOpArgs argsStruct = TFileOpArgs(); + argsStruct.iBuf1.Copy(aDirName); + argsStruct.iUint1 = aSwitch; + + iPckgBuf = argsStruct; + TIpcArgs args(&iPckgBuf); + SendReceive(EFileOpRmDir, args, aStatus); + } + +// -------------------------------------------------------------------------------------------- + +void RFBFileOpServerSession::Delete(const TDesC& aName, TUint aSwitch, TRequestStatus& aStatus) + { + TFileOpArgs argsStruct = TFileOpArgs(); + argsStruct.iBuf1.Copy(aName); + argsStruct.iUint1 = aSwitch; + + iPckgBuf = argsStruct; + TIpcArgs args(&iPckgBuf); + SendReceive(EFileOpDelete, args, aStatus); + } + +// -------------------------------------------------------------------------------------------- + +TInt RFBFileOpServerSession::MkDirAll(const TDesC& aPath) + { + TFileOpArgs argsStruct = TFileOpArgs(); + argsStruct.iBuf1.Copy(aPath); + + TPckgBuf pckgBuf; + pckgBuf = argsStruct; + TIpcArgs args(&pckgBuf); + return SendReceive(EFileOpMkDirAll, args); + } + +// -------------------------------------------------------------------------------------------- + +TInt RFBFileOpServerSession::CreateEmptyFile(const TDesC& aName) + { + TFileOpArgs argsStruct = TFileOpArgs(); + argsStruct.iBuf1.Copy(aName); + + TPckgBuf pckgBuf; + pckgBuf = argsStruct; + TIpcArgs args(&pckgBuf); + return SendReceive(EFileOpCreateEmptyFile, args); + } +// -------------------------------------------------------------------------------------------- + +TInt RFBFileOpServerSession::EraseMBR(TUint aDriveNumber) + { + TFileOpArgs argsStruct = TFileOpArgs(); + argsStruct.iUint1 = aDriveNumber; + + TPckgBuf pckgBuf; + pckgBuf = argsStruct; + TIpcArgs args(&pckgBuf); + return SendReceive(EFileOpEraseMBR, args); + } + +// -------------------------------------------------------------------------------------------- + +TInt RFBFileOpServerSession::PartitionDrive(TUint aDriveNumber, TUint aNumberOfPartitions) + { + TFileOpArgs argsStruct = TFileOpArgs(); + argsStruct.iUint1 = aDriveNumber; + argsStruct.iUint2 = aNumberOfPartitions; + + TPckgBuf pckgBuf; + pckgBuf = argsStruct; + TIpcArgs args(&pckgBuf); + return SendReceive(EFileOpPartitionDrive, args); + } + +// -------------------------------------------------------------------------------------------- + +TInt RFBFileOpServerSession::CancelOp() + { + TIpcArgs args( NULL ); + return SendReceive( EFileOpCancel, args ); + } + +// -------------------------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------- + +EXPORT_C CFBFileOpClient* CFBFileOpClient::NewL() + { + CFBFileOpClient* self = new(ELeave) CFBFileOpClient; + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// -------------------------------------------------------------------------------------------- + +EXPORT_C CFBFileOpClient::~CFBFileOpClient() + { + iFBFileOpServerSession.Close(); + } + +// -------------------------------------------------------------------------------------------- + +CFBFileOpClient::CFBFileOpClient() + { + } + +// -------------------------------------------------------------------------------------------- + +void CFBFileOpClient::ConstructL() + { + User::LeaveIfError(iFBFileOpServerSession.Connect()); + } + +// -------------------------------------------------------------------------------------------- + +EXPORT_C TInt CFBFileOpClient::Copy( const TDesC& aSourceFullName, + const TDesC& aTargetFullName, + TUint aSwitch ) + { + CAsyncWaiterClient* waiter = CAsyncWaiterClient::NewLC(); + iFBFileOpServerSession.Copy( aSourceFullName, aTargetFullName, aSwitch, waiter->iStatus ); + waiter->StartAndWait(); + TInt err = waiter->Result(); + + if ( err == KErrServerTerminated ) + { + User::LeaveIfError( iFBFileOpServerSession.Connect() ); + iFBFileOpServerSession.Copy( aSourceFullName, aTargetFullName, aSwitch, waiter->iStatus ); + waiter->StartAndWait(); + err = waiter->Result(); + } + CleanupStack::PopAndDestroy( waiter ); + return err; + } + +// -------------------------------------------------------------------------------------------- + +EXPORT_C TInt CFBFileOpClient::Rename(const TDesC& anOld, const TDesC& aNew, TUint aSwitch) + { + TInt err = iFBFileOpServerSession.Rename(anOld, aNew, aSwitch); + + if (err == KErrServerTerminated) + { + User::LeaveIfError(iFBFileOpServerSession.Connect()); + err = iFBFileOpServerSession.Rename(anOld, aNew, aSwitch); + } + + return err; + } + +// -------------------------------------------------------------------------------------------- + +EXPORT_C TInt CFBFileOpClient::Attribs(const TDesC& aName, TUint aSetMask, TUint aClearMask, const TTime& aTime, TUint aSwitch) + { + TInt err = iFBFileOpServerSession.Attribs(aName, aSetMask, aClearMask, aTime, aSwitch); + + if (err == KErrServerTerminated) + { + User::LeaveIfError(iFBFileOpServerSession.Connect()); + err = iFBFileOpServerSession.Attribs(aName, aSetMask, aClearMask, aTime, aSwitch); + } + + return err; + } + +// -------------------------------------------------------------------------------------------- + +EXPORT_C TInt CFBFileOpClient::RmDir(const TDesC& aDirName, TUint aSwitch) + { + CAsyncWaiterClient* waiter = CAsyncWaiterClient::NewLC(); + iFBFileOpServerSession.RmDir( aDirName, aSwitch, waiter->iStatus ); + waiter->StartAndWait(); + TInt err = waiter->Result(); + + if ( err == KErrServerTerminated ) + { + User::LeaveIfError( iFBFileOpServerSession.Connect() ); + iFBFileOpServerSession.RmDir( aDirName, aSwitch, waiter->iStatus ); + waiter->StartAndWait(); + err = waiter->Result(); + } + CleanupStack::PopAndDestroy( waiter ); + return err; + } + +// -------------------------------------------------------------------------------------------- + +EXPORT_C TInt CFBFileOpClient::Delete(const TDesC& aName, TUint aSwitch) + { + CAsyncWaiterClient* waiter = CAsyncWaiterClient::NewLC(); + iFBFileOpServerSession.Delete(aName, aSwitch, waiter->iStatus ); + waiter->StartAndWait(); + TInt err = waiter->Result(); + + if ( err == KErrServerTerminated ) + { + User::LeaveIfError( iFBFileOpServerSession.Connect() ); + iFBFileOpServerSession.Delete(aName, aSwitch, waiter->iStatus ); + waiter->StartAndWait(); + err = waiter->Result(); + } + CleanupStack::PopAndDestroy( waiter ); + return err; + } + +// -------------------------------------------------------------------------------------------- + +EXPORT_C TInt CFBFileOpClient::MkDirAll(const TDesC& aPath) + { + TInt err = iFBFileOpServerSession.MkDirAll(aPath); + + if (err == KErrServerTerminated) + { + User::LeaveIfError(iFBFileOpServerSession.Connect()); + err = iFBFileOpServerSession.MkDirAll(aPath); + } + + return err; + } + +// -------------------------------------------------------------------------------------------- + +EXPORT_C TInt CFBFileOpClient::CreateEmptyFile(const TDesC& aName) + { + TInt err = iFBFileOpServerSession.CreateEmptyFile(aName); + + if (err == KErrServerTerminated) + { + User::LeaveIfError(iFBFileOpServerSession.Connect()); + err = iFBFileOpServerSession.CreateEmptyFile(aName); + } + + return err; + } + +// -------------------------------------------------------------------------------------------- + +EXPORT_C TInt CFBFileOpClient::EraseMBR(TUint aDriveNumber) + { + TInt err = iFBFileOpServerSession.EraseMBR(aDriveNumber); + + if (err == KErrServerTerminated) + { + User::LeaveIfError(iFBFileOpServerSession.Connect()); + err = iFBFileOpServerSession.EraseMBR(aDriveNumber); + } + + return err; + } + +// -------------------------------------------------------------------------------------------- + +EXPORT_C TInt CFBFileOpClient::PartitionDrive(TUint aDriveNumber, TUint aNumberOfPartitions) + { + TInt err = iFBFileOpServerSession.PartitionDrive(aDriveNumber, aNumberOfPartitions); + + if (err == KErrServerTerminated) + { + User::LeaveIfError(iFBFileOpServerSession.Connect()); + err = iFBFileOpServerSession.PartitionDrive(aDriveNumber, aNumberOfPartitions); + } + + return err; + } + +// -------------------------------------------------------------------------------------------- + +EXPORT_C void CFBFileOpClient::CancelOp() + { + TInt err = iFBFileOpServerSession.CancelOp(); + + if ( err == KErrServerTerminated ) + { + User::LeaveIfError( iFBFileOpServerSession.Connect() ); + err = iFBFileOpServerSession.CancelOp(); // Ignore return value this time + } + } + +// -------------------------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------- + +CAsyncWaiterClient* CAsyncWaiterClient::NewL( TInt aPriority ) + { + CAsyncWaiterClient* self = new(ELeave) CAsyncWaiterClient( aPriority ); + return self; + } + +// -------------------------------------------------------------------------------------------- + +CAsyncWaiterClient* CAsyncWaiterClient::NewLC( TInt aPriority ) + { + CAsyncWaiterClient* self = new (ELeave) CAsyncWaiterClient( aPriority ); + CleanupStack::PushL( self ); + return self; + } + +// -------------------------------------------------------------------------------------------- + +CAsyncWaiterClient::CAsyncWaiterClient( TInt aPriority ) : CActive( aPriority ) + { + CActiveScheduler::Add( this ); + } + +// -------------------------------------------------------------------------------------------- + +CAsyncWaiterClient::~CAsyncWaiterClient() + { + Cancel(); + } + +// -------------------------------------------------------------------------------------------- + +void CAsyncWaiterClient::StartAndWait() + { + SetActive(); + iWait.Start(); + } + +// -------------------------------------------------------------------------------------------- + +TInt CAsyncWaiterClient::Result() const + { + return iError; + } + +// -------------------------------------------------------------------------------------------- + +void CAsyncWaiterClient::RunL() + { + iError = iStatus.Int(); + iWait.AsyncStop(); + } + +// -------------------------------------------------------------------------------------------- + +void CAsyncWaiterClient::DoCancel() + { + iError = KErrCancel; + if( iStatus == KRequestPending ) + { + TRequestStatus* s = &iStatus; + User::RequestComplete( s, KErrCancel ); + } + iWait.AsyncStop(); + } + +// -------------------------------------------------------------------------------------------- + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/fileopserver/group/FBFileOpServer.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/fileopserver/group/FBFileOpServer.mmp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include +#include + + +TARGET FileBrowserFileOpServer.exe +TARGETTYPE exe +UID 0 0x102828D8 +VENDORID VID_DEFAULT + +CAPABILITY CAP_FILE_SERVER + +SMPSAFE + +USERINCLUDE ../inc +USERINCLUDE ../../fileopclient/inc +OS_LAYER_SYSTEMINCLUDE +//SYSTEMINCLUDE /epoc32/include/kernel +SOURCEPATH ../src + + +SOURCE FBFileOpServer.cpp +SOURCE FBDrivePartitioner.cpp + +LIBRARY euser.lib +LIBRARY efsrv.lib +LIBRARY efile.lib diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/fileopserver/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/fileopserver/group/bld.inf Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,20 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +PRJ_MMPFILES +FBFileOpServer.mmp diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/fileopserver/inc/FBDrivePartitioner.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/fileopserver/inc/FBDrivePartitioner.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef __FBDRIVEPARTITIONER_H__ +#define __FBDRIVEPARTITIONER_H__ + +#include +#include + +class FBDrivePartioner + { +public: + static TInt FindLocalDriveNumber(RFs& aFs, TInt aDriveNumber, TInt& aLocalDriveNum); + static TInt EraseMBR(RFs& aFs, TInt aDriveNumber); + static TInt CreatePartitions(RFs& aFs, TInt aDriveNumber, TInt aPartCount); + static TInt FormatPartitions(RFs& aFs, TInt aDriveNumber, TInt aPartCount); + }; + + +#endif diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/fileopserver/inc/FBFileOpServer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/fileopserver/inc/FBFileOpServer.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,186 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef __FBFILEOPSERVER_H__ +#define __FBFILEOPSERVER_H__ + +#include +#include +#include "FBFileOpClientServer.h" + +// needed for creating server thread. +//const TUint KDefaultHeapSize=0x10000; + +// reasons for server panic +enum TMyPanic + { + EPanicBadDescriptor, + EPanicIllegalFunction + }; + +class CShutdown : public CTimer + { + enum {KMyShutdownDelay=0x200000}; // approx 2s + +public : + inline CShutdown(); + inline void ConstructL(); + inline void Start(); + +private : + void RunL(); + }; + +//********************************** +//CFBFileOpServer +//********************************** +/** +Our server class - an active object - and therefore derived ultimately from CActive. +It accepts requests from client threads and forwards +them to the client session to be dealt with. It also handles the creation +of the server-side client session. +*/ +class CFBFileOpServer : public CServer2 + { + +public : + static CServer2* NewLC(); + void AddSession(); + void DropSession(); + +protected : + +private : + CFBFileOpServer(); + void ConstructL(); + CSession2* NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const; + +public : + +private : + TInt iSessionCount; + CShutdown iShutdown; + + }; + +//********************************** +//CRequestObserver +//********************************** +/** +This class is for monitoring asynchronous request +and for completing related RMessage2 object. +*/ +class CRequestObserver : public CActive + { +public: + CRequestObserver( TInt aPriority ); + virtual ~CRequestObserver(); + + void StartWaiting( const RMessage2& aMsg ); + +private: + // from CActive + void RunL(); + void DoCancel(); + +private: + RMessage2 iMsg; + }; + + +//********************************** +//CFBFileOpServerSession +//********************************** +/** +This class represents a session with the server. +Functions are provided to respond appropriately to client messages. +*/ +class CFBFileOpServerSession : public CSession2, + public MFileManObserver + { + +public : + CFBFileOpServerSession(); + +private: // From MFileManObserver + + TControl NotifyFileManStarted(); + TControl NotifyFileManOperation(); + TControl NotifyFileManEnded(); + +protected : + // panic the client + void PanicClient(const RMessage2& aMessage,TInt aPanic) const; + +private : + ~CFBFileOpServerSession(); + inline CFBFileOpServer& Server(); + void CreateL(); + + //service requests + void ServiceL(const RMessage2& aMessage); + void DispatchMessageL(const RMessage2& aMessage, TBool& aComplete); + + void CopyL(const RMessage2& aMessage); + void RenameL(const RMessage2& aMessage); + void AttribsL(const RMessage2& aMessage); + void RmDirL(const RMessage2& aMessage, TBool& aComplete); + void DeleteL(const RMessage2& aMessage); + void MkDirAllL(const RMessage2& aMessage); + void CreateEmptyFileL(const RMessage2& aMessage); + void EraseMBRL(const RMessage2& aMessage); + void PartitionDriveL(const RMessage2& aMessage); + + void ServiceError(const RMessage2& aMessage, TInt aError); + + void CancelOp(); + +private : + RFs iFs; + RFile iFile; + CFileMan* iFileMan; + MFileManObserver::TControl iFileManObserverResult; + CRequestObserver* iReqObserver; + }; + + +//********************************** +//Inlines +//********************************** + +inline CShutdown::CShutdown() + :CTimer(-1) + {CActiveScheduler::Add(this);} + +inline void CShutdown::ConstructL() + {CTimer::ConstructL();} + +inline void CShutdown::Start() + {After(KMyShutdownDelay);} + +inline CFBFileOpServer::CFBFileOpServer() + :CServer2(0,ESharableSessions) + {} + +inline CFBFileOpServerSession::CFBFileOpServerSession() + {} + +inline CFBFileOpServer& CFBFileOpServerSession::Server() + {return *static_cast(const_cast(CSession2::Server()));} + +#endif diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/fileopserver/src/FBDrivePartitioner.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/fileopserver/src/FBDrivePartitioner.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,454 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include +#include +#include +#include + +#include "FBDrivePartitioner.h" + + +// copied from coreapplicationuisdomainpskeys.h +const TUid KPSUidCoreApplicationUIs = { 0x101F8767 }; +const TUint32 KCoreAppUIsMmcRemovedWithoutEject = 0x00000109; +enum TCoreAppUIsMmcRemovedWithoutEject + { + ECoreAppUIsEjectCommandUsedUninitialized = 0, + ECoreAppUIsEjectCommandNotUsed, + ECoreAppUIsEjectCommandUsed, + ECoreAppUIsEjectCommandUsedToDrive // Low 16-bits contain this value and high 16-bits TDriveNumber to eject + }; + + +// trace macros +#define TRACE(a) {_LIT( KMsg, a ); RDebug::Print(KMsg);} +#define TRACE1(a,b) {_LIT( KMsg, a ); RDebug::Print(KMsg,b);} +#define TRACE2(a,b,c) {_LIT( KMsg, a ); RDebug::Print(KMsg,b,c);} + + +// Set the partition alignment boundary +const TInt KPartitionAlignment = 0x1000; // 4kB +const TInt KMBRSize = 512; +const TInt KSectorSize = 512; +const TInt KMBRPartitionInfoOffset = 0x1BE; +const TInt KLargeFAT16Partition = 0x2000000; // 32MB +const TInt KPartitionEntrySize = 16; + +// Set for the iX86BootIndicator +//const TInt KPartitionBootable = 0x80; +const TInt KPartitionNonBootable = 0x0; + + +class TMBRPartition + { +public: + TUint8 iX86BootIndicator; + TUint8 iStartHead; + TUint8 iStartSector; + TUint8 iStartCylinder; + TUint8 iPartitionType; + TUint8 iEndHead; + TUint8 iEndSector; + TUint8 iEndCylinder; + TUint32 iFirstSector; + TUint32 iNumSectors; + }; + + +// -------------------------------------------------------------------------------------------- + +TInt FBDrivePartioner::FindLocalDriveNumber(RFs& aFs, TInt aDriveNumber, TInt& aLocalDriveNum) + { + TRACE1( "FBDrivePartitioner::FindLocalDriveNumber: start aDriveNumber=%d", aDriveNumber ); + + TInt err(KErrNone); + + TDriveInfo driveInfo; + err = aFs.Drive(driveInfo, aDriveNumber); + + TRACE1( "FBDrivePartitioner::FindLocalDriveNumber: get DriveInfo err=%d", err ); + + + TVolumeInfo vi; + err = aFs.Volume(vi, aDriveNumber); + + TRACE1( "FBDrivePartitioner::FindLocalDriveNumber: get VolumeInfo err=%d", err ); + + + TMediaSerialNumber serialNum; + err = aFs.GetMediaSerialNumber(serialNum, aDriveNumber); + + TRACE1( "FBDrivePartitioner::FindLocalDriveNumber: get MediaSerialNumber err=%d", err ); + + + TInt len = serialNum.Length(); + TInt n(0); + for (n=0; n buf; + for (TInt m=n; m hexBuf; + hexBuf.Format(_L("%02X "),serialNum[m]); + buf.Append(hexBuf); + } + buf.Append(_L("\n")); + } + + TBusLocalDrive drv; + TBool chg(EFalse); + aLocalDriveNum = -1; + for (n=0; n mbrBuf; + mbrBuf.Fill(0, mbrBuf.MaxLength()); + +/* + // write the next 16 sectors with the buffer. Usually you only write the first one, but this one should erase any following invalid sectors + for (TInt i=0; i<16; i++) + { + err = drv.Write(i*KMBRSize, KMBRSize, &mbrBuf, -1 , 0, 0x40000000); // RLocalDrive::ELocDrvWholeMedia==0x40000000 + TRACE2("FBDrivePartitioner::EraseMBR: sector %d, write returns %d", i+1, err); + } +*/ + + // erase the MBR + err = drv.Write(0, KMBRSize, &mbrBuf, -1 , 0, 0x40000000); // RLocalDrive::ELocDrvWholeMedia==0x40000000 + TRACE1("FBDrivePartitioner::EraseMBR: write returns %d", err); + + drv.Disconnect(); + + // force a remount, if this is the protected area, then it will have to be remounted + TRACE1( "FBDrivePartitioner::EraseMBR: Remounting drive number %d", aDriveNumber ); + TInt err2 = aFs.RemountDrive(aDriveNumber, NULL, 0); + TRACE1( "FBDrivePartitioner::EraseMBR: RemountDrive err2=%d", err2 ); + + TRACE1( "FBDrivePartitioner::EraseMBR: returns %d", err ); + return err; + } + +// -------------------------------------------------------------------------------------------- + +TInt FBDrivePartioner::CreatePartitions(RFs& aFs, TInt aDriveNumber, TInt aPartCount) + { + TRACE2( "FBDrivePartitioner::CreatePartitions: start aDriveNumber=%d aPartCount=%d", aDriveNumber, aPartCount ); + TInt err(KErrNone); + + TUint8 MBRPartitionInfo[ KPartitionEntrySize*KMBRMaxPrimaryPartitions ]; + + // Prevent SysAp shutting down applications + RProperty::Set( + KPSUidCoreApplicationUIs, + KCoreAppUIsMmcRemovedWithoutEject, + ECoreAppUIsEjectCommandUsed ); + + // Force the system to read the memory card erased MBR + err = aFs.RemountDrive( aDriveNumber ); + TRACE1( "FBDrivePartitioner::CreatePartitions: Remount result %d", err ); + + // Get the number of partitions from user + TUint8 partitionCount(aPartCount); + TBool change = EFalse; + TInt mcDriveNbr(2); + TLocalDriveCapsV4 dc; + TInt64 diskSpace(0); + +/* + err = FindLocalDriveNumber(aFs, aDriveNumber, mcDriveNbr); + + if (err != KErrNone) + { + TRACE1("FBDrivePartitioner::CreatePartitions: FindLocalDriveNumber err=%d returning", err); + return err; + } +*/ + + // Seek through the system drives to find memory card drive + for (TInt i = 0; i < KMaxLocalDrives; ++i) + { + RLocalDrive d; + change = EFalse; + err = d.Connect(i, change); + if (err == KErrNone) + { + TPckg capsPack(dc); + + if (d.Caps(capsPack) == KErrNone) + { + if (dc.iType == EMediaHardDisk) + { + mcDriveNbr = i; + diskSpace = dc.iSize; + TRACE1( "FBDrivePartitioner::CreatePartitions: found hard drive %d:", mcDriveNbr ); + } + } + d.Close(); + } + } + + // Connect to the local drive we found + RLocalDrive localDrive; + change = EFalse; + err = localDrive.Connect( mcDriveNbr, change ); + TRACE2( "FBDrivePartitioner::CreatePartitions: localDrive.Connect %d: %d", mcDriveNbr, err ); + TRACE1( "FBDrivePartitioner::CreatePartitions: diskSpace in sectors 0x%x, %d", diskSpace / KSectorSize ); + + // Let's read the MBR by using RLocalDrive + TUint8 data[KMBRSize]; + TPtr8 buf( &data[0], KMBRSize ); + err = localDrive.Read( 0, KMBRSize, buf ); + TRACE1( "FBDrivePartitioner::CreatePartitions: localDrive.Read %d", err ); + // Let's check the current drive layout here + memcpy( MBRPartitionInfo, &data[KMBRPartitionInfoOffset],(sizeof(TMBRPartition)<<2)); + TMBRPartition *partitionInfo = (TMBRPartition*) MBRPartitionInfo; + + // Clean the rest of the MBR buffer + buf.FillZ(); + + // Print out the partition info + for( TInt i = 0; i 0) + { + err = fmt.Next(count); + if (err != KErrNone) + { + TRACE1( "FBDrivePartitioner::FormatPartitions: Format error=%d", err ); + break; + } + } + fmt.Close(); + TRACE1( "FBDrivePartitioner::FormatPartitions: Format %S end", &name ); + } + + TRACE1("FBDrivePartitioner::FormatPartitions returns %d", err); + + return err; + } + +// -------------------------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/fileopserver/src/FBFileOpServer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/fileopserver/src/FBFileOpServer.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,474 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include "FBFileOpServer.h" +#include "FBDrivePartitioner.h" + +#include +#include + +// -------------------------------------------------------------------------------------------- + +//*********************************** +//CFBFileOpServer - implementations +//*********************************** + +CServer2* CFBFileOpServer::NewLC() + { + CFBFileOpServer* self = new(ELeave) CFBFileOpServer; + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +// -------------------------------------------------------------------------------------------- + +// +// 2nd phase construction - ensure the timer and server objects are running +// +void CFBFileOpServer::ConstructL() + { + StartL(KMyServerName); + iShutdown.ConstructL(); + // ensure that the server still exits even if the 1st client fails to connect + iShutdown.Start(); + } + +// -------------------------------------------------------------------------------------------- + +// +// Cretae a new client session. This should really check the version number. +// +CSession2* CFBFileOpServer::NewSessionL(const TVersion&,const RMessage2&) const + { + return new(ELeave) CFBFileOpServerSession(); + } + +// -------------------------------------------------------------------------------------------- + +// +// A new session is being created +// Cancel the shutdown timer if it was running +// +void CFBFileOpServer::AddSession() + { + ++iSessionCount; + iShutdown.Cancel(); + } + +// -------------------------------------------------------------------------------------------- + +// +// A session is being destroyed +// Start the shutdown timer if it is the last session. +// +void CFBFileOpServer::DropSession() + { + if (--iSessionCount==0) + iShutdown.Start(); + } + +// -------------------------------------------------------------------------------------------- + +CRequestObserver::CRequestObserver( TInt aPriority ) : CActive( aPriority ) + { + CActiveScheduler::Add( this ); + } + +CRequestObserver::~CRequestObserver() + { + Cancel(); + } + +void CRequestObserver::StartWaiting( const RMessage2& aMsg ) + { + iMsg = aMsg; + SetActive(); + } + +void CRequestObserver::RunL() + { + iMsg.Complete( iStatus.Int() ); + } + +void CRequestObserver::DoCancel() + { + iMsg.Complete( KErrCancel ); + } + +// -------------------------------------------------------------------------------------------- + +//*********************************** +//CFBFileOpServerSession - implementations +//*********************************** + +// +// 2nd phase construct for sessions - called by the CServer framework +// +void CFBFileOpServerSession::CreateL() + { + User::LeaveIfError(iFs.Connect()); + iFileMan = CFileMan::NewL( iFs, this ); + iReqObserver = new (ELeave) CRequestObserver( CActive::EPriorityStandard ); + Server().AddSession(); + } + +// -------------------------------------------------------------------------------------------- + +CFBFileOpServerSession::~CFBFileOpServerSession() + { + if (iFileMan) + { + delete iFileMan; + iFileMan = NULL; + } + iFs.Close(); + delete iReqObserver; + Server().DropSession(); + } + +// -------------------------------------------------------------------------------------------- + +/** +Services a client request. +*/ +void CFBFileOpServerSession::ServiceL(const RMessage2& aMessage) + { + TBool completeImmediately( ETrue ); + TRAPD( err,DispatchMessageL( aMessage, completeImmediately ) ); + if ( completeImmediately ) aMessage.Complete( err ); + } + +// -------------------------------------------------------------------------------------------- + +/** +Called by ServiceL() + +It tests the function code and then delegates to +the appropriate function. +*/ +void CFBFileOpServerSession::DispatchMessageL(const RMessage2& aMessage, TBool& aComplete) + { + switch (aMessage.Function()) + { + case EFileOpCopy: + CopyL(aMessage); + aComplete = EFalse; + return; + + case EFileOpRename: + RenameL(aMessage); + return; + + case EFileOpAttribs: + AttribsL(aMessage); + return; + + case EFileOpRmDir: + RmDirL(aMessage, aComplete); + return; + + case EFileOpDelete: + DeleteL(aMessage); + aComplete = EFalse; + return; + + case EFileOpMkDirAll: + MkDirAllL(aMessage); + return; + + case EFileOpCreateEmptyFile: + CreateEmptyFileL(aMessage); + return; + + case EFileOpEraseMBR: + EraseMBRL(aMessage); + return; + + case EFileOpPartitionDrive: + PartitionDriveL(aMessage); + return; + + case EFileOpCancel: + CancelOp(); + return; + + default: + PanicClient(aMessage, EPanicIllegalFunction); + return; + } + } + +// -------------------------------------------------------------------------------------------- + +void CFBFileOpServerSession::CopyL( const RMessage2& aMessage ) + { + __ASSERT_ALWAYS( iReqObserver && !iReqObserver->IsActive(), User::Leave( KErrServerBusy ) ); + TPckgBuf pckgBuf; + aMessage.ReadL( 0, pckgBuf, 0 ); + TFileOpArgs argsStruct = pckgBuf(); + + TInt err = iFileMan->Copy( argsStruct.iBuf1, argsStruct.iBuf2, argsStruct.iUint1, iReqObserver->iStatus ); + User::LeaveIfError( err ); + iFileManObserverResult = MFileManObserver::EContinue; + iReqObserver->StartWaiting( aMessage ); // start asynchronous waiting + } + +// -------------------------------------------------------------------------------------------- + +void CFBFileOpServerSession::RenameL(const RMessage2& aMessage) + { + TPckgBuf pckgBuf; + aMessage.ReadL(0, pckgBuf, 0); + TFileOpArgs argsStruct = pckgBuf(); + + iFileManObserverResult = MFileManObserver::EContinue; + User::LeaveIfError(iFileMan->Rename(argsStruct.iBuf1, argsStruct.iBuf2, argsStruct.iUint1)); + } + +// -------------------------------------------------------------------------------------------- + +void CFBFileOpServerSession::AttribsL(const RMessage2& aMessage) + { + TPckgBuf pckgBuf; + aMessage.ReadL(0, pckgBuf, 0); + TFileOpArgs argsStruct = pckgBuf(); + + iFileManObserverResult = MFileManObserver::EContinue; + User::LeaveIfError(iFileMan->Attribs(argsStruct.iBuf1, argsStruct.iUint1, argsStruct.iUint2, argsStruct.iTime1, argsStruct.iUint3)); + } + +// -------------------------------------------------------------------------------------------- + +void CFBFileOpServerSession::RmDirL( const RMessage2& aMessage, TBool& aComplete ) + { + TPckgBuf pckgBuf; + aMessage.ReadL( 0, pckgBuf, 0 ); + TFileOpArgs argsStruct = pckgBuf(); + + if ( argsStruct.iUint1 & CFileMan::ERecurse ) + { + __ASSERT_ALWAYS( iReqObserver && !iReqObserver->IsActive(), User::Leave( KErrServerBusy ) ); + User::LeaveIfError( iFileMan->RmDir( argsStruct.iBuf1, iReqObserver->iStatus ) ); + iFileManObserverResult = MFileManObserver::EContinue; + aComplete = EFalse; + iReqObserver->StartWaiting( aMessage ); // start asynchronous waiting + } + else + { + iFileManObserverResult = MFileManObserver::EContinue; + User::LeaveIfError( iFs.RmDir( argsStruct.iBuf1 ) ); + } + } + +// -------------------------------------------------------------------------------------------- + +void CFBFileOpServerSession::DeleteL( const RMessage2& aMessage ) + { + __ASSERT_ALWAYS( iReqObserver && !iReqObserver->IsActive(), User::Leave( KErrServerBusy ) ); + TPckgBuf pckgBuf; + aMessage.ReadL( 0, pckgBuf, 0 ); + TFileOpArgs argsStruct = pckgBuf(); + + User::LeaveIfError( iFileMan->Delete(argsStruct.iBuf1, argsStruct.iUint1, iReqObserver->iStatus ) ); + iFileManObserverResult = MFileManObserver::EContinue; + iReqObserver->StartWaiting( aMessage ); // start asynchronous waiting + } + +// -------------------------------------------------------------------------------------------- + +void CFBFileOpServerSession::MkDirAllL(const RMessage2& aMessage) + { + TPckgBuf pckgBuf; + aMessage.ReadL(0, pckgBuf, 0); + TFileOpArgs argsStruct = pckgBuf(); + + User::LeaveIfError(iFs.MkDirAll(argsStruct.iBuf1)); + } + +// -------------------------------------------------------------------------------------------- + +void CFBFileOpServerSession::CreateEmptyFileL(const RMessage2& aMessage) + { + TPckgBuf pckgBuf; + aMessage.ReadL(0, pckgBuf, 0); + TFileOpArgs argsStruct = pckgBuf(); + + TInt err(KErrNone); + RFile newFile; + err = newFile.Create(iFs, argsStruct.iBuf1, EFileShareExclusive); + if (err == KErrNone) + err = newFile.Flush(); + newFile.Close(); + + User::LeaveIfError(err); + } + +// -------------------------------------------------------------------------------------------- + +void CFBFileOpServerSession::EraseMBRL(const RMessage2& aMessage) + { + TPckgBuf pckgBuf; + aMessage.ReadL(0, pckgBuf, 0); + TFileOpArgs argsStruct = pckgBuf(); + + RFs fs; + CleanupClosePushL(fs); + User::LeaveIfError(fs.Connect()); + + User::LeaveIfError(FBDrivePartioner::EraseMBR(fs, argsStruct.iUint1)); + + CleanupStack::PopAndDestroy(); //fs + } + +// -------------------------------------------------------------------------------------------- + +void CFBFileOpServerSession::PartitionDriveL(const RMessage2& aMessage) + { + TPckgBuf pckgBuf; + aMessage.ReadL(0, pckgBuf, 0); + TFileOpArgs argsStruct = pckgBuf(); + + RFs fs; + CleanupClosePushL(fs); + User::LeaveIfError(fs.Connect()); + + FBDrivePartioner::CreatePartitions(fs, argsStruct.iUint1, argsStruct.iUint2); + User::LeaveIfError(FBDrivePartioner::FormatPartitions(fs, argsStruct.iUint1, argsStruct.iUint2)); + + CleanupStack::PopAndDestroy(); //fs + } + +// -------------------------------------------------------------------------------------------- + +// +// Panics the client +// +void CFBFileOpServerSession::PanicClient(const RMessage2& aMessage, TInt aPanic) const + { + _LIT(KTxtServer,"FBFileOpServer"); + aMessage.Panic(KTxtServer, aPanic); + } + +// -------------------------------------------------------------------------------------------- + +// +// Handle an error from CFBFileOpServerSession::ServiceL() +// A bad descriptor error implies a badly programmed client, so panic it; +// otherwise use the default handling (report the error to the client) +// +void CFBFileOpServerSession::ServiceError(const RMessage2& aMessage, TInt aError) + { + if (aError==KErrBadDescriptor) + PanicClient(aMessage,EPanicBadDescriptor); + CSession2::ServiceError(aMessage,aError); + } + +// -------------------------------------------------------------------------------------------- + +MFileManObserver::TControl CFBFileOpServerSession::NotifyFileManStarted() + { + return iFileManObserverResult; + } + +// -------------------------------------------------------------------------------------------- + +MFileManObserver::TControl CFBFileOpServerSession::NotifyFileManOperation() + { + return iFileManObserverResult; + } +// -------------------------------------------------------------------------------------------- + +MFileManObserver::TControl CFBFileOpServerSession::NotifyFileManEnded() + { + return iFileManObserverResult; + } + +// -------------------------------------------------------------------------------------------- + +void CFBFileOpServerSession::CancelOp() + { + iFileManObserverResult = MFileManObserver::ECancel; + iReqObserver->Cancel(); + } + +// -------------------------------------------------------------------------------------------- + +//********************************** +//Global functions +//********************************** + +// +// Initiate server exit when the timer expires +// +void CShutdown::RunL() + { + CActiveScheduler::Stop(); + } + +// -------------------------------------------------------------------------------------------- + +// +// Perform all server initialisation, in particular creation of the +// scheduler and server and then run the scheduler +// +static void RunServerL() + { + // naming the server thread after the server helps to debug panics + User::LeaveIfError(RThread::RenameMe(KMyServerName)); + // + // create and install the active scheduler we need + CActiveScheduler* s=new(ELeave) CActiveScheduler; + CleanupStack::PushL(s); + CActiveScheduler::Install(s); + // + // create the server (leave it on the cleanup stack) + CFBFileOpServer::NewLC(); + // + // Initialisation complete, now signal the client + RProcess::Rendezvous(KErrNone); + // + // Ready to run + CActiveScheduler::Start(); + // + // Cleanup the server and scheduler + CleanupStack::PopAndDestroy(2); + } + +// -------------------------------------------------------------------------------------------- + +// +// Server process entry-point +// +TInt E32Main() + { + __UHEAP_MARK; + // + CTrapCleanup* cleanup=CTrapCleanup::New(); + TInt r=KErrNoMemory; + if (cleanup) + { + TRAP(r,RunServerL()); + delete cleanup; + } + // + __UHEAP_MARKEND; + return r; + } + +// -------------------------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/group/ReleaseNotes_FileBrowser.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/group/ReleaseNotes_FileBrowser.txt Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,278 @@ +=============================================================================== + +RELEASE NOTES - FILEBROWSER v5.3.0 +RELEASED 24th September 2010 + +SUPPORTS S60 3.0+ + +=============================================================================== + +Product Description: +==================== +The FileBrowser tool can be used to browse directory hierarchies and perform +file operations under the S60 environment. It also contains some smaller tools +and functionalities that help RnD development and verification. + +Main Features: +============== +- Showing a drive list +- Browsing through directory hierarchies +- Disk admin tools for generic disk operations +- Searching files with different parameters +- Full clipboard functionality +- Copying/moving files with the help of a separate dialog +- Creating new files and directories +- Showing properties of files, directories and disks +- Sending, deleting, renaming, touching, setting attributes, + compressing and uncompressing of files +- Recursive directory support +- Sorting and ordering file view +- Filtering entries with a search field +- Text and hex viewer for files +- A settings screen for altering different kind of settings +- Data type viewer/editor +- Ability to give TCB capability for file operations +- Showing message attachments from Symbian messaging store +- Touch UI toolbar (S60 5.x only) + +=============================================================================== + +What's New in v5.3.0 +==================== +- Destination folder selection dialog updates +- Property dialog improved +- Toolbar placed to right in landscape +- New toobak button icons + +=============================================================================== + +Installation Notes: +=================== +FileBrowser is typically preinstalled on ROM. If not, it can be added to the +ROM with the .iby file. Alternatively, the .sis file can be found under the sis- +directory, but the user need to sign it with their own developer certificate. +In Nokia R&D environment, you can use directly the R&D-signed .sis file under the +internal\sis directory. + +FileBrowser is provided as full and lite version. Lite version is aimed for +those who cannot sign with TCB capability. Lite version can be generated by +defining FILEBROWSER_LITE flag and then by recompiling the application and +regenerating the sis file. + +When signing with own developer certificate, the following capabilities are +needed in the lite version: + ReadDeviceData + WriteDeviceData + DiskAdmin + AllFiles + SwEvent + NetworkServices + LocalServices + ReadUserData + WriteUserData + Location + UserEnvironment + +The full version requires these addtional capabilities: + CommDD + PowerMgmt + MultimediaDD + DRM + TrustedUI + ProtServ + NetworkControl + SurroundingsDD + TCB + +When builing FileBrowser against S60 3.0 or 3.1, you may need to patch your SDK +environment first with some fixes. For more information, please refer to the +instructions under the "envpatcher" directory. + +=============================================================================== + +System Requirements: +==================== +Basic Requirements: +- Any S60 3.x device or emulator environment + +=============================================================================== + +Compatibility Issues: +===================== +N/A + +=============================================================================== + +Known Issues: +============= +N/A + +=============================================================================== + +Version History: +================ + +Version 5.2.0 - 27th August 2010 +==================== +- Error fixes +- Destination folder selection dialog + +Version 5.1.1 - 26th June 2010 +==================== +- Error fixes +- File attributes + +Version 5.1.0 - 18th June 2010 +==================== +- Error fixes +- File filtering +- Usability improvements + +Version 5.0.1 - 21th May 2010 +==================== +- Error fixes +- All files to text file with file sizes +- Usability improvements + +Version 5.0.0 - 23th April 2010 +----------------------------- +- Orbit UI + +Version 4.5.2 - 10th December 2009 +----------------------------- +- Fix: UI layout problems fixed +- Fix: Filebrowser crashes with too long filenames + +Version 4.5.1 - 15th May 2009 +----------------------------- +- Fix: Refreshing display does not work well when starting FileBrowser +- Fix: Internal Mass storage drive is displayed as Memory Card + +Version 4.5.0 - 13th February 2009 +---------------------------------- +- Feature: Touch UI toolbar introduced with Navigate Up, Filter and Select + functionalities (S60 5.x only) +- Fix: Date and directory attributes don't work correctly with search + +Version 4.4.0 - 12th December 2008 +---------------------------------- +- Feature: "Remember last folder": File list view now remembers which folder + had the last focus before navigating deeper in a directory, and selects that + folder instead of the root of the directory when navigating back upwards. +- Fix: Execution of long file operations may cause WSERV 11 panic +- Fix: Allow formatting even if files are in use + +Version 4.3.3 - 8th August 2008 +------------------------------- +- Fix: Calculation of partition size with 64-bit values caused unwanted side + effects + +Version 4.3.2 - 5th May 2008 +------------------------------ +- Fix: Size of drive partitions should be calculated with 64-bit values + +Version 4.3.1 - 7th March 2008 +------------------------------ +- Fix: Crash when search field was active and changing file view mode + +Version 4.3.0 - 28th January 2008 +--------------------------------- +- Feature: Extended file view now displays also the directory/file time +- Feature: Text file viewer/editor supports also in UTF-8, UTF-16 little endian + and UTF-16 big endian formats +- Change: Opening with apparc is not anymore a default opening action but now + a list of another common actions appears +- Change: Font size in file list view has been adjusted to suit better in + currently used resolution +- Change: In first time start, extended view is activated in QHD resolution +- Change: Font size in file viewer and editor is now smaller so that more text + fits to the screen +- Change: Settings are now saved in dictionary store instead of cenreps +- Fix: Copy/move to folder functionality was broken +- Fix: Scroll bar did not work properly in text viewer when used via touch UI +- Fix: Last line of hex viewer was not warpped correctly +- Fix: Menu bars of file viewer and editor did not work properly +- Fix: Search should not return directories when searching a string +- Fix: Hash key selection should not be active in qwerty mode + +Version 4.2.0 - 14th January 2008 +--------------------------------- +- Feature: User mapped remote drives are visible in drive list view as normal + drive when setting is turned on +- Feature: Files can be edited in both text and hex modes +- Feature: Show checksums (message digests) on different algorithms for a file +- Feature: Error strings are now displayed for various operations instead of + generic error messages +- Feature: Disk can be ejected and dismounted via disk admin +- Change: Increased maximum heap usage to 32Mb to allow loading large files to + file editor +- Fix: Trying to create a directory which already exists did not return an + error +- Fix: In the file list view active item not visible when deleting last item in + the view +- Fix: Some file specific commands were visibile in menus also for directory + entries +- Fix: Utilizing secure backup leaked memory + +Version 4.1.0 - 17th December 2007 +---------------------------------- +- Feature: File operations are now started asynchronously with own recursion + handler which allows removing file locks and any protection attributes +- Feature: Status of each file operation can be monitored via RDebug +- Feature: Remove file locks via Secure Backup +- Feature: File operation functionality can be customized via the settings + dialog +- Feature: Multidrive support with erasing MBR and drive partition for drives + which support it +- Change: Remove screen capture support since the same functionality can be + done with the ScreenGrabber tool +- Fix: Forms were incorrectly constructed in search dialog and attribute editor + +Version 4.0.7 - 16th November 2007 +-------------------------------- +- Feature: In the list view, left/right arrow keys can be simulated with drag to + left/right gestures +- Fix: Touch click in the listbox view +- Fix: Scroll bar in the hex/text viewer can be scrolled on a touch UI + +Version 4.0.6 - 9th October 2007 +-------------------------------- +- Feature: Data type editor +- Fix: Layout in hex/text viewer in mirrored mode + +Version 4.0.5 - 27th August 2007 +-------------------------------- +- Fix: Wrong functionality while moving a folder +- Change: Handle backup session while formatting a drive + +Version 4.0.4 - 23th May 2007 +----------------------------- +- Feature: Modify debug mask +- Feature: Simulate Symbian OS error types +- Feature: Enable/disable icon server cache + +Version 4.0.3 - 28th February 2007 +---------------------------------- +- Feature: Drive snapshot functionality under the main drive selection list + +Version 4.0.2 - 31st January 2007 +--------------------------------- +- Feature: Dump message store walk into a text file +- Change: Enhance hex/text viewer +- Fix: Enhance folder browsing speed in Z-drive + +Version 4.0.1 - 17th January 2007 +--------------------------------- +- Fix: Opening of search field +- Fix: Enabling extended errors if c:\resource directory does not already + exist + +=============================================================================== + +Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +All rights reserved. + +This component and the accompanying materials are made available +under the terms of "Eclipse Public License v1.0" +which accompanies this distribution, and is available +at the URL "http://www.eclipse.org/legal/epl-v10.html". diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/group/backup_registration.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/group/backup_registration.xml Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,8 @@ + + + + + + + + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/group/bld_generic.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/group/bld_generic.inf Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include + +#ifndef FILEBROWSER_LITE + #include "../fileopserver/group/bld.inf" + #include "../fileopclient/group/bld.inf" +#endif + +PRJ_EXPORTS +../group/backup_registration.xml Z:/private/102828D6/backup_registration.xml +../rom/filebrowser.iby CORE_IBY_EXPORT_PATH(tools,filebrowser.iby) + + +PRJ_MMPFILES +#if defined(__SERIES60_30__) || defined(__SERIES60_31__) || defined(__S60_32__) + + #ifdef MARM + gnumakefile filebrowser_stub_sis.mk + #endif +#endif + +#if(!defined __SERIES60_30__ && !defined __SERIES60_31__ && !defined __S60_32__) + PRJ_EXTENSIONS + + #ifdef MARM + START EXTENSION app-services/buildstubsis + OPTION SRCDIR ../sis + OPTION SISNAME FileBrowser_stub + END + #endif +#endif diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/group/filebrowser_stub_sis.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/group/filebrowser_stub_sis.mk Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,56 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# + + +TARGETDIR=$(EPOCROOT)EPOC32\Data\Z\System\Install + +SISNAME=FileBrowser_stub +PKGNAME=FileBrowser_stub + +$(TARGETDIR) : + @perl -S emkdir.pl "$(TARGETDIR)" + +do_nothing : + rem do_nothing + +SISFILE=$(TARGETDIR)\$(SISNAME).sis + +$(SISFILE) : ..\sis\$(PKGNAME).pkg + makesis -s $? $@ + + + +MAKMAKE : do_nothing + +RESOURCE : do_nothing + +SAVESPACE : do_nothing + +BLD : do_nothing + +FREEZE : do_nothing + +LIB : do_nothing + +CLEANLIB : do_nothing + +FINAL : $(TARGETDIR) $(SISFILE) + +CLEAN : + @if exist $(SISFILE) erase $(SISFILE) + +RELEASABLES : + @echo $(SISFILE) diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/group/group.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/group/group.pro Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,19 @@ +# +# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# +# +TEMPLATE = subdirs + +BLD_INF_RULES.prj_platforms += "$${LITERAL_HASH}include \"bld_generic.inf\"" diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/icons/qgn_menu_filebrowser.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/icons/qgn_menu_filebrowser.svg Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,454 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/icons/qtg_indi_status_back.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/icons/qtg_indi_status_back.svg Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,17 @@ + + + +]> + + + + + + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/icons/qtg_mono_filebrowser_parent_folder.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/icons/qtg_mono_filebrowser_parent_folder.svg Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,9 @@ + + + + + + + + + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/icons/qtg_mono_filebrowser_paste.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/icons/qtg_mono_filebrowser_paste.svg Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/icons/qtg_mono_filebrowser_search.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/icons/qtg_mono_filebrowser_search.svg Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/icons/qtg_mono_filebrowser_selection_mode.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/icons/qtg_mono_filebrowser_selection_mode.svg Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,11 @@ + + + + + + + + + + + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/icons/qtg_mono_filebrowser_selection_mode_off.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/icons/qtg_mono_filebrowser_selection_mode_off.svg Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/rom/filebrowser.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/rom/filebrowser.iby Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef __ORBITFILEBROWSER_IBY__ +#define __ORBITFILEBROWSER_IBY__ + +S60_APP_EXE(FileBrowser) +//S60_APP_AIF_ICONS(FileBrowser) +S60_APP_RESOURCE(FileBrowser) +SCALABLE_IMAGE(APP_BITMAP_DIR,APP_BITMAP_DIR,FileBrowser) + +//#ifdef S60_UPGRADABLE_APP_REG_RSC +// S60_UPGRADABLE_APP_REG_RSC(FileBrowser) +//#else +// S60_APP_AIF_RSC(FileBrowser) +//#endif +data=ZPRIVATE\10003a3f\import\APPS\FileBrowser_reg.RSC Private\10003a3f\import\Apps\FileBrowser_reg.rsc + +#ifndef FILEBROWSER_LITE +file=ABI_DIR\BUILD_DIR\FileBrowserFileOpServer.exe PROGRAMS_DIR\FileBrowserFileOpServer.exe +file=ABI_DIR\BUILD_DIR\FileBrowserFileOpClient.dll SHARED_LIB_DIR\FileBrowserFileOpClient.dll +#endif + +data=ZPRIVATE\102828D6\backup_registration.xml private\102828D6\backup_registration.xml +data=ZSYSTEM\Install\FileBrowser_stub.sis \system\install\FileBrowser_stub.sis + + +#endif // __ORBITFILEBROWSER_IBY__ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/sis/FileBrowser_stub.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/sis/FileBrowser_stub.pkg Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,38 @@ +; +; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; + + +; Language - standard language definitions +&EN + +; Standard SIS file header +#{"FileBrowser"},(0x102828D6),1,0,0 + +; Non-localised vendor name +:"Nokia Corporation" + +; Localised vendor names +%{"Nokia Corporation"} + +; normal stuff: +""-"z:\sys\bin\FileBrowser.exe" +""-"z:\Resource\Apps\FileBrowser.mif" +""-"z:\Resource\Apps\FileBrowser.rsc" +""-"z:\private\10003a3f\import\apps\FileBrowser_reg.rsc" +""-"z:\private\102828D6\backup_registration.xml" + +""-"z:\sys\bin\FileBrowserFileOpServer.exe" +""-"z:\sys\bin\FileBrowserFileOpClient.dll" diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/ui/inc/enginewrapper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/ui/inc/enginewrapper.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,202 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef ENGINEWRAPPER_H +#define ENGINEWRAPPER_H + +#include "fbdriveentry.h" +#include "fbfileentry.h" +#include "filebrowsersettings.h" + +#include "engine.h" +#include "FBFileUtils.h" +#include "FB.hrh" + +#include +#include +#include + +class CEngine; +class SearchAttributes; +class SearchResults; +class FileBrowserView; +class HbProgressDialog; + +class QModelIndex; + +class OverwriteOptions +{ +public: + OverwriteOptions() : + doFileOperations(true), + queryIndex(0), + overWriteFlags(CFileMan::EOverWrite) + {} + + bool doFileOperations; + int queryIndex; + QString postFix; + int overWriteFlags; +}; + +/** + * class that is used for communicating between Symbian and Qt code. + */ +class EngineWrapper : public QObject, public MFileBrowserUI +{ + Q_OBJECT +public: + /** + * Constructor + */ + EngineWrapper(); + + /** + * Destructor + */ + ~EngineWrapper(); + + /** + * Initializes Engine Wrapper + * @return true if engine was started successfully + */ + bool init(); + +public: // from MFileBrowserUI + /* Functions that are called from engine: */ + void ShowInformationNote(const TDesC &aDescText, const TDesC &aDescTitle); + void ShowErrorNote(const TDesC& aDescText, TBool aNoTimeout = EFalse); + void ShowConfirmationNote(const TDesC& aDescText, TBool aNoTimeout = EFalse); + + void ShowProgressDialog(const TDesC& aDescText, TInt aMinimum, TInt aMaximum); + void CancelProgressDialog(); + void SetProgressValue(TInt aValue); + + void ShowWaitDialog(const TDesC& aText); + void CancelWaitDialog(); + void ProcessEvents(); + + TBool ShowConfirmationQuery(const TDesC& aDescText); + void NotifyModelHasChanged(); + +public: + /* Functions that are called from UI */ + bool searchFiles(); + SearchAttributes getFileSearchAttributes(); + int setFileSearchAttributes(SearchAttributes attributes); + SearchResults getSearchResults(); + + FileBrowserSettings &settings() { return mSettings; } + const FileBrowserSettings &settings() const { return mSettings; } + + void saveSettings(bool aNotifyModules = true); + + void startExecutingCommands(const QString &aCommandsExecutionMessage); + void refreshView(); + inline TListingMode listingMode() { return mEngine->FileUtils()->ListingMode(); } +// TBool IsCurrentDriveReadOnly(); +// TBool IsCurrentItemDirectory(); + void moveUpOneLevel(); + void moveDownToDirectory(const QModelIndex& index); + int clipboardCut(const QModelIndexList &aSelectionIndices); + int clipboardCopy(const QModelIndexList &aSelectionIndices); + void clipboardPaste(const OverwriteOptions &aOverwriteOptions); + void copyToFolder(const QString &aTargetDir, const OverwriteOptions &aOverwriteOptions, bool aMove); + void createNewFile(const QString &aNewFileName); + void createNewDirectory(const QString &aNewDirectoryName); + void deleteItems(const QModelIndexList& aSelectionIndices); + bool selectionHasDirs(); + void rename(const QModelIndex& aIndex, const QString aNewName); + void touch(bool aRecurse); + int getFilesCount(const QString &aDriveRoot); + int getFilesCountAndSize(const QString &aDriveRoot, qint64 &aSize); + int getEntriesCount(const QString &aDriveRoot); + QString getMimeType(const QString &aFullPath); + QString getOpenWith(const QString &aFullPath); + void setAttributes(quint32 &, quint32 &, bool &); + + bool openAppArc(QString fileName); + bool openDocHandler(QString fileName, bool embeddedVal = false); + + bool isDriveListViewActive(); + bool isCurrentDriveReadOnly(); + bool isClipBoardListInUse(); + int itemCount() const; + FbDriveEntry getDriveEntry(const QModelIndex& aIndex) const; + FbFileEntry getFileEntry(const QModelIndex& aIndex) const; + + const CArrayFix *convertSelectionList(const QModelIndexList &aSelectionIndices); + void setCurrentSelection(const QModelIndexList &aSelectionIndices); + bool isDestinationEntriesExists(const QModelIndexList &aSelectionIndices, QString aTargetDir); + bool targetExists(const QModelIndex& aIndex, const QString aNewName); + QString currentPath() const; + TOverwriteOptions convertOverwriteOptions(const OverwriteOptions &aOverwriteOptions); + bool hasDrivePassword(const QModelIndex &aIndex); + bool isDriveRemovable(const QModelIndex &aIndex); + bool isDriveLocked(const QModelIndex &aIndex); + void GetDriveName(const QModelIndex &aIndex, QString &aDriveName); + void GetDriveVolumeLabel(const QModelIndex &aIndex, QString &aDriveName); + + void DiskAdminSetDrivePassword(const QModelIndex &aIndex, const QString &aOldPassword, const QString &aNewPassword); + void DiskAdminUnlockDrive(const QModelIndex &aIndex, const QString &aOldPassword); + void DiskAdminClearDrivePassword(const QModelIndex &aIndex, const QString &aOldPassword); + void DiskAdminEraseDrivePassword(const QModelIndex &aIndex); + void DiskAdminFormatDrive(const QModelIndex &aIndex, bool aQuickFormat); + void DiskAdminQuickFormatDrive(const QModelIndex &aIndex, bool aQuickFormat); + void DiskAdminCheckDisk(const QModelIndex &aIndex); + void DiskAdminScanDrive(const QModelIndex &aIndex); + void DiskAdminSetDriveName(const QModelIndex &aIndex, const QString &aDriveName); + void DiskAdminSetDriveVolumeLabel(const QModelIndex &aIndex, const QString &aVolumeLabel); + void DiskAdminEjectDrive(const QModelIndex &aIndex); + void DiskAdminDismountDrive(const QModelIndex &aIndex); + void DiskAdminEraseMBR(const QModelIndex &aIndex); + void DiskAdminPartitionDrive(const QModelIndex &aIndex, bool aEraseMBR, int aAmountOfPartitions); + + void ToolsSetErrRd(bool aEnable); + bool ErrRdFileExists(); + + void ToolsErrorSimulateLeave(int aLeaveCode); + void ToolsErrorSimulatePanic(QString aPanicCategory, int aPanicCode); + void ToolsErrorSimulateException(int aExceptionCode); + + quint32 getDebugMask(); + void toolsSetDebugMask(quint32 aDbgMask); + + void toolsWriteAllFiles(); + + void showFileCheckSums(const QModelIndex &aIndex, TFileBrowserCmdFileChecksums checksumType); + + TClipBoardMode getClipBoardMode() { return mEngine->FileUtils()->GetClipBoardMode(); } + +signals: + void fileSystemDataChanged(); + +private slots: + void progressDialogCancelled(); + void waitDialogCancelled(); + +private: + // FB engine + CEngine *mEngine; + // List of found files results for Ui + QStringList mFilesFound; + FileBrowserSettings mSettings; + HbProgressDialog *mProgressDialog; + HbProgressDialog *mWaitDialog; + }; + +#endif //ENGINEWRAPPER_H diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/ui/inc/fbattributesview.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/ui/inc/fbattributesview.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef FBATTRIBUTESVIEW_H +#define FBATTRIBUTESVIEW_H + +#include + +class HbDataForm; +class HbDataFormModelItem; + +class FbAttributesView : public HbView +{ + Q_OBJECT + +public: + FbAttributesView(quint32 &, quint32 &, bool &); + virtual ~FbAttributesView(); + + quint32 &setAttributesMask() { return mSetAttributesMask; } + quint32 &clearAttributesMask() { return mClearAttributesMask; } + bool &recurse() { return mRecurse; } + +signals: + void finished(bool ok); + +public slots: + void accept(); + void reject(); + +private: + void initDataForm(); + void createToolbar(); + void loadSettings(); + void saveSettings(); + +private: + quint32 mSetAttributesMask; + quint32 mClearAttributesMask; + bool mRecurse; + + HbDataForm *mForm; + HbDataFormModelItem *mArchiveItem; + HbDataFormModelItem *mHiddenItem; + HbDataFormModelItem *mReadOnlyItem; + HbDataFormModelItem *mSystemItem; + HbDataFormModelItem *mRecurseItem; +}; + +#endif // FBATTRIBUTESVIEW_H diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/ui/inc/fbdriveentry.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/ui/inc/fbdriveentry.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef FBDRIVEENTRY_H +#define FBDRIVEENTRY_H + +#include "FBFileUtils.h" +#include +#include + + +/** + * class that is used for communicating between Symbian and Qt code. + */ +class FbDriveEntry { + +public: + + /** + * Constructor + */ + FbDriveEntry(TDriveEntry &); + + /** + * Destructor + */ + ~FbDriveEntry(); + + /* Functions that are called from UI */ +public: + QChar driveLetter(); + int number(); + QString mediaTypeString(); + QString attributesString(); + int iconId(); + qint64 volumeInfoFree(); + qint64 volumeInfoSize(); + QString volumeInfoNameString(); + uint volumeInfoUniqueId(); + +private: + TDriveEntry mDriveEntry; + }; + +#endif //FBDRIVEENTRY_H diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/ui/inc/fbdrivelistviewitem.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/ui/inc/fbdrivelistviewitem.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,65 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef FBDRIVELISTVIEWITEMS_H +#define FBDRIVELISTVIEWITEMS_H + +#include + +#include +#include + +class HbAbstractViewItem; +class HbLabel; +class HbCheckBox; +class HbWidget; + +class QGraphicsLinearLayout; +class QModelIndex; +class QGraphicsItem; + +class FbDriveListViewItem : public HbListViewItem +{ + Q_OBJECT + +public: + FbDriveListViewItem( QGraphicsItem *parent = 0 ); + ~FbDriveListViewItem(); + + virtual bool canSetModelIndex(const QModelIndex &index) const; + virtual HbAbstractViewItem *createItem(); + virtual void updateChildItems(); + +private slots: + void setCheckedState( int state ); + +private: + virtual void polish(HbStyleParameters& params); + +private: + void init(); + + QGraphicsLinearLayout *hLayout; + + HbLabel *mDiskNameLabel; + HbLabel *mSizeLabel; + HbLabel *mFreeLabel; + //HbCheckBox *mCheckBox; + HbLabel *mIconLabel; +}; + +#endif // FBDRIVELISTVIEWITEMS_H diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/ui/inc/fbdrivemodel.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/ui/inc/fbdrivemodel.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef FBDRIVEMODELH_H_ +#define FBDRIVEMODELH_H_ + +#include "fbdriveentry.h" + +#include +#include + +// Forward declarations +class EngineWrapper; +class QModelIndex; +class QFileIconProvider; +class QObject; + +class FbDriveModel : public QAbstractListModel +{ + Q_OBJECT + +public: + explicit FbDriveModel(EngineWrapper *engineWrapper, QObject *parent = 0); + virtual ~FbDriveModel(); + + int rowCount(const QModelIndex &parent = QModelIndex()) const; + QVariant data(const QModelIndex &index, int role) const; + QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; + + FbDriveEntry driveEntry(const QModelIndex &index) const; + QString driveLetter( const QModelIndex &index ) const; + QString mediaTypeString(const QModelIndex &index) const; + +private: + EngineWrapper *mEngineWrapper; + QFileIconProvider *mFileIconProvider; +}; + + + +#endif /* FBDRIVEMODELH_H_ */ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/ui/inc/fbdriveview.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/ui/inc/fbdriveview.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,240 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef FBDRIVEVIEWH_H_ +#define FBDRIVEVIEWH_H_ + +#include "menuaction.h" +#include "enginewrapper.h" + +#include +#include + +#include + +// Forward declarations +class QFileInfo; +class QSignalMapper; +class QItemSelection; +class QString; +class QGraphicsLinearLayout; + +class HbListView; +class HbListWidget; +class HbToolBar; +class HbLabel; +class HbDialog; +class HbAbstractViewItem; +class HbMenu; +class HbSearchPanel; + +class EditorView; +class SearchView; +class SettingsView; +class EngineWrapper; +class FbDriveModel; +class FileBrowserSortFilterProxyModel; + +class FbDriveView : public HbView +{ + Q_OBJECT + +public: + explicit FbDriveView(); + virtual ~FbDriveView(); + void init(EngineWrapper *engineWrapper); + +public slots: + void refreshList(); + +private: + void openListDialog(const QStringList &items, const QString &titleText, QObject *receiver, const char *member); + + QModelIndex currentItemIndex(); + void storeSelectedItemsOrCurrentItem(); + + // Menu related methods + void createMenu(); + void createFileMenu(); + void createEditMenu(); + void createViewMenu(); + void createToolsMenu(); + + void createSettingsMenuItem(); + void createAboutMenuItem(); + void createExitMenuItem(); + + void createContextMenu(); + void createFileContextMenu(); + void createEditContextMenu(); + void createViewContextMenu(); + void createDiskAdminContextMenu(); + +private slots: + // menu action slots + // file menu + void fileOpenDrive(); + void fileSearch(); + + void fileProperties(); + + // edit menu + void editSnapShotToE(); + + // view menu + void viewRefresh(); + + // disk admin menu + void diskAdminSetDrivePassword(); + void diskAdminSetDrivePasswordNew(HbAction *); + void doDiskAdminSetDrivePassword(HbAction *); + + void diskAdminUnlockDrive(); + void doDiskAdminUnlockDrive(HbAction *); + + void diskAdminClearDrivePassword(); + void doDiskAdminClearDrivePassword(HbAction *); + + void diskAdminEraseDrivePassword(); + void doDiskAdminEraseDrivePassword(int); + + void diskAdminFormatDrive(); + void doDiskAdminFormatDrive(int); + + void diskAdminQuickFormatDrive(); + void doDiskAdminQuickFormatDrive(int); + + void diskAdminCheckDisk(); + + void diskAdminScanDrive(); + void doDiskAdminScanDrive(int); + + void diskAdminSetDriveName(); + void doDiskAdminSetDriveName(HbAction *); + + void diskAdminSetDriveVolumeLabel(); + void doDiskAdminSetDriveVolumeLabel(HbAction *); + + void diskAdminEjectDrive(); + void diskAdminDismountDrive(); + void doDiskAdminDismountDrive(int); + + void diskAdminEraseMBR(); + void doDiskAdminEraseMBR(int); + void doDiskAdminReallyEraseMBR(int); + void doDiskAdminNotRemovableReallyEraseMBR(int); + + void diskAdminPartitionDrive(); + void diskAdminPartitionDriveProceed(int); + void diskAdminPartitionDriveReallyProceed(int); + void diskAdminPartitionDriveIsNotRemovable(int); + void diskAdminPartitionDriveEraseMbr(int); + void diskAdminPartitionDriveGetCount(HbAction *); + + // tools menu + void toolsAllAppsToTextFile(); + void toolsAllFilesToTextFile(); +// void toolsAvkonIconCacheEnable(); +// void toolsAvkonIconCacheDisable(); + + void toolsDisableExtendedErrors(); + void toolsDumpMsgStoreWalk(); + void toolsEditDataTypes(); + void toolsEnableExtendedErrors(); + + void toolsErrorSimulateLeave(); + void doToolsErrorSimulateLeave(HbAction *); + + void toolsErrorSimulatePanic(); + void doToolsErrorSimulatePanicCode(HbAction *); + void doToolsErrorSimulatePanic(HbAction *); + + void toolsErrorSimulateException(); + void doToolsErrorSimulateException(HbAction *); + +// void toolsLocalConnectivityActivateInfrared(); +// void toolsLocalConnectivityLaunchBTUI(); +// void toolsLocalConnectivityLaunchUSBUI(); + void toolsMessageInbox(); + void toolsMessageDrafts(); + void toolsMessageSentItems(); + void toolsMessageOutbox(); + void toolsMemoryInfo(); + void toolsSecureBackStart(); + void toolsSecureBackRestore(); + void toolsSecureBackStop(); + void toolsSetDebugMaskQuestion(); + void toolsSetDebugMask(HbAction *); + void toolsShowOpenFilesHere(); + + // main menu items + void about(); + +signals: + void aboutToShowFileView(); + void aboutToShowSettingsView(); + void aboutToShowEditorView(const QString &, bool); + void aboutToShowSearchView(const QString &); + void aboutToSimulateLeave(int); + +private slots: + void updateOptionMenu(); + void updateContextMenu(); + void selectionChanged(const QItemSelection &, const QItemSelection &); + void activated(const QModelIndex& index); + + void onLongPressed(HbAbstractViewItem *, QPointF); + +private: + EngineWrapper *mEngineWrapper; + + HbListView *mListView; + HbLabel *mNaviPane; + + QGraphicsLinearLayout *mMainLayout; + + // file info contains all needed information of selected file from file model + QModelIndexList mClipboardIndexes; + QModelIndexList mSelectionIndexes; + + FbDriveModel *mFbDriveModel; + OptionMenuActions mOptionMenuActions; + ContextMenuActions mContextMenuActions; + HbMenu *mContextMenu; + + // flags + bool mLocationChanged; + // flag for removing source file after copied to target file + bool mRemoveFileAfterCopied; + bool mClipBoardInUse; + bool mFolderContentChanged; + QModelIndex mCurrentIndex; + + // temporarily storage + QString mOldPassword; + QString mPanicCategory; + QString mAbsoluteFilePath; + OverwriteOptions mOverwriteOptions; + QModelIndex mModelIndex; + QString mNewFileName; + bool mProceed; + bool mEraseMBR; +}; + + + +#endif /* FBDRIVEVIEWH_H_ */ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/ui/inc/fbeditorview.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/ui/inc/fbeditorview.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef FBEDITORVIEW_H +#define FBEDITORVIEW_H + +#include + +class HbTextEdit; +class HbAction; + +class FbEditorView : public HbView +{ + Q_OBJECT + +public: + FbEditorView(); + ~FbEditorView(); + void open(const QString& fileName, bool flagReadOnly); + +signals: + void finished(bool ok); + +private slots: + void backButtonClicked(); + void displayInText(); + void displayInHex(); + void updateMenu(); + + /* + void newFile(); + bool save(); + bool saveAs(); + void about(); + void documentWasModified(); + */ + + +private: + void loadFile(const QString &fileName); + void createMenu(); + + // editor + HbTextEdit *mTextEdit; + // if flag true, file is currently in hex format + bool mFileHex; + bool mFlagReadOnly; + QString mFileName; + QString mFileContent; + + HbAction* mToTextAction; + HbAction* mToHexAction; + HbAction* mExitAction; +}; + +#endif // FBEDITORVIEW_H diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/ui/inc/fbfileentry.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/ui/inc/fbfileentry.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,85 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef FILEEENTRY_H +#define FILEEENTRY_H + +#include "FBFileUtils.h" +#include +#include +#include + +/** + * class that is used for communicating between Symbian and Qt code. + */ +class FbFileEntry +{ +public: + /** + * Constructor + */ + FbFileEntry(TFileEntry &); + + /** + * Destructor + */ + ~FbFileEntry(); + + /* Functions that are called from UI */ +public: + QString fullName(); + QString path(); + + int attributes(); + QString attributesString(); + bool isArchive() const { return mFileEntry.iEntry.IsArchive(); } + bool isHidden() const { return mFileEntry.iEntry.IsHidden(); } + bool isReadOnly() const { return mFileEntry.iEntry.IsReadOnly(); } + bool isSystem() const { return mFileEntry.iEntry.IsSystem(); } + + const QString archiveTextShort() const { return QString("A"); } + const QString hiddenTextShort() const { return QString("H"); } + const QString readOnlyTextShort() const { return QString("R"); } + const QString systemTextShort() const { return QString("S"); } + const QString noAttributeTextShort() const { return QString("-"); } + + const QString archiveText() const { return QString("Archive"); } + const QString hiddenText() const { return QString("Hidden"); } + const QString readOnlyText() const { return QString("Read Only"); } + const QString systemText() const { return QString("System"); } + const QString noAttributeText() const { return QString("None"); } + + int size(); + QString sizeString(); + +// QDateTime modified(); + QString modifiedDateTimeString(const QString aDateTimeFormat); + QString modifiedString(); +// int Uid(int id); + bool isDir(); + QString name(); + + int dirEntries(); + QString dirEntriesString(); + + int iconId(); + +private: + TFileEntry mFileEntry; + }; + +#endif //FBFILEEENTRY_H diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/ui/inc/fbfilelistviewitem.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/ui/inc/fbfilelistviewitem.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,65 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef FBFILELISTVIEWITEM_H +#define FBFILELISTVIEWITEM_H + +#include + +#include +#include + +class HbAbstractViewItem; +class HbLabel; +class HbCheckBox; +class HbWidget; + +class QGraphicsLinearLayout; +class QModelIndex; +class QGraphicsItem; + +class FbFileListViewItem : public HbListViewItem +{ + Q_OBJECT + +public: + FbFileListViewItem( QGraphicsItem *parent = 0 ); + ~FbFileListViewItem(); + + virtual bool canSetModelIndex(const QModelIndex &) const; + virtual HbAbstractViewItem *createItem(); + virtual void updateChildItems(); + +private slots: + void setCheckedState(int state); + +private: + virtual void polish(HbStyleParameters &); + +private: + void init(); + + QGraphicsLinearLayout *hLayout; + + HbLabel *mDiskNameLabel; + HbLabel *mSizeLabel; + HbLabel *mFreeLabel; + //HbCheckBox *mCheckBox; + HbLabel *mIconLabel; +}; + +#endif // FBFILELISTVIEWITEM_H diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/ui/inc/fbfilemodel.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/ui/inc/fbfilemodel.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef FBFILEMODELH_H_ +#define FBFILEMODELH_H_ + +#include + +// Forward declarations +class EngineWrapper; +class QModelIndex; +class QFileIconProvider; + +class FbFileModel : public QAbstractListModel +{ + Q_OBJECT + +public: + explicit FbFileModel(EngineWrapper *engineWrapper, QObject *parent = 0); + virtual ~FbFileModel(); + + int rowCount(const QModelIndex &parent = QModelIndex()) const; + QVariant data(const QModelIndex &index, int role) const; + QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; + + void moveDownToDirectory(const QModelIndex &index); + void moveUpOneLevel(); + +private: + EngineWrapper *mEngineWrapper; + QFileIconProvider *mFileIconProvider; +}; + + + +#endif /* FBFILEMODELH_H_ */ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/ui/inc/fbfileview.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/ui/inc/fbfileview.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,267 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef FBFILEVIEWH_H_ +#define FBFILEVIEWH_H_ + +#include "menuaction.h" +#include "enginewrapper.h" + +#include +#include +#include + +#include + +// Forward declarations +class QFileInfo; +class QSignalMapper; +class QItemSelection; +class QString; +class QGraphicsLinearLayout; + +class HbListView; +class HbListWidget; +class HbToolBar; +class HbLabel; +class HbDialog; +class HbAbstractViewItem; +class HbMenu; +class HbSearchPanel; + +class FbEditorView; +class SearchView; +class SettingsView; +class EngineWrapper; +class FbFileModel; +class FileBrowserSortFilterProxyModel; + +class FbFileView : public HbView +{ + Q_OBJECT + +public: + explicit FbFileView(); + virtual ~FbFileView(); + void init(EngineWrapper *engineWrapper); + +public slots: + void refreshList(); + +private: + void fileOverwriteDialog(); + void openListDialog(const QStringList &, const QString &, QObject *, const char *); + + void storeSelectedItemsOrCurrentItem(); + QModelIndex currentItemIndex(); + + // Menu related methods + void createMenu(); + void createFileMenu(); + void createEditMenu(); + void createViewMenu(); + void createToolsMenu(); + + void createSelectionMenuItem(); + void createSettingsMenuItem(); + void createAboutMenuItem(); + void createExitMenuItem(); + + void createContextMenu(); + void createFileContextMenu(); + void createEditContextMenu(); + void createViewContextMenu(); + void createSearchPanel(); + void createToolBar(); + +private slots: + // menu action slots + // file menu + void fileBackMoveUp(); + void fileOpenDirectory(); + void fileSearch(); + + void fileNewFile(); + void doFileNewFile(HbAction *); + + void fileNewDirectory(); + void doFileNewDirectory(HbAction *); + + void fileDelete(); + void doFileDelete(int); + + void fileRename(); + void doFileRename(HbAction *); + void doFileRenameFileExist(int); + + void fileTouch(); + void doFileTouch(int); + void fileProperties(); + + void fileChecksumsMD5(); + void fileChecksumsMD2(); + void fileChecksumsSHA1(); + void fileChecksums(TFileBrowserCmdFileChecksums checksumType); + + void fileSetAttributes(); + + // edit menu + void editSnapShotToE(); + void editCut(); + void editCopy(); + + void editPaste(); + void doEditPaste(); + + void editCopyToFolder(); + void doEditCopyToFolder(int); + void doEditCopy(); + + void editMoveToFolder(); + void doEditMoveToFolder(int); + void doEditMove(); + + void editSelect(); + void editUnselect(); + void editSelectAll(); + void editUnselectAll(); + + // view menu + void viewFilterEntries(); + void filterCriteriaChanged(const QString &); + void clearFilterCriteria(); + void viewRefresh(); + + // tools menu + void toolsAllAppsToTextFile(); + void toolsAllFilesToTextFile(); +// void toolsAvkonIconCacheEnable(); +// void toolsAvkonIconCacheDisable(); + + void toolsDisableExtendedErrors(); + void toolsDumpMsgStoreWalk(); + void toolsEditDataTypes(); + void toolsEnableExtendedErrors(); + + void toolsErrorSimulateLeave(); + void doToolsErrorSimulateLeave(HbAction *); + + void toolsErrorSimulatePanic(); + void doToolsErrorSimulatePanicCode(HbAction *); + void doToolsErrorSimulatePanic(HbAction *); + + void toolsErrorSimulateException(); + void doToolsErrorSimulateException(HbAction *); + +// void toolsLocalConnectivityActivateInfrared(); +// void toolsLocalConnectivityLaunchBTUI(); +// void toolsLocalConnectivityLaunchUSBUI(); + void toolsMessageInbox(); + void toolsMessageDrafts(); + void toolsMessageSentItems(); + void toolsMessageOutbox(); + void toolsMemoryInfo(); + void toolsSecureBackStart(); + void toolsSecureBackRestore(); + void toolsSecureBackStop(); + void toolsSetDebugMaskQuestion(); + void toolsSetDebugMask(HbAction *); + void toolsShowOpenFilesHere(); + + // main menu items + void selectionModeChanged(); + void selectionModeButtonTriggered(); + + void about(); + +signals: + void aboutToShowDriveView(); + void aboutToShowSettingsView(); + void aboutToShowEditorView(const QString &, bool); + void aboutToShowSearchView(const QString &); + void aboutToShowAttributesView(const QString &, quint32 &, quint32 &, bool &); + void aboutToSimulateLeave(int); + void overwriteOptionSelected(); + +private slots: + void setOrientation(Qt::Orientation); + void updateOptionMenu(); + void updateContextMenu(); + void activated(const QModelIndex& index); + void activateSelectionMode(); + void deActivateSelectionMode(); + void onLongPressed(HbAbstractViewItem *, QPointF); + + void fileOpen(HbAction *); + void fileOverwrite(HbAction *); + void fileOverwritePostfix(HbAction *); + +private: + // Internal methods + void proceedFileRename(); + void proceedFileTouch(bool recurse); + +private: + EngineWrapper *mEngineWrapper; + + HbListView *mListView; + HbToolBar *mToolBar; + HbLabel *mNaviPane; + HbSearchPanel *mSearchPanel; + + QGraphicsLinearLayout *mMainLayout; + + // file info contains all needed information of selected file from file model + QModelIndexList mClipboardIndexes; + QModelIndexList mSelectionIndexes; + + FbFileModel *mFbFileModel; + FileBrowserSortFilterProxyModel *mSortFilterProxyModel; + OptionMenuActions mOptionMenuActions; + ContextMenuActions mContextMenuActions; + HbMenu *mContextMenu; + HbAction *mToolbarBackAction; + HbAction* mToolbarFilterAction; + HbAction* mToolbarSelectionModeAction; + HbAction *mToolbarPasteAction; + + HbIcon mSelectionModeOnIcon; + HbIcon mSelectionModeOffIcon; + + // flags + bool mItemHighlighted; + bool mLocationChanged; + // flag for removing source file after copied to target file + bool mRemoveFileAfterCopied; + bool mClipBoardInUse; + QModelIndex mCurrentIndex; + + // temporarily storage + QString mOldPassword; + QString mPanicCategory; + QString mAbsoluteFilePath; + OverwriteOptions mOverwriteOptions; + QString mTargetDir; + QModelIndex mModelIndex; + QString mNewFileName; + bool mProceed; + bool mEraseMBR; +}; + + + +#endif /* FBFILEVIEWH_H_ */ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/ui/inc/fbfolderselectiondialog.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/ui/inc/fbfolderselectiondialog.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,78 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef FBFOLDERSELECTIONDIALOG_H_ +#define FBFOLDERSELECTIONDIALOG_H_ + +#include + +// forward declarations +class FbFolderSelectorWrapper; +class HbListWidget; +class HbListWidgetItem; +class HbLabel; +class QFileIconProvider; + +class FbFolderSelectionDialog : public HbDialog +{ + Q_OBJECT + +public: + explicit FbFolderSelectionDialog(QGraphicsItem *parent = 0); + virtual ~FbFolderSelectionDialog(); + + QString selectedFolder(); + +private: + void init(); + void createHeading(); + void createList(); + void createToolBar(); + +private slots: + void activated(HbListWidgetItem *); + void refreshView(); + void moveUpPressed(); + void acceptTriggered(); + +protected: + HbLabel *mTitle; + +private: + HbLabel *mCurrentPath; + HbListWidget *mFolderList; + FbFolderSelectorWrapper *mFolderSelectorWrapper; + QFileIconProvider *mFileIconProvider; +}; + +class FbCopyToFolderSelectionDialog : public FbFolderSelectionDialog +{ + Q_OBJECT + +public: + explicit FbCopyToFolderSelectionDialog(QGraphicsItem *parent = 0); +}; + +class FbMoveToFolderSelectionDialog : public FbFolderSelectionDialog +{ + Q_OBJECT + +public: + explicit FbMoveToFolderSelectionDialog(QGraphicsItem *parent = 0); +}; + +#endif // FBFOLDERSELECTIONDIALOG_H_ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/ui/inc/fbfolderselectorwrapper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/ui/inc/fbfolderselectorwrapper.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef FBFOLDERSELECTORWRAPPER_H_ +#define FBFOLDERSELECTORWRAPPER_H_ + +#include "fbdriveentry.h" +#include "fbfileentry.h" +#include "FBFolderSelector.h" + +#include +#include +#include + +class CEngine; +class SearchAttributes; +class SearchResults; +class FileBrowserView; +class HbProgressDialog; + +class QModelIndex; +class CFileBrowserFolderSelector; +class EngineWrapper; + + +/** + * class that is used for communicating between Symbian and Qt code. + */ +class FbFolderSelectorWrapper : public QObject, public MFolderSelectorUI +{ + Q_OBJECT +public: + FbFolderSelectorWrapper(); + ~FbFolderSelectorWrapper(); + + bool init(); + + QString currentPath() const; + bool isDriveListViewActive() const; + int itemCount() const; + FbDriveEntry getDriveEntry(const int aIndex) const; + FbFileEntry getFileEntry(const int aIndex) const; + + void moveDownToDirectory(int); + void moveUpOneLevel(); + +signals: + void FolderSelectionChanged(); + +public: // From MFolderSelectorUI + virtual void InformFolderSelectionChanged(); + +private: + CFileBrowserFolderSelector *mDestinationFolderSelector; +}; + +#endif // FBFOLDERSELECTORWRAPPER_H_ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/ui/inc/fbmainwindow.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/ui/inc/fbmainwindow.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef FBMAINWINDOW_H_ +#define FBMAINWINDOW_H_ + +#include + +class HbApplication; +class HbView; + +class EngineWrapper; +class FbDriveView; +class FbFileView; +class FbSettingsView; +class FbEditorView; +class FbSearchView; +class FbAttributesView; +class QWidget; + +class FbMainWindow : public HbMainWindow +{ + Q_OBJECT + +public: + explicit FbMainWindow(QWidget *parent = 0); + virtual ~FbMainWindow(); + + void init(); + +private slots: + void openPreviousBrowserView(); + void openFileBrowserView(bool); + void openDriveView(); + void openFileView(); + void openSettingsView(); + void openEditorView(const QString &, bool); + + void openSearchView(const QString &); + void closeSearchView(bool); + + void openAttributesView(const QString &, quint32 &, quint32 &, bool &); + void closeAttributesView(bool); + +private: + EngineWrapper *mEngineWrapper; + FbDriveView *mDriveView; + FbFileView *mFileView; + FbSettingsView *mSettingsView; + FbEditorView *mEditorView; + FbSearchView *mSearchView; + FbAttributesView *mAttributesView; + HbView *mPreviousView; +}; + +#endif /* FBMAINWINDOW_H_ */ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/ui/inc/fbpropertiesdialog.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/ui/inc/fbpropertiesdialog.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef FBPROPERTIESDIALOG_H_ +#define FBPROPERTIESDIALOG_H_ + +#include +#include +#include + +// forward declarations +class HbMarqueeItem; +class QString; +class QGraphicsItem; +class QGraphicsGridLayout; + +class FbPropertiesDialog : public HbDialog +{ + Q_OBJECT + +public: + explicit FbPropertiesDialog(QGraphicsItem *parent = 0); + virtual ~FbPropertiesDialog(); + + void setTitle(const QString &); + void setProperties(const QVector > &); + +private: + void createHeading(); + void createContentWidget(); + void createToolBar(); +private: + HbMarqueeItem *mTitle; + QGraphicsGridLayout *mGridLayout; +}; + +#endif // FBPROPERTIESDIALOG_H_ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/ui/inc/fbsearchview.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/ui/inc/fbsearchview.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,103 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef FBSEARCHVIEW_H +#define FBSEARCHVIEW_H + +#include + +#include +#include + +class QStringList; + +class EngineWrapper; +class HbDataForm; +class HbDataFormModelItem; +class HbProgressDialog; + +/** + * Settings class that is used for + */ +class SearchAttributes +{ +public: + QString mSearchDir; + QString mWildCards; + QString mTextInFile; + int mMinSize; + int mMaxSize; + QDate mMinDate; + QDate mMaxDate; + bool mRecurse; + bool mDefaultWildCard; +}; + +/** + * search results class. + */ +class SearchResults +{ +public: + int mNumberOfFoundFiles; + QStringList *mFoundFilesList; +}; + +class FbSearchView : public HbView +{ + Q_OBJECT + +public: + explicit FbSearchView(QGraphicsItem *parent = 0); + ~FbSearchView(); + + void open(const SearchAttributes &, const QString &); + void startFileSearch(EngineWrapper *); + +signals: + void finished(bool ok); + +private slots: + void accept(); + void reject(); + +private: + void initDataForm(); + void createToolbar(); + void loadAttributes(); + void readFormItems(); + +private: + /* Search attributes */ + SearchAttributes mAttributes; + /* Search results */ + SearchResults mResults; + + HbDataForm *mForm; + HbDataFormModelItem *mSearchFileNameItem; + HbDataFormModelItem *mWildCardItem; + HbDataFormModelItem *mHasString; + HbDataFormModelItem *mRecurse; + HbDataFormModelItem *mMinSize; + HbDataFormModelItem *mMaxSize; + HbDataFormModelItem *mMinDate; + HbDataFormModelItem *mMaxDate; + QString mPath; + HbProgressDialog *mProgressDialog; +}; + +#endif // FBSEARCHVIEW_H diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/ui/inc/fbsettingsview.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/ui/inc/fbsettingsview.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,79 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef FBSETTINGSVIEW_H +#define FBSETTINGSVIEW_H + +#include + +class HbDataForm; +class HbDataFormModelItem; +class EngineWrapper; +class FileBrowserSettings; + +class FbSettingsView : public HbView +{ + Q_OBJECT + +public: + FbSettingsView(EngineWrapper &engineWrapper); + virtual ~FbSettingsView(); + + void initDataForm(); +signals: + void finished(bool ok); + +public slots: +// void displayModeChanged(); +// void fileViewChanged(); +// void subDirectoryInfoChanged(); +// void associatedIconsChanged(); +// void rememberFolderOnExitChanged(); +// void rememberLastFolderChanged(); +// void showToolbarChanged(); + +// void toggleChange(QModelIndex, QModelIndex); + void accept(); + void reject(); + +private: + void createToolbar(); + void constructMenu(); + void loadSettings(const FileBrowserSettings &settings); + void saveSettings(FileBrowserSettings &settings); + +private: + EngineWrapper &mEngineWrapper; + + HbDataForm *mForm; + HbDataFormModelItem *mDisplayModeItem; + HbDataFormModelItem *mFileViewItem; + HbDataFormModelItem *mShowDirectoryInfoItem; + HbDataFormModelItem *mShowAssociatedIconsItem; + HbDataFormModelItem *mRememberFolderOnExitItem; + HbDataFormModelItem *mRememberLastFolderItem; + HbDataFormModelItem *mShowToolbarItem; + + HbDataFormModelItem *mSupportNetDrivesItem; //"Support net drives" + HbDataFormModelItem *mBypassPlatformSecurityItem; //"Bypass plat.security" + HbDataFormModelItem *mUnlockFilesViaSBItem; //"Unlock files via SB" + HbDataFormModelItem *mIgnoreProtectionAttributesItem; //"Ign. protection atts" + HbDataFormModelItem *mNoROAttributeCopyFromZItem; //"No RO-att copy from Z:" + +}; + +#endif // FBSETTINGSVIEW_H diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/ui/inc/filebrowsersettings.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/ui/inc/filebrowsersettings.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,78 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef FILEBROWSERSETTINGS_H_ +#define FILEBROWSERSETTINGS_H_ + +#include "engine.h" +#include "enginewrapper.h" + +#include + +/** + * Settings class that is used for ui settings handling + */ +class FileBrowserSettings +{ +public: + FileBrowserSettings(TFileBrowserSettings *aSettings) : mSettings(aSettings) { } + ~FileBrowserSettings() { } + + int displayMode() const { return mSettings->iDisplayMode; } + void setDisplayMode(int displayMode) { mSettings->iDisplayMode = displayMode; } + + int fileViewMode() const { return mSettings->iFileViewMode; } + void setFileViewMode(int fileViewMode) { mSettings->iFileViewMode = fileViewMode; } + + bool showSubDirectoryInfo() const { return mSettings->iShowSubDirectoryInfo; } + void setShowSubDirectoryInfo(bool showSubDirectoryInfo) { mSettings->iShowSubDirectoryInfo = showSubDirectoryInfo; } + + bool showAssociatedIcons() const { return mSettings->iShowAssociatedIcons; } + void setShowAssociatedIcons(bool showAssociatedIcons) { mSettings->iShowAssociatedIcons = showAssociatedIcons; } + + bool rememberLastPath() const { return mSettings->iRememberLastPath; } + void setRememberLastPath(bool rememberLastPath) { mSettings->iRememberLastPath = rememberLastPath; } + + QString lastPath() const { return QString((QChar*)mSettings->iLastPath.Ptr(),mSettings->iLastPath.Length()); } + void lastPath(const QString& lastPath) { mSettings->iLastPath = lastPath.utf16(); } + + bool rememberFolderSelection() const { return mSettings->iRememberFolderSelection; } + void setRememberFolderSelection(bool rememberFolderSelection) { mSettings->iRememberFolderSelection = rememberFolderSelection; } + + bool enableToolbar() const { return mSettings->iEnableToolbar; } + void setEnableToolbar(bool enableToolbar) { mSettings->iEnableToolbar = enableToolbar; } + + bool supportNetworkDrives() const { return mSettings->iSupportNetworkDrives; } + void setSupportNetworkDrives(bool supportNetworkDrives) { mSettings->iSupportNetworkDrives = supportNetworkDrives; } + + bool bypassPlatformSecurity() const { return mSettings->iBypassPlatformSecurity; } + void setBypassPlatformSecurity(bool bypassPlatformSecurity) { mSettings->iBypassPlatformSecurity = bypassPlatformSecurity; } + + bool removeFileLocks() const { return mSettings->iRemoveFileLocks; } + void setRemoveFileLocks(bool removeFileLocks) { mSettings->iRemoveFileLocks = removeFileLocks; } + + bool ignoreProtectionsAttributes() const { return mSettings->iIgnoreProtectionsAtts; } + void setIgnoreProtectionsAttributes(bool ignoreProtectionsAttributes) { mSettings->iIgnoreProtectionsAtts = ignoreProtectionsAttributes; } + + bool removeROMWriteProrection() const { return mSettings->iRemoveROMWriteProrection; } + void setRemoveROMWriteProrection(bool removeROMWriteProrection) { mSettings->iRemoveROMWriteProrection = removeROMWriteProrection; } + +private: + TFileBrowserSettings *mSettings; +}; + +#endif /* FILEBROWSERSETTINGS_H_ */ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/ui/inc/filebrowsersortfilterproxymodel.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/ui/inc/filebrowsersortfilterproxymodel.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef FILEBROWSERSORTFILTERPROXYMODEL_H +#define FILEBROWSERSORTFILTERPROXYMODEL_H + +#include +#include + +class FileBrowserSortFilterProxyModel : public QSortFilterProxyModel +{ + Q_OBJECT + +public: + FileBrowserSortFilterProxyModel(QObject *parent = 0); + + QString filterCriteria() const { return mFilterCriteria; } + void setFilterCriteria(const QString &criteria); + +protected: + bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const; + +private: + QString mFilterCriteria; +}; + +#endif // FILEBROWSERSORTFILTERPROXYMODEL_H diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/ui/inc/menuaction.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/ui/inc/menuaction.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,331 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef MENUACTION_H +#define MENUACTION_H + +class HbMenu; +class HbAction; + +class OptionMenuActions +{ +public: + OptionMenuActions() : + mFileMenu(0), + mFileBackMoveUp(0), + mFileOpenDrive(0), + mFileOpenDirectory(0), + mFileSearch(0), + mFileNewMenu(0), + mFileNewFile(0), + mFileNewDirectory(0), + mFileDelete(0), + mFileRename(0), + mFileTouch(0), + mFileProperties(0), + mFileChecksumsMenu(0), + mFileChecksumsMD5(0), + mFileChecksumsMD2(0), + mFileChecksumsSHA1(0), + mFileSetAttributes(0), + //Edit - + mEditMenu(0), + mEditSnapShotToE(0), + mEditCut(0), + mEditCopy(0), + mEditPaste(0), + mEditCopyToFolder(0), + mEditMoveToFolder(0), + mEditSelect(0), + mEditUnselect(0), + mEditSelectAll(0), + mEditUnselectAll(0), + // View - + mViewMenu(0), + mViewFilterEntries(0), + mViewRefresh(0), + // Disk admin - + mDiskAdminMenu(0), + mDiskAdminSetDrivePassword(0), + mDiskAdminUnlockDrive(0), + mDiskAdminClearDrivePassword(0), + mDiskAdminEraseDrivePassword(0), + mDiskAdminFormatDrive(0), + mDiskAdminQuickFormatDrive(0), + mDiskAdminCheckDisk(0), + mDiskAdminScanDrive(0), + mDiskAdminSetDriveName(0), + mDiskAdminSetDriveVolumeLabel(0), + mDiskAdminEjectDrive(0), + mDiskAdminDismountDrive(0), + mDiskAdminEraseMBR(0), + mDiskAdminPartitionDrive(0), + // Tools - + mToolsMenu(0), + mToolsAllAppsToTextFile(0), + mToolsAllFilesToTextFile(0), + mToolsAvkonIconCacheMenu(0), + mToolsAvkonIconCacheEnable(0), + mToolsAvkonIconCacheDisable(0), + mToolsDisableExtendedErrors(0), + mToolsDumpMsgStoreWalk(0), + mToolsEditDataTypes(0), + mToolsEnableExtendedErrors(0), + mToolsErrorSimulateMenu(0), + mToolsErrorSimulateLeave(0), + mToolsErrorSimulatePanic(0), + mToolsErrorSimulateException(0), + mToolsMessageAttachmentsMenu(0), + mToolsMessageInbox(0), + mToolsMessageDrafts(0), + mToolsMessageSentItems(0), + mToolsMessageOutbox(0), + mToolsLocalConnectivityMenu(0), + mToolsLocalConnectivityActivateInfrared(0), + mToolsLocalConnectivityLaunchBTUI(0), + mToolsLocalConnectivityLaunchUSBUI(0), + mToolsMemoryInfo(0), + mToolsSecureBackupMenu(0), + mToolsSecureBackStart(0), + mToolsSecureBackRestore(0), + mToolsSecureBackStop(0), + mToolsSetDebugMask(0), + mToolsShowOpenFilesHere(0), + mSelection(0), + mSetting(0), + mAbout(0), + mExit(0) + { + + } + + ~OptionMenuActions() { } +public: + //File menu operations + HbMenu *mFileMenu; + HbAction *mFileBackMoveUp; + HbAction *mFileOpenDrive; + HbAction *mFileOpenDirectory; + HbAction *mFileSearch; + HbMenu *mFileNewMenu; + HbAction *mFileNewFile; + HbAction *mFileNewDirectory; + HbAction *mFileDelete; + HbAction *mFileRename; + HbAction *mFileTouch; + HbAction *mFileProperties; + HbMenu *mFileChecksumsMenu; + HbAction *mFileChecksumsMD5; + HbAction *mFileChecksumsMD2; + HbAction *mFileChecksumsSHA1; + HbAction *mFileSetAttributes; + + //Edit - + HbMenu *mEditMenu; + HbAction *mEditSnapShotToE; + HbAction *mEditCut; + HbAction *mEditCopy; + HbAction *mEditPaste; + HbAction *mEditCopyToFolder; + HbAction *mEditMoveToFolder; + HbAction *mEditSelect; + HbAction *mEditUnselect; + HbAction *mEditSelectAll; + HbAction *mEditUnselectAll; + + // View - + HbMenu *mViewMenu; + HbAction *mViewFilterEntries; + HbAction *mViewRefresh; + + // Disk admin - + HbMenu *mDiskAdminMenu; + HbAction *mDiskAdminSetDrivePassword; + HbAction *mDiskAdminUnlockDrive; + HbAction *mDiskAdminClearDrivePassword; + HbAction *mDiskAdminEraseDrivePassword; + HbAction *mDiskAdminFormatDrive; + HbAction *mDiskAdminQuickFormatDrive; + HbAction *mDiskAdminCheckDisk; + HbAction *mDiskAdminScanDrive; + HbAction *mDiskAdminSetDriveName; + HbAction *mDiskAdminSetDriveVolumeLabel; + HbAction *mDiskAdminEjectDrive; + HbAction *mDiskAdminDismountDrive; + HbAction *mDiskAdminEraseMBR; + HbAction *mDiskAdminPartitionDrive; + + // Tools - + HbMenu *mToolsMenu; + HbAction *mToolsAllAppsToTextFile; + HbAction *mToolsAllFilesToTextFile; + + HbMenu *mToolsAvkonIconCacheMenu; + HbAction *mToolsAvkonIconCacheEnable; + HbAction *mToolsAvkonIconCacheDisable; + + HbAction *mToolsDisableExtendedErrors; + HbAction *mToolsDumpMsgStoreWalk; + HbAction *mToolsEditDataTypes; + + HbAction *mToolsEnableExtendedErrors; + + HbMenu *mToolsErrorSimulateMenu; + HbAction *mToolsErrorSimulateLeave; + HbAction *mToolsErrorSimulatePanic; + HbAction *mToolsErrorSimulateException; + + HbMenu *mToolsMessageAttachmentsMenu; + HbAction *mToolsMessageInbox; + HbAction *mToolsMessageDrafts; + HbAction *mToolsMessageSentItems; + HbAction *mToolsMessageOutbox; + + HbMenu *mToolsLocalConnectivityMenu; + HbAction *mToolsLocalConnectivityActivateInfrared; + HbAction *mToolsLocalConnectivityLaunchBTUI; + HbAction *mToolsLocalConnectivityLaunchUSBUI; + + HbAction *mToolsMemoryInfo; + + HbMenu *mToolsSecureBackupMenu; + HbAction *mToolsSecureBackStart; + HbAction *mToolsSecureBackRestore; + HbAction *mToolsSecureBackStop; + + HbAction *mToolsSetDebugMask; + HbAction *mToolsShowOpenFilesHere; + + HbAction *mSelection; + HbAction *mSetting; + HbAction *mAbout; + HbAction *mExit; +}; + + +class ContextMenuActions +{ +public: + ContextMenuActions() : + mOpenDirectory(0), + mSearch(0), + //File - + mFileMenu(0), + mFileBackMoveUp(0), + mFileOpenDrive(0), + mFileOpenDirectory(0), + mFileSearch(0), + mFileNewMenu(0), + mFileNewFile(0), + mFileNewDirectory(0), + mFileDelete(0), + mFileRename(0), + mFileTouch(0), + mFileProperties(0), + mFileChecksumsMenu(0), + mFileChecksumsMD5(0), + mFileChecksumsMD2(0), + mFileChecksumsSHA1(0), + mFileSetAttributes(0), + //Edit - + mEditMenu(0), +// mEditSnapShotToE(0), + mEditCut(0), + mEditCopy(0), + mEditPaste(0), + mEditCopyToFolder(0), + mEditMoveToFolder(0), + // View - +// mViewMenu(0), +// mViewFilterEntries(0), +// mViewRefresh(0), + // Disk admin - + mDiskAdminMenu(0), + mDiskAdminSetDrivePassword(0), + mDiskAdminUnlockDrive(0), + mDiskAdminClearDrivePassword(0), + mDiskAdminEraseDrivePassword(0), + mDiskAdminFormatDrive(0), + mDiskAdminQuickFormatDrive(0), + mDiskAdminCheckDisk(0), + mDiskAdminScanDrive(0), + mDiskAdminSetDriveName(0), + mDiskAdminSetDriveVolumeLabel(0), + mDiskAdminEjectDrive(0), + mDiskAdminDismountDrive(0), + mDiskAdminEraseMBR(0), + mDiskAdminPartitionDrive(0) + { + + } + + ~ContextMenuActions() { } +public: + HbAction *mOpenDirectory; + HbAction *mSearch; + //File menu operations + HbMenu *mFileMenu; + HbAction *mFileBackMoveUp; + HbAction *mFileOpenDrive; + HbAction *mFileOpenDirectory; + HbAction *mFileSearch; + HbMenu *mFileNewMenu; + HbAction *mFileNewFile; + HbAction *mFileNewDirectory; + HbAction *mFileDelete; + HbAction *mFileRename; + HbAction *mFileTouch; + HbAction *mFileProperties; + HbMenu *mFileChecksumsMenu; + HbAction *mFileChecksumsMD5; + HbAction *mFileChecksumsMD2; + HbAction *mFileChecksumsSHA1; + HbAction *mFileSetAttributes; + + //Edit - + HbMenu *mEditMenu; +// HbAction *mEditSnapShotToE; + HbAction *mEditCut; + HbAction *mEditCopy; + HbAction *mEditPaste; + HbAction *mEditCopyToFolder; + HbAction *mEditMoveToFolder; + +// // View - +// HbMenu *mViewMenu; +// HbAction *mViewFilterEntries; +// HbAction *mViewRefresh; + + // Disk admin - + HbMenu *mDiskAdminMenu; + HbAction *mDiskAdminSetDrivePassword; + HbAction *mDiskAdminUnlockDrive; + HbAction *mDiskAdminClearDrivePassword; + HbAction *mDiskAdminEraseDrivePassword; + HbAction *mDiskAdminFormatDrive; + HbAction *mDiskAdminQuickFormatDrive; + HbAction *mDiskAdminCheckDisk; + HbAction *mDiskAdminScanDrive; + HbAction *mDiskAdminSetDriveName; + HbAction *mDiskAdminSetDriveVolumeLabel; + HbAction *mDiskAdminEjectDrive; + HbAction *mDiskAdminDismountDrive; + HbAction *mDiskAdminEraseMBR; + HbAction *mDiskAdminPartitionDrive; +}; + +#endif // MENUACTION_H diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/ui/inc/notifications.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/ui/inc/notifications.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef NOTIFICATIONS_H_ +#define NOTIFICATIONS_H_ + +#include + +class HbProgressDialog; + +class Notifications +{ +public: + static void showAboutNote(); + static void showMessageBox(HbMessageBox::MessageBoxType type, const QString &text, const QString &label, int timeout = HbPopup::NoTimeout); + static void showInformationNote(const QString &text, const QString &title = QString()); + static void showErrorNote(const QString &text, bool noTimeout = false); + static void showConfirmationNote(const QString &text, bool noTimeout = false); + static bool showConfirmationQuery(const QString &aText); +}; + +#endif // NOTIFICATIONS_H_ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/ui/src/enginewrapper.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/ui/src/enginewrapper.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,1004 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "enginewrapper.h" +#include "engine.h" +#include "FBFileUtils.h" +#include "notifications.h" +#include "fbfileview.h" +#include "fbsearchview.h" +#include "filebrowsersettings.h" +//#include "fbsettingsview.h" + +#include + +#include +#include +#include + +// --------------------------------------------------------------------------- + +EngineWrapper::EngineWrapper() + : mEngine(0), + mFilesFound(), + mSettings(0), + mProgressDialog(0), + mWaitDialog(0) +{ +} + +// --------------------------------------------------------------------------- + +EngineWrapper::~EngineWrapper() +{ + if(mEngine != NULL) { + TRAP_IGNORE(mEngine->DeActivateEngineL()); + delete mEngine; + } + if (mProgressDialog) + delete mProgressDialog; + + if (mWaitDialog) + delete mWaitDialog; +} + +// --------------------------------------------------------------------------- + +bool EngineWrapper::init() +{ + TRAPD(err, mEngine = CEngine::NewL(this)); + if (err != KErrNone) { + return false; + } else { + TRAP_IGNORE(mEngine->ActivateEngineL()); + mSettings = FileBrowserSettings(&mEngine->Settings()); + return true; + } +} + +// --------------------------------------------------------------------------- +// Functions that are called from UI +// --------------------------------------------------------------------------- +bool EngineWrapper::searchFiles() +{ + TRAPD(err, mEngine->SearchL() ); + if(err != KErrNone) { + return false; + } + else { + return true; + } +} + +// --------------------------------------------------------------------------- +SearchAttributes EngineWrapper::getFileSearchAttributes() +{ + TSearchAttributes tAttributes = mEngine->GetSearchAttributes(); + SearchAttributes attributes; + + // Convert TSearchAttributes to SearchAttributes + attributes.mSearchDir = QString((QChar*)tAttributes.iSearchDir.Ptr(),tAttributes.iSearchDir.Length()); + attributes.mWildCards = QString((QChar*)tAttributes.iWildCards.Ptr(),tAttributes.iWildCards.Length()); + attributes.mTextInFile = QString((QChar*)tAttributes.iTextInFile.Ptr(),tAttributes.iTextInFile.Length()); + attributes.mMinSize = tAttributes.iMinSize; + attributes.mMaxSize = tAttributes.iMaxSize; + attributes.mRecurse = tAttributes.iRecurse; + attributes.mDefaultWildCard = tAttributes.iDefaultWildCard; + + // TTime to QDate + TBuf<20> timeString; + _LIT(KDateString,"%D%M%Y%/0%1%/1%2%/2%3%/3"); + TRAP_IGNORE( tAttributes.iMinDate.FormatL(timeString, KDateString) ); + QString temp = QString::fromUtf16(timeString.Ptr(), timeString.Length()); + temp.replace(QChar('/'), QChar('-')); + attributes.mMinDate = QDate::fromString(temp, "dd-MM-yyyy"); + + + TRAP_IGNORE( tAttributes.iMaxDate.FormatL(timeString, KDateString) ); + temp = QString::fromUtf16(timeString.Ptr(), timeString.Length()); + temp.replace(QChar('/'), QChar('-')); + attributes.mMaxDate = QDate::fromString(temp, "dd-MM-yyyy"); + + return attributes; + +} + +// --------------------------------------------------------------------------- +int EngineWrapper::setFileSearchAttributes(SearchAttributes attributes) +{ + TSearchAttributes tAttributes; + // Convert SearchAttributes to TSearchAttributes + + //convert QString to TFilename: + tAttributes.iSearchDir = TFileName(attributes.mSearchDir.utf16()); + tAttributes.iWildCards = TFileName(attributes.mWildCards.utf16()); + tAttributes.iTextInFile = TFileName(attributes.mTextInFile.utf16()); + + tAttributes.iMinSize = attributes.mMinSize; + tAttributes.iMaxSize = attributes.mMaxSize; + tAttributes.iRecurse = attributes.mRecurse; + tAttributes.iDefaultWildCard = attributes.mDefaultWildCard; + + // QDate to TTime for both min- and max Date + QString temp = attributes.mMinDate.toString("yyyy-MM-dd"); + QStringList dateList = temp.split("-"); + int month = dateList[1].toInt() - 1; + int day = dateList[2].toInt() - 1; + temp = dateList[0]; + if (month == 0) { + temp.append("00"); + } + else { + temp.append(QString::number(month)); + } + if (day == 0) { + temp.append("00"); + } + else { + temp.append(QString::number(day)); + } + temp.append(":"); + + TBuf<24> dateString(temp.utf16()); + tAttributes.iMinDate.Set(dateString); + + temp = attributes.mMaxDate.toString("yyyy-MM-dd"); + dateList = temp.split("-"); + month = dateList[1].toInt() - 1; + day = dateList[2].toInt() - 1; + temp = dateList[0]; + if (month == 0) { + temp.append("00"); + } + else { + temp.append(QString::number(month)); + } + if (day == 0) { + temp.append("00"); + } + else { + temp.append(QString::number(day)); + } + temp.append(":"); + dateString.Copy(temp.utf16()); + tAttributes.iMaxDate.Set(dateString); + + mEngine->ChangeAttributes(tAttributes); + return KErrNone; +} + + +// --------------------------------------------------------------------------- +SearchResults EngineWrapper::getSearchResults() +{ + TSearchResults tResults = mEngine->SearchResults(); + SearchResults results; + results.mNumberOfFoundFiles = tResults.iNumberOfFoundFiles; + CFileEntryList* foundFilesResult = mEngine->FoundFiles(); + if (!mFilesFound.isEmpty()) { + mFilesFound.clear(); + } + // copy file names and convert them from TFileName format to QStringList items type + for (int i = 0; i < foundFilesResult->Count(); i++) { + mFilesFound.append( + QString((QChar*)foundFilesResult->At(i).iFullName.Ptr(), + foundFilesResult->At(i).iFullName.Length()) + ); + } + results.mFoundFilesList = &mFilesFound; + return results; +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::saveSettings(bool aNotifyModules) +{ + return mEngine->SaveSettingsL(aNotifyModules);; +} + +// --------------------------------------------------------------------------- + +bool EngineWrapper::isDriveListViewActive() +{ + // TODO check return value + if (mEngine->FileUtils() && mEngine->FileUtils()->IsDriveListViewActive()) { + return true; + } else { + return false; + } +} + +bool EngineWrapper::isCurrentDriveReadOnly() +{ + // TODO check return value + if (mEngine->FileUtils() && mEngine->FileUtils()->IsCurrentDriveReadOnly()) { + return true; + } else { + return false; + } +} + +bool EngineWrapper::isClipBoardListInUse() +{ + if (mEngine->FileUtils() && mEngine->FileUtils()->ClipBoardList() && mEngine->FileUtils()->ClipBoardList()->Count() != 0) + return true; + else + return false; +} + +// --------------------------------------------------------------------------- +void EngineWrapper::startExecutingCommands(const QString &aCommandsExecutionMessage) +{ + TPtrC commandsExecutionMessage(reinterpret_cast(aCommandsExecutionMessage.constData())); + TRAPD(err, mEngine->FileUtils()->StartExecutingCommandsL(commandsExecutionMessage) ); + Q_UNUSED(err); //TODO +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::refreshView() +{ + if (mEngine->FileUtils()) { + TRAPD(err, mEngine->FileUtils()->RefreshViewL() ); + Q_UNUSED(err); //TODO + } +} + +void EngineWrapper::moveUpOneLevel() +{ + if (mEngine->FileUtils()) { + TRAPD(err, mEngine->FileUtils()->MoveUpOneLevelL() ); + Q_UNUSED(err); //TODO + } +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::moveDownToDirectory(const QModelIndex& aIndex) +{ + if (mEngine->FileUtils()) { + TRAPD(err, mEngine->FileUtils()->MoveDownToDirectoryL(aIndex.row()) ); + Q_UNUSED(err); //TODO + } +} + +// --------------------------------------------------------------------------- + +int EngineWrapper::clipboardCut(const QModelIndexList& aSelectionIndices) +{ + TInt operations = 0; + const CArrayFix *selectionIndexes = convertSelectionList(aSelectionIndices); + if (mEngine->FileUtils()) { + TRAPD(err, operations = mEngine->FileUtils()->ClipboardCutL(selectionIndexes) ); + Q_UNUSED(err); //TODO + } + delete selectionIndexes; + return operations; +} + +// --------------------------------------------------------------------------- +int EngineWrapper::clipboardCopy(const QModelIndexList& aSelectionIndices) +{ + TInt operations = 0; + const CArrayFix *selectionIndexes = convertSelectionList(aSelectionIndices); + + if (mEngine->FileUtils()) { + TRAPD(err, operations = mEngine->FileUtils()->ClipboardCopyL(selectionIndexes)); + Q_UNUSED(err); //TODO + } + delete selectionIndexes; + return operations; +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::clipboardPaste(const OverwriteOptions &aOverwriteOptions) +{ + TOverwriteOptions tOverwriteOptions = convertOverwriteOptions(aOverwriteOptions); + if (mEngine->FileUtils()) { + TRAPD(err, mEngine->FileUtils()->ClipboardPasteL(tOverwriteOptions)); + Q_UNUSED(err); //TODO + } +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::copyToFolder(const QString &aTargetDir, const OverwriteOptions &aOverwriteOptions, bool aMove) +{ + TFileName targetDir = TFileName(aTargetDir.utf16()); + TOverwriteOptions tOverwriteOptions = convertOverwriteOptions(aOverwriteOptions); + + + TRAPD(err, mEngine->FileUtils()->CopyToFolderL(targetDir, tOverwriteOptions, aMove ? ETrue : EFalse) ); + Q_UNUSED(err); //TODO +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::createNewFile(const QString &aNewFileName) +{ + TFileName fileName = TFileName(aNewFileName.utf16()); + TRAPD(err, mEngine->FileUtils()->NewFileL(fileName) ); + if (err == KErrNone) { + Notifications::showConfirmationNote(QString("New file created")); + } else if (err == KErrAlreadyExists) { + Notifications::showInformationNote(QString("File already exists")); + } else { + ShowErrorNote(mEngine->FileUtils()->ResolveErrorMessage(err)); + } + TRAP_IGNORE(mEngine->FileUtils()->RefreshViewL()); +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::createNewDirectory(const QString &aNewDirectoryName) +{ + TFileName newDirectoryName = TFileName(aNewDirectoryName.utf16()); + TRAPD(err, mEngine->FileUtils()->NewDirectoryL(newDirectoryName) ); + if (err == KErrNone) { + Notifications::showConfirmationNote(QString("New directory created")); + } else if (err == KErrAlreadyExists) { + Notifications::showInformationNote(QString("Directory already exists")); + } else { + ShowErrorNote(mEngine->FileUtils()->ResolveErrorMessage(err)); + } + TRAP_IGNORE(mEngine->FileUtils()->RefreshViewL()); +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::deleteItems(const QModelIndexList& aSelectionIndices) +{ + setCurrentSelection(aSelectionIndices); + TRAPD(err, mEngine->FileUtils()->DeleteL() ); + Q_UNUSED(err); //TODO +} + +// --------------------------------------------------------------------------- +bool EngineWrapper::selectionHasDirs() +{ + return mEngine->FileUtils()->SelectionHasDirs(); +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::rename(const QModelIndex& aIndex, const QString aNewName) +{ + if (mEngine->FileUtils()) { + const TFileName newName = TFileName(aNewName.utf16()); + TRAPD(err, mEngine->FileUtils()->RenameL(aIndex.row(), newName) ); + Q_UNUSED(err); //TODO + } +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::touch(bool aRecurse) +{ + if (mEngine->FileUtils()) { + TRAPD(err, mEngine->FileUtils()->TouchL(aRecurse) ); + Q_UNUSED(err); //TODO + } +} + +// --------------------------------------------------------------------------- + +int EngineWrapper::getFilesCount(const QString &aDriveRoot) +{ + int count = 0; + const TFileName driveRoot = TFileName(aDriveRoot.utf16()); + if (mEngine->FileUtils()) { + TRAPD(err, count = mEngine->FileUtils()->GetFilesCount(driveRoot)); + Q_UNUSED(err); //TODO + } + return count; +} + +int EngineWrapper::getFilesCountAndSize(const QString &aDriveRoot, qint64 &aSize) +{ + int count = 0; + TInt64 size = 0; + const TFileName driveRoot = TFileName(aDriveRoot.utf16()); + if (mEngine->FileUtils()) { + TRAPD(err, count = mEngine->FileUtils()->GetFilesCountAndSize(driveRoot, size)); + aSize = size; + Q_UNUSED(err); //TODO + } + return count; +} + +int EngineWrapper::getEntriesCount(const QString &aDriveRoot) +{ + int count = -1; + const TFileName driveRoot = TFileName(aDriveRoot.utf16()); + if (mEngine->FileUtils()) { + TRAPD(err, count = mEngine->FileUtils()->GetEntriesCount(driveRoot)); + Q_UNUSED(err); //TODO + } + return count; +} + +QString EngineWrapper::getMimeType(const QString &aFullPath) +{ + QString qMimeType; + if (mEngine->FileUtils()) { + const TFileName fullPath = TFileName(aFullPath.utf16()); + TFileName mimeType = mEngine->FileUtils()->GetMimeType(fullPath); + qMimeType = QString::fromUtf16(mimeType.Ptr(), mimeType.Length()); + } + return qMimeType; +} + +QString EngineWrapper::getOpenWith(const QString &aFullPath) +{ + QString qOpenWith; + if (mEngine->FileUtils()) { + const TFileName fullPath = TFileName(aFullPath.utf16()); + TFileName openWith = mEngine->FileUtils()->GetOpenWith(fullPath); + qOpenWith = QString::fromUtf16(openWith.Ptr(), openWith.Length()); + } + return qOpenWith; +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::setAttributes(quint32 &setAttributesMask, quint32 &clearAttributesMask, bool &recurse) +{ + if (mEngine->FileUtils()) { + TBool tRecurse = recurse ? ETrue : EFalse; + TRAPD(err, mEngine->FileUtils()->SetAttributesL(setAttributesMask, clearAttributesMask, tRecurse)); + Q_UNUSED(err); //TODO + } +} + +// --------------------------------------------------------------------------- + +bool EngineWrapper::openAppArc(QString fileName) +{ + + //convert QString to TFilename: + fileName.replace("/", "\\"); + TFileName fileToOpen = TFileName(fileName.utf16()); + + TRAPD(err, mEngine->OpenWithApparcL(fileToOpen) ); + if(err != KErrNone) { + return false; + } else { + return true; + } +} + +// --------------------------------------------------------------------------- + +bool EngineWrapper::openDocHandler(QString fileName, bool embeddedVal) +{ + //convert QString to TFilename: + fileName.replace("/", "\\"); + TFileName fileToOpen = TFileName(fileName.utf16()); + + TRAPD(err, mEngine->OpenWithDocHandlerL(fileToOpen, embeddedVal) ); + if(err != KErrNone) { + return false; + } else { + return true; + } +} + +// --------------------------------------------------------------------------- + +int EngineWrapper::itemCount() const +{ + if (mEngine->FileUtils()->IsDriveListViewActive()) { + return mEngine->FileUtils()->DriveEntries()->Count(); + } else { + return mEngine->FileUtils()->FileEntries()->Count(); + } +} + +// --------------------------------------------------------------------------- + +FbDriveEntry EngineWrapper::getDriveEntry(const QModelIndex& aIndex) const +{ + TDriveEntry driveEntry; + if (mEngine->FileUtils()->DriveEntries()->Count() > aIndex.row() && aIndex.row() >= 0) { + driveEntry = mEngine->FileUtils()->DriveEntries()->At(aIndex.row()); + } + return FbDriveEntry(driveEntry); +} + +// --------------------------------------------------------------------------- + +FbFileEntry EngineWrapper::getFileEntry(const QModelIndex& aIndex) const +{ + TFileEntry fileEntry; + if (mEngine->FileUtils()->FileEntries()->Count() > aIndex.row() && aIndex.row() >= 0) { + fileEntry = mEngine->FileUtils()->FileEntries()->At(aIndex.row()); + } + return FbFileEntry(fileEntry); +} + +// --------------------------------------------------------------------------- + +const CArrayFix *EngineWrapper::convertSelectionList(const QModelIndexList &aSelectionIndices) +{ + CArrayFixFlat* selectionIndexes = 0; + TRAPD(err, selectionIndexes = new(ELeave)CArrayFixFlat(4)); + if (err != KErrNone) { + return 0; + } + + for (int i=0; i< aSelectionIndices.count(); ++i) { + TRAPD(err, selectionIndexes->AppendL(aSelectionIndices.at(i).row()) ); + Q_UNUSED(err); //TODO + } + return selectionIndexes; +} + + +// --------------------------------------------------------------------------- + +void EngineWrapper::setCurrentSelection(const QModelIndexList &aSelectionIndices) +{ + const CArrayFix *selectionIndexes = convertSelectionList(aSelectionIndices); + mEngine->FileUtils()->SetCurrentSelection(selectionIndexes); + delete selectionIndexes; +} + +// --------------------------------------------------------------------------- + +bool EngineWrapper::isDestinationEntriesExists(const QModelIndexList &aSelectionIndices, QString aTargetDir) +{ + TFileName targetDir = TFileName(aTargetDir.utf16()); + //setCurrentSelection(aSelectionIndices); + Q_UNUSED(aSelectionIndices); + + TBool someEntryExists = mEngine->FileUtils()->IsDestinationEntriesExists(targetDir); + return someEntryExists; +} + +// --------------------------------------------------------------------------- +bool EngineWrapper::targetExists(const QModelIndex& aIndex, const QString aNewName) +{ + const TFileName newName = TFileName(aNewName.utf16()); + return mEngine->FileUtils()->TargetExists(aIndex.row(), newName); +} + +// --------------------------------------------------------------------------- + +QString EngineWrapper::currentPath() const +{ + return QString::fromUtf16(mEngine->FileUtils()->CurrentPath().Ptr(), + mEngine->FileUtils()->CurrentPath().Length()); +} + +TOverwriteOptions EngineWrapper::convertOverwriteOptions(const OverwriteOptions &aOverwriteOptions) +{ + TOverwriteOptions tOverwriteOptions; + tOverwriteOptions.iDoFileOperations = aOverwriteOptions.doFileOperations; + tOverwriteOptions.iQueryIndex = aOverwriteOptions.queryIndex; + tOverwriteOptions.iPostFix = TFileName(aOverwriteOptions.postFix.utf16()); + tOverwriteOptions.iOverWriteFlags = aOverwriteOptions.overWriteFlags; + return tOverwriteOptions; +} + +bool EngineWrapper::hasDrivePassword(const QModelIndex &aIndex) +{ + bool hasPassword = false; + if (mEngine->FileUtils()->DriveEntries()->Count() > aIndex.row() && aIndex.row() >= 0) + { + TDriveEntry driveEntry = mEngine->FileUtils()->DriveEntries()->At(aIndex.row()); + hasPassword = driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttHasPassword; + } + return hasPassword; +} + +bool EngineWrapper::isDriveRemovable(const QModelIndex &aIndex) +{ + bool isRemovable = false; + if (mEngine->FileUtils()->DriveEntries()->Count() > aIndex.row() && aIndex.row() >= 0) + { + TDriveEntry driveEntry = mEngine->FileUtils()->DriveEntries()->At(aIndex.row()); + isRemovable = driveEntry.iVolumeInfo.iDrive.iDriveAtt & KDriveAttRemovable; + } + return isRemovable; +} + +bool EngineWrapper::isDriveLocked(const QModelIndex &aIndex) +{ + bool isRemovable = false; + if (mEngine->FileUtils()->DriveEntries()->Count() > aIndex.row() && aIndex.row() >= 0) + { + TDriveEntry driveEntry = mEngine->FileUtils()->DriveEntries()->At(aIndex.row()); + isRemovable = driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttLocked; + } + return isRemovable; +} + +void EngineWrapper::GetDriveName(const QModelIndex &aIndex, QString &aDriveName) +{ + TFileName driveName; + mEngine->FileUtils()->GetDriveName(aIndex.row(), driveName); + aDriveName = QString::fromUtf16(driveName.Ptr(), driveName.Length()); +} + + +void EngineWrapper::GetDriveVolumeLabel(const QModelIndex &aIndex, QString &aVolumeLabel) +{ + TFileName volumeLabel; + mEngine->FileUtils()->GetDriveName(aIndex.row(), volumeLabel); + aVolumeLabel = QString::fromUtf16(volumeLabel.Ptr(), volumeLabel.Length()); +} + +/** + * Wrapper function for SetDrivePasswordL + */ +void EngineWrapper::DiskAdminSetDrivePassword(const QModelIndex &aIndex, + const QString &aOldPassword, + const QString &aNewPassword) +{ + TFileName oldPassword = TFileName(aOldPassword.utf16()); + TFileName newPassword = TFileName(aNewPassword.utf16()); + + TRAPD(err, mEngine->FileUtils()->SetDrivePasswordL(aIndex.row(), oldPassword, newPassword)); + + if (err == KErrNone) { + Notifications::showInformationNote(QString("Password set")); + } else if (err == KErrNotSupported) { + Notifications::showErrorNote(QString("Not supported for this drive")); + } else { + ShowErrorNote(mEngine->FileUtils()->ResolveErrorMessage(err)); + } + TRAP_IGNORE(mEngine->FileUtils()->RefreshViewL()); +} + +/** + * Wrapper function for UnlockDriveL + */ +void EngineWrapper::DiskAdminUnlockDrive(const QModelIndex &aIndex, const QString &aOldPassword) +{ + TFileName oldPassword = TFileName(aOldPassword.utf16()); + + TRAPD(err, mEngine->FileUtils()->UnlockDriveL(aIndex.row(), oldPassword)); + + if (err == KErrNone) { + Notifications::showInformationNote(QString("Drive unlocked")); + } else if (err == KErrNotSupported) { + Notifications::showErrorNote(QString("Not supported for this drive")); + } else { + ShowErrorNote(mEngine->FileUtils()->ResolveErrorMessage(err)); + } + + TRAP_IGNORE(mEngine->FileUtils()->RefreshViewL()); +} + +/** + * Wrapper function for ClearDrivePasswordL + */ +void EngineWrapper::DiskAdminClearDrivePassword(const QModelIndex &aIndex, const QString &aOldPassword) +{ + TFileName oldPassword = TFileName(aOldPassword.utf16()); + TRAPD(err, mEngine->FileUtils()->ClearDrivePasswordL(aIndex.row(), oldPassword)); + + if (err == KErrNone) { + Notifications::showInformationNote(QString("Password cleared")); + } else if (err == KErrNotSupported) { + Notifications::showErrorNote(QString("Not supported for this drive")); + } else { + ShowErrorNote(mEngine->FileUtils()->ResolveErrorMessage(err)); + } + + TRAP_IGNORE(mEngine->FileUtils()->RefreshViewL()); +} + +/** + * Wrapper function for ClearDrivePasswordL + */ +void EngineWrapper::DiskAdminEraseDrivePassword(const QModelIndex &aIndex) +{ + TRAPD(err, mEngine->FileUtils()->EraseDrivePasswordL(aIndex.row())); + + if (err == KErrNone) { + Notifications::showInformationNote(QString("Password erased")); + } else if (err == KErrNotSupported) { + Notifications::showErrorNote(QString("Not supported for this drive")); + } else { + Notifications::showErrorNote(QString("Cannot erase, you may have to format the drive first")); + } + + TRAP_IGNORE(mEngine->FileUtils()->RefreshViewL()); +} + +void EngineWrapper::DiskAdminFormatDrive(const QModelIndex &aIndex, bool aQuickFormat) +{ + TRAP_IGNORE(mEngine->FileUtils()->FormatDriveL(aIndex.row(), aQuickFormat)); +} + +void EngineWrapper::DiskAdminQuickFormatDrive(const QModelIndex &aIndex, bool aQuickFormat) +{ + TRAP_IGNORE(mEngine->FileUtils()->FormatDriveL(aIndex.row(), aQuickFormat)); +} + +void EngineWrapper::DiskAdminCheckDisk(const QModelIndex &aIndex) +{ + TRAP_IGNORE(mEngine->FileUtils()->CheckDiskL(aIndex.row())); +} + +/** + * Wrapper function for ScanDriveL + */ +void EngineWrapper::DiskAdminScanDrive(const QModelIndex &aIndex) +{ + TRAPD(err, mEngine->FileUtils()->ScanDriveL(aIndex.row())); + + if (err == KErrNone) { + Notifications::showConfirmationNote(QString("Run succesfully")); + } else if (err == KErrNotSupported) { + Notifications::showErrorNote(QString("Not supported for this drive")); + } else { + ShowErrorNote(mEngine->FileUtils()->ResolveErrorMessage(err)); + } + + TRAP_IGNORE(mEngine->FileUtils()->RefreshViewL()); +} + +/** + * Wrapper function for SetDriveNameL + */ +void EngineWrapper::DiskAdminSetDriveName(const QModelIndex &aIndex, const QString &aDriveName) +{ + TFileName driveName = TFileName(aDriveName.utf16()); + TRAPD(err, mEngine->FileUtils()->SetDriveNameL(aIndex.row(), driveName)); + + if (err == KErrNone) { + Notifications::showConfirmationNote(QString("Name changed")); + } else if (err == KErrNotSupported) { + Notifications::showErrorNote(QString("Not supported for this drive")); + } else { + ShowErrorNote(mEngine->FileUtils()->ResolveErrorMessage(err)); + } + + TRAP_IGNORE(mEngine->FileUtils()->RefreshViewL()); +} + +/** + * Wrapper function for SetDriveVolumeLabelL + */ +void EngineWrapper::DiskAdminSetDriveVolumeLabel(const QModelIndex &aIndex, const QString &aVolumeLabel) +{ + TFileName volumeLabel = TFileName(aVolumeLabel.utf16()); + TRAPD(err, mEngine->FileUtils()->SetDriveVolumeLabelL(aIndex.row(), volumeLabel)); + + if (err == KErrNone) { + Notifications::showConfirmationNote(QString("Volume label changed")); + } else if (err == KErrNotSupported) { + Notifications::showErrorNote(QString("Not supported for this drive")); + } else { + ShowErrorNote(mEngine->FileUtils()->ResolveErrorMessage(err)); + } + + TRAP_IGNORE(mEngine->FileUtils()->RefreshViewL()); +} + +/** + * Wrapper function for EjectDriveL + */ +void EngineWrapper::DiskAdminEjectDrive(const QModelIndex &aIndex) +{ + TRAPD(err, mEngine->FileUtils()->EjectDriveL(aIndex.row())); + + if (err == KErrNone) { + Notifications::showConfirmationNote(QString("Ejected succesfully")); + } else if (err == KErrNotSupported) { + Notifications::showErrorNote(QString("Not supported for this drive")); + } else { + ShowErrorNote(mEngine->FileUtils()->ResolveErrorMessage(err)); + } + + TRAP_IGNORE(mEngine->FileUtils()->RefreshViewL()); +} + +/** + * Wrapper function for DismountFileSystemL + */ +void EngineWrapper::DiskAdminDismountDrive(const QModelIndex &aIndex) +{ + TRAPD(err, mEngine->FileUtils()->DismountFileSystemL(aIndex.row())); + + if (err == KErrNone) { + Notifications::showConfirmationNote(QString("Dismounted succesfully")); + } else if (err == KErrNotSupported) { + Notifications::showErrorNote(QString("Not supported for this drive")); + } else { + ShowErrorNote(mEngine->FileUtils()->ResolveErrorMessage(err)); + } + + TRAP_IGNORE(mEngine->FileUtils()->RefreshViewL()); +} + +/** + * Wrapper function for EraseMBRL + */ +void EngineWrapper::DiskAdminEraseMBR(const QModelIndex &aIndex) +{ + TRAP_IGNORE(mEngine->FileUtils()->EraseMBRL(aIndex.row())); +} + +/** + * Wrapper function for PartitionDriveL + */ +void EngineWrapper::DiskAdminPartitionDrive(const QModelIndex &aIndex, bool aEraseMBR, int aAmountOfPartitions) +{ + TRAP_IGNORE(mEngine->FileUtils()->PartitionDriveL(aIndex.row(), aEraseMBR, aAmountOfPartitions)); +} + +void EngineWrapper::ToolsSetErrRd(bool aEnable) +{ + TRAP_IGNORE(mEngine->FileUtils()->SetErrRdL(aEnable)); +} + +bool EngineWrapper::ErrRdFileExists() +{ + return mEngine->FileUtils()->FileExists(KErrRdPath); +} + +void EngineWrapper::ToolsErrorSimulateLeave(int aLeaveCode) +{ + mEngine->FileUtils()->SimulateLeaveL(aLeaveCode); +} + +void EngineWrapper::ToolsErrorSimulatePanic(QString aPanicCategory, int aPanicCode) +{ + TBuf<128> panicCategory; + panicCategory.Copy(aPanicCategory.utf16()); + mEngine->FileUtils()->SimulatePanicL(panicCategory, aPanicCode); +} + +void EngineWrapper::ToolsErrorSimulateException(int aExceptionCode) +{ + mEngine->FileUtils()->SimulateExceptionL(aExceptionCode); +} + +quint32 EngineWrapper::getDebugMask() +{ + return mEngine->FileUtils()->GetDebugMask(); +} + +void EngineWrapper::toolsSetDebugMask(quint32 aDbgMask) +{ + mEngine->FileUtils()->SetDebugMaskL(aDbgMask); +} + +void EngineWrapper::toolsWriteAllFiles() +{ + mEngine->FileUtils()->WriteAllFilesL(); +} + +void EngineWrapper::showFileCheckSums(const QModelIndex &aIndex, TFileBrowserCmdFileChecksums checksumType) +{ + TRAPD(err, mEngine->FileUtils()->ShowFileCheckSumsL(aIndex.row(), checksumType)); + + if (err != KErrNone) { + ShowErrorNote(mEngine->FileUtils()->ResolveErrorMessage(err)); + } +} + +// --------------------------------------------------------------------------- +// Functions that are called from engine +// --------------------------------------------------------------------------- + +// --------------------------------------------------------------------------- + +void EngineWrapper::ShowErrorNote(const TDesC& aDescText, TBool aNoTimeout /*= EFalse*/) +{ + QString qText = QString::fromUtf16(aDescText.Ptr(), aDescText.Length()); + Notifications::showErrorNote(qText, aNoTimeout); +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::ShowInformationNote(const TDesC &aDescText, const TDesC &aDescTitle) +{ + QString qText = QString::fromUtf16(aDescText.Ptr(), aDescText.Length()); + QString qTitle = QString::fromUtf16(aDescTitle.Ptr(), aDescTitle.Length()); + Notifications::showInformationNote(qText, qTitle); +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::ShowConfirmationNote(const TDesC& aDescText, TBool aNoTimeout /*= EFalse*/) +{ + QString qText = QString::fromUtf16(aDescText.Ptr(), aDescText.Length()); + Notifications::showConfirmationNote(qText, aNoTimeout); +} + +void EngineWrapper::ShowProgressDialog(const TDesC& aDescText, TInt aMinimum, TInt aMaximum ) +{ + const QString qText = QString::fromUtf16(aDescText.Ptr(), aDescText.Length()); + if (!mProgressDialog) { + mProgressDialog = new HbProgressDialog(HbProgressDialog::WaitDialog); + QObject::connect(mProgressDialog, SIGNAL(cancelled()), this, SLOT(progressDialogCancelled())); + } + + mProgressDialog->setText(qText); + mProgressDialog->setMinimum(aMinimum); + mProgressDialog->setMaximum(aMaximum); + mEngine->FileUtils()->SetAllowProcessing(true); + mProgressDialog->show(); +} + +void EngineWrapper::CancelProgressDialog() +{ + if (mProgressDialog) { + QObject::disconnect(mProgressDialog, SIGNAL(cancelled()), this, SLOT(progressDialogCancelled())); + mProgressDialog->cancel(); + QObject::connect(mProgressDialog, SIGNAL(cancelled()), this, SLOT(progressDialogCancelled())); + } +} + +void EngineWrapper::SetProgressValue(TInt aValue) +{ + if (mProgressDialog) + mProgressDialog->setProgressValue(aValue); +} + +void EngineWrapper::progressDialogCancelled() +{ + mEngine->FileUtils()->DialogDismissedL(); +} + +void EngineWrapper::ShowWaitDialog(const TDesC& aDescText) +{ + const QString qText = QString::fromUtf16(aDescText.Ptr(), aDescText.Length()); + if (!mWaitDialog) { + mWaitDialog = new HbProgressDialog(HbProgressDialog::WaitDialog); + QObject::connect(mWaitDialog, SIGNAL(cancelled()), this, SLOT(waitDialogCancelled())); + } + + mWaitDialog->setText(qText); + mEngine->FileUtils()->SetAllowProcessing(true); + //mWaitDialog->setAttribute(Qt::WA_DeleteOnClose); + mWaitDialog->show(); +} + +void EngineWrapper::CancelWaitDialog() +{ + if (mWaitDialog) + mWaitDialog->cancel(); +} + +void EngineWrapper::waitDialogCancelled() +{ + mEngine->FileUtils()->SetAllowProcessing(false); +} + +void EngineWrapper::ProcessEvents() +{ + qApp->processEvents(); +} + +TBool EngineWrapper::ShowConfirmationQuery(const TDesC& aDescText) +{ + QString qText = QString::fromUtf16(aDescText.Ptr(), aDescText.Length()); + return Notifications::showConfirmationQuery(qText); +} + +void EngineWrapper::NotifyModelHasChanged() +{ + emit fileSystemDataChanged(); +} + +// --------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/ui/src/fbattributesview.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/ui/src/fbattributesview.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,210 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "fbattributesview.h" + +#include +#include +#include +#include +#include +#include + +#include + +#include + +const QStringList AttributesChoices = QStringList() << "Skip" << "On" << "Off"; +const QStringList RecurseChoices = QStringList() << "Recursive" << "Non-recursive"; +const QString acceptActionText = "OK"; +const QString rejectActionText = "Cancel"; +const int AttributeOn = 1; +const int AttributeOff = 2; +const int AttributeEnableRecursion = 0; +const int AttributeDisableRecursion = 1; + +FbAttributesView::FbAttributesView(quint32 &aSetAttMask, quint32 &aClearAttMask, bool &aRecurse) : + mSetAttributesMask(aSetAttMask), + mClearAttributesMask(aClearAttMask), + mRecurse(aRecurse), + mForm(0), + mArchiveItem(0), + mHiddenItem(0), + mReadOnlyItem(0), + mSystemItem(0), + mRecurseItem(0) +{ + setTitle("Set attributes"); + + // Override back navigation action + HbAction *leaveViewAction = new HbAction(Hb::BackNaviAction, this); + connect(leaveViewAction, SIGNAL(triggered()), this, SLOT(reject())); + setNavigationAction(leaveViewAction); + + initDataForm(); + createToolbar(); +} + +FbAttributesView::~FbAttributesView() +{ +} + +void FbAttributesView::initDataForm() +{ + mForm = new HbDataForm(this); + HbDataFormModel *model = new HbDataFormModel(); + + // Create Group for sequential image components + //mGroupSeguantialCapture = model->appendDataFormGroup(QString("Archive"), parent); + + mArchiveItem = new HbDataFormModelItem(HbDataFormModelItem::RadioButtonListItem); + mArchiveItem->setLabel("Archive"); + mArchiveItem->setContentWidgetData(QString("items"), AttributesChoices); + mArchiveItem->setContentWidgetData(QString("displayMode"), QString("embedded")); + + mHiddenItem = new HbDataFormModelItem(HbDataFormModelItem::RadioButtonListItem); + mHiddenItem->setLabel("Hidden"); + mHiddenItem->setContentWidgetData(QString("items"), AttributesChoices); + mHiddenItem->setContentWidgetData(QString("displayMode"), QString("embedded")); + + mReadOnlyItem = new HbDataFormModelItem(HbDataFormModelItem::RadioButtonListItem); + mReadOnlyItem->setLabel("Read only"); + mReadOnlyItem->setContentWidgetData(QString("items"), AttributesChoices); + mReadOnlyItem->setContentWidgetData(QString("displayMode"), QString("embedded")); + + mSystemItem = new HbDataFormModelItem(HbDataFormModelItem::RadioButtonListItem); + mSystemItem->setLabel("System"); + mSystemItem->setContentWidgetData(QString("items"), AttributesChoices); + mSystemItem->setContentWidgetData(QString("displayMode"), QString("embedded")); + + mRecurseItem = new HbDataFormModelItem(HbDataFormModelItem::RadioButtonListItem); + mRecurseItem->setLabel("Recurse"); + mRecurseItem->setContentWidgetData(QString("items"), RecurseChoices); + mRecurseItem->setContentWidgetData(QString("displayMode"), QString("embedded")); + + // load file search attribute values from FB engine: + loadSettings(); + + model->appendDataFormItem(mArchiveItem); + model->appendDataFormItem(mHiddenItem); + model->appendDataFormItem(mReadOnlyItem); + model->appendDataFormItem(mSystemItem); + model->appendDataFormItem(mRecurseItem); + + mForm->setModel(model); + + QGraphicsLinearLayout* layout = new QGraphicsLinearLayout(Qt::Vertical,this); + layout->addItem(mForm); + setLayout(layout); +} + +void FbAttributesView::createToolbar() +{ + HbToolBar *toolBar = new HbToolBar(this); + HbAction *acceptAction = new HbAction(acceptActionText); + connect(acceptAction, SIGNAL(triggered()), this, SLOT(accept())); + toolBar->addAction(acceptAction); + + HbAction *rejectAction = new HbAction(rejectActionText); + connect(rejectAction, SIGNAL(triggered()), this, SLOT(reject())); + toolBar->addAction(rejectAction); + + setToolBar(toolBar); +} + +/** + Set form item values from settings \a settings. + */ +void FbAttributesView::loadSettings() +{ + if (mSetAttributesMask & KEntryAttArchive) + mArchiveItem->setContentWidgetData(QString("selected"), AttributeOn); + else if (mClearAttributesMask & KEntryAttArchive) + mArchiveItem->setContentWidgetData(QString("selected"), AttributeOff); + + if (mSetAttributesMask & KEntryAttHidden) + mHiddenItem->setContentWidgetData(QString("selected"), AttributeOn); + else if (mClearAttributesMask & KEntryAttHidden) + mHiddenItem->setContentWidgetData(QString("selected"), AttributeOff); + + if (mSetAttributesMask & KEntryAttReadOnly) + mReadOnlyItem->setContentWidgetData(QString("selected"), AttributeOn); + else if (mClearAttributesMask & KEntryAttReadOnly) + mReadOnlyItem->setContentWidgetData(QString("selected"), AttributeOff); + + if (mSetAttributesMask & KEntryAttSystem) + mSystemItem->setContentWidgetData(QString("selected"), AttributeOn); + else if (mClearAttributesMask & KEntryAttSystem) + mSystemItem->setContentWidgetData(QString("selected"), AttributeOff); + + if (mRecurse) + mRecurseItem->setContentWidgetData(QString("selected"), AttributeEnableRecursion); + else + mRecurseItem->setContentWidgetData(QString("selected"), AttributeDisableRecursion); +} + +/** + Store form item data into \a settings + */ +void FbAttributesView::saveSettings() +{ + mSetAttributesMask = 0; + mClearAttributesMask = 0; + + int archive = mArchiveItem->contentWidgetData(QString("selected")).toInt(); + if (archive == AttributeOn) + mSetAttributesMask |= KEntryAttArchive; + else if (archive == AttributeOff) + mClearAttributesMask |= KEntryAttArchive; + + int hidden = mHiddenItem->contentWidgetData(QString("selected")).toInt(); + if (hidden == AttributeOn) + mSetAttributesMask |= KEntryAttHidden; + else if (hidden == AttributeOff) + mClearAttributesMask |= KEntryAttHidden; + + int readOnly = mReadOnlyItem->contentWidgetData(QString("selected")).toInt(); + if (readOnly == AttributeOn) + mSetAttributesMask |= KEntryAttReadOnly; + else if (readOnly == AttributeOff) + mClearAttributesMask |= KEntryAttReadOnly; + + int system = mSystemItem->contentWidgetData(QString("selected")).toInt(); + if (system == AttributeOn) + mSetAttributesMask |= KEntryAttSystem; + else if (system == AttributeOff) + mClearAttributesMask |= KEntryAttSystem; + + int recurse = mRecurseItem->contentWidgetData(QString("selected")).toInt(); + if (recurse == AttributeEnableRecursion) + mRecurse = ETrue; + else if (recurse == AttributeDisableRecursion) + mRecurse = EFalse; +} + +void FbAttributesView::accept() +{ + saveSettings(); + emit finished(true); +} + +void FbAttributesView::reject() +{ + emit finished(false); +} + +// End of file diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/ui/src/fbdriveentry.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/ui/src/fbdriveentry.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,95 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "fbdriveentry.h" + +// --------------------------------------------------------------------------- + +FbDriveEntry::FbDriveEntry(TDriveEntry &aDriveEntry) +: mDriveEntry(aDriveEntry) +{ +} + +// --------------------------------------------------------------------------- + +FbDriveEntry::~FbDriveEntry() +{ +} + +// --------------------------------------------------------------------------- + +QChar FbDriveEntry::driveLetter() +{ + return QChar(TUint(mDriveEntry.iLetter)); +} + +// --------------------------------------------------------------------------- + +int FbDriveEntry::number() +{ + return mDriveEntry.iNumber; +} + +// --------------------------------------------------------------------------- + +QString FbDriveEntry::mediaTypeString() +{ + return QString::fromUtf16(mDriveEntry.iMediaTypeDesc.Ptr(), mDriveEntry.iMediaTypeDesc.Length()); +} + +// --------------------------------------------------------------------------- + +QString FbDriveEntry::attributesString() +{ + return QString::fromUtf16(mDriveEntry.iAttributesDesc.Ptr(), mDriveEntry.iAttributesDesc.Length()); +} + +// --------------------------------------------------------------------------- + +int FbDriveEntry::iconId() +{ + return mDriveEntry.iIconId; +} + +// --------------------------------------------------------------------------- + +qint64 FbDriveEntry::volumeInfoFree() +{ + return mDriveEntry.iVolumeInfo.iFree; +} + +// --------------------------------------------------------------------------- + +qint64 FbDriveEntry::volumeInfoSize() +{ + return mDriveEntry.iVolumeInfo.iSize; +} + +// --------------------------------------------------------------------------- + +QString FbDriveEntry::volumeInfoNameString() +{ + return QString::fromUtf16(mDriveEntry.iVolumeInfo.iName.Ptr(), mDriveEntry.iVolumeInfo.iName.Length()); +} + +// --------------------------------------------------------------------------- + +uint FbDriveEntry::volumeInfoUniqueId() +{ + return mDriveEntry.iVolumeInfo.iUniqueID; +} +// --------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/ui/src/fbdrivelistviewitem.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/ui/src/fbdrivelistviewitem.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,173 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "fbdrivelistviewitem.h" +#include "fbdriveentry.h" +#include "fbdrivemodel.h" + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +FbDriveListViewItem::FbDriveListViewItem(QGraphicsItem *parent) : + HbListViewItem(parent), + hLayout(0), + mDiskNameLabel(0), + mSizeLabel(0), + mFreeLabel(0), + mIconLabel(0) +{ +} + +FbDriveListViewItem::~FbDriveListViewItem() +{ +} + +void FbDriveListViewItem::polish(HbStyleParameters& params) +{ + Q_UNUSED(params); +} + +bool FbDriveListViewItem::canSetModelIndex(const QModelIndex &index) const +{ + Q_UNUSED(index); + return true; +} + + +HbAbstractViewItem *FbDriveListViewItem::createItem() +{ + return new FbDriveListViewItem(*this); +} + +void FbDriveListViewItem::updateChildItems() +{ + if(!hLayout) { + init(); + } + + // Qt::DisplayRole +// QVariant displayRole = modelIndex().data(Qt::DisplayRole); +// QString diskName("default"); + QStringList stringList; +// if (displayRole.isValid()) { +// if (displayRole.canConvert()) { // EFileViewModeSimple +// stringList.append(displayRole.toString()); +// } else if (displayRole.canConvert()) { // EFileViewModeExtended +// stringList = displayRole.toStringList(); +// } +// if (stringList.count() > 0) +// diskName = stringList[0]; //modelIndex().data( Qt::UserRole ).toString(); +// +// mDiskNameLabel->setPlainText(diskName/*displayString*/); +// } +// if (stringList.count() > 1) +// mSizeLabel->setPlainText( stringList[1] ); + + + // Get the Drive Entry + const FbDriveModel* driveModel= qobject_cast(modelIndex().model()); + FbDriveEntry driveEntry = driveModel->driveEntry(modelIndex()); + + const QString SimpleDriveEntry("%1: <%2>"); + + QString diskName = SimpleDriveEntry.arg(driveEntry.driveLetter()).arg(driveEntry.mediaTypeString()); + mDiskNameLabel->setPlainText(diskName); + + const QString ExtendedDriveEntry("%1/%2 kB"); + QString diskSize = ExtendedDriveEntry.arg(QString::number(driveEntry.volumeInfoFree()/1024)) + .arg(QString::number(driveEntry.volumeInfoSize()/1024)); + mSizeLabel->setPlainText( diskSize ); + + //mFreeLabel->setPlainText( stringList[2] ); + + // mCheckBox->setCheckState( checkState() ); + + // Qt::DecorationRole + // QTBUG-11033 No Icon provided for QFileIconProvider::Desktop, Network, Drive on Symbian + QVariant decorationRole = modelIndex().data(Qt::DecorationRole); + if (decorationRole.isValid()) { + QIcon icon = qvariant_cast(decorationRole); + if( icon.isNull() ) { + QFileIconProvider fileIconProvider; + icon = fileIconProvider.icon(QFileIconProvider::File); + } + mIconLabel->setIcon(HbIcon(icon)); + } +} + +void FbDriveListViewItem::setCheckedState(int state) +{ + HbAbstractViewItem::setCheckState(static_cast(state)); +} + +void FbDriveListViewItem::init() +{ + hLayout = new QGraphicsLinearLayout(); + hLayout->setContentsMargins(0, 0, 0, 0); + + hLayout->setOrientation( Qt::Horizontal ); + hLayout->addItem(layout()); + + mIconLabel = new HbLabel(); + hLayout->addItem( mIconLabel ); + hLayout->setAlignment( mIconLabel, Qt::AlignTop ); + hLayout->setStretchFactor( mIconLabel, 0 ); + + QGraphicsLinearLayout *vLayout = new QGraphicsLinearLayout(); + //vLayout->setContentsMargins(0, 0, 0, 0); + vLayout->setOrientation( Qt::Vertical ); + + mDiskNameLabel = new HbLabel(); + HbFontSpec fontSpecPrimary(HbFontSpec::Primary); + //fontSpecPrimary.setTextHeight(18.0); + mDiskNameLabel->setFontSpec( fontSpecPrimary ); + vLayout->addItem( mDiskNameLabel ); + vLayout->setAlignment( mDiskNameLabel, Qt::AlignLeft ); + + mSizeLabel = new HbLabel(); + HbFontSpec fontSpecSecondary(HbFontSpec::Secondary); + //fontSpecSecondary.setTextHeight(18.0); + mSizeLabel->setFontSpec(fontSpecSecondary); + vLayout->addItem( mSizeLabel ); + vLayout->setAlignment(mSizeLabel, Qt::AlignLeft); + +// mFreeLabel = new HbLabel(); +// mFreeLabel->setFontSpec( HbFontSpec( HbFontSpec::Secondary ) ); +// vLayout->addItem( mFreeLabel ); +// vLayout->setAlignment( mFreeLabel, Qt::AlignLeft ); + + HbWidget *labelsWidget = new HbWidget(); + labelsWidget->setLayout(vLayout); + + hLayout->setAlignment( labelsWidget, Qt::AlignLeft ); + + hLayout->addItem( labelsWidget ); + hLayout->setStretchFactor( labelsWidget, 1 ); + + //this->setMaximumHeight( mDiskNameLabel->preferredHeight() ); + //setMaximumHeight( mIconLabel->preferredHeight() ); + + setLayout( hLayout ); +} diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/ui/src/fbdrivemodel.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/ui/src/fbdrivemodel.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,139 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "fbdrivemodel.h" +#include "enginewrapper.h" +#include "fbdriveentry.h" +#include "filebrowsersettings.h" +#include "FB.hrh" + +#include +#include + +/** + Constructs a file browser custom system model with the given \a engineWrapper and \a parent. + */ +FbDriveModel::FbDriveModel(EngineWrapper *engineWrapper, QObject *parent) : + QAbstractListModel(parent), + mEngineWrapper(engineWrapper), + mFileIconProvider(0) +{ + mFileIconProvider = new QFileIconProvider(); +} + +/** + Destroys this file browser custom system model. + */ +FbDriveModel::~FbDriveModel() +{ + if (mFileIconProvider) { + delete mFileIconProvider; + } +} + +/** + \reimp + */ +int FbDriveModel::rowCount(const QModelIndex &parent) const +{ + Q_UNUSED(parent); + return mEngineWrapper->itemCount(); +} + +/** + \reimp + */ +QVariant FbDriveModel::data(const QModelIndex &index, int role) const +{ + if (!index.isValid() || index.model() != this) + return QVariant(); + + switch (role) { + case Qt::EditRole: + case Qt::DisplayRole: { + QStringList listItem; + FbDriveEntry driveEntry(mEngineWrapper->getDriveEntry(index)); + if (mEngineWrapper->settings().fileViewMode() == EFileViewModeSimple) + { + const QString SimpleDriveEntry("%1: <%2>"); + listItem /*<< driveEntry.IconId() */ + << SimpleDriveEntry.arg(driveEntry.driveLetter()) + .arg(driveEntry.mediaTypeString()); + } else if (mEngineWrapper->settings().fileViewMode() == EFileViewModeExtended) { + const QString SimpleDriveEntry("%1: <%2>"); + const QString ExtendedDriveEntry("%1/%2 kB"); + listItem /*<< driveEntry.IconId()*/ + << SimpleDriveEntry.arg(driveEntry.driveLetter()) + .arg(driveEntry.mediaTypeString()) + << ExtendedDriveEntry.arg(QString::number(driveEntry.volumeInfoFree()/1024)) + .arg(QString::number(driveEntry.volumeInfoSize()/1024)); + + } + return listItem; + } + case Qt::DecorationRole: { + if (mEngineWrapper) { + QIcon icon; + //TODO Drive ico has to be provided, for some reason it is not visible + icon = mFileIconProvider->icon(QFileIconProvider::Drive); + return QVariant(icon); + } + } + } + return QVariant(); +} + +/** + \reimp + */ +QVariant FbDriveModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + Q_UNUSED(section); + Q_UNUSED(orientation); + Q_UNUSED(role); + + // TODO, implement or remove + return QVariant(); +} + + +FbDriveEntry FbDriveModel::driveEntry(const QModelIndex &index) const +{ + return mEngineWrapper->getDriveEntry(index); +} + +QString FbDriveModel::driveLetter(const QModelIndex &index) const +{ + QString diskLetter; + if (index.row() >= 0 && index.row() < mEngineWrapper->itemCount()) { + FbDriveEntry driveEntry(mEngineWrapper->getDriveEntry(index)); + diskLetter = driveEntry.driveLetter(); + } + return diskLetter; +} + +QString FbDriveModel::mediaTypeString(const QModelIndex &index) const +{ + QString mediaTypeString; + if (index.row() >= 0 && index.row() < mEngineWrapper->itemCount()) { + FbDriveEntry driveEntry(mEngineWrapper->getDriveEntry(index)); + mediaTypeString = driveEntry.mediaTypeString(); + } + return mediaTypeString; +} + +// --------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/ui/src/fbdriveview.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/ui/src/fbdriveview.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,1354 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "fbdriveview.h" +#include "fbsettingsview.h" +#include "fbeditorview.h" +#include "fbsearchview.h" +#include "enginewrapper.h" +#include "notifications.h" +#include "fbdrivemodel.h" +#include "filebrowsersortfilterproxymodel.h" +#include "fbdrivelistviewitem.h" +#include "fbpropertiesdialog.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +//TODO check if needed to do this way +#include + +// --------------------------------------------------------------------------- + +FbDriveView::FbDriveView() : + mEngineWrapper(0), + mListView(0), + mNaviPane(0), + mMainLayout(0), + mFbDriveModel(0), + mOptionMenuActions(), + mContextMenuActions(), + mContextMenu(0), + mLocationChanged(false), + mRemoveFileAfterCopied(false), +// mClipBoardInUse(false), + mFolderContentChanged(false), + mCurrentIndex(), + mOldPassword(), + mPanicCategory(), + mAbsoluteFilePath(), + mOverwriteOptions(), + mModelIndex(), + mNewFileName(), + mProceed(false), + mEraseMBR(false) +{ + setTitle("File Browser"); + + createMenu(); + createContextMenu(); +} + +// --------------------------------------------------------------------------- + +void FbDriveView::init(EngineWrapper *engineWrapper) +{ + mEngineWrapper = engineWrapper; + + mListView = new HbListView(this); + mListView->listItemPrototype()->setStretchingStyle(HbListViewItem::StretchLandscape); + + mListView->setItemPrototype(new FbDriveListViewItem(mListView)); + + mFbDriveModel = new FbDriveModel(mEngineWrapper); + if (!mListView->model()) { + mEngineWrapper->refreshView(); + mListView->setModel(mFbDriveModel); + } + + //mListView->setRootIndex(mFileSystemModel->index(startPath)); + //mListView->setRootIndex(model->index()); + +// mListView->setScrollingStyle(HbScrollArea::PanWithFollowOn); + + connect(mListView, SIGNAL(activated(QModelIndex)), this, SLOT(activated(QModelIndex))); + connect(mListView, SIGNAL(longPressed(HbAbstractViewItem*,QPointF)), + this, SLOT(onLongPressed(HbAbstractViewItem*, QPointF))); + + mNaviPane = new HbLabel(this); + mNaviPane->setPlainText(QString(" ")); // TODO get from settings or default + //mNaviPane->setPlainText(QString(mEngineWrapper->currentPath())); + HbFontSpec fontSpec(HbFontSpec::PrimarySmall); + mNaviPane->setFontSpec(fontSpec); + + // Create layout and add list view and naviPane into layout: + mMainLayout = new QGraphicsLinearLayout(Qt::Vertical); + mMainLayout->addItem(mNaviPane); + mMainLayout->addItem(mListView); + setLayout(mMainLayout); +} + +// --------------------------------------------------------------------------- + +FbDriveView::~FbDriveView() +{ +// if (mEngineWrapper) { +// delete mEngineWrapper; +// } + if (mContextMenu) { + mContextMenu->deleteLater(); + } + + delete mFbDriveModel; + delete mListView; +} + +/** + Initial setup for options menu. + Dynamic menu update during the runtime is performed by updateOptionMenu() which + to menu's aboutToShow() signal. + */ +void FbDriveView::createMenu() +{ + createFileMenu(); + createEditMenu(); + createViewMenu(); + createToolsMenu(); + + createSettingsMenuItem(); + createAboutMenuItem(); + createExitMenuItem(); + + // menu dynamic update + connect(menu(), SIGNAL(aboutToShow()), this, SLOT(updateOptionMenu())); +} + +/** + Initial setup for File submenu + */ +void FbDriveView::createFileMenu() +{ + mOptionMenuActions.mFileMenu = menu()->addMenu("File"); + + mOptionMenuActions.mFileSearch = mOptionMenuActions.mFileMenu->addAction("Search...", this, SLOT(fileSearch())); +} + +/** + Initial setup for Edit submenu + */ +void FbDriveView::createEditMenu() +{ + mOptionMenuActions.mEditMenu = menu()->addMenu("Edit"); + + mOptionMenuActions.mEditSnapShotToE = mOptionMenuActions.mEditMenu->addAction("Snap shot to E:", this, SLOT(editSnapShotToE())); + mOptionMenuActions.mEditSnapShotToE->setVisible(false); +} + +/** + Initial setup for View submenu + */ +void FbDriveView::createViewMenu() +{ + mOptionMenuActions.mViewMenu = menu()->addMenu("View"); + //mOptionMenuActions.mViewMenu->menuAction()->setVisible(false); + + //mOptionMenuActions.mViewFilterEntries = mOptionMenuActions.mViewMenu->addAction("Filter entries", this, SLOT(viewFilterEntries())); + mOptionMenuActions.mViewRefresh = mOptionMenuActions.mViewMenu->addAction("Refresh", this, SLOT(viewRefresh())); +} + +/** + Initial setup for Tools submenu + */ +void FbDriveView::createToolsMenu() +{ + mOptionMenuActions.mToolsMenu = menu()->addMenu("Tools"); + + mOptionMenuActions.mToolsAllAppsToTextFile = mOptionMenuActions.mToolsMenu->addAction("All apps to a text file", this, SLOT(toolsAllAppsToTextFile())); + mOptionMenuActions.mToolsAllAppsToTextFile->setVisible(false); + mOptionMenuActions.mToolsAllFilesToTextFile = mOptionMenuActions.mToolsMenu->addAction("All files to a text file", this, SLOT(toolsAllFilesToTextFile())); + //mOptionMenuActions.mToolsAllFilesToTextFile->setVisible(false); + +// mOptionMenuActions.mToolsAvkonIconCacheMenu = mOptionMenuActions.mToolsMenu->addMenu("Avkon icon cache"); +// mOptionMenuActions.mToolsAvkonIconCacheMenu->menuAction()->setVisible(false); +// mOptionMenuActions.mToolsAvkonIconCacheEnable = mOptionMenuActions.mToolsAvkonIconCacheMenu->addAction("Enable", this, SLOT(toolsAvkonIconCacheEnable())); +// mOptionMenuActions.mToolsAvkonIconCacheDisable = mOptionMenuActions.mToolsAvkonIconCacheMenu->addAction("Clear and disable", this, SLOT(toolsAvkonIconCacheDisable())); + + mOptionMenuActions.mToolsDisableExtendedErrors = mOptionMenuActions.mToolsMenu->addAction("Disable extended errors", this, SLOT(toolsDisableExtendedErrors())); + mOptionMenuActions.mToolsDumpMsgStoreWalk = mOptionMenuActions.mToolsMenu->addAction("Dump msg. store walk", this, SLOT(toolsDumpMsgStoreWalk())); + mOptionMenuActions.mToolsDumpMsgStoreWalk->setVisible(false); + mOptionMenuActions.mToolsEditDataTypes = mOptionMenuActions.mToolsMenu->addAction("Edit data types", this, SLOT(toolsEditDataTypes())); + mOptionMenuActions.mToolsEditDataTypes->setVisible(false); + mOptionMenuActions.mToolsEnableExtendedErrors = mOptionMenuActions.mToolsMenu->addAction("Enable extended errors", this, SLOT(toolsEnableExtendedErrors())); + + mOptionMenuActions.mToolsErrorSimulateMenu = mOptionMenuActions.mToolsMenu->addMenu("Error simulate"); + mOptionMenuActions.mToolsErrorSimulateLeave = mOptionMenuActions.mToolsErrorSimulateMenu->addAction("Leave", this, SLOT(toolsErrorSimulateLeave())); + mOptionMenuActions.mToolsErrorSimulatePanic = mOptionMenuActions.mToolsErrorSimulateMenu->addAction("Panic", this, SLOT(toolsErrorSimulatePanic())); + mOptionMenuActions.mToolsErrorSimulatePanic->setVisible(false); + mOptionMenuActions.mToolsErrorSimulateException = mOptionMenuActions.mToolsErrorSimulateMenu->addAction("Exception", this, SLOT(toolsErrorSimulateException())); + +// mOptionMenuActions.mLocalConnectivityMenu = mOptionMenuActions.mToolsMenu->addMenu("Local connectivity"); +// mOptionMenuActions.mToolsLocalConnectivityActivateInfrared = mOptionMenuActions.mLocalConnectivityMenu->addAction("Activate infrared", this, SLOT(toolsLocalConnectivityActivateInfrared())); +// mOptionMenuActions.mToolsLocalConnectivityLaunchBTUI = mOptionMenuActions.mLocalConnectivityMenu->addAction("Launch BT UI", this, SLOT(toolsLocalConnectivityLaunchBTUI())); +// mOptionMenuActions.mToolsLocalConnectivityLaunchUSBUI = mOptionMenuActions.mLocalConnectivityMenu->addAction("Launch USB UI", this, SLOT(toolsLocalConnectivityLaunchUSBUI())); + + mOptionMenuActions.mToolsMessageAttachmentsMenu = mOptionMenuActions.mToolsMenu->addMenu("Message attachments"); + mOptionMenuActions.mToolsMessageAttachmentsMenu->menuAction()->setVisible(false); + mOptionMenuActions.mToolsMessageInbox = mOptionMenuActions.mToolsMessageAttachmentsMenu->addAction("Inbox", this, SLOT(toolsMessageInbox())); + mOptionMenuActions.mToolsMessageDrafts = mOptionMenuActions.mToolsMessageAttachmentsMenu->addAction("Drafts", this, SLOT(toolsMessageDrafts())); + mOptionMenuActions.mToolsMessageSentItems = mOptionMenuActions.mToolsMessageAttachmentsMenu->addAction("Sent items", this, SLOT(toolsMessageSentItems())); + mOptionMenuActions.mToolsMessageOutbox = mOptionMenuActions.mToolsMessageAttachmentsMenu->addAction("Outbox", this, SLOT(toolsMessageOutbox())); + + mOptionMenuActions.mToolsMemoryInfo = mOptionMenuActions.mToolsMenu->addAction("Memory info", this, SLOT(toolsMemoryInfo())); + mOptionMenuActions.mToolsMemoryInfo->setVisible(false); + + mOptionMenuActions.mToolsSecureBackupMenu = mOptionMenuActions.mToolsMenu->addMenu("Secure backup"); + mOptionMenuActions.mToolsSecureBackupMenu->menuAction()->setVisible(false); + mOptionMenuActions.mToolsSecureBackStart = mOptionMenuActions.mToolsSecureBackupMenu->addAction("Start backup", this, SLOT(toolsSecureBackStart())); + mOptionMenuActions.mToolsSecureBackRestore = mOptionMenuActions.mToolsSecureBackupMenu->addAction("Start restore", this, SLOT(toolsSecureBackRestore())); + mOptionMenuActions.mToolsSecureBackStop = mOptionMenuActions.mToolsSecureBackupMenu->addAction("Stop", this, SLOT(toolsSecureBackStop())); + + mOptionMenuActions.mToolsSetDebugMask = mOptionMenuActions.mToolsMenu->addAction("Set debug mask", this, SLOT(toolsSetDebugMaskQuestion())); + mOptionMenuActions.mToolsShowOpenFilesHere = mOptionMenuActions.mToolsMenu->addAction("Show open files here", this, SLOT(toolsShowOpenFilesHere())); + mOptionMenuActions.mToolsShowOpenFilesHere->setVisible(false); +} + +/** + Creates Setting menu item in option menu + */ +void FbDriveView::createSettingsMenuItem() +{ + mOptionMenuActions.mSetting = menu()->addAction("Settings..."); + connect(mOptionMenuActions.mSetting, SIGNAL(triggered()), this, SIGNAL(aboutToShowSettingsView())); +} + + +/** + Creates About menu item in option menu + */ +void FbDriveView::createAboutMenuItem() +{ + // about note + mOptionMenuActions.mAbout = menu()->addAction("About"); + connect(mOptionMenuActions.mAbout, SIGNAL(triggered()), this, SLOT(about())); +} + +/** + Creates Exit menu item in option menu + */ +void FbDriveView::createExitMenuItem() +{ + // application exit + mOptionMenuActions.mExit = menu()->addAction("Exit"); + connect(mOptionMenuActions.mExit, SIGNAL(triggered()), qApp, SLOT(quit())); +} + +/** + update menu: disk admin available only in device root view. edit available only in folder view + when file or folder content exist in current folder, or clipboard has copied item. + file and view menus updated every time regarding the folder content. + tools, settings, about, exit always available. + If there's remove and add operations at same time, always remove first + to keep to the correct menu items order. + */ +void FbDriveView::updateOptionMenu() +{ + bool isFileItemListEmpty = mFbDriveModel->rowCount() == 0; +// bool isDriveListViewActive = true; //mEngineWrapper->isDriveListViewActive(); + bool isNormalModeActive = true; //iModel->FileUtils()->IsNormalModeActive(); +// bool isCurrentDriveReadOnly = mEngineWrapper->isCurrentDriveReadOnly(); //iModel->FileUtils()->IsCurrentDriveReadOnly(); +// bool isCurrentItemDirectory = mEngineWrapper->getFileEntry(currentItemIndex()).isDir(); + // bool currentSelected = true; //iContainer->ListBox()->View()->ItemIsSelected(iContainer->ListBox()->View()->CurrentItemIndex()); +// bool isAllSelected = mListView->selectionModel()->selection().count() == mFbDriveModel->rowCount(); + //bool isNoneSelected = mListView->selectionModel()->selection().count() != 0; +// bool hasSelectedItems = mListView->selectionModel()->selection().count() != 0; + //bool isSelectionMode = mOptionMenuActions.mSelection && mOptionMenuActions.mSelection->isChecked(); + bool isClipBoardEmpty = !mEngineWrapper->isClipBoardListInUse(); + bool showSnapShot = false; //iModel->FileUtils()->DriveSnapShotPossible(); + + bool showEditMenu(true); + if (!showSnapShot || isFileItemListEmpty && isClipBoardEmpty) + showEditMenu = false; + else + showEditMenu = true; + + mOptionMenuActions.mEditMenu->menuAction()->setVisible(showEditMenu); + + //aMenuPane->SetItemDimmed(EFileBrowserCmdFileOpen, isFileItemListEmpty || isDriveListViewActive || isCurrentItemDirectory); + + //aMenuPane->SetItemDimmed(EFileBrowserCmdFileView, isFileItemListEmpty || !hasSelectedItems || isCurrentItemDirectory || isDriveListViewActive); + //aMenuPane->SetItemDimmed(EFileBrowserCmdFileEdit, isFileItemListEmpty || !hasSelectedItems || isCurrentItemDirectory || isDriveListViewActive); + //aMenuPane->SetItemDimmed(EFileBrowserCmdFileSendTo, isFileItemListEmpty || driveListActive || isCurrentItemDirectory); + + // TODO mOptionMenuActions.mFileCompress->setVisible(!(isCurrentDriveReadOnly || isFileItemListEmpty || !hasSelectedItems || isCurrentItemDirectory || isDriveListViewActive)); + // TODO mOptionMenuActions.mFileDecompress->setVisible(!(isCurrentDriveReadOnly || isFileItemListEmpty || !hasSelectedItems || isCurrentItemDirectory || isDriveListViewActive)); + + // TODO mOptionMenuActions.mEditSnapShotToE->setVisible(isDriveListViewActive); + + // TODO mOptionMenuActions.mViewSort->setVisible(!(!isNormalModeActive || isDriveListViewActive || isFileItemListEmpty)); + // TODO mOptionMenuActions.mViewOrder->setVisible(!(!isNormalModeActive || isDriveListViewActive || isFileItemListEmpty)); + mOptionMenuActions.mViewRefresh->setVisible(isNormalModeActive); + //mOptionMenuActions.mViewFilterEntries->setVisible(!isFileItemListEmpty); + + // TODO R_FILEBROWSER_VIEW_SORT_SUBMENU + // aMenuPane->SetItemButtonState(iModel->FileUtils()->SortMode(), EEikMenuItemSymbolOn); + + // TODO R_FILEBROWSER_VIEW_ORDER_SUBMENU + // aMenuPane->SetItemButtonState(iModel->FileUtils()->OrderMode(), EEikMenuItemSymbolOn); + + // aResourceId == R_FILEBROWSER_TOOLS_SUBMENU + bool noExtendedErrorsAllowed = mEngineWrapper->ErrRdFileExists(); + mOptionMenuActions.mToolsDisableExtendedErrors->setVisible(noExtendedErrorsAllowed); + mOptionMenuActions.mToolsEnableExtendedErrors->setVisible(!noExtendedErrorsAllowed); + +// bool infraRedAllowed = mEngineWrapper->FileExists(KIRAppPath); +// bool bluetoothAllowed = mEngineWrapper->FileExists(KBTAppPath); +// bool usbAllowed = mEngineWrapper->FileExists(KUSBAppPath); +// +// bool noLocalCon = !infraRedAllowed && !bluetoothAllowed && !usbAllowed; +// mOptionMenuActions.mToolsLocalConnectivityMenu->menuAction()->setVisible(!noLocalCon); +// +// mOptionMenuActions.mToolsLocalConnectivityActivateInfrared->setVisible(infraRedAllowed); +// mOptionMenuActions.mToolsLocalConnectivityLaunchBTUI->setVisible(bluetoothAllowed); +// mOptionMenuActions.mToolsLocalConnectivityLaunchUSBUI->setVisible(usbAllowed); +} + +void FbDriveView::createContextMenu() +{ + mContextMenu = new HbMenu(); + connect(mContextMenu, SIGNAL(aboutToShow()), this, SLOT(updateContextMenu())); + + createFileContextMenu(); + createEditContextMenu(); + createViewContextMenu(); + createDiskAdminContextMenu(); +} + + +void FbDriveView::createFileContextMenu() +{ + mContextMenuActions.mFileProperties = mContextMenu->addAction("Properties", this, SLOT(fileProperties())); + mContextMenuActions.mFileSearch = mContextMenu->addAction("Search...", this, SLOT(fileSearch())); +} + +void FbDriveView::createEditContextMenu() +{ +// mContextMenuActions.mEditMenu = mContextMenu->addMenu("Edit"); + + //mContextMenuActions.mEditSnapShotToE = mContextMenuActions.mEditMenu->addAction("Snap shot to E:", this, SLOT(editSnapShotToE())); +// mContextMenuActions.mEditSnapShotToE->setVisible(false); +// mContextMenuActions.mEditCut = mContextMenuActions.mEditMenu->addAction("Cut", this, SLOT(editCut())); +// mContextMenuActions.mEditCopy = mContextMenuActions.mEditMenu->addAction("Copy", this, SLOT(editCopy())); +// mContextMenuActions.mEditPaste = mContextMenuActions.mEditMenu->addAction("Paste", this, SLOT(editPaste())); +// mContextMenuActions.mEditCopyToFolder = mContextMenuActions.mEditMenu->addAction("Copy to folder...", this, SLOT(editCopyToFolder())); +// mContextMenuActions.mEditMoveToFolder = mContextMenuActions.mEditMenu->addAction("Move to folder...", this, SLOT(editMoveToFolder())); +} + +void FbDriveView::createViewContextMenu() +{ + +} + +/** + Initial setup for Disk Admin submenu + */ +void FbDriveView::createDiskAdminContextMenu() +{ + mContextMenuActions.mDiskAdminMenu = mContextMenu->addMenu("Disk admin"); + //mContextMenuActions.mDiskAdminMenu->menuAction()->setVisible(false); + + mContextMenuActions.mDiskAdminSetDrivePassword = mContextMenuActions.mDiskAdminMenu->addAction("Set drive password", this, SLOT(diskAdminSetDrivePassword())); + mContextMenuActions.mDiskAdminUnlockDrive = mContextMenuActions.mDiskAdminMenu->addAction("Unlock drive", this, SLOT(diskAdminUnlockDrive())); + mContextMenuActions.mDiskAdminClearDrivePassword = mContextMenuActions.mDiskAdminMenu->addAction("Clear drive password", this, SLOT(diskAdminClearDrivePassword())); + mContextMenuActions.mDiskAdminEraseDrivePassword = mContextMenuActions.mDiskAdminMenu->addAction("Erase drive password", this, SLOT(diskAdminEraseDrivePassword())); + + mContextMenuActions.mDiskAdminFormatDrive = mContextMenuActions.mDiskAdminMenu->addAction("Format drive", this, SLOT(diskAdminFormatDrive())); + mContextMenuActions.mDiskAdminFormatDrive->setVisible(false); + mContextMenuActions.mDiskAdminQuickFormatDrive = mContextMenuActions.mDiskAdminMenu->addAction("Quick format drive", this, SLOT(diskAdminQuickFormatDrive())); + mContextMenuActions.mDiskAdminQuickFormatDrive->setVisible(false); + + mContextMenuActions.mDiskAdminCheckDisk = mContextMenuActions.mDiskAdminMenu->addAction("Check disk", this, SLOT(diskAdminCheckDisk())); + mContextMenuActions.mDiskAdminScanDrive = mContextMenuActions.mDiskAdminMenu->addAction("Scan drive", this, SLOT(diskAdminScanDrive())); + mContextMenuActions.mDiskAdminSetDriveName = mContextMenuActions.mDiskAdminMenu->addAction("Set drive name", this, SLOT(diskAdminSetDriveName())); + mContextMenuActions.mDiskAdminSetDriveVolumeLabel = mContextMenuActions.mDiskAdminMenu->addAction("Set drive volume label", this, SLOT(diskAdminSetDriveVolumeLabel())); + mContextMenuActions.mDiskAdminEjectDrive = mContextMenuActions.mDiskAdminMenu->addAction("Eject drive", this, SLOT(diskAdminEjectDrive())); + mContextMenuActions.mDiskAdminDismountDrive = mContextMenuActions.mDiskAdminMenu->addAction("Dismount drive", this, SLOT(diskAdminDismountDrive())); + mContextMenuActions.mDiskAdminEraseMBR = mContextMenuActions.mDiskAdminMenu->addAction("Erase MBR", this, SLOT(diskAdminEraseMBR())); + mContextMenuActions.mDiskAdminPartitionDrive = mContextMenuActions.mDiskAdminMenu->addAction("Partition drive", this, SLOT(diskAdminPartitionDrive())); +} + +void FbDriveView::updateContextMenu() +{ + bool isFileItemListEmpty = mFbDriveModel->rowCount() == 0; + mContextMenuActions.mFileProperties->setVisible(!isFileItemListEmpty); +} + +// --------------------------------------------------------------------------- + +void FbDriveView::onLongPressed(HbAbstractViewItem *listViewItem, QPointF coords) +{ + mCurrentIndex = listViewItem->modelIndex(); + + mContextMenu->setPreferredPos(coords); + mContextMenu->show(); +} + +/** + Refresh FileBrowser view + */ +void FbDriveView::refreshList() +{ + mEngineWrapper->refreshView(); + mListView->reset(); + + TListingMode listingMode = mEngineWrapper->listingMode(); + if (listingMode == ENormalEntries) + mNaviPane->setPlainText(QString(mEngineWrapper->currentPath())); + else if (listingMode == ESearchResults) + mNaviPane->setPlainText(QString(tr("Search results"))); + else if (listingMode == EOpenFiles) + mNaviPane->setPlainText(QString(tr("Open files"))); + else if (listingMode == EMsgAttachmentsInbox) + mNaviPane->setPlainText(QString(tr("Attachments in Inbox"))); + else if (listingMode == EMsgAttachmentsDrafts) + mNaviPane->setPlainText(QString(tr("Attachments in Drafts"))); + else if (listingMode == EMsgAttachmentsSentItems) + mNaviPane->setPlainText(QString(tr("Attachments in Sent Items"))); + else if (listingMode == EMsgAttachmentsOutbox) + mNaviPane->setPlainText(QString(tr("Attachments in Outbox"))); +} + +// --------------------------------------------------------------------------- +/** + Show a list dialog + \param List aList of item to select item from. + \param Title text titleText of a dialog heading widget + \return None + */ +void FbDriveView::openListDialog(const QStringList& items, const QString &titleText, QObject* receiver, const char* member) +{ + // Create a list and some simple content for it + HbSelectionDialog *dlg = new HbSelectionDialog(); + dlg->setAttribute(Qt::WA_DeleteOnClose); + // Set items to be popup's content + dlg->setStringItems(items); + dlg->setSelectionMode(HbAbstractItemView::SingleSelection); + + HbLabel *title = new HbLabel(dlg); + title->setPlainText(titleText); + dlg->setHeadingWidget(title); + + // Launch popup and handle the user response: + dlg->open(receiver, member); +} + +void FbDriveView::storeSelectedItemsOrCurrentItem() +{ + QItemSelectionModel *selectionIndexes = mListView->selectionModel(); + + // by default use selected items + if (selectionIndexes) { + if (selectionIndexes->hasSelection()) { + mSelectionIndexes = mListView->selectionModel()->selectedIndexes(); + } else { // or if none selected, use the current item index + mSelectionIndexes.clear(); + mSelectionIndexes.append(mCurrentIndex); +// QModelIndex currentIndex = currentItemIndex(); +// if (mFbDriveModel->rowCount(currentItemIndex) > currentItemIndex && currentItemIndex >= 0) +// { +// modelIndexList.append(currentIndex); +// } + } + } +// mClipBoardInUse = true; +} + +// --------------------------------------------------------------------------- + +QModelIndex FbDriveView::currentItemIndex() +{ + return mCurrentIndex;//mListView->selectionModel()->currentIndex(); +} + +// --------------------------------------------------------------------------- +// operations in File Menu +// --------------------------------------------------------------------------- + +void FbDriveView::fileOpenDrive() +{ + // TODO make a separate function to be called from here and fileOpenDirectory() + mLocationChanged = true; + // get selected drive or directory from list view model and open it: + //if (mListView->selectionModel()->hasSelection()) { +// if (mListView->selectionModel()->selection().count() != 0) { +// QModelIndex currentIndex = currentItemIndex(); + mEngineWrapper->moveDownToDirectory(mCurrentIndex); + mListView->setRootIndex(mCurrentIndex); + refreshList(); +// } else { +// Notifications::showErrorNote("not selected item!"); +// } +} + +void FbDriveView::fileSearch() +{ + QString searchPath; + HbAction *contextrMenuAction = static_cast(sender()); + if (contextrMenuAction + && contextrMenuAction->text().compare(QString("Search..."), Qt::CaseInsensitive) == 0 + && contextrMenuAction == mContextMenuActions.mFileSearch) { + FbDriveEntry driveEntry(mEngineWrapper->getDriveEntry(currentItemIndex())); + searchPath = driveEntry.driveLetter() + QString(":\\"); + } else { + searchPath = mEngineWrapper->currentPath(); + } + emit aboutToShowSearchView(searchPath); +} + +/** + Show file properties + */ +void FbDriveView::fileProperties() +{ + const QString MediaTypeText("Media"); + const QString AttributesText("Atts"); + const QString VolumeNameText("Name"); + const QString UniqueIdText("ID"); + const QString NumberOfFilesText("Files"); + const QString UsedText("Used"); + const QString FreeText("Free"); + const QString SizeText("Size"); + + QModelIndex currentIndex = currentItemIndex(); + QVector > properties; + QString titleText; + bool showDialog(false); + + if (currentIndex.row() >= 0 && currentIndex.row() < mEngineWrapper->itemCount()) { + // it is a drive entry + FbDriveEntry driveEntry(mEngineWrapper->getDriveEntry(currentIndex)); + + // set title + titleText = driveEntry.driveLetter() + (QString(":\\")); + + // media type + properties.append(qMakePair(MediaTypeText, driveEntry.mediaTypeString())); + + // attributes + QString attributes = driveEntry.attributesString(); // TODO should return QStringList + QStringList attributesList = attributes.split(" + "); + for(int i(0), ie(attributesList.count()); i < ie; ++i) { + properties.append(qMakePair(AttributesText, attributesList[i])); + } + + // volume name + if (driveEntry.volumeInfoNameString().length()) { + properties.append(qMakePair(VolumeNameText, driveEntry.volumeInfoNameString())); + } + + // unique id + QString uniqueId("0x"); + uniqueId.append(QString::number(driveEntry.volumeInfoUniqueId(), 16).toUpper()); + properties.append(qMakePair(UniqueIdText, uniqueId)); + + // number of files + if (mEngineWrapper->settings().showSubDirectoryInfo()) { + QString driveRoot = driveEntry.driveLetter() + (QString(":\\")); + int allFilesCount = mEngineWrapper->getFilesCount(driveRoot); + properties.append(qMakePair(NumberOfFilesText, QString::number(allFilesCount))); + } + + // used + QLocale loc; + qint64 used = driveEntry.volumeInfoSize() - driveEntry.volumeInfoFree(); + QString usedSize = loc.toString(used).append(QString(" B")); + properties.append(qMakePair(UsedText, usedSize)); + + // free + QString freeSize = loc.toString(driveEntry.volumeInfoFree()).append(QString(" B")); + properties.append(qMakePair(FreeText, freeSize)); + + // size + QString totalSize = loc.toString(driveEntry.volumeInfoSize()).append(QString(" B")); + properties.append(qMakePair(SizeText, totalSize)); + + showDialog = true; + } + + if (showDialog) { + FbPropertiesDialog *dialog = new FbPropertiesDialog(); + dialog->setTitle(titleText); + + // Set listwidget to be popup's content + dialog->setProperties(properties); + // Launch popup and handle the user response: + dialog->open(); + } +} + +// edit menu +void FbDriveView::editSnapShotToE() +{ + +} + +// --------------------------------------------------------------------------- +// view menu +// --------------------------------------------------------------------------- + +/** + Refresh view + */ +void FbDriveView::viewRefresh() +{ + refreshList(); +} + +// --------------------------------------------------------------------------- +// disk admin menu +// --------------------------------------------------------------------------- + +/** + Open old password for the selected drive dialog. + */ +void FbDriveView::diskAdminSetDrivePassword() +{ + QModelIndex currentIndex = currentItemIndex(); + // check if the drive has a password + if (mEngineWrapper->hasDrivePassword(currentIndex)) { + QString heading = QString("Existing password"); + HbInputDialog::queryText(heading, this, SLOT(diskAdminSetDrivePasswordNew(HbAction*)), QString(), scene()); + } else { + QString heading = QString("New password"); + HbInputDialog::queryText(heading, this, SLOT(doDiskAdminSetDrivePassword(HbAction*)), mOldPassword, scene()); + } +} + +/** + Open new password for the selected drive dialog. + */ +void FbDriveView::diskAdminSetDrivePasswordNew(HbAction *action) +{ + HbInputDialog *dlg = static_cast(sender()); + if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { + mOldPassword = dlg->value().toString(); + QString heading = QString("New password"); + HbInputDialog::queryText(heading, this, SLOT(doDiskAdminSetDrivePassword(HbAction*)), mOldPassword, scene()); + } +} + +/** + Set password for the selected drive. + */ +void FbDriveView::doDiskAdminSetDrivePassword(HbAction *action) +{ + HbInputDialog *dlg = static_cast(sender()); + if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { + QString newPassword = dlg->value().toString(); + QModelIndex currentIndex = currentItemIndex(); + mEngineWrapper->DiskAdminSetDrivePassword(currentIndex, mOldPassword, newPassword); + refreshList(); + mOldPassword = QString(); + newPassword = QString(); + } +} + +/** + Open Unlock the selected drive dialog. + */ +void FbDriveView::diskAdminUnlockDrive() +{ + QModelIndex currentIndex = currentItemIndex(); + // check if the drive is locked + if (mEngineWrapper->isDriveLocked(currentIndex)) { + QString heading = QString("Existing password"); + HbInputDialog::queryText(heading, this, SLOT(doDiskAdminUnlockDrive(HbAction*)), QString(), scene()); + } else { + Notifications::showInformationNote(QString("This drive is not locked")); + } +} + +/** + Unlock the selected drive. + */ +void FbDriveView::doDiskAdminUnlockDrive(HbAction *action) +{ + HbInputDialog *dlg = static_cast(sender()); + if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { + QString oldPassword = dlg->value().toString(); + QModelIndex currentIndex = currentItemIndex(); + mEngineWrapper->DiskAdminUnlockDrive(currentIndex, oldPassword); + refreshList(); + } +} + +/** + Open clear password of the selected drive dialog. + */ +void FbDriveView::diskAdminClearDrivePassword() +{ + QModelIndex currentIndex = currentItemIndex(); + // check if the drive has a password + if (mEngineWrapper->hasDrivePassword(currentIndex)) { + QString heading = QString("Existing password"); + HbInputDialog::queryText(heading, this, SLOT(doDiskAdminClearDrivePassword(HbAction*)), QString(), scene()); + } else { + Notifications::showInformationNote(QString("This drive has no password")); + } +} + +/** + Clear password of the selected drive. + */ +void FbDriveView::doDiskAdminClearDrivePassword(HbAction *action) +{ + HbInputDialog *dlg = static_cast(sender()); + if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { + QString oldPassword = dlg->value().toString(); + QModelIndex currentIndex = currentItemIndex(); + mEngineWrapper->DiskAdminClearDrivePassword(currentIndex, oldPassword); + refreshList(); + } +} + + +/** + Question for erase password of the selected drive + */ +void FbDriveView::diskAdminEraseDrivePassword() +{ + // check if the drive has a password + QModelIndex currentIndex = currentItemIndex(); + if (mEngineWrapper->hasDrivePassword(currentIndex)) { + HbMessageBox::question(QString("Are you sure? All data can be lost!"), + this, + SLOT(doDiskAdminEraseDrivePassword(int)), + HbMessageBox::Yes | HbMessageBox::No); + } else { + Notifications::showInformationNote(QString("This drive has no password")); + } +} + +/** + Erase password of the selected drive + */ +void FbDriveView::doDiskAdminEraseDrivePassword(int action) +{ + if (action == HbMessageBox::Yes) { + QModelIndex currentIndex = currentItemIndex(); + mEngineWrapper->DiskAdminEraseDrivePassword(currentIndex); + refreshList(); + } +} + +/** + Performs format on the selected drive + */ +void FbDriveView::diskAdminFormatDrive() +{ + HbMessageBox::question(QString("Are you sure? All data will be lost!"), + this, + SLOT(doDiskAdminFormatDrive(int)), + HbMessageBox::Yes | HbMessageBox::No); +} + +/** + Performs format on the selected drive + */ +void FbDriveView::doDiskAdminFormatDrive(int action) +{ + if (action == HbMessageBox::Yes) { + QModelIndex currentIndex = currentItemIndex(); + mEngineWrapper->DiskAdminFormatDrive(currentIndex, false); + } +} + +/** + Performs quick format on the selected drive + */ +void FbDriveView::diskAdminQuickFormatDrive() +{ + HbMessageBox::question(QString("Are you sure? All data will be lost!"), + this, + SLOT(doDiskAdminQuickFormatDrive(int)), + HbMessageBox::Yes | HbMessageBox::No); +} + +/** + Performs quick format on the selected drive + */ +void FbDriveView::doDiskAdminQuickFormatDrive(int action) +{ + if (action == HbMessageBox::Yes) { + QModelIndex currentIndex = currentItemIndex(); + mEngineWrapper->DiskAdminFormatDrive(currentIndex, true); + } +} + +/** + Checks the disk integrity on the selected drive + */ +void FbDriveView::diskAdminCheckDisk() +{ + QModelIndex currentIndex = currentItemIndex(); + mEngineWrapper->DiskAdminCheckDisk(currentIndex); +} + +/** + Checks the selected drive for errors and corrects them + */ +void FbDriveView::diskAdminScanDrive() +{ + HbMessageBox::question(QString("This finds errors on disk and corrects them. Proceed?"), + this, + SLOT(doDiskAdminScanDrive(int)), + HbMessageBox::Yes | HbMessageBox::No); +} + +/** + Checks the selected drive for errors and corrects them + */ +void FbDriveView::doDiskAdminScanDrive(int action) +{ + if (action == HbMessageBox::Yes) { + QModelIndex currentIndex = currentItemIndex(); + mEngineWrapper->DiskAdminScanDrive(currentIndex); + refreshList(); + } +} + +/** + Open drive name dialog + */ +void FbDriveView::diskAdminSetDriveName() +{ + QString driveName; + + // get existing drive name + QModelIndex currentIndex = currentItemIndex(); + mEngineWrapper->GetDriveName(currentIndex, driveName); + + QString heading = QString("New name"); + HbInputDialog::queryText(heading, this, SLOT(doDiskAdminSetDriveName(HbAction*)), driveName, scene()); +} + +/** + Set drive name. + */ +void FbDriveView::doDiskAdminSetDriveName(HbAction *action) +{ + HbInputDialog *dlg = static_cast(sender()); + if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { + QString driveName = dlg->value().toString(); + + QModelIndex currentIndex = currentItemIndex(); + mEngineWrapper->DiskAdminSetDriveName(currentIndex, driveName); + + refreshList(); + } +} + +/** + Open drive volume label dialog + */ +void FbDriveView::diskAdminSetDriveVolumeLabel() +{ + QString volumeLabel; + + // get existing drive name + QModelIndex currentIndex = currentItemIndex(); + mEngineWrapper->GetDriveVolumeLabel(currentIndex, volumeLabel); + + QString heading = QString("New volume label"); + HbInputDialog::queryText(heading, this, SLOT(doDiskAdminSetDriveVolumeLabel(HbAction*)), volumeLabel, scene()); +} + +/** + Set drive volume label. + */ +void FbDriveView::doDiskAdminSetDriveVolumeLabel(HbAction *action) +{ + HbInputDialog *dlg = static_cast(sender()); + if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { + QString volumeLabel = dlg->value().toString(); + + QModelIndex currentIndex = currentItemIndex(); + mEngineWrapper->DiskAdminSetDriveVolumeLabel(currentIndex, volumeLabel); + + refreshList(); + } +} + +/** + Eject the selected drive + */ +void FbDriveView::diskAdminEjectDrive() +{ + QModelIndex currentIndex = currentItemIndex(); + mEngineWrapper->DiskAdminEjectDrive(currentIndex); + refreshList(); +} + +/** + Dismount the selected drive + */ +void FbDriveView::diskAdminDismountDrive() +{ + HbMessageBox::question(QString("Are you sure you know what are you doing?"), + this, + SLOT(doDiskAdminDismountDrive(int)), + HbMessageBox::Yes | HbMessageBox::No); +} + +void FbDriveView::doDiskAdminDismountDrive(int action) +{ + if (action == HbMessageBox::Yes) { + QModelIndex currentIndex = currentItemIndex(); + mEngineWrapper->DiskAdminDismountDrive(currentIndex); + refreshList(); + } +} + +/** + Erase Master Boot Record of the selected drive + */ +void FbDriveView::diskAdminEraseMBR() +{ + // TODO What to do with FB LITE macros? + HbMessageBox::question(QString("Are you sure? Your media driver must support this!"), + this, + SLOT(doDiskAdminEraseMBR(int)), + HbMessageBox::Yes | HbMessageBox::No); +} + +void FbDriveView::doDiskAdminEraseMBR(int action) +{ + // TODO What to do with FB LITE macros? + if (action == HbMessageBox::Yes) { + HbMessageBox::question(QString("Are you really sure you know what are you doing ?!?"), + this, + SLOT(doDiskAdminReallyEraseMBR(int)), + HbMessageBox::Yes | HbMessageBox::No); + } +} + +void FbDriveView::doDiskAdminReallyEraseMBR(int action) +{ + if (action == HbMessageBox::Yes) { + QModelIndex currentIndex = currentItemIndex(); + // warn if the selected drive is not detected as removable + if (mEngineWrapper->isDriveRemovable(currentIndex)) { + mEngineWrapper->DiskAdminEraseMBR(currentIndex); + refreshList(); + } else { + HbMessageBox::question(QString("Selected drive is not removable, really continue?"), + this, + SLOT(doDiskAdminNotRemovableReallyEraseMBR(int)), + HbMessageBox::Yes | HbMessageBox::No); + } + } +} + +void FbDriveView::doDiskAdminNotRemovableReallyEraseMBR(int action) +{ + if (action == HbMessageBox::Yes) { + QModelIndex currentIndex = currentItemIndex(); + mEngineWrapper->DiskAdminEraseMBR(currentIndex); + refreshList(); + } + +} + +/** + Partition the selected drive + */ +void FbDriveView::diskAdminPartitionDrive() +{ + HbMessageBox::question(QString("Are you sure? Your media driver must support this!"), + this, + SLOT(diskAdminPartitionDriveProceed(int)), + HbMessageBox::Yes | HbMessageBox::No); +} + +/** + Partition the selected drive if user is sure + */ +void FbDriveView::diskAdminPartitionDriveProceed(int action) +{ + if (action == HbMessageBox::Yes) { + HbMessageBox::question(QString("Are you really sure you know what are you doing ?!?"), + this, + SLOT(diskAdminPartitionDriveReallyProceed(int)), + HbMessageBox::Yes | HbMessageBox::No); + } +} + +/** + Partition the selected drive if user is really sure + */ +void FbDriveView::diskAdminPartitionDriveReallyProceed(int action) +{ + if (action == HbMessageBox::Yes) { + QModelIndex currentIndex = currentItemIndex(); + mEraseMBR = false; + // warn if the selected drive is not detected as removable + mProceed = false; + if (mEngineWrapper->isDriveRemovable(currentIndex)) { + mProceed = true; + } else { + HbMessageBox::question(QString("Selected drive is not removable, really continue?"), + this, + SLOT(diskAdminPartitionDriveIsNotRemovable(int)), + HbMessageBox::Yes | HbMessageBox::No); + } + + if (mProceed) { + // query if erase mbr + mEraseMBR = false; + + HbMessageBox::question(QString("Erase MBR first (normally needed)?"), + this, + SLOT(diskAdminPartitionDriveEraseMbr(int)), + HbMessageBox::Yes | HbMessageBox::No); + + // TODO use HbListDialog + QStringList list; + list << "1" << "2" << "3" << "4"; + openListDialog(list, QString("Partitions?"), this, SLOT(diskAdminPartitionDriveGetCount(HbAction*))); + } + } +} + +/** + Store result of user query about proceeding when drive is not removable. + */ +void FbDriveView::diskAdminPartitionDriveIsNotRemovable(int action) +{ + if (action == HbMessageBox::Yes) { + mProceed = true; + } else { + mProceed = false; + } +} + +/** + Store result of user query about erase MBR + */ +void FbDriveView::diskAdminPartitionDriveEraseMbr(int action) +{ + if (action == HbMessageBox::Yes) { + mEraseMBR = true; + } +} + +/** + Partition the selected drive + */ +void FbDriveView::diskAdminPartitionDriveGetCount(HbAction* action) +{ + HbSelectionDialog *dlg = static_cast(sender()); + if(!action && dlg && dlg->selectedItems().count()){ + int selectionIndex = dlg->selectedItems().at(0).toInt(); + QModelIndex currentIndex = currentItemIndex(); + int amountOfPartitions = selectionIndex + 1; + mEngineWrapper->DiskAdminPartitionDrive(currentIndex, mEraseMBR, amountOfPartitions); + refreshList(); + } +} + +// --------------------------------------------------------------------------- +// tools menu +// --------------------------------------------------------------------------- +void FbDriveView::toolsAllAppsToTextFile() +{ + +} + +/** + Write all files to text file + */ +void FbDriveView::toolsAllFilesToTextFile() +{ + mEngineWrapper->toolsWriteAllFiles(); +} + +//void FbDriveView::toolsAvkonIconCacheEnable() +//{ +// +//} +//void FbDriveView::toolsAvkonIconCacheDisable() +//{ +// +//} + +/** + Disable extended errors + */ +void FbDriveView::toolsDisableExtendedErrors() +{ + mEngineWrapper->ToolsSetErrRd(false); +} + +void FbDriveView::toolsDumpMsgStoreWalk() +{ + +} +void FbDriveView::toolsEditDataTypes() +{ + +} + +/** + Enable extended errors + */ +void FbDriveView::toolsEnableExtendedErrors() +{ + mEngineWrapper->ToolsSetErrRd(true); +} + +/** + Open simulate leave dialog + */ +void FbDriveView::toolsErrorSimulateLeave() +{ + int leaveCode = -6; + QString heading = QString("Leave code"); + HbInputDialog::queryText(heading, this, SLOT(doToolsErrorSimulateLeave(HbAction*)), QString::number(leaveCode), scene()); +} + + +/** + Simulate leave. + */ +void FbDriveView::doToolsErrorSimulateLeave(HbAction *action) +{ + HbInputDialog *dlg = static_cast(sender()); + if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { + bool ok; + int leaveCode = dlg->value().toString().toInt(&ok); + if (leaveCode != 0 || ok) { + mEngineWrapper->ToolsErrorSimulateLeave(leaveCode); + } + } +} + +/** + Open simulate panic dialog. + */ +void FbDriveView::toolsErrorSimulatePanic() +{ + mPanicCategory = QString ("Test Category"); + QString heading = QString("Panic category"); + HbInputDialog::queryText(heading, this, SLOT(doToolsErrorSimulatePanicCode(HbAction*)), mPanicCategory, scene()); +} + +/** + Simulate panic. + */ +void FbDriveView::doToolsErrorSimulatePanicCode(HbAction *action) +{ + HbInputDialog *dlg = static_cast(sender()); + if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { + mPanicCategory = dlg->value().toString(); + int panicCode(555); + QString heading = QString("Panic code"); + HbInputDialog::queryInt(heading, this, SLOT(doToolsErrorSimulatePanic(HbAction*)), panicCode, scene()); + } +} + +/** + Simulate panic. + */ +void FbDriveView::doToolsErrorSimulatePanic(HbAction *action) +{ + HbInputDialog *dlg = static_cast(sender()); + if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { + bool ok; + int panicCode = dlg->value().toInt(&ok); + if (panicCode != 0 || ok) { + mEngineWrapper->ToolsErrorSimulatePanic(mPanicCategory, panicCode); + } + } +} + +/** + Open simulate exception dialog. + */ +void FbDriveView::toolsErrorSimulateException() +{ + int exceptionCode = 0; + QString heading = QString("Exception code"); + HbInputDialog::queryInt(heading, this, SLOT(doToolsErrorSimulateException(HbAction*)), exceptionCode, scene()); +} + +/** + Simulate exception. + */ +void FbDriveView::doToolsErrorSimulateException(HbAction *action) +{ + HbInputDialog *dlg = static_cast(sender()); + if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { + bool ok; + int exceptionCode = dlg->value().toInt(&ok); + if (exceptionCode != 0 || ok) { + mEngineWrapper->ToolsErrorSimulateException(exceptionCode); + } + } +} + +// void FbDriveView::toolsLocalConnectivityActivateInfrared() +//{ +// +//} +// void FbDriveView::toolsLocalConnectivityLaunchBTUI() +//{ +// +//} +// void FbDriveView::toolsLocalConnectivityLaunchUSBUI() +//{ +// +//} +void FbDriveView::toolsMessageInbox() +{ + +} +void FbDriveView::toolsMessageDrafts() +{ + +} +void FbDriveView::toolsMessageSentItems() +{ + +} +void FbDriveView::toolsMessageOutbox() +{ + +} +void FbDriveView::toolsMemoryInfo() +{ + +} +void FbDriveView::toolsSecureBackStart() +{ + +} +void FbDriveView::toolsSecureBackRestore() +{ + +} +void FbDriveView::toolsSecureBackStop() +{ + +} + +/** + Open debug mask dialog + */ +void FbDriveView::toolsSetDebugMaskQuestion() +{ + quint32 dbgMask = mEngineWrapper->getDebugMask(); + QString dbgMaskText = QString("0x").append(QString::number(dbgMask, 16)); + QString heading = QString("Kernel debug mask in hex format"); + HbInputDialog::queryText(heading, this, SLOT(toolsSetDebugMask(HbAction*)), dbgMaskText, scene()); +} + +/** + Set debug mask + */ +void FbDriveView::toolsSetDebugMask(HbAction *action) +{ + HbInputDialog *dlg = static_cast(sender()); + if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { + QString dbgMaskText = dlg->value().toString(); + if (dbgMaskText.length() > 2 && dbgMaskText[0]=='0' && dbgMaskText[1]=='x') { + bool ok; + quint32 dbgMask = dbgMaskText.toUInt(&ok, 16); + if (dbgMask != 0 || ok) { + mEngineWrapper->toolsSetDebugMask(dbgMask); + Notifications::showConfirmationNote(QString("Changed")); + } else { + Notifications::showErrorNote(QString("Cannot convert value")); + } + } else { + Notifications::showErrorNote(QString("Not in hex format")); + } + } +} + +void FbDriveView::toolsShowOpenFilesHere() +{ + +} + +// --------------------------------------------------------------------------- +// main menu items +// --------------------------------------------------------------------------- + +/** + Show about note + */ +void FbDriveView::about() +{ + Notifications::showAboutNote(); +} + +// --------------------------------------------------------------------------- +// End of operations +// --------------------------------------------------------------------------- + +// --------------------------------------------------------------------------- + +/** + Item is selected from list when selection mode is activated from menu + */ +void FbDriveView::selectionChanged(const QItemSelection &/*selected*/, const QItemSelection &/*deselected*/) +{ + //QItemSelectionModel *selectionModel = mListView->selectionModel(); +} + +/** + An item is clicked from navigation item list. Navigation item list contains + drive-, folder- or file items. Opens selected drive, folder or file popup menu + */ +void FbDriveView::activated(const QModelIndex& index) +{ + if (mFbDriveModel) { +// if (mEngineWrapper->isDriveListViewActive()) { + mEngineWrapper->moveDownToDirectory(index); + //emit aboutToShowFileView(QString(mEngineWrapper->currentPath())); + emit aboutToShowFileView(); + //refreshList(); +// } + } +} + +// --------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/ui/src/fbeditorview.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/ui/src/fbeditorview.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,144 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "fbeditorview.h" + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +FbEditorView::FbEditorView() : + mTextEdit(0), + mFileHex(false), + mFlagReadOnly(), + mFileName(), + mFileContent(), + mToTextAction(0), + mToHexAction(0), + mExitAction(0) +{ + // Override back navigation action + HbAction *backNaviAction = new HbAction(Hb::BackNaviAction, this); + connect(backNaviAction, SIGNAL(triggered()), this, SLOT(backButtonClicked())); + setNavigationAction(backNaviAction); + + createMenu(); + + // text editor +// mTextEdit = new QTextEdit(); +// QGraphicsLinearLayout *editorLayout = new QGraphicsLinearLayout(Qt::Vertical); +// QGraphicsProxyWidget *editorWidget = new QGraphicsProxyWidget(); +// editorWidget->setWidget(mTextEdit); +// editorLayout->addItem(editorWidget); +// setLayout(editorLayout); + + mTextEdit = new HbTextEdit(); + mTextEdit->setAlignment(Qt::AlignTop); + QGraphicsLinearLayout *editorLayout = new QGraphicsLinearLayout(Qt::Vertical, this); + editorLayout->addItem(mTextEdit); + setLayout(editorLayout); +} + +FbEditorView::~FbEditorView() +{ +// delete mTextEdit; +// delete mToTextAction; +// delete mToHexAction; +// delete mExitAction; +} + +void FbEditorView::open(const QString& fileName, bool flagReadOnly) +{ + mFlagReadOnly = flagReadOnly; + + if (!fileName.isEmpty()) { + mTextEdit->setReadOnly(mFlagReadOnly); + loadFile(fileName); + } + else { + // not valid file name + } +} + +void FbEditorView::loadFile(const QString &fileName) +{ + mFileName = fileName; + QFile file(fileName); + QFileInfo baseName(fileName); + setTitle(baseName.fileName()); + + if (!file.open(QFile::ReadOnly | QFile::Text)) { + // note: cannot be opened. readonly or not text + return; + } + QTextStream in(&file); + in.setAutoDetectUnicode(false); + + mFileContent = in.readAll(); + file.close(); + displayInText(); +} + +void FbEditorView::displayInText() +{ + mFileHex = false; + QByteArray asciiContent = mFileContent.toAscii(); + mTextEdit->setPlainText(QString(asciiContent)); +} + +void FbEditorView::displayInHex() +{ + QByteArray asciiContent = mFileContent.toAscii().toHex(); + QString textInHex = QString(asciiContent); + mTextEdit->setPlainText(textInHex); + mFileHex = true; +} + +void FbEditorView::createMenu() +{ + mToTextAction = menu()->addAction("View as text"); + connect(mToTextAction, SIGNAL(triggered()), this, SLOT(displayInText())); + mToHexAction = menu()->addAction("View as hex"); + connect(mToHexAction, SIGNAL(triggered()), this, SLOT(displayInHex())); +// mExitAction = menu()->addAction("Exit"); +// connect(mExitAction, SIGNAL(triggered()), this, SLOT(backButtonClicked())); + + // update the menus before showing it: + connect(menu(), SIGNAL(aboutToShow()), this, SLOT(updateMenu())); +} + +void FbEditorView::updateMenu() +{ + mToTextAction->setVisible(mFileHex); + mToHexAction->setVisible(!mFileHex); +} + +void FbEditorView::backButtonClicked() +{ + emit finished(false); +} + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/ui/src/fbfileentry.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/ui/src/fbfileentry.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,215 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "fbfileentry.h" + +#include + +// --------------------------------------------------------------------------- + +FbFileEntry::FbFileEntry(TFileEntry &aFileEntry) +: mFileEntry(aFileEntry) +{ +} + +// --------------------------------------------------------------------------- + +FbFileEntry::~FbFileEntry() +{ +} + +// --------------------------------------------------------------------------- + +QString FbFileEntry::fullName() +{ + return QString::fromUtf16(mFileEntry.iFullName.Ptr(), mFileEntry.iFullName.Length()); +} + +// --------------------------------------------------------------------------- + +QString FbFileEntry::path() +{ + return QString::fromUtf16(mFileEntry.iPath.Ptr(), mFileEntry.iPath.Length()); +} + +// --------------------------------------------------------------------------- + +int FbFileEntry::attributes() +{ + return mFileEntry.iEntry.iAtt; +} + +QString FbFileEntry::attributesString() +{ + QString attributesString; + if (mFileEntry.iEntry.IsArchive()) { + attributesString.append(archiveTextShort()); + } else { + attributesString.append(noAttributeTextShort()); + } + if (mFileEntry.iEntry.IsHidden()) { + attributesString.append(hiddenTextShort()); + } else { + attributesString.append(noAttributeTextShort()); + } + if (mFileEntry.iEntry.IsReadOnly()) { + attributesString.append(readOnlyTextShort()); + } else { + attributesString.append(noAttributeTextShort()); + } + if (mFileEntry.iEntry.IsSystem()) { + attributesString.append(systemTextShort()); + } else { + attributesString.append(noAttributeTextShort()); + } + + return attributesString; +} + +// --------------------------------------------------------------------------- + +int FbFileEntry::size() +{ + return mFileEntry.iEntry.iSize; +} + +// --------------------------------------------------------------------------- + +QString FbFileEntry::sizeString() +{ + QString sizeString; + if (size() < 1024) { + sizeString.append(QString::number(size())); + sizeString.append(" B"); + } else if (size() < 1024*1024) { + qreal sizeKB = static_cast(size() / 1024); + sizeString.append( QString::number(sizeKB, 'f',1)); + sizeString.append(" kB"); + } else { + qreal sizeMB = static_cast(size() / (1024*1024)); + sizeString.append( QString::number(sizeMB, 'f',1)); + sizeString.append(" MB"); + } + return sizeString; +} + +// --------------------------------------------------------------------------- + +//QDateTime FbFileEntry::modified() +//{ +// QDateTime modified; +// TTime time1Jan1970UTC = TTime(_L("19700101:000000.000000")); +// TTimeIntervalSeconds intervalSeconds; +// +// TTime entryModified = mFileEntry.iEntry.iModified; +// +// TInt err = /*mFileEntry.iEntry.iModified*/ entryModified.SecondsFrom(time1Jan1970UTC, intervalSeconds); +// if (err == KErrNone) { +// quint32 secsSince1Jan1970UTC = intervalSeconds.Int(); +// modified = QDateTime::fromTime_t(secsSince1Jan1970UTC); +// qDebug() << "QDateTime:: " << modified.toString(); +// modified.setTimeSpec(Qt::LocalTime); +// qDebug() << "QDateTime:: " << modified.toString() << modified.toLocalTime().toString(); +// } +// return modified; +//} + +// --------------------------------------------------------------------------- + +QString FbFileEntry::modifiedDateTimeString(const QString aDateTimeFormat) +{ + // TODO use HbExtendedLocale to convert date and time +// QDateTime modifiedInLocalTime = modified();//.toLocalTime(); +// HbExtendedLocale locale = HbExtendedLocale::system(); +// QString date = locale.format(modifiedInLocalTime.date(), r_qtn_date_usual); +// QString time = locale.format(modifiedInLocalTime.time(), r_qtn_time_usual); +// +// return date + " " + time; + QString modifiedString; + TTime entryModified = mFileEntry.iEntry.iModified; + RTz Tz; + TInt err = Tz.Connect(); + if ( err == KErrNone && Tz.ConvertToLocalTime( entryModified ) == KErrNone ) + { + entryModified = mFileEntry.iEntry.iModified; + } + TBuf<128> extraData; + const TFileName dateTimeFormat = TFileName(aDateTimeFormat.utf16()); + entryModified.FormatL(extraData, dateTimeFormat); + modifiedString = QString::fromUtf16(extraData.Ptr(), extraData.Length()); + Tz.Close(); + + return modifiedString; +} + +QString FbFileEntry::modifiedString() +{ + const QString KCurrentDate("%D%M%*Y%/0%1%/1%2%/2%3%/3 %-B%:0%J%:1%T%:2%S%:3%+B"); + return modifiedDateTimeString(KCurrentDate); +} + +// --------------------------------------------------------------------------- + +//int FbFileEntry::Uid(int id) +//{ +// return id;//mFileEntry.iEntry.iType[id]; +//} + +// --------------------------------------------------------------------------- + +bool FbFileEntry::isDir() +{ + return mFileEntry.iEntry.IsDir(); +} + +// --------------------------------------------------------------------------- + + +QString FbFileEntry::name() +{ + return QString::fromUtf16(mFileEntry.iEntry.iName.Ptr(), mFileEntry.iEntry.iName.Length()); +} + +// --------------------------------------------------------------------------- + +int FbFileEntry::dirEntries() +{ + return mFileEntry.iDirEntries; +} + +// --------------------------------------------------------------------------- + +QString FbFileEntry::dirEntriesString() +{ + QString dirEntriesString; + dirEntriesString.append(QString::number(dirEntries())); + if (dirEntries() == 1) { + dirEntriesString.append(" entry"); + } else { + dirEntriesString.append(" entries"); + } + return dirEntriesString; +} + +// --------------------------------------------------------------------------- + +int FbFileEntry::iconId() +{ + return mFileEntry.iIconId; +} + +// --------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/ui/src/fbfilelistviewitem.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/ui/src/fbfilelistviewitem.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,160 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "fbfilelistviewitem.h" + +#include +#include +#include +#include +#include + +#include +#include +#include + +FbFileListViewItem::FbFileListViewItem(QGraphicsItem *parent) : + HbListViewItem(parent), + hLayout(0), + mDiskNameLabel(0), + mSizeLabel(0), + mFreeLabel(0), + mIconLabel(0) +{ +} + +FbFileListViewItem::~FbFileListViewItem() +{ +} + +void FbFileListViewItem::polish(HbStyleParameters ¶ms) +{ + Q_UNUSED(params); +} + +bool FbFileListViewItem::canSetModelIndex(const QModelIndex &index) const +{ + Q_UNUSED(index); + return true; +} + + +HbAbstractViewItem *FbFileListViewItem::createItem() +{ + return new FbFileListViewItem(*this); +} + +void FbFileListViewItem::updateChildItems() +{ + if(!hLayout) { + init(); + } + + // Qt::DisplayRole + QVariant displayRole = modelIndex().data(Qt::DisplayRole); + QString diskName("default"); + QStringList stringList; + if (displayRole.isValid()) { + if (displayRole.canConvert()) { // EFileViewModeSimple + stringList.append(displayRole.toString()); + } else if (displayRole.canConvert()) { // EFileViewModeExtended + stringList = displayRole.toStringList(); + } + if (stringList.count() > 0) + diskName = stringList[0]; //modelIndex().data( Qt::UserRole ).toString(); + + mDiskNameLabel->setPlainText(diskName/*displayString*/); + } + +// mSizeLabel->setPlainText( hbTrId ( "Size: " ) /*+ FmUtils::formatStorageSize( driverInfo.size() )*/ ); +// mFreeLabel->setPlainText( hbTrId ( "Free: " ) /*+ FmUtils::formatStorageSize( driverInfo.freeSize() )*/ ); + if (stringList.count() > 1) + mSizeLabel->setPlainText( stringList[1] ); + + //mStorageSizeDiagram->setFreeSizePercentage(); + //mFreeLabel->setPlainText( stringList[2] ); + + // mCheckBox->setCheckState( checkState() ); + + // Qt::DecorationRole + QVariant decorationRole = modelIndex().data(Qt::DecorationRole); + if (decorationRole.isValid()) { + QIcon icon = qvariant_cast(decorationRole); +// if( icon.isNull() ) { +// QFileIconProvider fileIconProvider; +// icon = fileIconProvider.icon(QFileIconProvider::Drive); +// } + mIconLabel->setIcon(HbIcon(icon)); + } +} + +void FbFileListViewItem::setCheckedState(int state) +{ + HbAbstractViewItem::setCheckState(static_cast(state)); +} + +void FbFileListViewItem::init() +{ + hLayout = new QGraphicsLinearLayout(); + + hLayout->setOrientation( Qt::Horizontal ); + hLayout->addItem(layout()); + + mIconLabel = new HbLabel(); + hLayout->addItem( mIconLabel ); + hLayout->setAlignment( mIconLabel, Qt::AlignTop ); + hLayout->setStretchFactor( mIconLabel, 0 ); + +// mStorageSizeDiagram = new FbDriveStorageSizeDiagram(this); +// hLayout->addItem( mStorageSizeDiagram ); +// hLayout->setAlignment( mIconLabel, Qt::AlignTop ); +// hLayout->setStretchFactor( mStorageSizeDiagram, 0 ); + + QGraphicsLinearLayout *vLayout = new QGraphicsLinearLayout(); + vLayout->setOrientation( Qt::Vertical ); + + mDiskNameLabel = new HbLabel(); + //HbFontSpec fontSpecPrimary(HbFontSpec::Primary); + //fontSpecPrimary.setTextHeight(18.0); + //mDiskNameLabel->setFontSpec( fontSpecPrimary ); + vLayout->addItem( mDiskNameLabel ); + vLayout->setAlignment( mDiskNameLabel, Qt::AlignLeft ); + + mSizeLabel = new HbLabel(); + //HbFontSpec fontSpecSecondary(HbFontSpec::Secondary); + //fontSpecSecondary.setTextHeight(18.0); + //mSizeLabel->setFontSpec(fontSpecSecondary); + vLayout->addItem( mSizeLabel ); + vLayout->setAlignment(mSizeLabel, Qt::AlignLeft); + +// mFreeLabel = new HbLabel(); +// mFreeLabel->setFontSpec( HbFontSpec( HbFontSpec::Secondary ) ); +// vLayout->addItem( mFreeLabel ); +// vLayout->setAlignment( mFreeLabel, Qt::AlignLeft ); + + HbWidget *labelsWidget = new HbWidget(); + labelsWidget->setLayout(vLayout); + + hLayout->setAlignment( labelsWidget, Qt::AlignLeft ); + + hLayout->addItem( labelsWidget ); + hLayout->setStretchFactor( labelsWidget, 1 ); + +// this->setMaximumHeight(80); + + setLayout( hLayout ); +} diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/ui/src/fbfilemodel.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/ui/src/fbfilemodel.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,140 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "fbfilemodel.h" +#include "enginewrapper.h" +#include "fbfileentry.h" +#include "filebrowsersettings.h" +#include "FB.hrh" + +#include +#include + +/** + Constructs a file browser custom system model with the given \a engineWrapper and \a parent. + */ +FbFileModel::FbFileModel(EngineWrapper *engineWrapper, QObject *parent) : + QAbstractListModel(parent), + mEngineWrapper(engineWrapper), + mFileIconProvider(0) +{ + mFileIconProvider = new QFileIconProvider(); +} + +/** + Destroys this file browser custom system model. + */ +FbFileModel::~FbFileModel() +{ + if (mFileIconProvider) { + delete mFileIconProvider; + } +} + +/** + \reimp + */ +int FbFileModel::rowCount(const QModelIndex &parent) const +{ + Q_UNUSED(parent); + return mEngineWrapper->itemCount(); +} + +/** + \reimp + */ +QVariant FbFileModel::data(const QModelIndex &index, int role) const +{ + if (!index.isValid() || index.model() != this) + return QVariant(); + + switch (role) { + case Qt::EditRole: + case Qt::DisplayRole: { + QStringList listItem; + FbFileEntry fileEntry(mEngineWrapper->getFileEntry(index)); + if (mEngineWrapper->settings().fileViewMode() == EFileViewModeSimple) + { + listItem /*<< fileEntry.IconId()*/ + << fileEntry.name(); + } else if (mEngineWrapper->settings().fileViewMode() == EFileViewModeExtended) { + QString extraData; + extraData.append(fileEntry.modifiedString()); + if (fileEntry.isDir() && fileEntry.dirEntries() >= 0) { + extraData.append(" - "); + extraData.append(fileEntry.dirEntriesString()); + } else if (!fileEntry.isDir()) { + extraData.append(" - "); + extraData.append(fileEntry.sizeString()); + } + listItem /*<< fileEntry.IconId()*/ + << fileEntry.name() << extraData << fileEntry.attributesString(); + } + return listItem; + } + case Qt::DecorationRole: { + if (mEngineWrapper) { + QIcon icon; + FbFileEntry fileEntry(mEngineWrapper->getFileEntry(index)); + if (fileEntry.isDir()) { + icon = mFileIconProvider->icon(QFileIconProvider::Folder); + } else { + icon = mFileIconProvider->icon(QFileIconProvider::File); + } +// } + return QVariant(icon); + } + } + } + + return QVariant(); +} + +/** + * Move down to directory selected by index \a index + */ +void FbFileModel::moveDownToDirectory(const QModelIndex &index) +{ + beginResetModel(); + mEngineWrapper->moveDownToDirectory(index); + endResetModel(); +} + +/** + * Move to directory one level up + */ +void FbFileModel::moveUpOneLevel() +{ + beginResetModel(); + mEngineWrapper->moveUpOneLevel(); + endResetModel(); +} + +/** + \reimp + */ +QVariant FbFileModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + Q_UNUSED(section) + Q_UNUSED(orientation) + Q_UNUSED(role) + + // TODO, implement or remove + return QVariant(); +} + +// --------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/ui/src/fbfileview.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/ui/src/fbfileview.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,1759 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "fbfileview.h" +#include "fbsettingsview.h" +#include "fbeditorview.h" +#include "fbsearchview.h" +#include "enginewrapper.h" +#include "notifications.h" +#include "fbfolderselectiondialog.h" +#include "fbfilemodel.h" +#include "filebrowsersortfilterproxymodel.h" +//#include "fbfilelistviewitem.h" +#include "fbpropertiesdialog.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +//TODO check if needed to do this way +#include + +// --------------------------------------------------------------------------- + +FbFileView::FbFileView() : + mEngineWrapper(0), + mListView(0), + mToolBar(0), + mNaviPane(0), + mSearchPanel(0), + mMainLayout(0), + mFbFileModel(0), + mSortFilterProxyModel(0), + mOptionMenuActions(), + mContextMenuActions(), + mContextMenu(0), + mToolbarBackAction(0), + mToolbarFilterAction(0), + mToolbarSelectionModeAction(0), + mToolbarPasteAction(0), + mSelectionModeOnIcon(), + mSelectionModeOffIcon(), + mItemHighlighted(false), + mLocationChanged(false), + mRemoveFileAfterCopied(false), +// mClipBoardInUse(false), + mCurrentIndex(), + mOldPassword(), + mPanicCategory(), + mAbsoluteFilePath(), + mOverwriteOptions(), + mTargetDir(), + mModelIndex(), + mNewFileName(), + mProceed(false), + mEraseMBR(false) +{ + setTitle("File Browser"); + + createMenu(); + createContextMenu(); + createSearchPanel(); + createToolBar(); +} + +// --------------------------------------------------------------------------- + +void FbFileView::init(EngineWrapper *engineWrapper) +{ + mEngineWrapper = engineWrapper; + + mListView = new HbListView(this); + mListView->listItemPrototype()->setStretchingStyle(HbListViewItem::StretchLandscape); + +// mListView->setItemPrototype(new FbDiskListViewItem(mListView)); + + mFbFileModel = new FbFileModel(mEngineWrapper); + if (!mListView->model()) { + mEngineWrapper->refreshView(); + mListView->setModel(mFbFileModel); + } + mListView->setRootIndex(QModelIndex()); + + //setItemVisible(Hb::ToolBarItem, !mEngineWrapper->isDriveListViewActive()); +// mListView->setScrollingStyle(HbScrollArea::PanWithFollowOn); + + connect(mListView, SIGNAL(activated(QModelIndex)), this, SLOT(activated(QModelIndex))); + connect(mListView, SIGNAL(longPressed(HbAbstractViewItem*,QPointF)), + this, SLOT(onLongPressed(HbAbstractViewItem*, QPointF))); + connect(mEngineWrapper, SIGNAL(fileSystemDataChanged()), this, SLOT(refreshList())); + + mNaviPane = new HbLabel(this); + mNaviPane->setPlainText(QString(" ")); // TODO get from settings or default + //mNaviPane->setPlainText(QString(mEngineWrapper->currentPath())); + HbFontSpec fontSpec(HbFontSpec::PrimarySmall); + mNaviPane->setFontSpec(fontSpec); + + // Create layout and add list view and toolbar into layout: + mMainLayout = new QGraphicsLinearLayout(Qt::Vertical); + mMainLayout->addItem(mNaviPane); + mMainLayout->addItem(mListView); + setLayout(mMainLayout); +} + +// --------------------------------------------------------------------------- + +FbFileView::~FbFileView() +{ + if (mContextMenu) { + mContextMenu->deleteLater(); + } + if (mSortFilterProxyModel) { + delete mSortFilterProxyModel; + } + delete mFbFileModel; + delete mListView; + delete mToolBar; +} + +/** + Initial setup for options menu. + Dynamic menu update during the runtime is performed by updateOptionMenu() which + to menu's aboutToShow() signal. + */ +void FbFileView::createMenu() +{ + createFileMenu(); + createEditMenu(); + createViewMenu(); + createToolsMenu(); + + createSelectionMenuItem(); + createSettingsMenuItem(); + createAboutMenuItem(); + createExitMenuItem(); + + // menu dynamic update + connect(menu(), SIGNAL(aboutToShow()), this, SLOT(updateOptionMenu())); +} + +/** + Initial setup for File submenu + */ +void FbFileView::createFileMenu() +{ + mOptionMenuActions.mFileMenu = menu()->addMenu("File"); + + mOptionMenuActions.mFileBackMoveUp = mOptionMenuActions.mFileMenu->addAction("Back/Move up", this, SLOT(fileBackMoveUp())); + mOptionMenuActions.mFileSearch = mOptionMenuActions.mFileMenu->addAction("Search...", this, SLOT(fileSearch())); + + mOptionMenuActions.mFileNewMenu = mOptionMenuActions.mFileMenu->addMenu("New"); + mOptionMenuActions.mFileNewFile = mOptionMenuActions.mFileNewMenu->addAction("File", this, SLOT(fileNewFile())); + mOptionMenuActions.mFileNewDirectory = mOptionMenuActions.mFileNewMenu->addAction("Directory", this, SLOT(fileNewDirectory())); + + mOptionMenuActions.mFileDelete = mOptionMenuActions.mFileMenu->addAction("Delete", this, SLOT(fileDelete())); + mOptionMenuActions.mFileRename = mOptionMenuActions.mFileMenu->addAction("Rename", this, SLOT(fileRename())); + mOptionMenuActions.mFileTouch = mOptionMenuActions.mFileMenu->addAction("Touch", this, SLOT(fileTouch())); + + mOptionMenuActions.mFileSetAttributes = mOptionMenuActions.mFileMenu->addAction("Set attributes...", this, SLOT(fileSetAttributes())); +} + +/** + Initial setup for Edit submenu + */ +void FbFileView::createEditMenu() +{ + mOptionMenuActions.mEditMenu = menu()->addMenu("Edit"); + + mOptionMenuActions.mEditSnapShotToE = mOptionMenuActions.mEditMenu->addAction("Snap shot to E:", this, SLOT(editSnapShotToE())); + mOptionMenuActions.mEditSnapShotToE->setVisible(false); + mOptionMenuActions.mEditCut = mOptionMenuActions.mEditMenu->addAction("Cut", this, SLOT(editCut())); + mOptionMenuActions.mEditCopy = mOptionMenuActions.mEditMenu->addAction("Copy", this, SLOT(editCopy())); + mOptionMenuActions.mEditPaste = mOptionMenuActions.mEditMenu->addAction("Paste", this, SLOT(editPaste())); + + mOptionMenuActions.mEditCopyToFolder = mOptionMenuActions.mEditMenu->addAction("Copy to folder...", this, SLOT(editCopyToFolder())); + mOptionMenuActions.mEditMoveToFolder = mOptionMenuActions.mEditMenu->addAction("Move to folder...", this, SLOT(editMoveToFolder())); + + mOptionMenuActions.mEditSelect = mOptionMenuActions.mEditMenu->addAction("Select", this, SLOT(editSelect())); + mOptionMenuActions.mEditUnselect = mOptionMenuActions.mEditMenu->addAction("Unselect", this, SLOT(editUnselect())); + mOptionMenuActions.mEditSelectAll = mOptionMenuActions.mEditMenu->addAction("Select all", this, SLOT(editSelectAll())); + mOptionMenuActions.mEditUnselectAll = mOptionMenuActions.mEditMenu->addAction("Unselect all", this, SLOT(editUnselectAll())); +} + +/** + Initial setup for View submenu + */ +void FbFileView::createViewMenu() +{ + mOptionMenuActions.mViewMenu = menu()->addMenu("View"); + //mOptionMenuActions.mViewMenu->menuAction()->setVisible(false); + + mOptionMenuActions.mViewFilterEntries = mOptionMenuActions.mViewMenu->addAction("Filter entries", this, SLOT(viewFilterEntries())); + mOptionMenuActions.mViewRefresh = mOptionMenuActions.mViewMenu->addAction("Refresh", this, SLOT(viewRefresh())); +} + +/** + Initial setup for Tools submenu + */ +void FbFileView::createToolsMenu() +{ + mOptionMenuActions.mToolsMenu = menu()->addMenu("Tools"); + + mOptionMenuActions.mToolsAllAppsToTextFile = mOptionMenuActions.mToolsMenu->addAction("All apps to a text file", this, SLOT(toolsAllAppsToTextFile())); + mOptionMenuActions.mToolsAllAppsToTextFile->setVisible(false); + mOptionMenuActions.mToolsAllFilesToTextFile = mOptionMenuActions.mToolsMenu->addAction("All files to a text file", this, SLOT(toolsAllFilesToTextFile())); + //mOptionMenuActions.mToolsAllFilesToTextFile->setVisible(false); + +// mOptionMenuActions.mToolsAvkonIconCacheMenu = mOptionMenuActions.mToolsMenu->addMenu("Avkon icon cache"); +// mOptionMenuActions.mToolsAvkonIconCacheMenu->menuAction()->setVisible(false); +// mOptionMenuActions.mToolsAvkonIconCacheEnable = mOptionMenuActions.mToolsAvkonIconCacheMenu->addAction("Enable", this, SLOT(toolsAvkonIconCacheEnable())); +// mOptionMenuActions.mToolsAvkonIconCacheDisable = mOptionMenuActions.mToolsAvkonIconCacheMenu->addAction("Clear and disable", this, SLOT(toolsAvkonIconCacheDisable())); + + mOptionMenuActions.mToolsDisableExtendedErrors = mOptionMenuActions.mToolsMenu->addAction("Disable extended errors", this, SLOT(toolsDisableExtendedErrors())); + mOptionMenuActions.mToolsDumpMsgStoreWalk = mOptionMenuActions.mToolsMenu->addAction("Dump msg. store walk", this, SLOT(toolsDumpMsgStoreWalk())); + mOptionMenuActions.mToolsDumpMsgStoreWalk->setVisible(false); + mOptionMenuActions.mToolsEditDataTypes = mOptionMenuActions.mToolsMenu->addAction("Edit data types", this, SLOT(toolsEditDataTypes())); + mOptionMenuActions.mToolsEditDataTypes->setVisible(false); + mOptionMenuActions.mToolsEnableExtendedErrors = mOptionMenuActions.mToolsMenu->addAction("Enable extended errors", this, SLOT(toolsEnableExtendedErrors())); + + mOptionMenuActions.mToolsErrorSimulateMenu = mOptionMenuActions.mToolsMenu->addMenu("Error simulate"); + mOptionMenuActions.mToolsErrorSimulateLeave = mOptionMenuActions.mToolsErrorSimulateMenu->addAction("Leave", this, SLOT(toolsErrorSimulateLeave())); + mOptionMenuActions.mToolsErrorSimulatePanic = mOptionMenuActions.mToolsErrorSimulateMenu->addAction("Panic", this, SLOT(toolsErrorSimulatePanic())); + mOptionMenuActions.mToolsErrorSimulatePanic->setVisible(false); + mOptionMenuActions.mToolsErrorSimulateException = mOptionMenuActions.mToolsErrorSimulateMenu->addAction("Exception", this, SLOT(toolsErrorSimulateException())); + +// mOptionMenuActions.mLocalConnectivityMenu = mOptionMenuActions.mToolsMenu->addMenu("Local connectivity"); +// mOptionMenuActions.mToolsLocalConnectivityActivateInfrared = mOptionMenuActions.mLocalConnectivityMenu->addAction("Activate infrared", this, SLOT(toolsLocalConnectivityActivateInfrared())); +// mOptionMenuActions.mToolsLocalConnectivityLaunchBTUI = mOptionMenuActions.mLocalConnectivityMenu->addAction("Launch BT UI", this, SLOT(toolsLocalConnectivityLaunchBTUI())); +// mOptionMenuActions.mToolsLocalConnectivityLaunchUSBUI = mOptionMenuActions.mLocalConnectivityMenu->addAction("Launch USB UI", this, SLOT(toolsLocalConnectivityLaunchUSBUI())); + + mOptionMenuActions.mToolsMessageAttachmentsMenu = mOptionMenuActions.mToolsMenu->addMenu("Message attachments"); + mOptionMenuActions.mToolsMessageAttachmentsMenu->menuAction()->setVisible(false); + mOptionMenuActions.mToolsMessageInbox = mOptionMenuActions.mToolsMessageAttachmentsMenu->addAction("Inbox", this, SLOT(toolsMessageInbox())); + mOptionMenuActions.mToolsMessageDrafts = mOptionMenuActions.mToolsMessageAttachmentsMenu->addAction("Drafts", this, SLOT(toolsMessageDrafts())); + mOptionMenuActions.mToolsMessageSentItems = mOptionMenuActions.mToolsMessageAttachmentsMenu->addAction("Sent items", this, SLOT(toolsMessageSentItems())); + mOptionMenuActions.mToolsMessageOutbox = mOptionMenuActions.mToolsMessageAttachmentsMenu->addAction("Outbox", this, SLOT(toolsMessageOutbox())); + + mOptionMenuActions.mToolsMemoryInfo = mOptionMenuActions.mToolsMenu->addAction("Memory info", this, SLOT(toolsMemoryInfo())); + mOptionMenuActions.mToolsMemoryInfo->setVisible(false); + + mOptionMenuActions.mToolsSecureBackupMenu = mOptionMenuActions.mToolsMenu->addMenu("Secure backup"); + mOptionMenuActions.mToolsSecureBackupMenu->menuAction()->setVisible(false); + mOptionMenuActions.mToolsSecureBackStart = mOptionMenuActions.mToolsSecureBackupMenu->addAction("Start backup", this, SLOT(toolsSecureBackStart())); + mOptionMenuActions.mToolsSecureBackRestore = mOptionMenuActions.mToolsSecureBackupMenu->addAction("Start restore", this, SLOT(toolsSecureBackRestore())); + mOptionMenuActions.mToolsSecureBackStop = mOptionMenuActions.mToolsSecureBackupMenu->addAction("Stop", this, SLOT(toolsSecureBackStop())); + + mOptionMenuActions.mToolsSetDebugMask = mOptionMenuActions.mToolsMenu->addAction("Set debug mask", this, SLOT(toolsSetDebugMaskQuestion())); + mOptionMenuActions.mToolsShowOpenFilesHere = mOptionMenuActions.mToolsMenu->addAction("Show open files here", this, SLOT(toolsShowOpenFilesHere())); + mOptionMenuActions.mToolsShowOpenFilesHere->setVisible(false); +} + +/** + Creates Selection mode menu item in option menu + */ +void FbFileView::createSelectionMenuItem() +{ + if (!mOptionMenuActions.mSelection) { + mOptionMenuActions.mSelection = menu()->addAction("Selection mode"); + mOptionMenuActions.mSelection->setToolTip("Selection mode"); + mOptionMenuActions.mSelection->setCheckable(true); + connect(mOptionMenuActions.mSelection, SIGNAL(triggered()), this, SLOT(selectionModeChanged())); + } +} + +/** + Creates Setting menu item in option menu + */ +void FbFileView::createSettingsMenuItem() +{ + mOptionMenuActions.mSetting = menu()->addAction("Settings..."); + connect(mOptionMenuActions.mSetting, SIGNAL(triggered()), this, SIGNAL(aboutToShowSettingsView())); +} + + +/** + Creates About menu item in option menu + */ +void FbFileView::createAboutMenuItem() +{ + // about note + mOptionMenuActions.mAbout = menu()->addAction("About"); + connect(mOptionMenuActions.mAbout, SIGNAL(triggered()), this, SLOT(about())); +} + +/** + Creates Exit menu item in option menu + */ +void FbFileView::createExitMenuItem() +{ + // application exit + mOptionMenuActions.mExit = menu()->addAction("Exit"); + connect(mOptionMenuActions.mExit, SIGNAL(triggered()), qApp, SLOT(quit())); +} + +/** + update menu: disk admin available only in device root view. edit available only in folder view + when file or folder content exist in current folder, or clipboard has copied item. + file and view menus updated every time regarding the folder content. + tools, settings, about, exit always available. + If there's remove and add operations at same time, always remove first + to keep to the correct menu items order. + */ +void FbFileView::updateOptionMenu() +{ + bool isFileItemListEmpty = mFbFileModel->rowCount() == 0; + bool isNormalModeActive = true; //iModel->FileUtils()->IsNormalModeActive(); + bool isCurrentDriveReadOnly = mEngineWrapper->isCurrentDriveReadOnly(); //iModel->FileUtils()->IsCurrentDriveReadOnly(); + // bool isCurrentItemDirectory = mEngineWrapper->getFileEntry(currentItemIndex()).isDir(); + // bool currentSelected = true; //iContainer->ListBox()->View()->ItemIsSelected(iContainer->ListBox()->View()->CurrentItemIndex()); + bool isAllSelected = mListView->selectionModel()->selection().count() == mFbFileModel->rowCount(); + //bool isNoneSelected = mListView->selectionModel()->selection().count() != 0; + bool hasSelectedItems = mListView->selectionModel()->selection().count() != 0; + bool isSelectionMode = mOptionMenuActions.mSelection && mOptionMenuActions.mSelection->isChecked(); + bool isClipBoardEmpty = !mEngineWrapper->isClipBoardListInUse(); + //bool showSnapShot = false; //iModel->FileUtils()->DriveSnapShotPossible(); + + bool showEditMenu(true); + if (isFileItemListEmpty && isClipBoardEmpty) + showEditMenu = false; + else + showEditMenu = true; + + mOptionMenuActions.mEditMenu->menuAction()->setVisible(showEditMenu); + + //mOptionMenuActions.mFileBackMoveUp->setVisible( !isDriveListViewActive); + + //aMenuPane->SetItemDimmed(EFileBrowserCmdFileView, isFileItemListEmpty || !hasSelectedItems || isCurrentItemDirectory); + //aMenuPane->SetItemDimmed(EFileBrowserCmdFileEdit, isFileItemListEmpty || !hasSelectedItems || isCurrentItemDirectory); + //aMenuPane->SetItemDimmed(EFileBrowserCmdFileSendTo, isFileItemListEmpty || driveListActive || isCurrentItemDirectory); + + mOptionMenuActions.mFileNewMenu->menuAction()->setVisible(!isCurrentDriveReadOnly); + mOptionMenuActions.mFileDelete->setVisible(!isFileItemListEmpty && !isCurrentDriveReadOnly && hasSelectedItems/*isSelectionMode*/); + mOptionMenuActions.mFileRename->setVisible(!isFileItemListEmpty && !isCurrentDriveReadOnly && hasSelectedItems /*&& !isSelectionMode*/); + mOptionMenuActions.mFileTouch->setVisible(!isFileItemListEmpty && !isCurrentDriveReadOnly && hasSelectedItems); + + mOptionMenuActions.mFileSetAttributes->setVisible(!isFileItemListEmpty && !isCurrentDriveReadOnly && hasSelectedItems); + // TODO mOptionMenuActions.mFileCompress->setVisible(!(isCurrentDriveReadOnly || isFileItemListEmpty || !hasSelectedItems || isCurrentItemDirectory)); + // TODO mOptionMenuActions.mFileDecompress->setVisible(!(isCurrentDriveReadOnly || isFileItemListEmpty || !hasSelectedItems || isCurrentItemDirectory)); + + mOptionMenuActions.mEditMenu->menuAction()->setVisible( (!isSelectionMode && !isClipBoardEmpty && !isCurrentDriveReadOnly) + || (isSelectionMode)); + mOptionMenuActions.mEditCut->setVisible(!isFileItemListEmpty && !isCurrentDriveReadOnly && isSelectionMode && hasSelectedItems); + mOptionMenuActions.mEditCopy->setVisible(!isFileItemListEmpty && isSelectionMode && hasSelectedItems); + mOptionMenuActions.mEditPaste->setVisible(!isClipBoardEmpty && !isCurrentDriveReadOnly); + mOptionMenuActions.mEditCopyToFolder->setVisible(!isFileItemListEmpty && isSelectionMode && hasSelectedItems); + mOptionMenuActions.mEditMoveToFolder->setVisible(!isFileItemListEmpty && !isCurrentDriveReadOnly && isSelectionMode && hasSelectedItems); + + mOptionMenuActions.mEditSelect->setVisible(false/*!currentSelected && !isFileItemListEmpty*/); + mOptionMenuActions.mEditUnselect->setVisible(false/*currentSelected && !isFileItemListEmpty*/); + mOptionMenuActions.mEditSelectAll->setVisible(!isFileItemListEmpty && isSelectionMode && !isAllSelected); + mOptionMenuActions.mEditUnselectAll->setVisible(!isFileItemListEmpty && hasSelectedItems); + + // TODO mOptionMenuActions.mViewSort->setVisible(!(!isNormalModeActive || isFileItemListEmpty)); + // TODO mOptionMenuActions.mViewOrder->setVisible(!(!isNormalModeActive || isFileItemListEmpty)); + mOptionMenuActions.mViewRefresh->setVisible(isNormalModeActive); + mOptionMenuActions.mViewFilterEntries->setVisible(!isFileItemListEmpty); + + // TODO R_FILEBROWSER_VIEW_SORT_SUBMENU + // aMenuPane->SetItemButtonState(iModel->FileUtils()->SortMode(), EEikMenuItemSymbolOn); + + // TODO R_FILEBROWSER_VIEW_ORDER_SUBMENU + // aMenuPane->SetItemButtonState(iModel->FileUtils()->OrderMode(), EEikMenuItemSymbolOn); + + // aResourceId == R_FILEBROWSER_TOOLS_SUBMENU + bool noExtendedErrorsAllowed = mEngineWrapper->ErrRdFileExists(); + mOptionMenuActions.mToolsDisableExtendedErrors->setVisible(noExtendedErrorsAllowed); + mOptionMenuActions.mToolsEnableExtendedErrors->setVisible(!noExtendedErrorsAllowed); + +// bool infraRedAllowed = mEngineWrapper->FileExists(KIRAppPath); +// bool bluetoothAllowed = mEngineWrapper->FileExists(KBTAppPath); +// bool usbAllowed = mEngineWrapper->FileExists(KUSBAppPath); +// +// bool noLocalCon = !infraRedAllowed && !bluetoothAllowed && !usbAllowed; +// mOptionMenuActions.mToolsLocalConnectivityMenu->menuAction()->setVisible(!noLocalCon); +// +// mOptionMenuActions.mToolsLocalConnectivityActivateInfrared->setVisible(infraRedAllowed); +// mOptionMenuActions.mToolsLocalConnectivityLaunchBTUI->setVisible(bluetoothAllowed); +// mOptionMenuActions.mToolsLocalConnectivityLaunchUSBUI->setVisible(usbAllowed); +} + +void FbFileView::createContextMenu() +{ + mContextMenu = new HbMenu(); + connect(mContextMenu, SIGNAL(aboutToShow()), this, SLOT(updateContextMenu())); + + createFileContextMenu(); + createEditContextMenu(); + createViewContextMenu(); +} + + +void FbFileView::createFileContextMenu() +{ + mContextMenuActions.mFileMenu = mContextMenu->addMenu("File"); + + //mContextMenuActions.mFileBackMoveUp = mContextMenuActions.mFileMenu->addAction("Back/Move up (<-)", this, SLOT(fileBackMoveUp())); +// mContextMenuActions.mFileOpenDirectory = mContextMenuActions.mFileMenu->addAction("Open directory (->)", this, SLOT(fileOpenDirectory())); + mContextMenuActions.mFileOpenDirectory = mContextMenu->addAction("Open directory (->)", this, SLOT(fileOpenDirectory())); + mContextMenuActions.mSearch = mContextMenu->addAction("Search...", this, SLOT(fileSearch())); + mContextMenuActions.mFileSearch = mContextMenuActions.mFileMenu->addAction("Search...", this, SLOT(fileSearch())); + + mContextMenuActions.mFileDelete = mContextMenuActions.mFileMenu->addAction("Delete", this, SLOT(fileDelete())); + mContextMenuActions.mFileRename = mContextMenuActions.mFileMenu->addAction("Rename", this, SLOT(fileRename())); + mContextMenuActions.mFileTouch = mContextMenuActions.mFileMenu->addAction("Touch", this, SLOT(fileTouch())); + mContextMenuActions.mFileProperties = mContextMenuActions.mFileMenu->addAction("Properties", this, SLOT(fileProperties())); + + mContextMenuActions.mFileChecksumsMenu = mContextMenuActions.mFileMenu->addMenu("Checksums"); + mContextMenuActions.mFileChecksumsMD5 = mContextMenuActions.mFileChecksumsMenu->addAction("MD5", this, SLOT(fileChecksumsMD5())); + mContextMenuActions.mFileChecksumsMD2 = mContextMenuActions.mFileChecksumsMenu->addAction("MD2", this, SLOT(fileChecksumsMD2())); + mContextMenuActions.mFileChecksumsSHA1 = mContextMenuActions.mFileChecksumsMenu->addAction("SHA-1", this, SLOT(fileChecksumsSHA1())); + + mContextMenuActions.mFileSetAttributes = mContextMenuActions.mFileMenu->addAction("Set attributes...", this, SLOT(fileSetAttributes())); +} + +void FbFileView::createEditContextMenu() +{ + mContextMenuActions.mEditMenu = mContextMenu->addMenu("Edit"); + + //mContextMenuActions.mEditSnapShotToE = mContextMenuActions.mEditMenu->addAction("Snap shot to E:", this, SLOT(editSnapShotToE())); +// mContextMenuActions.mEditSnapShotToE->setVisible(false); + mContextMenuActions.mEditCut = mContextMenuActions.mEditMenu->addAction("Cut", this, SLOT(editCut())); + mContextMenuActions.mEditCopy = mContextMenuActions.mEditMenu->addAction("Copy", this, SLOT(editCopy())); + mContextMenuActions.mEditPaste = mContextMenuActions.mEditMenu->addAction("Paste", this, SLOT(editPaste())); + + mContextMenuActions.mEditCopyToFolder = mContextMenuActions.mEditMenu->addAction("Copy to folder...", this, SLOT(editCopyToFolder())); + mContextMenuActions.mEditMoveToFolder = mContextMenuActions.mEditMenu->addAction("Move to folder...", this, SLOT(editMoveToFolder())); +} + +void FbFileView::createViewContextMenu() +{ + +} + +void FbFileView::updateContextMenu() +{ + bool isFileItemListEmpty = mFbFileModel->rowCount() == 0; +// bool isNormalModeActive = true; //iModel->FileUtils()->IsNormalModeActive(); + bool isCurrentDriveReadOnly = mEngineWrapper->isCurrentDriveReadOnly(); + bool isCurrentItemDirectory = mEngineWrapper->getFileEntry(currentItemIndex()).isDir(); + bool hasSelectedItems = mListView->selectionModel()->selection().count() != 0; + bool isSelectionMode = mOptionMenuActions.mSelection && mOptionMenuActions.mSelection->isChecked(); + bool isClipBoardEmpty = !mEngineWrapper->isClipBoardListInUse(); + + mContextMenuActions.mFileOpenDirectory->setVisible(!isFileItemListEmpty && isCurrentItemDirectory && isSelectionMode); + mContextMenuActions.mSearch->setVisible(!isFileItemListEmpty && isSelectionMode && isCurrentItemDirectory); + mContextMenuActions.mFileSearch->setVisible(!isFileItemListEmpty && !isSelectionMode && isCurrentItemDirectory); + // File submenu + //mContextMenuActions.mFileBackMoveUp->setVisible(); + mContextMenuActions.mFileMenu->menuAction()->setVisible(!isSelectionMode); + + mContextMenuActions.mFileDelete->setVisible(!isFileItemListEmpty && !isCurrentDriveReadOnly); + mContextMenuActions.mFileRename->setVisible(!isFileItemListEmpty && !isCurrentDriveReadOnly && !isSelectionMode); + mContextMenuActions.mFileTouch->setVisible(!isFileItemListEmpty && !isCurrentDriveReadOnly); + mContextMenuActions.mFileProperties->setVisible(!isFileItemListEmpty && !isSelectionMode); + + mContextMenuActions.mFileChecksumsMenu->menuAction()->setVisible(!isFileItemListEmpty && !isSelectionMode && !isCurrentItemDirectory); + + // Edit submenu + mContextMenuActions.mEditMenu->menuAction()->setVisible(!isSelectionMode); + mContextMenuActions.mEditCut->setVisible(!(isCurrentDriveReadOnly || isFileItemListEmpty)); + mContextMenuActions.mEditCopy->setVisible(!(isFileItemListEmpty)); + mContextMenuActions.mEditPaste->setVisible(!isClipBoardEmpty && !isCurrentDriveReadOnly); + mContextMenuActions.mEditCopyToFolder->setVisible(!isFileItemListEmpty); + mContextMenuActions.mEditMoveToFolder->setVisible(!(isCurrentDriveReadOnly || isFileItemListEmpty)); +} + +// --------------------------------------------------------------------------- + +void FbFileView::onLongPressed(HbAbstractViewItem *listViewItem, QPointF coords) +{ + QModelIndex proxyIndex = listViewItem->modelIndex(); + //map to source model if needed + if (mSortFilterProxyModel) { + mCurrentIndex = mSortFilterProxyModel->mapToSource(proxyIndex); + } else { + mCurrentIndex = proxyIndex; + } + + mContextMenu->setPreferredPos(coords); + mContextMenu->show(); +} + +/** + Create a file browser search panel + */ +void FbFileView::createSearchPanel() +{ + // Create search panel widget + mSearchPanel = new HbSearchPanel(this); + mSearchPanel->setPlaceholderText(QString("Type filter criteria")); + mSearchPanel->setProgressive(false); + connect(mSearchPanel, SIGNAL(criteriaChanged(const QString &)), this, SLOT(filterCriteriaChanged(const QString &))); + connect(mSearchPanel, SIGNAL(exitClicked()), this, SLOT(clearFilterCriteria())); + mSearchPanel->hide(); +} + +/** + Create a file browser tool bar + */ +void FbFileView::createToolBar() +{ + mToolBar = toolBar(); + + connect(mainWindow(), SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(setOrientation(Qt::Orientation))); + + // Back button + mToolbarBackAction = new HbAction(mToolBar); + mToolbarBackAction->setToolTip("Back"); + HbIcon backIcon(QString(":/qtg_mono_filebrowser_parent_folder.svg")); + backIcon.setFlags(backIcon.flags() | HbIcon::Colorized); + mToolbarBackAction->setIcon(backIcon); + connect(mToolbarBackAction, SIGNAL(triggered()), this, SLOT(fileBackMoveUp())); + mToolBar->addAction(mToolbarBackAction); + + // Filter button + mToolbarFilterAction = new HbAction(mToolBar); + mToolbarFilterAction->setToolTip("Filter"); + HbIcon searchIcon(QString(":/qtg_mono_filebrowser_search.svg")); + searchIcon.setFlags(searchIcon.flags() | HbIcon::Colorized); + mToolbarFilterAction->setIcon(searchIcon); + connect(mToolbarFilterAction, SIGNAL(triggered()), this, SLOT(viewFilterEntries())); + mToolBar->addAction(mToolbarFilterAction); + + // Selection Mode button + mToolbarSelectionModeAction = new HbAction(mToolBar); + mOptionMenuActions.mSelection->setToolTip("Selection mode"); + connect(mToolbarSelectionModeAction, SIGNAL(triggered()), this, SLOT(selectionModeButtonTriggered())); + + mSelectionModeOnIcon.setIconName (QString(":/qtg_mono_filebrowser_selection_mode.svg")); + mSelectionModeOnIcon.setFlags(mSelectionModeOnIcon.flags() | HbIcon::Colorized); + + mSelectionModeOffIcon.setIconName(QString(":/qtg_mono_filebrowser_selection_mode_off.svg")); + mSelectionModeOffIcon.setFlags(mSelectionModeOffIcon.flags() | HbIcon::Colorized); + + mToolbarSelectionModeAction->setIcon(mSelectionModeOnIcon); + + mToolBar->addAction(mToolbarSelectionModeAction); + + // Paste button + mToolbarPasteAction = new HbAction(mToolBar); + mToolbarPasteAction->setToolTip("Paste"); + HbIcon pasteIcon(QString(":/qtg_mono_filebrowser_paste.svg")); + pasteIcon.setFlags(pasteIcon.flags() | HbIcon::Colorized); + mToolbarPasteAction->setIcon(pasteIcon); + connect(mToolbarPasteAction, SIGNAL(triggered()), this, SLOT(editPaste())); + mToolBar->addAction(mToolbarPasteAction); + mToolbarPasteAction->setEnabled(false); +} + +/** + * Change toolbar orientation + */ +void FbFileView::setOrientation(Qt::Orientation orientation) +{ + if (orientation == Qt::Horizontal) { + mToolBar->setOrientation(Qt::Vertical); + } else { + mToolBar->setOrientation(Qt::Horizontal); + } +} + +/** + Refresh FileBrowser view + */ +void FbFileView::refreshList() +{ + editUnselectAll(); + mEngineWrapper->refreshView(); + if (!mToolbarFilterAction->isEnabled()) { + clearFilterCriteria(); + } + mListView->reset(); + + if (mListView->model() && mListView->model()->rowCount() > 0) { + QModelIndex firstIndex = mListView->model()->index(0, 0); + mListView->scrollTo(firstIndex); + } + + mToolbarPasteAction->setEnabled(mEngineWrapper->isClipBoardListInUse()); + + TListingMode listingMode = mEngineWrapper->listingMode(); + if (listingMode == ENormalEntries) + mNaviPane->setPlainText(QString(mEngineWrapper->currentPath())); + else if (listingMode == ESearchResults) + mNaviPane->setPlainText(QString(tr("Search results"))); + else if (listingMode == EOpenFiles) + mNaviPane->setPlainText(QString(tr("Open files"))); + else if (listingMode == EMsgAttachmentsInbox) + mNaviPane->setPlainText(QString(tr("Attachments in Inbox"))); + else if (listingMode == EMsgAttachmentsDrafts) + mNaviPane->setPlainText(QString(tr("Attachments in Drafts"))); + else if (listingMode == EMsgAttachmentsSentItems) + mNaviPane->setPlainText(QString(tr("Attachments in Sent Items"))); + else if (listingMode == EMsgAttachmentsOutbox) + mNaviPane->setPlainText(QString(tr("Attachments in Outbox"))); +} + +// --------------------------------------------------------------------------- + +void FbFileView::fileOpen(HbAction *action) +{ +// Q_UNUSED(action); + HbSelectionDialog *dlg = static_cast(sender()); + if(!action && dlg && dlg->selectedItems().count()){ + int selectionIndex = dlg->selectedItems().at(0).toInt(); + + if (selectionIndex == 0) { + // open editor view + emit aboutToShowEditorView(mAbsoluteFilePath, true); + } else if (selectionIndex == 1) { + // AppArc + mEngineWrapper->openAppArc(mAbsoluteFilePath); + } else { + // DocHandler + mEngineWrapper->openDocHandler(mAbsoluteFilePath, true); + } + } +} + +/** + Open overwrite dialog + */ +void FbFileView::fileOverwriteDialog(/*QObject *receiver, const char *member*/) +{ + mOverwriteOptions = OverwriteOptions(); + // open user-dialog to select: view as text/hex, open w/AppArc or open w/DocH. embed + QStringList list; + list << QString("Overwrite all") + << QString("Skip all existing") + << QString("Gen. unique filenames") + << QString("Query postfix"); + openListDialog(list, QString("Overwrite?"), this, SLOT(fileOverwrite(HbAction *))); +} + +/** + File overwrite + */ +void FbFileView::fileOverwrite(HbAction *action) +{ + HbSelectionDialog *dlg = static_cast(sender()); + if(!action && dlg && dlg->selectedItems().count()) { + mOverwriteOptions.queryIndex = dlg->selectedItems().at(0).toInt(); + if (mOverwriteOptions.queryIndex == EFileActionQueryPostFix) { + QString heading = QString("Postfix"); + HbInputDialog::queryText(heading, + this, SLOT(fileOverwritePostfix(HbAction *)), + QString(), scene()); + } else if (mOverwriteOptions.queryIndex == EFileActionSkipAllExisting) { + mOverwriteOptions.overWriteFlags = 0; + emit overwriteOptionSelected(); + } else { + emit overwriteOptionSelected(); + } + } else { + mOverwriteOptions.doFileOperations = false; + emit overwriteOptionSelected(); + } +} + +/** + File overwrite postfix query dialog + */ +void FbFileView::fileOverwritePostfix(HbAction *action) +{ + HbInputDialog *dlg = static_cast(sender()); + if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { + mOverwriteOptions.postFix = dlg->value().toString(); + } else { + mOverwriteOptions.doFileOperations = false; + } + emit overwriteOptionSelected(); +} + +/** + Show a list dialog + \param List \a items of item to select item from. + \param Title text \a titleText of a dialog heading widget + \param Receiver \a receiver execute slot on + \param Slot \a executed when dialog has been closed + \return None + */ +void FbFileView::openListDialog(const QStringList& items, const QString &titleText, + QObject *receiver, const char *member) +{ + // Create a list and some simple content for it + HbSelectionDialog *dlg = new HbSelectionDialog(); + dlg->setAttribute(Qt::WA_DeleteOnClose); + // Set items to be popup's content + dlg->setStringItems(items); + dlg->setSelectionMode(HbAbstractItemView::SingleSelection); + + HbLabel *title = new HbLabel(dlg); + title->setPlainText(titleText); + dlg->setHeadingWidget(title); + // Launch popup and handle the user response: + dlg->open(receiver, member); +} + +/** + Stores selection or current index mapped to source model + */ +void FbFileView::storeSelectedItemsOrCurrentItem() +{ + QItemSelectionModel *selectionIndexes = mListView->selectionModel(); + + // by default use selected items + if (selectionIndexes) { + bool isSelectionMode = mOptionMenuActions.mSelection && mOptionMenuActions.mSelection->isChecked(); + if (isSelectionMode) { + if (selectionIndexes->hasSelection()) { + QItemSelection itemSelection = mListView->selectionModel()->selection(); + //map to source model if needed + if (mSortFilterProxyModel) { + mSelectionIndexes = mSortFilterProxyModel->mapSelectionToSource(itemSelection).indexes(); + } else { + mSelectionIndexes = itemSelection.indexes(); + } + } else { // or if none selected, clear selection + mSelectionIndexes.clear(); + } + } else { // or if none selected, use the current item index + mSelectionIndexes.clear(); + QModelIndex currentIndex = currentItemIndex(); //alreade mapped to source model + mSelectionIndexes.append(currentIndex); + } + } +} + +// --------------------------------------------------------------------------- + +QModelIndex FbFileView::currentItemIndex() +{ + return mCurrentIndex; +} + +// --------------------------------------------------------------------------- +// operations in File Menu +// --------------------------------------------------------------------------- + +/** + Move back/up in folder browsing history + */ +void FbFileView::fileBackMoveUp() +{ + mLocationChanged = true; + mFbFileModel->moveUpOneLevel(); + //mListView->setRootIndex(currentItemIndex()); + refreshList(); + if (mEngineWrapper->isDriveListViewActive()) { + emit aboutToShowDriveView(); + } +} + +void FbFileView::fileOpenDirectory() +{ + mLocationChanged = true; + mFbFileModel->moveDownToDirectory(currentItemIndex()); + + refreshList(); +} + +void FbFileView::fileSearch() +{ + QString searchPath; + HbAction *contextrMenuAction = static_cast(sender()); + if (contextrMenuAction + && (contextrMenuAction == mContextMenuActions.mSearch + || contextrMenuAction == mContextMenuActions.mFileSearch) + && mEngineWrapper->getFileEntry(currentItemIndex()).isDir()) { + searchPath = mEngineWrapper->currentPath() + + mEngineWrapper->getFileEntry(currentItemIndex()).name() + + QString("\\"); + } else { + searchPath = mEngineWrapper->currentPath(); + } + + emit aboutToShowSearchView(searchPath); +} + +/** + Open new file dialog + */ +void FbFileView::fileNewFile() +{ + QString heading = QString("Enter filename"); + HbInputDialog::queryText(heading, this, SLOT(doFileNewFile(HbAction*)), QString(), scene()); +} + +/** + Create a new file in current directory with a name queried from user + */ +void FbFileView::doFileNewFile(HbAction *action) +{ + HbInputDialog *dlg = static_cast(sender()); + if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { + QString newFileName = dlg->value().toString(); + mEngineWrapper->createNewFile(newFileName); + refreshList(); + } +} + +/** + Open new directory dialog + */ +void FbFileView::fileNewDirectory() +{ + QString heading = QString("Enter directory name"); + HbInputDialog::queryText(heading, this, SLOT(doFileNewDirectory(HbAction*)), QString(), scene()); +} + +/** + Create a new directory in current directory with a name queried from user + */ +void FbFileView::doFileNewDirectory(HbAction *action) +{ + HbInputDialog *dlg = static_cast(sender()); + if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { + QString newDirectoryName = dlg->value().toString(); + mEngineWrapper->createNewDirectory(newDirectoryName); + refreshList(); + } +} + +/** + Question for Delete actually selected files + */ +void FbFileView::fileDelete() +{ + storeSelectedItemsOrCurrentItem(); + const QString messageFormat = "Delete %1 entries?"; + QString message = messageFormat.arg(mSelectionIndexes.count()); + HbMessageBox::question(message, this, SLOT(doFileDelete(int)), HbMessageBox::Yes | HbMessageBox::No); +} + +/** + Delete actually selected files + */ +void FbFileView::doFileDelete(int action) +{ + if (action == HbMessageBox::Yes) { + mEngineWrapper->deleteItems(mSelectionIndexes); + mEngineWrapper->startExecutingCommands(QString("Deleting")); + } +} + +/** + Open rename dialog for actually selected files + */ +void FbFileView::fileRename() +{ + storeSelectedItemsOrCurrentItem(); + mEngineWrapper->setCurrentSelection(mSelectionIndexes); + + for (int i(0), ie(mSelectionIndexes.count()); i < ie; ++i ) { + mProceed = (i == ie-1); // if the last item + mModelIndex = mSelectionIndexes.at(i); + FbFileEntry entry = mEngineWrapper->getFileEntry(mModelIndex); + + QString heading = QString("Enter new name"); + HbInputDialog::queryText(heading, this, SLOT(doFileRename(HbAction*)), entry.name(), scene()); + } +} + +/** + Rename actually selected files + */ +void FbFileView::doFileRename(HbAction *action) +{ + HbInputDialog *dlg = static_cast(sender()); + if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { + mNewFileName = dlg->value().toString(); + + if (mEngineWrapper->targetExists(mModelIndex, mNewFileName)) { + const QString messageTemplate = QString("%1 already exists, overwrite?"); + QString message = messageTemplate.arg(mNewFileName); + HbMessageBox::question(message, this, SLOT(doFileRenameFileExist(int)), HbMessageBox::Yes | HbMessageBox::No); + } else { + proceedFileRename(); + } + } +} + +/** + Rename actually selected files + */ +void FbFileView::doFileRenameFileExist(int action) +{ + if (action == HbMessageBox::Yes) { + proceedFileRename(); + } +} + + +void FbFileView::proceedFileRename() +{ + mEngineWrapper->rename(mModelIndex, mNewFileName); + if (mProceed) { + mEngineWrapper->startExecutingCommands(QString("Renaming")); + refreshList(); + } +} + +/** + Touch actually selected files + */ +void FbFileView::fileTouch() +{ + storeSelectedItemsOrCurrentItem(); + mEngineWrapper->setCurrentSelection(mSelectionIndexes); + + if (mEngineWrapper->selectionHasDirs()) { + const QString message = "Recurse touch for all selected dirs?"; + HbMessageBox::question(message, this, SLOT(doFileTouch(int)), HbMessageBox::Yes | HbMessageBox::No); + } else { + proceedFileTouch(false); + } +} + +/** + Touch actually selected files + */ +void FbFileView::doFileTouch(int action) +{ + bool recurse = false; + if (action == HbMessageBox::Yes) { + recurse = true; + } + proceedFileTouch(recurse); +} + +void FbFileView::proceedFileTouch(bool recurse) +{ + mEngineWrapper->touch(recurse); + mEngineWrapper->startExecutingCommands(QString("Touching")); + refreshList(); +} + +void FbFileView::fileChecksumsMD5() +{ + fileChecksums(EFileChecksumsMD5); +} + +void FbFileView::fileChecksumsMD2() +{ + fileChecksums(EFileChecksumsMD2); +} + +void FbFileView::fileChecksumsSHA1() +{ + fileChecksums(EFileChecksumsSHA1); +} + +void FbFileView::fileChecksums(TFileBrowserCmdFileChecksums checksumType) +{ + mEngineWrapper->showFileCheckSums(currentItemIndex(), checksumType); +} + +/** + Show file properties + */ +void FbFileView::fileProperties() +{ + const QString PropertiesEntryFormat("%1\t%2"); + const QString PropertiesEntryTabbedFormat("\t%1"); + const QString PropertiesEntrySizeFormat("%1\t%2 B"); + const QString DateFormat("%D%M%Y%/0%1%/1%2%/2%3%/3"); + const QString TimeFormat("%-B%:0%J%:1%T%:2%S%:3%+B"); + + const QString AttributesText("Atts"); + const QString NumberOfEntriesText("Entries"); + const QString NumberOfFilesText("Files"); + const QString SizeText("Size"); + const QString PathText("Path"); + const QString DateText("Date"); + const QString TimeText("Time"); + const QString MimeTypeText("Mime"); + const QString OpensWithText("Opens"); + + QModelIndex currentIndex = currentItemIndex(); + QVector > properties; + QString titleText; + bool showDialog(false); + + if (currentIndex.row() >= 0 && currentIndex.row() < mEngineWrapper->itemCount()) { + // it is a file or a directory entry + FbFileEntry fileEntry(mEngineWrapper->getFileEntry(currentIndex)); + + // set title + titleText.append(fileEntry.name()); + + // path + properties.append(qMakePair(PathText, fileEntry.path())); + + // date + properties.append(qMakePair(DateText, fileEntry.modifiedDateTimeString(DateFormat))); + + // time + properties.append(qMakePair(TimeText, fileEntry.modifiedDateTimeString(TimeFormat))); + + if (!fileEntry.isDir()) { + // size + QLocale loc; + QString fileSize = loc.toString(fileEntry.size()); + + //QString fileSize = QString::number(fileEntry.size()); + properties.append(qMakePair(SizeText, fileSize)); + } else if (fileEntry.isDir() + && mEngineWrapper->settings().showSubDirectoryInfo()) { + + QString fullPath; + fullPath.append(fileEntry.path()) + .append(fileEntry.name()) + .append(QString("\\")); + + // number of entries + int entriesCount = mEngineWrapper->getEntriesCount(fullPath); + if (entriesCount >= 0) { + properties.append(qMakePair(NumberOfEntriesText, QString::number(entriesCount))); + } + + // number of files + qint64 size(0); + int allFilesCount = mEngineWrapper->getFilesCountAndSize(fullPath, size); + properties.append(qMakePair(NumberOfFilesText, QString::number(allFilesCount))); + + // size + QLocale loc; + QString folderSize = loc.toString(size); + properties.append(qMakePair(SizeText, folderSize)); + } + + // attributes + QStringList attributesValues; + if (fileEntry.isArchive()) + attributesValues.append(fileEntry.archiveText()); + if (fileEntry.isHidden()) + attributesValues.append(fileEntry.hiddenText()); + if (fileEntry.isReadOnly()) + attributesValues.append(fileEntry.readOnlyText()); + if (fileEntry.isSystem()) + attributesValues.append(fileEntry.systemText()); + if (attributesValues.isEmpty()) + attributesValues.append(fileEntry.noAttributeText()); + + for (int i(0), ie(attributesValues.count()); i < ie; ++i) { + properties.append(qMakePair(AttributesText, attributesValues.at(i))); + } + + if (!fileEntry.isDir()) { + // mime type + QString fullPath = fileEntry.path(); + fullPath.append(fileEntry.name()); + QString mimeType = mEngineWrapper->getMimeType(fullPath); + if (!mimeType.isEmpty()) { + properties.append(qMakePair(MimeTypeText, mimeType)); + } + + // opens with + QString openWith = mEngineWrapper->getOpenWith(fullPath); + if (!openWith.isEmpty()) { + properties.append(qMakePair(OpensWithText, openWith)); + } + } + showDialog = true; + } + + if (showDialog) { + FbPropertiesDialog *dialog = new FbPropertiesDialog(); + dialog->setTitle(titleText); + + // Set listwidget to be popup's content + dialog->setProperties(properties); + // Launch popup and handle the user response: + dialog->open(); + } +} + +void FbFileView::fileSetAttributes() +{ + storeSelectedItemsOrCurrentItem(); + mEngineWrapper->setCurrentSelection(mSelectionIndexes); + + QString attributesViewTitle("Multiple entries"); + + quint32 setAttributesMask(0); + quint32 clearAttributesMask(0); + bool recurse(false); + + // set default masks if only one file selected + if (mSelectionIndexes.count() == 1) + { + mModelIndex = mSelectionIndexes.at(0); + FbFileEntry fileEntry = mEngineWrapper->getFileEntry(mModelIndex); + + attributesViewTitle = fileEntry.name(); + + if (fileEntry.isArchive()) + setAttributesMask |= KEntryAttArchive; + else + clearAttributesMask |= KEntryAttArchive; + + if (fileEntry.isHidden()) + setAttributesMask |= KEntryAttHidden; + else + clearAttributesMask |= KEntryAttHidden; + + if (fileEntry.isReadOnly()) + setAttributesMask |= KEntryAttReadOnly; + else + clearAttributesMask |= KEntryAttReadOnly; + + if (fileEntry.isSystem()) + setAttributesMask |= KEntryAttSystem; + else + clearAttributesMask |= KEntryAttSystem; + } + + emit aboutToShowAttributesView(attributesViewTitle, setAttributesMask, clearAttributesMask, recurse); +} + +// edit menu +void FbFileView::editSnapShotToE() +{ + +} + +/** + Set selected files into clipboard. + Selected item will be removed after paste operation. + */ +void FbFileView::editCut() +{ + storeSelectedItemsOrCurrentItem(); + + // Store indices to clipboard + mClipboardIndexes.clear(); + for (int i = 0; i < mSelectionIndexes.size(); ++i) { + mClipboardIndexes.append(mSelectionIndexes.at(i)); + } + + mEngineWrapper->clipboardCut(mClipboardIndexes); + mEngineWrapper->setCurrentSelection(mClipboardIndexes); + + int operations = mClipboardIndexes.count(); + const QString message = QString ("%1 entries cut to clipboard"); + QString noteMsg = message.arg(operations); + + mToolbarPasteAction->setEnabled(true); + Notifications::showInformationNote(noteMsg); +} + +/** + Set selected files into clipboard. + Selected item will not be removed after paste operation. + */ +void FbFileView::editCopy() +{ + storeSelectedItemsOrCurrentItem(); + + // Store indices to clipboard + mClipboardIndexes.clear(); + for (int i = 0; i < mSelectionIndexes.size(); ++i) { + mClipboardIndexes.append(mSelectionIndexes.at(i)); + } + + mEngineWrapper->clipboardCopy(mClipboardIndexes); + mEngineWrapper->setCurrentSelection(mClipboardIndexes); + + int operations = mClipboardIndexes.count(); + + const QString message = QString ("%1 entries copied to clipboard"); + QString noteMsg = message.arg(operations); + + mToolbarPasteAction->setEnabled(true); + Notifications::showInformationNote(noteMsg); +} + +/** + Moves or copies file selection stored in clipboard to a actual directory. + Removing files depend on previous operation, i.e. Cut or Copy + */ +void FbFileView::editPaste() +{ + bool someEntryExists(false); + + someEntryExists = mEngineWrapper->isDestinationEntriesExists(mClipboardIndexes, mEngineWrapper->currentPath()); + if (someEntryExists) { + connect(this, SIGNAL(overwriteOptionSelected()), this, SLOT(doEditPaste())); + fileOverwriteDialog(); + } else { + doEditPaste(); + } +} + +void FbFileView::doEditPaste() +{ + mEngineWrapper->clipboardPaste(mOverwriteOptions); + mEngineWrapper->startExecutingCommands(mEngineWrapper->getClipBoardMode() == EClipBoardModeCut ? + QString("Moving") : QString("Copying") ); + disconnect(this, SIGNAL(overwriteOptionSelected()), this, SLOT(doEditPaste())); +} + +/** + Open copy to folder new filename dialog + */ +void FbFileView::editCopyToFolder() +{ + QString heading = QString("Enter new name"); + FbCopyToFolderSelectionDialog *folderSelectionDialog = new FbCopyToFolderSelectionDialog(); + folderSelectionDialog->open(this, SLOT(doEditCopyToFolder(int))); +} + +/** + Copies current file selection to a queried directory. + */ +void FbFileView::doEditCopyToFolder(int action) +{ + FbCopyToFolderSelectionDialog *dlg = qobject_cast(sender()); + if (dlg && action == HbDialog::Accepted) { + mTargetDir = dlg->selectedFolder(); + + bool someEntryExists(false); + + // TODO Set entry items here + storeSelectedItemsOrCurrentItem(); + mEngineWrapper->setCurrentSelection(mSelectionIndexes); + + someEntryExists = mEngineWrapper->isDestinationEntriesExists(mSelectionIndexes, mTargetDir); + if (someEntryExists) { + connect(this, SIGNAL(overwriteOptionSelected()), this, SLOT(doEditCopy())); + fileOverwriteDialog(); + } else { + doEditCopy(); + } + } +} + +void FbFileView::doEditCopy() +{ + mEngineWrapper->copyToFolder(mTargetDir, mOverwriteOptions, false); + mEngineWrapper->startExecutingCommands(QString("Copying")); + disconnect(this, SIGNAL(overwriteOptionSelected()), this, SLOT(doEditCopy())); +} + +/** + Open move to folder new filename dialog. + */ +void FbFileView::editMoveToFolder() +{ + QString heading = QString("Enter new name"); + FbMoveToFolderSelectionDialog *folderSelectionDialog = new FbMoveToFolderSelectionDialog(); + folderSelectionDialog->open(this, SLOT(doEditMoveToFolder(int))); +} + +/** + Moves current file selection to a queried directory. + */ +void FbFileView::doEditMoveToFolder(int action) +{ + FbMoveToFolderSelectionDialog *dlg = qobject_cast(sender()); + if (dlg && action == HbDialog::Accepted) { + mTargetDir = dlg->selectedFolder(); + + bool someEntryExists(false); + + // TODO Set entry items here + storeSelectedItemsOrCurrentItem(); + mEngineWrapper->setCurrentSelection(mSelectionIndexes); + + someEntryExists = mEngineWrapper->isDestinationEntriesExists(mSelectionIndexes, mTargetDir); + if (someEntryExists) { + connect(this, SIGNAL(overwriteOptionSelected()), this, SLOT(doEditMove())); + fileOverwriteDialog(); + } else { + doEditMove(); + } + } +} + +void FbFileView::doEditMove() +{ + mEngineWrapper->copyToFolder(mTargetDir, mOverwriteOptions, true); + mEngineWrapper->startExecutingCommands(QString("Moving")); + disconnect(this, SIGNAL(overwriteOptionSelected()), this, SLOT(doEditMove())); +} + +/** + Select current file + */ +void FbFileView::editSelect() +{ + QItemSelectionModel *selectionModel = mListView->selectionModel(); + if (selectionModel) { + selectionModel->select(selectionModel->currentIndex(), QItemSelectionModel::SelectCurrent); + selectionModel->select(selectionModel->currentIndex(), QItemSelectionModel::Select); + refreshList(); + } +} + +/** + Unselect current file + */ +void FbFileView::editUnselect() +{ + QItemSelectionModel *selectionModel = mListView->selectionModel(); + if (selectionModel) { + selectionModel->select(selectionModel->currentIndex(), QItemSelectionModel::Deselect); +// itemHighlighted(selectionModel->currentIndex()); + } +} + +/** + Select all files + */ +void FbFileView::editSelectAll() +{ + QItemSelectionModel *selectionModel = mListView->selectionModel(); + if (selectionModel) { + + //if (mFileBrowserModel->rowCount() > 0) { + if (mListView->model() && mListView->model()->rowCount() > 0) { + QModelIndex firstIndex = mListView->model()->index(0, 0); + QModelIndex lastIndex = mListView->model()->index( (mListView->model()->rowCount() - 1), 0); + + QItemSelection itemSelection(firstIndex, lastIndex); + selectionModel->select(itemSelection, QItemSelectionModel::SelectCurrent); + } + } +} + +/** + Unselect all files + */ +void FbFileView::editUnselectAll() +{ + QItemSelectionModel *selectionModel = mListView->selectionModel(); + if (selectionModel) { + selectionModel->clearSelection(); + } +} + +// --------------------------------------------------------------------------- +// view menu +// --------------------------------------------------------------------------- +/** + * Open the search panel + */ +void FbFileView::viewFilterEntries() +{ + if (mToolbarFilterAction) { + mToolbarFilterAction->setEnabled(false); + } + + if (mMainLayout && mSearchPanel) { + mMainLayout->addItem(mSearchPanel); + mSearchPanel->show(); + } +} + +/** + Set filter criteria to proxy model + */ +void FbFileView::filterCriteriaChanged(const QString &criteria) +{ + if (!mSortFilterProxyModel) { + mSortFilterProxyModel = new FileBrowserSortFilterProxyModel(this); + mSortFilterProxyModel->setSourceModel(mFbFileModel); + mSortFilterProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive); + mListView->setModel(mSortFilterProxyModel); + + } + mSortFilterProxyModel->setFilterCriteria(criteria); + + setTitle(criteria); + if (criteria.isEmpty()) { + setTitle("File Browser"); + } +} + +/** + Set filter criteria to proxy model + */ +void FbFileView::clearFilterCriteria() +{ + if (mToolbarFilterAction) { + mToolbarFilterAction->setEnabled(true); + } + + if (mSortFilterProxyModel) { + mListView->setModel(mFbFileModel); + mSortFilterProxyModel->deleteLater(); + mSortFilterProxyModel = 0; + } + + if (mMainLayout && mSearchPanel) { + mSearchPanel->setCriteria(QString("")); + mMainLayout->removeItem(mSearchPanel); + mSearchPanel->hide(); + refreshList(); + } + setTitle("File Browser"); +} + +/** + Refresh view + */ +void FbFileView::viewRefresh() +{ + refreshList(); +} + +// --------------------------------------------------------------------------- +// tools menu +// --------------------------------------------------------------------------- +void FbFileView::toolsAllAppsToTextFile() +{ + +} + +/** + Write all files to text file + */ +void FbFileView::toolsAllFilesToTextFile() +{ + mEngineWrapper->toolsWriteAllFiles(); +} + +//void FbFileView::toolsAvkonIconCacheEnable() +//{ +// +//} +//void FbFileView::toolsAvkonIconCacheDisable() +//{ +// +//} + +/** + Disable extended errors + */ +void FbFileView::toolsDisableExtendedErrors() +{ + mEngineWrapper->ToolsSetErrRd(false); +} + +void FbFileView::toolsDumpMsgStoreWalk() +{ + +} +void FbFileView::toolsEditDataTypes() +{ + +} + +/** + Enable extended errors + */ +void FbFileView::toolsEnableExtendedErrors() +{ + mEngineWrapper->ToolsSetErrRd(true); +} + +/** + Open simulate leave dialog + */ +void FbFileView::toolsErrorSimulateLeave() +{ + int leaveCode = -6; + QString heading = QString("Leave code"); + //HbInputDialog::queryInt(heading, this, SLOT(doToolsErrorSimulateLeave(HbAction*)), leaveCode, scene()); + HbInputDialog::queryText(heading, this, SLOT(doToolsErrorSimulateLeave(HbAction*)), QString::number(leaveCode), scene()); +} + + +/** + Simulate leave. + */ +void FbFileView::doToolsErrorSimulateLeave(HbAction *action) +{ + HbInputDialog *dlg = static_cast(sender()); + if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { + bool ok; + int leaveCode = dlg->value().toString().toInt(&ok); + if (leaveCode != 0 || ok) { + mEngineWrapper->ToolsErrorSimulateLeave(leaveCode); + } + } +} + +/** + Open simulate panic dialog. + */ +void FbFileView::toolsErrorSimulatePanic() +{ + mPanicCategory = QString ("Test Category"); + QString heading = QString("Panic category"); + HbInputDialog::queryText(heading, this, SLOT(doToolsErrorSimulatePanicCode(HbAction*)), mPanicCategory, scene()); +} + +/** + Simulate panic. + */ +void FbFileView::doToolsErrorSimulatePanicCode(HbAction *action) +{ + HbInputDialog *dlg = static_cast(sender()); + if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { + mPanicCategory = dlg->value().toString(); + int panicCode(555); + QString heading = QString("Panic code"); + HbInputDialog::queryInt(heading, this, SLOT(doToolsErrorSimulatePanic(HbAction*)), panicCode, scene()); + } +} + +/** + Simulate panic. + */ +void FbFileView::doToolsErrorSimulatePanic(HbAction *action) +{ + HbInputDialog *dlg = static_cast(sender()); + if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { + bool ok; + int panicCode = dlg->value().toInt(&ok); + if (panicCode != 0 || ok) { + mEngineWrapper->ToolsErrorSimulatePanic(mPanicCategory, panicCode); + } + } +} + +/** + Open simulate exception dialog. + */ +void FbFileView::toolsErrorSimulateException() +{ + int exceptionCode = 0; + QString heading = QString("Exception code"); + HbInputDialog::queryInt(heading, this, SLOT(doToolsErrorSimulateException(HbAction*)), exceptionCode, scene()); +} + +/** + Simulate exception. + */ +void FbFileView::doToolsErrorSimulateException(HbAction *action) +{ + HbInputDialog *dlg = static_cast(sender()); + if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { + bool ok; + int exceptionCode = dlg->value().toInt(&ok); + if (exceptionCode != 0 || ok) { + mEngineWrapper->ToolsErrorSimulateException(exceptionCode); + } + } +} + +// void FbFileView::toolsLocalConnectivityActivateInfrared() +//{ +// +//} +// void FbFileView::toolsLocalConnectivityLaunchBTUI() +//{ +// +//} +// void FbFileView::toolsLocalConnectivityLaunchUSBUI() +//{ +// +//} +void FbFileView::toolsMessageInbox() +{ + +} +void FbFileView::toolsMessageDrafts() +{ + +} +void FbFileView::toolsMessageSentItems() +{ + +} +void FbFileView::toolsMessageOutbox() +{ + +} +void FbFileView::toolsMemoryInfo() +{ + +} +void FbFileView::toolsSecureBackStart() +{ + +} +void FbFileView::toolsSecureBackRestore() +{ + +} +void FbFileView::toolsSecureBackStop() +{ + +} + +/** + Open debug mask dialog + */ +void FbFileView::toolsSetDebugMaskQuestion() +{ + quint32 dbgMask = mEngineWrapper->getDebugMask(); + QString dbgMaskText = QString("0x").append(QString::number(dbgMask, 16)); + QString heading = QString("Kernel debug mask in hex format"); + HbInputDialog::queryText(heading, this, SLOT(toolsSetDebugMask(HbAction*)), dbgMaskText, scene()); +} + +/** + Set debug mask + */ +void FbFileView::toolsSetDebugMask(HbAction *action) +{ + HbInputDialog *dlg = static_cast(sender()); + if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { + QString dbgMaskText = dlg->value().toString(); + if (dbgMaskText.length() > 2 && dbgMaskText[0]=='0' && dbgMaskText[1]=='x') { + bool ok; + quint32 dbgMask = dbgMaskText.toUInt(&ok, 16); + if (dbgMask != 0 || ok) { + mEngineWrapper->toolsSetDebugMask(dbgMask); + Notifications::showConfirmationNote(QString("Changed")); + } else { + Notifications::showErrorNote(QString("Cannot convert value")); + } + } else { + Notifications::showErrorNote(QString("Not in hex format")); + } + } +} + +void FbFileView::toolsShowOpenFilesHere() +{ + +} + +// --------------------------------------------------------------------------- +// main menu items +// --------------------------------------------------------------------------- +void FbFileView::selectionModeChanged() +{ + if (mOptionMenuActions.mSelection->isChecked()) { + activateSelectionMode(); + mToolbarSelectionModeAction->setIcon(mSelectionModeOffIcon); + } else { + deActivateSelectionMode(); + mToolbarSelectionModeAction->setIcon(mSelectionModeOnIcon); + } +} + +void FbFileView::selectionModeButtonTriggered() +{ + if (mOptionMenuActions.mSelection->isChecked()) { + mOptionMenuActions.mSelection->setChecked(false); + } else { + mOptionMenuActions.mSelection->setChecked(true); + } + selectionModeChanged(); +} + +/** + Show about note + */ +void FbFileView::about() +{ + Notifications::showAboutNote(); +} + +// --------------------------------------------------------------------------- +// End of operations +// --------------------------------------------------------------------------- + +// --------------------------------------------------------------------------- + +/** + An item is clicked from navigation item list. Navigation item list contains + drive-, folder- or file items. Opens selected drive, folder or file popup menu + */ +void FbFileView::activated(const QModelIndex& index) +{ + if (mFbFileModel) { + //map to source model + QModelIndex activatedIndex = index; + if (mSortFilterProxyModel) { + activatedIndex = mSortFilterProxyModel->mapToSource(index); + } + + if (mEngineWrapper->getFileEntry(activatedIndex).isDir()) { + // populate new content of changed navigation view. + mFbFileModel->moveDownToDirectory(activatedIndex); + refreshList(); + } else { // file item + // mSelectedFilePath = filePath; + FbFileEntry fileEntry = mEngineWrapper->getFileEntry(activatedIndex); + mAbsoluteFilePath = fileEntry.path() + fileEntry.name(); + + // open user-dialog to select: view as text/hex, open w/AppArc or open w/DocH. embed + QStringList list; + list << QString("View as text/hex") + << QString("Open w/ AppArc") + << QString("Open w/ DocH. embed"); + openListDialog(list, QString("Open file"), this, SLOT(fileOpen(HbAction *))); + } + } +} + +// --------------------------------------------------------------------------- + +void FbFileView::activateSelectionMode() +{ + QString path; + disconnect(mListView, SIGNAL(activated(QModelIndex)), this, SLOT(activated(QModelIndex))); + mListView->setSelectionMode(HbListView::MultiSelection); +} + +// --------------------------------------------------------------------------- + +void FbFileView::deActivateSelectionMode() +{ + mListView->setSelectionMode(HbListView::NoSelection); + connect(mListView, SIGNAL(activated(QModelIndex)), this, SLOT(activated(QModelIndex))); + editUnselectAll(); +} + +// --------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/ui/src/fbfolderselectiondialog.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/ui/src/fbfolderselectiondialog.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,244 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "fbfolderselectiondialog.h" +#include "fbfolderselectorwrapper.h" + +#include +#include +#include +#include +#include + +#include +#include +#include + +/** + * Constructor + */ +FbFolderSelectionDialog::FbFolderSelectionDialog(QGraphicsItem *parent) : + HbDialog(parent), + mTitle(0), + mCurrentPath(0), + mFolderList(0), + mFolderSelectorWrapper(0), + mFileIconProvider(0) +{ + init(); +} + +/** + * Destructor + */ +FbFolderSelectionDialog::~FbFolderSelectionDialog() +{ + if (mFileIconProvider) + delete mFileIconProvider; +} + +/** + * Provide currenntly selected folder + * \return current folder + */ +QString FbFolderSelectionDialog::selectedFolder() +{ + return mFolderSelectorWrapper->currentPath(); +} + +/** + * Initialize folder selection dialog + */ +void FbFolderSelectionDialog::init() +{ + setAttribute(Qt::WA_DeleteOnClose); + + mFileIconProvider = new QFileIconProvider(); + + createHeading(); + createList(); + createToolBar(); +} + +/** + * Create dialog heading widget + */ +void FbFolderSelectionDialog::createHeading() +{ + HbWidget *headingWidget = new HbWidget(this); + QGraphicsLinearLayout *headingLayout = new QGraphicsLinearLayout(Qt::Horizontal); + headingWidget->setLayout(headingLayout); + + QGraphicsLinearLayout *titleLayout = new QGraphicsLinearLayout(Qt::Vertical); + mTitle = new HbLabel(this); + mCurrentPath = new HbLabel(this); + mCurrentPath->setPlainText(" "); + mCurrentPath->setElideMode(Qt::ElideMiddle); + titleLayout->addItem(mTitle); + titleLayout->setAlignment( mTitle, Qt::AlignLeft); + titleLayout->addItem(mCurrentPath); + titleLayout->setAlignment( mCurrentPath, Qt::AlignLeft); + + HbPushButton *moveUpButton = new HbPushButton(headingWidget); + moveUpButton->setIcon(HbIcon(QString(":/qtg_indi_status_back.svg"))); + connect(moveUpButton, SIGNAL(pressed()), + this, SLOT(moveUpPressed())); + + headingLayout->addItem(titleLayout); + headingLayout->addItem(moveUpButton); + headingLayout->setAlignment(moveUpButton, Qt::AlignRight); + + setHeadingWidget(headingWidget); +} + +/** + * Create dialog content widget as a list of files + */ +void FbFolderSelectionDialog::createList() +{ + mFolderList = new HbListWidget(this); + mFolderSelectorWrapper = new FbFolderSelectorWrapper(); + mFolderSelectorWrapper->init(); + + refreshView(); + + setContentWidget(mFolderList); + connect(mFolderList, SIGNAL(activated(HbListWidgetItem *)), + this, SLOT(activated(HbListWidgetItem *))); + + connect(mFolderSelectorWrapper, SIGNAL(FolderSelectionChanged()), + this, SLOT(refreshView())); +} + +/** + * Create dialog toolbar + */ +void FbFolderSelectionDialog::createToolBar() +{ + HbAction *acceptAction = new HbAction(this); + acceptAction->setEnabled(false); + connect(acceptAction, SIGNAL(triggered()), + this, SLOT(acceptTriggered())); + addAction(acceptAction); + + HbAction *rejectAction = new HbAction(QString("Cancel"), this); + addAction(rejectAction); +} + +/** + * Refresh list widget content + */ +void FbFolderSelectionDialog::refreshView() +{ + mFolderList->clear(); + QIcon icon; + mCurrentPath->setPlainText(mFolderSelectorWrapper->currentPath()); + if (mFolderSelectorWrapper->isDriveListViewActive()) + { + const QString KSimpleDriveEntry("%d\t%c: <%S>\t\t"); + //TODO icon = mFileIconProvider->icon(QFileIconProvider::Drive); + icon = mFileIconProvider->icon(QFileIconProvider::File); + + for (TInt i=0; iitemCount(); i++) { + FbDriveEntry driveEntry = mFolderSelectorWrapper->getDriveEntry(i); + + const QString SimpleDriveEntry("%1: <%2>"); + QString diskName = SimpleDriveEntry.arg(driveEntry.driveLetter()).arg(driveEntry.mediaTypeString()); + + mFolderList->addItem(icon, diskName); + } + + if (actions().count() > 1) { + actions().at(0)->setEnabled(false); + } + } else { + const QString SimpleFileEntry("%1"); + icon = mFileIconProvider->icon(QFileIconProvider::Folder); + + for (TInt i=0; iitemCount(); i++) { + FbFileEntry fileEntry = mFolderSelectorWrapper->getFileEntry(i); + + QString fileName = SimpleFileEntry.arg(fileEntry.name()); ///*<< fileEntry.IconId()*/ + + mFolderList->addItem(icon, fileName); + } + + if (actions().count() > 1) { + actions().at(0)->setEnabled(true); + } + } +} + +/** + * Slot called when list item is activated + */ +void FbFolderSelectionDialog::activated(HbListWidgetItem * item) +{ + int row = mFolderList->row(item); + if (mFolderSelectorWrapper->isDriveListViewActive()) { + mFolderSelectorWrapper->moveDownToDirectory(row); + } else if (row >= 0) { + mFolderSelectorWrapper->moveDownToDirectory(row); + } +} + +/** + * Slot handling the move up button to move up one leve in directory hierarchy + */ +void FbFolderSelectionDialog::moveUpPressed() +{ + mFolderSelectorWrapper->moveUpOneLevel(); +} + +void FbFolderSelectionDialog::acceptTriggered() +{ + accept(); +} + +// --------------------------------------------------------------------------- + +/** + * Constructor + */ +FbCopyToFolderSelectionDialog::FbCopyToFolderSelectionDialog(QGraphicsItem *parent) : + FbFolderSelectionDialog(parent) +{ + if (headingWidget()) { + mTitle->setPlainText(QString("Copy to")); + } + if (actions().count() > 1) { + actions().at(0)->setText(QString("Copy here")); + } +} + +// --------------------------------------------------------------------------- + +/** + * Constructor + */ +FbMoveToFolderSelectionDialog::FbMoveToFolderSelectionDialog(QGraphicsItem *parent) : + FbFolderSelectionDialog(parent) +{ + if (headingWidget()) { + mTitle->setPlainText(QString("Move to")); + } + if (actions().count() > 1) { + actions().at(0)->setText(QString("Move here")); + } +} + +// End of file diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/ui/src/fbfolderselectorwrapper.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/ui/src/fbfolderselectorwrapper.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,134 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "fbfolderselectorwrapper.h" +#include "FBFolderSelector.h" + +#include + +// --------------------------------------------------------------------------- + +/** + * Constructor + */ +FbFolderSelectorWrapper::FbFolderSelectorWrapper() + : mDestinationFolderSelector(0) +{ +} + +/** + * Destructor + */ +FbFolderSelectorWrapper::~FbFolderSelectorWrapper() +{ + if (mDestinationFolderSelector) + delete mDestinationFolderSelector; +} + +/** + * Initializes Engine Wrapper + * @return true if engine was started successfully + */ +bool FbFolderSelectorWrapper::init() +{ + TFileName destinationFolder; + + TRAPD(err, mDestinationFolderSelector = CFileBrowserFolderSelector::NewL(destinationFolder, this)); + if (err != KErrNone) { + return false; + } else { + //TRAP_IGNORE(mEngine->ActivateEngineL()); + //mSettings = FileBrowserSettings(&mEngine->Settings()); + return true; + } +} + +/** + * Return current path + */ +QString FbFolderSelectorWrapper::currentPath() const +{ + return QString::fromUtf16(mDestinationFolderSelector->CurrentPath().Ptr(), + mDestinationFolderSelector->CurrentPath().Length()); +} + +/** + * Return whether drive list view is active + */ +bool FbFolderSelectorWrapper::isDriveListViewActive() const +{ + return mDestinationFolderSelector->IsDriveListViewActive(); +} + +/** + * Returns number of either drives or files depending on current view + */ +int FbFolderSelectorWrapper::itemCount() const +{ + if (isDriveListViewActive()) { + return mDestinationFolderSelector->DriveEntryList()->Count(); + } else { + return mDestinationFolderSelector->FileEntryList()->Count(); + } +} + +/** + * Returns drive entry for given \a index + */ +FbDriveEntry FbFolderSelectorWrapper::getDriveEntry(const int index) const +{ + TDriveEntry driveEntry; + if (mDestinationFolderSelector->DriveEntryList()->Count() > index && index >= 0) { + driveEntry = mDestinationFolderSelector->DriveEntryList()->At(index); + } + return FbDriveEntry(driveEntry); +} + +/** + * Returns file entry for given \a index + */ +FbFileEntry FbFolderSelectorWrapper::getFileEntry(const int index) const +{ + TFileEntry fileEntry; + if (mDestinationFolderSelector->FileEntryList()->Count() > index && index >= 0) { + fileEntry = mDestinationFolderSelector->FileEntryList()->At(index); + } + return FbFileEntry(fileEntry); +} + +/** + * Move down to selected item by \a index + */ +void FbFolderSelectorWrapper::moveDownToDirectory(int index) +{ + mDestinationFolderSelector->MoveDownToDirectoryL(index); +} + +/** + * Move up from folder + */ +void FbFolderSelectorWrapper::moveUpOneLevel() +{ + mDestinationFolderSelector->MoveUpOneLevelL(); +} + +void FbFolderSelectorWrapper::InformFolderSelectionChanged() +{ + emit FolderSelectionChanged(); +} + +// --------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/ui/src/fbmainwindow.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/ui/src/fbmainwindow.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,195 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#include +#include + +#include "fbmainwindow.h" +#include "enginewrapper.h" +#include "fbfileview.h" +#include "fbdriveview.h" +#include "fbsettingsview.h" +#include "fbeditorview.h" +#include "fbsearchview.h" +#include "fbattributesview.h" +#include "notifications.h" + +#include + +FbMainWindow::FbMainWindow(QWidget *parent) + : HbMainWindow(parent), + mEngineWrapper(0), + mDriveView(0), + mFileView(0), + mSettingsView(0), + mEditorView(0), + mSearchView(0), + mAttributesView(0), + mPreviousView(0) +{ +} + +FbMainWindow::~FbMainWindow () +{ + if (mEngineWrapper) { + delete mEngineWrapper; + } +} + +void FbMainWindow::init() +{ + // Create Engine Wrapper and initialize it + mEngineWrapper = new EngineWrapper(); + int error = mEngineWrapper->init(); + Q_ASSERT_X(error == 1, "FileBrowser", "Engine initialization failed"); + + // Create drive view + mDriveView = new FbDriveView(); + connect(mDriveView, SIGNAL(aboutToShowSettingsView()), this, SLOT(openSettingsView())); + connect(mDriveView, SIGNAL(aboutToShowFileView()), this, SLOT(openFileView())); + mDriveView->init(mEngineWrapper); + addView(mDriveView); + + // Create file view + mFileView = new FbFileView(); + connect(mFileView, SIGNAL(aboutToShowSettingsView()), this, SLOT(openSettingsView())); + connect(mFileView, SIGNAL(aboutToShowDriveView()), this, SLOT(openDriveView())); + mFileView->init(mEngineWrapper); + addView(mFileView); + + // Create settings view + mSettingsView = new FbSettingsView(*mEngineWrapper); + connect(mSettingsView, SIGNAL(finished(bool)), this, SLOT(openPreviousBrowserView())); + addView(mSettingsView); + + // Create editor view + mEditorView = new FbEditorView(); + connect(mFileView, SIGNAL(aboutToShowEditorView(const QString &, bool)), this, SLOT(openEditorView(const QString &, bool))); + connect(mEditorView, SIGNAL(finished(bool)), this, SLOT(openFileView())); + addView(mEditorView); + + // Create Search view + connect(mDriveView, SIGNAL(aboutToShowSearchView(QString)), this, SLOT(openSearchView(QString))); + connect(mFileView, SIGNAL(aboutToShowSearchView(QString)), this, SLOT(openSearchView(QString))); + + // Create Attributes view + connect(mFileView, SIGNAL(aboutToShowAttributesView(const QString &, quint32 &, quint32 &, bool &)), + this, SLOT(openAttributesView(const QString &, quint32 &, quint32 &, bool &))); + + // Show ApplicationView at startup + setCurrentView(mDriveView); + mPreviousView = mDriveView; + + // Show HbMainWindow + show(); +} + + +void FbMainWindow::openPreviousBrowserView() +{ + mDriveView->refreshList(); + mFileView->refreshList(); + setCurrentView(mPreviousView); +} + +void FbMainWindow::openFileBrowserView(bool accepted) +{ + mDriveView->refreshList(); + mFileView->refreshList(); + if (accepted) { + setCurrentView(mFileView); + } else { + setCurrentView(mPreviousView); + } +} + +void FbMainWindow::openDriveView() +{ + mDriveView->refreshList(); + setCurrentView(mDriveView); + mPreviousView = mDriveView; +} + +void FbMainWindow::openFileView() +{ + mDriveView->refreshList(); + mFileView->refreshList(); + setCurrentView(mFileView); + mPreviousView = mFileView; +} + +void FbMainWindow::openSettingsView() +{ + mSettingsView->initDataForm(); + setCurrentView(mSettingsView); +} + +void FbMainWindow::openEditorView(const QString &fileName, bool flagReadOnly) +{ + mEditorView->open(fileName, flagReadOnly); + setCurrentView(mEditorView); +} + +void FbMainWindow::openSearchView(const QString &path) +{ + if (!mSearchView) { + mSearchView = new FbSearchView(); + connect(mSearchView, SIGNAL(finished(bool)), this, SLOT(closeSearchView(bool))); + mSearchView->open(mEngineWrapper->getFileSearchAttributes(), path); + addView(mSearchView); + setCurrentView(mSearchView); + } +} + +void FbMainWindow::closeSearchView(bool accepted) +{ + if (accepted) { + mSearchView->startFileSearch(mEngineWrapper); + } + + removeView(mSearchView); + mSearchView->deleteLater(); + mSearchView = 0; + openFileView(); +} + +void FbMainWindow::openAttributesView(const QString &attributesViewTitle, + quint32 &setAttributesMask, + quint32 &clearAttributesMask, + bool &recurse) +{ + if (!mAttributesView) { + // Create attributes view + mAttributesView = new FbAttributesView(setAttributesMask, clearAttributesMask, recurse); + connect(mAttributesView, SIGNAL(finished(bool)), this, SLOT(closeAttributesView(bool))); + mAttributesView->setTitle(attributesViewTitle); + addView(mAttributesView); + setCurrentView(mAttributesView); + } +} + +void FbMainWindow::closeAttributesView(bool accepted) +{ + if (accepted) { + mEngineWrapper->setAttributes(mAttributesView->setAttributesMask(), mAttributesView->clearAttributesMask(), mAttributesView->recurse()); + } + openFileView(); + removeView(mAttributesView); + mAttributesView->deleteLater(); + mAttributesView = 0; +} + +// End of file diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/ui/src/fbpropertiesdialog.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/ui/src/fbpropertiesdialog.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,128 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "fbpropertiesdialog.h" + +#include +#include +#include +#include +#include + +#include +#include + +/** + * Constructor + */ +FbPropertiesDialog::FbPropertiesDialog(QGraphicsItem *parent) : + HbDialog(parent), + mTitle(0), + mGridLayout(0) +{ + setAttribute(Qt::WA_DeleteOnClose); + setDismissPolicy(HbPopup::TapOutside); + setTimeout(HbPopup::NoTimeout); + + createHeading(); + createContentWidget(); + createToolBar(); +} + +/** + * Destructor + */ +FbPropertiesDialog::~FbPropertiesDialog() +{ +} + +/** + * Set \a title into heading widget label + */ +void FbPropertiesDialog::setTitle(const QString &title) +{ + mTitle->setText(title); +} + +/** + * Fill content list with property list \a propertyList + */ +void FbPropertiesDialog::setProperties(const QVector > &properties) +{ + QString previousProperty(""); + QPair propertyPair; + HbLabel *propertyNameLabel; + HbLabel *propertyValueLabel; + for (int i(0), ie(properties.count()); i < ie; ++i) + { + propertyPair = properties.at(i); + propertyNameLabel = new HbLabel(); + if (propertyPair.first != previousProperty) { + propertyNameLabel->setPlainText(propertyPair.first); + propertyNameLabel->setElideMode(Qt::ElideNone); + propertyNameLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); + } + mGridLayout->addItem(propertyNameLabel, i, 0); + previousProperty = propertyPair.first; + + propertyValueLabel = new HbLabel(); + propertyValueLabel->setPlainText(propertyPair.second); + propertyValueLabel->setTextWrapping(Hb::TextWrapAnywhere); + mGridLayout->addItem(propertyValueLabel, i, 1); + } +} + +/** + * Create dialog heading widget + */ +void FbPropertiesDialog::createHeading() +{ + mTitle = new HbMarqueeItem(this); + mTitle->setLoopCount(1); + connect(this, SIGNAL(aboutToShow()), mTitle, SLOT(startAnimation())); + + // TODO later check if this is needed, default color is magenta, even if black theme used + QColor col = HbColorScheme::color("qtc_textedit_normal"); + if (col.isValid()) { + mTitle->setTextColor(col); + } + + setHeadingWidget(mTitle); +} + +/** + * Create dialog content widget as a grid + */ +void FbPropertiesDialog::createContentWidget() +{ + mGridLayout = new QGraphicsGridLayout(); + + QGraphicsWidget *contentWidget = new QGraphicsWidget; + contentWidget->setLayout(mGridLayout); + setContentWidget(contentWidget); +} + +/** + * Create dialog toolbar + */ +void FbPropertiesDialog::createToolBar() +{ + HbAction *rejectAction = new HbAction(QString("Cancel"), this); + addAction(rejectAction); +} + +// End of file diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/ui/src/fbsearchview.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/ui/src/fbsearchview.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,207 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "fbsearchview.h" +#include "enginewrapper.h" +#include "notifications.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +const QStringList RECURSEMODES = (QStringList() << "Non-recursive" << "Recursive"); +const QString AcceptActionText = "Search"; +const QString RejectActionText = "Cancel"; + + +FbSearchView::FbSearchView(QGraphicsItem *parent) + : HbView(parent), + mAttributes(), + mResults(), + mForm(0), + mSearchFileNameItem(0), + mWildCardItem(0), + mHasString(0), + mRecurse(0), + mMinSize(0), + mMaxSize(0), + mMinDate(0), + mMaxDate(0), + mPath(), + mProgressDialog(0) +{ + // Set title and add this view to main window + setTitle("Search"); + + // Override back navigation action + HbAction *leaveViewAction = new HbAction(Hb::BackNaviAction, this); + connect(leaveViewAction, SIGNAL(triggered()), this, SLOT(reject())); + setNavigationAction(leaveViewAction); + + initDataForm(); + createToolbar(); +} + +FbSearchView::~FbSearchView() +{ +} + +void FbSearchView::initDataForm() { + mForm = new HbDataForm(/*HbFormView::ModeEdit,*/ this); + HbDataFormModel *model = new HbDataFormModel(); + + mSearchFileNameItem = new HbDataFormModelItem(HbDataFormModelItem::TextItem); + mSearchFileNameItem->setLabel("Search dir: "); + + mWildCardItem = new HbDataFormModelItem(HbDataFormModelItem::TextItem); + mWildCardItem->setLabel("Wildcards: "); + + mHasString = new HbDataFormModelItem(HbDataFormModelItem::TextItem); + mHasString->setLabel("Has string: "); + + mRecurse = new HbDataFormModelItem(HbDataFormModelItem::ComboBoxItem); + mRecurse->setLabel("Recurse: "); + mRecurse->setContentWidgetData("items", RECURSEMODES); + + mMinSize = new HbDataFormModelItem(HbDataFormModelItem::TextItem); + mMinSize->setLabel("Min size: "); + + mMaxSize = new HbDataFormModelItem(HbDataFormModelItem::TextItem); + mMaxSize->setLabel("Max size: "); + + mMinDate = new HbDataFormModelItem(HbDataFormModelItem::TextItem); + mMinDate->setLabel("Min date: "); + mMinDate->setContentWidgetData("text", "01/01/1980"); + + mMaxDate = new HbDataFormModelItem(HbDataFormModelItem::TextItem); + mMaxDate->setLabel("Max date: "); + mMaxDate->setContentWidgetData("text", "31/12/2060"); + + model->appendDataFormItem(mSearchFileNameItem); + model->appendDataFormItem(mWildCardItem); + model->appendDataFormItem(mHasString); + model->appendDataFormItem(mRecurse); + model->appendDataFormItem(mMinSize); + model->appendDataFormItem(mMaxSize); + model->appendDataFormItem(mMinDate); + model->appendDataFormItem(mMaxDate); + mForm->setModel(model); + + QGraphicsLinearLayout* layout = new QGraphicsLinearLayout(Qt::Vertical,this); + layout->addItem(mForm); + setLayout(layout); +} + +void FbSearchView::createToolbar() +{ + HbToolBar *toolBar = new HbToolBar(this); + HbAction *acceptAction = new HbAction(AcceptActionText); + connect(acceptAction, SIGNAL(triggered()), this, SLOT(accept())); + toolBar->addAction(acceptAction); + + HbAction *rejectAction = new HbAction(RejectActionText); + connect(rejectAction, SIGNAL(triggered()), this, SLOT(reject())); + toolBar->addAction(rejectAction); + + setToolBar(toolBar); +} + +void FbSearchView::loadAttributes() +{ + // set data: + mSearchFileNameItem->setContentWidgetData("text", mPath); +// mSearchFileNameItem->setContentWidgetData("text", mAttributes.mSearchDir); + if (!mAttributes.mDefaultWildCard) { + mWildCardItem->setContentWidgetData("text", mAttributes.mWildCards); + } + mHasString->setContentWidgetData("text", mAttributes.mTextInFile); + + mRecurse->setContentWidgetData("selected", mAttributes.mRecurse); + + mMinSize->setContentWidgetData("text", mAttributes.mMinSize); + mMaxSize->setContentWidgetData("text", mAttributes.mMaxSize); + + mMinDate->setContentWidgetData("text", mAttributes.mMinDate); + mMaxDate->setContentWidgetData("text", mAttributes.mMaxDate); +} + +/** + * Reads form items and saves values of them into member variable mAttributes + */ +void FbSearchView::readFormItems() +{ + mAttributes.mSearchDir = mSearchFileNameItem->contentWidgetData("text").toString(); + + mAttributes.mDefaultWildCard = false; + QString wildCard = mWildCardItem->contentWidgetData("text").toString(); + if (wildCard.trimmed().isEmpty()) { + wildCard = QString("*"); + mAttributes.mDefaultWildCard = true; + } + mAttributes.mWildCards = wildCard; + mAttributes.mTextInFile = mHasString->contentWidgetData("text").toString(); + mAttributes.mMinSize = mMinSize->contentWidgetData("text").toInt(); + mAttributes.mMaxSize = mMaxSize->contentWidgetData("text").toInt(); + mAttributes.mMinDate = mMinDate->contentWidgetData("text").toDate(); + mAttributes.mMaxDate = mMaxDate->contentWidgetData("text").toDate(); + mAttributes.mRecurse = mRecurse->contentWidgetData("selected").toBool(); +} + +void FbSearchView::open(const SearchAttributes &searchAttributes, const QString &path) +{ + mPath = path; + // get settings from engine; + mAttributes = searchAttributes; + // load file search attribute values from FB engine: + loadAttributes(); +} + +void FbSearchView::startFileSearch(EngineWrapper *engineWrapper) +{ + // save form data values and set them as search attributes into FB engine. + readFormItems(); + engineWrapper->setFileSearchAttributes(mAttributes); + + bool err = engineWrapper->searchFiles(); + + // show results of file search: + mResults = engineWrapper->getSearchResults(); + + QString noteMsg("%1 entries found"); + Notifications::showInformationNote(noteMsg.arg(engineWrapper->itemCount())); +} + +void FbSearchView::accept() +{ + emit finished(true); +} + +void FbSearchView::reject() +{ + emit finished(false); +} diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/ui/src/fbsettingsview.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/ui/src/fbsettingsview.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,243 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "fbsettingsview.h" +#include "enginewrapper.h" +#include "filebrowsersettings.h" + +#include +#include +#include +#include +#include +#include + +#include + +const QStringList DisplayModeModes = (QStringList() << "Full screen" << "Normal"); +const QStringList FileViewModes = (QStringList() << "Simple" << "Extended"); +const QStringList Modes = (QStringList() << "Yes" << "No"); +const QString YesText = QString("Yes"); +const QString NoText = QString("No"); +const QString acceptActionText = "OK"; +const QString rejectActionText = "Cancel"; + +FbSettingsView::FbSettingsView(EngineWrapper &engineWrapper) : + mEngineWrapper(engineWrapper), + mForm(0), + mDisplayModeItem(0), + mFileViewItem(0), + mShowDirectoryInfoItem(0), + mShowAssociatedIconsItem(0), + mRememberFolderOnExitItem(0), + mRememberLastFolderItem(0), + mShowToolbarItem(0), + mSupportNetDrivesItem(0), + mBypassPlatformSecurityItem(0), + mUnlockFilesViaSBItem(0), + mIgnoreProtectionAttributesItem(0), + mNoROAttributeCopyFromZItem(0) +{ + setTitle("Settings"); + + // Override back navigation action + HbAction *leaveViewAction = new HbAction(Hb::BackNaviAction, this); + connect(leaveViewAction, SIGNAL(triggered()), this, SLOT(reject())); + setNavigationAction(leaveViewAction); + + initDataForm(); + createToolbar(); +} + +FbSettingsView::~FbSettingsView() +{ +} + +void FbSettingsView::initDataForm() +{ + mForm = new HbDataForm(this); + HbDataFormModel *model = new HbDataFormModel(); + +// connect(model, SIGNAL(dataChanged(QModelIndex, QModelIndex)), +// this, SLOT(toggleChange(QModelIndex, QModelIndex))); + + + // TODO to be done +// mDisplayModeItem = new HbDataFormModelItem(HbDataFormModelItem::ComboBoxItem); +// mDisplayModeItem->setLabel("Display mode: "); +// mDisplayModeItem->setContentWidgetData("items", DisplayModeModes); +// +// mFileViewItem = new HbDataFormModelItem(HbDataFormModelItem::ComboBoxItem); +// mFileViewItem->setLabel("File view: "); +// mFileViewItem->setContentWidgetData("items", FileViewModes); +// +// mShowDirectoryInfoItem = new HbDataFormModelItem(HbDataFormModelItem::ToggleValueItem); +// mShowDirectoryInfoItem->setLabel("Show directory info: "); +// mShowDirectoryInfoItem->setContentWidgetData(QString("text"), YesText); +// mShowDirectoryInfoItem->setContentWidgetData(QString("additionalText"), NoText); +// +// mShowAssociatedIconsItem = new HbDataFormModelItem(HbDataFormModelItem::ToggleValueItem); +// mShowAssociatedIconsItem->setLabel("Show associated icons: "); +// mShowAssociatedIconsItem->setContentWidgetData(QString("text"), YesText); +// mShowAssociatedIconsItem->setContentWidgetData(QString("additionalText"), NoText); +// +// mRememberFolderOnExitItem = new HbDataFormModelItem(HbDataFormModelItem::ToggleValueItem); +// mRememberFolderOnExitItem->setLabel("Remember folder on exit: "); +// mRememberFolderOnExitItem->setContentWidgetData(QString("text"), YesText); +// mRememberFolderOnExitItem->setContentWidgetData(QString("additionalText"), NoText); +// +// mRememberLastFolderItem = new HbDataFormModelItem(HbDataFormModelItem::ToggleValueItem); +// mRememberLastFolderItem->setLabel("Remember last folder: "); +// mRememberLastFolderItem->setContentWidgetData(QString("text"), YesText); +// mRememberLastFolderItem->setContentWidgetData(QString("additionalText"), NoText); +// +// mShowToolbarItem = new HbDataFormModelItem(HbDataFormModelItem::ToggleValueItem); +// mShowToolbarItem->setLabel("Show toolbar: "); +// mShowToolbarItem->setContentWidgetData(QString("text"), YesText); +// mShowToolbarItem->setContentWidgetData(QString("additionalText"), NoText); + + mSupportNetDrivesItem = new HbDataFormModelItem(HbDataFormModelItem::ToggleValueItem); + mSupportNetDrivesItem->setLabel("Support net drives: "); + mSupportNetDrivesItem->setContentWidgetData(QString("text"), YesText); + mSupportNetDrivesItem->setContentWidgetData(QString("additionalText"), NoText); + + mBypassPlatformSecurityItem = new HbDataFormModelItem(HbDataFormModelItem::ToggleValueItem); + mBypassPlatformSecurityItem->setLabel("Bypass plat.security: "); + mBypassPlatformSecurityItem->setContentWidgetData(QString("text"), YesText); + mBypassPlatformSecurityItem->setContentWidgetData(QString("additionalText"), NoText); + + mUnlockFilesViaSBItem = new HbDataFormModelItem(HbDataFormModelItem::ToggleValueItem); + mUnlockFilesViaSBItem->setLabel("Unlock files via SB: "); + mUnlockFilesViaSBItem->setContentWidgetData(QString("text"), YesText); + mUnlockFilesViaSBItem->setContentWidgetData(QString("additionalText"), NoText); + + mIgnoreProtectionAttributesItem = new HbDataFormModelItem(HbDataFormModelItem::ToggleValueItem); + mIgnoreProtectionAttributesItem->setLabel("Ign. protection atts: "); + mIgnoreProtectionAttributesItem->setContentWidgetData(QString("text"), YesText); + mIgnoreProtectionAttributesItem->setContentWidgetData(QString("additionalText"), NoText); + + mNoROAttributeCopyFromZItem = new HbDataFormModelItem(HbDataFormModelItem::ToggleValueItem); + mNoROAttributeCopyFromZItem->setLabel("No RO-att copy from Z: "); + mNoROAttributeCopyFromZItem->setContentWidgetData(QString("text"), YesText); + mNoROAttributeCopyFromZItem->setContentWidgetData(QString("additionalText"), NoText); + + // load file search attribute values from FB engine: + loadSettings(mEngineWrapper.settings()); + +// model->appendDataFormItem(mDisplayModeItem); +// model->appendDataFormItem(mFileViewItem); +// model->appendDataFormItem(mShowDirectoryInfoItem); +// model->appendDataFormItem(mShowAssociatedIconsItem); +// model->appendDataFormItem(mRememberFolderOnExitItem); +// model->appendDataFormItem(mRememberLastFolderItem); +// model->appendDataFormItem(mShowToolbarItem); + + model->appendDataFormItem(mSupportNetDrivesItem); + model->appendDataFormItem(mBypassPlatformSecurityItem); + model->appendDataFormItem(mUnlockFilesViaSBItem); + model->appendDataFormItem(mIgnoreProtectionAttributesItem); + model->appendDataFormItem(mNoROAttributeCopyFromZItem); + + mForm->setModel(model); + + QGraphicsLinearLayout* layout = new QGraphicsLinearLayout(Qt::Vertical,this); + layout->addItem(mForm); + setLayout(layout); +} + +void FbSettingsView::createToolbar() +{ + HbToolBar *toolBar = new HbToolBar(this); + HbAction *acceptAction = new HbAction(acceptActionText); + connect(acceptAction, SIGNAL(triggered()), this, SLOT(accept())); + toolBar->addAction(acceptAction); + + HbAction *rejectAction = new HbAction(rejectActionText); + connect(rejectAction, SIGNAL(triggered()), this, SLOT(reject())); + toolBar->addAction(rejectAction); + + setToolBar(toolBar); +} + +/** + Set form item values from settings \a settings. + */ +void FbSettingsView::loadSettings(const FileBrowserSettings &settings) +{ +// mDisplayModeItem->setContentWidgetData("text", settings.displayMode()); +// mFileViewItem->setContentWidgetData("text", settings.fileViewMode()); +// mShowDirectoryInfoItem->setContentWidgetData("text", settings.showSubDirectoryInfo()); +// mShowAssociatedIconsItem->setContentWidgetData("text", settings.showAssociatedIcons()); +// mRememberFolderOnExitItem->setContentWidgetData("text", settings.rememberFolderSelection()); +// mRememberLastFolderItem->setContentWidgetData("text", settings.rememberLastPath()); +// mShowToolbarItem->setContentWidgetData("text", settings.enableToolbar()); + + mSupportNetDrivesItem->setContentWidgetData("text", settings.supportNetworkDrives() ? YesText : NoText); + mSupportNetDrivesItem->setContentWidgetData("additionalText", !settings.supportNetworkDrives() ? YesText : NoText); + + mBypassPlatformSecurityItem->setContentWidgetData("text", settings.bypassPlatformSecurity() ? YesText : NoText); + mBypassPlatformSecurityItem->setContentWidgetData("additionalText", !settings.bypassPlatformSecurity() ? YesText : NoText); + + mUnlockFilesViaSBItem->setContentWidgetData("text", settings.removeFileLocks() ? YesText : NoText); + mUnlockFilesViaSBItem->setContentWidgetData("additionalText", !settings.removeFileLocks() ? YesText : NoText); + + mIgnoreProtectionAttributesItem->setContentWidgetData("text", settings.ignoreProtectionsAttributes() ? YesText : NoText); + mIgnoreProtectionAttributesItem->setContentWidgetData("additionalText", !settings.ignoreProtectionsAttributes() ? YesText : NoText); + + mNoROAttributeCopyFromZItem->setContentWidgetData("text", settings.removeROMWriteProrection() ? YesText : NoText); + mNoROAttributeCopyFromZItem->setContentWidgetData("additionalText", !settings.removeROMWriteProrection() ? YesText : NoText); +} + +/** + Store form item data into \a settings + */ +void FbSettingsView::saveSettings(FileBrowserSettings &settings) +{ +// settings.setDisplayMode(mDisplayModeItem->contentWidgetData("text").toInt()); +// settings.setFileViewMode(mFileViewItem->contentWidgetData("text").toInt()); +// settings.setShowSubDirectoryInfo(mShowDirectoryInfoItem->contentWidgetData("text").toBool()); +// settings.setShowAssociatedIcons(mShowAssociatedIconsItem->contentWidgetData("text").toBool()); +// settings.setRememberLastPath(mRememberFolderOnExitItem->contentWidgetData("text").toBool()); +// //settings.setLastPath(mRememberLastFolderItem->contentWidgetData("text").toString()); +// settings.setRememberFolderSelection(mRememberLastFolderItem->contentWidgetData("text").toBool()); +// settings.setEnableToolbar(mShowToolbarItem->contentWidgetData("text").toBool()); + + settings.setSupportNetworkDrives(mSupportNetDrivesItem->contentWidgetData("text").toString() == YesText); + settings.setBypassPlatformSecurity(mBypassPlatformSecurityItem->contentWidgetData("text").toString() == YesText); + settings.setRemoveFileLocks(mUnlockFilesViaSBItem->contentWidgetData("text").toString() == YesText); + settings.setIgnoreProtectionsAttributes(mIgnoreProtectionAttributesItem->contentWidgetData("text").toString() == YesText); + settings.setRemoveROMWriteProrection(mNoROAttributeCopyFromZItem->contentWidgetData("text").toString() == YesText); +} + +void FbSettingsView::constructMenu() +{ + +} + +void FbSettingsView::accept() +{ + saveSettings(mEngineWrapper.settings()); + mEngineWrapper.saveSettings(); + emit finished(true); +} + +void FbSettingsView::reject() +{ + emit finished(false); +} + +// End of file diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/ui/src/filebrowser.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/ui/src/filebrowser.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include +#include + +#include "fbmainwindow.h" + + +int main(int argc, char *argv[]) +{ + HbApplication app(argc, argv); + FbMainWindow window; + window.init(); + int result = app.exec(); + + return result; +} diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/ui/src/filebrowsersortfilterproxymodel.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/ui/src/filebrowsersortfilterproxymodel.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "filebrowsersortfilterproxymodel.h" + +#include +#include + +FileBrowserSortFilterProxyModel::FileBrowserSortFilterProxyModel(QObject *parent) + : QSortFilterProxyModel(parent) +{ +} + +bool FileBrowserSortFilterProxyModel::filterAcceptsRow(int sourceRow, + const QModelIndex &sourceParent) const +{ + QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent); + + QVariant displayRole = index.data(Qt::DisplayRole); + QStringList stringList; + if (displayRole.isValid()) { + if (displayRole.canConvert()) { + stringList.append(displayRole.toString()); + } else if (displayRole.canConvert()) { + stringList = displayRole.toStringList(); + } + QString itemName = stringList.at(0); + //QString criteria = filterRegExp().pattern(); + QString criteria = filterCriteria(); + if (!criteria.isEmpty()) { + bool contains = itemName.contains(criteria, Qt::CaseInsensitive); + return contains; + } else { + //invalidateFilter(); + return true; + } + } + return true; +} + +void FileBrowserSortFilterProxyModel::setFilterCriteria(const QString &criteria) +{ + mFilterCriteria = criteria; + invalidate(); +} + + +// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/ui/src/notifications.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/ui/src/notifications.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,79 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#include "notifications.h" + +#include +#include +#include + +// --------------------------------------------------------------------------- + +void Notifications::showMessageBox(HbMessageBox::MessageBoxType type, const QString &text, const QString &label, int timeout) +{ + HbMessageBox *messageBox = new HbMessageBox(type); + messageBox->setText(text); + if (label.length()) { + HbLabel *header = new HbLabel(label, messageBox); + messageBox->setHeadingWidget(header); + } + messageBox->setAttribute(Qt::WA_DeleteOnClose); + messageBox->setTimeout(timeout); + messageBox->open(); +} + +void Notifications::showAboutNote() +{ + showMessageBox(HbMessageBox::MessageTypeInformation, + "Version 5.3.0 - 24th September 2010. Copyright © 2010 Nokia Corporation" + "and/or its subsidiary(-ies). All rights reserved." + "Licensed under Eclipse Public License v1.0.", + "About File Browser" + ); +} + +// --------------------------------------------------------------------------- + +void Notifications::showInformationNote(const QString &text, const QString &title) +{ + showMessageBox(HbMessageBox::MessageTypeInformation, text, title, 3000); +} + +// --------------------------------------------------------------------------- + +void Notifications::showErrorNote(const QString &text, bool noTimeout) +{ + showMessageBox(HbMessageBox::MessageTypeWarning, text, "", + noTimeout ? HbPopup::NoTimeout : 3000 /*HbPopup::StandardTimeout*/); +} + +// --------------------------------------------------------------------------- + +void Notifications::showConfirmationNote(const QString &text, bool noTimeout) +{ + showMessageBox(HbMessageBox::MessageTypeInformation, text, "", + noTimeout ? HbPopup::NoTimeout : 3000 /*HbPopup::ConfirmationNoteTimeout*/); +} + +// --------------------------------------------------------------------------- + +bool Notifications::showConfirmationQuery(const QString &aText) +{ + Q_UNUSED(aText); + return false; //HbMessageBox::question(aText); +} + +// --------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/ui/ui.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/ui/ui.pro Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,132 @@ +# +# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# +# +TEMPLATE = app +TARGET = FileBrowser +DEPENDPATH += . +INCLUDEPATH += ./inc +load(hb.prf) +symbian:CONFIG -= symbian_i18n + +HEADERS += ./inc/menuaction.h \ + ./inc/enginewrapper.h \ + ./inc/fbmainwindow.h \ + ./inc/fbdrivelistviewitem.h \ + ./inc/fbdrivemodel.h \ + ./inc/fbdriveentry.h \ + ./inc/fbdriveview.h \ + ./inc/fbfilelistviewitem.h \ + ./inc/fbfilemodel.h \ + ./inc/fbfileentry.h \ + ./inc/fbfileview.h \ + ./inc/filebrowsersortfilterproxymodel.h \ + ./inc/filebrowsersettings.h \ + ./inc/fbsettingsview.h \ + ./inc/fbeditorview.h \ + ./inc/fbsearchview.h \ + ./inc/fbattributesview.h \ + ./inc/fbfolderselectiondialog.h \ + ./inc/fbfolderselectorwrapper.h \ + ./inc/fbpropertiesdialog.h \ + ./inc/notifications.h +SOURCES += ./src/filebrowser.cpp \ + ./src/enginewrapper.cpp \ + ./src/fbmainwindow.cpp \ + ./src/fbdrivelistviewitem.cpp \ + ./src/fbdrivemodel.cpp \ + ./src/fbdriveentry.cpp \ + ./src/fbdriveview.cpp \ + ./src/fbfilelistviewitem.cpp \ + ./src/fbfilemodel.cpp \ + ./src/fbfileentry.cpp \ + ./src/fbfileview.cpp \ + ./src/filebrowsersortfilterproxymodel.cpp \ + ./src/fbsettingsview.cpp \ + ./src/fbeditorview.cpp \ + ./src/fbsearchview.cpp \ + ./src/fbattributesview.cpp \ + ./src/fbfolderselectiondialog.cpp \ + ./src/fbfolderselectorwrapper.cpp \ + ./src/fbpropertiesdialog.cpp \ + ./src/notifications.cpp +RESOURCES += ./ui.qrc + +symbian { + INCLUDEPATH += ../ + LIBS += -leikcore \ + -lcommonengine \ + -ltzclient \ + -lapmime \ + -lcommonui \ + -leuser \ + -lapparc \ + -lcone \ + -lws32 \ + -lfbscli \ + -lImageConversion \ + -lPlatformEnv \ + -lapgrfx \ + -lefsrv \ + -lbafl \ + -lCentralRepository \ + -lmediaclientaudio \ + -lestor \ + -lgdi \ + -legul \ + -lmsgs \ + -lezlib \ + -lcdlengine \ + -lremconcoreapi \ + -lremconinterfacebase \ + -lsbeclient \ + -lhash \ + -letext \ + -lcharconv \ + #ifndef FILEBROWSER_LITE + -lfilebrowserfileopclient + #endif" + + INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE + + HEADERS += ../engine/engine.h \ + ../engine/FBFileUtils.h \ + ../engine/FBFileOps.h \ + ../engine/FB.hrh \ + ../engine/FBStd.h \ + ../engine/FBTraces.h \ + ../engine/FBFolderSelector.h \ + #ifndef FILEBROWSER_LITE + ../fileopclient/inc/FBFileOpClient.h + #endif + SOURCES += ../engine/engine.cpp \ + ../engine/FBFileUtils.cpp \ + ../engine/FBFileOps.cpp \ + ../engine/FBFolderSelector.cpp + RSS_RULES += "group_name = \"RnD Tools\";" + + MMP_RULES -= PAGED + MMP_RULES *= UNPAGEDDATA + MMP_RULES += SMPSAFE + + TARGET.CAPABILITY = NetworkServices LocalServices CAP_APPLICATION AllFiles DiskAdmin + TARGET.UID3 = 0xE85157B0 + TARGET.VID = 0x101FB657 // Nokia + TARGET.EPOCHEAPSIZE = 0x20000 0x4000000 // Min 128Kb, Max 64Mb + ICON = ../icons/qgn_menu_filebrowser.svg +} else { + error("Only Symbian supported!") +} + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/filebrowser/ui/ui.qrc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/filebrowser/ui/ui.qrc Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,10 @@ + + + ../icons/qtg_mono_filebrowser_parent_folder.svg + ../icons/qtg_mono_filebrowser_search.svg + ../icons/qtg_mono_filebrowser_selection_mode.svg + ../icons/qtg_mono_filebrowser_selection_mode_off.svg + ../icons/qtg_mono_filebrowser_paste.svg + ../icons/qtg_indi_status_back.svg + + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/launcher/ReleaseNotes_Launcher.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/launcher/ReleaseNotes_Launcher.txt Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,135 @@ +=============================================================================== + +RELEASE NOTES - LAUNCHER v4.0.1 +RELEASED 21st May 2010 + +SUPPORTS S60 3.0+ + +=============================================================================== + +Product Description: +==================== +Launcher is a testing utility application aimed to help test the launching of +applications installed in the system, both on user side disk drives and on +ROM. Launcher tests if an application can be launched and then, if the launch +has failed, reports the possible reason for the failure. It is a very useful +application when checking the build as the user can instantly see if the +applications work. Launcher can also be used when testing binary +compatibility issues because it can reveal any DLL files missing from the +device. + +Main Features: +============== +- Show a list of installed applications in all drives +- Launch selected applications and read their statuses from threads +- In case of a failure, report thread's exit type, reason and category +- Show missing DLL files required by the binary to be launched +- Show problems on the UI and print all cases to a log file +- Generate a list of DLLs in the device to a file +- Analyse binary compatibility of system DLLs comparing them to a user + given reference data. Report any binary compatibility issues or missing + DLL files. + +=============================================================================== + +What's New in v4.0.1 +==================== +- Feature: Orbit UI improvements +- Fix: Launching DLL analysis not starting + +=============================================================================== + +Installation Notes: +=================== +Launcher is typically preinstalled on ROM. If not, it can be added to the +ROM with the .iby file. Alternatively, a .sis file can be found under the sis- +directory, but the user needs to sign it with their own developer certificate. +In Nokia R&D environment, you can use directly the R&D-signed .sis file under the +internal\sis directory. + +When signing with own developer certificate, the following capabilities are +needed: + PowerMgmt + ReadDeviceData + WriteDeviceData + AllFiles + ReadUserData + WriteUserData + +When building Launcher against S60 3.0 or 3.1, you may need to patch your SDK +environment first with some fixes. For more information, please refer to the +instructions under the "envpatcher" directory. + +=============================================================================== + +System Requirements: +==================== +Basic Requirements: +- Any S60 3.x device or emulator environment + +=============================================================================== + +Compatibility Issues: +===================== +N/A + +=============================================================================== + +Known Issues: +============= + +Fails in a test despite the application is working correctly +------------------------------------------------------------ +- Some application may exit immediately after a launch. This can be + normal behavior and should be checked manually. Such application is, for example, + irapp.exe. + +Binary compatibility check support +---------------------------------- +- Currently, only uncompressed and deflate compressed ELF binaries are + supported. This means that for example WINSCW is not supported. + +=============================================================================== + +Version History: +================ +3.7.0 - 29th May 2009 +- Feature: Binary compatiblity check for DLLs, which checks UID1, UID2, UID3, SID +and capability values of system DLLs against an XML-formatted input file. +- Fix: Launcher panics when comparing a large DLL list against system DLLs. +- Fix: Launcher panics when application launching is cancelled. + +Version 3.6.3 - 14th March 2008 +------------------------------- +- Change: Removed unnecessary capabilities + +Version 3.6.2 - 6th November 2007 +-------------------------------- +- Fix: Applications can be selected/unselected on a touch UI +- Fix: Scroll bar in the output view can be scrolled on a touch UI + +Version 3.6.1 - 9th October 2007 +-------------------------------- +- Fix: Layout in out tab in mirrored mode +- Fix: Codescanner high warnings + +Version 3.6.0 - 25th January 2007 +--------------------------------- +- Fix: Re-fix problems when reading import section from binaries +- Fix: Output screen for larger resolutions +- Fix: Stopping of launching + +Version 3.5.0 - 4th December 2006 +--------------------------------- +- Fix: Problems when reading import section from binaries +- Change: Marquee used for items in the application list view + +=============================================================================== + +Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +All rights reserved. + +This component and the accompanying materials are made available +under the terms of "Eclipse Public License v1.0" +which accompanies this distribution, and is available +at the URL "http://www.eclipse.org/legal/epl-v10.html". diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/launcher/engine/inc/e32image.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/launcher/engine/inc/e32image.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,84 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef __LAUNCHERE32IMAGE_H__ +#define __LAUNCHERE32IMAGE_H__ + +#include +#include +#include +#include + +class E32ImageHeader; +class E32ImportSection; +class E32RelocSection; +class CEikonEnv; + + +NONSHARABLE_CLASS(E32ImageReader) : public CBase, public TProcessCreateInfo + { +public: + static E32ImageReader* NewLC(); + ~E32ImageReader(); + +public: + CDesCArray* ListOfDLLsL(const TDesC& aFullPathToE32Image); + +private: + E32ImageReader(); + void ConstructL(); + TInt LoadData(); + static TUint8* MemoryMove(TAny* aDestination, const TAny* aSource, TInt aNumberofBytes); + TInt LoadFile(TUint32 aCompression); + TInt LoadFileNoCompress(); + void LoadFileInflateL(); + TInt Read(TText8* aDest, TInt aSize); + TInt Read(TInt aPos, TText8* aDest, TInt aSize); + TInt ReadImportData(); + +private: + CEikonEnv* iEnv; + +public: + E32ImageHeader* iHeader; + E32ImportSection* iImportSection; + E32RelocSection* iCodeRelocSection; + E32RelocSection* iDataRelocSection; + TUint32* iImportData; + TUint8* iRestOfFileData; + TUint32 iRestOfFileSize; + TUint32 iConversionOffset; + RFile iFile; + TUint32 iCodeDelta; + TUint32 iDataDelta; + TUint32 iExportDirLoad; + TBool isDll; + TBool iAlreadyLoaded; + TAny* iCloseCodeSeg; + TInt iCurrentImportCount; + TInt iNextImportPos; + TUint32* iCurrentImportList; + TUint8 iCurrentImportListSorted; + TUint8 iExportDirLoadAllocated; + TUint8 iPadding1; + TUint8 iPadding2; + }; + +#endif // __LAUNCHERE32IMAGE_H__ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/launcher/engine/inc/e32imageheaders.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/launcher/engine/inc/e32imageheaders.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,540 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef __LAUNCHERE32IMAGEHEADERS_H__ +#define __LAUNCHERE32IMAGEHEADERS_H__ + +#include + +// from e32Huffman.h + +/** @file + @internalTechnology +*/ + +/** Bit output stream. + Good for writing bit streams for packed, compressed or huffman data algorithms. + + This class must be derived from and OverflowL() reimplemented if the bitstream data + cannot be generated into a single memory buffer. +*/ +class TBitOutput + { +public: + IMPORT_C TBitOutput(); + IMPORT_C TBitOutput(TUint8* aBuf,TInt aSize); + inline void Set(TUint8* aBuf,TInt aSize); + inline const TUint8* Ptr() const; + inline TInt BufferedBits() const; +// + IMPORT_C void WriteL(TUint aValue, TInt aLength); + IMPORT_C void HuffmanL(TUint aHuffCode); + IMPORT_C void PadL(TUint aPadding); +private: + void DoWriteL(TUint aBits, TInt aSize); + virtual void OverflowL(); +private: + TUint iCode; // code in production + TInt iBits; + TUint8* iPtr; + TUint8* iEnd; + }; + +/** Set the memory buffer to use for output + + Data will be written to this buffer until it is full, at which point OverflowL() will + be called. This should handle the data and then can Set() again to reset the buffer + for further output. + + @param aBuf The buffer for output + @param aSize The size of the buffer in bytes +*/ +inline void TBitOutput::Set(TUint8* aBuf,TInt aSize) + {iPtr=aBuf;iEnd=aBuf+aSize;} + +/** Get the current write position in the output buffer + + In conjunction with the address of the buffer, which should be known to the + caller, this describes the data in the bitstream. +*/ +inline const TUint8* TBitOutput::Ptr() const + {return iPtr;} + +/** Get the number of bits that are buffered + + This reports the number of bits that have not yet been written into the + output buffer. It will always lie in the range 0..7. Use PadL() to + pad the data out to the next byte and write it to the buffer. +*/ +inline TInt TBitOutput::BufferedBits() const + {return iBits+8;} + +/** Bit input stream. Good for reading bit streams for packed, compressed or huffman + data algorithms. +*/ +class TBitInput + { +public: + IMPORT_C TBitInput(); + IMPORT_C TBitInput(const TUint8* aPtr, TInt aLength, TInt aOffset=0); + IMPORT_C void Set(const TUint8* aPtr, TInt aLength, TInt aOffset=0); +// + IMPORT_C TUint ReadL(); + IMPORT_C TUint ReadL(TInt aSize); + IMPORT_C TUint HuffmanL(const TUint32* aTree); +private: + virtual void UnderflowL(); +private: + TInt iCount; + TUint iBits; + TInt iRemain; + const TUint32* iPtr; + }; + + +/** Huffman code toolkit. + + This class builds a huffman encoding from a frequency table and builds + a decoding tree from a code-lengths table + + The encoding generated is based on the rule that given two symbols s1 and s2, with + code length l1 and l2, and huffman codes h1 and h2: + + if l1= KImageHdrFmt_J) + return iCompressionType; + return 0; + } + inline TUint32 ModuleVersion() const + { + if ((iFlags & KImageHdrFmtMask) >= KImageHdrFmt_V) + return iModuleVersion; + return 0x00000000u; + } + inline TInt TotalSize() const; + inline TInt UncompressedFileSize() const; + inline TUint HeaderFormat() const + { return HdrFmtFromFlags(iFlags); } + inline TUint EntryPointFormat() const + { return EptFromFlags(iFlags); } + inline TUint ImportFormat() const + { return ImpFmtFromFlags(iFlags); } + inline TUint ABI() const + { return ABIFromFlags(iFlags); } + inline void GetSecurityInfo(SSecurityInfo& aInfo) const; + inline TCpu CpuIdentifier() const; + inline TProcessPriority ProcessPriority() const; + inline TUint32 ExceptionDescriptor() const; + TInt IntegrityCheck(TInt aFileSize); + static TInt New(E32ImageHeader*& aHdr, RFile& aFile); +public: + TUint32 iUid1; + TUint32 iUid2; + TUint32 iUid3; + TUint32 iUidChecksum; + TUint iSignature; // 'EPOC' + TUint32 iHeaderCrc; // CRC-32 of entire header + TUint32 iModuleVersion; // Version number for this executable (used in link resolution) + TUint32 iCompressionType; // Type of compression used (UID or 0 for none) + TVersion iToolsVersion; // Version of PETRAN/ELFTRAN which generated this file + TUint32 iTimeLo; + TUint32 iTimeHi; + TUint iFlags; // 0 = exe, 1 = dll, 2 = fixed address exe + TInt iCodeSize; // size of code, import address table, constant data and export dir + TInt iDataSize; // size of initialised data + TInt iHeapSizeMin; + TInt iHeapSizeMax; + TInt iStackSize; + TInt iBssSize; + TUint iEntryPoint; // offset into code of entry point + TUint iCodeBase; // where the code is linked for + TUint iDataBase; // where the data is linked for + TInt iDllRefTableCount; // filling this in enables E32ROM to leave space for it + TUint iExportDirOffset; // offset into the file of the export address table + TInt iExportDirCount; + TInt iTextSize; // size of just the text section, also doubles as the offset for the iat w.r.t. the code section + TUint iCodeOffset; // file offset to code section, also doubles as header size + TUint iDataOffset; // file offset to data section + TUint iImportOffset; // file offset to import section + TUint iCodeRelocOffset; // relocations for code and const + TUint iDataRelocOffset; // relocations for data + TUint16 iProcessPriority; // executables priority + TUint16 iCpuIdentifier; // 0x1000 = X86, 0x2000 = ARM + }; + +class E32ImageHeaderComp : public E32ImageHeader + { +public: + TUint32 iUncompressedSize; // Uncompressed size of file + // For J format this is file size - sizeof(E32ImageHeader) + // and this is included as part of the compressed data :-( + // For other formats this is file size - total header size + }; + +class E32ImageHeaderV : public E32ImageHeaderComp + { +public: + SSecurityInfo iS; + + // Use iSpare1 as offset to Exception Descriptor + TUint32 iExceptionDescriptor; // Offset in bytes from start of code section to Exception Descriptor, bit 0 set if valid + TUint32 iSpare2; + TUint16 iExportDescSize; // size of bitmap section + TUint8 iExportDescType; // type of description of holes in export table + TUint8 iExportDesc[1]; // description of holes in export table - extend + }; + +// export description type +const TUint KImageHdr_ExpD_NoHoles =0x00; // no holes, all exports present +const TUint KImageHdr_ExpD_FullBitmap =0x01; // full bitmap present +const TUint KImageHdr_ExpD_SparseBitmap8 =0x02; // sparse bitmap present, granularity 8 +const TUint KImageHdr_ExpD_Xip =0xff; // XIP file + + +inline TInt E32ImageHeader::TotalSize() const + { + if (HeaderFormat() == KImageHdrFmt_J && iCompressionType != 0) + return sizeof(E32ImageHeaderComp); + return iCodeOffset; + } + +inline TInt E32ImageHeader::UncompressedFileSize() const + { + TUint hdrfmt = HeaderFormat(); + if (hdrfmt == KImageHdrFmt_Original || iCompressionType == 0) + return -1; // not compressed + else if (hdrfmt == KImageHdrFmt_J) + return ((E32ImageHeaderComp*)this)->iUncompressedSize + sizeof(E32ImageHeader); + else + return ((E32ImageHeaderComp*)this)->iUncompressedSize + iCodeOffset; + } + +extern const SSecurityInfo KDefaultSecurityInfo; +inline void E32ImageHeader::GetSecurityInfo(SSecurityInfo& aInfo) const + { + if (HeaderFormat() >= KImageHdrFmt_V) + aInfo = ((E32ImageHeaderV*)this)->iS; + else + aInfo = KDefaultSecurityInfo; + } + +inline TCpu E32ImageHeader::CpuIdentifier() const + { + if (HeaderFormat() >= KImageHdrFmt_V) + return (TCpu)iCpuIdentifier; + return (TCpu)iHeaderCrc; + } + +inline TProcessPriority E32ImageHeader::ProcessPriority() const + { + if (HeaderFormat() >= KImageHdrFmt_V) + return (TProcessPriority)iProcessPriority; + return *(const TProcessPriority*)&iProcessPriority; + } + +inline TUint32 E32ImageHeader::ExceptionDescriptor() const + { + if (HeaderFormat() >= KImageHdrFmt_V) + { + TUint32 xd = ((E32ImageHeaderV*)this)->iExceptionDescriptor; + if ((xd & 1) && (xd != 0xffffffffu)) + return (xd & ~1); + } + return 0; + } + +class E32ImportBlock + { +public: + inline const E32ImportBlock* NextBlock(TUint aImpFmt) const; + inline TInt Size(TUint aImpFmt) const; + inline const TUint* Imports() const; // import list if present +public: + TUint32 iOffsetOfDllName; // offset of name of dll importing from + TInt iNumberOfImports; // no of imports from this dll +// TUint iImport[iNumberOfImports]; // list of imported ordinals, omitted in PE2 import format + }; + +inline TInt E32ImportBlock::Size(TUint aImpFmt) const + { + TInt r = sizeof(E32ImportBlock); + if (aImpFmt!=KImageImpFmt_PE2) + r += iNumberOfImports * sizeof(TUint); + return r; + } + +inline const E32ImportBlock* E32ImportBlock::NextBlock(TUint aImpFmt) const + { + const E32ImportBlock* next = this + 1; + if (aImpFmt!=KImageImpFmt_PE2) + next = (const E32ImportBlock*)( (TUint8*)next + iNumberOfImports * sizeof(TUint) ); + return next; + } + +inline const TUint* E32ImportBlock::Imports() const + { + return (const TUint*)(this + 1); + } + +class E32ImportSection + { +public: + TInt iSize; // size of this section +// E32ImportBlock[iDllRefTableCount]; + }; + +class E32RelocSection + { +public: + TInt iSize; // size of this relocation section + TInt iNumberOfRelocs; // number of relocations in this section + }; + + +typedef TUint8* (*TMemoryMoveFunction)(TAny* aTrg,const TAny* aSrc,TInt aLength); + +const TInt KDeflateLengthMag=8; +const TInt KDeflateDistanceMag=12; +const TInt KDeflateMinLength=3; +const TInt KDeflateMaxLength=KDeflateMinLength-1 + (1< + +typedef TBuf8<8> TDllIdValue; + +class CLauncherDLLElement : public CBase + { +public: + + enum TDifference + { + EDifference_UID1, // UID1 is different + EDifference_UID2, // UID1 is different + EDifference_UID3, // UID1 is different + EDifference_SID, // SID is different + EDifference_Capability // Capabilities are different + }; + + virtual ~CLauncherDLLElement(); + static CLauncherDLLElement* NewL(); + static CLauncherDLLElement* NewLC(); + + /* + * Compares DLL elements. + * @return ETrue if differencies exist, EFalse otherwise. + * @param aReferenceElement Reference DLL-element for comparison + * @param aDifferenceList Differencies are added to this list. + */ + TBool CompareL(const CLauncherDLLElement& aReferenceElement, RArray& aDifferenceList) const; + + /* + * Returns DLL name + * @return DLL name + */ + TFileName Name() const; + /* + * Sets DLL name + * @param aName DLL name + */ + void SetNameL(const TFileName& aName); + + /* + * Returns DLL UID1 + * @return UID1 object + */ + TUid UID1() const; + + /* + * Sets DLL UID1 + * @param aUID1 UID1 object + */ + void SetUID1L(TUid aUID1); + + /* + * Returns DLL UID2 + * @return UID2 object + */ + TUid UID2() const; + + /* + * Sets DLL UID2 + * @param aUID2 UID2 object + */ + void SetUID2L(TUid aUID2); + + /* + * Returns DLL UID3 + * @return UID3 object + */ + TUid UID3() const; + + /* + * Sets DLL UID3 + * @param aUID3 UID3 object + */ + void SetUID3L(TUid aUID3); + + /* + * Returns DLL SID + * @return SID object + */ + TUid SID() const; + + /* + * Sets DLL SID + * @param aSID SID object + */ + void SetSIDL(TUid aSID); + + /* + * Returns DLL capability + * @return capability value + */ + TUint32 Capability() const; + + /* + * Sets DLL capability + * @param aCapability capability value + */ + void SetCapabilityL(TUint32 aCapability); + +protected: + CLauncherDLLElement(); + virtual void ConstructL(); + +private: + TFileName iName; + TUid iUID1; + TUid iUID2; + TUid iUID3; + TUid iSID; + TUint32 iCapability; + }; + +#endif /* LAUNCHERDLLELEMENT_H_ */ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/launcher/engine/inc/launcherdllparser.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/launcher/engine/inc/launcherdllparser.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef LAUNCHERDLLPARSER_H_ +#define LAUNCHERDLLPARSER_H_ + +#include +#include +#include "launcherdllelement.h" + +#define UID1_OFFSET 0x00 +#define UID2_OFFSET 0x04 +#define UID3_OFFSET 0x08 +#define SID_OFFSET_ROM 0x44 +#define SID_OFFSET_ROFS 0x80 +#define CAPABILITY_OFFSET_ROM 0x4c +#define CAPABILITY_OFFSET_ROFS 0x88 + +class CLauncherDLLParser : public CBase + { +public: + + virtual ~CLauncherDLLParser(); + static CLauncherDLLParser* NewL(); + static CLauncherDLLParser* NewLC(); + + /** + * Reads data from the given DLL-file and sets parsed data to given object. + * @param aFileSession Reference to an open file session + * @param aFile Reference to the DLL file object + * @param aElement Reference to the element, which will contain the parsed data + */ + void ParseL( RFs& aFileSession, RFile& aFile, CLauncherDLLElement& aElement ); + +private: + + CLauncherDLLParser(); + void ConstructL(); + + /** + * Reads 32-bit unsigned integer from the given file. + * @return 32-bit unsigned integer value. + * @param aFile File handle. + */ + TUint32 ReadUint32L( RFile& aFile ); + }; + +#endif /* LAUNCHERDLLPARSER_H_ */ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/launcher/engine/inc/launcherengine.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/launcher/engine/inc/launcherengine.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,274 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef LAUNCHERENGINE_H +#define LAUNCHERENGINE_H + +#include +#include +#include +#include +#include + +#include "launcherparserobserver.h" + +// CONSTANTS +// None + +// MACROS +// None + +// DATA TYPES +// None + +// FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +class CEikonEnv; +class CAppThreadChecker; +class CAppRunningChecker; +class CLauncherXMLParser; +class CLauncherDLLParser; + + +// INFERFACE FOR COMMUNICATION WITH UI + +class MLauncherUI +{ +public: + /** + * Method for writing text to output window. + * @param aText A text to be written. + * @return None. + */ + virtual void PrintText(const TDesC& aText) = 0; + + /** + * Shows info message with text + * @param aText An text to be shown in message. + * @return None. + */ + virtual void ShowInfoMessage(const TDesC& aText) = 0; + + /** + * Shows error message with error text + * @param aText An error text to be shown in message. + * @return None. + */ + virtual void ShowErrorMessage(const TDesC& aText) = 0; + + /** + * Shows progress bar with text + * @param aText A text to be shown at top of the progress bar. + * @param aMinimum A minimum progress bar value. + * @param aMaximum A maximum progress bar value. + * @return None. + */ + virtual void ShowProgressBar(const TDesC& aText, TInt aMinimum, TInt aMaximum ) = 0; + + /** + * Sets progress bar value + * @param aValue A value between min and max value of the progress bar range + * @return None. + */ + virtual void SetProgressBarValue(TInt aValue) = 0; + + /** + * Hides progress bar + * @return None. + */ + virtual void HideProgressBar() = 0; + + /** + * Shows wait dialog with text + * @param aText A text to be shown at top of the wait bar. + * @return None. + */ + virtual void ShowWaitDialog(const TDesC& aText) = 0; + + /** + * Hides wait dialog + * @return None. + */ + virtual void HideWaitDialog() = 0; + + /** + * Changes focus to output view + * @return None. + */ + virtual void ChangeFocusToOutputView() = 0; + +}; + +// CLASS DECLARATION + +class CLauncherEngine: public CActive, public MLauncherParserObserver +{ + +public: + static CLauncherEngine* NewL(MLauncherUI *aLauncherUI); + ~CLauncherEngine(); + CDesCArray* ListOfAllAppsL(); + void StartAppLaunchingL(const CArrayFix* aSelectedApps, TBool aAutoClose); + void CheckIfAppIsRunningL(); + void CheckWhyThreadDiedL(); + void StopLaunchingL(); + TBool LogFileExists(); + TBool BCLogFileExists(); + + TInt DeleteLogFile(); + TInt DeleteBCLogFile(); + + void AnalyseDLLsL( const TDesC& aFileName ); + + void ElementParsedL(const CLauncherDLLElement& aDllElement); + void DocumentParsedL(TInt aErrorCode); + void ParsingProgressedL(TInt aBytes); + TInt ReadLineFromFileL(RFile& aFile, TDes& aReadBuf); + + const TDesC& RequiredDllsFilePath() const { return iRequiredDllsFilePath; }; + + void CancelBCAnalysis(); + +private: + CLauncherEngine(); + void ConstructL(MLauncherUI *aLauncherUI); + + void RunL(); + void DoCancel(); + + TInt FindFiles(const TDesC& aFileName, const TDesC& aPath); + void IssueLaunch(); + void WriteInitialStuffToTheLogL(const TDesC& aOwnData, RFile& aFile); + void CheckForMoreAppsL(); + void LaunchApplicationL(); + void DoLaunchApplicationL(); + CDesCArray* DependencyCheckForE32ImageL(); + + /** + * Performs binary compatibility analysis based on reference data given + * in XML-file. + */ + void DoBCAnalysisL(); + + /** + * Compares given DLL list to system DLLs + */ + void DoCompareDLLListsL(); + +private: + + MLauncherUI *iLauncherUI; + + RTimer iTimer; + CEikonEnv* iEnv; + RApaLsSession iLs; + RWsSession iWs; + HBufC8* iLogWriteBuf; + RFile iLogFile; + RFile iBCLogFile; + TFileName iLogFilePath; + TFileName iBCLogFilePath; + TFileName iSystemDllsFilePath; + TFileName iRequiredDllsFilePath; + + CDesCArray* iAppsArray; + CDesCArray* iAllAppsArray; + CDesCArray* iSystemDllArray; +// CDesCArray* iRequiredDllArray; + + TBool iLaunchingIsActive; + TBool iDLLAnalysisIsActive; + TBool iSkipHiddenAndEmbedOnly; + TBool iAutoClose; + TInt iAppLaunchCounter; + TInt iFailedCases; + TInt iOkCases; + TInt iSkippedCases; + TInt iTotalNumberOfCases; + + TUid iCurrentAppUid; + TThreadId iCurrentAppThreadId; + TBuf<128> iCurrentAppNameAndExt; + RThread iCurrentAppThread; +// + CAppThreadChecker* iAppThreadChecker; + CAppRunningChecker* iAppRunningChecker; + + CLauncherXMLParser* iXMLParser; + CLauncherDLLParser* iDLLParser; + CLauncherDLLElement* iDLLElement; + + TInt iFoundBCIssues; + HBufC* iBCIssuesBigBuffer; + + +public: + inline TBool SkipHiddenAndEmbedOnly() { return iSkipHiddenAndEmbedOnly; }; + inline void SetSkipHiddenAndEmbedOnly(TBool aSkip) { iSkipHiddenAndEmbedOnly = aSkip; }; + inline const TDesC& LogFilePath() { return iLogFilePath; } + inline const TDesC& BCLogFilePath() { return iBCLogFilePath; } + inline const TDesC& SystemDllsFilePath() { return iSystemDllsFilePath; } +}; + + + +class CAppRunningChecker : public CActive + { +public: + static CAppRunningChecker* NewL(CLauncherEngine* aLauncherEngine); + ~CAppRunningChecker(); + + void StartTesting(); + +private: + CAppRunningChecker(); + void ConstructL(CLauncherEngine* aLauncherEngine); + + void RunL(); + void DoCancel(); + +private: + RTimer iTimer; + CEikonEnv* iEnv; + CLauncherEngine* iLauncherEngine; + }; + +class CAppThreadChecker : public CActive + { +public: + static CAppThreadChecker* NewL(CLauncherEngine* aLauncherEngine); + ~CAppThreadChecker(); + + void ActivateChecking(); + void CheckIfAppIsRunningL(); + +private: + CAppThreadChecker(); + void ConstructL(CLauncherEngine* aLauncherEngine); + + void RunL(); + void DoCancel(); + +private: + CEikonEnv* iEnv; + CLauncherEngine* iLauncherEngine; + }; + + +#endif //LAUNCHERENGINE_H diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/launcher/engine/inc/launcherparserobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/launcher/engine/inc/launcherparserobserver.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef LAUNCHERPARSEROBSERVER_H_ +#define LAUNCHERPARSEROBSERVER_H_ + +class CLauncherDLLElement; + +class MLauncherParserObserver +{ +public: + + /** + * This method is called when parser has parsed next DLL element + * @param aDllElement Parsed DLL element. + */ + virtual void ElementParsedL(const CLauncherDLLElement& aDllElement) = 0; + + /** + * This method is called when the parsing is completed. If parsing was + * stopped due to an error, an error code is given in parameter. + * @param aErrorCode KErrNone if document was parsed successfully. + */ + virtual void DocumentParsedL(TInt aErrorCode) = 0; + + /** + * Parser calls this function during parsing to indicate the amount of + * bytes parsed from the given file. + * @param aBytes Amount of data (in bytes) parsed. Amount is incremental. + */ + virtual void ParsingProgressedL(TInt aBytes) = 0; + +}; + +#endif /* LAUNCHERPARSEROBSERVER_H_ */ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/launcher/engine/inc/launchertraces.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/launcher/engine/inc/launchertraces.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,103 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef __LAUNCHER_TRACES_H__ +#define __LAUNCHER_TRACES_H__ + +#include + + +// --------------------------------------------------------------------------- +// You change these logging method values below! Recompile the application to take changes effect. + + // logging methods + // 0 = No logging + // 1 = Flogger + // 2 = RDebug + // 3 = Flogger and RDebug + + #ifndef _DEBUG + + // Logging method for UREL builds: + #define LAUNCHER_LOGGING_METHOD 2 + + #else + + // Logging method for UDEB builds: + #define LAUNCHER_LOGGING_METHOD 0 + + #endif + + + +// --------------------------------------------------------------------------- +// Do not make any changes to lines below... + + #if LAUNCHER_LOGGING_METHOD == 1 || LAUNCHER_LOGGING_METHOD == 3 + + #include + _LIT(KLogFolder,"Launcher"); + _LIT(KLogFile,"Launcher_Trace.txt"); + + #endif + + #if LAUNCHER_LOGGING_METHOD == 2 || LAUNCHER_LOGGING_METHOD == 3 + + #include + + #endif + + + #if LAUNCHER_LOGGING_METHOD == 0 + + #define LOGTEXT(AAA) + #define LOGSTRING(AAA) + #define LOGSTRING2(AAA,BBB) + #define LOGSTRING3(AAA,BBB,CCC) + #define LOGSTRING4(AAA,BBB,CCC,DDD) + + + #elif LAUNCHER_LOGGING_METHOD == 1 + + #define LOGTEXT(AAA) RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend, AAA) + #define LOGSTRING(AAA) do { _LIT(tempLogDes,AAA); RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend,tempLogDes()); } while (0) + #define LOGSTRING2(AAA,BBB) do { _LIT(tempLogDes,AAA); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB); } while (0) + #define LOGSTRING3(AAA,BBB,CCC) do { _LIT(tempLogDes,AAA); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB,CCC); } while (0) + #define LOGSTRING4(AAA,BBB,CCC,DDD) do { _LIT(tempLogDes,AAA); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB,CCC,DDD); } while (0) + + #elif LAUNCHER_LOGGING_METHOD == 2 + + #define LOGTEXT(AAA) RDebug::Print(AAA) + #define LOGSTRING(AAA) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes); } while (0) + #define LOGSTRING2(AAA,BBB) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB); } while (0) + #define LOGSTRING3(AAA,BBB,CCC) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC); } while (0) + #define LOGSTRING4(AAA,BBB,CCC,DDD) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC, DDD); } while (0) + + #elif LAUNCHER_LOGGING_METHOD == 3 + + #define LOGTEXT(AAA) RDebug::Print(AAA); RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend, AAA) + #define LOGSTRING(AAA) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes); RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend,tempLogDes()); } while (0) + #define LOGSTRING2(AAA,BBB) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB); } while (0) + #define LOGSTRING3(AAA,BBB,CCC) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB,CCC); } while (0) + #define LOGSTRING4(AAA,BBB,CCC,DDD) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC, DDD); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB,CCC,DDD); } while (0) + + #endif + +// --------------------------------------------------------------------------- + +#endif // __LAUNCHER_TRACES_H__ + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/launcher/engine/inc/launcherxmlparser.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/launcher/engine/inc/launcherxmlparser.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,114 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef LAUNCHERXMLPARSER_H_ +#define LAUNCHERXMLPARSER_H_ + +#include +#include +#include +#include "launcherdllelement.h" +#include "launcherparserobserver.h" + +using namespace Xml; + +const TUint KXMLBufferSize = 1024; + +class CLauncherDLLElement; + +/** + * Parses DLL data from the given XML-file + */ +class CLauncherXMLParser : public CActive, public MContentHandler +{ +public: + + virtual ~CLauncherXMLParser(); + static CLauncherXMLParser* NewL(RFs& aFs); + static CLauncherXMLParser* NewLC(RFs& aFs); + + /** + * Parses the given XML-file and notifies the observer. + * @param aFilePath XML-file's path + * @param aObserver Pointer to the observer instance. + */ + void ParseL(const TDesC& aFilePath, MLauncherParserObserver* aObserver); + +protected: + + // from CActive + void DoCancel(); + void RunL(); + +private: + + CLauncherXMLParser(RFs& aFs); + void ConstructL(); + + /** + * Tells whether the current XML element is a sub-element of the 'dll'-element. + * @return ETrue if the current XML-element is sub-element of the 'dll'-element. + */ + TBool IsDataElement(); + + /** + * Deletes current data buffer and zeroes the pointer. + */ + void ClearXMLDataBuffer(); + + /** + * Converts 8-bit descriptor to 32-bit unsigned integer + * @return Converted 32-bit unsigned integer value. + * @param aStr 8-bit descriptor to be converted. + */ + TUint32 ConvertDes8ToUint32L(const TDesC8& aStr); + +public: + // From MContentHandler: + void OnStartDocumentL(const RDocumentParameters &aDocParam, TInt aErrorCode); + void OnEndDocumentL(TInt aErrorCode); + void OnStartElementL( const RTagInfo& aElement, + const RAttributeArray& aAttributes, + TInt aErrorCode); + void OnEndElementL(const RTagInfo& aElement, TInt aErrorCode); + void OnContentL(const TDesC8& aBytes, TInt aErrorCode); + void OnStartPrefixMappingL( const RString& aPrefix, + const RString& aUri, + TInt aErrorCode); + void OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode); + void OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt aErrorCode); + void OnSkippedEntityL(const RString& aName, TInt aErrorCode); + void OnProcessingInstructionL( const TDesC8& aTarget, + const TDesC8& aData, + TInt aErrorCode); + void OnError(TInt aErrorCode); + TAny* GetExtendedInterface(const TInt32 aUid); + +private: + CParser* iParser; // XML parser + RFs& iFileSession; + RFile iFile; // XML file + TBuf8 iXMLDataBuffer; + MLauncherParserObserver* iObserver; + CLauncherDLLElement* iCurrentDllElement; + TBuf8 iCurrentContent; + TBuf8 iCurrentElementName; + TBool iIgnoreError; + TInt iParsedBytes; +}; + +#endif /* LAUNCHERXMLPARSER_H_ */ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/launcher/engine/src/e32image.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/launcher/engine/src/e32image.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,846 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +#include "e32image.h" +#include "e32imageheaders.h" +#include "launchertraces.h" + + +const TInt KMaxHeaderSize = sizeof(E32ImageHeaderV) + 65536/8; + +SCapabilitySet AllCapabilities; +SCapabilitySet DisabledCapabilities; + +// --------------------------------------------------------------------------- + +E32ImageReader* E32ImageReader::NewLC() + { + E32ImageReader* self = new(ELeave) E32ImageReader; + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +// --------------------------------------------------------------------------- + +E32ImageReader::E32ImageReader() + { + } + +// --------------------------------------------------------------------------- + +void E32ImageReader::ConstructL() + { + LOGSTRING("Launcher: E32ImageReader::ConstructL"); + + iEnv = CEikonEnv::Static(); + } + +// --------------------------------------------------------------------------- + +CDesCArray* E32ImageReader::ListOfDLLsL(const TDesC& aFullPathToE32Image) + { + LOGSTRING("Launcher: E32ImageReader::ListOfDLLsL"); + + // open the file for reading + User::LeaveIfError( iFile.Open(iEnv->FsSession(), aFullPathToE32Image, EFileRead) ); + CleanupClosePushL(iFile); + + // get local copies of capability sets + TCapabilitySet caps; + caps.SetAllSupported(); + AllCapabilities=*(SCapabilitySet*)∩︀ + caps.SetDisabled(); + DisabledCapabilities=*(SCapabilitySet*)∩︀ + + // read the header of the image + User::LeaveIfError( E32ImageHeader::New(iHeader, iFile) ); + + // set stuff + iHeapSizeMin = iHeader->iHeapSizeMin; + iHeapSizeMax = iHeader->iHeapSizeMax; + iStackSize = iHeader->iStackSize; + iPriority = iHeader->ProcessPriority(); + iDepCount = iHeader->iDllRefTableCount; + iExportDirCount = iHeader->iExportDirCount; + iExportDir = iHeader->iExportDirOffset-iHeader->iCodeOffset; + iTextSize = iHeader->iTextSize; + iCodeSize = iHeader->iCodeSize; + iDataSize = iHeader->iDataSize; + iBssSize = iHeader->iBssSize; + iTotalDataSize = iDataSize+iBssSize; + iFileEntryPoint = iHeader->iEntryPoint; + iEntryPtVeneer = 0; + iExceptionDescriptor = iHeader->ExceptionDescriptor(); + if (iHeader->iExportDirOffset) + iExportDirLoad=iExportDir; + + // allocate data for the code area + iCodeLoadAddress = (TUint32)User::Alloc(iCodeSize); + + // load data from the binary + User::LeaveIfError( LoadData() ); + + // create an array for the dll names from the import list + CDesCArray* dllArray = new(ELeave) CDesCArrayFlat(100); + CleanupStack::PushL(dllArray); + + // get the dll names from the import section + E32ImportSection* importSection = (E32ImportSection *)iImportData; + E32ImportBlock* block; + if(importSection) + block = (E32ImportBlock*)(importSection+1); + else + block = NULL; + iNextImportPos = 0; + + // loop through all import data blocks + for (TInt i=0; iiOffsetOfDllName); + TBuf8 rootname; + if (dllname.Length() > KMaxKernelName) + User::Leave( KErrNotSupported ); + + // parse the filename + TFileNameInfo fni; + User::LeaveIfError( fni.Set(dllname, TFileNameInfo::EAllowUid) ); + fni.GetName(rootname, TFileNameInfo::EIncludeBaseExt); + + // append the name to the dll name array + TFileName dllName16; + dllName16.Copy(rootname); + dllArray->AppendL(dllName16); + + // get the next block + TUint impfmt = iHeader->ImportFormat(); + block = (E32ImportBlock*)block->NextBlock(impfmt); + } + + CleanupStack::Pop(); //dllArray + CleanupStack::PopAndDestroy(); //iFile + + // free memory + delete iHeader; + iHeader = NULL; + delete iImportSection; + iImportSection = NULL; + delete iCodeRelocSection; + iCodeRelocSection = NULL; + delete iDataRelocSection; + iDataRelocSection = NULL; + + User::Free((TAny*)iCodeLoadAddress); + User::Free(iRestOfFileData); + User::Free(iCurrentImportList); + if (iExportDirLoadAllocated) + User::Free((TAny*)iExportDirLoad); + + return dllArray; + } + +// --------------------------------------------------------------------------- + +E32ImageReader::~E32ImageReader() + { + LOGSTRING("Launcher: E32ImageReader::~E32ImageReader"); + } + + +// --------------------------------------------------------------------------- + +TInt FileRead(RFile& aFile, TUint8* aDest, TInt aSize) + { + TPtr8 p(aDest,aSize,aSize); + return aFile.Read(p,aSize); + } + +// --------------------------------------------------------------------------- + +TInt E32ImageHeader::New(E32ImageHeader*& aHdr, RFile& aFile) + { + LOGSTRING("Launcher: E32ImageHeader::New"); + + E32ImageHeader* h = NULL; + TInt hdrsz = 0; + TInt filesize; + TInt r = aFile.Size(filesize); + if (r!=KErrNone) + return r; + E32ImageHeader bh; + r = FileRead(aFile, (TUint8*)&bh, sizeof(E32ImageHeader)); + if (r==KErrNone) + { + hdrsz = bh.TotalSize(); + if ( (TUint(hdrsz) > TUint(KMaxHeaderSize)) || (TUint(hdrsz) < TUint(sizeof(bh))) ) + return KErrCorrupt; + } + h = (E32ImageHeader*)User::Alloc(hdrsz); + if (!h) + return KErrNoMemory; + wordmove(h, &bh, sizeof(E32ImageHeader)); + if (hdrsz > (TInt)sizeof(E32ImageHeader)) + r = FileRead(aFile, (TUint8*)(h + 1), hdrsz - sizeof(E32ImageHeader)); + if (r==KErrNone) + r = h->IntegrityCheck(filesize); + if (r==KErrNone) + { + if (h->HeaderFormat() >= KImageHdrFmt_V) + { + // Overide capabilities in image + for(TInt i=0; iiS.iCaps[i] |= DisabledCapabilities[i]; + ((E32ImageHeaderV*)h)->iS.iCaps[i] &= AllCapabilities[i]; + } + } + aHdr = h; + } + else + { + delete h; + aHdr = NULL; + } + return r; + } + +// --------------------------------------------------------------------------- + +TInt E32ImageHeader::IntegrityCheck(TInt aFileSize) + { + LOGSTRING("Launcher: E32ImageHeader::IntegrityCheck"); + + TInt hdrsz = TotalSize(); + TUint hdrfmt = HeaderFormat(); + TUidType uids = *(const TUidType*)&iUid1; + E32ImageHeaderV* v = NULL; + TCheckedUid chkuid(uids); + const TUint32* pChkUid = (const TUint32*)&chkuid; + + if (pChkUid[3] != iUidChecksum) + return KErrCorrupt; + + if (hdrfmt == KImageHdrFmt_V) + { + TUint32 supplied_crc = iHeaderCrc; + iHeaderCrc = KImageCrcInitialiser; + TUint32 crc = 0; + Mem::Crc32(crc, this, hdrsz); + iHeaderCrc = supplied_crc; + if (crc != supplied_crc) + return KErrCorrupt; + v = (E32ImageHeaderV*)this; + TUint total_eds = v->iExportDescSize + sizeof(v->iExportDescSize) + sizeof(v->iExportDescType); + total_eds = (total_eds + 3) &~ 3; + if (total_eds + (TUint)_FOFF(E32ImageHeaderV, iExportDescSize) != (TUint)hdrsz) + return KErrCorrupt; + if (TUint(v->iExportDescType) > KImageHdr_ExpD_SparseBitmap8) + return KErrNotSupported; + } + else if (hdrfmt >= KImageHdrFmt_V) + return KErrNotSupported; + + TCpu cpu = CpuIdentifier(); + TUint abi = ABI(); + TUint impfmt = ImportFormat(); + TUint compression = CompressionType(); + + TUint uncompressed_size = compression ? UncompressedFileSize() : (TUint)aFileSize; + + if (iSignature != 0x434f5045) // 'EPOC' + return KErrCorrupt; + if (iCodeSize<0) + return KErrCorrupt; + if (iDataSize<0) + return KErrCorrupt; + if (iHeapSizeMin<0) + return KErrCorrupt; + if (iHeapSizeMax= uncompressed_size) + return KErrCorrupt; + if (TUint(iExportDirCount)>65535) + return KErrCorrupt; + if (iTextSize<0) + return KErrCorrupt; + if (iCodeSize= uncompressed_size) + return KErrCorrupt; + if (iDataOffset >= uncompressed_size) + return KErrCorrupt; + if (iImportOffset >= uncompressed_size) + return KErrCorrupt; + if (iCodeRelocOffset >= uncompressed_size) + return KErrCorrupt; + if (iDataRelocOffset >= uncompressed_size) + return KErrCorrupt; + if (TUint(iCodeSize+iDataSize) > uncompressed_size) + return KErrCorrupt; + + if (abi>KImageABI_EABI) + return KErrNotSupported; + if (impfmt>KImageImpFmt_PE2) + return KErrNotSupported; + if (iUid1 != (TUint32)KExecutableImageUidValue && iUid1 != (TUint32)KDynamicLibraryUidValue) + return KErrNotSupported; + TUint32 mv = ModuleVersion(); + if (mv >= 0x80000000u || (mv & 0x0000ffffu) > 0x8000u) + return KErrNotSupported; + + return KErrNone; + } +// --------------------------------------------------------------------------- + +TInt E32ImageReader::LoadData() + { + LOGSTRING("Launcher: E32ImageReader::LoadData"); + + TInt remainder; + iFile.Size(remainder); + + remainder -= iHeader->TotalSize(); + TUint32 compression = iHeader->CompressionType(); + if (compression != KMyFormatNotCompressed) + { + remainder = iHeader->UncompressedFileSize() - iHeader->iCodeOffset; + } + + remainder -= iHeader->iCodeSize; + + if (remainder > 0) + { + iRestOfFileData = (TUint8*)User::Alloc(remainder); + if (iRestOfFileData) + iRestOfFileSize=remainder; + else + return KErrNoMemory; + } + + iConversionOffset = iHeader->iCodeOffset + iHeader->iCodeSize; + + TInt r = LoadFile(compression); + if (r !=KErrNone) + return r; + + + TUint8* source=NULL; + if (iHeader->iImportOffset) + { + TUint bufferOffset=iHeader->iImportOffset-iConversionOffset; + + if(bufferOffset>iRestOfFileSize || bufferOffset+sizeof(E32ImportSection)>iRestOfFileSize) + return KErrCorrupt; + + source=iRestOfFileData+bufferOffset; + + iImportSection = new E32ImportSection; + + if (iImportSection) + Mem::Move((TText8*)iImportSection, source, sizeof(E32ImportSection)); + else + return KErrNoMemory; + } + + iCodeDelta = iCodeRunAddress-iHeader->iCodeBase; + iDataDelta = iDataRunAddress-iHeader->iDataBase; + + if (r==KErrNone) + r = ReadImportData(); + + return r; + } + +// --------------------------------------------------------------------------- + +TUint8* E32ImageReader::MemoryMove(TAny* aDestination, const TAny* aSource, TInt aNumberofBytes) + { + return Mem::Move(aDestination, aSource, aNumberofBytes); + } + +// --------------------------------------------------------------------------- + +GLDEF_C TInt svRelocateExports(TAny* aPtr) + { + E32ImageReader* pI=(E32ImageReader*)aPtr; + TUint32* destExport=(TUint32*)pI->iExportDirLoad; + TInt i=pI->iExportDirCount; + TUint32 codeBase=pI->iCodeRunAddress; + while (i-->0) + *destExport+++=codeBase; + return 0; + } + +// --------------------------------------------------------------------------- + +TInt E32ImageReader::LoadFile(TUint32 aCompression) + { + LOGSTRING("Launcher: E32ImageReader::LoadFile"); + + TInt r(KErrNone); + + if (aCompression == KMyFormatNotCompressed) + r=LoadFileNoCompress(); + + else if (aCompression == KMyUidCompressionDeflate) + { + TRAP(r, LoadFileInflateL()); + } + + else + r = KErrNotSupported; + + return r; + } + +// --------------------------------------------------------------------------- + +TInt E32ImageReader::LoadFileNoCompress() + { + LOGSTRING("Launcher: E32ImageReader::LoadFileNoCompress"); + + TInt r(KErrNone); + + if (iHeader->iCodeSize) + { + r = Read(iHeader->iCodeOffset, (TText8*)iCodeLoadAddress, iCodeSize); + } + + if (r != KErrNone) + { + return r; + } + + if (iRestOfFileSize) + { + r = Read(iConversionOffset, (TText8*)iRestOfFileData, iRestOfFileSize); + } + + return r; + } + +// --------------------------------------------------------------------------- + +void FileCleanup(TAny* aPtr) + { + TFileInput* f=(TFileInput*)aPtr; + f->Cancel(); + delete f; + } + +// --------------------------------------------------------------------------- + +void E32ImageReader::LoadFileInflateL() + { + LOGSTRING("Launcher: E32ImageReader::LoadFileInflateL"); + + TInt pos = iHeader->TotalSize(); + User::LeaveIfError(iFile.Seek(ESeekStart,pos)); + + TFileInput* file = new (ELeave) TFileInput(iFile); + CleanupStack::PushL(TCleanupItem(&FileCleanup,file)); + CInflater* inflater = CInflater::NewLC(*file); + + if (iHeader->iCodeSize) + { + TInt count = inflater->ReadL((TUint8*)iCodeLoadAddress, iCodeSize, &MemoryMove); + + if(count!=iCodeSize) + User::Leave(KErrCorrupt); + } + + if (iRestOfFileSize) + { + TUint32 count = inflater->ReadL(iRestOfFileData, iRestOfFileSize, &Mem::Move); + + if(count!=iRestOfFileSize) + User::Leave(KErrCorrupt); + } + + CleanupStack::PopAndDestroy(2,file); + } + +// --------------------------------------------------------------------------- + +TInt E32ImageReader::Read(TText8* aDest, TInt aSize) + { + TPtr8 p(aDest,aSize,aSize); + return iFile.Read(p,aSize); + } + +// --------------------------------------------------------------------------- + +TInt E32ImageReader::Read(TInt aPos, TText8* aDest, TInt aSize) + { + TPtr8 p(aDest,aSize,aSize); + if (aPos<0) + return KErrCorrupt; + return iFile.Read(aPos,p,aSize); + } + +// --------------------------------------------------------------------------- + +TInt E32ImageReader::ReadImportData() + { + LOGSTRING("Launcher: E32ImageReader::ReadImportData"); + + if (!iHeader->iImportOffset) + return KErrNone; + + TUint32 bufferOffset = iHeader->iImportOffset-iConversionOffset; + + if(bufferOffset>iRestOfFileSize || bufferOffset+iImportSection->iSize>iRestOfFileSize) + return KErrCorrupt; + + iImportData = (TUint32*)(iRestOfFileData+bufferOffset); + + E32ImportSection* s = (E32ImportSection*)iImportData; + E32ImportBlock* b = (E32ImportBlock*)(s + 1); + TUint impfmt = iHeader->ImportFormat(); + TInt i; + TInt n = 0; + + for (i=0; iiNumberOfImports > n) + n = b->iNumberOfImports; + b = (E32ImportBlock*)b->NextBlock(impfmt); + } + + iCurrentImportList = (TUint32*)User::Alloc(n * sizeof(TUint32)); + + if (!iCurrentImportList) + return KErrNoMemory; + + return KErrNone; + } + +// --------------------------------------------------------------------------- + +inline CInflater::CInflater(TBitInput& aInput) + :iBits(&aInput),iEncoding(0),iOut(0) + {} + +// --------------------------------------------------------------------------- + +void CInflater::ConstructL() + { + iEncoding=new(ELeave) TEncoding; + InitL(); + iLen=0; + iOut=new(ELeave) TUint8[KDeflateMaxDistance]; + iAvail=iLimit=iOut; + } + +// --------------------------------------------------------------------------- + +CInflater* CInflater::NewLC(TBitInput& aInput) + { + CInflater* self=new(ELeave) CInflater(aInput); + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +// --------------------------------------------------------------------------- + +CInflater::~CInflater() + { + delete iEncoding; + delete [] iOut; + } + +// --------------------------------------------------------------------------- + +TInt CInflater::ReadL(TUint8* aBuffer,TInt aLength, TMemoryMoveFunction aMemMovefn) + { + TInt tfr=0; + for (;;) + { + TInt len=Min(aLength,iLimit-iAvail); + if (len && aBuffer) + { + aMemMovefn(aBuffer,iAvail,len); + aBuffer+=len; + } + aLength-=len; + iAvail+=len; + tfr+=len; + if (aLength==0) + return tfr; + len=InflateL(); + if (len==0) + return tfr; + iAvail=iOut; + iLimit=iAvail+len; + } + } + +// --------------------------------------------------------------------------- + +TInt CInflater::SkipL(TInt aLength) + { + return ReadL(0,aLength,Mem::Move); + } + +// --------------------------------------------------------------------------- + +void CInflater::InitL() + { + Huffman::InternalizeL(*iBits,iEncoding->iLitLen,KDeflationCodes); + + if (!Huffman::IsValid(iEncoding->iLitLen,TEncoding::ELitLens) || + !Huffman::IsValid(iEncoding->iDistance,TEncoding::EDistances)) + User::Leave(KErrCorrupt); + + Huffman::Decoding(iEncoding->iLitLen,TEncoding::ELitLens,iEncoding->iLitLen); + Huffman::Decoding(iEncoding->iDistance,TEncoding::EDistances,iEncoding->iDistance,KDeflateDistCodeBase); + } + +// --------------------------------------------------------------------------- + +TInt CInflater::InflateL() + { + TUint8* out=iOut; + TUint8* const end=out+KDeflateMaxDistance; + const TUint32* tree=iEncoding->iLitLen; + if (iLen<0) // EOF + return 0; + if (iLen>0) + goto useHistory; + + while (outHuffmanL(tree)-TEncoding::ELiterals; + if (val<0) + { + *out++=TUint8(val); + continue; + } + if (val==TEncoding::EEos-TEncoding::ELiterals) + { + iLen=-1; + break; + } + + TInt code=val&0xff; + if (code>=8) + { + TInt xtra=(code>>2)-1; + code-=xtra<<2; + code<<=xtra; + code|=iBits->ReadL(xtra); + } + if (valiDistance; + continue; + } + + iRptr=out-(code+1); + if (iRptr+KDeflateMaxDistanceiLitLen; + }; + + return out-iOut; + } + +// --------------------------------------------------------------------------- + +TFileInput::TFileInput(RFile& aFile) + :iFile(aFile),iReadBuf(iBuf1),iPtr(iBuf1,KBufSize) + { + aFile.Read(iPtr,iStat); + } + +// --------------------------------------------------------------------------- + +void TFileInput::Cancel() + { + if (iReadBuf) + User::WaitForRequest(iStat); + } + +// --------------------------------------------------------------------------- + +void TFileInput::UnderflowL() + { + TUint8* b=iReadBuf; + ASSERT(b!=NULL); + User::WaitForRequest(iStat); + iReadBuf=0; + User::LeaveIfError(iStat.Int()); + if(iPtr.Length()==0) + User::Leave(KErrCorrupt); + Set(b,iPtr.Length()*8); + + b = b==iBuf1 ? iBuf2 : iBuf1; + iPtr.Set(b,0,KBufSize); + iFile.Read(iPtr,iStat); + iReadBuf=b; + } + +// --------------------------------------------------------------------------- + +TFileNameInfo::TFileNameInfo() + { + memclr(this, sizeof(TFileNameInfo)); + } + +// --------------------------------------------------------------------------- + +TInt TFileNameInfo::Set(const TDesC8& aFileName, TUint aFlags) + { + iUid = 0; + iVersion = 0; + iPathPos = 0; + iName = aFileName.Ptr(); + iLen = aFileName.Length(); + iExtPos = aFileName.LocateReverse('.'); + if (iExtPos<0) + iExtPos = iLen; + TInt osq = aFileName.LocateReverse('['); + TInt csq = aFileName.LocateReverse(']'); + if (!(aFlags & EAllowUid) && (osq>=0 || csq>=0)) + { + return KErrBadName; + } + if (osq>=iExtPos || csq>=iExtPos) + { + return KErrBadName; + } + TInt p = iExtPos; + if ((aFlags & EAllowUid) && p>=10 && iName[p-1]==']' && iName[p-10]=='[') + { + TPtrC8 uidstr(iName + p - 9, 8); + TLex8 uidlex(uidstr); + TUint32 uid = 0; + TInt r = uidlex.Val(uid, EHex); + if (r==KErrNone && uidlex.Eos()) + iUid = uid, p -= 10; + } + iUidPos = p; + TInt ob = aFileName.LocateReverse('{'); + TInt cb = aFileName.LocateReverse('}'); + if (ob>=iUidPos || cb>=iUidPos) + { + return KErrBadName; + } + if (ob>=0 && cb>=0 && p-1==cb) + { + TPtrC8 p8(iName, p); + TInt d = p8.LocateReverse('.'); + TPtrC8 verstr(iName+ob+1, p-ob-2); + TLex8 verlex(verstr); + if (ob==p-10 && dob && p-1>d && (aFlags & EAllowDecimalVersion)) + { + TUint32 maj = 0; + TUint32 min = 0; + TInt r = verlex.Val(maj, EDecimal); + TUint c = (TUint)verlex.Get(); + TInt r2 = verlex.Val(min, EDecimal); + if (r==KErrNone && c=='.' && r2==KErrNone && verlex.Eos() && maj<32768 && min<32768) + iVersion = (maj << 16) | min, p = ob; + } + } + iVerPos = p; + if (iLen>=2 && iName[1]==':') + { + TUint c = iName[0]; + if (c!='?' || !(aFlags & EAllowPlaceholder)) + { + c |= 0x20; + if (c<'a' || c>'z') + { + return KErrBadName; + } + } + iPathPos = 2; + } + TPtrC8 pathp(iName+iPathPos, iVerPos-iPathPos); + if (pathp.Locate('[')>=0 || pathp.Locate(']')>=0 || pathp.Locate('{')>=0 || pathp.Locate('}')>=0 || pathp.Locate(':')>=0) + { + return KErrBadName; + } + iBasePos = pathp.LocateReverse('\\') + 1 + iPathPos; + + return KErrNone; + } + +// --------------------------------------------------------------------------- + +void TFileNameInfo::GetName(TDes8& aName, TUint aFlags) const + { + if (aFlags & EIncludeDrive) + aName.Append(Drive()); + if (aFlags & EIncludePath) + { + if (PathLen() && iName[iPathPos]!='\\') + aName.Append('\\'); + aName.Append(Path()); + } + if (aFlags & EIncludeBase) + aName.Append(Base()); + if ((aFlags & EForceVer) || ((aFlags & EIncludeVer) && VerLen()) ) + { + aName.Append('{'); + aName.AppendNumFixedWidth(iVersion, EHex, 8); + aName.Append('}'); + } + if ((aFlags & EForceUid) || ((aFlags & EIncludeUid) && UidLen()) ) + { + aName.Append('['); + aName.AppendNumFixedWidth(iUid, EHex, 8); + aName.Append(']'); + } + if (aFlags & EIncludeExt) + aName.Append(Ext()); + } + +// --------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/launcher/engine/src/launcherdllelement.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/launcher/engine/src/launcherdllelement.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,191 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "launcherdllelement.h" +#include "launchertraces.h" + +// --------------------------------------------------------------------------- + +CLauncherDLLElement::~CLauncherDLLElement() + { + LOGSTRING("Launcher: CLauncherDLLElement::~CLauncherDLLElement"); + } + +// --------------------------------------------------------------------------- + +CLauncherDLLElement::CLauncherDLLElement() + { + } + +// --------------------------------------------------------------------------- + +CLauncherDLLElement* CLauncherDLLElement::NewL() + { + LOGSTRING("Launcher: CLauncherDLLElement::NewL"); + CLauncherDLLElement* self = CLauncherDLLElement::NewLC(); + CleanupStack::Pop(); + return self; + } + +// --------------------------------------------------------------------------- + +CLauncherDLLElement* CLauncherDLLElement::NewLC() + { + LOGSTRING("Launcher: CLauncherDLLElement::NewLC"); + CLauncherDLLElement* self = new (ELeave) CLauncherDLLElement; + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +// --------------------------------------------------------------------------- + +void CLauncherDLLElement::ConstructL() + { + + } + +// --------------------------------------------------------------------------- + +TBool CLauncherDLLElement::CompareL(const CLauncherDLLElement& aReferenceElement, RArray& aDifferenceList) const + { + LOGSTRING2("Launcher: CLauncherDLLElement::CompareL - DLLName: %S", &iName); + if( iName != aReferenceElement.Name()) + { + LOGSTRING("Launcher: CLauncherDLLElement::CompareL: ERROR - DLL names don't match."); + User::Leave(KErrArgument); + } + + TBool diff = EFalse; + + if( iUID1 != aReferenceElement.UID1()) + { + diff = ETrue; + aDifferenceList.AppendL(this->EDifference_UID1); + LOGSTRING3("Launcher: CLauncherDLLElement::CompareL - UID1s differs: %x vs. %x", iUID1, aReferenceElement.UID1()); + } + if( iUID2!= aReferenceElement.UID2()) + { + diff = ETrue; + aDifferenceList.AppendL(this->EDifference_UID2); + LOGSTRING3("Launcher: CLauncherDLLElement::CompareL - UID2s differs: %x vs. %x", iUID2, aReferenceElement.UID2()); + } + if( iUID3 != aReferenceElement.UID3()) + { + diff = ETrue; + aDifferenceList.AppendL(this->EDifference_UID3); + LOGSTRING3("Launcher: CLauncherDLLElement::CompareL - UID3s differs: %x vs. %x", iUID3, aReferenceElement.UID3()); + } + if( iSID != aReferenceElement.SID()) + { + diff = ETrue; + aDifferenceList.AppendL(this->EDifference_SID); + LOGSTRING3("Launcher: CLauncherDLLElement::CompareL - SIDs differs: %x vs. %x", iSID, aReferenceElement.SID()); + } + if( iCapability != aReferenceElement.Capability()) + { + diff = ETrue; + aDifferenceList.AppendL(this->EDifference_Capability); + LOGSTRING3("Launcher: CLauncherDLLElement::CompareL - Capabilities differs: %x vs. %x", iCapability, aReferenceElement.Capability()); + } + + return diff; + } + +// --------------------------------------------------------------------------- + +TFileName CLauncherDLLElement::Name() const + { + return iName; + } + +// --------------------------------------------------------------------------- + +void CLauncherDLLElement::SetNameL(const TFileName& aName) + { + iName.Copy(aName); + } + +// --------------------------------------------------------------------------- + +TUid CLauncherDLLElement::UID1() const + { + return iUID1; + } + +// --------------------------------------------------------------------------- + +void CLauncherDLLElement::SetUID1L(TUid aUID1) + { + iUID1.iUid = aUID1.iUid; + } + +// --------------------------------------------------------------------------- + +TUid CLauncherDLLElement::UID2() const + { + return iUID2; + } + +// --------------------------------------------------------------------------- + +void CLauncherDLLElement::SetUID2L(TUid aUID2) + { + iUID2 = aUID2; + } + +// --------------------------------------------------------------------------- + +TUid CLauncherDLLElement::UID3() const + { + return iUID3; + } + +// --------------------------------------------------------------------------- + +void CLauncherDLLElement::SetUID3L(TUid aUID3) + { + iUID3 = aUID3; + } + +// --------------------------------------------------------------------------- + +TUid CLauncherDLLElement::SID() const + { + return iSID; + } + +// --------------------------------------------------------------------------- + +void CLauncherDLLElement::SetSIDL(TUid aSID) + { + iSID = aSID; + } + +// --------------------------------------------------------------------------- + +TUint32 CLauncherDLLElement::Capability() const + { + return iCapability; + } + +// --------------------------------------------------------------------------- + +void CLauncherDLLElement::SetCapabilityL(TUint32 aCapability) + { + iCapability = aCapability; + } diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/launcher/engine/src/launcherdllparser.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/launcher/engine/src/launcherdllparser.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,133 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "launcherdllparser.h" +#include "launchertraces.h" + +// --------------------------------------------------------------------------- + +CLauncherDLLParser::~CLauncherDLLParser() + { + LOGSTRING("Launcher: CLauncherDLLParser::~CLauncherDLLParser"); + } + +// --------------------------------------------------------------------------- + +CLauncherDLLParser::CLauncherDLLParser() + { + LOGSTRING("Launcher: CLauncherDLLParser::CLauncherDLLParser"); + } + +// --------------------------------------------------------------------------- + +CLauncherDLLParser* CLauncherDLLParser::NewL() + { + LOGSTRING("Launcher: CLauncherDLLParser::NewL"); + CLauncherDLLParser* self = CLauncherDLLParser::NewLC(); + CleanupStack::Pop(); + return self; + } + +// --------------------------------------------------------------------------- + +CLauncherDLLParser* CLauncherDLLParser::NewLC() + { + LOGSTRING("Launcher: CLauncherDLLParser::NewLC"); + CLauncherDLLParser* self = new (ELeave) CLauncherDLLParser; + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +// --------------------------------------------------------------------------- + +void CLauncherDLLParser::ConstructL() + { + + } + +// --------------------------------------------------------------------------- + +void CLauncherDLLParser::ParseL( RFs& aFileSession, RFile& aFile, CLauncherDLLElement& aElement ) + { + TFileName dllName; + TFileName fullName; + TUid tmpUID; + TInt offset = 0; + + aFile.Name(dllName); + aFile.FullName(fullName); + aElement.SetNameL(dllName); + + TBool isFileInRom = aFileSession.IsFileInRom(fullName) != 0; + + /** + * Read UID1 + */ + offset = UID1_OFFSET; + aFile.Seek(ESeekStart, offset); // Set file position + tmpUID.iUid = ReadUint32L(aFile); + aElement.SetUID1L(tmpUID); + + /** + * Read UID2 + */ + offset = UID2_OFFSET; + aFile.Seek(ESeekStart, offset); // Set file position + tmpUID.iUid = ReadUint32L(aFile); + aElement.SetUID2L(tmpUID); + + /** + * Read UID3 + */ + offset = UID3_OFFSET; + aFile.Seek(ESeekStart, offset); // Set file position + tmpUID.iUid = ReadUint32L(aFile); + aElement.SetUID3L(tmpUID); + + /** + * Read SID + */ + if( isFileInRom ) + offset = SID_OFFSET_ROM; + else + offset = SID_OFFSET_ROFS; + aFile.Seek(ESeekStart, offset); // Set file position + tmpUID.iUid = ReadUint32L(aFile); + aElement.SetSIDL(tmpUID); + + /** + * Read Capability + */ + if( isFileInRom ) + offset = CAPABILITY_OFFSET_ROM; + else + offset = CAPABILITY_OFFSET_ROFS; + aFile.Seek(ESeekStart, offset); // Set file position + TUint32 tmpVal = ReadUint32L(aFile); + aElement.SetCapabilityL(tmpVal); + } + +// --------------------------------------------------------------------------- + +TUint32 CLauncherDLLParser::ReadUint32L( RFile& aFile ) + { + TBuf8<4> tempBuf; + User::LeaveIfError(aFile.Read(tempBuf, 4)); + const TUint8* ptr = tempBuf.Ptr(); + return TUint32(ptr[0] | (ptr[1]<<8) | (ptr[2]<<16) | (ptr[3]<<24)); + } diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/launcher/engine/src/launcherengine.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/launcher/engine/src/launcherengine.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,1665 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include +#include +#include +#include +#include + +#include "launchertraces.h" +#include "e32image.h" +#include "launcherxmlparser.h" +#include "launcherdllparser.h" +#include "launcherengine.h" + +_LIT(KLogFileName, "LauncherLog.txt"); +_LIT(KBCLogFileName, "LauncherBCLog.txt"); +_LIT(KSystemDllsFileName, "SystemDlls.txt"); +_LIT(KRequiredDllsFileName, "RequiredDlls.xml"); +_LIT(KDotXML,".xml"); +_LIT(KDotLauncherXML,".launcherxml"); + +_LIT(KFileSeparator, "\t"); +_LIT(KFileNewLine, "\r\n"); + +_LIT(KNewLine, "\n"); + +const TInt KMaxAppsArraySize=250; +const TInt KMaxDllArraySize=5000; +const TInt KLauncherLogBufferSize = 4096; + +// After this many issues, issues are buffered and printed +// in the end of analysis +const TInt KBigBufferUsageThreshold=10; + +// Buffer allocation unit +const TInt KBigBufferAllocBytes=1024; + +// --------------------------------------------------------------------------- + +CLauncherEngine* CLauncherEngine::NewL(MLauncherUI *aLauncherUI) + { + CLauncherEngine* self = new(ELeave) CLauncherEngine; + CleanupStack::PushL(self); + self->ConstructL(aLauncherUI); + CleanupStack::Pop(); + return self; + } + +// --------------------------------------------------------------------------- + +CLauncherEngine::CLauncherEngine() : CActive(EActivePriorityIpcEventsHigh) + { + } + +// --------------------------------------------------------------------------- + +template +void AppendLogBufferL(const TDesC& aText, T*& aBuf, TInt aIncreaseStep = KLauncherLogBufferSize) + { + if( aBuf == 0 ) + { + aBuf = T::NewL(aIncreaseStep); + } + + TInt currentMaxLength = aBuf->Des().MaxLength(); + if( aBuf->Des().Length() + aText.Length() > currentMaxLength ) + { + TInt increaseSize = Max(aText.Length(), aIncreaseStep); + aBuf = aBuf->ReAllocL(aBuf->Des().MaxLength() + increaseSize ); + } + aBuf->Des().Append(aText); + } + +// --------------------------------------------------------------------------- + +void CLauncherEngine::ConstructL(MLauncherUI *aLauncherUI) + { + LOGSTRING("Launcher: CLauncherEngine::ConstructL"); + + User::LeaveIfNull( aLauncherUI ); + + iLauncherUI = aLauncherUI; + + + iEnv = CEikonEnv::Static(); + iLaunchingIsActive = EFalse; + iDLLAnalysisIsActive = EFalse; + iSkipHiddenAndEmbedOnly = ETrue; + + User::LeaveIfError(iTimer.CreateLocal()); + + User::LeaveIfError(iLs.Connect()); + User::LeaveIfError(iWs.Connect()); + + iAppThreadChecker = CAppThreadChecker::NewL(this); + iAppRunningChecker = CAppRunningChecker::NewL(this); + + iAllAppsArray = new(ELeave) CDesCArrayFlat(KMaxAppsArraySize); + iAppsArray = new(ELeave) CDesCArrayFlat(KMaxAppsArraySize); + iSystemDllArray = new(ELeave) CDesCArrayFlat(KMaxDllArraySize); + + iLogWriteBuf = HBufC8::NewL(KLauncherLogBufferSize); + + iLogFilePath = PathInfo::PhoneMemoryRootPath(); + iLogFilePath.Append( KLogFileName ); + + iBCLogFilePath = PathInfo::PhoneMemoryRootPath(); + iBCLogFilePath.Append( KBCLogFileName ); + + iSystemDllsFilePath = PathInfo::PhoneMemoryRootPath(); + iSystemDllsFilePath.Append( KSystemDllsFileName ); + + iRequiredDllsFilePath = PathInfo::PhoneMemoryRootPath(); + iRequiredDllsFilePath.Append( KRequiredDllsFileName ); + + iDLLParser = CLauncherDLLParser::NewL(); + + CActiveScheduler::Add(this); + } + +// --------------------------------------------------------------------------- + +CLauncherEngine::~CLauncherEngine() + { + LOGSTRING("Launcher: CLauncherEngine::~CLauncherEngine"); + + Cancel(); + + // close the log + iLogFile.Close(); + iBCLogFile.Close(); + if (iLogWriteBuf) + delete iLogWriteBuf; + + if (iAppRunningChecker) + delete iAppRunningChecker; + + if (iAppThreadChecker) + delete iAppThreadChecker; + + if (iSystemDllArray) + { + iSystemDllArray->Reset(); + delete iSystemDllArray; + } + + if (iAppsArray) + { + iAppsArray->Reset(); + delete iAppsArray; + } + + + if (iAllAppsArray) + { + iAllAppsArray->Reset(); + delete iAllAppsArray; + } + + delete iXMLParser; + // delete iDLLParser; + //delete iDLLElement; + delete iBCIssuesBigBuffer; + + iWs.Close(); + iLs.Close(); + iTimer.Close(); + } + +// --------------------------------------------------------------------------- + +void CLauncherEngine::DoCancel() + { + LOGSTRING("Launcher: CLauncherEngine::DoCancel"); + + if( iXMLParser ) + { + iXMLParser->Cancel(); + } + iTimer.Cancel(); + + } + +// --------------------------------------------------------------------------- + +void CLauncherEngine::RunL() + { + + LOGSTRING("Launcher: CLauncherEngine::RunL"); + TInt err = iStatus.Int(); + User::LeaveIfError(err); + + // write full app path to the log file + WriteInitialStuffToTheLogL(iAppsArray->MdcaPoint(iAppLaunchCounter), iLogFile); + + // get the uid of the current app + iCurrentAppUid = KNullUid; + TApaAppInfo appInfo; + iLs.GetAllApps(); + while (iLs.GetNextApp(appInfo) == KErrNone) + { + if (appInfo.iFullName.CompareF( iAppsArray->MdcaPoint(iAppLaunchCounter) ) == 0) + { + iCurrentAppUid = appInfo.iUid; + break; + } + } + + if (iCurrentAppUid == KNullUid) + { + iLogWriteBuf->Des().Append(_L("[WARN: App has no UID] ")); + } + + // parse the filename + TParse nameParser; + nameParser.SetNoWild(iAppsArray->MdcaPoint(iAppLaunchCounter), NULL, NULL); + iCurrentAppNameAndExt.Copy(nameParser.Drive()); + iCurrentAppNameAndExt.Append(nameParser.NameAndExt()); + + // do not try to launch these apps + if (iAppsArray->MdcaPoint(iAppLaunchCounter).FindF(_L("\\Launcher.")) != KErrNotFound + || iAppsArray->MdcaPoint(iAppLaunchCounter).FindF(_L("\\Phone.")) != KErrNotFound + || iAppsArray->MdcaPoint(iAppLaunchCounter).FindF(_L("\\Startup.")) != KErrNotFound + || iAppsArray->MdcaPoint(iAppLaunchCounter).FindF(_L("\\SplashScreen.")) != KErrNotFound + || iAppsArray->MdcaPoint(iAppLaunchCounter).FindF(_L("\\eshell.")) != KErrNotFound) + { + + iLauncherUI->PrintText(iCurrentAppNameAndExt); + iLauncherUI->PrintText(_L(": SKIPPED automatically\n")); + + iLogWriteBuf->Des().Append(_L("[SKIPPED automatically] ")); + iLogWriteBuf->Des().Append(KFileNewLine); + iLogFile.Write(iLogWriteBuf->Des()); + + iSkippedCases++; + CheckForMoreAppsL(); + } + + else + { + + // dependency check not needed if the app is in the ROM/ROFS, because they'll be checked automatically + // when the rom image is built + + if (iCurrentAppNameAndExt[0] != 'Z' && iCurrentAppNameAndExt[0] != 'z') + { + + if (iCurrentAppNameAndExt[2] == '[') // this is quite likely a Java application, no dependency test needed + { + iLogWriteBuf->Des().Append(_L("[Dependency check not done] ")); + } + else + { // otherwise check depencies + + #ifdef __WINS__ + + // emulator not supported + + #else + + // ELF binaries + + CDesCArray* missingDllArray = NULL; + + TRAPD(err, missingDllArray = DependencyCheckForE32ImageL()); + + // some error happened while processing the E32 image + if (err != KErrNone) + { + + iLauncherUI->PrintText(iCurrentAppNameAndExt); + iLauncherUI->PrintText(_L(": unable to read import table!\n")); + + iLogWriteBuf->Des().Append(_L("[Unable to read import table!] ")); + } + + // print missing dependencies + else if (err==KErrNone && missingDllArray) + { + if (missingDllArray->MdcaCount() > 0) + { + iLauncherUI->PrintText(iCurrentAppNameAndExt); + iLauncherUI->PrintText(_L(": missing dependencies: ")); + + iLogWriteBuf->Des().Append(_L("[Missing dependencies: ")); + + for (TInt k=0; kMdcaCount(); k++) + { + iLauncherUI->PrintText(missingDllArray->MdcaPoint(k)); + iLauncherUI->PrintText(_L(" ")); + + iLogWriteBuf->Des().Append(missingDllArray->MdcaPoint(k)); + iLogWriteBuf->Des().Append(_L(" ")); + } + + iLauncherUI->PrintText(_L("\n")); + + iLogWriteBuf->Des().Append(_L("] ")); + } + } + + if (missingDllArray) + delete missingDllArray; + + #endif + + } // if '[' + } // if 'Z' + + + + // check if the app is already running + TApaTaskList taskList(iWs); + TApaTask thisTask = taskList.FindApp(iCurrentAppUid); + if (thisTask.Exists()) + { + iLogWriteBuf->Des().Append(_L(" [OK: App already running]")); + iLogWriteBuf->Des().Append(KFileNewLine); + iLogFile.Write(iLogWriteBuf->Des()); + + iOkCases++; + CheckForMoreAppsL(); + } + + else + { + // check the program's capabilities + TApaAppCapabilityBuf buf; + iLs.GetAppCapability(buf, iCurrentAppUid); + TApaAppCapability cap = buf(); + + // if it's embeddable only, don't launch if setting is enabled + if (cap.iEmbeddability == TApaAppCapability::EEmbeddableOnly && SkipHiddenAndEmbedOnly()) + { + + iLauncherUI->PrintText(iCurrentAppNameAndExt); + iLauncherUI->PrintText(_L(": SKIPPED: embeddable only\n")); + + iLogWriteBuf->Des().Append(_L("[SKIPPED: embeddable only] ")); + iLogWriteBuf->Des().Append(KFileNewLine); + iLogFile.Write(iLogWriteBuf->Des()); + + iSkippedCases++; + CheckForMoreAppsL(); + } + + // if it's hidden, don't launch if setting is enabled + else if (cap.iAppIsHidden && SkipHiddenAndEmbedOnly()) + { + + iLauncherUI->PrintText(iCurrentAppNameAndExt); + iLauncherUI->PrintText(_L(": SKIPPED: hidden\n")); + + iLogWriteBuf->Des().Append(_L("[SKIPPED: hidden] ")); + iLogWriteBuf->Des().Append(KFileNewLine); + iLogFile.Write(iLogWriteBuf->Des()); + + iSkippedCases++; + CheckForMoreAppsL(); + } + + // otherwise do the normal launch test + else + { + LaunchApplicationL(); + } + + } //if (thisTask.Exists()) + + } //if (iAppsArray->MdcaPoint(iAppLaunchCounter).FindF + + } + +// --------------------------------------------------------------------------- + +CDesCArray* CLauncherEngine::ListOfAllAppsL() + { + LOGSTRING("Launcher: CLauncherEngine::ListOfAllAppsL"); + + // find all DLLs from the system + iSystemDllArray->Reset(); + TRAP_IGNORE( FindFiles(_L("*.dll"), _L("\\sys\\bin\\")) ); + + // write the list of DLLs to a file + RFile dllFile; + if (dllFile.Replace(iEnv->FsSession(), iSystemDllsFilePath, EFileWrite) == KErrNone) + { + TBuf8 dllName; + + for (TInt i=0; iMdcaCount(); i++) + { + dllName.Copy( iSystemDllArray->MdcaPoint(i) ); + dllName.Append( KFileNewLine ); + + dllFile.Write( dllName ); + } + + dllFile.Close(); + } + + // reset the apps list + iAllAppsArray->Reset(); + + // search all apps + TApaAppInfo appInfo; + iLs.GetAllApps(); + + while (iLs.GetNextApp(appInfo) == KErrNone) + { + iAllAppsArray->AppendL(appInfo.iFullName); + } + + + // remove launcher.app / launcher.exe from the list + for (TInt i=0; iMdcaCount(); i++) + { + if (iAllAppsArray->MdcaPoint(i).FindF(_L("\\Launcher.")) != KErrNotFound) + { + iAllAppsArray->Delete(i); + iAllAppsArray->Compress(); + break; + } + } + + // sort the elements + iAllAppsArray->Sort(); + + return iAllAppsArray; + } + +// --------------------------------------------------------------------------- + +TInt CLauncherEngine::FindFiles(const TDesC& aFileName, const TDesC& aPath) + { + TFindFile fileFinder(iEnv->FsSession()); + CDir* fileList; + TInt err = fileFinder.FindWildByDir(aFileName, aPath, fileList); + + while (err == KErrNone) + { + for (TInt i=0; iCount(); i++) + { + TParse fullentry; + fullentry.Set((*fileList)[i].iName, &fileFinder.File(), NULL); + + TRAP(err, iSystemDllArray->AppendL(fullentry.NameAndExt())); + } + + delete fileList; + err = fileFinder.FindWild(fileList); + } + return err; + } + +// --------------------------------------------------------------------------- + + +void CLauncherEngine::StartAppLaunchingL(const CArrayFix* aSelectedApps, TBool aAutoClose) + { + LOGSTRING("Launcher: CLauncherEngine::StartAppLaunchingL"); + + // check that we have something to launch + if (aSelectedApps->Count() <= 0) + { + _LIT(message, "Nothing selected"); + iLauncherUI->ShowErrorMessage(message); + } + else + { + // update the list of applications to be tested + iAppsArray->Reset(); + + TInt ref(0); + TKeyArrayFix key(0, ECmpTUint16); + TInt index(0); + + for (TInt i=0; iMdcaCount(); i++) + { + ref = i; + + // if the application is selected, append it to the apps array + if (aSelectedApps->Find(ref, key, index) == 0) + { + iAppsArray->AppendL(iAllAppsArray->MdcaPoint(i)); + } + } + + + // to make sure that our algorithm works correctly + if (iAppsArray->MdcaCount() != aSelectedApps->Count()) + { + _LIT(message, "Something went wrong..."); + iLauncherUI->ShowErrorMessage(message); + } + + + // init + Cancel(); + iLaunchingIsActive = ETrue; + iAutoClose = aAutoClose; + iAppLaunchCounter = 0; + iFailedCases = 0; + iOkCases = 0; + iSkippedCases = 0; + iTotalNumberOfCases = iAppsArray->MdcaCount(); + iCurrentAppUid = KNullUid; + + // open the log file for writing + if (iLogFile.Open(iEnv->FsSession(), iLogFilePath, EFileWrite) != KErrNone) + { + iEnv->FsSession().MkDirAll(iLogFilePath); + iLogFile.Replace(iEnv->FsSession(), iLogFilePath, EFileWrite); + } + else + { + // file opens correctly, seek to the end + TInt fileSize=0; + iLogFile.Size(fileSize); + iLogFile.Seek(ESeekCurrent, fileSize); + } + + // change focus to output view!! + iLauncherUI->ChangeFocusToOutputView(); + + //text to log + iLauncherUI->PrintText(_L("New test started.\n")); + + // start the first launch! + IssueLaunch(); + + } + } + +// --------------------------------------------------------------------------- + +void CLauncherEngine::IssueLaunch() + { + LOGSTRING("Launcher: CLauncherEngine::IssueLaunch"); + + __ASSERT_ALWAYS(!IsActive(), User::Panic(_L("Timing error?"), 100)); + + // this should keep the backlight on + User::ResetInactivityTime(); + + iDLLAnalysisIsActive = EFalse; + // some delay + iTimer.After(iStatus, 1000000); + SetActive(); + } + +// --------------------------------------------------------------------------- + +// --------------------------------------------------------------------------- + +void CLauncherEngine::WriteInitialStuffToTheLogL(const TDesC& aOwnData, RFile& aFile) + { + LOGSTRING("Launcher: CLauncherEngine::WriteInitialStuffToTheLog"); + + TTime time; + time.HomeTime(); + TBuf<32> currentTime; + TBuf<32> currentDate; + + // current date + _LIT(KCurrentDate,"%D%M%Y%/0%1%/1%2%/2%3%/3"); + time.FormatL(currentDate, KCurrentDate); + iLogWriteBuf->Des().Copy(currentDate); + AppendLogBufferL(KFileSeparator(), iLogWriteBuf); + + // current time + _LIT(KCurrentTime,"%-B%:0%J%:1%T%:2%S%:3%+B"); + time.FormatL(currentTime, KCurrentTime); + AppendLogBufferL(currentTime, iLogWriteBuf); + AppendLogBufferL(KFileSeparator(), iLogWriteBuf); + + // available RAM memory + TMemoryInfoV1Buf memory; + UserHal::MemoryInfo(memory); + iLogWriteBuf->Des().AppendNum(memory().iFreeRamInBytes); + AppendLogBufferL(KFileSeparator(), iLogWriteBuf); + + // own data, eg. application name + AppendLogBufferL(aOwnData, iLogWriteBuf); + AppendLogBufferL(KFileSeparator(), iLogWriteBuf); + AppendLogBufferL(KFileNewLine(), iLogWriteBuf); + + // write the buffer to the file + aFile.Write(iLogWriteBuf->Des()); + + // clear the buffer + iLogWriteBuf->Des().Copy(_L("")); + } + +// --------------------------------------------------------------------------- + + +void CLauncherEngine::CheckForMoreAppsL() + { + LOGSTRING("Launcher: CLauncherEngine::CheckForMoreAppsL"); + + // make sure the launcher app is in the foreground + TApaTaskList taskList(iWs); + TUid launcherAppUid; + launcherAppUid.iUid = 0x101FB74F; + TApaTask launcherTask = taskList.FindApp(launcherAppUid); + launcherTask.BringToForeground(); + + + // check if we have more test to be executed + if ( iAppLaunchCounter >= iTotalNumberOfCases-1 ) + { + + // all done, show stats + TBuf<200> message; + message.Append( _L("Done: ") ); + message.AppendNum( iOkCases ); + message.Append( _L(" ok, ") ); + message.AppendNum( iFailedCases ); + message.Append( _L(" failed, ") ); + message.AppendNum( iSkippedCases ); + message.Append( _L(" skipped.") ); + + // print the message to the output screen + iLauncherUI->PrintText(message); + iLauncherUI->PrintText(_L("\n\n")); + + //write same stuff to the log + WriteInitialStuffToTheLogL(message, iLogFile); + iLogWriteBuf->Des().Copy(KFileNewLine); + iLogWriteBuf->Des().Append(KFileNewLine); + iLogFile.Write(iLogWriteBuf->Des()); + + // close the log + iLogFile.Close(); + + iLaunchingIsActive = EFalse; + + // all apps launched + _LIT(KAllDoneMessage, "All apps launched"); + iLauncherUI->ShowInfoMessage(KAllDoneMessage); + } + else + { + // more apps to be launched, maintain requests + iAppLaunchCounter++; + IssueLaunch(); + } + + } + +// --------------------------------------------------------------------------- + +void CLauncherEngine::LaunchApplicationL() + { + LOGSTRING("Launcher: CLauncherEngine::LaunchApplication"); + LOGSTRING3("Launcher: Trying to launch %S, UID: %d", &iCurrentAppNameAndExt, iCurrentAppUid.iUid); + + TRAPD(err, DoLaunchApplicationL()); + + if (err!=KErrNone) + { + iLogWriteBuf->Des().Append(_L("[FAIL: Cannot launch the app] ")); + + iLauncherUI->PrintText(iCurrentAppNameAndExt); + iLauncherUI->PrintText(_L(": cannot launch\n")); + + // write the buffer to the log + iLogWriteBuf->Des().Append(KFileNewLine); + iLogFile.Write(iLogWriteBuf->Des()); + + // this application isn't even launchable, go to next one + iFailedCases++; + CheckForMoreAppsL(); + } + + } +// --------------------------------------------------------------------------- + + +void CLauncherEngine::DoLaunchApplicationL() + { + LOGSTRING("Launcher: CLauncherEngine::DoLaunchApplicationL"); + + // create a new handle + RThread newThreadHandle; + iCurrentAppThread = newThreadHandle; + + + // Find the task with uid3 + TApaTaskList tasklist(iWs); + TApaTask task=tasklist.FindApp(iCurrentAppUid); + + if (task.Exists()) + // Task exists, bring it to foreground + { + task.BringToForeground(); + } + else + // Task doesn't exist, launch a new instance of an application + { + TApaAppInfo appInfo; + User::LeaveIfError(iLs.GetAppInfo(appInfo, iCurrentAppUid)); + TApaAppCapabilityBuf capBuf; + User::LeaveIfError(iLs.GetAppCapability(capBuf, iCurrentAppUid)); + TApaAppCapability& caps = capBuf(); + + CApaCommandLine* cmdLine=CApaCommandLine::NewLC(); + cmdLine->SetExecutableNameL(appInfo.iFullName); + + if ( caps.iLaunchInBackground ) + // Apps capability defines that the app is launched in background + { + cmdLine->SetCommandL(EApaCommandBackground); + } + else + { + cmdLine->SetCommandL(EApaCommandRun); + } + + // start the app + User::LeaveIfError(iLs.StartApp(*cmdLine, iCurrentAppThreadId)); + + // activate thread checker active object + iAppThreadChecker->ActivateChecking(); + + // now open a handle to the thread and register death notifier + TInt err = iCurrentAppThread.Open(iCurrentAppThreadId); + if (err == KErrNone) + iCurrentAppThread.Logon(iAppThreadChecker->iStatus); + else + { + iCurrentAppThread.Close(); + TRequestStatus* status = &iAppThreadChecker->iStatus; + User::RequestComplete(status, KErrNone); + iAppThreadChecker->Cancel(); + User::Leave(err); + } + + CleanupStack::PopAndDestroy(); // cmdLine + } + + // the application is now running, start a check to see if it's still alive + iAppRunningChecker->StartTesting(); + + } + +// --------------------------------------------------------------------------- + +void CLauncherEngine::CheckIfAppIsRunningL() + { + LOGSTRING("Launcher: CLauncherEngine::CheckIfAppIsRunningL"); + + // cancel the death notifier since it isn't needed anymore + if( iCurrentAppThread.Handle() != 0 ) + { + iCurrentAppThread.LogonCancel(iAppThreadChecker->iStatus); + } + + // cancel checkers + iAppThreadChecker->Cancel(); + iAppRunningChecker->Cancel(); + + + + // check from the window server if the app is running + TApaTaskList taskList(iWs); + TApaTask thisTask = taskList.FindApp(iCurrentAppUid); + + if( !thisTask.Exists() ) // application not running -> FAIL + { + // check from the thread why it quit + CheckWhyThreadDiedL(); + + // --> CheckForMoreApps() and all the other stuff called from CheckWhyThreadDied() ! + + } + else + { + // app is running! + iOkCases++; + + // close handle to the thread + iCurrentAppThread.Close(); + + + iLogWriteBuf->Des().Append(_L(" [OK]")); + iLogWriteBuf->Des().Append(KFileNewLine); + iLogFile.Write(iLogWriteBuf->Des()); + + + // close the running application if needed + if (iAutoClose) + { + // since the application is still open, let's close it + thisTask.EndTask(); + //User::After(1000); + //thisTask.SendSystemEvent(EApaSystemEventShutdown); + //thisTask.KillTask(); + //User::After(1000); + } + + // this app is done now, move to the next one! + CheckForMoreAppsL(); + + } + } + +// --------------------------------------------------------------------------- + +void CLauncherEngine::CheckWhyThreadDiedL() + { + LOGSTRING("Launcher: CLauncherEngine::CheckWhyThreadDiedL"); + + // cancel the death notifier since it isn't needed anymore + if( iCurrentAppThread.Handle() != 0 ) + { + iCurrentAppThread.LogonCancel(iAppThreadChecker->iStatus); + } + + // make sure all checkers are cancelled + iAppRunningChecker->Cancel(); + iAppThreadChecker->Cancel(); + + TBuf<256> outputText; + outputText.Append(_L("App.Closed. ")); + + + if (iCurrentAppThread.ExitType() == EExitKill) + { + outputText.Append(_L("\"EExitKill\"")); + } + else if (iCurrentAppThread.ExitType() == EExitTerminate) + { + outputText.Append(_L("\"EExitTerminate\"")); + } + else if (iCurrentAppThread.ExitType() == EExitPanic) + { + outputText.Append(_L("\"EExitPanic\"")); + } + else if (iCurrentAppThread.ExitType() == EExitPending) + { + outputText.Append(_L("\"EExitPending\"")); + } + else // unknown reason + { + outputText.Append(_L("\"Exit_Unknown_Reason\"")); + } + + outputText.Append(_L(" code:")); + TInt exitReason = iCurrentAppThread.ExitReason(); + outputText.AppendNum(exitReason); + outputText.Append(_L(" \"")); + + TPtrC exitCategory = iCurrentAppThread.ExitCategory(); + outputText.Append(exitCategory); + + outputText.Append(_L("\"")); + + + // print to screen + iLauncherUI->PrintText(iCurrentAppNameAndExt); + iLauncherUI->PrintText(_L(": ")); + iLauncherUI->PrintText(outputText); + iLauncherUI->PrintText(_L("\n")); + + // write to the log also + iLogWriteBuf->Des().Append(_L(" [FAIL: ")); + iLogWriteBuf->Des().Append(outputText); + iLogWriteBuf->Des().Append(_L("]")); + iLogWriteBuf->Des().Append(KFileNewLine); + + iLogFile.Write(iLogWriteBuf->Des()); + + // close handle to the thread + //iCurrentAppThread.Close(); <-- not safe the close the handle because of the "App.Closed" dialog + // somehow takes ownership of the thread or something + + // nothing to do anymore, move to the next app + iFailedCases++; + CheckForMoreAppsL(); + } + +// --------------------------------------------------------------------------- +// --------------------------------------------------------------------------- + +CDesCArray* CLauncherEngine::DependencyCheckForE32ImageL() + { + LOGSTRING("Launcher: CLauncherEngine::DependencyCheckForE32ImageL"); + + // create an empty array for the missing dll names + CDesCArray* missingDllArray = new(ELeave) CDesCArrayFlat(100); + CleanupStack::PushL(missingDllArray); + + // get a list of DLLs from the E32 image file + E32ImageReader* reader = E32ImageReader::NewLC(); + CDesCArray* dllArray = reader->ListOfDLLsL( iAppsArray->MdcaPoint(iAppLaunchCounter) ); + CleanupStack::PopAndDestroy(); // reader + CleanupStack::PushL(dllArray); + + // compare system DLL and image DLL arrays + TInt pos(0); + for (TInt j=0; jMdcaCount(); j++) + { + if (iSystemDllArray->Find(dllArray->MdcaPoint(j), pos, ECmpFolded) != 0) + { + // DLL not found, append the name to the list of missing DLLs + missingDllArray->AppendL(dllArray->MdcaPoint(j)); + } + } + + CleanupStack::PopAndDestroy(); // dllArray + CleanupStack::Pop(); // missingDllArray + + LOGSTRING("Launcher: CLauncherEngine::DependencyCheckForE32ImageL returns"); + + return missingDllArray; + } + +// --------------------------------------------------------------------------- + +TInt CLauncherEngine::DeleteLogFile() + { + LOGSTRING("Launcher: CLauncherEngine::DeleteLogFile"); + return BaflUtils::DeleteFile(iEnv->FsSession(), iLogFilePath); + } + +// --------------------------------------------------------------------------- + +void CLauncherEngine::StopLaunchingL() + { + LOGSTRING("Launcher: CLauncherEngine::StopLaunchingL"); + if(iLaunchingIsActive) + { + //write to the log + WriteInitialStuffToTheLogL(_L("Cancelled by the user !!! "), iLogFile); + iLogWriteBuf->Des().Copy(KFileNewLine); + iLogWriteBuf->Des().Append(KFileNewLine); + iLogFile.Write(iLogWriteBuf->Des()); + + // close the log + iLogFile.Close(); + + // print to the screen + iLauncherUI->PrintText(_L("Launching cancelled.\n\n")); + + // cancel all active objects + if( iCurrentAppThread.Handle() != 0 ) + { + iCurrentAppThread.LogonCancel(iAppThreadChecker->iStatus); + } + Cancel(); + iAppRunningChecker->Cancel(); + iAppThreadChecker->Cancel(); + + iLaunchingIsActive = EFalse; + + _LIT(KMessage, "Launching cancelled"); + iLauncherUI->ShowInfoMessage(KMessage); + + } + } + +// --------------------------------------------------------------------------- + +TBool CLauncherEngine::LogFileExists() + { + LOGSTRING("Launcher: CLauncherEngine::LogFileExists"); + return BaflUtils::FileExists(iEnv->FsSession(), iLogFilePath); + } + +// --------------------------------------------------------------------------- + +TInt CLauncherEngine::DeleteBCLogFile() + { + LOGSTRING("Launcher: CLauncherEngine::DeleteBCLogFile"); + return BaflUtils::DeleteFile(iEnv->FsSession(), iBCLogFilePath); + } + + +// --------------------------------------------------------------------------- + +TBool CLauncherEngine::BCLogFileExists() + { + LOGSTRING("Launcher: CLauncherEngine::BCLogFileExists"); + return BaflUtils::FileExists(iEnv->FsSession(), iBCLogFilePath); + } + +// --------------------------------------------------------------------------- +void CLauncherEngine::AnalyseDLLsL( const TDesC& aFileName ) + { + LOGSTRING("Launcher: CLauncherEngine::AnalyseDLLsL"); + _LIT(KStartSeparator, "******************************"); + _LIT(KStartingAnalysis, "Starting BC Analysis for DLLs."); + _LIT(KInputFileSelected, "Input file selected: "); + + // Reset found issues counter and buffer + iFoundBCIssues = 0; + delete iBCIssuesBigBuffer; + iBCIssuesBigBuffer = 0; + + // Reset log writing buffer: + iLogWriteBuf->Des().Zero(); + + if( IsActive() ) + { + Cancel(); + } + + iRequiredDllsFilePath = aFileName; + + if( BaflUtils::FileExists(iEnv->FsSession(), iRequiredDllsFilePath) == EFalse ) + { + LOGSTRING2("Launcher: CLauncherEngine::AnalyseDLLsL - can't find input file: %S", &iRequiredDllsFilePath); + User::Leave( KErrNotFound ); + } + + // open the log file for writing + if (iBCLogFile.Open(iEnv->FsSession(), iBCLogFilePath, EFileWrite) != KErrNone) + { + iEnv->FsSession().MkDirAll(iLogFilePath); + User::LeaveIfError( iBCLogFile.Replace(iEnv->FsSession(), iBCLogFilePath, EFileWrite) ); + } + else + { + // file opens correctly, seek to the end + TInt fileSize=0; + iBCLogFile.Size(fileSize); + iBCLogFile.Seek(ESeekCurrent, fileSize); + } + + AppendLogBufferL(KFileNewLine(), iLogWriteBuf); + AppendLogBufferL(KStartSeparator(), iLogWriteBuf); + AppendLogBufferL(KFileNewLine(), iLogWriteBuf); + iBCLogFile.Write(iLogWriteBuf->Des()); + iLogWriteBuf->Des().Zero(); + + // Resolve file type. Should we use XML parsing or just compare DLL list + TBool xmlParsing = + KDotXML().Compare(iRequiredDllsFilePath.Right(KDotXML().Length())) == 0 || + KDotLauncherXML().Compare(iRequiredDllsFilePath.Right(KDotLauncherXML().Length())) == 0; + + // Log analysis starting time and selected input file: + WriteInitialStuffToTheLogL(KStartingAnalysis, iBCLogFile); + AppendLogBufferL(KInputFileSelected(), iLogWriteBuf); + AppendLogBufferL(iRequiredDllsFilePath, iLogWriteBuf); + AppendLogBufferL(KFileNewLine(), iLogWriteBuf); + iBCLogFile.Write(iLogWriteBuf->Des()); + iLogWriteBuf->Des().Zero(); + + if( xmlParsing ) + { + iLauncherUI->ChangeFocusToOutputView(); + DoBCAnalysisL(); + } + else + { + DoCompareDLLListsL(); + } + } + +// --------------------------------------------------------------------------- + +void CLauncherEngine::DoBCAnalysisL() + { + LOGSTRING("Launcher: CLauncherEngine::DoBCAnalysisL"); + if( iXMLParser == 0 ) + { + iXMLParser = CLauncherXMLParser::NewL(iEnv->FsSession()); + } + + TEntry entry; + User::LeaveIfError(iEnv->FsSession().Entry(iRequiredDllsFilePath, entry)); + TInt fileSize = entry.iSize; + + _LIT(KAnalysing,"Analysing DLLs"); + iLauncherUI->ShowProgressBar(KAnalysing, 0, fileSize); + iDLLAnalysisIsActive = ETrue; + + iXMLParser->ParseL(iRequiredDllsFilePath, this); + } + +// --------------------------------------------------------------------------- + +void CLauncherEngine::CancelBCAnalysis() + { + LOGSTRING("Launcher: CLauncherEngine::CancelBCAnalysis"); + if( iXMLParser ) + { + iXMLParser->Cancel(); + } + iLauncherUI->PrintText(_L("\nAnalysis cancelled.\n\n")); + WriteInitialStuffToTheLogL(_L("Analysis cancelled by user"), iBCLogFile); + iLogWriteBuf->Des().Zero(); + iBCLogFile.Close(); + } + +// --------------------------------------------------------------------------- + +void CLauncherEngine::DoCompareDLLListsL() + { + LOGSTRING("Launcher: CLauncherEngine::DoCompareDLLListsL"); + + RFile file; + CleanupClosePushL(file); + + // Show progress bar + _LIT(KAnalysing,"Analysing DLLs"); + iLauncherUI->ShowWaitDialog(KAnalysing); + + if(file.Open(iEnv->FsSession(), iRequiredDllsFilePath, EFileRead) != KErrNone) + { + // Hide wait dialog + iLauncherUI->HideWaitDialog(); + + iLauncherUI->ChangeFocusToOutputView(); + + TBuf<200> msg; + + + msg.Format(_L("Unable to open %S for reading!\n\n"), &iRequiredDllsFilePath); + iLauncherUI->PrintText( msg ); + } + else + { + + CDesCArray* requiredDllArray = new(ELeave) CDesCArrayFlat(KMaxDllArraySize); + CleanupStack::PushL(requiredDllArray); + + // read all lines the text file + TFileName dllName; + TInt i(0); + while( ReadLineFromFileL(file, dllName) == KErrNone && i 1) + requiredDllArray->AppendL(dllName); + + i++; + } + + if (requiredDllArray->MdcaCount() == 0) + { + // Hide wait dialog + iLauncherUI->HideWaitDialog(); + + iLauncherUI->ChangeFocusToOutputView(); + + TBuf<200> msg; + msg.Format(_L("File %S is empty!\n\n"), &iRequiredDllsFilePath); + iLauncherUI->PrintText( msg ); + } + else + { + // compare the arrays and print any missing items + CDesCArray* missingDllArray = new(ELeave) CDesCArrayFlat(KMaxDllArraySize); + CleanupStack::PushL(missingDllArray); + + TInt pos(0); + for (TInt j=0; jMdcaCount(); j++) + { + if (iSystemDllArray->Find(requiredDllArray->MdcaPoint(j), pos, ECmpFolded) != 0) + { + // DLL not found, append the name to the list of missing DLLs + missingDllArray->AppendL(requiredDllArray->MdcaPoint(j)); + } + } + + + if (missingDllArray->MdcaCount() == 0) + { + _LIT(KMessage, "No missing files found"); + AppendLogBufferL(KMessage(), iLogWriteBuf); + iLauncherUI->ShowInfoMessage(KMessage); + } + else + { + iLauncherUI->ChangeFocusToOutputView(); + _LIT(KMissingFiles, "Missing files:\n"); + + //iLauncherUI->PrintText( KMissingFiles ); + AppendLogBufferL(KMissingFiles(), iBCIssuesBigBuffer, KBigBufferAllocBytes); + + AppendLogBufferL(KMissingFiles(), iLogWriteBuf); + + for (TInt i=0; iMdcaCount(); i++) + { + //iLauncherUI->PrintText( missingDllArray->MdcaPoint(i) ); + AppendLogBufferL(missingDllArray->MdcaPoint(i), iBCIssuesBigBuffer, KBigBufferAllocBytes); + //iLauncherUI->PrintText( _L("\n") ); + AppendLogBufferL(KNewLine(), iBCIssuesBigBuffer, KBigBufferAllocBytes); + + AppendLogBufferL(missingDllArray->MdcaPoint(i), iLogWriteBuf); + AppendLogBufferL(KFileNewLine(), iLogWriteBuf); + } + AppendLogBufferL(KNewLine(), iBCIssuesBigBuffer, KBigBufferAllocBytes); + iLauncherUI->PrintText( iBCIssuesBigBuffer->Des() ); + } + + // Hide wait dialog + iLauncherUI->HideWaitDialog(); + + CleanupStack::PopAndDestroy(); // missingDllArray + } + + CleanupStack::PopAndDestroy(); // requiredDllArray + } + + CleanupStack::PopAndDestroy(); //file + iBCLogFile.Write(iLogWriteBuf->Des()); + iLogWriteBuf->Des().Zero(); + iBCLogFile.Close(); + } + +// --------------------------------------------------------------------------- + +void CLauncherEngine::ParsingProgressedL(TInt aBytes) + { + LOGSTRING2("Launcher: CLauncherEngine::ParsingProgressedL - Bytes: %d", aBytes); + iLauncherUI->SetProgressBarValue(aBytes); + } + +// --------------------------------------------------------------------------- + + +void CLauncherEngine::ElementParsedL(const CLauncherDLLElement& aDllElement) + { + LOGSTRING("Launcher: CLauncherEngine::ElementParsedL"); + User::ResetInactivityTime(); + + _LIT(KIndent, " "); + _LIT(KIssuesFound, "Binary compatibility issues found:"); + _LIT(KDLLMissing,"DLL is missing"); + _LIT(KUID1Changed,"UID1 changed"); + _LIT(KUID2Changed,"UID2 changed"); + _LIT(KUID3Changed,"UID3 changed"); + _LIT(KSIDChanged,"SID changed"); + _LIT(KCapabilityChanged,"Capability changed"); + + if( iDLLElement == 0 ) + { + iDLLElement = CLauncherDLLElement::NewL(); + } + + TFindFile fileFinder(iEnv->FsSession()); + _LIT(KDLLPath, "\\sys\\bin\\"); + TInt err = fileFinder.FindByPath(aDllElement.Name(), &KDLLPath); + + TBuf<256> issueStr; + + if( err == KErrNotFound ) + { + if( iFoundBCIssues++ == 0 ) + { + iLauncherUI->PrintText( KIssuesFound ); + iLauncherUI->PrintText( KNewLine ); + AppendLogBufferL(KFileNewLine(), iLogWriteBuf); + AppendLogBufferL(KIssuesFound(), iLogWriteBuf); + AppendLogBufferL(KFileNewLine(), iLogWriteBuf); + } + issueStr.Copy(aDllElement.Name()); + issueStr.Append(KNewLine); + issueStr.Append(KIndent); + issueStr.Append(KDLLMissing); + issueStr.Append(KNewLine); + + AppendLogBufferL(issueStr, iLogWriteBuf); + + TFileName dllName = aDllElement.Name(); + LOGSTRING2("Launcher: DLL not found: %S", &dllName); + if( iFoundBCIssues > KBigBufferUsageThreshold ) + { + if( iBCIssuesBigBuffer == 0) + { + iBCIssuesBigBuffer = HBufC::NewL(KBigBufferAllocBytes); + } + TInt maxSize = iBCIssuesBigBuffer->Des().Length() + issueStr.Length(); + if( maxSize >= iBCIssuesBigBuffer->Des().MaxLength()) + { + iBCIssuesBigBuffer = iBCIssuesBigBuffer->ReAllocL(maxSize + KBigBufferAllocBytes ); + } + TPtr ptr(iBCIssuesBigBuffer->Des()); + ptr += issueStr; + } + else + { + iLauncherUI->PrintText( issueStr); + } + } + else if( err == KErrNone) + { + // File is found, so let's try to open it: + RFile dllFile; + CleanupClosePushL(dllFile); + if( dllFile.Open(iEnv->FsSession(), fileFinder.File(), EFileRead) == KErrNone ) + { + // Parse DLL: + iDLLParser->ParseL(iEnv->FsSession(), dllFile, *iDLLElement); + CleanupStack::PopAndDestroy(); // dllFile + RArray diffs; + CleanupClosePushL(diffs); + + // Compare DLLs: + if( iDLLElement->CompareL(aDllElement, diffs)) + { + if( iFoundBCIssues++ == 0 ) + { + iLauncherUI->PrintText( KIssuesFound ); + iLauncherUI->PrintText( KNewLine ); + AppendLogBufferL(KFileNewLine(), iLogWriteBuf); + AppendLogBufferL(KIssuesFound(), iLogWriteBuf); + AppendLogBufferL(KFileNewLine(), iLogWriteBuf); + } + // Differencies found: + for( TInt i = 0; i < diffs.Count(); ++i ) + { + // Print DLL name: + if( i == 0 ) + { + issueStr.Copy(aDllElement.Name()); + issueStr.Append(KNewLine); + } + + // Print differencies: + issueStr.Append(KIndent); + switch(diffs[i]) + { + case CLauncherDLLElement::EDifference_UID1: + issueStr.Append(KUID1Changed); + break; + case CLauncherDLLElement::EDifference_UID2: + issueStr.Append( KUID2Changed ); + break; + case CLauncherDLLElement::EDifference_UID3: + issueStr.Append( KUID3Changed ); + break; + case CLauncherDLLElement::EDifference_SID: + issueStr.Append( KSIDChanged ); + break; + case CLauncherDLLElement::EDifference_Capability: + issueStr.Append( KCapabilityChanged ); + break; + } + issueStr.Append( KNewLine ); + } + AppendLogBufferL(issueStr, iLogWriteBuf); + if( iFoundBCIssues > KBigBufferUsageThreshold ) + { + // To improve performance, don't print issues to output anymore. + // Instead, store the issues in buffer and print them when analysis is done. + if( iBCIssuesBigBuffer == 0) + { + iBCIssuesBigBuffer = HBufC::NewL(KBigBufferAllocBytes); + } + TInt maxSize = iBCIssuesBigBuffer->Des().Length() + issueStr.Length(); + if( maxSize >= iBCIssuesBigBuffer->Des().MaxLength()) + { + TInt increaseSize = Max(issueStr.Length(), KBigBufferAllocBytes); + iBCIssuesBigBuffer = iBCIssuesBigBuffer->ReAllocL(maxSize + increaseSize ); + } + TPtr ptr(iBCIssuesBigBuffer->Des()); + ptr += issueStr; + } + else + { + iLauncherUI->PrintText( issueStr); + } + } + CleanupStack::Pop(); // diffs + diffs.Close(); + } + else + { + CleanupStack::PopAndDestroy(); // dllFile + } + } + } + +// --------------------------------------------------------------------------- +void CLauncherEngine::DocumentParsedL(TInt aErrorCode) + { + LOGSTRING2("Launcher: CLauncherEngine::DocumentParsedL (Error code: %d)", aErrorCode); + + iDLLAnalysisIsActive = EFalse; + _LIT(KParseError, "Parse error: "); + _LIT(KNoIssues, "No binary compatibility issues found"); + + if( IsActive() ) + { + Cancel(); + } + + //hide progress bar + iLauncherUI->HideProgressBar(); + + if( aErrorCode != KErrNone ) + { + TBuf<16> errorCodeString; + errorCodeString.AppendNum(aErrorCode); + iLauncherUI->PrintText( KNewLine ); + iLauncherUI->PrintText( KParseError ); + iLauncherUI->PrintText( errorCodeString ); + iLauncherUI->PrintText( KNewLine ); + AppendLogBufferL(KFileNewLine(), iLogWriteBuf); + AppendLogBufferL(KParseError(), iLogWriteBuf); + AppendLogBufferL(errorCodeString, iLogWriteBuf); + AppendLogBufferL(KFileNewLine(), iLogWriteBuf); + } + else if(iFoundBCIssues == 0) + { + iLauncherUI->PrintText( KNoIssues ); + iLauncherUI->PrintText( KNewLine ); + AppendLogBufferL(KFileNewLine(), iLogWriteBuf); + AppendLogBufferL(KNoIssues(), iLogWriteBuf); + AppendLogBufferL(KFileNewLine(), iLogWriteBuf); + } + else if( iBCIssuesBigBuffer && iBCIssuesBigBuffer->Des().Length() > 0 ) + { + iLauncherUI->PrintText(iBCIssuesBigBuffer->Des()); + delete iBCIssuesBigBuffer; + iBCIssuesBigBuffer = 0; + } + if( iLogWriteBuf->Length() > 0 && iBCLogFile.SubSessionHandle() != 0) + { + iBCLogFile.Write(iLogWriteBuf->Des()); + } + WriteInitialStuffToTheLogL(_L("Analysis ready"), iBCLogFile); + iLogWriteBuf->Des().Zero(); + iBCLogFile.Close(); + } + +// --------------------------------------------------------------------------- + +TInt CLauncherEngine::ReadLineFromFileL(RFile& aFile, TDes& aReadBuf) + { + LOGSTRING("Launcher: CLauncherEngine::ReadLineFromFile"); + + _LIT8(KImcvCRLF, "\r\n"); + TInt err(KErrNone); + + HBufC8* tempLine = HBufC8::NewLC(1000); + TPtr8 buffer = tempLine->Des(); + + // clear the target buffer + aReadBuf.Zero(); + + // get the current file position + TInt filePos(0); + aFile.Seek(ESeekCurrent, filePos); + + // read the buffer + err = aFile.Read(buffer); + + // check if it's the end of file + TInt s = buffer.Length(); + if (s == 0) + err = KErrEof; + + if (err == KErrNone) + { + // copy to the lfcr and then set the file pointer to the point after that + TInt pos = buffer.Find(KImcvCRLF); + if (pos != -1) + { + TFileName tempBuf; + buffer.SetLength(pos); + tempBuf.Copy(buffer); + aReadBuf.Justify(tempBuf, pos, ELeft, ' '); + filePos += (pos+2); + + // set the file pointer back to after the lfcr + aFile.Seek(ESeekStart, filePos); + } + + // else fill the whole buffer + else + { + aReadBuf.Copy(buffer); + } + } + + CleanupStack::PopAndDestroy(); // tempLine + return err; + } + + +// --------------------------------------------------------------------------- +// --------------------------------------------------------------------------- + + +////////////////////////////////////////////////////////////////////////////////////// + +// --------------------------------------------------------------------------- + +CAppThreadChecker* CAppThreadChecker::NewL(CLauncherEngine* aLauncherEngine) + { + LOGSTRING("Launcher: CAppThreadChecker::NewL"); + + CAppThreadChecker* self = new(ELeave) CAppThreadChecker; + CleanupStack::PushL(self); + self->ConstructL(aLauncherEngine); + CleanupStack::Pop(); + return self; + } + +// --------------------------------------------------------------------------- + +CAppThreadChecker::CAppThreadChecker() : CActive(EActivePriorityIpcEventsHigh) + { + } + +// --------------------------------------------------------------------------- + +void CAppThreadChecker::ConstructL(CLauncherEngine* aLauncherEngine) + { + LOGSTRING("Launcher: CAppThreadChecker::ConstructL"); + + iEnv = CEikonEnv::Static(); + + iLauncherEngine = aLauncherEngine; + + CActiveScheduler::Add(this); + } + +// --------------------------------------------------------------------------- + +CAppThreadChecker::~CAppThreadChecker() + { + LOGSTRING("Launcher: CAppThreadChecker::~CAppThreadChecker"); + + Cancel(); + } + +// --------------------------------------------------------------------------- + +void CAppThreadChecker::ActivateChecking() + { + LOGSTRING("Launcher: CAppThreadChecker::ActivateChecking"); + + __ASSERT_ALWAYS(!IsActive(), User::Panic(_L("Thread Checker"), 300)); + + SetActive(); + } + +// --------------------------------------------------------------------------- + +void CAppThreadChecker::RunL() + { + LOGSTRING("Launcher: CAppThreadChecker::RunL"); + + // check the state of the thread + iLauncherEngine->CheckWhyThreadDiedL(); + } + +// --------------------------------------------------------------------------- + +void CAppThreadChecker::DoCancel() + { + LOGSTRING("Launcher: CAppThreadChecker::DoCancel"); + } + +// --------------------------------------------------------------------------- + + + +// --------------------------------------------------------------------------- + +////////////////////////////////////////////////////////////////////////////////////// + +// --------------------------------------------------------------------------- + +CAppRunningChecker* CAppRunningChecker::NewL(CLauncherEngine* aLauncherEngine) + { + LOGSTRING("Launcher: CAppRunningChecker::NewL"); + + CAppRunningChecker* self = new(ELeave) CAppRunningChecker; + CleanupStack::PushL(self); + self->ConstructL(aLauncherEngine); + CleanupStack::Pop(); + return self; + } + +// --------------------------------------------------------------------------- + +CAppRunningChecker::CAppRunningChecker() : CActive(EActivePriorityIpcEventsHigh) + { + } + +// --------------------------------------------------------------------------- + +void CAppRunningChecker::ConstructL(CLauncherEngine* aLauncherEngine) + { + LOGSTRING("Launcher: CAppRunningChecker::ConstructL"); + + iEnv = CEikonEnv::Static(); + User::LeaveIfError(iTimer.CreateLocal()); + + iLauncherEngine = aLauncherEngine; + + CActiveScheduler::Add(this); + } + +// --------------------------------------------------------------------------- + +CAppRunningChecker::~CAppRunningChecker() + { + LOGSTRING("Launcher: CAppRunningChecker::~CAppRunningChecker"); + + Cancel(); + + iTimer.Close(); + } + +// --------------------------------------------------------------------------- + +void CAppRunningChecker::StartTesting() + { + LOGSTRING("Launcher: CAppRunningChecker::StartTesting"); + + __ASSERT_ALWAYS(!IsActive(), User::Panic(_L("Running Checker"), 200)); + + // async delay of seven seconds + iTimer.After(iStatus, 7000000); + SetActive(); + } + +// --------------------------------------------------------------------------- + +void CAppRunningChecker::RunL() + { + LOGSTRING("Launcher: CAppRunningChecker::RunL"); + + // check if the application is running + iLauncherEngine->CheckIfAppIsRunningL(); + } + +// --------------------------------------------------------------------------- + +void CAppRunningChecker::DoCancel() + { + LOGSTRING("Launcher: CAppRunningChecker::DoCancel"); + iTimer.Cancel(); + } + +// --------------------------------------------------------------------------- + + + +////////////////////////////////////////////////////////////////////////////////////// + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/launcher/engine/src/launcherxmlparser.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/launcher/engine/src/launcherxmlparser.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,430 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include +#include +#include "launcherxmlparser.h" +#include "launchertraces.h" + +_LIT8(KXmlMimeType, "text/xml"); + +/** + * XML element names + */ +_LIT8(KDll, "dll"); +_LIT8(KDllName, "dllname"); +_LIT8(KUID1, "uid1"); +_LIT8(KUID2, "uid2"); +_LIT8(KUID3, "uid3"); +_LIT8(KSID, "sid"); +_LIT8(KCapability, "capability"); + +// --------------------------------------------------------------------------- + +CLauncherXMLParser::CLauncherXMLParser(RFs& aFs) +: +CActive( EPriorityIdle ), +iParser(0), +iFileSession(aFs), +iParsedBytes(0) + { + CActiveScheduler::Add( this ); + } + +// --------------------------------------------------------------------------- + +void CLauncherXMLParser::ConstructL() + { + LOGSTRING("Launcher: CLauncherXMLParser::ConstructL"); + } + +// --------------------------------------------------------------------------- + +CLauncherXMLParser* CLauncherXMLParser::NewL(RFs& aFs) + { + LOGSTRING("Launcher: CLauncherXMLParser::NewL"); + CLauncherXMLParser* self = CLauncherXMLParser::NewLC(aFs); + CleanupStack::Pop(); + return self; + } + +// --------------------------------------------------------------------------- + +CLauncherXMLParser* CLauncherXMLParser::NewLC(RFs& aFs) + { + LOGSTRING("Launcher: CLauncherXMLParser::NewLC"); + CLauncherXMLParser* self = new (ELeave) CLauncherXMLParser(aFs); + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +// --------------------------------------------------------------------------- + +CLauncherXMLParser::~CLauncherXMLParser() + { + LOGSTRING("Launcher: CLauncherXMLParser::~CLauncherXMLParser"); + Cancel(); + delete iParser; + delete iCurrentDllElement; + } + +// --------------------------------------------------------------------------- + +void CLauncherXMLParser::ClearXMLDataBuffer() + { + iXMLDataBuffer.Zero(); + } + +// --------------------------------------------------------------------------- + +void CLauncherXMLParser::DoCancel() + { + LOGSTRING("Launcher: CLauncherXMLParser::DoCancel"); + iIgnoreError = ETrue; + if( iParser ) + { + TRAP_IGNORE(iParser->ParseEndL()); + } + iFile.Close(); + ClearXMLDataBuffer(); + } + +// --------------------------------------------------------------------------- +// Gives current buffer content to parser for processing. Then reads +// next part of the file in the buffer and waits for next scheduled run. + +void CLauncherXMLParser::RunL() + { + TInt err = iStatus.Int(); + LOGSTRING2("Launcher: CLauncherXMLParser::RunL - iStatus: %d", err); + if( err != KErrNone ) + { + iObserver->DocumentParsedL(err); // Observer should cancel parsing + iFile.Close(); + ClearXMLDataBuffer(); + } + else + { + iParsedBytes += iXMLDataBuffer.Length(); + iObserver->ParsingProgressedL(iParsedBytes); + // Check if the end of the file is reached: + if( iXMLDataBuffer.Length() > 0) + { + // Parse the data in buffer + LOGSTRING("Launcher: CLauncherXMLParser::RunL: Starting XML parsing"); + if( iParser ) + { + iParser->ParseL( iXMLDataBuffer ); + } + else + { + LOGSTRING("CLauncherXMLParser::RunL - Error: NULL parser"); + User::Leave(KErrGeneral); + } + // Read new data from XML file to buffer: + iFile.Read( iXMLDataBuffer, KXMLBufferSize, iStatus ); + SetActive(); + } + else + { + // End of the file reached. Stop parsing and close the file: + LOGSTRING("Launcher: CLauncherXMLParser::RunL: Data parsed. Stopping"); + if( iParser ) + { + iParser->ParseEndL(); + } + iFile.Close(); + ClearXMLDataBuffer(); + } + } + } + +// --------------------------------------------------------------------------- + +void CLauncherXMLParser::ParseL(const TDesC& aFilePath, MLauncherParserObserver* aObserver) + { + LOGSTRING2("Launcher: CLauncherXMLParser::ParseL: %S", &aFilePath); + iIgnoreError = EFalse; + iParsedBytes = 0; + if ( IsActive() ) + { + Cancel(); + } + + if( aObserver == 0 ) + { + LOGSTRING("Launcher: CLauncherXMLParser::ParseL: Error: Observer is a NULL pointer."); + User::Leave(KErrArgument); + } + + // Open the XML-file + TInt err = iFile.Open( iFileSession, aFilePath, EFileRead ); + User::LeaveIfError( err ); + + // Create and start XML-parser: + delete iParser; + iParser = 0; + iParser = CParser::NewL(KXmlMimeType, *this); + + // Set observer: + iObserver = aObserver; + + // Initialize the buffer and read first part of the XML-file: + ClearXMLDataBuffer(); + iFile.Read( iXMLDataBuffer, KXMLBufferSize, iStatus ); + SetActive(); + iParser->ParseBeginL(); // Reset the parser to xml-filetype + } + +// --------------------------------------------------------------------------- + +void CLauncherXMLParser::OnStartDocumentL(const Xml::RDocumentParameters& /*aDocParam*/, TInt aErrorCode) + { + LOGSTRING2("Launcher: CLauncherXMLParser::OnStartDocumentL (Error code: %d)", aErrorCode); + if( aErrorCode != KErrNone ) + { + iObserver->DocumentParsedL(aErrorCode); + } + } + +// --------------------------------------------------------------------------- + +void CLauncherXMLParser::OnEndDocumentL(TInt aErrorCode) + { + LOGSTRING2("Launcher: CLauncherXMLParser::OnEndDocumentL (Error code: %d)", aErrorCode); + iObserver->DocumentParsedL(aErrorCode); + } + +// --------------------------------------------------------------------------- + +void CLauncherXMLParser::OnStartPrefixMappingL( const RString& /*aPrefix*/, + const RString& /*aUri*/, + TInt aErrorCode) + { + LOGSTRING2("Launcher: CLauncherXMLParser::OnStartPrefixMappingL (Error code: %d)", aErrorCode); + if( aErrorCode != KErrNone ) + { + iObserver->DocumentParsedL(aErrorCode); + } + } + +// --------------------------------------------------------------------------- + +void CLauncherXMLParser::OnEndPrefixMappingL(const RString& /*aPrefix*/, TInt aErrorCode) + { + LOGSTRING2("Launcer: CLauncherXMLParser::OnEndPrefixMappingL (Error code: %d)", aErrorCode); + if( aErrorCode != KErrNone ) + { + iObserver->DocumentParsedL(aErrorCode); + } + } + +// --------------------------------------------------------------------------- + +void CLauncherXMLParser::OnIgnorableWhiteSpaceL(const TDesC8& /*aBytes*/, TInt aErrorCode) + { + LOGSTRING2("Launcher: CLauncherXMLParser::OnIgnorableWhiteSpaceL (Error code: %d)", aErrorCode); + if( aErrorCode != KErrNone ) + { + iObserver->DocumentParsedL(aErrorCode); + } + } + +// --------------------------------------------------------------------------- + +void CLauncherXMLParser::OnSkippedEntityL(const RString& /*aName*/, TInt aErrorCode) + { + LOGSTRING2("Launcher: CLauncherXMLParser::OnSkippedEntityL (Error code: %d)", aErrorCode); + if( aErrorCode != KErrNone ) + { + iObserver->DocumentParsedL(aErrorCode); + } + } + +// --------------------------------------------------------------------------- + +void CLauncherXMLParser::OnProcessingInstructionL( const TDesC8& /*aTarget*/, + const TDesC8& /*aData*/, + TInt aErrorCode) + { + LOGSTRING2("Launcher: CLauncherXMLParser::OnProcessingInstructionL (Error code: %d)", aErrorCode); + if( aErrorCode != KErrNone ) + { + iObserver->DocumentParsedL(aErrorCode); + } + } + +// --------------------------------------------------------------------------- + +void CLauncherXMLParser::OnError(TInt aErrorCode) + { + LOGSTRING2("Launcher: CLauncherXMLParser::OnError: %d", aErrorCode); + if( iIgnoreError == EFalse ) + { + TRAP_IGNORE(iObserver->DocumentParsedL(aErrorCode)); + } + } + +// --------------------------------------------------------------------------- + +TAny* CLauncherXMLParser::GetExtendedInterface(const TInt32 aUid) + { + (void)aUid; + LOGSTRING2("Launcher: CLauncherXMLParser::GetExtendedInterface (UID: %d)", aUid); + return 0; + } + +// --------------------------------------------------------------------------- + +void CLauncherXMLParser::OnStartElementL( const RTagInfo& aElement, + const RAttributeArray& /*aAttributes*/, + TInt aErrorCode) + { + LOGSTRING2("Launcher: CLauncherXMLParser::OnStartElementL (Error code: %d)", aErrorCode); + if( aErrorCode != KErrNone ) + { + iObserver->DocumentParsedL(aErrorCode); + } + else + { + // Save XML-element name: + iCurrentElementName = aElement.LocalName().DesC(); + + // If this is 'dll'-element, initialize new DLL element instance: + if( iCurrentDllElement == 0 && iCurrentElementName == KDll ) + { + iCurrentDllElement = CLauncherDLLElement::NewL(); + } + // Clear contents buffer: + iCurrentContent.Zero(); + } + } + +// --------------------------------------------------------------------------- + +void CLauncherXMLParser::OnEndElementL(const RTagInfo& aElement, TInt aErrorCode) + { + LOGSTRING2("Launcher: CLauncherXMLParser::OnEndElementL (Error code: %d)", aErrorCode); + if( aErrorCode != KErrNone ) + { + iObserver->DocumentParsedL(aErrorCode); + } + else + { + // Save XML-element's name: + iCurrentElementName = aElement.LocalName().DesC(); + TUid tmpUID; + + if( IsDataElement() ) + { + // Check that we have a pointer to parent DLL element + if( iCurrentDllElement == 0 ) + { + LOGSTRING("Launcher: CLauncherXMLParser: Error in parsing xml (parent DLL element missing)."); + User::Leave(KErrGeneral); + } + // DLL name + if( iCurrentElementName == KDllName ) + { + TFileName dllName; + dllName.Copy(iCurrentContent); + iCurrentDllElement->SetNameL(dllName); + } + // UID1 + else if( iCurrentElementName == KUID1 ) + { + tmpUID.iUid = ConvertDes8ToUint32L(iCurrentContent); + iCurrentDllElement->SetUID1L(tmpUID); + } + // UID2 + else if( iCurrentElementName == KUID2 ) + { + tmpUID.iUid = ConvertDes8ToUint32L(iCurrentContent); + iCurrentDllElement->SetUID2L(tmpUID); + } + // UID3 + else if( iCurrentElementName == KUID3 ) + { + tmpUID.iUid = ConvertDes8ToUint32L(iCurrentContent); + iCurrentDllElement->SetUID3L(tmpUID); + } + // SID + else if( iCurrentElementName == KSID ) + { + tmpUID.iUid = ConvertDes8ToUint32L(iCurrentContent); + iCurrentDllElement->SetSIDL(tmpUID); + } + // Capability + else if( iCurrentElementName == KCapability ) + { + iCurrentDllElement->SetCapabilityL(ConvertDes8ToUint32L(iCurrentContent)); + } + } + else if( iCurrentElementName == KDll ) + { + // DLL element parsed, give current DLL object to observer: + iObserver->ElementParsedL(*iCurrentDllElement); + } + } + } + +// --------------------------------------------------------------------------- + +TBool CLauncherXMLParser::IsDataElement() + { + if( iCurrentElementName == KDllName || + iCurrentElementName == KUID1 || + iCurrentElementName == KUID2 || + iCurrentElementName == KUID3 || + iCurrentElementName == KSID || + iCurrentElementName == KCapability ) + { + return ETrue; + } + return EFalse; + } + +// --------------------------------------------------------------------------- +// Reads content of an xml-element. + +void CLauncherXMLParser::OnContentL(const TDesC8& aBytes, TInt aErrorCode) + { + LOGSTRING2("Launcher: CLauncherXMLParser::OnContentL (Error code: %d)", aErrorCode); + if( aErrorCode != KErrNone ) + { + iObserver->DocumentParsedL(aErrorCode); + } + else if( iCurrentElementName.Length() == 0) + { + LOGSTRING("Launcher: CLauncherXMLParser: Error in parsing xml (element name missing)."); + User::Leave(KErrGeneral); + } + iCurrentContent.Append(aBytes); + } + +// --------------------------------------------------------------------------- + +TUint32 CLauncherXMLParser::ConvertDes8ToUint32L(const TDesC8& aStr) + { + LOGSTRING("Launcher: CLauncherXMLParser::ConvertDes8ToUintL"); + TUint32 uintVal = 0; + TLex8 lex(aStr); + TInt errorCode=lex.Val(uintVal, EHex); + User::LeaveIfError(errorCode); + return uintVal; + } diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/launcher/icons/check.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/launcher/icons/check.svg Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,90 @@ + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/launcher/icons/qgn_menu_launcher.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/launcher/icons/qgn_menu_launcher.svg Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/launcher/inc/applicationview.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/launcher/inc/applicationview.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,140 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef APPLICATIONVIEW_H +#define APPLICATIONVIEW_H + +#include + +class HbAction; +class HbDocumentLoader; +class HbListWidget; +class CommonActions; +class EngineWrapper; + +class ApplicationView : public HbView +{ + Q_OBJECT + +public: + + /** + * Constructor + */ + ApplicationView(); + + /** + * Destructor + */ + ~ApplicationView(); + + /** + * Created Application View + */ + static ApplicationView* create(HbDocumentLoader &loader, + CommonActions *commonActions, + EngineWrapper *engine); + + /** + * Setter for engine + */ + void setEngine(EngineWrapper *engine); + +private slots: + + + /** + * Refreshed application list + */ + void refreshAppList(); + + /** + * Launches selected applications + */ + void launchSelectedApplications(); + + /** + * Launches and closes selected applications + */ + void launchAndCloseSelectedApplications(); + + /** + * Selects all list items + */ + void selectAllItems(); + + /** + * unselects all items + */ + void unselectAllItems(); + + /** + * Changes launch options so that hidden applications are skipped + */ + void launchOptionsSkipHidden(); + + /** + * Changes launch options so that hidden applications are not skipped + */ + void launchOptionsDontSkipHidden(); + + /** + * Opens output view + */ + void openOutputView(); + + +private: + + /** + * Initializes view + */ + void init(HbDocumentLoader &loader, CommonActions *commonActions); + + /** + * connects signals and slots + */ + void connectSignalsAndSlots(); + + /** + * Loads all UI items from xml file + */ + void loadItemsFromXml(HbDocumentLoader &loader); + +private slots: + + +private: + EngineWrapper *mEngine; + + //UI components: + HbListWidget *mApplicationList; + + //Actions: + HbAction *mActionRefresh; + HbAction *mActionLaunchApps; + HbAction *mActionLaunchAndCloseApps; + HbAction *mActionSkipHidden; + HbAction *mActionDontSkipHidden; + HbAction *mActionSelectAll; + HbAction *mActionUnselectAll; + HbAction *mActionOpenOutputView; + + +}; + +#endif // APPLICATIONVIEW_H diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/launcher/inc/commonActions.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/launcher/inc/commonActions.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,106 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef COMMONACTIONS_H +#define COMMONACTIONS_H + +#include + +class EngineWrapper; +class HbAction; +class HbMenu; +class HbApplication; + +class CommonActions : public QObject +{ + Q_OBJECT +public: + + /** + * Constructor + */ + CommonActions(EngineWrapper *engine, HbApplication *application); + + /** + * Destructor + */ + ~CommonActions(); + + /** + * Adds all actions to menu that is given as parameter + */ + void addActionsToMenu(HbMenu *menu); + +public slots: + + /** + * Shows about box + */ + void showAbout(); + + /** + * Stops launching applications + */ + void stopLaunch(); + + /** + * Sends DLL info + */ + void sendDllInfo(); + + /** + * Compares DLL infos + */ + void compareDllInfo(); + + /** + * Sends log + */ + void sendLog(); + + /** + * Deletes log + */ + void deleteLog(); + + /** + * Exits launcher + */ + void exit(); + +private: + void connectSignalsAndSlots(); + +private: + EngineWrapper *mEngine; + + HbApplication *mApplication; + + //Actions: + + HbAction *mActionStopLaunch; + HbAction *mActionSendDllInfo; + HbAction *mActionCompareDllInfo; + HbAction *mActionSendLog; + HbAction *mActionDeleteLog; + HbAction *mActionAbout; + HbAction *mActionExit; + +}; + +#endif //COMMONACTIONS_H diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/launcher/inc/enginewrapper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/launcher/inc/enginewrapper.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,170 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef ENGINEWRAPPER_H +#define ENGINEWRAPPER_H + +#include +#include +#include +#include + +#include "launcherengine.h" + +class HbProgressDialog; +class HbDeviceProgressDialog; +class HbAction; + +class LauncherMainWindow; + + +class EngineWrapper : public QObject, public MLauncherUI +{ + Q_OBJECT + +public: + + /** + * Constructor + */ + EngineWrapper(LauncherMainWindow* mainWindow); + + /** + * Destructor + */ + ~EngineWrapper(); + + /** + * Initializes Engine Wrapper + * @return true if engine was started successfully + */ + bool init(); + +public: + // functions that are called from UI + + /** + * Fetches list of applications from engine + */ + bool listOfAllApps(QStringList &allAppsQStringList); + + /** + * Starts launching applications that are given as parameter + */ + bool startAppLaunching(const QModelIndexList &list, bool autoClose); + + /** + * Sets engine to skip hidden applications when launching + */ + void setSkipHiddenAndEmbedOnly(bool skip); + + /** + * Stops launching applications + */ + bool stopLaunching(); + + /** + * Sends log + */ + bool sendLog(); + + /** + * Deletes log + */ + bool deleteLog(); + + /** + * Compares dll + */ + void compareDlls(); + + /** + * Sends list of dlls + */ + bool sendListOfDlls(); + +public: + // From MLauncherUIEngine + // functions that are called from Engine + + /** + * Shows error message with error text + */ + virtual void ShowErrorMessage(const TDesC& aText); + + /** + * Shows information message with info text + */ + virtual void ShowInfoMessage(const TDesC& aText); + + /** + * Shows progress bar with text + */ + virtual void ShowProgressBar(const TDesC& aText, TInt aMinimum = 0, TInt aMaximum = 0 ); + + /** + * Sets progress bar value + */ + virtual void SetProgressBarValue(TInt aValue); + + /** + * Hides progress bar + */ + virtual void HideProgressBar(); + + /** + * Shows wait dialog with text + */ + virtual void ShowWaitDialog(const TDesC& aText); + + /** + * Hides wait dialog + */ + virtual void HideWaitDialog(); + + /** + * Changes focus to output view + */ + virtual void ChangeFocusToOutputView(); + + /** + * Prints text to output views log + */ + virtual void PrintText(const TDesC& aText); + +public slots: + void doCompareDlls(HbAction*); + void CancelDllBCanalysis(); + +private: + + /** + * Allocate CArrayFix and copy QList to it + */ + CArrayFix* QModelIndexListToCArrayFixL(const QModelIndexList& qlist); + +private: + CLauncherEngine *mEngine; + LauncherMainWindow *mMainWindow; + HbProgressDialog* mProgressDialog; + HbDeviceProgressDialog* mWaitDialog; +}; + + + + +#endif //ENGINEWRAPPER_H diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/launcher/inc/launchermainwindow.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/launcher/inc/launchermainwindow.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef LauncherMainWindow_H_ +#define LauncherMainWindow_H_ + +#include +#include + +class HbApplication; +class ApplicationView; +class OutputView; +class EngineWrapper; +class CommonActions; + +class LauncherMainWindow : public HbMainWindow + { +public: + + LauncherMainWindow ( QWidget *parent = 0 ); + virtual ~LauncherMainWindow (); + + int init( HbApplication &app ); + + void openApplicationView(); + void openOutputView(); + /** + * Prints text into output + */ + void printText(const QString &text); + +private: //data + EngineWrapper* mEngineWrapper; + ApplicationView* mApplicationView; + OutputView* mOutputView; + CommonActions* mCommonActions; + }; + +#endif /* LauncherMainWindow_H_ */ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/launcher/inc/notifications.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/launcher/inc/notifications.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef NOTIFICATIONS_H_ +#define NOTIFICATIONS_H_ + +#include +#include + + +class Notifications + { +public: + + /** + * shows message box of the specified type with text and label + */ + static void showMessageBox( + HbMessageBox::MessageBoxType type, + const QString &text, + const QString &label, + int timeout = HbPopup::NoTimeout + ); + + /** + * shows about box + */ + static void about(); + + /** + * shows information type message box + */ + static void showInformationNote(const QString &text); + + /** + * shows warning type message box + */ + static void showErrorNote(const QString &text); + + /** + * shows progressbar + */ + static HbDeviceProgressDialog* showWaitDialog(const QString &text); + + + }; + + + +#endif // NOTIFICATIONS_H_ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/launcher/inc/outputview.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/launcher/inc/outputview.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,94 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef OUTPUTVIEW_H +#define OUTPUTVIEW_H + +#include + +class HbDocumentLoader; +class HbAction; +class HbTextEdit; +class CommonActions; + +class OutputView : public HbView +{ + Q_OBJECT + +public: + /** + * Constructor + */ + OutputView(); + + /** + * Destructor + */ + ~OutputView(); + + /** + * Creates output view and adds it into main window + */ + static OutputView* create(HbDocumentLoader &loader, CommonActions *commonActions); + + /** + * Prints text into output + */ + void printText(const QString &text); + +private slots: + + /** + * Clears output + */ + void clearOutput(); + + /** + * Opens application view + */ + void openApplicationView(); + +private: + + /** + * Initializes view + */ + void init(HbDocumentLoader &loader, CommonActions *commonActions); + + /** + * Loads all output view's ui components from xml-file + */ + void loadItemsFromXml(HbDocumentLoader &loader); + + /** + * connects signals and slots to each other + */ + void connectSignalsAndSlots(); + + +private: + + // Actions + HbAction *mActionClear; + HbAction *mActionOpenApplicationView; + + HbTextEdit *mTextOutput; + +}; + +#endif // OUTPUTVIEW + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/launcher/launcher.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/launcher/launcher.pro Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,68 @@ +TEMPLATE = app +TARGET = Launcher +load(hb.prf) +symbian:CONFIG -= symbian_i18n +DEPENDPATH += src +DEPENDPATH += inc +INCLUDEPATH += inc + +HEADERS += launchermainwindow.h applicationview.h enginewrapper.h notifications.h outputview.h commonActions.h +SOURCES += main.cpp launchermainwindow.cpp applicationview.cpp enginewrapper.cpp notifications.cpp outputview.cpp commonActions.cpp +RESOURCES += launcher.qrc + +symbian: { + + BLD_INF_RULES.prj_exports += "./rom/Launcher.iby CORE_IBY_EXPORT_PATH(tools,Launcher.iby)" + BLD_INF_RULES.prj_exports += "./rom/backup_registration.xml Z:/private/101fb74f/backup_registration.xml" + + launcher_stub_sis_mk = \ + "$${LITERAL_HASH}if defined(__SERIES60_30__) || defined(__SERIES60_31__) || defined(__S60_32__)" \ + " $${LITERAL_HASH}ifdef MARM" \ + " gnumakefile .sis/launcher_stub_sis.mk" \ + " $${LITERAL_HASH}endif" \ + "$${LITERAL_HASH}endif" + BLD_INF_RULES.prj_mmpfiles += launcher_stub_sis_mk + + launcher_buildstubsis_extension = \ + "$${LITERAL_HASH}if(!defined __SERIES60_30__ && !defined __SERIES60_31__ && !defined __S60_32__)" \ + " $${LITERAL_HASH}ifdef MARM" \ + " START EXTENSION app-services/buildstubsis" \ + " OPTION SRCDIR sis" \ + " OPTION SISNAME Launcher_stub" \ + " END" \ + " $${LITERAL_HASH}endif" \ + "$${LITERAL_HASH}endif" + BLD_INF_RULES.prj_extensions += launcher_buildstubsis_extension + + INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE + + DEPENDPATH += engine/inc + DEPENDPATH += engine/src + INCLUDEPATH += engine/inc + + HEADERS += launcherengine.h launchertraces.h e32image.h e32imageheaders.h launcherxmlparser.h launcherdllelement.h launcherparserobserver.h launcherdllparser.h + SOURCES += launcherengine.cpp e32image.cpp launcherxmlparser.cpp launcherdllelement.cpp launcherdllparser.cpp + + RSS_RULES += "group_name = \"RnD Tools\""; + + LIBS += -lapgrfx -lPlatformEnv -lxqutils -lxmlframework -lbafl -lshareui -lws32 -lapparc -lefsrv -lcone + + + TARGET.CAPABILITY = ReadUserData ReadDeviceData WriteUserData WriteDeviceData PowerMgmt AllFiles + + TARGET.UID2 = 0x100039CE + TARGET.UID3 = 0x101FB74F + TARGET.SID = 0x101FB74F + TARGET.VID = 0x101FB657 // Nokia + + TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 // Min 128Kb, Max 32Mb + + ICON = ./icons/qgn_menu_launcher.svg + + MMP_RULES -= PAGED + MMP_RULES *= UNPAGEDDATA + MMP_RULES += SMPSAFE + +} else { + error("Only Symbian supported!") +} diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/launcher/launcher.qrc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/launcher/launcher.qrc Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,9 @@ + + + src/applicationview.xml + src/outputview.xml + + + icons/qgn_menu_launcher.svg + + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/launcher/rom/Launcher.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/launcher/rom/Launcher.iby Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef __LAUNCHER_IBY__ +#define __LAUNCHER_IBY__ + +S60_APP_EXE(Launcher) +S60_APP_RESOURCE(Launcher) +SCALABLE_IMAGE(APP_BITMAP_DIR,APP_BITMAP_DIR,Launcher) +data=ZPRIVATE\10003a3f\import\APPS\Launcher_reg.RSC Private\10003a3f\import\Apps\Launcher_reg.rsc + +//#ifdef S60_UPGRADABLE_APP_REG_RSC +// S60_UPGRADABLE_APP_REG_RSC(Launcher) +//#else +// S60_APP_AIF_RSC(Launcher) +//#endif + +data=ZPRIVATE\101FB74F\backup_registration.xml private\101FB74F\backup_registration.xml +data=ZSYSTEM\Install\Launcher_stub.sis \system\install\Launcher_stub.sis + +#endif diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/launcher/rom/backup_registration.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/launcher/rom/backup_registration.xml Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,8 @@ + + + + + + + + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/launcher/sis/Launcher_S60-5x.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/launcher/sis/Launcher_S60-5x.pkg Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,43 @@ +; +; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; + +; Language - standard language definitions +&EN + +; Standard SIS file header +#{"Launcher"},(0x101FB74F),4,0,0,TYPE=SA + +;Supports S60 v 5.0 +[0x1028315F], 0, 0, 0, {"S60ProductID"} + +;Supports S60 v 5.1 +[0x10283160], 0, 0, 0, {"S60ProductID"} + +;Supports S60 v 5.2 +[0x20022E6D], 0, 0, 0, {"S60ProductID"} + +; Non-localised vendor name +:"Nokia Corporation" + +; Localised vendor names +%{"Nokia Corporation"} + +; normal stuff: +"\epoc32\release\armv5\urel\launcher.exe"-"!:\sys\bin\launcher.exe" +"\epoc32\data\z\resource\apps\launcher.mif"-"!:\resource\apps\launcher.mif" +"\epoc32\data\z\resource\apps\launcher.rsc"-"!:\resource\apps\launcher.rsc" +"\epoc32\data\z\private\10003a3f\import\apps\launcher_reg.rsc"-"!:\private\10003a3f\import\apps\launcher_reg.rsc" +"..\group\backup_registration.xml"-"!:\private\101fb74f\backup_registration.xml" diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/launcher/sis/Launcher_stub.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/launcher/sis/Launcher_stub.pkg Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,34 @@ +; +; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; + +; Language - standard language definitions +&EN + +; Standard SIS file header +#{"Launcher"},(0x101FB74F),4,0,0 + +; Non-localised vendor name +:"Nokia Corporation" + +; Localised vendor names +%{"Nokia Corporation"} + +; normal stuff: +""-"z:\sys\bin\Launcher.exe" +""-"z:\Resource\Apps\Launcher.mif" +""-"z:\Resource\Apps\Launcher.rsc" +""-"z:\private\10003a3f\import\apps\Launcher_reg.rsc" +""-"z:\private\101FB74F\backup_registration.xml" \ No newline at end of file diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/launcher/sis/launcher_stub_sis.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/launcher/sis/launcher_stub_sis.mk Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,56 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# + + +TARGETDIR=$(EPOCROOT)EPOC32\Data\Z\System\Install + +SISNAME=Launcher_stub +PKGNAME=Launcher_stub + +$(TARGETDIR) : + @perl -S emkdir.pl "$(TARGETDIR)" + +do_nothing : + rem do_nothing + +SISFILE=$(TARGETDIR)\$(SISNAME).sis + +$(SISFILE) : .\$(PKGNAME).pkg + makesis -s $? $@ + + + +MAKMAKE : do_nothing + +RESOURCE : do_nothing + +SAVESPACE : do_nothing + +BLD : do_nothing + +FREEZE : do_nothing + +LIB : do_nothing + +CLEANLIB : do_nothing + +FINAL : $(TARGETDIR) $(SISFILE) + +CLEAN : + @if exist $(SISFILE) erase $(SISFILE) + +RELEASABLES : + @echo $(SISFILE) diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/launcher/src/applicationview.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/launcher/src/applicationview.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,299 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include +#include +#include +#include +#include +#include + +#include "applicationview.h" +#include "launchermainwindow.h" +#include "enginewrapper.h" +#include "notifications.h" +#include "commonActions.h" +#include "outputview.h" + + + + +// xml definition of view +const char *APPLICATIONVIEW_XML = ":/xml/applicationview.xml"; + +// name of the application view object in the xml file. +const char *APPLICATIONVIEW = "applicationview"; +const char *LISTVIEW = "applicationList"; +const char *ACTIONREFRESH = "actionRefresh"; +const char *ACTIONLAUNCHAPPS = "actionLaunchApps"; +const char *ACTIONLAUNCHANDCLOSEAPPS = "actionLaunchAppsAndClose"; +const char *ACTIONSELECT = "actionSelectAll"; +const char *ACTIONUNSELECT = "actionUnselectAll"; +const char *ACTIONOPENOUTPUTVIEW = "actionOpenOutputView"; +const char *ACTIONSKIPHIDDEN = "actionSkipHidden"; +const char *ACTIONDONTSKIPHIDDEN = "actionDontSkipHidden"; + +// --------------------------------------------------------------------------- + +ApplicationView* ApplicationView::create(HbDocumentLoader &loader, CommonActions *commonActions, EngineWrapper *engine) +{ + + // Load xml-file + bool ok = false; + qDebug("QTLauncher::load xml"); + loader.load(APPLICATIONVIEW_XML, &ok); + + // Load Application View: + QGraphicsWidget *widget = loader.findWidget(APPLICATIONVIEW); + Q_ASSERT_X(ok && (widget != 0), "Launcher", "Invalid launcher.xml file"); + ApplicationView *applicationView = qobject_cast(widget); + + // Set enginewrappers pointer to applicationview and initialize it + applicationView->setEngine(engine); + applicationView->init(loader, commonActions); + + return applicationView; +} + +// --------------------------------------------------------------------------- + +ApplicationView::ApplicationView() + : mEngine(0), + mActionRefresh(0), + mActionLaunchApps(0), + mActionLaunchAndCloseApps(0), + mActionSkipHidden(0), + mActionDontSkipHidden(0), + mActionSelectAll(0), + mActionUnselectAll(0), + mActionOpenOutputView(0) +{ +} + +// --------------------------------------------------------------------------- + +void ApplicationView::setEngine(EngineWrapper *engine) +{ + mEngine = engine; +} + +// --------------------------------------------------------------------------- + +ApplicationView::~ApplicationView() +{ + if(mActionRefresh) + mActionRefresh->deleteLater(); + if(mActionLaunchApps) + mActionLaunchApps->deleteLater(); + if(mActionLaunchAndCloseApps) + mActionLaunchAndCloseApps->deleteLater(); + if(mActionSkipHidden) + mActionSkipHidden->deleteLater(); + if(mActionDontSkipHidden) + mActionDontSkipHidden->deleteLater(); + if(mActionSelectAll) + mActionSelectAll->deleteLater(); + if(mActionUnselectAll) + mActionUnselectAll->deleteLater(); + if(mActionOpenOutputView) + mActionOpenOutputView->deleteLater(); +} + +// --------------------------------------------------------------------------- + +void ApplicationView::init(HbDocumentLoader &loader, CommonActions *commonActions) +{ + // Load items from xml file + loadItemsFromXml(loader); + + // Set actions checkable and select "Skip hidden & embed" + mActionSkipHidden->setCheckable(true); + mActionSkipHidden->setChecked(true); + mActionDontSkipHidden->setCheckable(true); + + commonActions->addActionsToMenu(menu()); + + // Set list widget settings + mApplicationList->setClampingStyle(HbScrollArea::BounceBackClamping); + mApplicationList->setSelectionMode(HbAbstractItemView::MultiSelection); + + // Refresh application list + refreshAppList(); + + // Connect signals and slots + connectSignalsAndSlots(); + +} + +// --------------------------------------------------------------------------- + +void ApplicationView::refreshAppList() +{ + // Clear list + + mApplicationList->clear(); + QStringList apps; + + // show wait dialog + QObject *dialog = static_cast(Notifications::showWaitDialog("Initializing")); + + // Get application list from engine + if(!mEngine->listOfAllApps(apps)) { + Notifications::showErrorNote("Unable to refresh list"); + } + + // Format values to list widget + int i = 0; + while(i < apps.size()) { + mApplicationList->addItem(/*HbIcon(":/gfx/check.svg"),*/apps.at(i)); + i++; + } + mApplicationList->selectAll(); + + // remove the wait dialog + delete dialog; +} + +// --------------------------------------------------------------------------- + +void ApplicationView::connectSignalsAndSlots() +{ + // Actions + connect(mActionRefresh, SIGNAL(triggered()), this, SLOT(refreshAppList())); + connect(mActionLaunchApps, SIGNAL(triggered()), this, SLOT(launchSelectedApplications())); + connect(mActionLaunchAndCloseApps, SIGNAL(triggered()), this, SLOT(launchAndCloseSelectedApplications())); + connect(mActionSelectAll, SIGNAL(triggered()), this, SLOT(selectAllItems())); + connect(mActionUnselectAll, SIGNAL(triggered()), this, SLOT(unselectAllItems())); + connect(mActionSkipHidden, SIGNAL(triggered()), this, SLOT(launchOptionsSkipHidden())); + connect(mActionDontSkipHidden, SIGNAL(triggered()), this, SLOT(launchOptionsDontSkipHidden())); + connect(mActionOpenOutputView, SIGNAL(triggered()), this, SLOT(openOutputView())); +} + +// --------------------------------------------------------------------------- + + +void ApplicationView::loadItemsFromXml(HbDocumentLoader &loader) +{ + + // List widget: + QGraphicsWidget *widget = loader.findWidget(LISTVIEW); + Q_ASSERT_X((widget != 0), "Launcher", "Invalid launcher.xml file"); + mApplicationList = qobject_cast(widget); + + /* ACTIONS: */ + //refresh + QObject *object= loader.findObject(ACTIONREFRESH); + Q_ASSERT_X((object != 0), "Launcher", "Invalid launcher.xml file"); + mActionRefresh = qobject_cast(object); + + // launch applications + object= loader.findObject(ACTIONLAUNCHAPPS); + Q_ASSERT_X((object != 0), "Launcher", "Invalid launcher.xml file"); + mActionLaunchApps = qobject_cast(object); + + // launch and close + object= loader.findObject(ACTIONLAUNCHANDCLOSEAPPS); + Q_ASSERT_X((object != 0), "Launcher", "Invalid launcher.xml file"); + mActionLaunchAndCloseApps = qobject_cast(object); + + // select all applications + object= loader.findObject(ACTIONSELECT); + Q_ASSERT_X((object != 0), "Launcher", "Invalid launcher.xml file"); + mActionSelectAll = qobject_cast(object); + + // unselect all applications + object= loader.findObject(ACTIONUNSELECT); + Q_ASSERT_X((object != 0), "Launcher", "Invalid launcher.xml file"); + mActionUnselectAll = qobject_cast(object); + + // open output view + object= loader.findObject(ACTIONOPENOUTPUTVIEW); + Q_ASSERT_X((object != 0), "Launcher", "Invalid launcher.xml file"); + mActionOpenOutputView = qobject_cast(object); + + // skip hidden + object= loader.findObject(ACTIONSKIPHIDDEN); + Q_ASSERT_X((object != 0), "Launcher", "Invalid launcher.xml file"); + mActionSkipHidden = qobject_cast(object); + + // do not skip hidden + object= loader.findObject(ACTIONDONTSKIPHIDDEN); + Q_ASSERT_X((object != 0), "Launcher", "Invalid launcher.xml file"); + mActionDontSkipHidden = qobject_cast(object); + +} + +// --------------------------------------------------------------------------- + +void ApplicationView::launchSelectedApplications() +{ + QModelIndexList list = mApplicationList->selectionModel()->selectedIndexes(); + mEngine->startAppLaunching(list, false); +} + +// --------------------------------------------------------------------------- + +void ApplicationView::launchAndCloseSelectedApplications() +{ + QModelIndexList list = mApplicationList->selectionModel()->selectedIndexes(); + mEngine->startAppLaunching(list, true); +} + +// --------------------------------------------------------------------------- + +void ApplicationView::selectAllItems() +{ + mApplicationList->selectAll(); +} + +// --------------------------------------------------------------------------- + +void ApplicationView::unselectAllItems() +{ + mApplicationList->clearSelection(); +} +// --------------------------------------------------------------------------- + +void ApplicationView::launchOptionsSkipHidden() +{ + mActionSkipHidden->setChecked(true); + mActionDontSkipHidden->setChecked(false); + mEngine->setSkipHiddenAndEmbedOnly(true); +} + +// --------------------------------------------------------------------------- + +void ApplicationView::launchOptionsDontSkipHidden() +{ + mActionSkipHidden->setChecked(false); + mActionDontSkipHidden->setChecked(true); + mEngine->setSkipHiddenAndEmbedOnly(false); +} + +// --------------------------------------------------------------------------- + +void ApplicationView::openOutputView() +{ + qDebug("OpenOutputView"); + LauncherMainWindow *pMainWindow = static_cast< LauncherMainWindow * >( mainWindow() ); + if( pMainWindow ) + { + pMainWindow->openOutputView(); + } +} + +// --------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/launcher/src/applicationview.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/launcher/src/applicationview.xml Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/launcher/src/commonActions.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/launcher/src/commonActions.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,143 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include +#include + +#include "hbaction.h" +#include "hbmenu.h" +#include "commonActions.h" +#include "notifications.h" +#include "enginewrapper.h" + +// --------------------------------------------------------------------------- + +CommonActions::CommonActions(EngineWrapper *engine, HbApplication *application) + : mEngine(engine), mApplication(application) +{ + + + mActionStopLaunch = new HbAction("Stop launch", this); + mActionSendLog = new HbAction("Send log", this); + mActionDeleteLog = new HbAction("Delete log", this); + mActionSendDllInfo = new HbAction("Send list of DLLs", this); + mActionCompareDllInfo = new HbAction("Dll BC analysis", this); + mActionAbout = new HbAction("About", this); + mActionExit = new HbAction("Exit", this); + + + connectSignalsAndSlots(); +} + +// --------------------------------------------------------------------------- + +CommonActions::~CommonActions() +{ +} + +// --------------------------------------------------------------------------- + +void CommonActions::showAbout() +{ + Notifications::about(); +} + +// --------------------------------------------------------------------------- + +void CommonActions::exit() +{ + mApplication->exit(); +} + +// --------------------------------------------------------------------------- + +void CommonActions::sendDllInfo() +{ + if (!mEngine->sendListOfDlls()) { + Notifications::showErrorNote("Unable to send list"); + } + +} + +// --------------------------------------------------------------------------- + +void CommonActions::compareDllInfo() +{ + mEngine->compareDlls(); +} + +// --------------------------------------------------------------------------- + +void CommonActions::sendLog() +{ + if (!mEngine->sendLog()) { + Notifications::showErrorNote("Unable to send log"); + } +} + +// --------------------------------------------------------------------------- + +void CommonActions::deleteLog() +{ + if (mEngine->deleteLog()) { + QString text = "Log file(s) deleted"; + Notifications::showInformationNote(text); + } + else { + QString text = "Unable to delete"; + Notifications::showErrorNote(text); + } +} + +// --------------------------------------------------------------------------- + +void CommonActions::stopLaunch() +{ + if (!mEngine->stopLaunching()) { + Notifications::showErrorNote("Unable to stop launching"); + } +} + +// --------------------------------------------------------------------------- + +void CommonActions::addActionsToMenu(HbMenu *menu) +{ + menu->addAction(mActionStopLaunch); + menu->addAction(mActionSendLog); + menu->addAction(mActionDeleteLog); + HbMenu *menuDllInfo = menu->addMenu("Dll Info"); + menuDllInfo->addAction(mActionSendDllInfo); + menuDllInfo->addAction(mActionCompareDllInfo); + menu->addAction(mActionAbout); + menu->addAction(mActionExit); +} + +// --------------------------------------------------------------------------- + +void CommonActions::connectSignalsAndSlots() +{ + connect(mActionStopLaunch, SIGNAL(triggered()), this, SLOT(stopLaunch())); + connect(mActionSendDllInfo, SIGNAL(triggered()), this, SLOT(sendDllInfo())); + connect(mActionCompareDllInfo, SIGNAL(triggered()), this, SLOT(compareDllInfo())); + connect(mActionSendLog, SIGNAL(triggered()), this, SLOT(sendLog())); + connect(mActionDeleteLog, SIGNAL(triggered()), this, SLOT(deleteLog())); + connect(mActionAbout, SIGNAL(triggered()), this, SLOT(showAbout())); + connect(mActionExit, SIGNAL(triggered()), this, SLOT( exit() ) ); +} + + +// --------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/launcher/src/enginewrapper.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/launcher/src/enginewrapper.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,355 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "launchermainwindow.h" +#include "notifications.h" +#include "enginewrapper.h" + +// --------------------------------------------------------------------------- + +EngineWrapper::EngineWrapper(LauncherMainWindow* mainWindow) +: mEngine(0), + mMainWindow(mainWindow), + mProgressDialog(0), + mWaitDialog(0) +{ +} + +// --------------------------------------------------------------------------- + +EngineWrapper::~EngineWrapper() +{ + if (mEngine != NULL) { + delete mEngine; + mEngine = NULL; + } + if (mProgressDialog != NULL) { + delete mProgressDialog; + mProgressDialog = NULL; + } + if (mWaitDialog != NULL) { + delete mWaitDialog; + mWaitDialog = NULL; + } +} + +// --------------------------------------------------------------------------- + +bool EngineWrapper::init() +{ + + // construct engine + TRAPD(error, mEngine = CLauncherEngine::NewL(this)); + if (error != KErrNone) { + return false; + } + + return true; + +} + +// --------------------------------------------------------------------------- + +bool EngineWrapper::listOfAllApps(QStringList &allAppsQStringList){ + + // Get application CDesCArray list from engine + CDesCArray* allAppsCDescArray = 0; + TRAPD(error, allAppsCDescArray = mEngine->ListOfAllAppsL()); + if(error != KErrNone) { + return false; + } + + //convert CDesCArray to QStringList + for (int i = 0; i < allAppsCDescArray->Count(); i++) { + allAppsQStringList.append(QString::fromUtf16( + allAppsCDescArray->MdcaPoint(i).Ptr(), + allAppsCDescArray->MdcaPoint(i).Length())); + } + return true; +} + +// --------------------------------------------------------------------------- +bool EngineWrapper::startAppLaunching(const QModelIndexList &qList, bool autoClose) +{ + + // check if used has not selected any files + if (qList.size() == 0) { + Notifications::showErrorNote("Nothing selected"); + return false; + } + + bool retval(true); + CArrayFix* pArrayFix = NULL; + try{ + // Create CArrayFix for application numbers that are launched and Qlist into CArrayFix + QT_TRAP_THROWING( pArrayFix = QModelIndexListToCArrayFixL(qList) ); + + // Start launching applications + QT_TRAP_THROWING(mEngine->StartAppLaunchingL(pArrayFix, autoClose ? ETrue : EFalse)); + } + catch (const std::exception &e){ + qDebug() << "EngineWrapper::startAppLaunching - exception: " << e.what(); + retval = false; + } + + if(pArrayFix) + delete pArrayFix; + + return retval; +} + +// --------------------------------------------------------------------------- + +bool EngineWrapper::stopLaunching() +{ + TRAPD(error, mEngine->StopLaunchingL()); + if (error != KErrNone) { + return false; + } + else { + return true; + } +} + +// --------------------------------------------------------------------------- + +bool EngineWrapper::sendLog() +{ + ShareUi dialog; + QList fileList; + + if( mEngine->LogFileExists() ) + { + const TDesC& logFilePath = mEngine->LogFilePath(); + fileList.append( QString::fromUtf16( logFilePath.Ptr(), logFilePath.Length() ) ); + } + if( mEngine->BCLogFileExists() ) + { + const TDesC& BCLogFilePath = mEngine->BCLogFilePath(); + fileList.append( QString::fromUtf16( BCLogFilePath.Ptr(), BCLogFilePath.Length() ) ); + } + + if( !fileList.empty()){ + dialog.init(fileList,true); + return true; + } + else{ + return false; + } + +} + +// --------------------------------------------------------------------------- + +bool EngineWrapper::deleteLog() +{ + // if log file exists delete it. + if (mEngine->LogFileExists()) { + if (mEngine->DeleteLogFile() != KErrNone) { + return false; + } + } + + //if BC log file exists, delete it. + if (mEngine->BCLogFileExists()) { + if (mEngine->DeleteBCLogFile() != KErrNone) { + return false; + } + } + + return true; + +} + +// --------------------------------------------------------------------------- + +bool EngineWrapper::sendListOfDlls() +{ + const TDesC& systemDllsFilePath = mEngine->SystemDllsFilePath(); + + if ( BaflUtils::FileExists( CEikonEnv::Static()->FsSession(), systemDllsFilePath) ){ + ShareUi dialog; + QList fileList; + fileList.append( QString::fromUtf16( systemDllsFilePath.Ptr(), systemDllsFilePath.Length() ) ); + dialog.init(fileList,true); + return true; + } + else{ + Notifications::showErrorNote("DLL list does not exist"); + return false; + } +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::doCompareDlls(HbAction* action) + { + HbInputDialog *dlg = static_cast(sender()); + if( action && !action->text().compare("ok", Qt::CaseInsensitive) ) + { + TFileName fileName( dlg->value().toString().utf16() ); + TRAPD(error, mEngine->AnalyseDLLsL( fileName ) ); + if( error != KErrNone ) + { + HideWaitDialog(); + HideProgressBar(); + Notifications::showErrorNote( QString("Error in analyse: %1").arg( error ) ); + } + } + } + +// --------------------------------------------------------------------------- + +void EngineWrapper::compareDlls() +{ + const TDesC& requiredDllsFileName = mEngine->RequiredDllsFilePath(); + QString fileName = QString::fromUtf16( requiredDllsFileName.Ptr(), requiredDllsFileName.Length() ); + HbInputDialog::getText( "Select input file for BC analysis:", this, SLOT(doCompareDlls(HbAction*)), fileName ); +} + +// --------------------------------------------------------------------------- +void EngineWrapper::ShowProgressBar(const TDesC& descText, TInt minimum, TInt maximum) +{ + QString qStringText = XQConversions::s60DescToQString(descText); + + if(mProgressDialog){ + delete mProgressDialog; + mProgressDialog = NULL; + } + mProgressDialog = new HbProgressDialog( HbProgressDialog::ProgressDialog ); + + if( maximum > 0 ) + mProgressDialog->setRange(minimum, maximum); + //iProgressDialog->setAutoClose(true); + mProgressDialog->setText(qStringText); + connect(mProgressDialog, SIGNAL(cancelled()), this, SLOT(CancelDllBCanalysis())); + mProgressDialog->show(); +} + +// --------------------------------------------------------------------------- +void EngineWrapper::SetProgressBarValue(TInt value) +{ + if (mProgressDialog && value > 0 ){ + mProgressDialog->setProgressValue(value); + } +} + +// --------------------------------------------------------------------------- +void EngineWrapper::HideProgressBar() +{ + if (mProgressDialog != NULL) { + disconnect(mProgressDialog, SIGNAL(cancelled), this, SLOT(CancelDllBCanalysis())); + delete mProgressDialog; + mProgressDialog = NULL; + } +} + +// --------------------------------------------------------------------------- +void EngineWrapper::CancelDllBCanalysis() +{ + mEngine->CancelBCAnalysis(); +} + +// --------------------------------------------------------------------------- +void EngineWrapper::ShowWaitDialog(const TDesC& descText) +{ + QString qStringText = XQConversions::s60DescToQString(descText); + + if(mWaitDialog){ + delete mWaitDialog; + mWaitDialog = NULL; + } + mWaitDialog = Notifications::showWaitDialog(qStringText); +} + +// --------------------------------------------------------------------------- +void EngineWrapper::HideWaitDialog() +{ + if (mWaitDialog != NULL) { + delete mWaitDialog; + mWaitDialog = NULL; + } +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::setSkipHiddenAndEmbedOnly(bool skip) +{ + if(skip) { + mEngine->SetSkipHiddenAndEmbedOnly(ETrue); + } + else { + mEngine->SetSkipHiddenAndEmbedOnly(EFalse); + } +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::ChangeFocusToOutputView() +{ + mMainWindow->openOutputView(); +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::PrintText(const TDesC& descText) +{ + + // Convert the descriptor to QString + QString qStringText = XQConversions::s60DescToQString(descText); + mMainWindow->printText(qStringText); +} + +// --------------------------------------------------------------------------- + +CArrayFix* EngineWrapper::QModelIndexListToCArrayFixL(const QModelIndexList& qlist) +{ + CArrayFix* pArrayFix = new (ELeave) CArrayFixFlat( qlist.size() ); + CleanupStack::PushL(pArrayFix); + for (int j = 0; j < qlist.size(); j++) { + pArrayFix->AppendL(qlist.at(j).row()); + } + CleanupStack::Pop(pArrayFix); + return pArrayFix; +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::ShowErrorMessage(const TDesC& descText) +{ + QString qStringText = XQConversions::s60DescToQString(descText); + Notifications::showErrorNote(qStringText); +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::ShowInfoMessage(const TDesC& descText) +{ + QString qStringText = XQConversions::s60DescToQString(descText); + Notifications::showInformationNote(qStringText); +} + +// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/launcher/src/launchermainwindow.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/launcher/src/launchermainwindow.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,121 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include +#include +#include + +#include "enginewrapper.h" +#include "commonActions.h" +#include "applicationview.h" +#include "outputview.h" +#include "launchermainwindow.h" + +// Here we create custom document loader to be able to use custom views in XML. +class LauncherDocumentLoader : public HbDocumentLoader +{ +public: + virtual QObject *createObject(const QString& type, const QString &name); +}; + +QObject *LauncherDocumentLoader::createObject(const QString& type, const QString &name) +{ + // Application view + if (type == ApplicationView::staticMetaObject.className()) { + QObject *object = new ApplicationView; + object->setObjectName(name); + return object; + } + + // Output view + else if (type == OutputView::staticMetaObject.className()) { + QObject *object = new OutputView; + object->setObjectName(name); + return object; + } + + return HbDocumentLoader::createObject(type, name); +} + + +LauncherMainWindow::LauncherMainWindow( QWidget *parent ) : HbMainWindow( parent ) + ,mEngineWrapper(0) + ,mApplicationView(0) + ,mOutputView(0) + ,mCommonActions(0) + { + } + +LauncherMainWindow::~LauncherMainWindow () + { + if(mCommonActions) + delete mCommonActions; + if(mEngineWrapper) + delete mEngineWrapper; + } + +int LauncherMainWindow::init( HbApplication &app ) + { + + // Create Engine Wrapper and initialize it + mEngineWrapper = new EngineWrapper(this); + if (!mEngineWrapper->init()) { + return EXIT_FAILURE; + } + + // Create common actions class for actions that are used in all views of Launcher + mCommonActions = new CommonActions(mEngineWrapper, &app); + + // Create document loader + LauncherDocumentLoader loader; + + // Create application view + mApplicationView = ApplicationView::create(loader, mCommonActions, mEngineWrapper); + // Add view to main window + addView(mApplicationView); + + loader.reset(); + + // Create output view + mOutputView = OutputView::create(loader, mCommonActions); + // Add view to main window + addView(mOutputView); + + // Show ApplicationView at startup + setCurrentView(mApplicationView); + + // Show HbMainWindow + show(); + + return 0;// no errors + } + +void LauncherMainWindow::openApplicationView() + { + setCurrentView(mApplicationView); + } + +void LauncherMainWindow::openOutputView() + { + setCurrentView(mOutputView); + } + +void LauncherMainWindow::printText(const QString &text) + { + mOutputView->printText(text); + } diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/launcher/src/main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/launcher/src/main.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include +#include + + +int main(int argc, char *argv[]) +{ + + // Create application, main window. + HbApplication app(argc, argv); + // Create main window + LauncherMainWindow mainWindow; + // init main window + int error = mainWindow.init(app); + if(error) + return error; + // enter event loop + return app.exec(); +} + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/launcher/src/notifications.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/launcher/src/notifications.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,88 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include +#include +#include + + +#include "notifications.h" + +// --------------------------------------------------------------------------- + +void Notifications::showMessageBox(HbMessageBox::MessageBoxType type, const QString &text, const QString &label, int timeout ) +{ + HbMessageBox *messageBox = new HbMessageBox(type); + messageBox->setText(text); + if(label.length()) + { + HbLabel *header = new HbLabel(label, messageBox); + messageBox->setHeadingWidget(header); + } + messageBox->setAttribute(Qt::WA_DeleteOnClose); + messageBox->setTimeout(timeout); + messageBox->open(); +} + +// --------------------------------------------------------------------------- + +void Notifications::about() +{ + Notifications::showMessageBox( + HbMessageBox::MessageTypeInformation, + "Version 4.0.1 - 21st May 2010. Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. Licensed under Eclipse Public License v1.0.", + "About Launcher" + ); +} + +// --------------------------------------------------------------------------- + +HbDeviceProgressDialog* Notifications::showWaitDialog(const QString &text) +{ + HbDeviceProgressDialog *note = new HbDeviceProgressDialog( HbProgressDialog::WaitDialog ); + note->setText( text ); + note->setAction(0); + note->show(); + return note; +} + +// --------------------------------------------------------------------------- + +void Notifications::showInformationNote(const QString &text) +{ + Notifications::showMessageBox( + HbMessageBox::MessageTypeInformation, + text, + "", // no label + 3000 + ); +} + +// --------------------------------------------------------------------------- + +void Notifications::showErrorNote(const QString &text) +{ + Notifications::showMessageBox( + HbMessageBox::MessageTypeWarning, + text, + "", // no label + 3000 + ); +} + +// --------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/launcher/src/outputview.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/launcher/src/outputview.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,159 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include +#include +#include +#include +#include + +#include "enginewrapper.h" +#include "commonActions.h" +#include "outputview.h" + +// xml definition of view +const char *OUTPUTVIEW_XML = ":/xml/outputview.xml"; + +// name of the output view object in the xml file. +const char *OUTPUTVIEW = "outputview"; +const char *ACTIONCLEAR = "actionClearWindow"; +const char *TEXTOUTPUT = "textEdit"; +const char *ACTIONOPENAPPLICATIONVIEW = "actionOpenApplicationView"; + +// --------------------------------------------------------------------------- + + +OutputView::OutputView(): + mActionClear(0), + mActionOpenApplicationView(0), + mTextOutput(0) +{ + +} + +// --------------------------------------------------------------------------- + +OutputView::~OutputView() +{ + if(mActionClear) + mActionClear->deleteLater(); + if(mActionOpenApplicationView) + mActionOpenApplicationView->deleteLater(); +} + + +// --------------------------------------------------------------------------- + +OutputView* OutputView::create(HbDocumentLoader &loader, + CommonActions *commonActions) +{ + // Load application view from xml-file + bool ok = false; + loader.load(OUTPUTVIEW_XML, &ok); + + // Output View: + QGraphicsWidget *widget = loader.findWidget(OUTPUTVIEW); + Q_ASSERT_X(ok && (widget != 0), "Launcher", "Invalid launcher.xml file"); + OutputView *outputView = qobject_cast(widget); + + // initialize view + outputView->init(loader, commonActions); + + return outputView; +} + +// --------------------------------------------------------------------------- + + +void OutputView::loadItemsFromXml(HbDocumentLoader &loader) +{ + + // List widget: + QGraphicsWidget *widget = loader.findWidget(TEXTOUTPUT); + Q_ASSERT_X((widget != 0), "Launcher", "Invalid launcher.xml file"); + mTextOutput = qobject_cast(widget); + + // clear action: + QObject *object= loader.findObject(ACTIONCLEAR); + Q_ASSERT_X((object != 0), "Launcher", "Invalid launcher.xml file"); + mActionClear = qobject_cast(object); + + // open output view + object= loader.findObject(ACTIONOPENAPPLICATIONVIEW); + Q_ASSERT_X((object != 0), "Launcher", "Invalid launcher.xml file"); + mActionOpenApplicationView = qobject_cast(object); + +} + +// --------------------------------------------------------------------------- + + +void OutputView::init(HbDocumentLoader &loader, CommonActions *commonActions) +{ + loadItemsFromXml(loader); + connectSignalsAndSlots(); + + // set text edit components settings + mTextOutput->setPlainText("Ready.\n\n"); + mTextOutput->setReadOnly(true); + mTextOutput->setCursorVisibility( Hb::TextCursorHidden ); + mTextOutput->setAttribute(Qt::WA_InputMethodEnabled, false); + + // add actions to menu + commonActions->addActionsToMenu(menu()); + +} + +// --------------------------------------------------------------------------- + +void OutputView::connectSignalsAndSlots() +{ + // Clear action + connect(mActionClear, SIGNAL(triggered()), this, SLOT(clearOutput())); + connect(mActionOpenApplicationView, SIGNAL(triggered()), this, SLOT(openApplicationView())); +} + +// --------------------------------------------------------------------------- + +void OutputView::clearOutput() +{ + mTextOutput->setPlainText(""); +} + +// --------------------------------------------------------------------------- + +void OutputView::printText(const QString &text) +{ + QString newText = mTextOutput->toPlainText() + text; + mTextOutput->setPlainText(newText); + mTextOutput->setCursorPosition(newText.length()-1); +} + +// --------------------------------------------------------------------------- + +void OutputView::openApplicationView() +{ + qDebug("openApplicationView"); + LauncherMainWindow *pMainWindow = static_cast< LauncherMainWindow * >( mainWindow() ); + if( pMainWindow ) + { + pMainWindow->openApplicationView(); + } +} + +// --------------------------------------------------------------------------- + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/launcher/src/outputview.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/launcher/src/outputview.xml Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/engine/inc/loadgen.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/engine/inc/loadgen.hrh Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,190 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef LOADGEN_HRH +#define LOADGEN_HRH + +enum TLoadGenCommandIds + { + ELoadGenCmdNewLoad, + ELoadGenCmdNewLoadCPULoad, + ELoadGenCmdNewLoadEatMemory, + ELoadGenCmdNewLoadPhoneCall, + ELoadGenCmdNewLoadNetConn, + ELoadGenCmdNewLoadKeyPress, + ELoadGenCmdNewLoadMessages, + ELoadGenCmdNewLoadApplications, + ELoadGenCmdNewLoadPhotoCaptures, + ELoadGenCmdNewLoadBluetooth, + ELoadGenCmdNewLoadPointerEvent, + ELoadGenStopAll, + ELoadGenSuspendAll, + ELoadGenResumeAll, + + ELoadGenCmdLaunchPerfMon, + ELoadGenCmdAbout, + + ELoadGenCmdSettingsChange, + ELoadGenCmdSettingsExit, + ELoadGenCmdSettingsBack, + + ELoadGenSettingItemList + }; + +enum TEditorFormItemIds + { + ELoadGenCPULoadQueryPriority = 1000, + ELoadGenCPULoadQueryMode, + ELoadGenCPULoadQueryType, + ELoadGenCPULoadQueryLength, + ELoadGenCPULoadQueryIdle, + ELoadGenCPULoadQueryVariance, + ELoadGenCPULoadQueryCpu, + + ELoadGenMemoryEatQueryPriority, + ELoadGenMemoryEatQuerySource, + ELoadGenMemoryEatQueryType, + ELoadGenMemoryEatQueryBuffer, + ELoadGenMemoryEatQueryIdle, + ELoadGenMemoryEatQueryAmount, + ELoadGenMemoryEatQueryRandomMin, + ELoadGenMemoryEatQueryRandomMax, + ELoadGenMemoryEatQueryVariance, + + ELoadGenPhoneCallQueryPriority, + ELoadGenPhoneCallQueryDestination, + ELoadGenPhoneCallQueryLength, + ELoadGenPhoneCallQueryIdle, + ELoadGenPhoneCallQueryVariance, + + ELoadGenNetConnQueryPriority, + ELoadGenNetConnQueryDestination, + ELoadGenNetConnQueryIdle, + ELoadGenNetConnQueryVariance, + + ELoadGenKeyPressQueryPriority, + ELoadGenKeyPressQueryHeartBeat, + ELoadGenKeyPressQueryVariance, + + ELoadGenMessagesQueryPriority, + ELoadGenMessagesQueryType, // Message type + ELoadGenMessagesQueryDestination, // Phone number + ELoadGenMessagesQueryAmount, // Messages + ELoadGenMessagesQueryLength, // Message length + ELoadGenMessagesQueryMessage, // Message + ELoadGenMessagesQueryIdle, // idle period + ELoadGenMessagesQueryVariance, + + ELoadGenApplicationsQueryPriority, + ELoadGenApplicationsLaunchingInterval, + ELoadGenApplicationsKeyPressQueryHeartBeat, + ELoadGenApplicationsMaxOpen, + ELoadGenApplicationsKeyPressType, + ELoadGenApplicationsQueryVariance, + + ELoadGenPhotoCaptureQueryPriority, + ELoadGenPhotoCaptureQueryDevice, + ELoadGenPhotoCaptureQueryIdle, + ELoadGenPhotoCaptureQueryVariance, + + ELoadGenBluetoothQueryPriority, + ELoadGenBluetoothQueryIdle, + ELoadGenBluetoothQueryVariance, + + ELoadGenPointerEventQueryPriority, + ELoadGenPointerEventQueryHeartBeat, + ELoadGenPointerEventQueryVariance + }; + +enum TItemActionMenuTypes + { + EItemActionMenuTypeStop = 0, + EItemActionMenuTypeSuspendResume, + EItemActionMenuTypeEdit + }; + +enum TThreadPriorityTypes + { + EThreadPriorityTypeMuchLess = 0, + EThreadPriorityTypeLess, + EThreadPriorityTypeNormal, + EThreadPriorityTypeMore, + EThreadPriorityTypeMuchMore, + EThreadPriorityTypeRealTime, + EThreadPriorityTypeAbsoluteVeryLow, + EThreadPriorityTypeAbsoluteLow, + EThreadPriorityTypeAbsoluteBackground, + EThreadPriorityTypeAbsoluteForeground, + EThreadPriorityTypeAbsoluteHigh + }; + +enum TCpuLoadMode + { + ECpuLoadModeYielding = 0, + ECpuLoadModeBlocking + }; + +enum TCpuLoadTypes + { + ECpuLoadTypeContinuous = 0, + ECpuLoadTypePeriodic + }; + +enum TMemoryEatTypes + { + EMemoryEatTypeMemoryToEat = 0, + EMemoryEatTypeMemoryToBeLeft, + EMemoryEatTypeWavy + }; + +enum TMemoryEatSourceTypes + { + EMemoryEatSourceTypeRAM = 0, + EMemoryEatSourceTypeDriveC, + EMemoryEatSourceTypeDriveD, + EMemoryEatSourceTypeDriveE, + EMemoryEatSourceTypeDriveF, + EMemoryEatSourceTypeDriveG, + EMemoryEatSourceTypeDriveH, + EMemoryEatSourceTypeDriveI, + EMemoryEatSourceTypeDriveJ, + EMemoryEatSourceTypeDriveK, + EMemoryEatSourceTypeDriveL, + EMemoryEatSourceTypeDriveM, + EMemoryEatSourceTypeDriveN + }; + +enum TMessageTypes + { + EMessageTypeSMS = 0, + EMessageTypeMMS + }; + +enum TApplicationsKeyPressTypes + { + EApplicationsKeyPressTypeNone = 0, + EApplicationsKeyPressTypeArrows + }; + +enum TApplicationsEventTypes + { + EApplicationsCloseApplication = 0, + EApplicationsLaunchApplication + }; + +#endif // LOADGEN_HRH diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/engine/inc/loadgen_applications.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/engine/inc/loadgen_applications.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,197 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +#ifndef LOADGEN_APPLICATIONS_H +#define LOADGEN_APPLICATIONS_H + +// INCLUDES +#include +#include +#include + +#include "loadgen_loadbase.h" +#include "loadgen_loadattributes.h" + + +// FORWARD DECLARATIONS +class CLauncherEngine; + +// CLASS DECLARATIONS + +class CAppLauncher : public CLoadBase + { +public: + static CAppLauncher* NewL( TApplicationsAttributes& aAttributes, + TInt aReferenceNumber ); + virtual ~CAppLauncher(); + +private: // Constructors + CAppLauncher( TApplicationsAttributes& aAttributes, + TInt aReferenceNumber ); + void ConstructL(); + +public: // New methods + virtual void Resume(); + virtual void Suspend(); + virtual void SetPriority(); + virtual void Close(); + virtual TPtrC Description(); + inline TApplicationsAttributes& Attributes() { return iAttributes; } + inline void SetAttributes(const TApplicationsAttributes& aAttributes) { iAttributes = aAttributes; } + + +public: // New static methods + static TInt ThreadFunction( TAny* aThreadArg ); + +private: // New static methods + static void GenerateLoad( TApplicationsAttributes& aAttributes ); + +private: // Data + TApplicationsAttributes iAttributes; + RThread iThread; + }; + +// Class to start launching applications in given period + +// CLASS DECLARATIONS +class CAppLauncherManager : public CActive + { +public: + static CAppLauncherManager* NewL( TApplicationsAttributes& aAttributes ); + ~CAppLauncherManager(); + +private: + CAppLauncherManager( TApplicationsAttributes& aAttributes ); + void ConstructL(); + +private: + void RunL(); + void DoCancel(); + +private: + static TInt PeriodicTimerCallBack( TAny* aAny ); + void SimulateEventL(); + +public: + inline CPeriodic* PeriodicTimer() { return iPeriodicTimer; } + +private: + TApplicationsAttributes& iAttributes; + CPeriodic* iPeriodicTimer; + RWsSession iWsSession; + CLauncherEngine* iLauncherEngine; + TInt iAppEventType; + }; + +// A class where applicationg launching and ending is implemented +#include +#include + +// FORWARD DECLARATIONS +class CAppKeyPressManager; + +// CLASS DECLARATIONS +class CLauncherEngine : public CBase + { +public: + static CLauncherEngine* NewL( TApplicationsAttributes& aAttributes ); + ~CLauncherEngine(); + +public: + void StartAppLaunchingL(); + void StopApplication( TBool aRandomApplication ); + + +private: + CLauncherEngine( TApplicationsAttributes& aAttributes ); + void ConstructL(); + TBool LaunchApplicationL(); + void DoLaunchApplicationL(); + +public: + inline TInt AppLaunchCounter() { return iAppLaunchCounter; } + +private: + RTimer iTimer; + RApaLsSession iLs; + RWsSession iWs; + TInt iAppLaunchCounter; + TUid iCurrentAppUid; + TThreadId iCurrentAppThreadId; + TBuf<128> iCurrentAppNameAndExt; + RThread iCurrentAppThread; + TInt iParallelApplicationsCounter; + TApplicationsAttributes& iAttributes; + + CAppKeyPressManager* iAppKeyPressManager; + }; + + +// A class where key presses can be added to application +#include +// FORWARD DECLARATIONS +class CApplicationKeyPresses; +// CLASS DECLARATIONS +class CAppKeyPressManager : public CBase + { +public: + static CAppKeyPressManager* NewL( TApplicationsAttributes& aAttributes ); + ~CAppKeyPressManager(); + void AddNewApplicationUidToKeyEventsL( TUid aUid ); + TUid KillApplication( TBool aRandomApplication ); + +private: + CAppKeyPressManager( TApplicationsAttributes& aAttributes ); + void ConstructL(); + +private: + RPointerArray iKeyPresses; + TApplicationsAttributes& iAttributes; + }; + +// A class which sends key press events to application +// CLASS DECLARATIONS +class CApplicationKeyPresses : public CBase + { +public: + static CApplicationKeyPresses* NewL( TUid aUid, + TApplicationsAttributes& aAttributes ); + ~CApplicationKeyPresses(); + +private: + CApplicationKeyPresses( TUid aUid, TApplicationsAttributes& aAttributes ); + void ConstructL(); + +private: + static TInt PeriodicTimerCallBack( TAny* aAny ); + void SimulateKeyEvent(); + +public: + inline CPeriodic* PeriodicTimer() { return iPeriodicTimer; } + +private: + TUid iUid; + TApplicationsAttributes& iAttributes; + CPeriodic* iPeriodicTimer; + RWsSession iWsSession; +public: + inline TUid ApplicationUid() { return iUid; }; + }; + +#endif // LOADGEN_APPLICATIONS diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/engine/inc/loadgen_bluetooth.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/engine/inc/loadgen_bluetooth.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,108 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +#ifndef LOADGEN_BLUETOOTH_H +#define LOADGEN_BLUETOOTH_H + +// INCLUDES +#include +#include +#include +#include "loadgen_loadbase.h" +#include "loadgen_loadattributes.h" +#include +#include + +// FORWARD DECLARATIONS + +// CLASS DECLARATIONS + +class CBluetooth : public CLoadBase + { +public: + static CBluetooth* NewL(TBluetoothAttributes& aAttributes, TInt aReferenceNumber); + virtual ~CBluetooth(); + +private: // Constructors + CBluetooth(TBluetoothAttributes& aAttributes, TInt aReferenceNumber); + void ConstructL(); + +public: // New methods + virtual void Resume(); + virtual void Suspend(); + virtual void SetPriority(); + virtual void Close(); + virtual TPtrC Description(); + inline TBluetoothAttributes& Attributes() { return iAttributes; } + inline void SetAttributes(const TBluetoothAttributes& aAttributes) { iAttributes = aAttributes; } + +public: // New static methods + static TInt ThreadFunction(TAny* aThreadArg); + +private: // New static methods + static void GenerateLoad(TBluetoothAttributes& aAttributes); + void InitializeBluetoothL(); + TBool SetBTPowerState(TBool aState); + +private: // Data + + TBluetoothAttributes iAttributes; + RThread iThread; + }; + + + + +class CBTManager : public CActive//, public MBTPowerManagerObserver + { + public: + + static CBTManager* NewL(TBluetoothAttributes& aAttrs); + virtual ~CBTManager(); + + private: + + CBTManager( TBluetoothAttributes& aAttrs); + void ConstructL(); + TInt StartBTDeviceDiscovery(); + + private: + + static TInt PeriodicTimerCallBack(TAny* aAny); + public: + + /** + * From CActive: + */ + void RunL(); + void DoCancel(); + + private: + + CPeriodic* iPeriodicTimer; + TBluetoothAttributes& iAttributes; + CRepository* iBTPowerStateCRepo; + RSocketServ iSocketServerHnd; + RHostResolver iHostResolver; + TNameEntry iBTNameEntry; + }; + + +#endif + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/engine/inc/loadgen_cpuload.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/engine/inc/loadgen_cpuload.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +#ifndef LOADGEN_CPULOAD_H +#define LOADGEN_CPULOAD_H + +// INCLUDES +#include +#include + +#include "loadgen_loadbase.h" +#include "loadgen_loadattributes.h" + + +// FORWARD DECLARATIONS + + + +// CLASS DECLARATIONS + +class CCPULoad : public CLoadBase + { +public: + static CCPULoad* NewL(TCPULoadAttributes& aAttributes, TInt aReferenceNumber); + virtual ~CCPULoad(); + +private: // Constructors + CCPULoad(TCPULoadAttributes& aAttributes, TInt aReferenceNumber); + void ConstructL(); + +public: // New methods + virtual void Resume(); + virtual void Suspend(); + virtual void SetPriority(); + virtual void Close(); + virtual TPtrC Description(); + inline TCPULoadAttributes& Attributes() { return iAttributes; } + inline void SetAttributes(const TCPULoadAttributes& aAttributes) { iAttributes = aAttributes; } + +public: // New static methods + static TInt ThreadFunction(TAny* aThreadArg); + +private: // New static methods + static void GenerateLoad(TCPULoadAttributes& aAttributes); + static void DoHeaveStuff(TInt aMode); + +private: // Data + TCPULoadAttributes iAttributes; + RThread iThread; + }; + + +#endif diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/engine/inc/loadgen_httpreceiver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/engine/inc/loadgen_httpreceiver.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,183 @@ + + +#ifndef CHTTPReceiver_H +#define CHTTPReceiver_H + +#include +#include +#include +#include +#include + +// CONSTANTS +// None. + +// MACROS +#ifdef _DEBUG +#define TRACE( text ) RDebug::Printf( text ); +#define TRACE2( text, arg ) RDebug::Printf( text, arg ); +#else +#define TRACE( text ) +#define TRACE2( text, arg ) +#endif + +// DATA TYPES +// None. + +// FUNCTION PROTOTYPES +// None. + +// FORWARD DECLARATIONS +// None. + +class MHTTPRecvObserver + { + public: + + /** + * Callback for HTTP response received. + * @param aStatus Status code. + * @return None. + */ + virtual void HTTPFileReceived( TInt aStatus ) = 0; + }; + +// CLASS DECLARATION + +class CHTTPReceiver + : public CBase, + public MHTTPTransactionCallback + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CHTTPReceiver* NewL( MHTTPRecvObserver& aObserver ); + + /** + * Two-phased constructor. + */ + static CHTTPReceiver* NewLC( MHTTPRecvObserver& aObserver ); + + /** + * Destructor. + */ + virtual ~CHTTPReceiver(); + + /** + * Cancels the current HTTP transaction. + */ + void CancelTransaction(); + + /** + * Opens a connection to destination aUri and sends data using HTTP GET. + * Callbacks via MHTTPRecvObserver::HTTPFileReceived + * Leaves with KErrNotReady If network is not available + * @param aUri Destination URL, if http scheme not specified, prepends scheme. + */ + void SendHTTPGetL( const TDesC8& aUri ); + + protected: // Constructors and destructor + + /** + * C++ default constructor. + */ + CHTTPReceiver( MHTTPRecvObserver& aObserver ); + + /** + * Symbian 2nd phase constructor. + */ + void ConstructL(); + + /** + * Sets HTTP header fields. + * @param aHeaders HTTP headers. + * @param aHdrField Header field to set. + * @param aHdrValue Header field value. + */ + void SetHeaderL(RHTTPHeaders aHeaders, TInt aHdrField, + const TDesC8& aHdrValue); + + //From MHTTPTransactionCallback + /** + * Called by HTTP framework when HTTP events occur. + * @param aTransaction The transaction that the event has occurred on. + * @param aEvent The event that has occurred. + */ + void MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent& aEvent); + + /** + * Called when RunL leaves from a transaction event. + * @param aError The leave code that RunL left with. + * @param aTransaction The transaction that was being processed. + * @param aEvent The event that was being processed. + * @return KErrNone. + */ + TInt MHFRunError( TInt aError, + RHTTPTransaction aTransaction, + const THTTPEvent& aEvent); + + /** + * Starts HTTP connection. + */ + void SetupConnectionL(); + + /** + * Utility:Checks for http uri scheme and prepends if not exists to the url + * @param aUri UriParser. + * @param aURL URL to check for. + * @return None + */ + void CheckForHTTPSchemeL(TUriParser8& aUri, const TDesC8& aURL); + + /** + * Utility: finish receiving, call calback HTTPFileReceived() + * @param aError to be signaled + * @return None + */ + void Finalize(); + + private: + + // Request uri, might need to prepend http scheme. + HBufC8* iUrl; + + // RSocketServ object. + RSocketServ iSocketServ; + + // RConnection object. + RConnection iConnection; + + // HTTP session. + RHTTPSession iSession; + + // HTTP transaction used for request. + RHTTPTransaction iTransaction; + + // Observer to notify. + MHTTPRecvObserver& iObserver; + + // ETrue if transaction in progress. + TBool iRunning; + + // ETrue if connection set up done. + TBool iConnectionSetupDone; + + // Response Status + TInt iResponseStatus; + +#ifdef _DEBUG + // Http response body written to file + RFile iResponseFile; + + // RFs to be used for writing to iResponseFile + RFs iFs; +#endif + +}; + +#endif + +// CHTTPReceiver_H +// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/engine/inc/loadgen_keypress.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/engine/inc/loadgen_keypress.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,95 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef LOADGEN_KEYPRESS_H +#define LOADGEN_KEYPRESS_H + +// INCLUDES +#include +#include +#include + +#include "loadgen_loadbase.h" +#include "loadgen_loadattributes.h" + + +// FORWARD DECLARATIONS + + + +// CLASS DECLARATIONS + +class CKeyPress : public CLoadBase + { +public: + static CKeyPress* NewL(TKeyPressAttributes& aAttributes, TInt aReferenceNumber); + virtual ~CKeyPress(); + +private: // Constructors + CKeyPress(TKeyPressAttributes& aAttributes, TInt aReferenceNumber); + void ConstructL(); + +public: // New methods + virtual void Resume(); + virtual void Suspend(); + virtual void SetPriority(); + virtual void Close(); + virtual TPtrC Description(); + inline TKeyPressAttributes& Attributes() { return iAttributes; } + inline void SetAttributes(const TKeyPressAttributes& aAttributes) { iAttributes = aAttributes; } + +public: // New static methods + static TInt ThreadFunction(TAny* aThreadArg); + +private: // New static methods + static void GenerateLoad(TKeyPressAttributes& aAttributes); + +private: // Data + TKeyPressAttributes iAttributes; + RThread iThread; + }; + + +class CKeyPressManager : public CActive + { +public: + static CKeyPressManager* NewL(TKeyPressAttributes& aAttributes); + ~CKeyPressManager(); + +private: + CKeyPressManager(TKeyPressAttributes& aAttributes); + void ConstructL(); + +private: + void RunL(); + void DoCancel(); + +private: + static TInt PeriodicTimerCallBack(TAny* aAny); + void SimulateKeyEvent(); + +public: + inline CPeriodic* PeriodicTimer() { return iPeriodicTimer; } + +private: + TKeyPressAttributes& iAttributes; + CPeriodic* iPeriodicTimer; + RWsSession iWsSession; + }; + +#endif diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/engine/inc/loadgen_loadattributes.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/engine/inc/loadgen_loadattributes.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,167 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef LOADGEN_LOADATTRIBUTES_H +#define LOADGEN_LOADATTRIBUTES_H + +// INCLUDES +#include +#include +#include // CDesCArray + +const TInt KCPUSelection_FreeScheduling = -1; +const TInt KCPUSelection_AllCPUs = 999; + +// FORWARD DECLARATIONS + + +// CLASS DECLARATIONS +class TCPULoadAttributes + { +public: + TUint iId; + TUint iPriority; + TUint iMode; + TUint iType; + TUint iLength; + TUint iIdle; + TUint iRandomVariance; + // iCpu defines in which CPU the load thread should be executed in + // (in SMP environments). 0 = CPU0, 1 = CPU1 etc. Negative value means + // that CPU is undefined. When CPU is undefined, Scheduler can schedule + // the load thread freely to any CPU as it pleases. + TInt iCpu; + // Defines how many CPUs the running system has. + TUint iCpuCount; + }; + +class TMemoryEatAttributes + { +public: + TUint iId; + TUint iPriority; + TUint iSource; + TUint iType; + TUint iBuffer; + TUint iIdle; + TInt64 iAmount; + TInt64 iRandomMin; + TInt64 iRandomMax; + TBuf<64> iAmountDes; + TBuf<64> iRandomMinDes; + TBuf<64> iRandomMaxDes; + TUint iRandomVariance; + TRequestStatus* iDeathStatus; + }; + +class TPhoneCallAttributes + { +public: + TUint iId; + TUint iPriority; + TBuf<128> iDestination; + TUint iLength; + TUint iIdle; + TUint iRandomVariance; + TRequestStatus* iDeathStatus; + }; + +class TNetConnAttributes + { +public: + TUint iId; + TUint iPriority; + TBuf<128> iDestination; + TUint iIdle; + TUint iRandomVariance; + TRequestStatus* iDeathStatus; + }; + +class TKeyPressAttributes + { +public: + TUint iId; + TUint iPriority; + TUint iHeartBeat; + TUint iRandomVariance; + TRequestStatus* iDeathStatus; + }; + +class TPointerEventAttributes + { +public: + TUint iId; + TUint iPriority; + TUint iHeartBeat; + TUint iRandomVariance; + TRequestStatus* iDeathStatus; + }; + +class TMessageAttributes + { +public: + TUint iId; + TInt iMessageType; + TBuf<128> iDestination; + TUint iPriority; + TUint iAmount; + TInt iLength; + TUint iIdle; + TUint iRandomVariance; + TRequestStatus* iDeathStatus; + }; + +class TApplicationsAttributes + { +public: + TUint iId; + TUint iPriority; + TUint iLaunchingInterval; + TUint iKeyPressType; + TUint iMaxOpen; + TUint iHeartBeat; + TUint iRandomVariance; + CDesCArray* iAppsArray; + TRequestStatus* iDeathStatus; + }; + + +class TPhotoCaptureAttributes + { +public: + TUint iId; + TInt iPriority; + TInt iCameraCount; + TInt iCamera; + TUint iIdle; + TUint iRandomVariance; + TRequestStatus* iDeathStatus; + }; + +class TBluetoothAttributes + { +public: + TUint iId; + TInt iPriority; + TUint iIdle; + TUint iRandomVariance; + TRequestStatus* iDeathStatus; + TBool iBluetoothSupported; + }; + +#endif diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/engine/inc/loadgen_loadbase.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/engine/inc/loadgen_loadbase.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,66 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef LOADGEN_LOADBASE_H +#define LOADGEN_LOADBASE_H + +// INCLUDES +#include +#include + +#include "loadgen_loadbase.h" + + +// FORWARD DECLARATIONS + + + +// CLASS DECLARATIONS + +class CLoadBase : public CBase + { +public: + enum TLoadState + { + ELoadStateInvalid = -1, + ELoadStateConstructed, + ELoadStateRunning, + ELoadStateSuspended, + ELoadStateClosed + }; + +protected: // Constructors + CLoadBase(); + void ConstructL(); + +public: // New methods + virtual void Resume(); + virtual void Suspend(); + virtual void SetPriority(); + virtual void Close(); + virtual TPtrC Description(); + inline TInt State() { return iState; } + inline TInt Type() { return iType; } + +protected: // Data + TInt iState; + TInt iType; + }; + + +#endif diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/engine/inc/loadgen_memoryeat.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/engine/inc/loadgen_memoryeat.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,108 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef LOADGEN_MEMORYEAT_H +#define LOADGEN_MEMORYEAT_H + +// INCLUDES +#include +#include +#include +#include + +#include "loadgen_loadbase.h" +#include "loadgen_loadattributes.h" + + +// FORWARD DECLARATIONS + + + +// CLASS DECLARATIONS + +class CMemoryEat : public CLoadBase + { +public: + static CMemoryEat* NewL(TMemoryEatAttributes& aAttributes, TInt aReferenceNumber); + virtual ~CMemoryEat(); + +private: // Constructors + CMemoryEat(TMemoryEatAttributes& aAttributes, TInt aReferenceNumber); + void ConstructL(); + +public: // New methods + virtual void Resume(); + virtual void Suspend(); + virtual void SetPriority(); + virtual void Close(); + virtual TPtrC Description(); + inline TMemoryEatAttributes& Attributes() { return iAttributes; } + inline void SetAttributes(const TMemoryEatAttributes& aAttributes) { iAttributes = aAttributes; } + +public: // New static methods + static TInt ThreadFunction(TAny* aThreadArg); +private: + static void GenerateLoad(TMemoryEatAttributes& aAttributes); + +private: // Data + TMemoryEatAttributes iAttributes; + RThread iThread; + }; + + +class CMemoryEatManager : public CActive + { +public: + static CMemoryEatManager* NewL(TMemoryEatAttributes& aAttributes); + ~CMemoryEatManager(); + +private: + CMemoryEatManager(TMemoryEatAttributes& aAttributes); + void ConstructL(); + +private: + void RunL(); + void DoCancel(); + +private: + static TInt PeriodicTimerCallBack(TAny* aAny); + void InitMemoryEatL(); + void DestroyMemoryEat(); + void EatMemoryL(); + void DoEatMemoryL( TInt64 aNewSize ); + void HandleEatMemoryL( TInt64 aNewSize ); + void AllocMemoryL( TInt64 aNewSize ); + void FreeMemoryL( TInt64 aNewSize ); + TInt64 ReadFreeMemory(); + + +public: + inline CPeriodic* PeriodicTimer() { return iPeriodicTimer; } + +private: + TMemoryEatAttributes& iAttributes; + CPeriodic* iPeriodicTimer; + RChunk iEatChunk; + RFile iEatFile; + RFs iFs; + TBool iWavyEatMoreMemory; + TInt iFilesCounter; + }; + + +#endif diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/engine/inc/loadgen_messages.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/engine/inc/loadgen_messages.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,422 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef LOADGEN_MESSAGES_H +#define LOADGEN_MESSAGES_H + +// INCLUDES +#include +#include + +#include "loadgen_loadbase.h" +#include "loadgen_loadattributes.h" + + +// FORWARD DECLARATIONS +class CSmsHandler; +class CMmsHandler; + +const TInt EMaxMessageLength = 512; + +// CLASS DECLARATIONS + +class CMessages : public CLoadBase + { +public: + static CMessages* NewL( TMessageAttributes& aAttributes, TInt aReferenceNumber ); + virtual ~CMessages(); + +private: // Constructors + CMessages( TMessageAttributes& aAttributes, TInt aReferenceNumber ); + void ConstructL(); + +public: // New methods + virtual void Resume(); + virtual void Suspend(); + virtual void SetPriority(); + virtual void Close(); + virtual TPtrC Description(); + inline TMessageAttributes& Attributes() { return iAttributes; } + inline void SetAttributes(const TMessageAttributes& aAttributes) { iAttributes = aAttributes; } + +public: // New static methods + static TInt ThreadFunction( TAny* aThreadArg ); + +private: // New static methods + static void GenerateLoad( TMessageAttributes& aAttributes ); + +private: // Data + TMessageAttributes iAttributes; + RThread iThread; + + }; + + +class CMessageManager : public CActive + { +private: + enum TState + { + EStateIdle = 0, + EStateSend, + EStateSending + }; +public: + static CMessageManager* NewL( TMessageAttributes& aAttributes ); + virtual ~CMessageManager(); + + +private: + CMessageManager( TMessageAttributes& aAttributes ); + void ConstructL(); + +private: + void RunL(); + void DoCancel(); + +private: + static TInt PeriodicTimerCallBack( TAny* aAny ); + void HandleMessageSending(); + void DoDial(); + void DoHangup(); + void CreateMessage(); + +public: + inline CPeriodic* PeriodicTimer() { return iPeriodicTimer; } + void HandleStatus( TInt aErr ); + +private: + TMessageAttributes& iAttributes; + CPeriodic* iPeriodicTimer; + TInt iState; + CSmsHandler* iSmsHandler; + CMmsHandler* iMmsHandler; + TInt iMessageCounter; + HBufC* iMessage; + }; + +// INCLUDES +#include +#include +#include +#include +// CONSTANTS +const TInt KBfrLength = 20; +const TInt KTelephoneNumberMaxLength = 100; + +// FORWARD DECLARATIONS +class CSmsAppUi; +class CClientMtmRegistry; +class CSmsClientMtm; + +// CLASS DECLARATION +/** +* CSmsHandler application engine class. +* Takes care of sending and receiveing SMS messages using the SMS client MTM. +* Interacts with the application UI class. +*/ +class CSmsHandler : public CActive, public MMsvSessionObserver + { + public: // Constructors and destructor + + /** + * NewL. + * Two-phased constructor. + * @param aSmsAppUi Pointer to AppUi instance. + * @return Pointer to the created instance of CSmsHandler. + */ + static CSmsHandler* NewL( CMessageManager& aManager ); + + /** + * NewLC. + * Two-phased constructor. + * @param aSmsAppUi Pointer to AppUi instance. + * @return Pointer to the created instance of CSmsHandler. + */ + static CSmsHandler* NewLC( CMessageManager& aManager ); + + /** + * ~CSmsHandler + * Destructor. + */ + virtual ~CSmsHandler(); + + public: // New functions + /** + * SendL. + * Starts the process of creating and sending an SMS message. + * @param aRecipientNumber The number of the recipent. + * @param aMessageText The message text. + * @return ETrue if successful, EFalse if not. + */ + TBool SendL( const TDesC& aRecipientNumber, + const TDesC& aMessageText ); + + public: // Functions from base classes + + /** + * From MMsvSessionObserver, HandleSessionEventL. + * Handles notifications of events from the Message Server. + * @param aEvent The event that has taken place + * @param aArg1 Event type-specific argument value + * @param aArg2 Event type-specific argument value + * @param aArg3 Event type-specific argument value + */ + void HandleSessionEventL( TMsvSessionEvent aEvent, TAny* aArg1, + TAny* aArg2, TAny* aArg3 ); + + protected: // Functions from base classes + + /** + * From CActive, DoCancel. + * Cancels any outstanding requests. + */ + void DoCancel(); + + /** + * From CActive, RunL. + * Handles an active object’s request completion event. + */ + void RunL(); + + private: // Constructors + + /** + * CSmsHandler. + * C++ default constructor. + * @param aSmsAppUi Pointer to AppUi instance. + */ + CSmsHandler( CMessageManager& aManager ); + + /** + * ConstructL. + * 2nd phase constructor. + */ + void ConstructL(); + + private: // New functions + + /** + * AccessMtmL. + * Access the MTM Registry and create an SMS specific Client MTM instance. + */ + void AccessMtmL(); + + /** + * CreateMsgL. + * Create an SMS message. + * @return ETrue if successful, EFalse is unsuccessful. + */ + TBool CreateMsgL(); + + /** + * ScheduleL. + * Schedule an SMS message for sending. + */ + void ScheduleL(); + + /** + * ValidateL. + * Validate an SMS message. + * @return ETrue if successful, EFalse is unsuccessful. + */ + TBool ValidateL(); + + private: // Enumeration + + /** + * TState, enumeration for the state of the handler, used by RunL(). + */ + enum TState + { + EWaitingForMoving = 1, + EWaitingForScheduling + }; + + private: // Data + + /** + * iState, the state of the handler. + */ + TState iState; + + /** + * iSession, the contact database. + * Owned by CSmsHandler object. + */ + CMsvSession* iSession; + + /** + * iMtmRegistry, client MTM registry. + * Owned by CSmsHandler object. + */ + CClientMtmRegistry* iMtmRegistry; + + /** + * iSmsMtm, SMS specific Client MTM. + * Owned by CSmsHandler object. + */ + CSmsClientMtm* iSmsMtm; + + /** + * iOperation, the current message server operation. + * Owned by CSmsHandler object. + */ + CMsvOperation* iOperation; + + /** + * iRecipientNumber, telephone number of the recipient. + */ + TBuf iRecipientNumber; + + /** + * iMessageText, SMS message text. + */ + TBuf iMessageText; + + + /** + * iSmsAppUi, application UI + * Not owned by CSmsHandler object. + */ + CSmsAppUi* iSmsAppUi; + + /** + * iMtmUiRegistry, User Interface MTM Registry. + * Owned by CSmsHandler object. + */ + CMtmUiRegistry* iMtmUiRegistry; + + CMessageManager& iManager; + + }; + + +// INCLUDES +#include // for MMsvSessionObserver +#include // for CMmsClientMtm +#include + +// Forward declarations +class CClientMtmRegistry; +class CMsvSession; + +// +// Container class to draw text on screen +// +class CMmsHandler : public CBase, public MMsvSessionObserver + { +public: // Constructors and destructor + + /** + * NewL. + * Two-phased constructor. + * @param aSmsAppUi Pointer to AppUi instance. + * @return Pointer to the created instance of CSmsHandler. + */ + static CMmsHandler* NewL( CMessageManager& aManager ); + + /** + * NewLC. + * Two-phased constructor. + * @param aSmsAppUi Pointer to AppUi instance. + * @return Pointer to the created instance of CSmsHandler. + */ + static CMmsHandler* NewLC( CMessageManager& aManager ); + + /** + * ~CSmsHandler + * Destructor. + */ + virtual ~CMmsHandler(); + +private: // Constructors + + /** + * CSmsHandler. + * C++ default constructor. + * @param aSmsAppUi Pointer to AppUi instance. + */ + CMmsHandler( CMessageManager& aManager ); + + /** + * ConstructL. + * 2nd phase constructor. + */ + void ConstructL(); + +public: // New functions + + /* + * Creates client MTM registry when session is ready for use. + * This completes model construction and is called after 'server + * ready' event is received after async opening of CMsvSession. + */ + void CompleteConstructL(); + + /* + * CMmsHandler::CreateNewMessageL() + * Creates a new message server entry and set up default values. + * In case the attachment file does not found method return EFalse + * otherwise ETrue. + * There are differenses how to add attachment file between 2nd and 3rd edition. + */ + TBool CreateMsgL(); + + /** + * Send the message. + * Return values: ETrue or EFalse + */ + TBool SendMessageL(); + + /** + * SendL. + * Starts the process of creating and sending an SMS message. + * @param aRecipientNumber The number of the recipent. + * @param aMessageText The message text. + * @return ETrue if successful, EFalse if not. + */ + TBool SendL( const TDesC& aRecipientNumber, + const TDesC& aMessageText ); + +private: + // from MMsvSessionObserver + void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3); + + void SetMessageBodyL(); + +private: + + CMsvSession* iSession; // Client session on the message server + CMmsClientMtm* iMmsMtm; // Message Type Module (MMS) + CClientMtmRegistry* iMtmReg; // Mtm client registry for creating new mtms + + /** + * iRecipientNumber, telephone number of the recipient. + */ + TBuf iRecipientNumber; + + /** + * iMessageText, SMS message text. + */ + TBuf iMessageText; + + CMessageManager& iManager; + + }; +#endif // LOADGEN_MESSAGES_H diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/engine/inc/loadgen_netconn.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/engine/inc/loadgen_netconn.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,97 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef LOADGEN_NETCONN_H +#define LOADGEN_NETCONN_H + +// INCLUDES +#include +#include +#include "loadgen_httpreceiver.h" + +#include "loadgen_loadbase.h" +#include "loadgen_loadattributes.h" + + +// FORWARD DECLARATIONS +class CNetConnManager; + + +// CLASS DECLARATIONS + +class CNetConn : public CLoadBase + { +public: + static CNetConn* NewL(TNetConnAttributes& aAttributes, TInt aReferenceNumber); + virtual ~CNetConn(); + +private: // Constructors + CNetConn(TNetConnAttributes& aAttributes, TInt aReferenceNumber); + void ConstructL(); + +public: // New methods + virtual void Resume(); + virtual void Suspend(); + virtual void SetPriority(); + virtual void Close(); + virtual TPtrC Description(); + inline TNetConnAttributes& Attributes() { return iAttributes; } + inline void SetAttributes(const TNetConnAttributes& aAttributes) { iAttributes = aAttributes; } + +public: // New static methods + static TInt ThreadFunction(TAny* aThreadArg); + +private: // New static methods + static void GenerateLoad(TNetConnAttributes& aAttributes); + +private: // Data + TNetConnAttributes iAttributes; + RThread iThread; + }; + + +class CNetConnManager : public CActive, public MHTTPRecvObserver + { +public: + static CNetConnManager* NewL(TNetConnAttributes& aAttributes); + ~CNetConnManager(); + +private: + CNetConnManager(TNetConnAttributes& aAttributes); + void ConstructL(); + +private: + void RunL(); + void DoCancel(); + +private: + static TInt PeriodicTimerCallBack(TAny* aAny); + void StartDownloadL(); + +private: // MHTTPRecvObserver + void HTTPFileReceived( TInt aStatus ); +public: + inline CPeriodic* PeriodicTimer() { return iPeriodicTimer; } + +private: + TNetConnAttributes& iAttributes; + CPeriodic* iPeriodicTimer; + CHTTPReceiver* iHTTPReceiver; + }; + +#endif diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/engine/inc/loadgen_phonecall.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/engine/inc/loadgen_phonecall.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,135 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef LOADGEN_PHONECALL_H +#define LOADGEN_PHONECALL_H + +// INCLUDES +#include +#include +#include + + +#include "loadgen_loadbase.h" +#include "loadgen_loadattributes.h" + + +// FORWARD DECLARATIONS +class CPhoneCallManager; +class CDialer; + + +// CLASS DECLARATIONS + +class CPhoneCall : public CLoadBase + { +public: + static CPhoneCall* NewL(TPhoneCallAttributes& aAttributes, TInt aReferenceNumber); + virtual ~CPhoneCall(); + +private: // Constructors + CPhoneCall(TPhoneCallAttributes& aAttributes, TInt aReferenceNumber); + void ConstructL(); + +public: // New methods + virtual void Resume(); + virtual void Suspend(); + virtual void SetPriority(); + virtual void Close(); + virtual TPtrC Description(); + inline TPhoneCallAttributes& Attributes() { return iAttributes; } + inline void SetAttributes(const TPhoneCallAttributes& aAttributes) { iAttributes = aAttributes; } + +public: // New static methods + static TInt ThreadFunction(TAny* aThreadArg); + +private: // New static methods + static void GenerateLoad(TPhoneCallAttributes& aAttributes); + +private: // Data + TPhoneCallAttributes iAttributes; + RThread iThread; + }; + + + +class CPhoneCallManager : public CActive + { +private: + enum TState + { + EStateIdle = 0, + EStateCall + }; +public: + static CPhoneCallManager* NewL(TPhoneCallAttributes& aAttributes); + ~CPhoneCallManager(); + +private: + CPhoneCallManager(TPhoneCallAttributes& aAttributes); + void ConstructL(); + +private: + void RunL(); + void DoCancel(); + +private: + static TInt PeriodicTimerCallBack(TAny* aAny); + void HandleCalls(); + void DoDial(); + void DoHangup(); + +public: + inline CPeriodic* PeriodicTimer() { return iPeriodicTimer; } + void HandleStatus(TInt aErr); + +private: + TPhoneCallAttributes& iAttributes; + CDialer* iDialer; + CPeriodic* iPeriodicTimer; + TInt iState; + }; + + +class CDialer : public CActive + { +public: + static CDialer* NewL(CPhoneCallManager& aManager); + ~CDialer(); + +private: + CDialer(CPhoneCallManager& aManager); + void ConstructL(); + +private: + void RunL(); + void DoCancel(); + +public: + void Dial(const TDesC& aDestination); + void Hangup(); + +private: + CPhoneCallManager& iManager; + CTelephony* iTelephony; + CTelephony::TCallId iCallId; + CTelephony::TCallParamsV1 iCallParams; + CTelephony::TCallParamsV1Pckg iCallParamsPckg; + }; + +#endif diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/engine/inc/loadgen_photocapture.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/engine/inc/loadgen_photocapture.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,140 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef LOADGEN_PHOTOCAPTURE_H +#define LOADGEN_PHOTOCAPTURE_H + +// INCLUDES +#include +#include +#include // CCamera, MCameraObserver + +#include "loadgen_loadbase.h" +#include "loadgen_loadattributes.h" + + +// FORWARD DECLARATIONS +class CCameraManager; + + +// CLASS DECLARATIONS + +class CPhotoCapture : public CLoadBase + { +public: + static CPhotoCapture* NewL(TPhotoCaptureAttributes& aAttributes, TInt aReferenceNumber); + virtual ~CPhotoCapture(); + +private: // Constructors + CPhotoCapture(TPhotoCaptureAttributes& aAttributes, TInt aReferenceNumber); + void ConstructL(); + +public: // New methods + virtual void Resume(); + virtual void Suspend(); + virtual void SetPriority(); + virtual void Close(); + virtual TPtrC Description(); + inline TPhotoCaptureAttributes& Attributes() { return iAttributes; } + inline void SetAttributes(const TPhotoCaptureAttributes& aAttributes) { iAttributes = aAttributes; } + + +public: // New static methods + static TInt ThreadFunction(TAny* aThreadArg); + //static void SetImagesReady(TInt aImages); + //static TInt ImagesReady(); + +private: // New static methods + static void GenerateLoad(TPhotoCaptureAttributes& aAttributes); + static void DoHeaveStuff(TInt aMode); + +private: // Data + TPhotoCaptureAttributes iAttributes; + RThread iThread; + //static TInt iImagesReady; + }; + + + + +class CCameraManager : public CActive, public MCameraObserver + { + public: + + static CCameraManager* NewL(TPhotoCaptureAttributes& aAttrs); + virtual ~CCameraManager(); + + private: + + CCameraManager(TPhotoCaptureAttributes& aAttrs); + void ConstructL(); + + private: + /** + * From MCameraObserver: + */ + virtual void ReserveComplete(TInt aError); + virtual void PowerOnComplete(TInt aError); + virtual void ViewFinderFrameReady(CFbsBitmap& aFrame); + virtual void ImageReady(CFbsBitmap* aBitmap, + HBufC8* aData, TInt aError); + virtual void FrameBufferReady(MFrameBuffer* aFrameBuffer, + TInt aError); + + static TInt PeriodicTimerCallBack(TAny* aAny); + public: + + /** + * Reserves the camera. + */ + void ReserveCameraL(); + + /** + * Takes a picture. + */ + void CapturePhotoL(); + + TInt NumberOfPictures(); + + /** + * From CActive: + */ + void RunL(); + void DoCancel(); + + private: + + enum TState + { + ENotReady, + ECameraReserved, + EIdle, + ECapture + }; + + CPeriodic* iPeriodicTimer; + TPhotoCaptureAttributes& iAttributes; + CCamera* iCamera; + TState iState; + TInt iNumOfPics; + TCameraInfo iCameraInfo; + TInt iCurrentCamera; + }; + + +#endif diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/engine/inc/loadgen_pointerevent.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/engine/inc/loadgen_pointerevent.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,95 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef LOADGEN_POINTEREVENT_H +#define LOADGEN_POINTEREVENT_H + +// INCLUDES +#include +#include +#include +#include +#include "loadgen_loadbase.h" +#include "loadgen_loadattributes.h" + + +// FORWARD DECLARATIONS + + + +// CLASS DECLARATIONS + +class CPointerEvent : public CLoadBase + { +public: + static CPointerEvent* NewL(TPointerEventAttributes& aAttributes, TInt aReferenceNumber); + virtual ~CPointerEvent(); + +private: // Constructors + CPointerEvent(TPointerEventAttributes& aAttributes, TInt aReferenceNumber); + void ConstructL(); + +public: // New methods + virtual void Resume(); + virtual void Suspend(); + virtual void SetPriority(); + virtual void Close(); + virtual TPtrC Description(); + inline TPointerEventAttributes& Attributes() { return iAttributes; } + inline void SetAttributes(const TPointerEventAttributes& aAttributes) { iAttributes = aAttributes; } + +public: // New static methods + static TInt ThreadFunction(TAny* aThreadArg); + +private: // New static methods + static void GenerateLoad(TPointerEventAttributes& aAttributes); + +private: // Data + TPointerEventAttributes iAttributes; + RThread iThread; + }; + + +class CPointerEventManager : public CActive + { +public: + static CPointerEventManager* NewL(TPointerEventAttributes& aAttributes); + ~CPointerEventManager(); + +private: + CPointerEventManager(TPointerEventAttributes& aAttributes); + void ConstructL(); + +private: + void RunL(); + void DoCancel(); + +private: + static TInt PeriodicTimerCallBack(TAny* aAny); + void SimulatePointerEvent(); + +public: + inline CPeriodic* PeriodicTimer() { return iPeriodicTimer; } + +private: + TPointerEventAttributes& iAttributes; + CPeriodic* iPeriodicTimer; + //RWsSession iWsSession; + }; + +#endif diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/engine/inc/loadgen_std.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/engine/inc/loadgen_std.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef LOADGEN_STD_H +#define LOADGEN_STD_H + + + +#endif + +// End of File + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/engine/inc/loadgen_traces.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/engine/inc/loadgen_traces.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,106 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef __LOADGEN_TRACES_H__ +#define __LOADGEN_TRACES_H__ + +#include + + +// --------------------------------------------------------------------------- +// You change these logging method values below! Recompile the application to take changes effect. + + // logging methods + // 0 = No logging + // 1 = Flogger + // 2 = RDebug + // 3 = Flogger and RDebug + + #ifndef _DEBUG + + // Logging method for UREL builds: + #define LOADGEN_LOGGING_METHOD 3 + + #else + + // Logging method for UDEB builds: + #define LOADGEN_LOGGING_METHOD 3 + + #endif + + + +// --------------------------------------------------------------------------- +// Do not make any changes to lines below... + + #if LOADGEN_LOGGING_METHOD == 1 || LOADGEN_LOGGING_METHOD == 3 + + #include + _LIT(KLogFolder,"loadgen"); + _LIT(KLogFile,"loadgen_trace.txt"); + + #endif + + #if LOADGEN_LOGGING_METHOD == 2 || LOADGEN_LOGGING_METHOD == 3 + + #include + + #endif + + + #if LOADGEN_LOGGING_METHOD == 0 + + #define LOGTEXT(AAA) + #define LOGSTRING(AAA) + #define LOGSTRING2(AAA,BBB) + #define LOGSTRING3(AAA,BBB,CCC) + #define LOGSTRING4(AAA,BBB,CCC,DDD) + + + #elif LOADGEN_LOGGING_METHOD == 1 + + #define LOGTEXT(AAA) RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend, AAA) + #define LOGSTRING(AAA) do { _LIT(tempLogDes,AAA); RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend,tempLogDes()); } while (0) + #define LOGSTRING2(AAA,BBB) do { _LIT(tempLogDes,AAA); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB); } while (0) + #define LOGSTRING3(AAA,BBB,CCC) do { _LIT(tempLogDes,AAA); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB,CCC); } while (0) + #define LOGSTRING4(AAA,BBB,CCC,DDD) do { _LIT(tempLogDes,AAA); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB,CCC,DDD); } while (0) + + #elif LOADGEN_LOGGING_METHOD == 2 + + #define LOGTEXT(AAA) RDebug::Print(AAA) + #define LOGSTRING(AAA) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes); } while (0) + #define LOGSTRING2(AAA,BBB) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB); } while (0) + #define LOGSTRING3(AAA,BBB,CCC) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC); } while (0) + #define LOGSTRING4(AAA,BBB,CCC,DDD) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC, DDD); } while (0) + + #elif LOADGEN_LOGGING_METHOD == 3 + + #define LOGTEXT(AAA) RDebug::Print(AAA); RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend, AAA) + #define LOGSTRING(AAA) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes); RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend,tempLogDes()); } while (0) + #define LOGSTRING2(AAA,BBB) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB); } while (0) + #define LOGSTRING3(AAA,BBB,CCC) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB,CCC); } while (0) + #define LOGSTRING4(AAA,BBB,CCC,DDD) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC, DDD); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB,CCC,DDD); } while (0) + + #endif + +// --------------------------------------------------------------------------- + +#endif // __LOADGEN_TRACES_H__ + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/engine/inc/loadgen_utils.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/engine/inc/loadgen_utils.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef LOADGEN_UTILS_H +#define LOADGEN_UTILS_H + +// INCLUDES +#include +#include + +const TUint KHalFunction_EKernelHalNumLogicalCpus = 16; //EKernelHalNumLogicalCpus +const TUint KHalFunction_EKernelHalLockThreadToCpu = 19; //EKernelHalLockThreadToCpu + +class CLoadGenUtils { + +public: + static TThreadPriority SettingItemToThreadPriority(TInt aIndex); + static void SettingItemToThreadDescription(TInt aIndex, TDes& aBuf); + static void SettingItemToSourceDescription(TInt aIndex, TDes& aBuf); + static TInt MilliSecondsToMicroSeconds(TInt aMilliSeconds, TInt aRandomVariance=0); + static TInt RandomNumber(TInt aMin, TInt aMax); + static TSize ScreenSize(); + +private: + /* Desctructor pure Virtual -> static class cannot be instantiated or inherited */ + virtual ~CLoadGenUtils()=0; + static TInt64 iRandomNumberSeed; + +}; + +#endif \ No newline at end of file diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/engine/src/loadgen_applications.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/engine/src/loadgen_applications.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,683 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +// INCLUDE FILES +#include "loadgen_applications.h" +#include "loadgen_utils.h" +#include "loadgen.hrh" +#include + +#include +#include "loadgen_traces.h" + +_LIT(KThreadName, "Applications %d"); + +const TInt KDefaultStartDelay = 500; +const TInt KThreadNameLength = 64; +const TInt KDescriptorBufSize = 256; +const TInt KPriorityBufSize = 16; +const TInt KScanCodeStart = 32; + +// ===================================== MEMBER FUNCTIONS ===================================== + +CAppLauncher* CAppLauncher::NewL( TApplicationsAttributes& aAttributes, TInt aReferenceNumber ) + { + CAppLauncher* self = new(ELeave) CAppLauncher( aAttributes, aReferenceNumber ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// -------------------------------------------------------------------------------------------- + +CAppLauncher::~CAppLauncher() + { + Close(); + } + +// -------------------------------------------------------------------------------------------- + +CAppLauncher::CAppLauncher( + TApplicationsAttributes& aAttributes, TInt aReferenceNumber ) : + iAttributes( aAttributes ) + { + iAttributes.iId = aReferenceNumber; + } + +// -------------------------------------------------------------------------------------------- + +void CAppLauncher::ConstructL() + { + CLoadBase::ConstructL(); + + iType = ELoadGenCmdNewLoadApplications; + + TBuf threadName; + threadName.Format( KThreadName, iAttributes.iId ); + + // create a thread + User::LeaveIfError( iThread.Create( threadName, ThreadFunction, + KDefaultStackSize*2, KMinHeapSize, + KKilo * KMinHeapSize, (TAny*) &iAttributes ) ); + + // set priority of the thread + SetPriority(); + } + +// -------------------------------------------------------------------------------------------- + +TInt CAppLauncher::ThreadFunction( TAny* aThreadArg ) + { + CTrapCleanup* pC = CTrapCleanup::New(); + CActiveScheduler* pS = new CActiveScheduler; + CActiveScheduler::Install( pS ); + + // start generating load, pass pointer to arguments + GenerateLoad( *( ( TApplicationsAttributes* ) aThreadArg ) ); + + delete pS; + delete pC; + + return KErrNone; + } + +// -------------------------------------------------------------------------------------------- + +void CAppLauncher::GenerateLoad( TApplicationsAttributes& aAttributes ) + { + CAppLauncherManager* appLauncherManager = NULL; + TRAPD( err, appLauncherManager = CAppLauncherManager::NewL( aAttributes ) ); + if ( err == KErrNone ) + { + CActiveScheduler::Start(); + } + delete appLauncherManager; + } + +// -------------------------------------------------------------------------------------------- + +void CAppLauncher::Resume() + { + CLoadBase::Resume(); + + iThread.Resume(); + } + +// -------------------------------------------------------------------------------------------- + +void CAppLauncher::Suspend() + { + CLoadBase::Suspend(); + + iThread.Suspend(); + } + +// -------------------------------------------------------------------------------------------- + +void CAppLauncher::SetPriority() + { + CLoadBase::SetPriority(); + + iThread.SetPriority( CLoadGenUtils::SettingItemToThreadPriority( iAttributes.iPriority ) ); + } + +// -------------------------------------------------------------------------------------------- + +void CAppLauncher::Close() + { + CLoadBase::Close(); + + if ( iThread.ExitReason() == 0 ) // check if the thread is still alive + { + // signal the thread that it needs to close + iThread.RequestComplete( iAttributes.iDeathStatus, KErrCancel ); + + // wait the thread to die + TRequestStatus waiter; + iThread.Logon( waiter ); + User::WaitForRequest( waiter ); + iThread.Close(); + } + } + +// -------------------------------------------------------------------------------------------- + +TPtrC CAppLauncher::Description() + { + TBuf buf; + TBuf prioBuf; + CLoadGenUtils::SettingItemToThreadDescription( iAttributes.iPriority, prioBuf ); + + _LIT(KAppLauncherEntry, "[%d] Appls prio=%S max apps=%d heartbeat=%dms random=%d%%"); + buf.Format( KAppLauncherEntry, iAttributes.iId, &prioBuf, iAttributes.iMaxOpen, + iAttributes.iHeartBeat, iAttributes.iRandomVariance ); + + return TPtrC( buf ); + } + +// -------------------------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------- + +CAppLauncherManager* CAppLauncherManager::NewL( TApplicationsAttributes& aAttributes ) + { + CAppLauncherManager* self = new(ELeave) CAppLauncherManager(aAttributes); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// -------------------------------------------------------------------------------------------- + +CAppLauncherManager::CAppLauncherManager( TApplicationsAttributes& aAttributes ) : + CActive( EPriorityStandard ), iAttributes( aAttributes ) + { + iAppEventType = EApplicationsLaunchApplication; + } + +// -------------------------------------------------------------------------------------------- + +CAppLauncherManager::~CAppLauncherManager() + { + if ( iPeriodicTimer ) + { + iPeriodicTimer->Cancel(); + delete iPeriodicTimer; + } + delete iLauncherEngine; + Cancel(); + + iWsSession.Close(); + } + +// -------------------------------------------------------------------------------------------- + +void CAppLauncherManager::ConstructL() + { + CActiveScheduler::Add( this ); + + // create instance to application launcher + iLauncherEngine = CLauncherEngine::NewL( iAttributes ); + + // set the status as pending + iStatus = KRequestPending; + SetActive(); + + // set the death status pointer point to the request status of this ao + iAttributes.iDeathStatus = &iStatus; + + // init + User::LeaveIfError( iWsSession.Connect() ); + + // start timer + iPeriodicTimer = CPeriodic::NewL( CActive::EPriorityStandard ); + iPeriodicTimer->Start( KDefaultStartDelay, + CLoadGenUtils::MilliSecondsToMicroSeconds( + iAttributes.iLaunchingInterval, iAttributes.iRandomVariance ), + TCallBack( PeriodicTimerCallBack, this ) ); + } + +// -------------------------------------------------------------------------------------------- + +void CAppLauncherManager::RunL() + { + // request status has completed by the main thread meaning that we need to stop now + CActiveScheduler::Stop(); + } + +// -------------------------------------------------------------------------------------------- + +void CAppLauncherManager::DoCancel() + { + } + +// -------------------------------------------------------------------------------------------- + +TInt CAppLauncherManager::PeriodicTimerCallBack( TAny* aAny ) + { + CAppLauncherManager* self = static_cast( aAny ); + + TRAPD( err, self->SimulateEventL() ); + if ( KErrNone != err ) + { + return err; + } + return KErrNone; + } + +// -------------------------------------------------------------------------------------------- + +void CAppLauncherManager::SimulateEventL() + { + // Randomly start new applications. + // After maximum applications launched stop one application. + // And after that start launching again. + if ( iAppEventType == EApplicationsLaunchApplication && + iAttributes.iMaxOpen == iLauncherEngine->AppLaunchCounter() ) + { + iAppEventType = EApplicationsCloseApplication; + } + if ( iAppEventType == EApplicationsCloseApplication && + iAttributes.iMaxOpen -1 == iLauncherEngine->AppLaunchCounter() ) + { + iAppEventType = EApplicationsLaunchApplication; + } + + // Launch or stop + if ( iAppEventType == EApplicationsLaunchApplication ) + { + iLauncherEngine->StartAppLaunchingL(); + } + else + { + iLauncherEngine->StopApplication( ETrue ); + } + } + +// -------------------------------------------------------------------------------------------- + +#include +#include +#include +#include +#include +#include +#include + +// --------------------------------------------------------------------------- + +CLauncherEngine* CLauncherEngine::NewL( TApplicationsAttributes& aAttributes ) + { + CLauncherEngine* self = new(ELeave) CLauncherEngine( aAttributes ); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// --------------------------------------------------------------------------- + +CLauncherEngine::CLauncherEngine( TApplicationsAttributes& aAttributes ) : + iAttributes( aAttributes ) + { + } + +// --------------------------------------------------------------------------- + +void CLauncherEngine::ConstructL() + { + LOGSTRING("LoadGen: CLauncherEngine::ConstructL"); + iAppKeyPressManager = CAppKeyPressManager::NewL( iAttributes ); + iAppLaunchCounter = 0; + User::LeaveIfError( iTimer.CreateLocal() ); + + User::LeaveIfError( iLs.Connect() ); + User::LeaveIfError( iWs.Connect() ); + + } + +// --------------------------------------------------------------------------- + +CLauncherEngine::~CLauncherEngine() + { + LOGSTRING("LoadGen: CLauncherEngine::~CLauncherEngine"); + StopApplication( EFalse ); + iWs.Close(); + iLs.Close(); + iTimer.Close(); + delete iAppKeyPressManager; + } + +// --------------------------------------------------------------------------- + +void CLauncherEngine::StartAppLaunchingL() + { + LOGSTRING("LoadGen: CLauncherEngine::StartAppLaunchingL"); + if ( iAppLaunchCounter == iAttributes.iMaxOpen ) + { + return; + } + + // start launching + TBool launched( EFalse ); + while ( !launched ) + { + launched = LaunchApplicationL(); + } + } + +// --------------------------------------------------------------------------- + +TBool CLauncherEngine::LaunchApplicationL() + { + LOGSTRING("LoadGen: CLauncherEngine::LaunchApplicationL"); + TBool result( EFalse ); + // get the uid of the current app + iCurrentAppUid = KNullUid; + TApaAppInfo appInfo; + + // get application list size + TInt appsListSize = iAttributes.iAppsArray->MdcaCount(); + // get random application number in the list + TInt appTolaunch = CLoadGenUtils::RandomNumber( 0, appsListSize - 1 ); + // get file name of the application to be launched + TFileName launchFileName = iAttributes.iAppsArray->MdcaPoint( appTolaunch ); + iLs.GetAllApps(); + while ( iLs.GetNextApp( appInfo ) == KErrNone ) + { + // get file name in current appInfo + TFileName appFileName = appInfo.iFullName; + // get AppUid + if ( appFileName.CompareF( launchFileName ) == 0 ) + { + iCurrentAppUid = appInfo.iUid; + break; + } + } + + if ( iCurrentAppUid != KNullUid ) + { + // parse the filename + TParse nameParser; + nameParser.SetNoWild( iAttributes.iAppsArray->MdcaPoint( appTolaunch ), NULL, NULL ); + iCurrentAppNameAndExt.Copy( nameParser.Drive() ); + iCurrentAppNameAndExt.Append( nameParser.NameAndExt() ); + + // do not try to launch these apps + if ( iCurrentAppUid != KNullUid && + iAttributes.iAppsArray->MdcaPoint( appTolaunch).FindF(_L("\\loadgen.")) == KErrNotFound && + iAttributes.iAppsArray->MdcaPoint( appTolaunch ).FindF( _L("\\Phone." ) ) == KErrNotFound && + iAttributes.iAppsArray->MdcaPoint( appTolaunch).FindF( _L("\\Startup.") ) == KErrNotFound && + iAttributes.iAppsArray->MdcaPoint( appTolaunch ).FindF( _L("\\SplashScreen.") ) == KErrNotFound && + iAttributes.iAppsArray->MdcaPoint( appTolaunch ).FindF( _L("\\cameraapp.") ) == KErrNotFound && + iAttributes.iAppsArray->MdcaPoint( appTolaunch ).FindF( _L("\\eshell.") ) == KErrNotFound && + iAttributes.iAppsArray->MdcaPoint( appTolaunch ).FindF( _L("\\ConnTest.") ) == KErrNotFound && + iAttributes.iAppsArray->MdcaPoint( appTolaunch ).FindF( _L("\\Launcher.") ) == KErrNotFound && + +#ifdef __WINS__ + iAttributes.iAppsArray->MdcaPoint( appTolaunch ).FindF( _L("\\DebugAgent.") ) == KErrNotFound && + iAttributes.iAppsArray->MdcaPoint( appTolaunch ).FindF( _L("\\redirect.") ) == KErrNotFound && +#endif + iAttributes.iAppsArray->MdcaPoint( appTolaunch ).FindF( _L("\\VoiceRecorder.") ) == KErrNotFound ) + { + + // check if the app is already running + TApaTaskList taskList( iWs ); + TApaTask thisTask = taskList.FindApp( iCurrentAppUid ); + if ( !thisTask.Exists( )) + { + // check the program's capabilities + TApaAppCapabilityBuf buf; + iLs.GetAppCapability( buf, iCurrentAppUid ); + TApaAppCapability cap = buf(); + + // if it's embeddable only, don't launch if setting is enabled + // if it's hidden, don't launch if setting is enabled + if ( cap.iEmbeddability != TApaAppCapability::EEmbeddableOnly && + !cap.iAppIsHidden ) + { + LOGSTRING2("launchFileName = %S", &launchFileName); + + DoLaunchApplicationL(); + result = ETrue; + } + } + } + } + return result; + } + + +// --------------------------------------------------------------------------- + +void CLauncherEngine::DoLaunchApplicationL() + { + LOGSTRING("LoadGen: CLauncherEngine::DoLaunchApplicationL"); + + // Find the task with uid3 + TApaTaskList tasklist( iWs ); + TApaTask task=tasklist.FindApp( iCurrentAppUid ); + + if ( !task.Exists() ) + // Task doesn't exist, launch a new instance of an application + { + TApaAppInfo appInfo; + User::LeaveIfError( iLs.GetAppInfo( appInfo, iCurrentAppUid ) ); + + CApaCommandLine* cmdLine=CApaCommandLine::NewLC(); + cmdLine->SetExecutableNameL( appInfo.iFullName ); + + // app is launched in background + cmdLine->SetCommandL( EApaCommandBackground ); + + // start the app + User::LeaveIfError( iLs.StartApp( *cmdLine ) ); + iAppKeyPressManager->AddNewApplicationUidToKeyEventsL( iCurrentAppUid ); + iAppLaunchCounter++; + + CleanupStack::PopAndDestroy( cmdLine ); + } + } + +// --------------------------------------------------------------------------- + +void CLauncherEngine::StopApplication( TBool aRandomApplication ) + { + LOGSTRING("LoadGen: CLauncherEngine::StopApplication"); + + // remove key pressing instance + TUid appToDelete = iAppKeyPressManager->KillApplication( aRandomApplication ); + if ( appToDelete != KNullUid ) + { + TApaTaskList taskList( iWs ); + TApaTask thisTask = taskList.FindApp( appToDelete ); + + if ( thisTask.Exists() ) + { + // since the application is still open, let's close it + thisTask.EndTask(); + } + iAppLaunchCounter--; + } + + // return if only one application requested + if ( aRandomApplication ) + { + return; + } + + // remove all launched applications because load is requested to be closed + while ( appToDelete != KNullUid ) + { + appToDelete = iAppKeyPressManager->KillApplication( aRandomApplication ); + + if ( appToDelete != KNullUid ) + { + TApaTaskList taskList( iWs ); + TApaTask thisTask = taskList.FindApp( appToDelete ); + + if ( thisTask.Exists() ) + { + // since the application is still open, let's close it + thisTask.EndTask(); + } + iAppLaunchCounter--; + } + } + } + +// -------------------------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------- + +CAppKeyPressManager* CAppKeyPressManager::NewL( TApplicationsAttributes& aAttributes ) + { + LOGSTRING("LoadGen: CAppKeyPressManager::NewL"); + CAppKeyPressManager* self = new(ELeave) CAppKeyPressManager( aAttributes ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// -------------------------------------------------------------------------------------------- + +CAppKeyPressManager::CAppKeyPressManager( TApplicationsAttributes& aAttributes ) : + iAttributes( aAttributes ) + { + LOGSTRING("LoadGen: CAppKeyPressManager::CAppKeyPressManager"); + } + +// -------------------------------------------------------------------------------------------- + +CAppKeyPressManager::~CAppKeyPressManager() + { + LOGSTRING("LoadGen: CAppKeyPressManager::~CAppKeyPressManager"); + if ( iKeyPresses.Count() != 0 ) + { + iKeyPresses.ResetAndDestroy(); + } + + iKeyPresses.Close(); + } + +// -------------------------------------------------------------------------------------------- + +void CAppKeyPressManager::ConstructL() + { + LOGSTRING("LoadGen: CAppKeyPressManager::ConstructL"); + } + + +// -------------------------------------------------------------------------------------------- +void CAppKeyPressManager::AddNewApplicationUidToKeyEventsL( TUid aUid ) + { + LOGSTRING("LoadGen: CAppKeyPressManager::AddNewApplicationUidToKeyEventsL"); + CApplicationKeyPresses* applicationKP = CApplicationKeyPresses::NewL( aUid, + iAttributes ); + CleanupStack::PushL( applicationKP ); + User::LeaveIfError( iKeyPresses.Append( applicationKP ) ); + CleanupStack::Pop( applicationKP ); + } + +// -------------------------------------------------------------------------------------------- +TUid CAppKeyPressManager::KillApplication( TBool aRandomApplication ) + { + TUid applicationUid = KNullUid; + TInt appToDelete = iKeyPresses.Count() - 1 ; + // remove the newest application if not random + if ( aRandomApplication ) + { + appToDelete = CLoadGenUtils::RandomNumber( 0, iKeyPresses.Count() - 1 ); + } + if ( iKeyPresses.Count() ) + { + // get random application and delete it + + applicationUid = iKeyPresses[appToDelete]->ApplicationUid(); + delete iKeyPresses[appToDelete]; + iKeyPresses.Remove( appToDelete ); + } + return applicationUid; + } +// -------------------------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------- + +CApplicationKeyPresses* CApplicationKeyPresses::NewL( TUid aUid, TApplicationsAttributes& + aAttributes ) + { + LOGSTRING("LoadGen: CApplicationKeyPresses::NewL"); + CApplicationKeyPresses* self = new(ELeave) CApplicationKeyPresses( aUid, aAttributes ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// -------------------------------------------------------------------------------------------- + +CApplicationKeyPresses::CApplicationKeyPresses( TUid aUid, + TApplicationsAttributes& aAttributes ) : + iUid( aUid ), iAttributes( aAttributes ) + { + LOGSTRING("LoadGen: CApplicationKeyPresses::CApplicationKeyPresses"); + } + +// -------------------------------------------------------------------------------------------- + +CApplicationKeyPresses::~CApplicationKeyPresses() + { + LOGSTRING("LoadGen: CApplicationKeyPresses::~CApplicationKeyPresses"); + if ( iPeriodicTimer ) + { + iPeriodicTimer->Cancel(); + delete iPeriodicTimer; + } + + iWsSession.Close(); + } + +// -------------------------------------------------------------------------------------------- + +void CApplicationKeyPresses::ConstructL() + { + LOGSTRING("LoadGen: CApplicationKeyPresses::ConstructL"); + // init + User::LeaveIfError( iWsSession.Connect() ); + + // start timer + iPeriodicTimer = CPeriodic::NewL( CActive::EPriorityStandard ); + if ( iAttributes.iKeyPressType ) + { + iPeriodicTimer->Start( KDefaultStartDelay, + CLoadGenUtils::MilliSecondsToMicroSeconds( + iAttributes.iHeartBeat, + iAttributes.iRandomVariance ), + TCallBack( PeriodicTimerCallBack, this ) ); + } + } + +// -------------------------------------------------------------------------------------------- + +TInt CApplicationKeyPresses::PeriodicTimerCallBack( TAny* aAny ) + { + CApplicationKeyPresses* self = static_cast( aAny ); + self->SimulateKeyEvent(); + return KErrNone; + } + +// -------------------------------------------------------------------------------------------- + +void CApplicationKeyPresses::SimulateKeyEvent() + { + LOGSTRING("LoadGen: CApplicationKeyPresses::SimulateKeyEvent"); + // for arrow key events + + TInt wgId(0); + CApaWindowGroupName::FindByAppUid( iUid, iWsSession, wgId ); + // generate a random arrow key event + TWsEvent event; + event.SetType( EEventKey ); + event.Key()->iCode = CLoadGenUtils::RandomNumber( EKeyLeftArrow, EKeyDownArrow ); + event.Key()->iScanCode = event.Key()->iCode - KScanCodeStart; + event.Key()->iModifiers = 0; + event.Key()->iRepeats = 0; + iWsSession.SendEventToWindowGroup( wgId, event ); + } + +// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/engine/src/loadgen_bluetooth.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/engine/src/loadgen_bluetooth.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,339 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +// INCLUDE FILES +#include "loadgen_bluetooth.h" +#include "loadgen_utils.h" +#include "loadgen.hrh" +#include "loadgen_traces.h" +#include +#include +#include +#include +#include +#include +#include +#include + +_LIT(KThreadName, "Bluetooth %d"); +_LIT(KBTLinkManagerStr, "BTLinkManager"); + +const TInt KDefaultStart = 50; +const TInt KDefaultPeriod = 5000000; + +// ===================================== MEMBER FUNCTIONS ===================================== + +CBluetooth* CBluetooth::NewL(TBluetoothAttributes& aAttributes, TInt aReferenceNumber) + { + CBluetooth* self = new(ELeave) CBluetooth(aAttributes, aReferenceNumber); + CleanupStack::PushL(self); + TRAPD(err, self->ConstructL()); + if( err != KErrNone ) + { + User::Leave(err); + } + CleanupStack::Pop(self); + return self; + } + +// -------------------------------------------------------------------------------------------- + +CBluetooth::~CBluetooth() + { + Close(); + } + +// -------------------------------------------------------------------------------------------- + +CBluetooth::CBluetooth(TBluetoothAttributes& aAttributes, TInt aReferenceNumber) : iAttributes(aAttributes) + { + iAttributes.iId = aReferenceNumber; + } + +// -------------------------------------------------------------------------------------------- + +void CBluetooth::ConstructL() + { + CLoadBase::ConstructL(); + + iType = ELoadGenCmdNewLoadBluetooth; + + InitializeBluetoothL(); + + TBuf<64> threadName; + threadName.Format(KThreadName, iAttributes.iId); + + // create a thread + User::LeaveIfError(iThread.Create(threadName, ThreadFunction, KDefaultStackSize*2, KMinHeapSize, 1024*KMinHeapSize, (TAny*) &iAttributes )); + + // set priority of the thread + SetPriority(); + iState = ELoadStateConstructed; + } + +// -------------------------------------------------------------------------------------------- + +TInt CBluetooth::ThreadFunction(TAny* aThreadArg) + { + TInt err = KErrNone; + + CTrapCleanup* pC = CTrapCleanup::New(); + CActiveScheduler* pS = new CActiveScheduler; + CActiveScheduler::Install(pS); + + // start generating load, pass pointer to arguments + GenerateLoad(*((TBluetoothAttributes*) aThreadArg)); + + delete pS; + delete pC; + + return err; + } + +// -------------------------------------------------------------------------------------------- + +void CBluetooth::GenerateLoad(TBluetoothAttributes& aAttributes) + { + CBTManager* btManager = 0; + TRAPD(err, btManager = CBTManager::NewL(aAttributes)); + if (err == KErrNone) CActiveScheduler::Start(); + delete btManager; + } + +// -------------------------------------------------------------------------------------------- + +void CBluetooth::Resume() + { + CLoadBase::Resume(); + iThread.Resume(); + } + +// -------------------------------------------------------------------------------------------- + +void CBluetooth::Suspend() + { + CLoadBase::Suspend(); + iThread.Suspend(); + } + +// -------------------------------------------------------------------------------------------- + +void CBluetooth::SetPriority() + { + CLoadBase::SetPriority(); + iThread.SetPriority(CLoadGenUtils::SettingItemToThreadPriority(iAttributes.iPriority)); + } + +// -------------------------------------------------------------------------------------------- + +void CBluetooth::Close() + { + LOGSTRING2("LoadGen: CBluetooth::~CBluetooth() - State: %d", iState); + if( iState != ELoadStateInvalid ) + { + CLoadBase::Close(); + // kill the thread immediately + iThread.Kill(0); + iThread.Close(); + } + } + +// -------------------------------------------------------------------------------------------- +TPtrC CBluetooth::Description() + { + TBuf<256> buf; + TBuf<16> prioBuf; + CLoadGenUtils::SettingItemToThreadDescription(iAttributes.iPriority, prioBuf); + + _LIT(KBluetoothEntry, "[%d] Bluetooth prio=%S idle=%dms random=%d%%"); + buf.Format(KBluetoothEntry, iAttributes.iId, &prioBuf, iAttributes.iIdle, iAttributes.iRandomVariance); + + return TPtrC(buf); + } + +// -------------------------------------------------------------------------------------------- +void CBluetooth::InitializeBluetoothL() + { + // Create central repository for checking and setting bluetooth power state + CRepository* btPowerStateCRepo = CRepository::NewL(KCRUidBluetoothPowerState); + + // Check if the BT is already turned on: + TInt btPowerState = 0; + btPowerStateCRepo->Get(KBTPowerState, btPowerState); + delete btPowerStateCRepo; + btPowerStateCRepo = 0; + + if(btPowerState == EBTPowerOff) + { + // Switch bt power on: + if (SetBTPowerState(ETrue) == EFalse) + { + LOGSTRING("LoadGen: Bluetooth could not be switched on"); + User::Leave(KErrNotReady); + } + } + } + +// -------------------------------------------------------------------------------------------- +TBool CBluetooth::SetBTPowerState(TBool aState) + { + // Ask user to turn on the bluetooth device: + RNotifier btPowerNotifier; + TInt errCode = btPowerNotifier.Connect(); + + TBool retVal = errCode == KErrNone; + + if( errCode == KErrNone ) + { + TPckgBuf powerRequest(aState); + TPckgBuf powerReply(EFalse); + TRequestStatus powerRequestStatus; + btPowerNotifier.StartNotifierAndGetResponse(powerRequestStatus, + KPowerModeSettingNotifierUid, + powerRequest, + powerReply); + User::WaitForRequest(powerRequestStatus); + btPowerNotifier.CancelNotifier(KPowerModeSettingNotifierUid); + btPowerNotifier.Close(); + if( powerReply() == EFalse ) + { + LOGSTRING("LoadGen: Bluetooth activating cancelled."); + } + retVal = powerReply(); + } + + return retVal; + } + +// -------------------------------------------------------------------------------------------- +CBTManager* CBTManager::NewL( TBluetoothAttributes& aAttrs) + { + CBTManager* self = new (ELeave) CBTManager( aAttrs); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// -------------------------------------------------------------------------------------------- +CBTManager::~CBTManager() + { + if (iPeriodicTimer) + { + iPeriodicTimer->Cancel(); + delete iPeriodicTimer; + } + iHostResolver.Close(); + Cancel(); + } + +// -------------------------------------------------------------------------------------------- +CBTManager::CBTManager( TBluetoothAttributes& aAttrs) +: +CActive(EPriorityStandard), +iAttributes(aAttrs) + { + } + +// -------------------------------------------------------------------------------------------- +void CBTManager::ConstructL() + { + // Socket server session initiation: + User::LeaveIfError(iSocketServerHnd.Connect()); + + CActiveScheduler::Add(this); + // set the status as pending + iStatus = KRequestPending; + SetActive(); + + // set the death status pointer point to the request status of this ao + iAttributes.iDeathStatus = &iStatus; + + // start timer + iPeriodicTimer = CPeriodic::NewL(CActive::EPriorityStandard); + iPeriodicTimer->Start(KDefaultStart, KDefaultPeriod, TCallBack(PeriodicTimerCallBack, this)); + } + +// -------------------------------------------------------------------------------------------- +void CBTManager::DoCancel() + { + LOGSTRING("LoadGen: CBTManager::DoCancel()"); + } + +// -------------------------------------------------------------------------------------------- +void CBTManager::RunL() + { + // request status has completed by the main thread meaning that we need to stop now + CActiveScheduler::Stop(); + } + +// -------------------------------------------------------------------------------------------- +TInt CBTManager::StartBTDeviceDiscovery() + { + TInt retVal = KErrNone; + RThread myThread; + + // Initialize host resolver + iHostResolver.Close(); + TProtocolDesc protocolInfo; + retVal = iSocketServerHnd.FindProtocol(KBTLinkManagerStr(), protocolInfo); + if( retVal == KErrNone ) + { + retVal = iHostResolver.Open(iSocketServerHnd, protocolInfo.iAddrFamily, protocolInfo.iProtocol); + } + + if( retVal == KErrNone ) + { + TInquirySockAddr socketAddress; + socketAddress.SetIAC( KGIAC ); + socketAddress.SetAction(KHostResInquiry|KHostResName|KHostResIgnoreCache); + retVal = iHostResolver.GetByAddress(socketAddress, iBTNameEntry); + // Loop all discovered devices: + while( retVal == KErrNone ) + { + LOGSTRING3("LoadGen: Thread %S found device: %S", &(myThread.Name()), &(iBTNameEntry().iName) ); + // Get next device + retVal = iHostResolver.Next(iBTNameEntry); + } + } + + // KErrEof is returned when no more devices to loop + if( retVal == KErrEof ) + { + retVal = KErrNone; + } + + iPeriodicTimer->Start( CLoadGenUtils::MilliSecondsToMicroSeconds( iAttributes.iIdle, + iAttributes.iRandomVariance ), KDefaultPeriod, + TCallBack( PeriodicTimerCallBack, this ) ); + + return retVal; + } + +// -------------------------------------------------------------------------------------------- + +TInt CBTManager::PeriodicTimerCallBack(TAny* aAny) + { + CBTManager* self = static_cast( aAny ); + self->iPeriodicTimer->Cancel(); + // Perform device discovery: + self->StartBTDeviceDiscovery(); + return KErrNone; + } + +// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/engine/src/loadgen_cpuload.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/engine/src/loadgen_cpuload.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,270 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +// INCLUDE FILES +#include "loadgen_cpuload.h" +#include "loadgen_utils.h" +#include "loadgen.hrh" +#include +#include +#include +#include +#include + +_LIT(KThreadName, "CPULoad %d"); + +// ===================================== MEMBER FUNCTIONS ===================================== + +CCPULoad* CCPULoad::NewL(TCPULoadAttributes& aAttributes, TInt aReferenceNumber) + { + CCPULoad* self = new(ELeave) CCPULoad(aAttributes, aReferenceNumber); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// -------------------------------------------------------------------------------------------- + +CCPULoad::~CCPULoad() + { + Close(); + } + +// -------------------------------------------------------------------------------------------- + +CCPULoad::CCPULoad(TCPULoadAttributes& aAttributes, TInt aReferenceNumber) : iAttributes(aAttributes) + { + iAttributes.iId = aReferenceNumber; + } + +// -------------------------------------------------------------------------------------------- + +void CCPULoad::ConstructL() + { + CLoadBase::ConstructL(); + + iType = ELoadGenCmdNewLoadCPULoad; + + TBuf<64> threadName; + threadName.Format(KThreadName, iAttributes.iId); + + // create a thread + User::LeaveIfError(iThread.Create(threadName, ThreadFunction, KDefaultStackSize*2, KMinHeapSize, 1024*KMinHeapSize, (TAny*) &iAttributes )); + + // set priority of the thread + SetPriority(); + } + +// -------------------------------------------------------------------------------------------- + +TInt CCPULoad::ThreadFunction(TAny* aThreadArg) + { + TCPULoadAttributes* threadArg = (TCPULoadAttributes*)aThreadArg; + TInt err = KErrNone; + + // if a cpu is defined, tie this thread to the given cpu (SMP environment) + if (threadArg->iCpu >= 0 && threadArg->iCpu != KCPUSelection_AllCPUs ) + { + UserSvr::HalFunction(EHalGroupKernel, KHalFunction_EKernelHalLockThreadToCpu, (TAny*) threadArg->iCpu, 0); + } + + CTrapCleanup* pC = CTrapCleanup::New(); + CActiveScheduler* pS = new CActiveScheduler; + CActiveScheduler::Install(pS); + + // start generating load, pass pointer to arguments + GenerateLoad(*((TCPULoadAttributes*) aThreadArg)); + + delete pS; + delete pC; + + return err; + } + +// -------------------------------------------------------------------------------------------- + +void CCPULoad::GenerateLoad(TCPULoadAttributes& aAttributes) + { + for (;;) + { + if (aAttributes.iType == ECpuLoadTypeContinuous) + { + // do constantly heave stuff + DoHeaveStuff(aAttributes.iMode); + } + + else if (aAttributes.iType == ECpuLoadTypePeriodic) + { + // do periodically heave stuff + TTime startTime; + startTime.HomeTime(); // get start time + + TTime currentTime; + TTimeIntervalMicroSeconds interval; + TInt processPeriod; + #ifdef QT_SUPPORT + + #else + processPeriod = CLoadGenUtils::MilliSecondsToMicroSeconds(aAttributes.iLength, aAttributes.iRandomVariance); + #endif + do + { + // do heave stuff + DoHeaveStuff(aAttributes.iMode); + + currentTime.HomeTime(); + interval = currentTime.MicroSecondsFrom(startTime); + } + while (interval.Int64() < processPeriod); + + + // now wait + User::After( CLoadGenUtils::MilliSecondsToMicroSeconds(aAttributes.iIdle, aAttributes.iRandomVariance) ); + } + + else + { + User::Panic(_L("Unk.type"), 888); + } + } + } + +// -------------------------------------------------------------------------------------------- + +void CCPULoad::DoHeaveStuff(TInt aMode) + { + TTime now; + now.HomeTime(); + TInt64 seed = now.Int64(); + + TReal random = Math::FRand(seed); + + TReal target(10); + TReal source(10); + + target += random; + + Math::Cos(target, source); + + source = source / 1.0382873; + source -= 32.24343; + source += 132.24343; + source *= random; + + // yield trick + if (aMode == ECpuLoadModeYielding) + { + // sleep randomly + if (User::TickCount() % 50 == 0) + User::AfterHighRes(1); + } + } + +// -------------------------------------------------------------------------------------------- + +void CCPULoad::Resume() + { + CLoadBase::Resume(); + + iThread.Resume(); + } + +// -------------------------------------------------------------------------------------------- + +void CCPULoad::Suspend() + { + CLoadBase::Suspend(); + + iThread.Suspend(); + } + +// -------------------------------------------------------------------------------------------- + +void CCPULoad::SetPriority() + { + CLoadBase::SetPriority(); + + iThread.SetPriority(CLoadGenUtils::SettingItemToThreadPriority(iAttributes.iPriority)); + } + +// -------------------------------------------------------------------------------------------- + +void CCPULoad::Close() + { + CLoadBase::Close(); + + // kill the thread immediately + iThread.Kill(0); + + iThread.Close(); + } + +// -------------------------------------------------------------------------------------------- + +TPtrC CCPULoad::Description() + { + TBuf<256> buf; + TBuf<16> prioBuf; + CLoadGenUtils::SettingItemToThreadDescription(iAttributes.iPriority, prioBuf); + + if (iAttributes.iType == ECpuLoadTypeContinuous) + { + if (iAttributes.iMode == ECpuLoadModeYielding) + { + _LIT(KCPULoadEntryContinuous, "[%d] CPULoad prio=%S mode=yielding type=cont"); + buf.Format(KCPULoadEntryContinuous, iAttributes.iId, &prioBuf); + } + else if (iAttributes.iMode == ECpuLoadModeBlocking) + { + _LIT(KCPULoadEntryContinuous, "[%d] CPULoad prio=%S mode=blocking type=cont"); + buf.Format(KCPULoadEntryContinuous, iAttributes.iId, &prioBuf); + } + } + + else if (iAttributes.iType == ECpuLoadTypePeriodic) + { + if (iAttributes.iMode == ECpuLoadModeYielding) + { + _LIT(KCPULoadEntryPeriodic, "[%d] CPULoad prio=%S mode=yielding type=period peak=%dms idle=%dms random=%d%%"); + buf.Format(KCPULoadEntryPeriodic, iAttributes.iId, &prioBuf, iAttributes.iLength, iAttributes.iIdle, iAttributes.iRandomVariance); + } + else if (iAttributes.iMode == ECpuLoadModeBlocking) + { + _LIT(KCPULoadEntryPeriodic, "[%d] CPULoad prio=%S mode=blocking type=period peak=%dms idle=%dms random=%d%%"); + buf.Format(KCPULoadEntryPeriodic, iAttributes.iId, &prioBuf, iAttributes.iLength, iAttributes.iIdle, iAttributes.iRandomVariance); + } + } + + // if we are running a load in a specific cpu, add the "name" of the + // cpu to the description. (SMP environment) + if (iAttributes.iCpu >= 0 && iAttributes.iCpu != KCPUSelection_AllCPUs) + { + TBuf<15> cpu; + _LIT(KCPU, " CPU%d"); + cpu.Format(KCPU, iAttributes.iCpu); + buf.Append(cpu); + } + + return TPtrC(buf); + } + +// -------------------------------------------------------------------------------------------- + + +// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/engine/src/loadgen_httpreceiver.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/engine/src/loadgen_httpreceiver.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,353 @@ + +#include +#include +#include "loadgen_httpreceiver.h" + +// CONSTANTS +_LIT8( KHttpScheme, "http" ); +_LIT8( KSchemeAddon, "://" ); +// This client accepts all content types. +_LIT8(KAccept, "*/*"); + +CHTTPReceiver* CHTTPReceiver::NewL( MHTTPRecvObserver& aObserver ) + { + CHTTPReceiver* self = CHTTPReceiver::NewLC( aObserver ); + CleanupStack::Pop( self ); + return self; + } + +CHTTPReceiver* CHTTPReceiver::NewLC( MHTTPRecvObserver& aObserver ) + { + CHTTPReceiver* self = new (ELeave)CHTTPReceiver( aObserver ); + CleanupStack::PushL( self ); + self->ConstructL(); + return self; + } + +CHTTPReceiver::CHTTPReceiver( MHTTPRecvObserver& aObserver ) : + iObserver(aObserver), iRunning(EFalse), iConnectionSetupDone(EFalse) + { + } + +void CHTTPReceiver::ConstructL() + { +#ifdef _DEBUG + User::LeaveIfError( iFs.Connect() ); +#endif + } + +CHTTPReceiver::~CHTTPReceiver() + { + TRACE( "Entry: CHTTPReceiver::~CHTTPReceiver" ); + + CancelTransaction(); + + TRAP_IGNORE( iSession.DisconnectL() ); + iSession.Close(); + iConnection.Stop(); + iConnection.Close(); + iSocketServ.Close(); + + TRACE( "Entry: CHTTPReceiver::~CHTTPReceiver - delete iUrl" ); + delete iUrl; + +#ifdef _DEBUG + iFs.Close(); +#endif + TRACE( "Exit: CHTTPReceiver::~CHTTPReceiver" ); + } + +void CHTTPReceiver::CancelTransaction() + { + if ( !iRunning) + return; + + TRACE( "Entry: CHTTPReceiver::CancelTransaction" ); + + if ( iRunning) + { + iTransaction.Close(); + iRunning = EFalse; + } + + TRACE( "Exit: CHTTPReceiver::CancelTransaction" ); + } + +// ---------------------------------------------------------------------------- +// CHTTPReceiver::SendHTTPGetL() +// +// Start a new HTTP GET transaction. +// ---------------------------------------------------------------------------- +void CHTTPReceiver::SendHTTPGetL( const TDesC8& aURL ) + { + TRACE( "Entry: CHTTPReceiver::SendHTTPGetL" ); + + iResponseStatus = KErrGeneral; + +#ifdef _DEBUG + iResponseFile.Replace( iFs, _L("C:\\Data\\loadgen.htm"), EFileWrite ); +#endif + + SetupConnectionL(); + + // Parse string to URI (as defined in RFC2396) + TUriParser8 uri; + + CheckForHTTPSchemeL(uri, aURL); + + RStringF method = iSession.StringPool().StringF(HTTP::EGET, RHTTPSession::GetTable()); + CleanupClosePushL( method ); + + iTransaction = iSession.OpenTransactionL(uri, *this, method); + + // Set headers for request: accepted content type + RHTTPHeaders hdr = iTransaction.Request().GetHeaderCollection(); + SetHeaderL(hdr, HTTP::EAccept, KAccept); + + iTransaction.SubmitL(); + + iRunning = ETrue; + CleanupStack::PopAndDestroy(); + TRACE( "Exit: CHTTPReceiver::SendHTTPGetL" ); + return; + } + +void CHTTPReceiver::CheckForHTTPSchemeL(TUriParser8& aUri, const TDesC8& aURL) + { + if( iUrl ) + { + delete iUrl; + iUrl = NULL; + } + + iUrl = aURL.AllocL(); + aUri.Parse( *iUrl ); + + TPtrC8 scheme( aUri.Extract (EUriScheme) ); + + // unsupported or no scheme in url. + // Insert 'http://' to the beginning of it. + if ( scheme != KHttpScheme ) + { + HBufC8* tempBuf = HBufC8::NewL( KHttpScheme().Length() + KSchemeAddon().Length() + aURL.Length() ); + CleanupStack::PushL( tempBuf ); + tempBuf->Des().Append( KHttpScheme ); + tempBuf->Des().Append( KSchemeAddon ); + tempBuf->Des().Append( aURL ); + + if( iUrl ) + { + delete iUrl; + iUrl = NULL; + } + iUrl = tempBuf; + aUri.Parse( *iUrl ); + CleanupStack::PopAndDestroy( tempBuf ); + } + } + +// Used to set header value to HTTP request +void CHTTPReceiver::SetHeaderL (RHTTPHeaders aHeaders, TInt aHdrField, const TDesC8& aHdrValue) + { + RStringF valStr = iSession.StringPool().OpenFStringL (aHdrValue); + CleanupClosePushL (valStr); + THTTPHdrVal val(valStr); + aHeaders.SetFieldL (iSession.StringPool().StringF (aHdrField, RHTTPSession::GetTable ()), val); + CleanupStack::PopAndDestroy (); // valStr + } + +// Inherited from MHTTPTransactionCallback +// Called by framework to pass transaction events. +// ---------------------------------------------------------------------------- +void CHTTPReceiver::MHFRunL( RHTTPTransaction aTransaction, const THTTPEvent& aEvent ) + { + TRACE( "Entry: CHTTPReceiver::MHFRunL" ); + TRACE2( "Entry: CHTTPReceiver::MHFRunL <%d>", aEvent.iStatus ); + + // state check + if ( !iRunning ) + { + TRACE( "Exit1: CHTTPReceiver::MHFRunL: recv in wrong state" ); + return; + } + + switch ( aEvent.iStatus ) + { + case THTTPEvent::EGotResponseHeaders: + { + TRACE( "Entry: CHTTPReceiver::MHFRunL EGotResponseHeaders" ); + // Get HTTP status code from header (e.g. 200) + RHTTPResponse resp = aTransaction.Response(); + iResponseStatus = resp.StatusCode(); + } + break; + + case THTTPEvent::EGotResponseBodyData: + { + // Get the body data supplier + TRACE( "Entry: CHTTPReceiver::MHFRunL EGotResponseBodyData" ); + MHTTPDataSupplier* body = aTransaction.Response().Body (); + TPtrC8 dataChunk; + body->GetNextDataPart ( dataChunk ); +#ifdef _DEBUG + if ( dataChunk.Length() ) + { + iResponseFile.Write( dataChunk ); + } +#endif + body->ReleaseData (); + } + break; + + case THTTPEvent::EResponseComplete: + { + // Indicates that header & body of response is completely received. + // Notify Observer + TRACE( "Entry: CHTTPReceiver::MHFRunL EResponseComplete" ); + } + break; + + case THTTPEvent::ESucceeded: + { + // Transaction can be closed now. It's not needed anymore. + TRACE( "Entry: CHTTPReceiver::MHFRunL ESucceeded" ); + Finalize(); + } + break; + + case THTTPEvent::EFailed: + { + TRACE( "Entry: CHTTPReceiver::MHFRunL EFailed" ); + iResponseStatus = KErrGeneral; + Finalize(); + } + break; + + default: + TRACE( "Entry: CHTTPReceiver::MHFRunL EDefault" ); + break; + } + } + +// Called by framework when *leave* occurs in handling of transaction event. +// These errors must be handled, or otherwise HTTP-CORE 6 panic is thrown. +// ---------------------------------------------------------------------------- +TInt CHTTPReceiver::MHFRunError ( TInt aError, RHTTPTransaction /*aTransaction*/, const THTTPEvent& /*aEvent*/ ) + { + TRACE( "Entry: CHTTPReceiver::MHFRunError" ); + iResponseStatus = aError; + Finalize(); + + TRACE( "Exit: CHTTPReceiver::MHFRunError" ); + return KErrNone; + } + +void CHTTPReceiver::SetupConnectionL () + { + TRACE( "Entry: CHTTPReceiver::StartConnectionL" ); + + // check if conncetion is already open + if ( iRunning ) + { + return; + } + + if ( iConnectionSetupDone ) + { + return; + } + + iConnectionSetupDone = ETrue; + + // open HTTP session + iSession.OpenL(); + + // open socket server + TInt result = iSocketServ.Connect(); + if ( result == KErrNone) + { + // open connection + result = iConnection.Open(iSocketServ); + if ( result == KErrNone) + { + // set overrides + TCommDbConnPref pref; + pref.SetDialogPreference (ECommDbDialogPrefPrompt); + //pref.SetDirection (ECommDbConnectionDirectionOutgoing); + //pref.SetIapId (accessPoint); + + // start with overrides + result = iConnection.Start(pref); + + if ( result == KErrNone) + { + // get connection info from iSession + RHTTPConnectionInfo connInfo = iSession.ConnectionInfo (); + RStringPool pool = iSession.StringPool (); + + // set socket server + connInfo.SetPropertyL (pool.StringF (HTTP::EHttpSocketServ, + RHTTPSession::GetTable () ), + THTTPHdrVal( iSocketServ.Handle () ) ); + + // attach to connection + TInt connectionPtr= REINTERPRET_CAST( TInt, + &iConnection ); + + connInfo.SetPropertyL (pool.StringF ( + HTTP::EHttpSocketConnection, + RHTTPSession::GetTable () ), + THTTPHdrVal (connectionPtr) ); + +#if defined(__WINSCW__) || defined(__WINS__) // if Emulator + _LIT8(KProxyAddr, "192.168.0.252:4040"); + TBufC8<30> proxyAddr(KProxyAddr); + + RStringF prxAddr = iSession.StringPool().OpenFStringL (proxyAddr); + CleanupClosePushL (prxAddr); + THTTPHdrVal prxUsage(iSession.StringPool().StringF (HTTP::EUseProxy, + RHTTPSession::GetTable ())); + iSession.ConnectionInfo().SetPropertyL (iSession.StringPool().StringF (HTTP::EProxyUsage, + RHTTPSession::GetTable ()), prxUsage); + iSession.ConnectionInfo().SetPropertyL (iSession.StringPool().StringF (HTTP::EProxyAddress, + RHTTPSession::GetTable ()), prxAddr); + CleanupStack::PopAndDestroy (); // prxAddr +#endif + + } + else + { + TRACE2( "CHTTPReceiver:: connection start: <%d>", result ); + } + } + else + { + TRACE2( "CHTTPReceiver:: connection open: <%d>", result ); + } + } + else + { + TRACE2( "CHTTPReceiver:: connection to socket server: <%d>", result ); + } + + User::LeaveIfError( result ); + + TRACE( "Exit: CHTTPReceiver::StartConnectionL" ); + } + +// ---------------------------------------------------------------------------- +// CHTTPReceiver::Finalize +// +// ---------------------------------------------------------------------------- +// +void CHTTPReceiver::Finalize() + { + TRACE( "Exit: CHTTPReceiver::Finalize" ); +#ifdef _DEBUG + iResponseFile.Close(); +#endif + iTransaction.Close(); + iRunning = EFalse; + iObserver.HTTPFileReceived( iResponseStatus ); + TRACE( "Exit: CHTTPReceiver::Finalize" ); + } diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/engine/src/loadgen_keypress.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/engine/src/loadgen_keypress.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,257 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +// INCLUDE FILES +#include "loadgen_keypress.h" +#include "loadgen_utils.h" +#include "loadgen.hrh" +#include + +#include + +_LIT(KThreadName, "KeyPress %d"); + +const TInt KDefaultStart = 50; +const TInt KDefaultPeriod = 5000000; + +// ===================================== MEMBER FUNCTIONS ===================================== + +CKeyPress* CKeyPress::NewL(TKeyPressAttributes& aAttributes, TInt aReferenceNumber) + { + CKeyPress* self = new(ELeave) CKeyPress(aAttributes, aReferenceNumber); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// -------------------------------------------------------------------------------------------- + +CKeyPress::~CKeyPress() + { + Close(); + } + +// -------------------------------------------------------------------------------------------- + +CKeyPress::CKeyPress(TKeyPressAttributes& aAttributes, TInt aReferenceNumber) : iAttributes(aAttributes) + { + iAttributes.iId = aReferenceNumber; + } + +// -------------------------------------------------------------------------------------------- + +void CKeyPress::ConstructL() + { + CLoadBase::ConstructL(); + + iType = ELoadGenCmdNewLoadKeyPress; + + TBuf<64> threadName; + threadName.Format(KThreadName, iAttributes.iId); + + // create a thread + User::LeaveIfError(iThread.Create(threadName, ThreadFunction, KDefaultStackSize*2, KMinHeapSize, 1024*KMinHeapSize, (TAny*) &iAttributes )); + + // set priority of the thread + SetPriority(); + } + +// -------------------------------------------------------------------------------------------- + +TInt CKeyPress::ThreadFunction(TAny* aThreadArg) + { + CTrapCleanup* pC = CTrapCleanup::New(); + CActiveScheduler* pS = new CActiveScheduler; + CActiveScheduler::Install(pS); + + // start generating load, pass pointer to arguments + GenerateLoad(*((TKeyPressAttributes*) aThreadArg)); + + delete pS; + delete pC; + + return KErrNone; + } + +// -------------------------------------------------------------------------------------------- + +void CKeyPress::GenerateLoad(TKeyPressAttributes& aAttributes) + { + CKeyPressManager* keyPressManager = NULL; + TRAPD(err, keyPressManager = CKeyPressManager::NewL(aAttributes)); + if (err == KErrNone) CActiveScheduler::Start(); + delete keyPressManager; + } + +// -------------------------------------------------------------------------------------------- + +void CKeyPress::Resume() + { + CLoadBase::Resume(); + + iThread.Resume(); + } + +// -------------------------------------------------------------------------------------------- + +void CKeyPress::Suspend() + { + CLoadBase::Suspend(); + + iThread.Suspend(); + } + +// -------------------------------------------------------------------------------------------- + +void CKeyPress::SetPriority() + { + CLoadBase::SetPriority(); + + iThread.SetPriority(CLoadGenUtils::SettingItemToThreadPriority(iAttributes.iPriority)); + } + +// -------------------------------------------------------------------------------------------- + +void CKeyPress::Close() + { + CLoadBase::Close(); + + if (iThread.ExitReason() == 0) // check if the thread is still alive + { + // signal the thread that it needs to close + iThread.RequestComplete(iAttributes.iDeathStatus, KErrCancel); + + // wait the thread to die + TRequestStatus waiter; + iThread.Logon(waiter); + User::WaitForRequest(waiter); + iThread.Close(); + } + } + +// -------------------------------------------------------------------------------------------- + +TPtrC CKeyPress::Description() + { + TBuf<256> buf; + TBuf<16> prioBuf; + CLoadGenUtils::SettingItemToThreadDescription(iAttributes.iPriority, prioBuf); + + _LIT(KKeyPressEntry, "[%d] KeyPress prio=%S heartbeat=%dms random=%d%%"); + buf.Format(KKeyPressEntry, iAttributes.iId, &prioBuf, iAttributes.iHeartBeat, iAttributes.iRandomVariance); + + return TPtrC(buf); + } + +// -------------------------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------- + +CKeyPressManager* CKeyPressManager::NewL(TKeyPressAttributes& aAttributes) + { + CKeyPressManager* self = new(ELeave) CKeyPressManager(aAttributes); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +// -------------------------------------------------------------------------------------------- + +CKeyPressManager::CKeyPressManager(TKeyPressAttributes& aAttributes) : + CActive(EPriorityStandard), iAttributes(aAttributes) + { + } + +// -------------------------------------------------------------------------------------------- + +CKeyPressManager::~CKeyPressManager() + { + Cancel(); + + iWsSession.Close(); + } + +// -------------------------------------------------------------------------------------------- + +void CKeyPressManager::ConstructL() + { + CActiveScheduler::Add(this); + + // set the status as pending + iStatus = KRequestPending; + SetActive(); + + // set the death status pointer point to the request status of this ao + iAttributes.iDeathStatus = &iStatus; + + // init + User::LeaveIfError( iWsSession.Connect() ); + + // start timer + iPeriodicTimer = CPeriodic::NewL(CActive::EPriorityStandard); + iPeriodicTimer->Start(KDefaultStart, KDefaultPeriod, TCallBack(PeriodicTimerCallBack, this)); + } + +// -------------------------------------------------------------------------------------------- + +void CKeyPressManager::RunL() + { + // request status has completed by the main thread meaning that we need to stop now + CActiveScheduler::Stop(); + } + +// -------------------------------------------------------------------------------------------- + +void CKeyPressManager::DoCancel() + { + } + +// -------------------------------------------------------------------------------------------- + +TInt CKeyPressManager::PeriodicTimerCallBack(TAny* aAny) + { + CKeyPressManager* self = static_cast( aAny ); + + self->iPeriodicTimer->Cancel(); + self->SimulateKeyEvent(); + + return KErrNone; + } + +// -------------------------------------------------------------------------------------------- + +void CKeyPressManager::SimulateKeyEvent() + { + // generate a random key event from a to z + TKeyEvent keyEvent; + keyEvent.iCode = CLoadGenUtils::RandomNumber('a','z'); + keyEvent.iScanCode = keyEvent.iCode - 32; + keyEvent.iModifiers = 0; + keyEvent.iRepeats = 0; + + iWsSession.SimulateKeyEvent(keyEvent); + iWsSession.Flush(); + + // call timer + iPeriodicTimer->Start(CLoadGenUtils::MilliSecondsToMicroSeconds(iAttributes.iHeartBeat, iAttributes.iRandomVariance), KDefaultPeriod, TCallBack(PeriodicTimerCallBack, this)); + } + +// -------------------------------------------------------------------------------------------- + +// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/engine/src/loadgen_loadbase.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/engine/src/loadgen_loadbase.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +// INCLUDE FILES +#include "loadgen_loadbase.h" +#include "loadgen.hrh" + +// ===================================== MEMBER FUNCTIONS ===================================== + +CLoadBase::CLoadBase() + { + } + +// -------------------------------------------------------------------------------------------- + +void CLoadBase::ConstructL() + { + iState = ELoadStateInvalid; + } + +// -------------------------------------------------------------------------------------------- + +void CLoadBase::Resume() + { + iState = ELoadStateRunning; + } + +// -------------------------------------------------------------------------------------------- + +void CLoadBase::Suspend() + { + iState = ELoadStateSuspended; + } + +// -------------------------------------------------------------------------------------------- + +void CLoadBase::SetPriority() + { + } + +// -------------------------------------------------------------------------------------------- + +void CLoadBase::Close() + { + iState = ELoadStateClosed; + } + +// -------------------------------------------------------------------------------------------- + +TPtrC CLoadBase::Description() + { + return TPtrC(KNullDesC); + } + +// -------------------------------------------------------------------------------------------- + +// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/engine/src/loadgen_memoryeat.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/engine/src/loadgen_memoryeat.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,603 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +// INCLUDE FILES +#include "loadgen_memoryeat.h" +#include "loadgen_utils.h" +#include "loadgen.hrh" +#include "loadgen_traces.h" +#include + +#include + +_LIT(KThreadName, "MemEat %d"); +_LIT(KChunkName, "LoadGen %d"); +_LIT(KFilePath, "%c:\\system\\temp\\LoadGen-%d_%d.$$$"); + +// currently can only handle 2GB +const TInt64 KMaxEatSize = 2147483647; + +const TInt KDefaultStart = 50; +const TInt KDefaultPeriod = 5000000; + +// ===================================== MEMBER FUNCTIONS ===================================== + +CMemoryEat* CMemoryEat::NewL(TMemoryEatAttributes& aAttributes, TInt aReferenceNumber) + { + CMemoryEat* self = new(ELeave) CMemoryEat(aAttributes, aReferenceNumber); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// -------------------------------------------------------------------------------------------- + +CMemoryEat::~CMemoryEat() + { + Close(); + } + +// -------------------------------------------------------------------------------------------- + +CMemoryEat::CMemoryEat(TMemoryEatAttributes& aAttributes, TInt aReferenceNumber) : iAttributes(aAttributes) + { + iAttributes.iId = aReferenceNumber; + } + +// -------------------------------------------------------------------------------------------- + +void CMemoryEat::ConstructL() + { + CLoadBase::ConstructL(); + + iType = ELoadGenCmdNewLoadEatMemory; + + TBuf<64> threadName; + threadName.Format(KThreadName, iAttributes.iId); + + // create a thread + User::LeaveIfError(iThread.Create(threadName, ThreadFunction, KDefaultStackSize*2, KMinHeapSize, 32*1024*KMinHeapSize, (TAny*) &iAttributes )); + + // set priority of the thread + SetPriority(); + } + +// -------------------------------------------------------------------------------------------- + +TInt CMemoryEat::ThreadFunction(TAny* aThreadArg) + { + CTrapCleanup* pC = CTrapCleanup::New(); + CActiveScheduler* pS = new CActiveScheduler; + CActiveScheduler::Install(pS); + + // start memory eat, pass pointer to arguments + GenerateLoad(*((TMemoryEatAttributes*) aThreadArg)); + + delete pS; + delete pC; + + return KErrNone; + } + +// -------------------------------------------------------------------------------------------- + +void CMemoryEat::GenerateLoad(TMemoryEatAttributes& aAttributes) + { + CMemoryEatManager* memoryEatManager = NULL; + TRAPD(err, memoryEatManager = CMemoryEatManager::NewL(aAttributes)); + if (err == KErrNone) CActiveScheduler::Start(); + delete memoryEatManager; + } + +// -------------------------------------------------------------------------------------------- + +void CMemoryEat::Resume() + { + CLoadBase::Resume(); + + iThread.Resume(); + } + +// -------------------------------------------------------------------------------------------- + +void CMemoryEat::Suspend() + { + CLoadBase::Suspend(); + + iThread.Suspend(); + } + +// -------------------------------------------------------------------------------------------- + +void CMemoryEat::SetPriority() + { + CLoadBase::SetPriority(); + + iThread.SetPriority(CLoadGenUtils::SettingItemToThreadPriority(iAttributes.iPriority)); + } + +// -------------------------------------------------------------------------------------------- + +void CMemoryEat::Close() + { + CLoadBase::Close(); + + if (iThread.ExitReason() == 0) // check if the thread is still alive + { + // signal the thread that it needs to close + iThread.RequestComplete(iAttributes.iDeathStatus, KErrCancel); + + // wait the thread to die + TRequestStatus waiter; + iThread.Logon(waiter); + User::WaitForRequest(waiter); + iThread.Close(); + } + } + +// -------------------------------------------------------------------------------------------- + +TPtrC CMemoryEat::Description() + { + TBuf<256> buf; + TBuf<16> prioBuf; + CLoadGenUtils::SettingItemToThreadDescription(iAttributes.iPriority, prioBuf); + TBuf<16> srcBuf; + CLoadGenUtils::SettingItemToSourceDescription(iAttributes.iSource, srcBuf); + + if (iAttributes.iType == EMemoryEatTypeMemoryToEat) + { + _LIT(KMemoryEatEntryMemoryToEat, "[%d] MemEat src=%S prio=%S type=MemToEat amount=%LDB buf=%dB idle=%dms"); + + buf.Format(KMemoryEatEntryMemoryToEat, iAttributes.iId, &srcBuf, &prioBuf, iAttributes.iAmount, iAttributes.iBuffer, iAttributes.iIdle); + } + else if (iAttributes.iType == EMemoryEatTypeMemoryToBeLeft) + { + _LIT(KMemoryEatEntryMemoryToBeLeft, "[%d] MemEat src=%S prio=%S type=MemToBeLeft amount=%LDB buf=%dB idle=%dms"); + + buf.Format(KMemoryEatEntryMemoryToBeLeft, iAttributes.iId, &srcBuf, &prioBuf, iAttributes.iAmount, iAttributes.iBuffer, iAttributes.iIdle); + } + + else if (iAttributes.iType == EMemoryEatTypeWavy) + { + _LIT(KMemoryEatEntryRandom, "[%d] MemEat src=%S prio=%S type=Random min=%LDB max=%LDB buf=%dB idle=%dms"); + + buf.Format(KMemoryEatEntryRandom, iAttributes.iId, &srcBuf, &prioBuf, iAttributes.iRandomMin, iAttributes.iRandomMax, iAttributes.iBuffer, iAttributes.iIdle); + } + + return TPtrC(buf); + } + +// -------------------------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------- + +CMemoryEatManager* CMemoryEatManager::NewL(TMemoryEatAttributes& aAttributes) + { + CMemoryEatManager* self = new(ELeave) CMemoryEatManager(aAttributes); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +// -------------------------------------------------------------------------------------------- + +CMemoryEatManager::CMemoryEatManager(TMemoryEatAttributes& aAttributes) : + CActive(EPriorityStandard), iAttributes(aAttributes) + { + } + +// -------------------------------------------------------------------------------------------- + +CMemoryEatManager::~CMemoryEatManager() + { + Cancel(); + DestroyMemoryEat(); + } + +// -------------------------------------------------------------------------------------------- + +void CMemoryEatManager::ConstructL() + { + CActiveScheduler::Add(this); + + // set the status as pending + iStatus = KRequestPending; + SetActive(); + + // set the death status pointer point to the request status of this ao + iAttributes.iDeathStatus = &iStatus; + + // init + InitMemoryEatL(); + + // start timer + iPeriodicTimer = CPeriodic::NewL(CActive::EPriorityStandard); + iPeriodicTimer->Start(KDefaultStart, KDefaultPeriod, TCallBack(PeriodicTimerCallBack, this)); + } + +// -------------------------------------------------------------------------------------------- + +void CMemoryEatManager::RunL() + { + // request status has completed by the main thread meaning that we need to stop now + CActiveScheduler::Stop(); + } + +// -------------------------------------------------------------------------------------------- + +void CMemoryEatManager::DoCancel() + { + } + +// -------------------------------------------------------------------------------------------- + +TInt CMemoryEatManager::PeriodicTimerCallBack(TAny* aAny) + { + TInt result = KErrNone; + CMemoryEatManager* self = static_cast( aAny ); + + self->iPeriodicTimer->Cancel(); + TRAP( result, self->EatMemoryL() ); + + return result; + } + +// -------------------------------------------------------------------------------------------- + +void CMemoryEatManager::InitMemoryEatL() + { + // create a chunk for RAM + if (iAttributes.iSource == EMemoryEatSourceTypeRAM) + { + TBuf<64> chunkName; + chunkName.Format(KChunkName, iAttributes.iId); + + // set max size of the chunk to be size of the RAM memory + TMemoryInfoV1Buf ramMemory; + UserHal::MemoryInfo(ramMemory); + + User::LeaveIfError( iEatChunk.CreateGlobal(chunkName, 0, ramMemory().iMaxFreeRamInBytes-1, EOwnerThread) ); + } + + // create a temporary file to disk + else + { + // connect to RFs + User::LeaveIfError( iFs.Connect() ); + + iFilesCounter = 0; + + TFileName eatFileName; + eatFileName.Format( KFilePath, 'B'+iAttributes.iSource, iAttributes.iId, 1 ); + + iFs.MkDirAll( eatFileName ); + User::LeaveIfError( iEatFile.Replace( iFs, eatFileName, EFileWrite ) ); + iFilesCounter++; + } + + iWavyEatMoreMemory = ETrue; + } + +// -------------------------------------------------------------------------------------------- + +void CMemoryEatManager::DestroyMemoryEat() + { + if (iAttributes.iSource == EMemoryEatSourceTypeRAM) + { + iEatChunk.Adjust(0); + iEatChunk.Close(); + } + else + { + // close current file + + iEatFile.Flush(); + iEatFile.Close(); + + // delete created files + for ( TInt k = 1; k <= iFilesCounter; k++ ) + { + TFileName eatFileName; + eatFileName.Format( KFilePath, 'B'+iAttributes.iSource, iAttributes.iId, k ); + iFs.Delete( eatFileName ); + } + iFs.Close(); + } + } + +// -------------------------------------------------------------------------------------------- + +void CMemoryEatManager::EatMemoryL() + { + // get current sizes + TInt64 eatSizeNow(0); + TInt sizeNow(0); + TInt64 freeSystemMemory(0); + + if (iAttributes.iSource == EMemoryEatSourceTypeRAM) + { + eatSizeNow = iEatChunk.Size(); // get current chunk size + } + else + { + User::LeaveIfError( iEatFile.Size( sizeNow ) ); + if ( iFilesCounter > 1) + { + eatSizeNow += sizeNow + ( ( iFilesCounter - 1 ) * KMaxEatSize ); + } + else + { + eatSizeNow = sizeNow ; + } + } + LOGSTRING2("Loadgen:EatMemoryL eatSizeNow = %d", eatSizeNow ); + + freeSystemMemory = ReadFreeMemory(); + + // eat until specific amount of memory at most amount of buffer at a time + if (iAttributes.iType == EMemoryEatTypeMemoryToEat) + { + // grow partial buffer to match exact amount + if ( ( iAttributes.iAmount - eatSizeNow >= 0 && + iAttributes.iAmount - eatSizeNow < iAttributes.iBuffer ) ) + { + DoEatMemoryL( eatSizeNow + ( iAttributes.iAmount - eatSizeNow ) ); + } + + // grow full buffer + else if ( eatSizeNow < iAttributes.iAmount ) + { + DoEatMemoryL( eatSizeNow + iAttributes.iBuffer ); + } + // shrink partial buffer to match exact amount + else if (eatSizeNow - iAttributes.iAmount >= 0 && eatSizeNow - iAttributes.iAmount < iAttributes.iBuffer) + { + DoEatMemoryL(eatSizeNow - (eatSizeNow - iAttributes.iAmount)); + } + + // shrink full buffer + else if (eatSizeNow > iAttributes.iAmount) + { + DoEatMemoryL(eatSizeNow - iAttributes.iBuffer); + } + } + + + // eat until specific amount of free memory has been reached at most amount of buffer at a time + else if (iAttributes.iType == EMemoryEatTypeMemoryToBeLeft) + { + // grow partial buffer to match exact amount + if (freeSystemMemory - iAttributes.iAmount >= 0 && freeSystemMemory - iAttributes.iAmount < iAttributes.iBuffer) + { + DoEatMemoryL(eatSizeNow + (freeSystemMemory - iAttributes.iAmount)); + } + + // grow full buffer + else if (freeSystemMemory > iAttributes.iAmount) + { + DoEatMemoryL(eatSizeNow + iAttributes.iBuffer); + } + + // shrink partial buffer to match exact amount + if (iAttributes.iAmount - freeSystemMemory >= 0 && iAttributes.iAmount - freeSystemMemory < iAttributes.iBuffer) + { + DoEatMemoryL(eatSizeNow - (iAttributes.iAmount - freeSystemMemory)); + } + + // shrink full buffer + else if (freeSystemMemory < iAttributes.iAmount) + { + DoEatMemoryL(eatSizeNow - iAttributes.iBuffer); + } + } + + // wavy memory eat + else if (iAttributes.iType == EMemoryEatTypeWavy) + { + // grow to max value if not under it + if (freeSystemMemory > iAttributes.iRandomMax) + { + DoEatMemoryL(eatSizeNow + (freeSystemMemory - iAttributes.iRandomMax) + iAttributes.iBuffer); + iWavyEatMoreMemory = ETrue; // change direction + } + + // shrink to min value if not below it + else if (freeSystemMemory < iAttributes.iRandomMin) + { + DoEatMemoryL(eatSizeNow - (iAttributes.iRandomMin - freeSystemMemory) - iAttributes.iBuffer); + iWavyEatMoreMemory = EFalse; // change direction + } + + // grow or shrink + else + { + if (iWavyEatMoreMemory) + { + // grow partial buffer to match exact amount + if (freeSystemMemory - iAttributes.iRandomMin >= 0 && freeSystemMemory - iAttributes.iRandomMin < iAttributes.iBuffer) + { + DoEatMemoryL(eatSizeNow + (freeSystemMemory - iAttributes.iRandomMin)); + iWavyEatMoreMemory = EFalse; // change direction since limit reached + } + + // grow full buffer + else + { + DoEatMemoryL(eatSizeNow + iAttributes.iBuffer); + } + } + + else // shrink + { + // shrink partial buffer to match exact amount + if (iAttributes.iRandomMax - freeSystemMemory >= 0 && iAttributes.iRandomMax - freeSystemMemory < iAttributes.iBuffer) + { + DoEatMemoryL(eatSizeNow - (iAttributes.iRandomMax - freeSystemMemory)); + iWavyEatMoreMemory = ETrue; // change direction since limit reached + } + + // shrink full buffer + else + { + DoEatMemoryL(eatSizeNow - iAttributes.iBuffer); + } + } + } + } + + + // call timer + iPeriodicTimer->Start(CLoadGenUtils::MilliSecondsToMicroSeconds(iAttributes.iIdle, iAttributes.iRandomVariance), KDefaultPeriod, TCallBack(PeriodicTimerCallBack, this)); + } + +// -------------------------------------------------------------------------------------------- + +void CMemoryEatManager::DoEatMemoryL( TInt64 aNewSize ) + { + // check that new size is in valid range + if (aNewSize < 0) + { + aNewSize = 0; + } + LOGSTRING2("Loadgen::DoEatMemoryL aNewSize = %ld", aNewSize ); + // set new size + if (iAttributes.iSource == EMemoryEatSourceTypeRAM) + { + TInt err = iEatChunk.Adjust( aNewSize ); + } + else + { + HandleEatMemoryL( aNewSize ); + } + } + +// -------------------------------------------------------------------------------------------- + +void CMemoryEatManager::HandleEatMemoryL( TInt64 aNewSize ) + { + // current size = open file size + full files sizes + TInt currentFileSize = 0; + User::LeaveIfError( iEatFile.Size( currentFileSize ) ); + TInt64 currentSize = currentFileSize + ( ( iFilesCounter - 1 ) * KMaxEatSize ); + + if ( aNewSize > currentSize ) // increasing + { + AllocMemoryL( aNewSize ); + } + else if ( aNewSize < currentSize )//decreasing + { + FreeMemoryL( aNewSize ); + } + } + +// -------------------------------------------------------------------------------------------- +void CMemoryEatManager::AllocMemoryL( TInt64 aNewSize ) + { + LOGSTRING("Loadgen: CMemoryEatManager::AllocMemoryL =>"); + // size of the file that remains open + TInt64 sizeLeft = aNewSize % KMaxEatSize; + // amount of the files that is needed + TInt64 filesNeeded = aNewSize / KMaxEatSize; + if ( sizeLeft > 0 ) + { + filesNeeded++; + } + + if ( filesNeeded > iFilesCounter ) + { + // update current file size to 2 GB + User::LeaveIfError( iEatFile.SetSize( KMaxEatSize ) ); + // close current file + iEatFile.Flush(); + iEatFile.Close(); + + // open new file + TFileName eatFileName; + eatFileName.Format( KFilePath, 'B'+iAttributes.iSource, iAttributes.iId, ++iFilesCounter ); + + iFs.MkDirAll( eatFileName ); + User::LeaveIfError( iEatFile.Replace( iFs, eatFileName, EFileWrite ) ); + + } + User::LeaveIfError( iEatFile.SetSize( sizeLeft ) ); + LOGSTRING("Loadgen: CMemoryEatManager::AllocMemoryL <="); + } + +// -------------------------------------------------------------------------------------------- +void CMemoryEatManager::FreeMemoryL( TInt64 aNewSize ) + { + LOGSTRING("Loadgen: CMemoryEatManager::FreeMemoryL =>"); + // size of the file that remains open + TInt sizeLeft = aNewSize % KMaxEatSize; + + LOGSTRING2("Loadgen: sizeLeft = %d ", sizeLeft ); + // amount of the files that is needed + TInt filesNeeded = aNewSize / KMaxEatSize; + + if ( filesNeeded == 0 ) + { + filesNeeded = 1; + } + + if ( iFilesCounter > 1 && filesNeeded < iFilesCounter ) + { + TFileName eatFileName; + + // close current open file + iEatFile.Flush(); + iEatFile.Close(); + // remove file + eatFileName.Format( KFilePath, 'B'+iAttributes.iSource, iAttributes.iId, iFilesCounter-- ); + iFs.Delete( eatFileName ); + + // remove files not needed + while ( iFilesCounter > filesNeeded ) + { + eatFileName.Format( KFilePath, 'B'+iAttributes.iSource, iAttributes.iId, iFilesCounter-- ); + iFs.Delete( eatFileName ); + } + + // open new file + eatFileName.Format( KFilePath, 'B'+iAttributes.iSource, iAttributes.iId, iFilesCounter ); + User::LeaveIfError( iEatFile.Open( iFs, eatFileName, EFileWrite ) ); + } + User::LeaveIfError( iEatFile.SetSize( sizeLeft ) ); + LOGSTRING("Loadgen: CMemoryEatManager::FreeMemoryL <="); + } + +// -------------------------------------------------------------------------------------------- +TInt64 CMemoryEatManager::ReadFreeMemory() + { + if ( iAttributes.iSource == EMemoryEatSourceTypeRAM ) + { + TMemoryInfoV1Buf ramMemory; + UserHal::MemoryInfo( ramMemory ); // get available RAM + return (TInt64)ramMemory().iFreeRamInBytes; + } + else + { + TVolumeInfo volumeInfo; + iFs.Volume( volumeInfo, iAttributes.iSource + 1 ); // get available disk + return volumeInfo.iFree; + } + } +// -------------------------------------------------------------------------------------------- + +// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/engine/src/loadgen_messages.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/engine/src/loadgen_messages.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,990 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +// INCLUDE FILES +#include "loadgen_messages.h" +#include "loadgen_utils.h" +#include "loadgen.hrh" +#include +#include + +_LIT(KThreadName, "Messages %d"); +_LIT(KMessageSMS, "A test message from LoadGen S60 RnD tool. "); +_LIT( KMessageSMSType, "SMS" ); +_LIT( KMessageMMSType, "MMS" ); + +const TInt KTestMessageLength = 42; +const TInt KDefaultStart = 50; +const TInt KDefaultPeriod = 5000000; + +// ===================================== MEMBER FUNCTIONS ===================================== + +CMessages* CMessages::NewL( TMessageAttributes& aAttributes, TInt aReferenceNumber ) + { + CMessages* self = new(ELeave) CMessages( aAttributes, aReferenceNumber ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// -------------------------------------------------------------------------------------------- + +CMessages::~CMessages() + { + Close(); + } + +// -------------------------------------------------------------------------------------------- + +CMessages::CMessages( TMessageAttributes& aAttributes, + TInt aReferenceNumber ) + : iAttributes( aAttributes ) + { + iAttributes.iId = aReferenceNumber; + } + +// -------------------------------------------------------------------------------------------- + +void CMessages::ConstructL() + { + CLoadBase::ConstructL(); + + iType = ELoadGenCmdNewLoadMessages; + + TBuf<64> threadName; + threadName.Format( KThreadName, iAttributes.iId ); + + // create a thread + User::LeaveIfError( iThread.Create( threadName, + ThreadFunction, + KDefaultStackSize * 2, + KMinHeapSize, + 1024 * KMinHeapSize, + (TAny*) &iAttributes ) ); + + // set priority of the thread + SetPriority(); + } + +// -------------------------------------------------------------------------------------------- + +TInt CMessages::ThreadFunction(TAny* aThreadArg) + { + CTrapCleanup* pC = CTrapCleanup::New(); + CActiveScheduler* pS = new CActiveScheduler; + CActiveScheduler::Install( pS ); + + // start generating load, pass pointer to arguments + GenerateLoad( *( ( TMessageAttributes* ) aThreadArg ) ); + + delete pS; + delete pC; + + return KErrNone; + } + +// -------------------------------------------------------------------------------------------- + +void CMessages::GenerateLoad( TMessageAttributes& aAttributes ) + { + CMessageManager* messagesManager = NULL; + TRAPD( err, messagesManager = CMessageManager::NewL( aAttributes ) ); + + if ( err == KErrNone ) + { + CActiveScheduler::Start(); + } + delete messagesManager; + } + +// -------------------------------------------------------------------------------------------- + +void CMessages::Resume() + { + CLoadBase::Resume(); + + iThread.Resume(); + } + +// -------------------------------------------------------------------------------------------- + +void CMessages::Suspend() + { + CLoadBase::Suspend(); + + iThread.Suspend(); + } + +// -------------------------------------------------------------------------------------------- + +void CMessages::SetPriority() + { + CLoadBase::SetPriority(); + + iThread.SetPriority( CLoadGenUtils::SettingItemToThreadPriority( iAttributes.iPriority ) ); + } + +// -------------------------------------------------------------------------------------------- + +void CMessages::Close() + { + CLoadBase::Close(); + + if ( iThread.ExitReason() == 0 ) // check if the thread is still alive + { + // signal the thread that it needs to close + iThread.RequestComplete( iAttributes.iDeathStatus, KErrCancel ); + + // wait the thread to die + TRequestStatus waiter; + iThread.Logon( waiter ); + User::WaitForRequest( waiter ); + iThread.Close(); + } + } + +// -------------------------------------------------------------------------------------------- + +TPtrC CMessages::Description() + { + TBuf<256> buf; + TBuf<16> prioBuf; + TBuf<3> typeBuf; + CLoadGenUtils::SettingItemToThreadDescription( iAttributes.iPriority, prioBuf ); + if ( iAttributes.iMessageType == EMessageTypeSMS ) + { + typeBuf.Copy( KMessageSMSType ); + } + else + { + typeBuf.Copy( KMessageMMSType ); + } + _LIT(KMessagesEntry, "[%d] Type=%S prio=%S dest=%S idle=%dms random=%d%%"); + buf.Format( KMessagesEntry, iAttributes.iId, &typeBuf, &prioBuf, &iAttributes.iDestination, + iAttributes.iIdle, iAttributes.iRandomVariance ); + + return TPtrC( buf ); + } +// -------------------------------------------------------------------------------------------- + +CMessageManager* CMessageManager::NewL( TMessageAttributes& aAttributes ) + { + CMessageManager* self = new(ELeave) CMessageManager( aAttributes ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// -------------------------------------------------------------------------------------------- +CMessageManager::CMessageManager( TMessageAttributes& aAttributes ) : + CActive( EPriorityStandard ), iAttributes( aAttributes ), iState( EStateIdle ) + { + iMessageCounter = 0; + } + +// -------------------------------------------------------------------------------------------- + +CMessageManager::~CMessageManager() + { + Cancel(); + delete iMessage; + if ( iPeriodicTimer ) + { + iPeriodicTimer->Cancel(); + delete iPeriodicTimer; + } + if ( iAttributes.iMessageType == EMessageTypeSMS && iSmsHandler ) + { + delete iSmsHandler; + } + else if ( iMmsHandler ) + { + delete iMmsHandler; + } + } + +// -------------------------------------------------------------------------------------------- + +void CMessageManager::ConstructL() + { + CActiveScheduler::Add( this ); + + // set the status as pending + iStatus = KRequestPending; + SetActive(); + + // set the death status pointer point to the request status of this ao + iAttributes.iDeathStatus = &iStatus; + if ( iAttributes.iAmount > 0 ) + { + iState = EStateSend; + } + iMessage = HBufC::NewL( iAttributes.iLength ); + CreateMessage(); + + // init SMS sender ao + if ( iAttributes.iMessageType == EMessageTypeSMS ) + { + iSmsHandler = CSmsHandler::NewL( *this ); + } + else + { + iMmsHandler = CMmsHandler::NewL( *this ); + } + // start timer + iPeriodicTimer = CPeriodic::NewL( CActive::EPriorityStandard ); + iPeriodicTimer->Start( KDefaultStart, KDefaultPeriod, + TCallBack( PeriodicTimerCallBack, this ) ); + } + +// -------------------------------------------------------------------------------------------- + +void CMessageManager::RunL() + { + // request status has completed by the main thread meaning that we need to stop now + CActiveScheduler::Stop(); + } + +// -------------------------------------------------------------------------------------------- + +void CMessageManager::DoCancel() + { + } + +// -------------------------------------------------------------------------------------------- + +TInt CMessageManager::PeriodicTimerCallBack(TAny* aAny) + { + CMessageManager* self = static_cast( aAny ); + + self->iPeriodicTimer->Cancel(); + self->HandleMessageSending(); + + return KErrNone; + } + +// -------------------------------------------------------------------------------------------- + +void CMessageManager::CreateMessage() + { + // Message body + TBuf mToYou( KMessageSMS ); + TPtr ptr = iMessage->Des(); + + // Take as many characters as user requested to create the message + for ( TInt j = 0; j < iAttributes.iLength; j++ ) + { + for ( TInt k = 0; k < KTestMessageLength; k++ ) + { + ptr.Append( mToYou[k] ); + j++; + if ( j == iAttributes.iLength ) + { + break; + } + } + } + } + + +// -------------------------------------------------------------------------------------------- + +void CMessageManager::HandleMessageSending() + { + if ( iState == EStateSend && iAttributes.iDestination.Length() <= KTelephoneNumberMaxLength ) + { + TBool err( KErrNone ); + + // make a new call + iState = EStateSending; + + iMessageCounter++; + if ( iAttributes.iMessageType == EMessageTypeSMS ) + { + TRAP( err, iSmsHandler->SendL( iAttributes.iDestination, *iMessage ) ); + if ( !err ) + { + iState = EStateIdle; + iPeriodicTimer->Start( CLoadGenUtils::MilliSecondsToMicroSeconds( iAttributes.iIdle, + iAttributes.iRandomVariance ), KDefaultPeriod, + TCallBack( PeriodicTimerCallBack, this ) ); + + } + } + else + { + TRAP( err, iMmsHandler->SendL( iAttributes.iDestination, *iMessage ) ); + if ( err ) + { + HandleStatus( EStateIdle ); + } + } + } + else + { + iState = EStateIdle; + iPeriodicTimer->Start( CLoadGenUtils::MilliSecondsToMicroSeconds( iAttributes.iIdle, + iAttributes.iRandomVariance ), KDefaultPeriod, + TCallBack( PeriodicTimerCallBack, this ) ); + + } + } + +// -------------------------------------------------------------------------------------------- + +void CMessageManager::HandleStatus( TInt /*aErr*/ ) + { + // timer after wait + if ( iMessageCounter < iAttributes.iAmount ) + { + iState = EStateSend; + iPeriodicTimer->Cancel(); + iPeriodicTimer->Start( CLoadGenUtils::MilliSecondsToMicroSeconds( iAttributes.iIdle, + iAttributes.iRandomVariance ), KDefaultPeriod, + TCallBack( PeriodicTimerCallBack, this ) ); + } + } + +// -------------------------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------- +// INCLUDE FILES +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "smutset.h" +#include "smuthdr.h" + + + +// ============================ MEMBER FUNCTIONS =============================== +// ----------------------------------------------------------------------------- +// CSmsHandler::CSmsHandler() +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +CSmsHandler::CSmsHandler( CMessageManager& aManager ) + : CActive( CActive::EPriorityStandard ), iManager( aManager ) + { + CActiveScheduler::Add( this ); + } + +// ----------------------------------------------------------------------------- +// CSmsHandler::ConstructL() +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CSmsHandler::ConstructL() + { + // Session to message server is opened asynchronously. + iSession = CMsvSession::OpenAsyncL( *this ); + + } + +// ----------------------------------------------------------------------------- +// CSmsHandler::NewL() +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CSmsHandler* CSmsHandler::NewL( CMessageManager& aManager ) + { + CSmsHandler* self = NewLC( aManager ); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CSmsHandler::NewLC() +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CSmsHandler* CSmsHandler::NewLC( CMessageManager& aManager ) + { + CSmsHandler* self = new ( ELeave ) CSmsHandler( aManager ); + CleanupStack::PushL( self ); + self->ConstructL(); + return self; + } + +// ---------------------------------------------------------- +// CSmsHandler::~CSmsHandler() +// Destructor. +// ---------------------------------------------------------- +// +CSmsHandler::~CSmsHandler() + { + Cancel(); // cancel any outstanding request + + delete iOperation; + delete iMtmUiRegistry; + delete iSmsMtm; + delete iMtmRegistry; + delete iSession; // session must be deleted last + } + +// ----------------------------------------------------------------------------- +// CSmsHandler::DoCancel() +// Cancels a request. +// ----------------------------------------------------------------------------- +// +void CSmsHandler::DoCancel() + { + if ( iOperation ) + { + iOperation->Cancel(); + } + } + +// ----------------------------------------------------------------------------- +// CSmsHandler::RunL() +// Handles request completion events. +// ----------------------------------------------------------------------------- +// +void CSmsHandler::RunL() + { + User::LeaveIfError( iStatus != KErrNone ); + + // Determine the current operations progress. + // ProgressL returns an 8 bit descriptor. + TBufC8 progress( iOperation->ProgressL() ); + _LIT8( KCompare, "KErrNone" ); + User::LeaveIfError( !progress.Compare( KCompare ) ); + + // The pointer to the current CMsvOperation object is no longer needed. + delete iOperation; + iOperation = NULL; + + // Determine which request has finished. + switch ( iState ) + { + case EWaitingForMoving: + // Once a message is moved to Outbox it is scheduled for sending. + ScheduleL(); + break; + + case EWaitingForScheduling: + { + TMsvEntry entry( iSmsMtm->Entry().Entry() ); + TInt state( entry.SendingState() ); + + if ( state == KMsvSendStateWaiting || state == KMsvSendStateScheduled) + { + // notify the observer that status has changed + iManager.HandleStatus( iStatus.Int() ); + } + break; + } + + default: + break; + } + } + +// ----------------------------------------------------------------------------- +// CSmsHandler::HandleSessionEventL() +// Handles notifications of events from the Message Server. +// ----------------------------------------------------------------------------- +// +void CSmsHandler::HandleSessionEventL( TMsvSessionEvent aEvent, + TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/) + { + switch ( aEvent ) + { + // Session to server established + case EMsvServerReady: + { + TMsvId serviceId( KUidMsgTypeSMS.iUid ); // SMS service id + + // Determine if the event was succesful. + // ServiceProgress inserts TBuf8 value in progress. + TBuf8 progress; + iSession->ServiceProgress( serviceId, progress ); + _LIT8( KCompare, "KErrNone" ); + + if ( progress.Compare( KCompare ) ) + { + // Check that MtmRegistry has not already been accessed. + if ( !iMtmRegistry ) + { + AccessMtmL(); + } + } + break; + } + + // All other events are ignored. + default: + break; + } + } + +// ----------------------------------------------------------------------------- +// CSmsHandler::AccessMtmL() +// Access the MTM Registry and create a SMS specific Client MTM instance. +// ----------------------------------------------------------------------------- +// +void CSmsHandler::AccessMtmL() + { + // Create an MTM Registry object. + iMtmRegistry = CClientMtmRegistry::NewL( *iSession ); + + // Create an SMS Client MTM object. + iSmsMtm = STATIC_CAST( CSmsClientMtm*, iMtmRegistry->NewMtmL( KUidMsgTypeSMS ) ); + } + +// ----------------------------------------------------------------------------- +// CSmsHandler::SendL() +// Starts the process of creating and sending an SMS message. +// ----------------------------------------------------------------------------- +// +TBool CSmsHandler::SendL( const TDesC& aRecipientNumber, + const TDesC& aMessageText ) + { + iRecipientNumber = aRecipientNumber; + iMessageText = aMessageText; + + if ( CreateMsgL() ) + { + return ETrue; + } + + return EFalse; + } + +// ----------------------------------------------------------------------------- +// CSmsHandler::CreateMsgL() +// Create an SMS message. +// ----------------------------------------------------------------------------- +// +TBool CSmsHandler::CreateMsgL() + { + if(!iSmsMtm) + { + return EFalse; + } + // Current entry is the Draft folder. + iSmsMtm->SwitchCurrentEntryL( KMsvDraftEntryId ); + + // Create a new SMS message entry as a child of the current context. + iSmsMtm->CreateMessageL( KUidMsgTypeSMS.iUid ); + + CMsvEntry& serverEntry = iSmsMtm->Entry(); + TMsvEntry entry( serverEntry.Entry() ); + + CRichText& body = iSmsMtm->Body(); // the body of the message + body.Reset(); + // Insert the message text gotten as input from user. + body.InsertL( 0, iMessageText ); + + // Message will be sent immediately. + entry.SetSendingState( KMsvSendStateWaiting ); + + entry.iDate.UniversalTime(); // insert current time //Solution for HomeTime() + + // Set the SMS message settings for the message. + CSmsHeader& header = iSmsMtm->SmsHeader(); + CSmsSettings* settings = CSmsSettings::NewL(); + CleanupStack::PushL( settings ); + + settings->CopyL( iSmsMtm->ServiceSettings() ); // restore settings + settings->SetDelivery( ESmsDeliveryImmediately ); // to be delivered immediately + settings->SetDeliveryReport(ETrue); + header.SetSmsSettingsL( *settings ); // new settings + + // Let's check if there is a service center address. + if ( header.Message().ServiceCenterAddress().Length() == 0 ) + { + // No, there isn't. We assume there is at least one service center + // number set and use the default service center number. + CSmsSettings* serviceSettings = &( iSmsMtm->ServiceSettings() ); + + // Check if number of service center addresses in the list is null. + + //Changed for 3rd Edition specially + if ( !serviceSettings->ServiceCenterCount() ) + { + CleanupStack::PopAndDestroy( settings ); + return EFalse; // quit creating the message + } + + else + { + //Changed for 3rd Edition specially + CSmsNumber* smsCenter= CSmsNumber::NewL(); + CleanupStack::PushL(smsCenter); + smsCenter->SetAddressL((serviceSettings->GetServiceCenter( + serviceSettings->DefaultServiceCenter())).Address()); + header.Message().SetServiceCenterAddressL( smsCenter->Address() ); + CleanupStack::PopAndDestroy(smsCenter); + } + } + + CleanupStack::PopAndDestroy( settings ); + + // Recipient number is displayed also as the recipient alias. + entry.iDetails.Set( iRecipientNumber ); + // Add addressee. + iSmsMtm->AddAddresseeL( iRecipientNumber, entry.iDetails ); + + // Validate message. + if ( !ValidateL() ) + { + return EFalse; + } + + entry.SetVisible( ETrue ); // set message as visible + entry.SetInPreparation( EFalse ); // set together with the visibility flag + serverEntry.ChangeL( entry ); // commit changes + iSmsMtm->SaveMessageL(); // save message + + TMsvSelectionOrdering selection; + CMsvEntry* parentEntry = CMsvEntry::NewL( iSmsMtm->Session(), KMsvDraftEntryId, selection ); + CleanupStack::PushL( parentEntry ); + + // Move message to Outbox. + iOperation =parentEntry->MoveL( entry.Id(), KMsvGlobalOutBoxIndexEntryId, iStatus ); + + CleanupStack::PopAndDestroy( parentEntry ); + + iState = EWaitingForMoving; + SetActive(); + + return ETrue; + } + +// ----------------------------------------------------------------------------- +// CSmsHandler::ValidateL() +// Validate an SMS message. +// ----------------------------------------------------------------------------- +// +TBool CSmsHandler::ValidateL() + { + if( !iSmsMtm ) + { + return EFalse; + } + // Empty part list to hold the result. + TMsvPartList result( KMsvMessagePartNone ); + + // Validate message body. + result = iSmsMtm->ValidateMessage( KMsvMessagePartBody ); + + if ( result != KMsvMessagePartNone ) + { + return EFalse; + } + + // Validate recipient. + result = iSmsMtm->ValidateMessage( KMsvMessagePartRecipient ); + + if ( result != KMsvMessagePartNone ) + { + return EFalse; + } + + return ETrue; + } + +// ----------------------------------------------------------------------------- +// CSmsHandler::ScheduleL() +// Schedule an SMS message for sending. +// ----------------------------------------------------------------------------- +// +void CSmsHandler::ScheduleL() + { + if( !iSmsMtm ) + { + return; + } + CMsvEntrySelection* selection = new ( ELeave ) CMsvEntrySelection; + CleanupStack::PushL( selection ); + selection->AppendL( iSmsMtm->Entry().EntryId() ); // add message to selection + + // Add entry to task scheduler. + TBuf8<1> dummyParams; // dummy parameters needed for InvokeAsyncFunctionL + iOperation = iSmsMtm->InvokeAsyncFunctionL( ESmsMtmCommandScheduleCopy, + *selection, dummyParams, iStatus ); + + CleanupStack::PopAndDestroy( selection ); + + iState = EWaitingForScheduling; + SetActive(); + } + +// -------------------------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------- + + + +// INCLUDE FILES +#include // for CClientMtmRegistry +#include // for Message type IDs +#include // for CMmsClientMtm +#include // for CAknTextQueryDialog +#include +#include // Check the file exist + +#include //Attachemt mimeheader +#include //Attachment manager + +// ----------------------------------------------------------------------------- +// CMmsHandler::CSmsHandler() +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +CMmsHandler::CMmsHandler( CMessageManager& aManager ) : iManager( aManager ) + { + } + +// ----------------------------------------------------------------------------- +// CMmsHandler::ConstructL() +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CMmsHandler::ConstructL() + { + // Session to message server is opened asynchronously. + iSession = CMsvSession::OpenAsyncL( *this ); + + } + +// ----------------------------------------------------------------------------- +// CMmsHandler::NewL() +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CMmsHandler* CMmsHandler::NewL( CMessageManager& aManager ) + { + CMmsHandler* self = NewLC( aManager ); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CMmsHandler::NewLC() +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CMmsHandler* CMmsHandler::NewLC( CMessageManager& aManager ) + { + CMmsHandler* self = new ( ELeave ) CMmsHandler( aManager ); + CleanupStack::PushL( self ); + self->ConstructL(); + return self; + } + +// ---------------------------------------------------------- +// CMmsHandler::~CSmsHandler() +// Destructor. +// ---------------------------------------------------------- +// +CMmsHandler::~CMmsHandler() + { + delete iMmsMtm; + delete iMtmReg; + delete iSession; // session must be deleted last (and constructed first) + } + +/* +----------------------------------------------------------------------------- + CMmsHandler::CompleteConstructL() + Creates client MTM registry when session is ready for use. + This completes model construction and is called after 'server + ready' event is received after async opening of CMsvSession. +----------------------------------------------------------------------------- +*/ +void CMmsHandler::CompleteConstructL() + { + // We get a MtmClientRegistry from our session + // this registry is used to instantiate new mtms. + iMtmReg = CClientMtmRegistry::NewL( *iSession ); + iMmsMtm = (CMmsClientMtm*)iMtmReg->NewMtmL( KUidMsgTypeMultimedia ); + } + +/* +----------------------------------------------------------------------------- + CMmsHandler::HandleSessionEventL() + + Receives session events from observer and calls event handling functions. + Note that if additional session event handlers are defined + in the session, they are called before this function (as this is the + main session observer). + The type of event is indicated by the value of aEvent. The + interpretation of the TAny arguments depends on this type. +----------------------------------------------------------------------------- +*/ +void CMmsHandler::HandleSessionEventL(TMsvSessionEvent aEvent, + TAny* /*aArg1*/, + TAny* /*aArg2*/, + TAny* /*aArg3*/) + { + switch ( aEvent ) + { + // This event tells us that the session has been opened + case EMsvServerReady: + { + CompleteConstructL(); // Construct the mtm registry & MMS mtm + break; + } + default: + { + break; + } + } + } + + +// ----------------------------------------------------------------------------- +// CSmsHandler::SendL() +// Starts the process of creating and sending an SMS message. +// ----------------------------------------------------------------------------- +// +TBool CMmsHandler::SendL( const TDesC& aRecipientNumber, + const TDesC& aMessageText ) + { + TInt result( EFalse ); + + iRecipientNumber = aRecipientNumber; + iMessageText = aMessageText; + + if ( CreateMsgL() ) + { + if ( SendMessageL() ) + { + result = ETrue; + } + } + + return result; + } + +/* +----------------------------------------------------------------------------- + CMmsHandler::CreateMsgL() + Creates a new message server entry and set up default values. + In case the attachment file does not found method return EFalse + otherwise ETrue. + There are differenses how to add attachment file between 2nd and 3rd edition. +----------------------------------------------------------------------------- +*/ +TBool CMmsHandler::CreateMsgL() + { + + // - CMsvEntry accesses and acts upon a particular Message Server entry. + // - NewL() does not create a new entry, but simply a new object to access an existing entry. + // - It takes in as parameters the client's message server session, + // ID of the entry to access and initial sorting order of the children of the entry. + CMsvEntry* entry = CMsvEntry::NewL( *iSession, + KMsvGlobalOutBoxIndexEntryId, + TMsvSelectionOrdering() ); + CleanupStack::PushL( entry ); + + // Set context to the parent folder (Outbox) + iMmsMtm->SwitchCurrentEntryL( entry->EntryId() ); + + // Create new message in the parent folder (Outbox) and set it as the current context. + iMmsMtm->CreateMessageL( iMmsMtm->DefaultServiceL() ); + + CleanupStack::PopAndDestroy( entry ); + + // Setting recipients + // use this to add the "To" recipients. + iMmsMtm->AddAddresseeL( iRecipientNumber ); + + //Setting message subject + _LIT(KMessageSubject, "MMS Message"); + iMmsMtm->SetSubjectL( KMessageSubject ); + + // add message text + SetMessageBodyL(); + + TMsvEntry ent = iMmsMtm->Entry().Entry(); + // Set InPreparation to false + ent.SetInPreparation( EFalse ); + ent.SetVisible( ETrue ); // mark as visible, after this the message can be seen in Outbox and, after sending, in Sent folder. + + iMmsMtm->Entry().ChangeL( ent ); // Commit changes + + //Save the changes + iMmsMtm->SaveMessageL(); + + return ETrue; + } + +//--------------------------------------------------------------------------------- +void CMmsHandler::SetMessageBodyL() + { + _LIT (KFilenameText, "msg.txt"); + CMsvStore* store = iMmsMtm->Entry().EditStoreL(); + CleanupStack::PushL( store ); + + TMsvAttachmentId attachmentId = KMsvNullIndexEntryId; + + iMmsMtm->CreateTextAttachmentL ( *store, + attachmentId, + iMessageText, + KFilenameText ); + + store->CommitL(); + + CleanupStack::PopAndDestroy( store ); + } + +/* +----------------------------------------------------------------------------- + CMmsHandler::SendMessageL() + Sends the message. + Return values: ETrue or EFalse +----------------------------------------------------------------------------- +*/ +TBool CMmsHandler::SendMessageL() + { + + // Start sending the message via the Server MTM to the MMS server + CMsvOperationWait* wait = CMsvOperationWait::NewLC(); + wait->iStatus = KRequestPending; + CMsvOperation* op = NULL; + op = iMmsMtm->SendL( wait->iStatus ); + wait->Start(); + CleanupStack::PushL( op ); + CActiveScheduler::Start(); + + // The following is to ignore the completion of other active objects. It is not + // needed if the app has a command absorbing control. + while( wait->iStatus == KRequestPending ) + { + CActiveScheduler::Start(); + } + + iManager.HandleStatus( wait->iStatus.Int() ); + CleanupStack::PopAndDestroy(2); // op, wait + + return ETrue; + } +// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/engine/src/loadgen_netconn.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/engine/src/loadgen_netconn.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,271 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +// INCLUDE FILES +#include "loadgen_netconn.h" +#include "loadgen_utils.h" +#include "loadgen.hrh" +#include + +#include +#include + +_LIT(KThreadName, "NetConn %d"); + +const TInt KDefaultStart = 50; +const TInt KDefaultPeriod = 5000000; + +// ===================================== MEMBER FUNCTIONS ===================================== + +CNetConn* CNetConn::NewL(TNetConnAttributes& aAttributes, TInt aReferenceNumber) + { + CNetConn* self = new(ELeave) CNetConn(aAttributes, aReferenceNumber); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// -------------------------------------------------------------------------------------------- + +CNetConn::~CNetConn() + { + Close(); + } + +// -------------------------------------------------------------------------------------------- + +CNetConn::CNetConn(TNetConnAttributes& aAttributes, TInt aReferenceNumber) : iAttributes(aAttributes) + { + iAttributes.iId = aReferenceNumber; + } + +// -------------------------------------------------------------------------------------------- + +void CNetConn::ConstructL() + { + CLoadBase::ConstructL(); + + iType = ELoadGenCmdNewLoadNetConn; + + TBuf<64> threadName; + threadName.Format(KThreadName, iAttributes.iId); + + // create a thread + User::LeaveIfError(iThread.Create(threadName, ThreadFunction, KDefaultStackSize*2, 1024*KMinHeapSize, 16*1024*KMinHeapSize, (TAny*) &iAttributes )); + + // set priority of the thread + SetPriority(); + } + +// -------------------------------------------------------------------------------------------- + +TInt CNetConn::ThreadFunction(TAny* aThreadArg) + { + CTrapCleanup* pC = CTrapCleanup::New(); + CActiveScheduler* pS = new CActiveScheduler; + CActiveScheduler::Install(pS); + + // start generating load, pass pointer to arguments + GenerateLoad(*((TNetConnAttributes*) aThreadArg)); + + delete pS; + delete pC; + + return KErrNone; + } + +// -------------------------------------------------------------------------------------------- + +void CNetConn::GenerateLoad(TNetConnAttributes& aAttributes) + { + CNetConnManager* netConnManager = NULL; + TRAPD(err, netConnManager = CNetConnManager::NewL(aAttributes)); + if (err == KErrNone) CActiveScheduler::Start(); + delete netConnManager; + } + +// -------------------------------------------------------------------------------------------- + +void CNetConn::Resume() + { + CLoadBase::Resume(); + + iThread.Resume(); + } + +// -------------------------------------------------------------------------------------------- + +void CNetConn::Suspend() + { + CLoadBase::Suspend(); + + iThread.Suspend(); + } + +// -------------------------------------------------------------------------------------------- + +void CNetConn::SetPriority() + { + CLoadBase::SetPriority(); + + iThread.SetPriority(CLoadGenUtils::SettingItemToThreadPriority(iAttributes.iPriority)); + } + +// -------------------------------------------------------------------------------------------- + +void CNetConn::Close() + { + CLoadBase::Close(); + + if (iThread.ExitReason() == 0) // check if the thread is still alive + { + // signal the thread that it needs to close + iThread.RequestComplete(iAttributes.iDeathStatus, KErrCancel); + + // wait the thread to die + TRequestStatus waiter; + iThread.Logon(waiter); + User::WaitForRequest(waiter); + iThread.Close(); + } + } + +// -------------------------------------------------------------------------------------------- + +TPtrC CNetConn::Description() + { + TBuf<256> buf; + TBuf<16> prioBuf; + CLoadGenUtils::SettingItemToThreadDescription(iAttributes.iPriority, prioBuf); + + _LIT(KNetConnEntry, "[%d] NetConn prio=%S dest=%S idle=%dms random=%d%%"); + buf.Format(KNetConnEntry, iAttributes.iId, &prioBuf, &iAttributes.iDestination, iAttributes.iIdle, iAttributes.iRandomVariance); + + return TPtrC(buf); + } + +// -------------------------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------- + +CNetConnManager* CNetConnManager::NewL(TNetConnAttributes& aAttributes) + { + CNetConnManager* self = new(ELeave) CNetConnManager(aAttributes); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +// -------------------------------------------------------------------------------------------- + +CNetConnManager::CNetConnManager(TNetConnAttributes& aAttributes) : + CActive(EPriorityStandard), iAttributes(aAttributes) + { + } + +// -------------------------------------------------------------------------------------------- + +CNetConnManager::~CNetConnManager() + { + Cancel(); + + delete iHTTPReceiver; + } + +// -------------------------------------------------------------------------------------------- + +void CNetConnManager::ConstructL() + { + CActiveScheduler::Add(this); + + // set the status as pending + iStatus = KRequestPending; + SetActive(); + + // set the death status pointer point to the request status of this ao + iAttributes.iDeathStatus = &iStatus; + + iHTTPReceiver = CHTTPReceiver::NewL( *this ); + + // start timer + iPeriodicTimer = CPeriodic::NewL(CActive::EPriorityStandard); + iPeriodicTimer->Start(KDefaultStart, KDefaultPeriod, TCallBack(PeriodicTimerCallBack, this)); + } + +// -------------------------------------------------------------------------------------------- + +void CNetConnManager::RunL() + { + // request status has completed by the main thread meaning that we need to stop now + CActiveScheduler::Stop(); + } + +// -------------------------------------------------------------------------------------------- + +void CNetConnManager::DoCancel() + { + } + +// -------------------------------------------------------------------------------------------- + +TInt CNetConnManager::PeriodicTimerCallBack(TAny* aAny) + { + CNetConnManager* self = static_cast( aAny ); + + self->iPeriodicTimer->Cancel(); + TRAPD(err,self->StartDownloadL()); + + return err; + } + +// -------------------------------------------------------------------------------------------- + +void CNetConnManager::StartDownloadL() + { + + // create new download + TBuf8<256> url; + url.Copy(iAttributes.iDestination); + + iHTTPReceiver->SendHTTPGetL( url ); + } + +// -------------------------------------------------------------------------------------------- + +void CNetConnManager::HTTPFileReceived( TInt aStatus ) + { + switch ( aStatus ) + { + case 200: + { + // assume that the download has finished in this stage + iPeriodicTimer->Start(CLoadGenUtils::MilliSecondsToMicroSeconds(iAttributes.iIdle, iAttributes.iRandomVariance), KDefaultPeriod, TCallBack(PeriodicTimerCallBack, this)); + break; + } + + default: + { + break; + } + } + } + +// -------------------------------------------------------------------------------------------- + +// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/engine/src/loadgen_phonecall.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/engine/src/loadgen_phonecall.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,353 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +// INCLUDE FILES +#include "loadgen_phonecall.h" +#include "loadgen_utils.h" +#include "loadgen.hrh" +#include + +#include + +_LIT(KThreadName, "PhoneCall %d"); + +const TInt KDefaultStart = 50; +const TInt KDefaultPeriod = 5000000; + +// ===================================== MEMBER FUNCTIONS ===================================== + +CPhoneCall* CPhoneCall::NewL(TPhoneCallAttributes& aAttributes, TInt aReferenceNumber) + { + CPhoneCall* self = new(ELeave) CPhoneCall(aAttributes, aReferenceNumber); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// -------------------------------------------------------------------------------------------- + +CPhoneCall::~CPhoneCall() + { + Close(); + } + +// -------------------------------------------------------------------------------------------- + +CPhoneCall::CPhoneCall(TPhoneCallAttributes& aAttributes, TInt aReferenceNumber) : iAttributes(aAttributes) + { + iAttributes.iId = aReferenceNumber; + } + +// -------------------------------------------------------------------------------------------- + +void CPhoneCall::ConstructL() + { + CLoadBase::ConstructL(); + + iType = ELoadGenCmdNewLoadPhoneCall; + + TBuf<64> threadName; + threadName.Format(KThreadName, iAttributes.iId); + + // create a thread + User::LeaveIfError(iThread.Create(threadName, ThreadFunction, KDefaultStackSize*2, KMinHeapSize, 1024*KMinHeapSize, (TAny*) &iAttributes )); + + // set priority of the thread + SetPriority(); + } + +// -------------------------------------------------------------------------------------------- + +TInt CPhoneCall::ThreadFunction(TAny* aThreadArg) + { + CTrapCleanup* pC = CTrapCleanup::New(); + CActiveScheduler* pS = new CActiveScheduler; + CActiveScheduler::Install(pS); + + // start generating load, pass pointer to arguments + GenerateLoad(*((TPhoneCallAttributes*) aThreadArg)); + + delete pS; + delete pC; + + return KErrNone; + } + +// -------------------------------------------------------------------------------------------- + +void CPhoneCall::GenerateLoad(TPhoneCallAttributes& aAttributes) + { + CPhoneCallManager* phoneCallManager = NULL; + TRAPD(err, phoneCallManager = CPhoneCallManager::NewL(aAttributes)); + if (err == KErrNone) CActiveScheduler::Start(); + delete phoneCallManager; + } + +// -------------------------------------------------------------------------------------------- + +void CPhoneCall::Resume() + { + CLoadBase::Resume(); + + iThread.Resume(); + } + +// -------------------------------------------------------------------------------------------- + +void CPhoneCall::Suspend() + { + CLoadBase::Suspend(); + + iThread.Suspend(); + } + +// -------------------------------------------------------------------------------------------- + +void CPhoneCall::SetPriority() + { + CLoadBase::SetPriority(); + + iThread.SetPriority(CLoadGenUtils::SettingItemToThreadPriority(iAttributes.iPriority)); + } + +// -------------------------------------------------------------------------------------------- + +void CPhoneCall::Close() + { + CLoadBase::Close(); + + if (iThread.ExitReason() == 0) // check if the thread is still alive + { + // signal the thread that it needs to close + iThread.RequestComplete(iAttributes.iDeathStatus, KErrCancel); + + // wait the thread to die + TRequestStatus waiter; + iThread.Logon(waiter); + User::WaitForRequest(waiter); + iThread.Close(); + } + } + +// -------------------------------------------------------------------------------------------- + +TPtrC CPhoneCall::Description() + { + TBuf<256> buf; + TBuf<16> prioBuf; + CLoadGenUtils::SettingItemToThreadDescription(iAttributes.iPriority, prioBuf); + + _LIT(KPhoneCallEntry, "[%d] PhoneCall prio=%S dest=%S length=%dms idle=%dms random=%d%%"); + buf.Format(KPhoneCallEntry, iAttributes.iId, &prioBuf, &iAttributes.iDestination, iAttributes.iLength, iAttributes.iIdle, iAttributes.iRandomVariance); + + return TPtrC(buf); + } + +// -------------------------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------- + +CPhoneCallManager* CPhoneCallManager::NewL(TPhoneCallAttributes& aAttributes) + { + CPhoneCallManager* self = new(ELeave) CPhoneCallManager(aAttributes); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +// -------------------------------------------------------------------------------------------- + +CPhoneCallManager::CPhoneCallManager(TPhoneCallAttributes& aAttributes) : + CActive(EPriorityStandard), iAttributes(aAttributes), iState(EStateIdle) + { + } + +// -------------------------------------------------------------------------------------------- + +CPhoneCallManager::~CPhoneCallManager() + { + Cancel(); + + if (iPeriodicTimer) + { + iPeriodicTimer->Cancel(); + delete iPeriodicTimer; + } + + delete iDialer; + } + +// -------------------------------------------------------------------------------------------- + +void CPhoneCallManager::ConstructL() + { + CActiveScheduler::Add(this); + + // set the status as pending + iStatus = KRequestPending; + SetActive(); + + // set the death status pointer point to the request status of this ao + iAttributes.iDeathStatus = &iStatus; + + // init dialer ao + iDialer = CDialer::NewL(*this); + + // start timer + iPeriodicTimer = CPeriodic::NewL(CActive::EPriorityStandard); + iPeriodicTimer->Start(KDefaultStart, KDefaultPeriod, TCallBack(PeriodicTimerCallBack, this)); + } + +// -------------------------------------------------------------------------------------------- + +void CPhoneCallManager::RunL() + { + // request status has completed by the main thread meaning that we need to stop now + CActiveScheduler::Stop(); + } + +// -------------------------------------------------------------------------------------------- + +void CPhoneCallManager::DoCancel() + { + } + +// -------------------------------------------------------------------------------------------- + +TInt CPhoneCallManager::PeriodicTimerCallBack(TAny* aAny) + { + CPhoneCallManager* self = static_cast( aAny ); + + self->iPeriodicTimer->Cancel(); + self->HandleCalls(); + + return KErrNone; + } + +// -------------------------------------------------------------------------------------------- + +void CPhoneCallManager::HandleCalls() + { + if (iState == EStateIdle) + { + // make a new call + iState = EStateCall; + iDialer->Dial(iAttributes.iDestination); + } + + else if (iState == EStateCall) + { + // hangup existing call + iState = EStateIdle; + iDialer->Hangup(); + } + } + +// -------------------------------------------------------------------------------------------- + +void CPhoneCallManager::HandleStatus(TInt /*aErr*/) + { + // call timer after wait + if (iState == EStateCall) + { + iPeriodicTimer->Start(CLoadGenUtils::MilliSecondsToMicroSeconds(iAttributes.iLength, iAttributes.iRandomVariance), KDefaultPeriod, TCallBack(PeriodicTimerCallBack, this)); + } + + else if (iState == EStateIdle) + { + iPeriodicTimer->Start(CLoadGenUtils::MilliSecondsToMicroSeconds(iAttributes.iIdle, iAttributes.iRandomVariance), KDefaultPeriod, TCallBack(PeriodicTimerCallBack, this)); + } + } + +// -------------------------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------- + +CDialer* CDialer::NewL(CPhoneCallManager& aManager) + { + CDialer* self = new(ELeave) CDialer(aManager); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +// -------------------------------------------------------------------------------------------- + +CDialer::CDialer(CPhoneCallManager& aManager) : + CActive(EPriorityStandard), iManager(aManager), iCallParamsPckg(iCallParams) + { + } + +// -------------------------------------------------------------------------------------------- + +CDialer::~CDialer() + { + Cancel(); + delete iTelephony; + } + +// -------------------------------------------------------------------------------------------- + +void CDialer::ConstructL() + { + CActiveScheduler::Add(this); + + // init telephony object + iTelephony = CTelephony::NewL(); + } + +// -------------------------------------------------------------------------------------------- + +void CDialer::RunL() + { + // notify the observer that status has changed + iManager.HandleStatus(iStatus.Int()); + } + +// -------------------------------------------------------------------------------------------- + +void CDialer::DoCancel() + { + iTelephony->CancelAsync(CTelephony::EDialNewCallCancel); + iTelephony->CancelAsync(CTelephony::EHangupCancel); + } + +// -------------------------------------------------------------------------------------------- + +void CDialer::Dial(const TDesC& aDestination) + { + CTelephony::TTelNumber telNumber(aDestination); + iCallParams.iIdRestrict = CTelephony::ESendMyId; + iTelephony->DialNewCall(iStatus, iCallParamsPckg, telNumber, iCallId); + SetActive(); + } + +// -------------------------------------------------------------------------------------------- + +void CDialer::Hangup() + { + iTelephony->Hangup(iStatus, iCallId); + SetActive(); + } + +// -------------------------------------------------------------------------------------------- + + + +// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/engine/src/loadgen_photocapture.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/engine/src/loadgen_photocapture.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,389 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +// INCLUDE FILES +#include "loadgen_photocapture.h" +#include "loadgen_utils.h" +#include "loadgen.hrh" +#include "loadgen_traces.h" +#include +#include +#include +#include +#include + +_LIT(KThreadName, "PhotoCapture %d"); + +const TInt KDefaultStart = 50; +const TInt KDefaultPeriod = 5000000; + +//TInt CPhotoCapture::iImagesReady = 0; + +// ===================================== MEMBER FUNCTIONS ===================================== + +CPhotoCapture* CPhotoCapture::NewL(TPhotoCaptureAttributes& aAttributes, TInt aReferenceNumber) + { + CPhotoCapture* self = new(ELeave) CPhotoCapture(aAttributes, aReferenceNumber); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// -------------------------------------------------------------------------------------------- + +CPhotoCapture::~CPhotoCapture() + { + Close(); + } + +// -------------------------------------------------------------------------------------------- + +CPhotoCapture::CPhotoCapture(TPhotoCaptureAttributes& aAttributes, TInt aReferenceNumber) : iAttributes(aAttributes) + { + iAttributes.iId = aReferenceNumber; + } + +// -------------------------------------------------------------------------------------------- + +void CPhotoCapture::ConstructL() + { + CLoadBase::ConstructL(); + + iType = ELoadGenCmdNewLoadPhotoCaptures; + + TBuf<64> threadName; + threadName.Format(KThreadName, iAttributes.iId); + + // create a thread + User::LeaveIfError(iThread.Create(threadName, ThreadFunction, KDefaultStackSize*2, KMinHeapSize, 1024*KMinHeapSize, (TAny*) &iAttributes )); + + // set priority of the thread + SetPriority(); + } + +// -------------------------------------------------------------------------------------------- + +TInt CPhotoCapture::ThreadFunction(TAny* aThreadArg) + { + TInt err = KErrNone; + + CTrapCleanup* pC = CTrapCleanup::New(); + CActiveScheduler* pS = new CActiveScheduler; + CActiveScheduler::Install(pS); + + // start generating load, pass pointer to arguments + GenerateLoad(*((TPhotoCaptureAttributes*) aThreadArg)); + + delete pS; + delete pC; + + return err; + } + +// -------------------------------------------------------------------------------------------- + +void CPhotoCapture::GenerateLoad(TPhotoCaptureAttributes& aAttributes) + { + CCameraManager* cameraManager = 0; + TRAPD(err, cameraManager = CCameraManager::NewL(aAttributes)); + if (err == KErrNone) CActiveScheduler::Start(); + delete cameraManager; + } + +// -------------------------------------------------------------------------------------------- + +void CPhotoCapture::Resume() + { + CLoadBase::Resume(); + iThread.Resume(); + } + +// -------------------------------------------------------------------------------------------- + +void CPhotoCapture::Suspend() + { + CLoadBase::Suspend(); + iThread.Suspend(); + } + +// -------------------------------------------------------------------------------------------- + +void CPhotoCapture::SetPriority() + { + CLoadBase::SetPriority(); + iThread.SetPriority(CLoadGenUtils::SettingItemToThreadPriority(iAttributes.iPriority)); + } + +// -------------------------------------------------------------------------------------------- + +void CPhotoCapture::Close() + { + CLoadBase::Close(); + + // kill the thread immediately + iThread.Kill(0); + + iThread.Close(); + } + +// -------------------------------------------------------------------------------------------- + +TPtrC CPhotoCapture::Description() + { + TBuf<256> buf; + TBuf<16> prioBuf; + CLoadGenUtils::SettingItemToThreadDescription(iAttributes.iPriority, prioBuf); + + _LIT(KPhotoCaptureEntry, "[%d] PhotoCapture camera=%d prio=%S idle=%dms random=%d%%"); + buf.Format(KPhotoCaptureEntry, iAttributes.iId, iAttributes.iCamera, &prioBuf, iAttributes.iIdle, iAttributes.iRandomVariance); + + return TPtrC(buf); + } + +// -------------------------------------------------------------------------------------------- + + +// -------------------------------------------------------------------------------------------- +CCameraManager* CCameraManager::NewL(TPhotoCaptureAttributes& aAttrs) + { + CCameraManager* self = new (ELeave) CCameraManager(aAttrs); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// -------------------------------------------------------------------------------------------- +CCameraManager::~CCameraManager() + { + delete iCamera; + if (iPeriodicTimer) + { + iPeriodicTimer->Cancel(); + delete iPeriodicTimer; + } + } + +// -------------------------------------------------------------------------------------------- +CCameraManager::CCameraManager(TPhotoCaptureAttributes& aAttrs) +: +CActive(EPriorityStandard), +iAttributes(aAttrs) + { + iState = ENotReady; + iNumOfPics = 0; + } + +// -------------------------------------------------------------------------------------------- +void CCameraManager::ConstructL() + { + CActiveScheduler::Add(this); + // set the status as pending + iStatus = KRequestPending; + SetActive(); + + // set the death status pointer point to the request status of this ao + iAttributes.iDeathStatus = &iStatus; + + // start timer + iPeriodicTimer = CPeriodic::NewL(CActive::EPriorityStandard); + iPeriodicTimer->Start(KDefaultStart, KDefaultPeriod, TCallBack(PeriodicTimerCallBack, this)); + } + +// -------------------------------------------------------------------------------------------- +void CCameraManager::DoCancel() + { + } + +// -------------------------------------------------------------------------------------------- +void CCameraManager::RunL() + { + // request status has completed by the main thread meaning that we need to stop now + CActiveScheduler::Stop(); + } + +// -------------------------------------------------------------------------------------------- +void CCameraManager::ReserveCameraL() + { + LOGSTRING2("LoadGen: CCameraManager::ReserveCameraL() - Using Camera %d", iAttributes.iCamera); + if( iCamera ) + { + iCamera->Release(); + } + delete iCamera; + iCamera = 0; + TRAPD( err, iCamera = CCamera::NewL(*this, iAttributes.iCamera)); + iCurrentCamera = iAttributes.iCamera; + if(err != KErrNone) + { + LOGSTRING2("LoadGen: CCamera::NewL leaves with error: %d", err); + User::Leave(err); + } + iCamera->CameraInfo(iCameraInfo); + iCamera->Reserve(); + } + +// -------------------------------------------------------------------------------------------- +void CCameraManager::ReserveComplete(TInt aError) + { + if( aError != KErrNone ) + LOGSTRING2("LoadGen: CCameraManager::ReserveComplete() - Error: %d", aError); + + if( aError == KErrNone ) + { + iState = ECameraReserved; + iCamera->PowerOn(); + } + } + +// -------------------------------------------------------------------------------------------- +void CCameraManager::PowerOnComplete(TInt aError) + { + if( aError != KErrNone ) + { + LOGSTRING2("LoadGen: CCameraManager::PowerOnComplete() - Error: %d", aError); + return; + } + + // Define image format, try JPEG images first: + CCamera::TFormat format = CCamera::EFormatExif; + + if(iCameraInfo.iImageFormatsSupported & CCamera::EFormatExif) + { + LOGSTRING("LoadGen: CCameraManager::PowerOnComplete() - EXIF JPEG supported"); + format = CCamera::EFormatExif; + } + else if( iCameraInfo.iImageFormatsSupported & CCamera::EFormatJpeg ) + { + LOGSTRING("LoadGen: CCameraManager::PowerOnComplete() - JFIF JPEG supported"); + format = CCamera::EFormatJpeg; + } + else if( iCameraInfo.iImageFormatsSupported & CCamera::EFormatFbsBitmapColor4K ) + { + LOGSTRING("LoadGen: CCameraManager::PowerOnComplete() - Bitmap 4K Color supported"); + format = CCamera::EFormatFbsBitmapColor4K; + } + else if( iCameraInfo.iImageFormatsSupported & CCamera::EFormatFbsBitmapColor64K ) + { + LOGSTRING("LoadGen: CCameraManager::PowerOnComplete() - Bitmap 64K Color supported"); + format = CCamera::EFormatFbsBitmapColor64K; + } + else if( iCameraInfo.iImageFormatsSupported & CCamera::EFormatFbsBitmapColor16M ) + { + LOGSTRING("LoadGen: CCameraManager::PowerOnComplete() - Bitmap 16M Color supported"); + format = CCamera::EFormatFbsBitmapColor16M; + } + else + { + LOGSTRING2("LoadGen: CCameraManager::PowerOnComplete() - JPEGs not supported, trying \"User defined\" (Supported formats: %d)", iCameraInfo.iImageFormatsSupported); + format = CCamera::EFormatUserDefined; + } + const TInt KImageSizeIndex = 0; // Largest image size + TRAPD( err, iCamera->PrepareImageCaptureL(format, KImageSizeIndex)); + if( err != KErrNone ) + { + LOGSTRING2("LoadGen: CCameraManager::PowerOnComplete() - Error while preparing camera: %d", err); + } + // Camera ready: + iState = EIdle; + // Take photo: + TRAP(err, CapturePhotoL()); + if( err != KErrNone ) + { + LOGSTRING2("LoadGen: CCameraManager::PowerOnComplete() - Photo capture error: %d", err); + } + } + +// -------------------------------------------------------------------------------------------- +void CCameraManager::ViewFinderFrameReady(CFbsBitmap& /*aFrame*/) + { + } + +// -------------------------------------------------------------------------------------------- +void CCameraManager::ImageReady(CFbsBitmap* aBitmap, HBufC8* aData, TInt aError) + { + if( aError != KErrNone ) + { + LOGSTRING2("LoadGen: CCameraManager::ImageReady() - Error: %d", aError); + } + else + { + iNumOfPics++; + LOGSTRING2("LoadGen: CCameraManager::ImageReady() - Images successfully captured: %d", iNumOfPics); + } + delete aBitmap; + delete aData; + iState = EIdle; + } + +// -------------------------------------------------------------------------------------------- +void CCameraManager::FrameBufferReady(MFrameBuffer* /*aFrameBuffer*/, TInt aError) + { + if( aError != KErrNone ) + LOGSTRING2("LoadGen: CCameraManager::FrameBufferReady() - Error: %d", aError); + } + +// -------------------------------------------------------------------------------------------- +void CCameraManager::CapturePhotoL() + { + // Camera Manager must be in idle state when taking a photo + if( iState == ENotReady ) + { + // Not ready, camera must be reserved: + ReserveCameraL(); + } + else if (iState == EIdle) + { + if( iCurrentCamera != iAttributes.iCamera ) + { + LOGSTRING3("LoadGen: CCameraManager::CapturePhotoL() - Switching from Camera %d to Camera %d", iCurrentCamera, iAttributes.iCamera); + ReserveCameraL(); + } + else + { + iState = ECapture; + if( iCameraInfo.iFlashModesSupported & CCamera::EFlashForced) + { + iCamera->SetFlashL(CCamera::EFlashForced); + } + iCamera->CaptureImage(); + iPeriodicTimer->Start( CLoadGenUtils::MilliSecondsToMicroSeconds( iAttributes.iIdle, + iAttributes.iRandomVariance ), KDefaultPeriod, + TCallBack( PeriodicTimerCallBack, this ) ); + } + } + else + { + iPeriodicTimer->Start( CLoadGenUtils::MilliSecondsToMicroSeconds( iAttributes.iIdle, + iAttributes.iRandomVariance ), KDefaultPeriod, + TCallBack( PeriodicTimerCallBack, this ) ); + } + } + +// -------------------------------------------------------------------------------------------- + +TInt CCameraManager::PeriodicTimerCallBack(TAny* aAny) + { + CCameraManager* self = static_cast( aAny ); + self->iPeriodicTimer->Cancel(); + TRAP_IGNORE(self->CapturePhotoL()); + return KErrNone; + } + +// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/engine/src/loadgen_pointerevent.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/engine/src/loadgen_pointerevent.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,271 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +// INCLUDE FILES +#include "loadgen_pointerevent.h" +#include "loadgen_utils.h" +#include "loadgen.hrh" +#include + +#include + +_LIT(KThreadName, "PointerEvent %d"); + +const TInt KDefaultStart = 50; +const TInt KDefaultPeriod = 5000000; + +// ===================================== MEMBER FUNCTIONS ===================================== + +CPointerEvent* CPointerEvent::NewL(TPointerEventAttributes& aAttributes, TInt aReferenceNumber) + { + CPointerEvent* self = new(ELeave) CPointerEvent(aAttributes, aReferenceNumber); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// -------------------------------------------------------------------------------------------- + +CPointerEvent::~CPointerEvent() + { + Close(); + } + +// -------------------------------------------------------------------------------------------- + +CPointerEvent::CPointerEvent(TPointerEventAttributes& aAttributes, TInt aReferenceNumber) : iAttributes(aAttributes) + { + iAttributes.iId = aReferenceNumber; + } + +// -------------------------------------------------------------------------------------------- + +void CPointerEvent::ConstructL() + { + CLoadBase::ConstructL(); + + iType = ELoadGenCmdNewLoadPointerEvent; + + TBuf<64> threadName; + threadName.Format(KThreadName, iAttributes.iId); + + // create a thread + User::LeaveIfError(iThread.Create(threadName, ThreadFunction, KDefaultStackSize*2, KMinHeapSize, 1024*KMinHeapSize, (TAny*) &iAttributes )); + + // set priority of the thread + SetPriority(); + } + +// -------------------------------------------------------------------------------------------- + +TInt CPointerEvent::ThreadFunction(TAny* aThreadArg) + { + CTrapCleanup* pC = CTrapCleanup::New(); + CActiveScheduler* pS = new CActiveScheduler; + CActiveScheduler::Install(pS); + + // start generating load, pass pointer to arguments + GenerateLoad(*((TPointerEventAttributes*) aThreadArg)); + + delete pS; + delete pC; + + return KErrNone; + } + +// -------------------------------------------------------------------------------------------- + +void CPointerEvent::GenerateLoad(TPointerEventAttributes& aAttributes) + { + CPointerEventManager* pointerEventManager = NULL; + TRAPD(err, pointerEventManager = CPointerEventManager::NewL(aAttributes)); + if (err == KErrNone) CActiveScheduler::Start(); + delete pointerEventManager; + } + +// -------------------------------------------------------------------------------------------- + +void CPointerEvent::Resume() + { + CLoadBase::Resume(); + + iThread.Resume(); + } + +// -------------------------------------------------------------------------------------------- + +void CPointerEvent::Suspend() + { + CLoadBase::Suspend(); + + iThread.Suspend(); + } + +// -------------------------------------------------------------------------------------------- + +void CPointerEvent::SetPriority() + { + CLoadBase::SetPriority(); + + iThread.SetPriority(CLoadGenUtils::SettingItemToThreadPriority(iAttributes.iPriority)); + } + +// -------------------------------------------------------------------------------------------- + +void CPointerEvent::Close() + { + CLoadBase::Close(); + + if (iThread.ExitReason() == 0) // check if the thread is still alive + { + // signal the thread that it needs to close + iThread.RequestComplete(iAttributes.iDeathStatus, KErrCancel); + + // wait the thread to die + TRequestStatus waiter; + iThread.Logon(waiter); + User::WaitForRequest(waiter); + iThread.Close(); + } + } + +// -------------------------------------------------------------------------------------------- + +TPtrC CPointerEvent::Description() + { + TBuf<256> buf; + TBuf<16> prioBuf; + CLoadGenUtils::SettingItemToThreadDescription(iAttributes.iPriority, prioBuf); + + _LIT(KPointerEventEntry, "[%d] PointerEvent prio=%S heartbeat=%dms random=%d%%"); + buf.Format(KPointerEventEntry, iAttributes.iId, &prioBuf, iAttributes.iHeartBeat, iAttributes.iRandomVariance); + + return TPtrC(buf); + } + +// -------------------------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------- + +CPointerEventManager* CPointerEventManager::NewL(TPointerEventAttributes& aAttributes) + { + CPointerEventManager* self = new(ELeave) CPointerEventManager(aAttributes); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +// -------------------------------------------------------------------------------------------- + +CPointerEventManager::CPointerEventManager(TPointerEventAttributes& aAttributes) : + CActive(EPriorityStandard), iAttributes(aAttributes) + { + } + +// -------------------------------------------------------------------------------------------- + +CPointerEventManager::~CPointerEventManager() + { + Cancel(); + } + +// -------------------------------------------------------------------------------------------- + +void CPointerEventManager::ConstructL() + { + CActiveScheduler::Add(this); + + // set the status as pending + iStatus = KRequestPending; + SetActive(); + + // set the death status pointer point to the request status of this ao + iAttributes.iDeathStatus = &iStatus; + + // init + + // start timer + iPeriodicTimer = CPeriodic::NewL(CActive::EPriorityStandard); + iPeriodicTimer->Start(KDefaultStart, KDefaultPeriod, TCallBack(PeriodicTimerCallBack, this)); + } + +// -------------------------------------------------------------------------------------------- + +void CPointerEventManager::RunL() + { + // request status has completed by the main thread meaning that we need to stop now + CActiveScheduler::Stop(); + } + +// -------------------------------------------------------------------------------------------- + +void CPointerEventManager::DoCancel() + { + } + +// -------------------------------------------------------------------------------------------- + +TInt CPointerEventManager::PeriodicTimerCallBack(TAny* aAny) + { + CPointerEventManager* self = static_cast( aAny ); + + self->iPeriodicTimer->Cancel(); + self->SimulatePointerEvent(); + + return KErrNone; + } + +// -------------------------------------------------------------------------------------------- + +void CPointerEventManager::SimulatePointerEvent() + { + // Check the screen size and select pointer event position + // randomly + TSize screenSize = CLoadGenUtils::ScreenSize(); + + TInt x1 = CLoadGenUtils::RandomNumber(0, screenSize.iWidth); + TInt y1 = CLoadGenUtils::RandomNumber(0, screenSize.iHeight); + + // Generate "Pointer down" event: + TRawEvent eventPointerDown; + eventPointerDown.Set(TRawEvent::EButton1Down, x1, y1); + UserSvr::AddEvent(eventPointerDown); + + // Get new random position for "Move pointer" and + // "Pointer up" events + TInt x2 = CLoadGenUtils::RandomNumber(0, screenSize.iWidth); + TInt y2 = CLoadGenUtils::RandomNumber(0, screenSize.iHeight); + + // Generate "Move pointer" event: + TRawEvent eventMovePointer; + eventMovePointer.Set(TRawEvent::EPointerMove, x2, y2); + UserSvr::AddEvent(eventMovePointer); + + // Generate "Pointer up" event: + TRawEvent eventPointerUp; + eventPointerUp.Set(TRawEvent::EButton1Up, x2, y2); + UserSvr::AddEvent(eventPointerUp); + + // call timer + iPeriodicTimer->Start(CLoadGenUtils::MilliSecondsToMicroSeconds(iAttributes.iHeartBeat, iAttributes.iRandomVariance), KDefaultPeriod, TCallBack(PeriodicTimerCallBack, this)); + } + +// -------------------------------------------------------------------------------------------- + +// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/engine/src/loadgen_utils.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/engine/src/loadgen_utils.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,266 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +// INCLUDE FILES +#include +#include +#include + +#include "loadgen_utils.h" +#include "loadgen.hrh" + +inline TInt64 INIT_SEED() +{ + TTime now; + now.HomeTime(); + return now.Int64(); +} + +TInt64 CLoadGenUtils::iRandomNumberSeed = INIT_SEED(); + +TThreadPriority CLoadGenUtils::SettingItemToThreadPriority(TInt aIndex) + { + TThreadPriority threadPriority = EPriorityNull; + + switch ( aIndex ) + { + case EThreadPriorityTypeMuchLess: + { + threadPriority = EPriorityMuchLess; break; + } + case EThreadPriorityTypeLess: + { + threadPriority = EPriorityLess; break; + } + case EThreadPriorityTypeNormal: + { + threadPriority = EPriorityNormal; break; + } + case EThreadPriorityTypeMore: + { + threadPriority = EPriorityMore; break; + } + case EThreadPriorityTypeMuchMore: + { + threadPriority = EPriorityMuchMore; break; + } + case EThreadPriorityTypeRealTime: + { + threadPriority = EPriorityRealTime; break; + } + case EThreadPriorityTypeAbsoluteVeryLow: + { + threadPriority = EPriorityAbsoluteVeryLow; break; + } + case EThreadPriorityTypeAbsoluteLow: + { + threadPriority = EPriorityAbsoluteLow; break; + } + case EThreadPriorityTypeAbsoluteBackground: + { + threadPriority = EPriorityAbsoluteBackground; break; + } + case EThreadPriorityTypeAbsoluteForeground: + { + threadPriority = EPriorityAbsoluteForeground; break; + } + case EThreadPriorityTypeAbsoluteHigh: + { + threadPriority = EPriorityAbsoluteHigh; break; + } + + default: + { + User::Panic(_L("Wrong tp index"), 276); + break; + } + } + + return threadPriority; + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenUtils::SettingItemToThreadDescription(TInt aIndex, TDes& aBuf) + { + switch ( aIndex ) + { + case EThreadPriorityTypeMuchLess: + { + aBuf.Append(_L("ML(-20)")); break; + } + case EThreadPriorityTypeLess: + { + aBuf.Append(_L("L(-10)")); break; + } + case EThreadPriorityTypeNormal: + { + aBuf.Append(_L("NO(0)")); break; + } + case EThreadPriorityTypeMore: + { + aBuf.Append(_L("M(10)")); break; + } + case EThreadPriorityTypeMuchMore: + { + aBuf.Append(_L("MM(20)")); break; + } + case EThreadPriorityTypeRealTime: + { + aBuf.Append(_L("RL(30)")); break; + } + case EThreadPriorityTypeAbsoluteVeryLow: + { + aBuf.Append(_L("AVL(100)")); break; + } + case EThreadPriorityTypeAbsoluteLow: + { + aBuf.Append(_L("AL(200)")); break; + } + case EThreadPriorityTypeAbsoluteBackground: + { + aBuf.Append(_L("ABG(300)")); break; + } + case EThreadPriorityTypeAbsoluteForeground: + { + aBuf.Append(_L("AFG(400)")); break; + } + case EThreadPriorityTypeAbsoluteHigh: + { + aBuf.Append(_L("AH(500)")); break; + } + + default: + { + User::Panic(_L("Wrong td index"), 277); + break; + } + } + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenUtils::SettingItemToSourceDescription(TInt aIndex, TDes& aBuf) + { + switch ( aIndex ) + { + case EMemoryEatSourceTypeRAM: + { + aBuf.Append(_L("RAM")); break; + } + case EMemoryEatSourceTypeDriveC: + { + aBuf.Append(_L("C:")); break; + } + case EMemoryEatSourceTypeDriveD: + { + aBuf.Append(_L("D:")); break; + } + case EMemoryEatSourceTypeDriveE: + { + aBuf.Append(_L("E:")); break; + } + case EMemoryEatSourceTypeDriveF: + { + aBuf.Append(_L("F:")); break; + } + case EMemoryEatSourceTypeDriveG: + { + aBuf.Append(_L("G:")); break; + } + case EMemoryEatSourceTypeDriveH: + { + aBuf.Append(_L("H:")); break; + } + case EMemoryEatSourceTypeDriveI: + { + aBuf.Append(_L("I:")); break; + } + case EMemoryEatSourceTypeDriveJ: + { + aBuf.Append(_L("J:")); break; + } + case EMemoryEatSourceTypeDriveK: + { + aBuf.Append(_L("K:")); break; + } + case EMemoryEatSourceTypeDriveL: + { + aBuf.Append(_L("L:")); break; + } + case EMemoryEatSourceTypeDriveM: + { + aBuf.Append(_L("M:")); break; + } + case EMemoryEatSourceTypeDriveN: + { + aBuf.Append(_L("N:")); break; + } + + default: + { + User::Panic(_L("Wrong src index"), 278); + break; + } + } + } + +// -------------------------------------------------------------------------------------------- + +TInt CLoadGenUtils::MilliSecondsToMicroSeconds(TInt aMilliSeconds, TInt aRandomVariance) + { + __ASSERT_ALWAYS(aRandomVariance >= 0 && aRandomVariance <= 100, User::Panic(_L("Inv.var."), 180)); + __ASSERT_ALWAYS(aMilliSeconds >=0, User::Panic(_L("Inv.ms."), 181)); + + // if no variance defined, just do a quick conversion + if (aRandomVariance == 0 || aMilliSeconds == 0) + return aMilliSeconds * 1000; + + // otherwise calculate difference + TInt diff = 1000 * aMilliSeconds / 2 * aRandomVariance / 100; + + return RandomNumber(aMilliSeconds*1000-diff, aMilliSeconds*1000+diff); + } + +// -------------------------------------------------------------------------------------------- + +TInt CLoadGenUtils::RandomNumber(TInt aMin, TInt aMax) + { + TInt range = (aMax > aMin ? aMax - aMin : aMin - aMax) + 1; + TInt random = (TInt) (range * Math::FRand(iRandomNumberSeed)); + + random = (random % range) + aMin; + + if (random > aMax) + random = aMax; + else if (random < aMin) + random = aMin; + + return random; + } + +// -------------------------------------------------------------------------------------------- + +TSize CLoadGenUtils::ScreenSize() + { + TInt x = 0; + TInt y = 0; + HAL::Get(HALData::EDisplayXPixels, x); + HAL::Get(HALData::EDisplayYPixels, y); + return TSize(x, y); + } diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/envpatcher/EnvPatcher.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/envpatcher/EnvPatcher.pl Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,498 @@ +# +# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# Environment Patcher - Patches older S60 SDKs for supporting +# tricks in newer platforms +# + + +require v5.6.1; + +use File::Copy; +use strict; + +# check amount of commandline options is valid +if (@ARGV != 1) +{ + print "Usage: EnvPatcher \n"; + exit 1; +} + + +# get epocroot and convert, convert \ -> / +(my $epocroot = $ARGV[0]) =~ s{\\}{/}g; + +# remove any trailing forward slashes +$epocroot =~ s/\/$//; + + +# create variables for paths +my $e32toolsdir = $epocroot."/epoc32/tools"; +my $e32includedir = $epocroot."/epoc32/include"; +my $e32includeoemdir = $e32includedir."/oem"; +my $platformpathspath = $e32includedir."/platform_paths.hrh"; +my $domainplatformpathspath = $e32includedir."/domain/osextensions/platform_paths.hrh"; +my $mmppmpath = $e32toolsdir."/mmp.pm"; +my $pathutlpmpath = $e32toolsdir."/pathutl.pm"; +my $prepfilepmpath = $e32toolsdir."/prepfile.pm"; + +# variables for hacked content +my $dependshack = "\t\t\tif (/^DEPENDS\$/o) {\r\n\t\t\t\tnext LINE; # Ignore DEPENDS keyword, not needed by ABLD\r\n\t\t\t}\r\n"; +my $forwardslashhack = "\t\t# EnvPatcher forwardslash hack begins\r\n\t\t\$_=~s{/}{\\\\}g; # convert all forward slashes to backslashes\r\n\t\t# EnvPatcher forwardslash hack ends\r\n\r\n"; +my $coreibyexportsupport = "\r\n// Following definition is used for exporting tools and stubs IBY files to\r\n// Core image.\r\n#define CORE_IBY_EXPORT_PATH(path,exported) /epoc32/rom/include/##exported\r\n"; + + +# check epoc32\tools exists +unless (-d $e32toolsdir) +{ + print "$e32toolsdir not found, please check valid epocroot has been given!\n"; + exit 1; +} + +# check epoc32\include exists +unless (-d $e32includedir) +{ + print "$e32includedir not found, please check valid epocroot has been given!\n"; + exit 1; +} + + +# create epoc32\include\oem if it does not exist +unless (-d $e32includeoemdir) +{ + mkdir $e32includeoemdir or die; + print "Missing directory $e32includeoemdir created succesfully.\n"; +} + + +# check if epoc32\include\domain\osextensions\platform_paths.hrh exists +if (-e $domainplatformpathspath) +{ + # show an error if the file does not have any platform macros + unless (string_exists_in_file($domainplatformpathspath, "OS_LAYER_SYSTEMINCLUDE")) + { + print "ERROR: $domainplatformpathspath does not have SF macros.\n"; + print "Please check your environment, if you have S60 3.2 OEM or newer, please get the latest version!\n"; + exit 2; + } +} + + +# check if epoc32\include\platform_paths.hrh exists +if (-e $platformpathspath) +{ + print "$platformpathspath already exists, not checking it.\n"; +} +else +{ + # create the file missing file + create_default_platform_paths_hrh(); + print "Missing file $platformpathspath created succesfully.\n"; +} + + +# check if CORE_IBY_EXPORT_PATH macro exist in the platform_paths.hrh +unless (string_exists_in_file($platformpathspath, "CORE_IBY_EXPORT_PATH")) +{ + # read content of the platform_paths.hrh + my @filecontent = read_file_to_array($platformpathspath); + + my $match_found = 0; + my $i = 0; + my $match_found_pos = 0; + + # find the position where the include guards start (this should be a safe position) + foreach (@filecontent) + { + if ($_ =~ /#define PLATFORM_PATHS_HRH/) + { + $match_found = 1; + $match_found_pos = $i; + last; + } + + $i++; + } + + if ($match_found) + { + # insert the patched content to the file + splice(@filecontent, $match_found_pos+1, 0, $coreibyexportsupport); + + # write the modified array to the file + write_file_from_array($platformpathspath, @filecontent); + + print "Platform_paths.hrh updated to support CORE_IBY_EXPORT_PATH macro.\n"; + } + else + { + print "WARNING: $platformpathspath is corrupted or not supported!\n"; + } +} + + +# check if epoc32\tools\mmp.pm exists +if (-e $mmppmpath) +{ + # check if DEPENDS keyword already exists in the file + if (string_exists_in_file($mmppmpath, "DEPENDS")) + { + print "The SDK has already been patched with DEPENDS keyword hack.\n"; + } + else + { + # read content of the mmp.pm file + my @filecontent = read_file_to_array($mmppmpath); + + my $match_found = 0; + my $i = 0; + my $match_found_pos = 0; + + # loop through the array to find the correct place + foreach (@filecontent) + { + if ($_ =~ /Unrecognised Resource Keyword/) + { + $match_found = 1; + $match_found_pos = $i; + last; + } + + $i++; + } + + if ($match_found) + { + # insert the patched content to the file + splice(@filecontent, $match_found_pos-1, 0, $dependshack); + + # write the modified array to the file + write_file_from_array($mmppmpath, @filecontent); + + print "Mmp.pm patched with DEPENDS keyword hack.\n"; + } + else + { + print "ERROR: Unable to find correct place from $mmppmpath for patching!\n"; + print "Your SDK environment probably is not supported by this script!\n"; + exit(2); + } + } +} +else +{ + print "WARNING: $mmppmpath not found, this environment is not supported!\n"; +} + + +# check if epoc32\tools\pathutl.pm exists +if (-e $pathutlpmpath) +{ + # check if "sub Path_Norm" already exists in the pathutil.pm file + # if it does not exists, then we need to patch prepfile.pm + if (string_exists_in_file($pathutlpmpath, "sub Path_Norm")) + { + print "The SDK is non Symbian OS 9.1, no need to add forward slash hack.\n"; + } + else + { + # check if prepfile.pm has already been patched + if (string_exists_in_file($prepfilepmpath, "EnvPatcher forwardslash hack")) + { + print "The SDK has already been patched with forwardslash hack.\n"; + } + else + { + # read content of the prepfile.pm file + my @filecontent = read_file_to_array($prepfilepmpath); + + my $match_found = 0; + my $i = 0; + my $match_found_pos = 0; + + # loop through the array to find the correct place + foreach (@filecontent) + { + if ($_ =~ /# skip blank lines/) + { + $match_found = 1; + $match_found_pos = $i; + last; + } + + $i++; + } + + if ($match_found) + { + # insert the patched content to the file + splice(@filecontent, $match_found_pos+6, 0, $forwardslashhack); + + # write the modified array to the file + write_file_from_array($prepfilepmpath, @filecontent); + + print "Prepfile.pm patched with forward slash hack.\n"; + } + else + { + print "ERROR: Unable to find correct place from $prepfilepmpath for patching!\n"; + print "Your SDK environment probably is not supported by this script!\n"; + exit(2); + } + } + } +} +else +{ + print "WARNING: $pathutlpmpath not found, this environment is not supported!\n"; +} + + + +# checks if string exists in the file +sub string_exists_in_file +{ + my $filepath = $_[0]; + my $findstring = $_[1]; + my $match_found = 0; + + open(FILE, "<", $filepath) or die "Failed to open $filepath for reading!"; + + # loop through the file for occurances + while () + { + if ($_ =~ /$findstring/) + { + $match_found = 1; + last; + } + } + + close FILE; + + return $match_found; +} + + +# reads lines from a file to an array +sub read_file_to_array +{ + my $filepath = $_[0]; + + open(FILE, "<", $filepath) or die "Failed to open $filepath for reading!"; + my @data = ; + close FILE; + + return(@data); +} + + +# writes lines from an array to a file +sub write_file_from_array +{ + my ($filepath, @data) = @_; + + # take a backup of the file + copy ($filepath, $filepath."EnvPatcher") or die "Cannot take backup of $filepath to $filepath.EnvPatcher"; + + open(FILE, ">", $filepath) or die "Failed to open $filepath for writing!"; + + # write the array to file + foreach my $line (@data) + { + print FILE "$line"; + } + + close FILE; +} + +sub create_default_platform_paths_hrh +{ + # the file does not exist, so create the missing file + open(FILE, ">", $platformpathspath) or die "Failed to open $platformpathspath for writing!\n"; + + print FILE < thus they are first. +*/ +#define APP_LAYER_SYSTEMINCLUDE SYSTEMINCLUDE /epoc32/include /epoc32/include/oem + +/** +* This define statements defines the SYSTEMINCLUDE-line, which is intended to be +* used in the mmp-files that are part of the middleware-layer. It includes all +* the needed directories from the /epoc32/include, that are valid ones for the +* middleware-layer components. +*/ +#define MW_LAYER_SYSTEMINCLUDE SYSTEMINCLUDE /epoc32/include /epoc32/include/oem + +/** +* This define statements defines the SYSTEMINCLUDE-line, which is intended to be +* used in the mmp-files that are part of the osextensions-layer. It includes all +* the needed directories from the /epoc32/include, that are valid ones for the +* os-layer components. +*/ +#define OS_LAYER_SYSTEMINCLUDE SYSTEMINCLUDE /epoc32/include /epoc32/include/oem + + +// Below statement is Deprecated and the OS_LAYER_SYSTEMINCLUDE-macro has to be +// used. +#define OSEXT_LAYER_SYSTEMINCLUDE OS_LAYER_SYSTEMINCLUDE + +/** +* This define statements defines the SYSTEMINCLUDE-line, which is intended to be +* used in the mmp-files that are part of the os-layer. This is intended +* to be only used by those components which need to use in their mmp-file either +* kern_ext.mmh or nkern_ext.mmh. Reason is that those +* 2 files already contain the /epoc32/include as system include path. +* +*/ +#define OS_LAYER_KERNEL_SYSTEMINCLUDE SYSTEMINCLUDE /epoc32/include/oem + + +// Below statement is Deprecated and the OS_LAYER_KERNEL_SYSTEMINCLUDE-macro +// has to be used. +#define OSEXT_LAYER_KERNEL_SYSTEMINCLUDE OS_LAYER_KERNEL_SYSTEMINCLUDE + +/** +**************************************************************************** +* Definitions that also define the paths to the layer specific source directories. +**************************************************************************** +*/ +/** +* The below 3 macros define the paths to the layer-specific source dirs. +* See usage on top of this hrh-file, these are used the same way as +* for instance the OS_LAYER_DOMAIN_EXPORT_PATH +* Deprecated: is not allowed to be using in Symbian Foundation +*/ +#define APP_LAYER_SOURCE_PATH(rest) /s60/app/##rest +#define MW_LAYER_SOURCE_PATH(rest) /s60/mw/##rest +#define OSEXT_LAYER_SOURCE_PATH(rest) /s60/osext/##rest + +/** +**************************************************************************** +* Definitions to export IBY files to different folders where they will be taken +* to ROM image +**************************************************************************** +*/ +// Following definition is used for exporting tools and stubs IBY files to +// Core image. +#define CORE_IBY_EXPORT_PATH(path,exported) /epoc32/rom/include/##exported + +/** +* --------------------------------------- +* Macros for Configuration tool migration. +* The below macros define the location under epoc32, where the confml +* (Configuration Markup Language) and crml (Central Repository Markup Language) +* files should be exported. +* --------------------------------------- +*/ +#define CONFML_EXPORT_PATH(file,category) /epoc32/rom/config/confml_data/##category##/##file +#define CRML_EXPORT_PATH(file,category) /epoc32/rom/config/confml_data/##category##/##file +#define GCFML_EXPORT_PATH(file,category) /epoc32/rom/config/confml_data/##category##/##file +#define CONFML_CONFIG_EXPORT_PATH(file,category) /epoc32/rom/config/confml_data/##category##/config/##file + +#define APP_LAYER_CONFML(exported) CONFML_EXPORT_PATH(exported,s60) +#define APP_LAYER_CRML(exported) CRML_EXPORT_PATH(exported,s60) +#define APP_LAYER_GCFML(exported) GCFML_EXPORT_PATH(exported,s60) +#define APP_LAYER_CONFML_CONFIG(exported) CONFML_CONFIG_EXPORT_PATH(exported,s60) + +#define MW_LAYER_CONFML(exported) CONFML_EXPORT_PATH(exported,s60) +#define MW_LAYER_CRML(exported) CRML_EXPORT_PATH(exported,s60) +#define MW_LAYER_GCFML(exported) GCFML_EXPORT_PATH(exported,s60) +#define MW_LAYER_CONFML_CONFIG(exported) CONFML_CONFIG_EXPORT_PATH(exported,s60) + +// Deprecate: Use the OS_LAYER_* macros instead of OSEXT_LAYER_* +#define OSEXT_LAYER_CONFML(exported) CONFML_EXPORT_PATH(exported,s60) +#define OSEXT_LAYER_CRML(exported) CRML_EXPORT_PATH(exported,s60) +#define OSEXT_LAYER_GCFML(exported) GCFML_EXPORT_PATH(exported,s60) +#define OSEXT_LAYER_CONFML_CONFIG(exported) CONFML_CONFIG_EXPORT_PATH(exported,s60) +#define OS_LAYER_CONFML(exported) CONFML_EXPORT_PATH(exported,s60) +#define OS_LAYER_CRML(exported) CRML_EXPORT_PATH(exported,s60) +#define OS_LAYER_GCFML(exported) GCFML_EXPORT_PATH(exported,s60) +#define OS_LAYER_CONFML_CONFIG(exported) CONFML_CONFIG_EXPORT_PATH(exported,s60) + +#endif // end of PLATFORM_PATHS_HRH + +ENDOFTHEFILE + + close FILE; +} diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/envpatcher/ReadMe.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/envpatcher/ReadMe.txt Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,47 @@ +Environment Patcher +=================== + +Updated: 9th January 2009 + + +Introduction: +------------- +This tool can be used to patch your S60 SDK environment so that the tricks and +macros introduced in the latest SDKs can be used in a public SDK and older +OEM releases. + +This tool can perform the following tasks: +- Adds support for forward slashes in paths in bld.inf/.mmp files in S60 3.0 +- Removes an unncessary warning about DEPENDS resource keyword in an .mmp file +- Creates a missing epoc32\include\platform_paths.hrh file for supporting + platform macros introduced since S60 3.2 OEM and Symbian Foundation releases +- Modifies epoc32\include\platform_paths.hrh for missing macros +- Creates a missing epoc32\include\oem directory to suppress a possible warning + + +Usage: +------ +EnvPatcher.pl + +Where EPOCROOT is the path to the root of the SDK, for example: + EnvPatcher.pl c:\Symbian\9.1\S60_3rd_MR + EnvPatcher.pl z:\ + + +Requirements: +------------- +- S60 SDK (public or OEM), version 3.0 or newer +- Perl 5.6.1 or newer + + + + +Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights +reserved. + +This material, including documentation and any related computer programs, is +protected by copyright controlled by Nokia. All rights are reserved. Copying, +including reproducing, storing, adapting or translating, any or all of this +material requires the prior written consent of Nokia. This material also +contains confidential information which may not be disclosed to others without +the prior written consent of Nokia. diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/group/ReleaseNotes_LoadGen.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/group/ReleaseNotes_LoadGen.txt Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,140 @@ +=============================================================================== + +RELEASE NOTES - LOAD GENERATOR v1.6.0 +RELEASED 8th October 2010 + +SUPPORTS S60 3.0+ + +=============================================================================== + +Product Description: +==================== +LoadGen is an S60 UI application that provides an easy way to generate load +into a device. You can use LoadGen to simulate the behavior and possible +problems of a device when put under a heavy load in actual usage scenarios. + +Main Features: +============== +- Load types: + - CPU load (yielding or blocking) + - Memory eat (RAM and disks) + - Phone calls + - Network connection + - Key press + - SMS and MMS sending + - Launching applications + - Photo captures + - Bluetooth device discovery + - Touch UI pointer events +- Each load type can be executed periodically (that is, idle time can be + applied after each round) +- Each started load will be run in a separate thread +- Each load type can be paused/resumed and stopped + +=============================================================================== + +What's New in v1.6.0 +==================== +- New LoadGen icons +- Bug fixes + + +What's New in v1.5.0 +==================== +- Feature: Orbit UI introduced + + +=============================================================================== + +Installation Notes: +=================== +LoadGen is typically preinstalled on ROM. If not, it can be added to the +ROM with the .iby file. Alternatively, the .sis file can be found under the sis- +directory, but the user need to sign it with their own developer certificate. +In Nokia R&D environment, you can use directly the R&D-signed .sis file under the +internal\sis directory. + +When signing with own developer certificate, the following capabilities are +needed: + NetworkServices + SwEvent + ReadUserData + WriteUserData + +When builing LoadGen against S60 3.0 or 3.1, you may need to patch your SDK +environment first with some fixes. For more information, please refer to the +instructions under the "envpatcher" directory. + +=============================================================================== + +System Requirements: +==================== +Basic Requirements: +- Any S60 3.x device or emulator environment + +=============================================================================== + +Compatibility Issues: +===================== +N/A + +=============================================================================== + +Known Issues: +============= +- Launched applications are not always terminated by LoadGen. This occurs with + applications that are waiting for user input. + +=============================================================================== + +Version History: +================ + +Version 1.4.0 +==================== +- Feature: New load: Photo capture. +- Feature: New load: Bluetooth actions. +- Feature: New load: Pointer (touch ui) events. + +Version 1.3.0 - 30th June 2009 +============================== +- Feature: SMP support: CPU can be selected for CPU load. + +Version 1.2.1 - 6th March 2009 +============================== +- Fix: Messages load crashes Load Generator + +Version 1.2.0 - 20th February 2009 +================================== +- Feature: New load: application launch +- Fix: LoadGen crashes when changing the Type of CPU load + +Version 1.1.0 - 12th December 2008 +================================== +- Feature: SMS and MMS messages can be sent +- Fix: It was not possible to eat more memory than 2GB + +Version 1.0.1 - 18th March 2008 +=============================== +- Fix: It was possible to edit source type for existing memory eat item +- Fix: Thread priority was not changed when editing existing item +- Fix: Memory eat did not work properly or caused crash in some cases +- Fix: Editing existing memory eat replaced values with default values +- Fix: Memory about queries did not have any check for maximum value +- Fix: Stopping a crashed load crashed the whole application + + +Version 1.0.0 - 6th March 2008 +------------------------------ +- Initial version + +=============================================================================== + + Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). + All rights reserved. + This component and the accompanying materials are made available + under the terms of "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/group/backup_registration.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/group/backup_registration.xml Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,8 @@ + + + + + + + + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/group/bld.inf Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,32 @@ +// ============================================================================ +// * Makefile for building: group +// * Generated by qmake (2.01a) (Qt 4.6.3) on: 2010-06-17T13:18:03 +// * This file is generated by qmake and should not be modified by the +// * user. +// * Project: group.pro +// * Template: subdirs +// ============================================================================ + +#define BLD_INF_GROUP_037FC092 + + +prj_platforms + +WINSCW GCCE ARMV5 ARMV6 +#include "bld_generic.inf" +#include "../ui/avkon/group/bld.inf" + + +prj_mmpfiles + + +prj_extensions + + +#if defined(WINSCW) +#endif + +START EXTENSION qt/qmake_store_build +END + + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/group/bld_generic.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/group/bld_generic.inf Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include + + +PRJ_EXPORTS +../group/backup_registration.xml Z:/private/20011384/backup_registration.xml + + + +PRJ_MMPFILES +#if defined(__SERIES60_30__) || defined(__SERIES60_31__) || defined(__S60_32__) + gnumakefile loadgen_icons_aif.mk + gnumakefile loadgen_extraicons.mk + + #ifdef MARM + gnumakefile loadgen_stub_sis.mk + #endif +#endif + + +#if(!defined __SERIES60_30__ && !defined __SERIES60_31__ && !defined __S60_32__) + PRJ_EXTENSIONS + START EXTENSION s60/mifconv + OPTION TARGETFILE loadgen_aif.mif + OPTION SOURCEDIR ../icons + OPTION SOURCES -c8,8 qgn_menu_loadgen + END + + START EXTENSION s60/mifconv + OPTION TARGETFILE loadgen_extraicons.mif + OPTION HEADERFILE loadgen_extraicons.mbg + OPTION SOURCEDIR ../icons + OPTION SOURCES -c8,8 qgn_prob_status_red -c8,8 qgn_prob_status_green + END + + #ifdef MARM + START EXTENSION app-services/buildstubsis + OPTION SRCDIR ../sis + OPTION SISNAME LoadGen_stub + END + #endif +#endif diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/group/group.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/group/group.pro Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,5 @@ + + +TEMPLATE = subdirs + +BLD_INF_RULES.prj_platforms += "$${LITERAL_HASH}include \"bld_generic.inf\"" diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/group/loadgen_extraicons.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/group/loadgen_extraicons.mk Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,60 @@ +# +# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# + +ifeq (WINS,$(findstring WINS, $(PLATFORM))) +ZDIR=\epoc32\release\$(PLATFORM)\$(CFG)\z +else +ZDIR=\epoc32\data\z +endif + +TARGETDIR=$(ZDIR)\resource\apps +ICONTARGETFILENAME=$(TARGETDIR)\loadgen_extraicons.mif + +HEADERDIR=\epoc32\include +HEADERFILENAME=$(HEADERDIR)\loadgen_extraicons.mbg + + +do_nothing : + @rem do_nothing + +MAKMAKE : do_nothing + +BLD : do_nothing + +CLEAN : + @if exist $(ICONTARGETFILENAME) erase $(ICONTARGETFILENAME) + @if exist $(HEADERFILENAME) erase $(HEADERFILENAME) + +LIB : do_nothing + +CLEANLIB : do_nothing + +RESOURCE : $(ICONTARGETFILENAME) + +$(ICONTARGETFILENAME) (HEADERFILENAME) : ..\icons\qgn_prob_status_red.svg ..\icons\qgn_prob_status_green.svg + mifconv $(ICONTARGETFILENAME) /h$(HEADERFILENAME) \ + /c8,8 ..\icons\qgn_prob_status_red.svg \ + /c8,8 ..\icons\qgn_prob_status_green.svg + +FREEZE : do_nothing + +SAVESPACE : do_nothing + +RELEASABLES : + @echo $(HEADERFILENAME) && \ + @echo $(ICONTARGETFILENAME) + +FINAL : do_nothing diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/group/loadgen_icons_aif.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/group/loadgen_icons_aif.mk Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,54 @@ +# +# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# + +ifeq (WINS,$(findstring WINS, $(PLATFORM))) +ZDIR=\epoc32\release\$(PLATFORM)\$(CFG)\z +else +ZDIR=\epoc32\data\z +endif + +TARGETDIR=$(ZDIR)\resource\apps +ICONTARGETFILENAME=$(TARGETDIR)\loadgen_aif.mif + + +do_nothing : + @rem do_nothing + +MAKMAKE : do_nothing + +BLD : do_nothing + +CLEAN : + @if exist $(ICONTARGETFILENAME) erase $(ICONTARGETFILENAME) + +LIB : do_nothing + +CLEANLIB : do_nothing + +RESOURCE : $(ICONTARGETFILENAME) + +$(ICONTARGETFILENAME) : ..\icons\qgn_menu_loadgen.svg + mifconv $(ICONTARGETFILENAME) \ + /c8,8 ..\icons\qgn_menu_loadgen.svg + +FREEZE : do_nothing + +SAVESPACE : do_nothing + +RELEASABLES : + @echo $(ICONTARGETFILENAME) + +FINAL : do_nothing diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/group/loadgen_stub_sis.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/group/loadgen_stub_sis.mk Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,56 @@ +# +# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# + + +TARGETDIR=$(EPOCROOT)EPOC32\Data\Z\System\Install + +SISNAME=LoadGen_stub +PKGNAME=LoadGen_stub + +$(TARGETDIR) : + @perl -S emkdir.pl "$(TARGETDIR)" + +do_nothing : + rem do_nothing + +SISFILE=$(TARGETDIR)\$(SISNAME).sis + +$(SISFILE) : ..\sis\$(PKGNAME).pkg + makesis -s $? $@ + + + +MAKMAKE : do_nothing + +RESOURCE : do_nothing + +SAVESPACE : do_nothing + +BLD : do_nothing + +FREEZE : do_nothing + +LIB : do_nothing + +CLEANLIB : do_nothing + +FINAL : $(TARGETDIR) $(SISFILE) + +CLEAN : + @if exist $(SISFILE) erase $(SISFILE) + +RELEASABLES : + @echo $(SISFILE) diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/icons/LoadGen_application_icon_svgt.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/icons/LoadGen_application_icon_svgt.svg Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/icons/mono_new_load.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/icons/mono_new_load.svg Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,10 @@ + + + + + + + + + + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/icons/mono_resume_all.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/icons/mono_resume_all.svg Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,7 @@ + + + + + + + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/icons/mono_stop_all.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/icons/mono_stop_all.svg Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,9 @@ + + + + + + + + + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/icons/mono_suspend_all.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/icons/mono_suspend_all.svg Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,9 @@ + + + + + + + + + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/icons/qgn_menu_loadgen.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/icons/qgn_menu_loadgen.svg Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/icons/qgn_prob_status_green.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/icons/qgn_prob_status_green.svg Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/icons/qgn_prob_status_red.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/icons/qgn_prob_status_red.svg Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/loadgen.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/loadgen.pro Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,24 @@ +# +# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# +# + + +TEMPLATE = subdirs + +DEFINES += QT_NO_DEBUG_OUTPUT QT_NO_WARNING_OUTPUT QT_NO_DEBUG + +SUBDIRS = group \ + ui/hb diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/sis/LoadGen_S60-30.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/sis/LoadGen_S60-30.pkg Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,38 @@ +; +; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; + +; Language - standard language definitions +&EN + +; Standard SIS file header +#{"LoadGen"},(0x20011384),1,4,0,TYPE=SA + +; Supports S60 v 3.0 +[0x101F7961], 0, 0, 0, {"S60ProductID"} + +; Non-localised vendor name +:"Nokia Corporation" + +; Localised vendor names +%{"Nokia Corporation"} + +; normal stuff: +"\epoc32\RELEASE\armv5\UREL\LoadGen.exe"-"!:\sys\bin\LoadGen.exe" +"\epoc32\data\z\Resource\apps\LoadGen_aif.mif"-"!:\Resource\Apps\LoadGen_aif.mif" +"\epoc32\data\z\Resource\apps\LoadGen_ExtraIcons.mif"-"!:\Resource\Apps\LoadGen_ExtraIcons.mif" +"\epoc32\data\z\Resource\apps\LoadGen.rsc"-"!:\Resource\Apps\LoadGen.rsc" +"\epoc32\data\z\PRIVATE\10003A3F\APPS\LoadGen_reg.rsc"-"!:\private\10003a3f\import\apps\LoadGen_reg.rsc" +"..\group\backup_registration.xml"-"!:\private\20011384\backup_registration.xml" diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/sis/LoadGen_S60-30.sis Binary file utilityapps/loadgen/sis/LoadGen_S60-30.sis has changed diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/sis/LoadGen_stub.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/sis/LoadGen_stub.pkg Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,37 @@ +; +; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; + + +; Language - standard language definitions +&EN + +; Standard SIS file header +#{"LoadGen"},(0x20011384),1,0,0 + +; Non-localised vendor name +:"Nokia Corporation" + +; Localised vendor names +%{"Nokia Corporation"} + +; normal stuff: +""-"z:\sys\bin\LoadGen.exe" +""-"z:\Resource\Apps\LoadGen.mif" +""-"z:\Resource\Apps\LoadGen_aif.mif" +""-"z:\Resource\Apps\LoadGen_ExtraIcons.mif" +""-"z:\Resource\Apps\LoadGen.rsc" +""-"z:\private\10003a3f\import\apps\LoadGen_reg.rsc" +""-"z:\private\20011384\backup_registration.xml" diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/ui/avkon/data/loadgen.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/ui/avkon/data/loadgen.rss Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,1421 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +NAME MATT + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "loadgen.hrh" +#include "loadgen_std.h" + + +// --------------------------------------------------------- +// +// Define the resource file signature +// This resource should be empty. +// +// --------------------------------------------------------- +// +RESOURCE RSS_SIGNATURE { } + +// --------------------------------------------------------- +// +// Default Document Name +// +// --------------------------------------------------------- +// +RESOURCE TBUF r_default_document_name { buf=""; } + +// --------------------------------------------------------- +// +// Define default menu and CBA key. +// +// --------------------------------------------------------- +// +RESOURCE EIK_APP_INFO + { + //status_pane = r_loadgen_status_pane; + //menubar = r_loadgen_menubar; + //cba = R_AVKON_SOFTKEYS_OPTIONS_EXIT; + } + + +//---------------------------------------------------- +// +// r_loadgen_hotkeys +// +//---------------------------------------------------- +// +RESOURCE HOTKEYS r_loadgen_hotkeys + { + control= + { + HOTKEY { command=EAknCmdExit; key='e'; } + }; + } + + +//---------------------------------------------------- +// r_loadgen_view_main +//---------------------------------------------------- +// +RESOURCE AVKON_VIEW r_loadgen_view_main + { + hotkeys=r_loadgen_hotkeys; + menubar=r_loadgen_menubar_view_main; + cba=R_AVKON_SOFTKEYS_OPTIONS_EXIT; + } + +//---------------------------------------------------- +// r_loadgen_menubar_view_main +//---------------------------------------------------- +// +RESOURCE MENU_BAR r_loadgen_menubar_view_main + { + titles= + { + MENU_TITLE { menu_pane=r_loadgen_app_menu; txt="App"; }, + MENU_TITLE { menu_pane=r_loadgen_view_main_menu; txt="Main"; } + }; + } + +//---------------------------------------------------- +// r_loadgen_view_main_menu +//---------------------------------------------------- +// + +RESOURCE MENU_PANE r_loadgen_view_main_menu + { + items= + { + }; + } + + + +//---------------------------------------------------- +// r_loadgen_app_menu +//---------------------------------------------------- +// +RESOURCE MENU_PANE r_loadgen_app_menu + { + items= + { + MENU_ITEM { command=ELoadGenCmdNewLoad; txt="New load"; cascade=r_loadgen_newload_submenu; }, + MENU_ITEM { command=ELoadGenStopAll; txt="Stop all"; }, + MENU_ITEM { command=ELoadGenSuspendAll; txt="Suspend all"; }, + MENU_ITEM { command=ELoadGenResumeAll; txt="Resume all"; }, + MENU_ITEM { command=ELoadGenCmdLaunchPerfMon; txt="Launch PerfMon"; }, + MENU_ITEM { command=ELoadGenCmdAbout; txt="About"; }, + MENU_ITEM { command=EAknCmdExit; txt="Exit"; } + }; + } + +RESOURCE MENU_PANE r_loadgen_newload_submenu + { + items = + { + MENU_ITEM { command=ELoadGenCmdNewLoadCPULoad; txt="CPU load"; }, + MENU_ITEM { command=ELoadGenCmdNewLoadEatMemory; txt="Eat memory"; }, + MENU_ITEM { command=ELoadGenCmdNewLoadPhoneCall; txt="Phone calls"; }, + MENU_ITEM { command=ELoadGenCmdNewLoadMessages; txt="Messages"; }, + MENU_ITEM { command=ELoadGenCmdNewLoadNetConn; txt="Network conn."; }, + MENU_ITEM { command=ELoadGenCmdNewLoadKeyPress; txt="Key presses"; }, + MENU_ITEM { command=ELoadGenCmdNewLoadApplications; txt="Applications"; }, + MENU_ITEM { command=ELoadGenCmdNewLoadPhotoCaptures; txt="Photo captures"; }, + MENU_ITEM { command=ELoadGenCmdNewLoadBluetooth; txt="Bluetooth actions"; }, + MENU_ITEM { command=ELoadGenCmdNewLoadPointerEvent; txt="Pointer events"; } + }; + } + +//---------------------------------------------------- +// r_loadgen_settings_dialog +// Dialog for setting list +//---------------------------------------------------- +// +RESOURCE DIALOG r_loadgen_settings_dialog + { + flags = + EEikDialogFlagNoDrag | EEikDialogFlagFillAppClientRect | + EEikDialogFlagButtonsRight | EEikDialogFlagCbaButtons | + EEikDialogFlagWait | EEikDialogFlagNoTitleBar; + buttons = R_AVKON_SOFTKEYS_OPTIONS_BACK; + items = + { + DLG_LINE + { + type = EAknCtSettingListBox; + id = ELoadGenSettingItemList; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = LISTBOX + { + flags = EAknListBoxSelectionList; + }; + } + }; + } + +//---------------------------------------------------- +// r_loadgen_settings_menubar +//---------------------------------------------------- +// + +RESOURCE MENU_BAR r_loadgen_settings_menubar + { + titles = + { + MENU_TITLE + { + menu_pane = r_loadgen_settings_menupane; + txt = " "; // dummy + } + }; + } + +RESOURCE MENU_PANE r_loadgen_settings_menupane + { + items = + { + MENU_ITEM + { + command = ELoadGenCmdSettingsChange; + txt = "Change"; + }, + MENU_ITEM + { + command = ELoadGenCmdSettingsExit; + txt = "Exit"; + } + }; + } + + + + +// --------------------------------------------------------- +// +// r_loadgen_about_dialog +// About dialog - show version and copyright info etc. +// +// --------------------------------------------------------- +// +RESOURCE DIALOG r_loadgen_about_dialog + { + flags = EGeneralQueryFlags | EEikDialogFlagNoBorder | EEikDialogFlagNoShadow; + buttons = R_AVKON_SOFTKEYS_OK_EMPTY; + items= + { + DLG_LINE + { + type = EAknCtPopupHeadingPane; + id = EAknMessageQueryHeaderId; + control = AVKON_HEADING + { + label = "About LoadGen"; + headinglayout = R_AVKON_WML_SIGN_QUERY_HEADING_PANE; + }; + }, + DLG_LINE + { + type = EAknCtMessageQuery; + id = EAknMessageQueryContentId; + control = AVKON_MESSAGE_QUERY + { + message = "Version 1.6.0 - 8th October 2010. Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. Licensed under Eclipse Public License v1.0."; + }; + } + }; + } + +// --------------------------------------------------------- +// r_general_confirmation_query +// --------------------------------------------------------- +// + +RESOURCE DIALOG r_general_confirmation_query + { + flags = EGeneralQueryFlags; + buttons = R_AVKON_SOFTKEYS_YES_NO; + items = + { + DLG_LINE + { + type = EAknCtQuery; + id = EGeneralQuery; + control = AVKON_CONFIRMATION_QUERY + { + layout = EConfirmationQueryLayout; + }; + } + }; + } + +// --------------------------------------------------------- +// r_general_text_query +// --------------------------------------------------------- +// +RESOURCE DIALOG r_general_text_query + { + flags = EGeneralQueryFlags; + buttons = R_AVKON_SOFTKEYS_OK_CANCEL; + items= + { + DLG_LINE + { + type = EAknCtQuery; + id = EGeneralQuery; + control = AVKON_DATA_QUERY + { + layout = EDataLayout; + control = EDWIN + { + width = 256; + lines = 3; + maxlength = 256; + }; + }; + } + }; + } + +// --------------------------------------------------------- +// r_general_text_query +// --------------------------------------------------------- +// +RESOURCE DIALOG r_general_numeric_query + { + flags = EGeneralQueryFlags; + buttons = R_AVKON_SOFTKEYS_OK_CANCEL; + items = + { + DLG_LINE + { + type = EAknCtQuery; + id = EGeneralQuery; + control= AVKON_DATA_QUERY + { + layout = ENumberLayout; + control = AVKON_INTEGER_EDWIN + { + min = -999999; + max = 999999; + }; + }; + } + }; + } + + +// --------------------------------------------------------- +// r_item_action_query +// --------------------------------------------------------- +// +RESOURCE DIALOG r_item_action_query + { + flags = EGeneralQueryFlags; + buttons = R_AVKON_SOFTKEYS_OK_CANCEL; + items = + { + AVKON_LIST_QUERY_DLG_LINE + { + control= AVKON_LIST_QUERY_CONTROL + { + listtype = EAknCtSinglePopupMenuListBox; + listbox = AVKON_LIST_QUERY_LIST + { + array_id = r_item_action_query_array; + }; + heading = ""; + }; + } + }; + } + +RESOURCE ARRAY r_item_action_query_array + { + items = + { + LBUF {txt = "Stop"; }, + LBUF {txt = "Resume/suspend"; }, + LBUF {txt = "Edit"; } + }; + } + + +// --------------------------------------------------------- +// r_cpuload_form_dialog +// --------------------------------------------------------- +// +RESOURCE DIALOG r_cpuload_form_dialog + { + flags = EAknDialogGenericFullScreen; + buttons = R_AVKON_SOFTKEYS_OK_CANCEL; + form = r_cpuload_form; + } + +RESOURCE FORM r_cpuload_form + { + flags = EEikFormEditModeOnly | EEikFormUseDoubleSpacedFormat; + items = + { + DLG_LINE + { + type = EAknCtPopupFieldText; + prompt = "Priority"; + id = ELoadGenCPULoadQueryPriority; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = POPUP_FIELD_TEXT + { + popupfield = POPUP_FIELD + { + width = 100; + }; + textarray = r_thread_priority_textarray; + active = 0; + }; + }, + DLG_LINE + { + type = EAknCtPopupFieldText; + prompt = "Load mode"; + id = ELoadGenCPULoadQueryMode; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = POPUP_FIELD_TEXT + { + popupfield = POPUP_FIELD + { + width = 100; + }; + textarray = r_cpuloadmode_textarray; + active = 0; + }; + }, + DLG_LINE + { + type = EAknCtPopupFieldText; + prompt = "Type"; + id = ELoadGenCPULoadQueryType; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = POPUP_FIELD_TEXT + { + popupfield = POPUP_FIELD + { + width = 100; + }; + textarray = r_cpuloadtype_textarray; + active = 0; + }; + } + }; + } + +RESOURCE DLG_LINE r_cpuload_dlg_line_periodic_length + { + type = EEikCtNumberEditor; + prompt = "Length (ms)"; + id = ELoadGenCPULoadQueryLength; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = NUMBER_EDITOR + { + min = 0; + max = 999999999; + }; + } + +RESOURCE DLG_LINE r_cpuload_dlg_line_periodic_idle + { + type = EEikCtNumberEditor; + prompt = "Idle (ms)"; + id = ELoadGenCPULoadQueryIdle; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = NUMBER_EDITOR + { + min = 0; + max = 999999999; + }; + } + +RESOURCE DLG_LINE r_cpuload_dlg_line_periodic_variance + { + type = EEikCtNumberEditor; + prompt = "Random variance (%)"; + id = ELoadGenCPULoadQueryVariance; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = NUMBER_EDITOR + { + min = 0; + max = 100; + }; + } + +RESOURCE DLG_LINE r_cpuload_dlg_line_cpu + { + type = EAknCtPopupFieldText; + prompt = "CPU"; + id = ELoadGenCPULoadQueryCpu; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = POPUP_FIELD_TEXT + { + popupfield = POPUP_FIELD + { + width = 100; + }; + textarray = r_cpuloadcpu_textarray; + active = 0; + }; + } + + +// --------------------------------------------------------- +// r_memoryeat_form_dialog +// --------------------------------------------------------- +// +RESOURCE DIALOG r_memoryeat_form_dialog + { + flags = EAknDialogGenericFullScreen; + buttons = R_AVKON_SOFTKEYS_OK_CANCEL; + form = r_memoryeat_form; + } + +RESOURCE FORM r_memoryeat_form + { + flags = EEikFormEditModeOnly | EEikFormUseDoubleSpacedFormat; + items = + { + DLG_LINE + { + type = EAknCtPopupFieldText; + prompt = "Priority"; + id = ELoadGenMemoryEatQueryPriority; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = POPUP_FIELD_TEXT + { + popupfield = POPUP_FIELD + { + width = 100; + }; + textarray = r_thread_priority_textarray; + active = 0; + }; + }, + DLG_LINE + { + type = EAknCtPopupFieldText; + prompt = "Source"; + id = ELoadGenMemoryEatQuerySource; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = POPUP_FIELD_TEXT + { + popupfield = POPUP_FIELD + { + width = 100; + }; + textarray = r_memoryeatsource_textarray; + active = 0; + }; + }, + DLG_LINE + { + type = EAknCtPopupFieldText; + prompt = "Type"; + id = ELoadGenMemoryEatQueryType; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = POPUP_FIELD_TEXT + { + popupfield = POPUP_FIELD + { + width = 100; + }; + textarray = r_memoryeattype_textarray; + active = 0; + }; + }, + DLG_LINE + { + type = EEikCtNumberEditor; + prompt = "Buffer (B)"; + id = ELoadGenMemoryEatQueryBuffer; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = NUMBER_EDITOR + { + min = 0; + max = 999999999; + }; + }, + DLG_LINE + { + type = EEikCtNumberEditor; + prompt = "Idle after buffer (ms)"; + id = ELoadGenMemoryEatQueryIdle; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = NUMBER_EDITOR + { + min = 0; + max = 999999999; + }; + }, + DLG_LINE + { + type = EEikCtNumberEditor; + prompt = "Random variance (%)"; + id = ELoadGenMemoryEatQueryVariance; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = NUMBER_EDITOR + { + min = 0; + max = 100; + }; + } + }; + } + +RESOURCE DLG_LINE r_memoryeat_dlg_line_amount + { + type = EEikCtEdwin; + prompt = "Amount (B)"; + id = ELoadGenMemoryEatQueryAmount; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = EDWIN + { + flags = KMultiLineExpandingEditorFlags | EEikEdwinNoLineOrParaBreaks; + maxlength = 14; + width = 6; + default_input_mode = EAknEditorNumericInputMode; + allowed_input_modes = EAknEditorNumericInputMode; + }; + } + +RESOURCE DLG_LINE r_memoryeat_dlg_line_random_min + { + type = EEikCtEdwin; + prompt = "Min to be left (B)"; + id = ELoadGenMemoryEatQueryRandomMin; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = EDWIN + { + flags = KMultiLineExpandingEditorFlags | EEikEdwinNoLineOrParaBreaks; + maxlength = 14; + width = 6; + default_input_mode = EAknEditorNumericInputMode; + allowed_input_modes = EAknEditorNumericInputMode; + }; + } + +RESOURCE DLG_LINE r_memoryeat_dlg_line_random_max + { + type = EEikCtEdwin; + prompt = "Max to be left (B)"; + id = ELoadGenMemoryEatQueryRandomMax; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = EDWIN + { + flags = KMultiLineExpandingEditorFlags | EEikEdwinNoLineOrParaBreaks; + maxlength = 14; + width = 6; + default_input_mode = EAknEditorNumericInputMode; + allowed_input_modes = EAknEditorNumericInputMode; + }; + } + + + +// --------------------------------------------------------- +// r_phonecall_form_dialog +// --------------------------------------------------------- +// +RESOURCE DIALOG r_phonecall_form_dialog + { + flags = EAknDialogGenericFullScreen; + buttons = R_AVKON_SOFTKEYS_OK_CANCEL; + form = r_phonecall_form; + } + +RESOURCE FORM r_phonecall_form + { + flags = EEikFormEditModeOnly | EEikFormUseDoubleSpacedFormat; + items = + { + DLG_LINE + { + type = EAknCtPopupFieldText; + prompt = "Priority"; + id = ELoadGenPhoneCallQueryPriority; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = POPUP_FIELD_TEXT + { + popupfield = POPUP_FIELD + { + width = 100; + }; + textarray = r_thread_priority_textarray; + active = 0; + }; + }, + DLG_LINE + { + type = EEikCtEdwin; + prompt = "Phone number"; + id = ELoadGenPhoneCallQueryDestination; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = EDWIN + { + width = 255; + maxlength = 255; + }; + }, + DLG_LINE + { + type = EEikCtNumberEditor; + prompt = "Length (ms)"; + id = ELoadGenPhoneCallQueryLength; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = NUMBER_EDITOR + { + min = 0; + max = 999999999; + }; + }, + DLG_LINE + { + type = EEikCtNumberEditor; + prompt = "Idle (ms)"; + id = ELoadGenPhoneCallQueryIdle; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = NUMBER_EDITOR + { + min = 0; + max = 999999999; + }; + }, + DLG_LINE + { + type = EEikCtNumberEditor; + prompt = "Random variance (%)"; + id = ELoadGenPhoneCallQueryVariance; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = NUMBER_EDITOR + { + min = 0; + max = 100; + }; + } + }; + } + + +// --------------------------------------------------------- +// r_netconn_form_dialog +// --------------------------------------------------------- +// +RESOURCE DIALOG r_netconn_form_dialog + { + flags = EAknDialogGenericFullScreen; + buttons = R_AVKON_SOFTKEYS_OK_CANCEL; + form = r_netconn_form; + } + +RESOURCE FORM r_netconn_form + { + flags = EEikFormEditModeOnly | EEikFormUseDoubleSpacedFormat; + items = + { + DLG_LINE + { + type = EAknCtPopupFieldText; + prompt = "Priority"; + id = ELoadGenNetConnQueryPriority; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = POPUP_FIELD_TEXT + { + popupfield = POPUP_FIELD + { + width = 100; + }; + textarray = r_thread_priority_textarray; + active = 0; + }; + }, + DLG_LINE + { + type = EEikCtEdwin; + prompt = "Destination URL"; + id = ELoadGenNetConnQueryDestination; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = EDWIN + { + width = 255; + maxlength = 255; + }; + }, + DLG_LINE + { + type = EEikCtNumberEditor; + prompt = "Idle (ms)"; + id = ELoadGenNetConnQueryIdle; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = NUMBER_EDITOR + { + min = 0; + max = 999999999; + }; + }, + DLG_LINE + { + type = EEikCtNumberEditor; + prompt = "Random variance (%)"; + id = ELoadGenNetConnQueryVariance; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = NUMBER_EDITOR + { + min = 0; + max = 100; + }; + } + }; + } + + +// --------------------------------------------------------- +// r_keypress_form_dialog +// --------------------------------------------------------- +// +RESOURCE DIALOG r_keypress_form_dialog + { + flags = EAknDialogGenericFullScreen; + buttons = R_AVKON_SOFTKEYS_OK_CANCEL; + form = r_keypress_form; + } + +RESOURCE FORM r_keypress_form + { + flags = EEikFormEditModeOnly | EEikFormUseDoubleSpacedFormat; + items = + { + DLG_LINE + { + type = EAknCtPopupFieldText; + prompt = "Priority"; + id = ELoadGenKeyPressQueryPriority; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = POPUP_FIELD_TEXT + { + popupfield = POPUP_FIELD + { + width = 100; + }; + textarray = r_thread_priority_textarray; + active = 0; + }; + }, + DLG_LINE + { + type = EEikCtNumberEditor; + prompt = "Heartbeat (ms)"; + id = ELoadGenKeyPressQueryHeartBeat; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = NUMBER_EDITOR + { + min = 0; + max = 999999999; + }; + }, + DLG_LINE + { + type = EEikCtNumberEditor; + prompt = "Random variance (%)"; + id = ELoadGenKeyPressQueryVariance; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = NUMBER_EDITOR + { + min = 0; + max = 100; + }; + } + }; + } + +// --------------------------------------------------------- +// r_pointerevent_form_dialog +// --------------------------------------------------------- +// +RESOURCE DIALOG r_pointerevent_form_dialog + { + flags = EAknDialogGenericFullScreen; + buttons = R_AVKON_SOFTKEYS_OK_CANCEL; + form = r_pointerevent_form; + } + +RESOURCE FORM r_pointerevent_form + { + flags = EEikFormEditModeOnly | EEikFormUseDoubleSpacedFormat; + items = + { + DLG_LINE + { + type = EAknCtPopupFieldText; + prompt = "Priority"; + id = ELoadGenPointerEventQueryPriority; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = POPUP_FIELD_TEXT + { + popupfield = POPUP_FIELD + { + width = 100; + }; + textarray = r_thread_priority_textarray; + active = 0; + }; + }, + DLG_LINE + { + type = EEikCtNumberEditor; + prompt = "Heartbeat (ms)"; + id = ELoadGenPointerEventQueryHeartBeat; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = NUMBER_EDITOR + { + min = 0; + max = 999999999; + }; + }, + DLG_LINE + { + type = EEikCtNumberEditor; + prompt = "Random variance (%)"; + id = ELoadGenPointerEventQueryVariance; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = NUMBER_EDITOR + { + min = 0; + max = 100; + }; + } + }; + } + +// --------------------------------------------------------- +// r_messages_form_dialog +// --------------------------------------------------------- +// +RESOURCE DIALOG r_messages_form_dialog + { + flags = EAknDialogGenericFullScreen; + buttons = R_AVKON_SOFTKEYS_OK_CANCEL; + form = r_messages_form; + } + +RESOURCE FORM r_messages_form + { + flags = EEikFormEditModeOnly | EEikFormUseDoubleSpacedFormat; + items = + { + DLG_LINE + { + type = EAknCtPopupFieldText; + prompt = "Priority"; + id = ELoadGenMessagesQueryPriority; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = POPUP_FIELD_TEXT + { + popupfield = POPUP_FIELD + { + width = 100; + }; + textarray = r_thread_priority_textarray; + active = 0; + }; + }, + DLG_LINE + { + type = EAknCtPopupFieldText; + prompt = "Type"; + id = ELoadGenMessagesQueryType; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = POPUP_FIELD_TEXT + { + popupfield = POPUP_FIELD + { + width = 100; + }; + textarray = r_message_type_textarray; + active = 0; + }; + }, + DLG_LINE + { + type = EEikCtEdwin; + prompt = "Phone number"; + id = ELoadGenMessagesQueryDestination; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = EDWIN + { + width = 255; + maxlength = 255; + }; + }, + DLG_LINE + { + type = EEikCtNumberEditor; + prompt = "Maximum amount of messages"; + id = ELoadGenMessagesQueryAmount; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = NUMBER_EDITOR + { + min = 0; + max = 1000; + }; + }, + DLG_LINE + { + type = EEikCtNumberEditor; + prompt = "Message length"; + id = ELoadGenMessagesQueryLength; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = NUMBER_EDITOR + { + min = 0; + max = 512; + }; + }, + DLG_LINE + { + type = EEikCtNumberEditor; + prompt = "Idle (ms)"; + id = ELoadGenMessagesQueryIdle; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = NUMBER_EDITOR + { + min = 0; + max = 999999999; + }; + }, + DLG_LINE + { + type = EEikCtNumberEditor; + prompt = "Random variance (%)"; + id = ELoadGenMessagesQueryVariance; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = NUMBER_EDITOR + { + min = 0; + max = 100; + }; + } + }; + } + +// --------------------------------------------------------- +// r_applicatios_form_dialog +// --------------------------------------------------------- +// +RESOURCE DIALOG r_applications_form_dialog + { + flags = EAknDialogGenericFullScreen; + buttons = R_AVKON_SOFTKEYS_OK_CANCEL; + form = r_applications_form; + } + +RESOURCE FORM r_applications_form + { + flags = EEikFormEditModeOnly | EEikFormUseDoubleSpacedFormat; + items = + { + DLG_LINE + { + type = EAknCtPopupFieldText; + prompt = "Priority"; + id = ELoadGenApplicationsQueryPriority; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = POPUP_FIELD_TEXT + { + popupfield = POPUP_FIELD + { + width = 100; + }; + textarray = r_thread_priority_textarray; + active = 0; + }; + }, + DLG_LINE + { + type = EEikCtNumberEditor; + prompt = "Max parallel applications"; + id = ELoadGenApplicationsMaxOpen; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = NUMBER_EDITOR + { + min = 0; + max = 100; + }; + }, + DLG_LINE + { + type = EEikCtNumberEditor; + prompt = "Launching interval (ms)"; + id = ELoadGenApplicationsLaunchingInterval; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = NUMBER_EDITOR + { + min = 0; + max = 999999999; + }; + }, + + DLG_LINE + { + type = EAknCtPopupFieldText; + prompt = "Key press type"; + id = ELoadGenApplicationsKeyPressType; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = POPUP_FIELD_TEXT + { + popupfield = POPUP_FIELD + { + width = 100; + }; + textarray = r_applications_keypress_type_textarray; + active = 0; + }; + }, + DLG_LINE + { + type = EEikCtNumberEditor; + prompt = "Key press interval (ms)"; + id = ELoadGenApplicationsKeyPressQueryHeartBeat; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = NUMBER_EDITOR + { + min = 0; + max = 999999999; + }; + }, + DLG_LINE + { + type = EEikCtNumberEditor; + prompt = "Random variance (%)"; + id = ELoadGenApplicationsQueryVariance; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = NUMBER_EDITOR + { + min = 0; + max = 100; + }; + } + }; + } + +// --------------------------------------------------------- +// r_photocapture_form_dialog +// --------------------------------------------------------- +// +RESOURCE DIALOG r_photocapture_form_dialog + { + flags = EAknDialogGenericFullScreen; + buttons = R_AVKON_SOFTKEYS_OK_CANCEL; + form = r_photocapture_form; + } + +RESOURCE FORM r_photocapture_form + { + flags = EEikFormEditModeOnly | EEikFormUseDoubleSpacedFormat; + items = + { + DLG_LINE + { + type = EAknCtPopupFieldText; + prompt = "Priority"; + id = ELoadGenPhotoCaptureQueryPriority; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = POPUP_FIELD_TEXT + { + popupfield = POPUP_FIELD + { + width = 100; + }; + textarray = r_thread_priority_textarray; + active = 0; + }; + }, + DLG_LINE + { + type = EEikCtNumberEditor; + prompt = "Idle (ms)"; + id = ELoadGenPhotoCaptureQueryIdle; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = NUMBER_EDITOR + { + min = 0; + max = 999999999; + }; + }, + DLG_LINE + { + type = EEikCtNumberEditor; + prompt = "Random variance (%)"; + id = ELoadGenPhotoCaptureQueryVariance; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = NUMBER_EDITOR + { + min = 0; + max = 100; + }; + } + }; + } + +/*RESOURCE DLG_LINE r_photocapture_dlg_line_periodic_idle + { + type = EEikCtNumberEditor; + prompt = "Idle (ms)"; + id = ELoadGenPhotoCaptureQueryIdle; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = NUMBER_EDITOR + { + min = 0; + max = 999999999; + }; + } + +RESOURCE DLG_LINE r_photocapture_dlg_line_periodic_variance + { + type = EEikCtNumberEditor; + prompt = "Random variance (%)"; + id = ELoadGenPhotoCaptureQueryVariance; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = NUMBER_EDITOR + { + min = 0; + max = 100; + }; + }*/ + +RESOURCE DLG_LINE r_photocapture_dlg_line_device + { + type = EAknCtPopupFieldText; + prompt = "Device"; + id = ELoadGenPhotoCaptureQueryDevice; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = POPUP_FIELD_TEXT + { + popupfield = POPUP_FIELD + { + width = 100; + }; + textarray = r_photocapturedevice_textarray; + active = 0; + }; + } + +// --------------------------------------------------------- +// r_photocapture_form_dialog +// --------------------------------------------------------- +// +RESOURCE DIALOG r_bluetooth_form_dialog + { + flags = EAknDialogGenericFullScreen; + buttons = R_AVKON_SOFTKEYS_OK_CANCEL; + form = r_bluetooth_form; + } + +RESOURCE FORM r_bluetooth_form + { + flags = EEikFormEditModeOnly | EEikFormUseDoubleSpacedFormat; + items = + { + DLG_LINE + { + type = EAknCtPopupFieldText; + prompt = "Priority"; + id = ELoadGenBluetoothQueryPriority; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = POPUP_FIELD_TEXT + { + popupfield = POPUP_FIELD + { + width = 100; + }; + textarray = r_thread_priority_textarray; + active = 0; + }; + }, + DLG_LINE + { + type = EEikCtNumberEditor; + prompt = "Idle (ms)"; + id = ELoadGenBluetoothQueryIdle; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = NUMBER_EDITOR + { + min = 0; + max = 999999999; + }; + }, + DLG_LINE + { + type = EEikCtNumberEditor; + prompt = "Random variance (%)"; + id = ELoadGenBluetoothQueryVariance; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = NUMBER_EDITOR + { + min = 0; + max = 100; + }; + } + }; + } + +// --------------------------------------------------------- +// Arrays for forms: + +RESOURCE ARRAY r_thread_priority_textarray + { + items = + { + LBUF { txt = "Much less (-20)"; }, + LBUF { txt = "Less (-10)"; }, + LBUF { txt = "Normal (0)"; }, + LBUF { txt = "More (10)"; }, + LBUF { txt = "Much more (20)"; }, + LBUF { txt = "Real time (30)"; }, + LBUF { txt = "Abs. very low (100)"; }, + LBUF { txt = "Abs. low (200)"; }, + LBUF { txt = "Abs. backgr. (300)"; }, + LBUF { txt = "Abs. foregr. (400)"; }, + LBUF { txt = "Abs. high (500)"; } + }; + } + +RESOURCE ARRAY r_cpuloadmode_textarray + { + items = + { + LBUF { txt = "Yielding"; }, + LBUF { txt = "Blocking"; } + }; + } + +RESOURCE ARRAY r_cpuloadtype_textarray + { + items = + { + LBUF { txt = "Continuous"; }, + LBUF { txt = "Periodic"; } + }; + } + +RESOURCE ARRAY r_cpuloadcpu_textarray + { + items = + { + LBUF { txt = "CPU0"; } + }; + } + +RESOURCE ARRAY r_memoryeatsource_textarray + { + items = + { + LBUF { txt = "RAM"; }, + LBUF { txt = "C:"; }, + LBUF { txt = "D:"; }, + LBUF { txt = "E:"; }, + LBUF { txt = "F:"; }, + LBUF { txt = "G:"; }, + LBUF { txt = "H:"; }, + LBUF { txt = "I:"; }, + LBUF { txt = "J:"; }, + LBUF { txt = "K:"; }, + LBUF { txt = "L:"; }, + LBUF { txt = "M:"; }, + LBUF { txt = "N:"; } + }; + } + +RESOURCE ARRAY r_memoryeattype_textarray + { + items = + { + LBUF { txt = "Memory to eat"; }, + LBUF { txt = "Memory to be left"; }, + LBUF { txt = "Alternate min/max"; } + }; + } + +RESOURCE ARRAY r_message_type_textarray + { + items = + { + LBUF { txt = "SMS"; }, + LBUF { txt = "MMS"; } + }; + } + +RESOURCE ARRAY r_applications_keypress_type_textarray + { + items = + { + LBUF { txt = "None"; }, + LBUF { txt = "Arrow keys"; } + }; + } + +RESOURCE ARRAY r_photocapturedevice_textarray + { + items = + { + LBUF { txt = "Camera 1"; } + }; + } + + +RESOURCE LOCALISABLE_APP_INFO r_loadgen_localisable_app_info + { + short_caption = "LoadGen"; + caption_and_icon = + CAPTION_AND_ICON_INFO + { + caption = "Load Gener."; + + number_of_icons = 1; + + // Note for ROM-based apps it is recommended to add the drive letter + // icon_file = "z:"APP_BITMAP_DIR"\\myapp_aif.mif"; + icon_file = APP_BITMAP_DIR"\\loadgen_aif.mif"; + }; + } + + + +// --------------------------------------------------------- +// +// RESOURCE LOCALISABLE_APP_INFO +// +// --------------------------------------------------------- +// diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/ui/avkon/data/loadgen_reg.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/ui/avkon/data/loadgen_reg.rss Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +#include +#include +#include + + +UID2 KUidAppRegistrationResourceFile +UID3 0x20011384 + + +RESOURCE APP_REGISTRATION_INFO + { + app_file = "LoadGen"; + localisable_resource_file = APP_RESOURCE_DIR"\\LoadGen"; + localisable_resource_id = R_LOADGEN_LOCALISABLE_APP_INFO; + group_name = "RnD Tools"; + } diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/ui/avkon/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/ui/avkon/group/bld.inf Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,43 @@ +/* +* ============================================================================ +* Name : bld.inf +* Part of : LoadGen / LoadGenUI +* Description : Build information file for project LoadGen +* Version : %version: 1 % +* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +PRJ_PLATFORMS + +WINSCW ARMV5 + + +PRJ_EXPORTS +../rom/loadgen.iby CORE_IBY_EXPORT_PATH(tools,loadgen.iby) + +PRJ_MMPFILES + + +loadgen.mmp + + +PRJ_TESTMMPFILES + + +PRJ_TESTEXPORTS + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/ui/avkon/group/loadgen.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/ui/avkon/group/loadgen.mmp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,120 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +#include +#include + + +TARGET LoadGen.exe +TARGETTYPE exe +EPOCSTACKSIZE 0x5000 +EPOCHEAPSIZE 0x10000 0x1000000 // Min 64Kb, Max 16Mb + +UID 0x100039CE 0x20011384 + +VENDORID VID_DEFAULT +CAPABILITY swevent ReadUserData WriteUserData NetworkServices UserEnvironment CAP_APPLICATION AllFiles + +LANG SC + +SMPSAFE + +START RESOURCE ../data/loadgen.rss +HEADER +TARGETPATH APP_RESOURCE_DIR +END + +START RESOURCE ../data/loadgen_reg.rss +DEPENDS loadgen.rsg +TARGETPATH /private/10003a3f/apps +END + +APP_LAYER_SYSTEMINCLUDE +USERINCLUDE /epoc32/include/mw/http +USERINCLUDE ../inc +SOURCEPATH ../src + +SOURCE loadgen_app.cpp +SOURCE loadgen_document.cpp +SOURCE loadgen_appui.cpp +SOURCE loadgen_model.cpp +SOURCE loadgen_mainview.cpp +SOURCE loadgen_maincontainer.cpp +SOURCE loadgen_settingsviewdlg.cpp +SOURCE loadgen_editors.cpp + +USERINCLUDE ../../../engine/inc +SOURCEPATH ../../../engine/src + + + +SOURCE loadgen_loadbase.cpp +SOURCE loadgen_cpuload.cpp +SOURCE loadgen_memoryeat.cpp +SOURCE loadgen_phonecall.cpp +SOURCE loadgen_netconn.cpp +SOURCE loadgen_keypress.cpp +SOURCE loadgen_messages.cpp +SOURCE loadgen_applications.cpp +SOURCE loadgen_photocapture.cpp +SOURCE loadgen_bluetooth.cpp +SOURCE loadgen_pointerevent.cpp +SOURCE loadgen_utils.cpp +SOURCE loadgen_httpreceiver.cpp + +LIBRARY euser.lib +LIBRARY commonengine.lib +LIBRARY apparc.lib +LIBRARY cone.lib +LIBRARY eikcore.lib +LIBRARY eikcoctl.lib +LIBRARY eikctl.lib +LIBRARY eikdlg.lib +LIBRARY avkon.lib +LIBRARY ws32.lib +LIBRARY apgrfx.lib +LIBRARY efsrv.lib +LIBRARY bafl.lib +LIBRARY gdi.lib +LIBRARY aknicon.lib +LIBRARY aknskins.lib +LIBRARY aknskinsrv.lib +LIBRARY egul.lib +LIBRARY etel3rdparty.lib +LIBRARY downloadmgr.lib +LIBRARY commdb.lib +LIBRARY flogger.lib +LIBRARY estor.lib +LIBRARY msgs.lib +LIBRARY smcm.lib +LIBRARY gsmu.lib +LIBRARY etext.lib +LIBRARY sendas2.lib +LIBRARY ecam.lib +LIBRARY featdiscovery.lib +LIBRARY centralrepository.lib +LIBRARY esock.lib +LIBRARY bluetooth.lib +LIBRARY hal.lib +LIBRARY http.lib +LIBRARY inetprotutil.lib + +UNPAGEDDATA +SMPSAFE +// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/ui/avkon/inc/loadgen_app.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/ui/avkon/inc/loadgen_app.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef LOADGEN_APP_H +#define LOADGEN_APP_H + + +// INCLUDES +#include + +// CONSTANTS +// UID of the application +const TUid KUidLoadGen = { 0x20011384 }; + +// CLASS DECLARATION + +/** +* CLoadGenApp application class. +* Provides factory to create concrete document object. +* +*/ +class CLoadGenApp : public CAknApplication + { + + public: // Functions from base classes + /** + * From CApaApplication, overridden to enable INI file support. + * @return A pointer to the dictionary store + */ + CDictionaryStore* OpenIniFileLC(RFs& aFs) const; + private: + + /** + * From CApaApplication, creates CLoadGenDocument document object. + * @return A pointer to the created document object. + */ + CApaDocument* CreateDocumentL(); + + /** + * From CApaApplication, returns application's UID (KUidLoadGen). + * @return The value of KUidLoadGen. + */ + TUid AppDllUid() const; + }; + +#endif + +// End of File + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/ui/avkon/inc/loadgen_appui.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/ui/avkon/inc/loadgen_appui.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef LOADGEN_APPUI_H +#define LOADGEN_APPUI_H + +// INCLUDES +#include +#include +#include +#include +#include +#include +#include +#include "loadgen_std.h" + +// FORWARD DECLARATIONS +class CLoadGenModel; +class CAknNavigationControlContainer; +class CAknTabGroup; +class CAknNavigationDecorator; + + +// CLASS DECLARATIONS + +class CLoadGenAppUi : public CAknViewAppUi + { +public: // constructors and destructor + void ConstructL(); + ~CLoadGenAppUi(); + +private: // From MEikMenuObserver + void DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane); + +private: + void HandleCommandL(TInt aCommand); + + virtual TKeyResponse HandleKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType); + +private: //Data + CLoadGenModel* iModel; + CAknNavigationControlContainer* iNaviPane; + CAknTabGroup* iTabGroup; + CAknNavigationDecorator* iDecoratedTabGroup; + }; + +#endif + +// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/ui/avkon/inc/loadgen_document.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/ui/avkon/inc/loadgen_document.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,77 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef LOADGEN_DOCUMENT_H +#define LOADGEN_DOCUMENT_H + +// INCLUDES +#include + +// CONSTANTS + +// FORWARD DECLARATIONS +class CEikAppUi; +class CLoadGenModel; + + +// CLASS DECLARATION + +/** +* CLoadGenDocument application class. +*/ +class CLoadGenDocument : public CAknDocument + { + public: // Constructors and destructor + static CLoadGenDocument* NewL(CEikApplication& aApp); + virtual ~CLoadGenDocument(); + + public: // New functions + + public:// from CEikDocument + CFileStore* OpenFileL(TBool aDoOpen,const TDesC& aFilename,RFs& aFs); + protected: // New functions + + protected: // Functions from base classes + + private: + + /** + * EPOC default constructor. + */ + CLoadGenDocument(CEikApplication& aApp); + void ConstructL(); + + private: + + /** + * From CEikDocument, create CLoadGenAppUi "App UI" object. + */ + CEikAppUi* CreateAppUiL(); + + public: + inline CLoadGenModel* Model() { return iModel; } + + private: + CLoadGenModel* iModel; + + }; + +#endif + +// End of File + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/ui/avkon/inc/loadgen_editors.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/ui/avkon/inc/loadgen_editors.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,339 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef LOADGEN_EDITORS_H +#define LOADGEN_EDITORS_H + +// INCLUDES +#include +#include +#include + +#include "loadgen_loadattributes.h" + + +// FORWARD DECLARATIONS +class CAknQueryValueText; +class CAknQueryValueTextArray; + +// CLASS DECLARATIONS + +class CLoadGenLoadTypeEditorBase : public CAknForm + { +protected: // Constructors + CLoadGenLoadTypeEditorBase(TBool aEditingExisting); + void ConstructL(const TDesC& aTitleText); + +protected: // From CEikDialog + TBool OkToExitL(TInt aButtonId); + void PreLayoutDynInitL(); + void HandleControlStateChangeL(TInt aControlId); + +protected: // New methods + virtual TBool DoRunQueryLD(TInt aResource); + +public: // New methods + virtual TBool RunQueryLD(); + +protected: // New methods + void InsertFieldAfterL(TInt aResourceId, TInt aControlId, TInt aPrevControlId); + void UpdateFormL(); + +protected: // Data + TBool iEditingExisting; + }; + + + + +class CLoadGenCPULoadEditor : public CLoadGenLoadTypeEditorBase + { +public: + static CLoadGenCPULoadEditor* NewL(TCPULoadAttributes& aAttributes, TBool aEditingExisting=EFalse); + virtual ~CLoadGenCPULoadEditor(); + +private: // Constructors + CLoadGenCPULoadEditor(TCPULoadAttributes& aAttributes, TBool aEditingExisting=EFalse); + void ConstructL(); + +protected: // From CEikDialog + TBool OkToExitL(TInt aButtonId); + void PreLayoutDynInitL(); + void HandleControlStateChangeL(TInt aControlId); + +public: // New methods + virtual TBool RunQueryLD(); + +private: // New methods + void UpdateVisibilitiesOfFieldsL(TBool aFormInit=EFalse); + void LoadCPUsL(); + +private: // Data + TCPULoadAttributes& iAttributes; + CAknQueryValueText* iCpuQueryValText; + CAknQueryValueTextArray* iCpuTextArray; + CDesCArray* iCPUsArray; + }; + + + + +class CLoadGenMemoryEatEditor : public CLoadGenLoadTypeEditorBase + { +public: + static CLoadGenMemoryEatEditor* NewL(TMemoryEatAttributes& aAttributes, TBool aEditingExisting=EFalse); + virtual ~CLoadGenMemoryEatEditor(); + +private: // Constructors + CLoadGenMemoryEatEditor(TMemoryEatAttributes& aAttributes, TBool aEditingExisting=EFalse); + void ConstructL(); + +protected: // From CEikDialog + TBool OkToExitL(TInt aButtonId); + void PreLayoutDynInitL(); + void HandleControlStateChangeL(TInt aControlId); + +public: // New methods + virtual TBool RunQueryLD(); + +private: // New methods + void UpdateVisibilitiesOfFieldsL(TBool aFormInit=EFalse); + void UpdateAvailableMemoryL(); + +private: // Data + TMemoryEatAttributes& iAttributes; + }; + + + +class CLoadGenPhoneCallEditor : public CLoadGenLoadTypeEditorBase + { +public: + static CLoadGenPhoneCallEditor* NewL(TPhoneCallAttributes& aAttributes, TBool aEditingExisting=EFalse); + virtual ~CLoadGenPhoneCallEditor(); + +private: // Constructors + CLoadGenPhoneCallEditor(TPhoneCallAttributes& aAttributes, TBool aEditingExisting=EFalse); + void ConstructL(); + +protected: // From CEikDialog + TBool OkToExitL(TInt aButtonId); + void PreLayoutDynInitL(); + void HandleControlStateChangeL(TInt aControlId); + +public: // New methods + virtual TBool RunQueryLD(); + +private: // New methods + void UpdateVisibilitiesOfFieldsL(TBool aFormInit=EFalse); + +private: // Data + TPhoneCallAttributes& iAttributes; + }; + + + +class CLoadGenNetConnEditor : public CLoadGenLoadTypeEditorBase + { +public: + static CLoadGenNetConnEditor* NewL(TNetConnAttributes& aAttributes, TBool aEditingExisting=EFalse); + virtual ~CLoadGenNetConnEditor(); + +private: // Constructors + CLoadGenNetConnEditor(TNetConnAttributes& aAttributes, TBool aEditingExisting=EFalse); + void ConstructL(); + +protected: // From CEikDialog + TBool OkToExitL(TInt aButtonId); + void PreLayoutDynInitL(); + void HandleControlStateChangeL(TInt aControlId); + +public: // New methods + virtual TBool RunQueryLD(); + +private: // New methods + void UpdateVisibilitiesOfFieldsL(TBool aFormInit=EFalse); + +private: // Data + TNetConnAttributes& iAttributes; + }; + + + + +class CLoadGenKeyPressEditor : public CLoadGenLoadTypeEditorBase + { +public: + static CLoadGenKeyPressEditor* NewL(TKeyPressAttributes& aAttributes, TBool aEditingExisting=EFalse); + virtual ~CLoadGenKeyPressEditor(); + +private: // Constructors + CLoadGenKeyPressEditor(TKeyPressAttributes& aAttributes, TBool aEditingExisting=EFalse); + void ConstructL(); + +protected: // From CEikDialog + TBool OkToExitL(TInt aButtonId); + void PreLayoutDynInitL(); + void HandleControlStateChangeL(TInt aControlId); + +public: // New methods + virtual TBool RunQueryLD(); + +private: // New methods + void UpdateVisibilitiesOfFieldsL(TBool aFormInit=EFalse); + +private: // Data + TKeyPressAttributes& iAttributes; + }; + +class CLoadGenPointerEventEditor : public CLoadGenLoadTypeEditorBase + { +public: + static CLoadGenPointerEventEditor* NewL(TPointerEventAttributes& aAttributes, TBool aEditingExisting=EFalse); + virtual ~CLoadGenPointerEventEditor(); + +private: // Constructors + CLoadGenPointerEventEditor(TPointerEventAttributes& aAttributes, TBool aEditingExisting=EFalse); + void ConstructL(); + +protected: // From CEikDialog + TBool OkToExitL(TInt aButtonId); + void PreLayoutDynInitL(); + void HandleControlStateChangeL(TInt aControlId); + +public: // New methods + virtual TBool RunQueryLD(); + +private: // New methods + void UpdateVisibilitiesOfFieldsL(TBool aFormInit=EFalse); + +private: // Data + TPointerEventAttributes& iAttributes; + }; + + + +class CLoadGenMessagesEditor : public CLoadGenLoadTypeEditorBase + { +public: + static CLoadGenMessagesEditor* NewL( TMessageAttributes& aAttributes, + TBool aEditingExisting = EFalse ); + virtual ~CLoadGenMessagesEditor(); + +private: // Constructors + CLoadGenMessagesEditor( TMessageAttributes& aAttributes, + TBool aEditingExisting = EFalse ); + void ConstructL(); + +protected: // From CEikDialog + TBool OkToExitL( TInt aButtonId ); + void PreLayoutDynInitL(); + void HandleControlStateChangeL( TInt aControlId ); + +public: // New methods + virtual TBool RunQueryLD(); + +private: // New methods + void UpdateVisibilitiesOfFieldsL( TBool aFormInit = EFalse ); + +private: // Data + TMessageAttributes& iAttributes; + }; + +class CLoadGenApplicationsEditor : public CLoadGenLoadTypeEditorBase + { +public: + static CLoadGenApplicationsEditor* NewL( TApplicationsAttributes& aAttributes, + TBool aEditingExisting = EFalse ); + virtual ~CLoadGenApplicationsEditor(); + +private: // Constructors + CLoadGenApplicationsEditor( TApplicationsAttributes& aAttributes, + TBool aEditingExisting = EFalse ); + void ConstructL(); + +protected: // From CEikDialog + TBool OkToExitL( TInt aButtonId ); + void PreLayoutDynInitL(); + void HandleControlStateChangeL( TInt aControlId ); + +public: // New methods + virtual TBool RunQueryLD(); + +private: // New methods + void UpdateVisibilitiesOfFieldsL( TBool aFormInit = EFalse ); + +private: // Data + TApplicationsAttributes& iAttributes; + }; + +class CLoadGenPhotoCaptureEditor : public CLoadGenLoadTypeEditorBase + { +public: + static CLoadGenPhotoCaptureEditor* NewL(TPhotoCaptureAttributes& aAttributes, TBool aEditingExisting=EFalse); + virtual ~CLoadGenPhotoCaptureEditor(); + +private: // Constructors + CLoadGenPhotoCaptureEditor(TPhotoCaptureAttributes& aAttributes, TBool aEditingExisting=EFalse); + void ConstructL(); + +protected: // From CEikDialog + TBool OkToExitL(TInt aButtonId); + void PreLayoutDynInitL(); + void HandleControlStateChangeL(TInt aControlId); + +public: // New methods + virtual TBool RunQueryLD(); + +private: // New methods + void UpdateVisibilitiesOfFieldsL(TBool aFormInit=EFalse); + void LoadCamerasL(); + +private: // Data + TPhotoCaptureAttributes& iAttributes; + CAknQueryValueText* iCameraQueryValText; + CAknQueryValueTextArray* iCameraTextArray; + CDesCArray* iCamerasArray; + }; + +class CLoadGenBluetoothEditor : public CLoadGenLoadTypeEditorBase + { +public: + static CLoadGenBluetoothEditor* NewL(TBluetoothAttributes& aAttributes, TBool aEditingExisting=EFalse); + virtual ~CLoadGenBluetoothEditor(); + +private: // Constructors + CLoadGenBluetoothEditor(TBluetoothAttributes& aAttributes, TBool aEditingExisting=EFalse); + void ConstructL(); + +protected: // From CEikDialog + TBool OkToExitL(TInt aButtonId); + void PreLayoutDynInitL(); + void HandleControlStateChangeL(TInt aControlId); + +public: // New methods + virtual TBool RunQueryLD(); + +private: // New methods + void UpdateVisibilitiesOfFieldsL(TBool aFormInit=EFalse); + +private: // Data + TBluetoothAttributes& iAttributes; + }; + +#endif diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/ui/avkon/inc/loadgen_maincontainer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/ui/avkon/inc/loadgen_maincontainer.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef LOADGEN_VALUESCONTAINER_H +#define LOADGEN_VALUESCONTAINER_H + +// INCLUDES +#include +#include +#include + +// FORWARD DECLARATIONS +class CLoadGenModel; +class CLoadGenCAknSingleGraphicStyleListBox; + +// CLASS DECLARATIONS + +class CLoadGenMainContainer : public CCoeControl, MCoeControlObserver, MEikListBoxObserver + { +public: + void ConstructL(const TRect& aRect); + ~CLoadGenMainContainer(); + +private: + void SizeChanged(); + TInt CountComponentControls() const; + CCoeControl* ComponentControl(TInt aIndex) const; + void Draw(const TRect& aRect) const; + void HandleResourceChange(TInt aType); + void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType); // From MEikListBoxObserver + void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType); // From MCoeControlObserver + TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType); + +public: + const CArrayFix* ListBoxSelectionIndexes(); + TInt ListBoxSelectionIndexesCount(); + void SetDefaultTitlePaneTextL(); + TInt CurrentListBoxItemIndex(); + void SetListBoxTextArrayL(CDesCArray* aTextArray); + inline CLoadGenCAknSingleGraphicStyleListBox* ListBox() { return iListBox; } + +private: + CLoadGenModel* iModel; + CLoadGenCAknSingleGraphicStyleListBox* iListBox; + }; + +class CLoadGenCAknSingleGraphicStyleListBox : public CAknSingleGraphicStyleListBox + { + void SizeChanged(); + void SizeChangedL(); + }; + +#endif + +// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/ui/avkon/inc/loadgen_mainview.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/ui/avkon/inc/loadgen_mainview.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef LOADGEN_VALUESVIEW_H +#define LOADGEN_VALUESVIEW_H + +// INCLUDES +#include + +#include "loadgen_std.h" + + + +// CONSTANTS +// UID of view +const TUid KMainViewUID = {1}; + + +// FORWARD DECLARATIONS +class CLoadGenMainContainer; +class CLoadGenModel; + + +// CLASS DECLARATION + +/** +* CLoadGenMainView view class. +* +*/ +class CLoadGenMainView : public CAknView + { + public: // Constructors and destructor + void ConstructL(); + ~CLoadGenMainView(); + + public: // Functions from base classes + TUid Id() const; + void HandleCommandL(TInt aCommand); + void HandleClientRectChange(); + + private: // From MEikMenuObserver + void DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane); + + private: // From AknView + void DoActivateL(const TVwsViewId& aPrevViewId, TUid aCustomMessageId, const TDesC8& aCustomMessage); + void DoDeactivate(); + + private: // Data + CLoadGenMainContainer* iContainer; + CLoadGenModel* iModel; + }; + +#endif + +// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/ui/avkon/inc/loadgen_model.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/ui/avkon/inc/loadgen_model.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,124 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef LOADGEN_MODEL_H +#define LOADGEN_MODEL_H + +// INCLUDES +#include +#include +#include + +#include "loadgen_loadattributes.h" + +// FORWARD DECLARATIONS +class CLoadGenMainContainer; +class CLoadGenGraphsContainer; +class CEikonEnv; +class CLoadBase; + + +typedef CArrayFixSeg CLoadItemList; + +const TUint KMaxCPUs = 4; + +// CLASS DECLARATIONS + +class TLoadGenSettings + { +public: + }; + +class CLoadGenModel : public CActive + { +private: + enum TContainerDrawState + { + EDrawStateInvalid = -1, + EDrawStateMain + }; + +public: + static CLoadGenModel* NewL(); + ~CLoadGenModel(); + void ActivateModelL(); + void DeActivateModelL(); + +private: + void RunL(); + void DoCancel(); + +private: + CLoadGenModel(); + void ConstructL(); + void LoadSettingsL(); + void EditLoadL(CLoadBase* aItem); + void DoStartNewLoadL(TInt aCommand); + void AppendToLoadItemListL(CLoadBase* aItem); + void DeleteFromLoadItemListL(TInt aIndex); + void SuspendOrResumeFromLoadItemListL(TInt aIndex); + void DeleteAllLoadItems(); + void RefreshViewL(TBool aClearSelection=ETrue); + CDesCArray* ListOfAllAppsL(); + +public: + void StopAllLoadItemsL(); + void SuspendAllLoadItemsL(); + void ResumeAllLoadItemsL(); + + TInt LoadItemCount() const; + void ShowItemActionMenuL(); + void StopSelectedOrHighlightedItemsL(); + void SuspendOrResumeSelectedOrHighlightedItemsL(); + + CDesCArray* GenerateListBoxItemTextArrayL(); + void StartNewLoadL(TInt aCommand); + void SaveSettingsL(); + void SetMainContainer(CLoadGenMainContainer* aContainer); + TInt LaunchSettingsDialogL(); + inline TLoadGenSettings& Settings() { return iSettings; } + inline CEikonEnv* EikonEnv() { return iEnv; } + inline RApaLsSession& LsSession() { return iLs; } + inline CLoadGenMainContainer* MainContainer() { return iMainContainer; } + inline TBool LoadItemsExists() { return iLoadItemList->Count() > 0; } + + +private: + RTimer iTimer; + CLoadGenMainContainer* iMainContainer; + CEikonEnv* iEnv; + TLoadGenSettings iSettings; + RApaLsSession iLs; + TInt iDrawState; + CLoadItemList* iLoadItemList; + TInt iReferenceNumber; + TCPULoadAttributes iCpuLoadAttributes; + TMemoryEatAttributes iMemoryEatAttributes; + TPhoneCallAttributes iPhoneCallAttributes; + TNetConnAttributes iNetConnAttributes; + TKeyPressAttributes iKeyPressAttributes; + TMessageAttributes iMessageAttributes; + TApplicationsAttributes iApplicationsAttributes; + TPhotoCaptureAttributes iPhotoCaptureAttributes; + TBluetoothAttributes iBluetoothAttributes; + TPointerEventAttributes iPointerEventAttributes; + static TInt64 iRandomNumberSeed; + }; + + +#endif diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/ui/avkon/inc/loadgen_settingsviewdlg.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/ui/avkon/inc/loadgen_settingsviewdlg.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,82 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef LOADGEN_SETTINGSVIEWDLG_H +#define LOADGEN_SETTINGSVIEWDLG_H + +// INCLUDES +#include +#include +#include +#include + +// FORWARD DECLARATIONS +class CAknSettingItemArray; +class CAknSettingStyleListBox; +class CAknNavigationControlContainer; +class CAknNavigationDecorator; +class CAknTabGroup; +class TLoadGenSettings; + + +// CLASS DEFINITIONS + +class CLoadGenSettingsViewDlg : public CAknDialog, public MEikListBoxObserver, public MAknTabObserver + { +public: + static CLoadGenSettingsViewDlg* NewL(TLoadGenSettings& aSettings); + virtual ~CLoadGenSettingsViewDlg(); + +public: // From MEikListBoxObserver + void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType); + +public: // From MAknTabObserver + void TabChangedL(TInt aIndex); + +public: // From CAknDialog + void ProcessCommandL(TInt aCommandId); + +protected: // From CEikDialog + TKeyResponse OfferKeyEventL(const TKeyEvent &aKeyEvent, TEventCode aType); + void PreLayoutDynInitL(); + TBool OkToExitL(TInt aButtonId); + +private: // New methods + void ShowSettingPageL(TBool aCalledFromMenu); + void SetVisibilitiesOfSettingItemsL(); + void UpdateListBoxL(); + void AddSettingItemL(TInt aId, TInt aTitleResource, TInt aSettingPageResource, TInt aAssociatedResource, TInt aOrdinal); + +private: // Constructors + CLoadGenSettingsViewDlg(TLoadGenSettings& aSettings); + void ConstructL(); + +private: // Data + CAknSettingItemArray* iSettingItemArray; + CAknSettingStyleListBox* iListBox; + CAknNavigationControlContainer* iNaviContainer; + CAknNavigationDecorator* iDecoratedTabGroup; + CAknTabGroup* iTabGroup; + TLoadGenSettings& iSettings; + }; + + +#endif + +// End of File + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/ui/avkon/rom/loadgen.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/ui/avkon/rom/loadgen.iby Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef __LOADGEN_IBY__ +#define __LOADGEN_IBY__ + +S60_APP_EXE(LoadGen) +S60_APP_AIF_ICONS(LoadGen) +S60_APP_RESOURCE(LoadGen) +SCALABLE_IMAGE(APP_BITMAP_DIR,APP_BITMAP_DIR,LoadGen_ExtraIcons) +#ifdef S60_UPGRADABLE_APP_REG_RSC + S60_UPGRADABLE_APP_REG_RSC(LoadGen) +#else + S60_APP_AIF_RSC(LoadGen) +#endif + +data=ZPRIVATE\20011384\backup_registration.xml private\20011384\backup_registration.xml +data=ZSYSTEM\Install\LoadGen_stub.sis \system\install\LoadGen_stub.sis + +#endif // __LOADGEN_IBY__ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/ui/avkon/src/loadgen_app.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/ui/avkon/src/loadgen_app.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,73 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +// INCLUDE FILES +#include "loadgen_app.h" +#include "loadgen_document.h" + +#include + + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CLoadGenApp::AppDllUid() +// Returns application UID +// --------------------------------------------------------- +// +TUid CLoadGenApp::AppDllUid() const + { + return KUidLoadGen; + } + +// --------------------------------------------------------- +// CDictionaryStore* CLoadGenApp::OpenIniFileLC(RFs& aFs) const +// overrides CAknApplication::OpenIniFileLC to enable INI file support +// --------------------------------------------------------- +// +CDictionaryStore* CLoadGenApp::OpenIniFileLC(RFs& aFs) const + { + return CEikApplication::OpenIniFileLC(aFs); + } + +// --------------------------------------------------------- +// CLoadGenApp::CreateDocumentL() +// Creates CLoadGenDocument object +// --------------------------------------------------------- +// +CApaDocument* CLoadGenApp::CreateDocumentL() + { + return CLoadGenDocument::NewL( *this ); + } + +// ================= OTHER EXPORTED FUNCTIONS ============== + +LOCAL_C CApaApplication* NewApplication() + { + return new CLoadGenApp; + } + + +GLDEF_C TInt E32Main() + { + return EikStart::RunApplication(NewApplication); + } + + +// End of File + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/ui/avkon/src/loadgen_appui.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/ui/avkon/src/loadgen_appui.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,158 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +// INCLUDE FILES +#include "loadgen_appui.h" +#include "loadgen_mainview.h" +#include "loadgen.hrh" +#include "loadgen_model.h" +#include "loadgen_document.h" +#include + +#include +#include +#include + + +// ================= MEMBER FUNCTIONS ======================= + +void CLoadGenAppUi::ConstructL() + { + // disable window server priority control for this application + iEikonEnv->WsSession().ComputeMode( RWsSession::EPriorityControlDisabled ); + + // set as system application to prevent getting shut down events + iEikonEnv->SetSystem(ETrue); + + + BaseConstructL(EAknEnableSkin); + + iModel = static_cast(reinterpret_cast(iEikonEnv->AppUi())->Document())->Model(); + + CLoadGenMainView* mainView = new(ELeave) CLoadGenMainView; + CleanupStack::PushL(mainView); + mainView->ConstructL(); + AddViewL(mainView); // transfer ownership to CAknViewAppUi + CleanupStack::Pop(); // mainView + + SetDefaultViewL(*mainView); + + // notify the model that everything has been constructed + iModel->ActivateModelL(); + } + +// -------------------------------------------------------------------------------------------- + +CLoadGenAppUi::~CLoadGenAppUi() + { + // notify the model that the application is closing + if (iModel) + TRAP_IGNORE(iModel->DeActivateModelL()); + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenAppUi::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane) + { + if (aResourceId == R_LOADGEN_APP_MENU) + { + aMenuPane->SetItemDimmed(ELoadGenStopAll, !iModel->LoadItemsExists()); + aMenuPane->SetItemDimmed(ELoadGenSuspendAll, !iModel->LoadItemsExists()); + aMenuPane->SetItemDimmed(ELoadGenResumeAll, !iModel->LoadItemsExists()); + } + } + +// -------------------------------------------------------------------------------------------- + +TKeyResponse CLoadGenAppUi::HandleKeyEventL(const TKeyEvent& /*aKeyEvent*/, TEventCode /*aType*/) + { + return EKeyWasNotConsumed; + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenAppUi::HandleCommandL(TInt aCommand) + { + switch ( aCommand ) + { + case ELoadGenCmdLaunchPerfMon: + { + // launch Performance Monitor + const TUid KUidPerfMon = { 0x20011385 }; + + RWsSession ws; + User::LeaveIfError( ws.Connect() ); + CleanupClosePushL(ws); + + RApaLsSession ls; + User::LeaveIfError( ls.Connect() ); + CleanupClosePushL(ls); + + + // try to find the task of PerfMon + TApaTaskList tasklist(ws); + TApaTask task = tasklist.FindApp(KUidPerfMon); + + if (task.Exists()) + { + // task exists, bring it to foreground + task.BringToForeground(); + } + else + { + TApaAppInfo appInfo; + User::LeaveIfError(ls.GetAppInfo(appInfo, KUidPerfMon)); + + CApaCommandLine* cmdLine = CApaCommandLine::NewLC(); + cmdLine->SetExecutableNameL(appInfo.iFullName); + cmdLine->SetCommandL(EApaCommandBackground); + + // start the app + User::LeaveIfError(ls.StartApp(*cmdLine)); + + CleanupStack::PopAndDestroy(); //cmdLine + } + + CleanupStack::PopAndDestroy(2); //ws,ls + } + break; + + case ELoadGenCmdAbout: + { + CAknMessageQueryDialog* dialog = new(ELeave) CAknMessageQueryDialog; + dialog->ExecuteLD(R_LOADGEN_ABOUT_DIALOG); + } + break; + + // a normal way to close an application + case EAknCmdExit: + case EEikCmdExit: + case EAknSoftkeyExit: + { + Exit(); + } + break; + + default: + break; + } + } + +// -------------------------------------------------------------------------------------------- + +// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/ui/avkon/src/loadgen_document.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/ui/avkon/src/loadgen_document.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,83 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +// INCLUDE FILES +#include "loadgen_document.h" +#include "loadgen_appui.h" +#include "loadgen_model.h" + +// ================= MEMBER FUNCTIONS ======================= + +// constructor +CLoadGenDocument::CLoadGenDocument(CEikApplication& aApp) +: CAknDocument(aApp) + { + } + +// ---------------------------------------------------- + +// destructor +CLoadGenDocument::~CLoadGenDocument() + { + delete iModel; + } + +// ---------------------------------------------------- + +// EPOC default constructor can leave. +void CLoadGenDocument::ConstructL() + { + iModel = CLoadGenModel::NewL(); + } + +// ---------------------------------------------------- + +// Two-phased constructor. +CLoadGenDocument* CLoadGenDocument::NewL(CEikApplication& aApp) + { + CLoadGenDocument* self = new(ELeave) CLoadGenDocument(aApp); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + + return self; + } + +// ---------------------------------------------------- +// CLoadGenDocument::CreateAppUiL() +// constructs CLoadGenAppUi +// ---------------------------------------------------- +// +CEikAppUi* CLoadGenDocument::CreateAppUiL() + { + return new (ELeave) CLoadGenAppUi; + } + +// ---------------------------------------------------- +// CLoadGenDocument::OpenFileL +// Overrides CAknDocument::OpenFileL to support document file +// ---------------------------------------------------- +// +CFileStore* CLoadGenDocument::OpenFileL(TBool aDoOpen,const TDesC& aFilename,RFs& aFs) + { + return CEikDocument::OpenFileL(aDoOpen, aFilename, aFs); + } + +// ---------------------------------------------------- + +// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/ui/avkon/src/loadgen_editors.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/ui/avkon/src/loadgen_editors.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,1437 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +// INCLUDE FILES +#include "loadgen_editors.h" +#include "loadgen_loadattributes.h" +#include "loadgen.hrh" +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// ===================================== MEMBER FUNCTIONS ===================================== + +// -------------------------------------------------------------------------------------------- + +CLoadGenLoadTypeEditorBase::CLoadGenLoadTypeEditorBase(TBool aEditingExisting): + iEditingExisting(aEditingExisting) + { + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenLoadTypeEditorBase::ConstructL(const TDesC& aTitleText) + { + CAknForm::ConstructL(); + + // set title text + CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane(); + CAknTitlePane* tp = static_cast( sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); + tp->SetTextL( aTitleText ); + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenLoadTypeEditorBase::PreLayoutDynInitL() + { + CAknForm::PreLayoutDynInitL(); + } + +// -------------------------------------------------------------------------------------------- + +TBool CLoadGenLoadTypeEditorBase::OkToExitL(TInt /*aButtonId*/) + { + return ETrue; + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenLoadTypeEditorBase::HandleControlStateChangeL(TInt aControlId) + { + CAknForm::HandleControlStateChangeL(aControlId); + } + +// -------------------------------------------------------------------------------------------- + +TBool CLoadGenLoadTypeEditorBase::RunQueryLD() + { + User::Panic(_L("Unk.form"), 222); + + return ETrue; + } + +// -------------------------------------------------------------------------------------------- + +TBool CLoadGenLoadTypeEditorBase::DoRunQueryLD(TInt aResource) + { + return ExecuteLD(aResource); + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenLoadTypeEditorBase::InsertFieldAfterL(TInt aResourceId, TInt aControlId, TInt aPrevControlId) + { + CCoeControl* prevControl = Control(aPrevControlId); + __ASSERT_DEBUG(prevControl, User::Panic(_L("Form.Ctrl.Null"), 111)); + TInt pos = FindLineIndex(*prevControl); + pos = pos + 1; + InsertLineL(pos, aResourceId); + Line(aControlId)->ActivateL(); + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenLoadTypeEditorBase::UpdateFormL() + { + UpdatePageL(ETrue); + } + +// -------------------------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------- + +CLoadGenCPULoadEditor* CLoadGenCPULoadEditor::NewL(TCPULoadAttributes& aAttributes, TBool aEditingExisting) + { + CLoadGenCPULoadEditor* self = new(ELeave) CLoadGenCPULoadEditor(aAttributes, aEditingExisting); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// -------------------------------------------------------------------------------------------- + +CLoadGenCPULoadEditor::~CLoadGenCPULoadEditor() + { + delete iCpuQueryValText; + delete iCpuTextArray; + delete iCPUsArray; + } + +// -------------------------------------------------------------------------------------------- + +CLoadGenCPULoadEditor::CLoadGenCPULoadEditor(TCPULoadAttributes& aAttributes, TBool aEditingExisting) : + CLoadGenLoadTypeEditorBase(aEditingExisting), iAttributes(aAttributes) + { + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenCPULoadEditor::ConstructL() + { + CLoadGenLoadTypeEditorBase::ConstructL(_L("CPU load")); + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenCPULoadEditor::PreLayoutDynInitL() + { + CLoadGenLoadTypeEditorBase::PreLayoutDynInitL(); + + // load values to static editors + CAknPopupFieldText* edPriority = static_cast(Control(ELoadGenCPULoadQueryPriority)); + CAknPopupFieldText* edMode = static_cast(Control(ELoadGenCPULoadQueryMode)); + CAknPopupFieldText* edType = static_cast(Control(ELoadGenCPULoadQueryType)); + edPriority->SetCurrentValueIndex(iAttributes.iPriority); + edMode->SetCurrentValueIndex(iAttributes.iMode); + edType->SetCurrentValueIndex(iAttributes.iType); + + LoadCPUsL(); + + UpdateVisibilitiesOfFieldsL(ETrue); + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenCPULoadEditor::LoadCPUsL() + { + // if we are running in SMP environment + if (iAttributes.iCpuCount > 1) + { + // insert possibility to select which cpu the load is generated to + InsertFieldAfterL(R_CPULOAD_DLG_LINE_CPU, ELoadGenCPULoadQueryCpu, ELoadGenCPULoadQueryType); + + iCPUsArray = new (ELeave) CDesCArrayFlat( 5 ); + + // "Free scheduling" means that no specific cpu is selected. Scheduler desides + // which CPUu runs load thread at which time. + iCPUsArray->AppendL(_L("Free scheduling")); + + // add CPUs + for (int i = 0; i < iAttributes.iCpuCount; i++) + { + TBuf<10> cpu; + _LIT(KCPU, "CPU%d"); + cpu.Format(KCPU, i); + iCPUsArray->AppendL(cpu); + } + + // "All CPUs" means that one thread is started for each CPU. + iCPUsArray->AppendL(_L("All CPUs")); + + iCpuTextArray = CAknQueryValueTextArray::NewL(); + iCpuTextArray->SetArray( *iCPUsArray ); + iCpuQueryValText = CAknQueryValueText::NewL(); + iCpuQueryValText->SetArrayL( iCpuTextArray ); + // CPU is not defined, set "Free scheduling" as default selection in query list + if (iAttributes.iCpu < 0) + { + iCpuQueryValText->SetCurrentValueIndex(0); + } + // "All CPUs" selected. It is last choise in the selection list. + else if (iAttributes.iCpu == KCPUSelection_AllCPUs) + { + iCpuQueryValText->SetCurrentValueIndex(iCpuTextArray->MdcaCount()-1); + } + // CPU is defined, set the correct CPU as default selection in query list + else + { + // iCpu starts from zero (i.e. CPU0 is first CPU), but index zero + // in iCpuQueryValText is "Free scheduling", hence iCpu+1. + iCpuQueryValText->SetCurrentValueIndex(iAttributes.iCpu+1); + } + + CAknPopupField* popup = static_cast(Control( ELoadGenCPULoadQueryCpu)); + popup->SetQueryValueL( iCpuQueryValText ); + } + } + +// -------------------------------------------------------------------------------------------- + +TBool CLoadGenCPULoadEditor::OkToExitL(TInt aButtonId) + { + if (aButtonId == EAknSoftkeyOk) + { + // store values from editors + CAknPopupFieldText* edPriority = static_cast(Control(ELoadGenCPULoadQueryPriority)); + CAknPopupFieldText* edMode = static_cast(Control(ELoadGenCPULoadQueryMode)); + CAknPopupFieldText* edType = static_cast(Control(ELoadGenCPULoadQueryType)); + CEikNumberEditor* edPeak = static_cast(ControlOrNull(ELoadGenCPULoadQueryLength)); + CEikNumberEditor* edIdle = static_cast(ControlOrNull(ELoadGenCPULoadQueryIdle)); + CEikNumberEditor* edVariance = static_cast(ControlOrNull(ELoadGenCPULoadQueryVariance)); + + // we are running in SMP environment + if (iAttributes.iCpuCount > 1) + { + TInt currentValueIndex = iCpuQueryValText->CurrentValueIndex(); + // user selected a specific CPU in which the load thread should be run in. + if (currentValueIndex == 0) + { + // User selected "Free scheduling" + iAttributes.iCpu = KCPUSelection_FreeScheduling; + } + else if( currentValueIndex == iCpuTextArray->MdcaCount()-1 ) + { + // User selected "All CPUs", which is the last item in the selection list + iAttributes.iCpu = KCPUSelection_AllCPUs; + } + else + { + // iCpu should start from zero (CPU0 is the first cpu) + // but zero in currentValueIndex means "Free scheduling". CPU0 in + // currentValueIndex is at index 1, hence -1. + iAttributes.iCpu = currentValueIndex - 1; + } + } + + iAttributes.iPriority = edPriority->CurrentValueIndex(); + iAttributes.iMode = edMode->CurrentValueIndex(); + iAttributes.iType = edType->CurrentValueIndex(); + if (edPeak) iAttributes.iLength = edPeak->Number(); + if (edIdle) iAttributes.iIdle = edIdle->Number(); + if (edVariance) iAttributes.iRandomVariance = edVariance->Number(); + } + + return ETrue; + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenCPULoadEditor::UpdateVisibilitiesOfFieldsL(TBool aFormInit) + { + // filter based on selected cpu load type + CAknPopupFieldText* edType = static_cast( Control( ELoadGenCPULoadQueryType ) ); + + if ( !aFormInit && edType->CurrentValueIndex() == ECpuLoadTypeContinuous ) + { + // save values before deleting the items + CCoeControl* control = ControlOrNull( ELoadGenCPULoadQueryLength ); + if ( control ) + { + CEikNumberEditor* edPeak = static_cast( control ); + iAttributes.iLength = edPeak->Number(); + DeleteLine( ELoadGenCPULoadQueryLength ); + control = NULL; + } + control = ControlOrNull( ELoadGenCPULoadQueryIdle ); + if ( control ) + { + CEikNumberEditor* edIdle = static_cast( control ); + iAttributes.iIdle = edIdle->Number(); + DeleteLine( ELoadGenCPULoadQueryIdle ); + control = NULL; + } + control = ControlOrNull( ELoadGenCPULoadQueryVariance ); + if ( control ) + { + CEikNumberEditor* edVariance = static_cast( control ); + iAttributes.iRandomVariance = edVariance->Number(); + DeleteLine( ELoadGenCPULoadQueryVariance ); + } + } + else if ( edType->CurrentValueIndex() == ECpuLoadTypePeriodic ) + { + // insert new fields + InsertFieldAfterL(R_CPULOAD_DLG_LINE_PERIODIC_LENGTH, ELoadGenCPULoadQueryLength, ELoadGenCPULoadQueryType); + InsertFieldAfterL(R_CPULOAD_DLG_LINE_PERIODIC_IDLE, ELoadGenCPULoadQueryIdle, ELoadGenCPULoadQueryLength); + InsertFieldAfterL(R_CPULOAD_DLG_LINE_PERIODIC_VARIANCE, ELoadGenCPULoadQueryVariance, ELoadGenCPULoadQueryIdle); + + // load values to just created editors + CEikNumberEditor* edPeak = static_cast(Control(ELoadGenCPULoadQueryLength)); + CEikNumberEditor* edIdle = static_cast(Control(ELoadGenCPULoadQueryIdle)); + CEikNumberEditor* edVariance = static_cast(Control(ELoadGenCPULoadQueryVariance)); + edPeak->SetNumber(iAttributes.iLength); + edIdle->SetNumber(iAttributes.iIdle); + edVariance->SetNumber(iAttributes.iRandomVariance); + } + + UpdateFormL(); + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenCPULoadEditor::HandleControlStateChangeL(TInt aControlId) + { + CLoadGenLoadTypeEditorBase::HandleControlStateChangeL(aControlId); + + // update visibilities of fields + if (aControlId == ELoadGenCPULoadQueryType) + { + UpdateVisibilitiesOfFieldsL(); + } + } + +// -------------------------------------------------------------------------------------------- + +TBool CLoadGenCPULoadEditor::RunQueryLD() + { + return CLoadGenLoadTypeEditorBase::DoRunQueryLD(R_CPULOAD_FORM_DIALOG); + } + +// -------------------------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------- + +CLoadGenMemoryEatEditor* CLoadGenMemoryEatEditor::NewL(TMemoryEatAttributes& aAttributes, TBool aEditingExisting) + { + CLoadGenMemoryEatEditor* self = new(ELeave) CLoadGenMemoryEatEditor(aAttributes, aEditingExisting); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// -------------------------------------------------------------------------------------------- + +CLoadGenMemoryEatEditor::~CLoadGenMemoryEatEditor() + { + } + +// -------------------------------------------------------------------------------------------- + +CLoadGenMemoryEatEditor::CLoadGenMemoryEatEditor(TMemoryEatAttributes& aAttributes, TBool aEditingExisting) : + CLoadGenLoadTypeEditorBase(aEditingExisting), iAttributes(aAttributes) + { + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenMemoryEatEditor::ConstructL() + { + CLoadGenLoadTypeEditorBase::ConstructL(_L("Memory eat")); + + // convert int64 vals to descs + iAttributes.iAmountDes.Copy(KNullDesC); + iAttributes.iRandomMinDes.Copy(KNullDesC); + iAttributes.iRandomMaxDes.Copy(KNullDesC); + + iAttributes.iAmountDes.AppendNum(iAttributes.iAmount); + iAttributes.iRandomMinDes.AppendNum(iAttributes.iRandomMin); + iAttributes.iRandomMaxDes.AppendNum(iAttributes.iRandomMax); + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenMemoryEatEditor::PreLayoutDynInitL() + { + CLoadGenLoadTypeEditorBase::PreLayoutDynInitL(); + + // load values to static editors + CAknPopupFieldText* edPriority = static_cast(Control(ELoadGenMemoryEatQueryPriority)); + CAknPopupFieldText* edSource = static_cast(Control(ELoadGenMemoryEatQuerySource)); + CAknPopupFieldText* edType = static_cast(Control(ELoadGenMemoryEatQueryType)); + CEikNumberEditor* edBuffer = static_cast(Control(ELoadGenMemoryEatQueryBuffer)); + CEikNumberEditor* edIdle = static_cast(Control(ELoadGenMemoryEatQueryIdle)); + CEikNumberEditor* edVariance = static_cast(Control(ELoadGenMemoryEatQueryVariance)); + + edPriority->SetCurrentValueIndex(iAttributes.iPriority); + edSource->SetCurrentValueIndex(iAttributes.iSource); + edType->SetCurrentValueIndex(iAttributes.iType); + edBuffer->SetNumber(iAttributes.iBuffer); + edIdle->SetNumber(iAttributes.iIdle); + edVariance->SetNumber(iAttributes.iRandomVariance); + + UpdateVisibilitiesOfFieldsL(ETrue); + UpdateAvailableMemoryL(); + + // set source as dimmed if editing existing item + if (iEditingExisting) + { + SetLineDimmedNow(ELoadGenMemoryEatQuerySource, ETrue); + } + } + +// -------------------------------------------------------------------------------------------- + +TBool CLoadGenMemoryEatEditor::OkToExitL(TInt aButtonId) + { + if (aButtonId == EAknSoftkeyOk) + { + // store values from editors + CAknPopupFieldText* edPriority = static_cast(Control(ELoadGenMemoryEatQueryPriority)); + CAknPopupFieldText* edSource = static_cast(Control(ELoadGenMemoryEatQuerySource)); + CAknPopupFieldText* edType = static_cast(Control(ELoadGenMemoryEatQueryType)); + CEikNumberEditor* edBuffer = static_cast(Control(ELoadGenMemoryEatQueryBuffer)); + CEikNumberEditor* edIdle = static_cast(Control(ELoadGenMemoryEatQueryIdle)); + CEikNumberEditor* edVariance = static_cast(Control(ELoadGenMemoryEatQueryVariance)); + + iAttributes.iPriority = edPriority->CurrentValueIndex(); + iAttributes.iSource = edSource->CurrentValueIndex(); + iAttributes.iType = edType->CurrentValueIndex(); + iAttributes.iBuffer = edBuffer->Number(); + iAttributes.iIdle = edIdle->Number(); + iAttributes.iRandomVariance = edVariance->Number(); + + + CEikEdwin* edAmount = static_cast(ControlOrNull(ELoadGenMemoryEatQueryAmount)); + CEikEdwin* edRandomMin = static_cast(ControlOrNull(ELoadGenMemoryEatQueryRandomMin)); + CEikEdwin* edRandomMax = static_cast(ControlOrNull(ELoadGenMemoryEatQueryRandomMax)); + + // get desc values and convert to int64 + if (edAmount) + { + edAmount->GetText(iAttributes.iAmountDes); + + TLex converter; + converter.Assign(iAttributes.iAmountDes); + User::LeaveIfError(converter.Val(iAttributes.iAmount)); + } + + if (edRandomMin) + { + edRandomMin->GetText(iAttributes.iRandomMinDes); + + TLex converter; + converter.Assign(iAttributes.iRandomMinDes); + User::LeaveIfError(converter.Val(iAttributes.iRandomMin)); + } + + if (edRandomMax) + { + edRandomMax->GetText(iAttributes.iRandomMaxDes); + + TLex converter; + converter.Assign(iAttributes.iRandomMaxDes); + User::LeaveIfError(converter.Val(iAttributes.iRandomMax)); + + // swap min max values if they in wrong order + if (iAttributes.iRandomMin > iAttributes.iRandomMax) + { + TInt64 temp(iAttributes.iRandomMin); + iAttributes.iRandomMin = iAttributes.iRandomMax; + iAttributes.iRandomMax = temp; + } + + } + } + + return ETrue; + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenMemoryEatEditor::UpdateVisibilitiesOfFieldsL(TBool aFormInit) + { + // filter based on selected memory eat type + CAknPopupFieldText* edType = static_cast(Control(ELoadGenMemoryEatQueryType)); + + if (!aFormInit && (edType->CurrentValueIndex() == EMemoryEatTypeMemoryToEat || edType->CurrentValueIndex() == EMemoryEatTypeMemoryToBeLeft)) + { + // no need for changes if amount field is already active + CEikNumberEditor* edAmount = static_cast(ControlOrNull(ELoadGenMemoryEatQueryAmount)); + if (edAmount) return; + + // save values before deleting the items + CEikEdwin* edRandomMin = static_cast(Control(ELoadGenMemoryEatQueryRandomMin)); + CEikEdwin* edRandomMax = static_cast(Control(ELoadGenMemoryEatQueryRandomMax)); + edRandomMin->GetText(iAttributes.iRandomMinDes); + edRandomMax->GetText(iAttributes.iRandomMaxDes); + + DeleteLine(ELoadGenMemoryEatQueryRandomMin); + DeleteLine(ELoadGenMemoryEatQueryRandomMax); + } + else if (!aFormInit && edType->CurrentValueIndex() == EMemoryEatTypeWavy) + { + // save values before deleting the items + CEikEdwin* edAmount = static_cast(Control(ELoadGenMemoryEatQueryAmount)); + edAmount->GetText(iAttributes.iAmountDes); + + DeleteLine(ELoadGenMemoryEatQueryAmount); + } + + if (edType->CurrentValueIndex() == EMemoryEatTypeMemoryToEat || edType->CurrentValueIndex() == EMemoryEatTypeMemoryToBeLeft) + { + // insert new fields + InsertFieldAfterL(R_MEMORYEAT_DLG_LINE_AMOUNT, ELoadGenMemoryEatQueryAmount, ELoadGenMemoryEatQueryType); + + // load values to just created editors + CEikEdwin* edAmount = static_cast(Control(ELoadGenMemoryEatQueryAmount)); + edAmount->SetTextL(&iAttributes.iAmountDes); + } + else if (edType->CurrentValueIndex() == EMemoryEatTypeWavy) + { + // insert new fields + InsertFieldAfterL(R_MEMORYEAT_DLG_LINE_RANDOM_MIN, ELoadGenMemoryEatQueryRandomMin, ELoadGenMemoryEatQueryType); + InsertFieldAfterL(R_MEMORYEAT_DLG_LINE_RANDOM_MAX, ELoadGenMemoryEatQueryRandomMax, ELoadGenMemoryEatQueryRandomMin); + + // load values to just created editors + CEikEdwin* edRandomMin = static_cast(Control(ELoadGenMemoryEatQueryRandomMin)); + CEikEdwin* edRandomMax = static_cast(Control(ELoadGenMemoryEatQueryRandomMax)); + edRandomMin->SetTextL(&iAttributes.iRandomMinDes); + edRandomMax->SetTextL(&iAttributes.iRandomMaxDes); + } + + UpdateFormL(); + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenMemoryEatEditor::UpdateAvailableMemoryL() + { + // this feature is used only when not editing existing load + if (!iEditingExisting) + { + CAknPopupFieldText* edSource = static_cast(ControlOrNull(ELoadGenMemoryEatQuerySource)); + CEikEdwin* edAmount = static_cast(ControlOrNull(ELoadGenMemoryEatQueryAmount)); + + if (edAmount && edSource) + { + iAttributes.iAmountDes.Copy(KNullDesC); + + if (edSource->CurrentValueIndex() == EMemoryEatSourceTypeRAM) + { + // RAM + TMemoryInfoV1Buf ramMemory; + UserHal::MemoryInfo(ramMemory); + + iAttributes.iAmountDes.AppendNum(ramMemory().iFreeRamInBytes); + } + else + { + // get drive + TVolumeInfo volumeInfo; + if (CEikonEnv::Static()->FsSession().Volume(volumeInfo, edSource->CurrentValueIndex()+1) == KErrNone) + { + iAttributes.iAmountDes.AppendNum(volumeInfo.iFree); + } + else + { + iAttributes.iAmountDes.AppendNum(0); + } + } + + edAmount->SetTextL(&iAttributes.iAmountDes); + } + } + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenMemoryEatEditor::HandleControlStateChangeL(TInt aControlId) + { + CLoadGenLoadTypeEditorBase::HandleControlStateChangeL(aControlId); + + // update visibilities of fields + if (aControlId == ELoadGenMemoryEatQueryType) + { + UpdateVisibilitiesOfFieldsL(); + } + + // update memory when source changes + else if (aControlId == ELoadGenMemoryEatQuerySource) + { + UpdateAvailableMemoryL(); + } + } + +// -------------------------------------------------------------------------------------------- + +TBool CLoadGenMemoryEatEditor::RunQueryLD() + { + return CLoadGenLoadTypeEditorBase::DoRunQueryLD(R_MEMORYEAT_FORM_DIALOG); + } + + +// -------------------------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------- + +CLoadGenPhoneCallEditor* CLoadGenPhoneCallEditor::NewL(TPhoneCallAttributes& aAttributes, TBool aEditingExisting) + { + CLoadGenPhoneCallEditor* self = new(ELeave) CLoadGenPhoneCallEditor(aAttributes, aEditingExisting); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// -------------------------------------------------------------------------------------------- + +CLoadGenPhoneCallEditor::~CLoadGenPhoneCallEditor() + { + } + +// -------------------------------------------------------------------------------------------- + +CLoadGenPhoneCallEditor::CLoadGenPhoneCallEditor(TPhoneCallAttributes& aAttributes, TBool aEditingExisting) : + CLoadGenLoadTypeEditorBase(aEditingExisting), iAttributes(aAttributes) + { + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenPhoneCallEditor::ConstructL() + { + CLoadGenLoadTypeEditorBase::ConstructL(_L("Phone calls")); + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenPhoneCallEditor::PreLayoutDynInitL() + { + CLoadGenLoadTypeEditorBase::PreLayoutDynInitL(); + + // load values to static editors + CAknPopupFieldText* edPriority = static_cast(Control(ELoadGenPhoneCallQueryPriority)); + CEikEdwin* edDestination = static_cast(Control(ELoadGenPhoneCallQueryDestination)); + CEikNumberEditor* edLength = static_cast(Control(ELoadGenPhoneCallQueryLength)); + CEikNumberEditor* edIdle = static_cast(Control(ELoadGenPhoneCallQueryIdle)); + CEikNumberEditor* edVariance = static_cast(Control(ELoadGenPhoneCallQueryVariance)); + + edPriority->SetCurrentValueIndex(iAttributes.iPriority); + edDestination->SetTextL(&iAttributes.iDestination); + edLength->SetNumber(iAttributes.iLength); + edIdle->SetNumber(iAttributes.iIdle); + edVariance->SetNumber(iAttributes.iRandomVariance); + + UpdateVisibilitiesOfFieldsL(ETrue); + } + +// -------------------------------------------------------------------------------------------- + +TBool CLoadGenPhoneCallEditor::OkToExitL(TInt aButtonId) + { + if (aButtonId == EAknSoftkeyOk) + { + // store values from editors + CAknPopupFieldText* edPriority = static_cast(Control(ELoadGenPhoneCallQueryPriority)); + CEikEdwin* edDestination = static_cast(Control(ELoadGenPhoneCallQueryDestination)); + CEikNumberEditor* edLength = static_cast(Control(ELoadGenPhoneCallQueryLength)); + CEikNumberEditor* edIdle = static_cast(Control(ELoadGenPhoneCallQueryIdle)); + CEikNumberEditor* edVariance = static_cast(Control(ELoadGenPhoneCallQueryVariance)); + + iAttributes.iPriority = edPriority->CurrentValueIndex(); + edDestination->GetText(iAttributes.iDestination); + iAttributes.iLength = edLength->Number(); + iAttributes.iIdle = edIdle->Number(); + iAttributes.iRandomVariance = edVariance->Number(); + } + + return ETrue; + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenPhoneCallEditor::UpdateVisibilitiesOfFieldsL(TBool /*aFormInit*/) + { + UpdateFormL(); + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenPhoneCallEditor::HandleControlStateChangeL(TInt aControlId) + { + CLoadGenLoadTypeEditorBase::HandleControlStateChangeL(aControlId); + } + +// -------------------------------------------------------------------------------------------- + +TBool CLoadGenPhoneCallEditor::RunQueryLD() + { + return CLoadGenLoadTypeEditorBase::DoRunQueryLD(R_PHONECALL_FORM_DIALOG); + } + +// -------------------------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------- + +CLoadGenNetConnEditor* CLoadGenNetConnEditor::NewL(TNetConnAttributes& aAttributes, TBool aEditingExisting) + { + CLoadGenNetConnEditor* self = new(ELeave) CLoadGenNetConnEditor(aAttributes, aEditingExisting); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// -------------------------------------------------------------------------------------------- + +CLoadGenNetConnEditor::~CLoadGenNetConnEditor() + { + } + +// -------------------------------------------------------------------------------------------- + +CLoadGenNetConnEditor::CLoadGenNetConnEditor(TNetConnAttributes& aAttributes, TBool aEditingExisting) : + CLoadGenLoadTypeEditorBase(aEditingExisting), iAttributes(aAttributes) + { + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenNetConnEditor::ConstructL() + { + CLoadGenLoadTypeEditorBase::ConstructL(_L("Network conn.")); + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenNetConnEditor::PreLayoutDynInitL() + { + CLoadGenLoadTypeEditorBase::PreLayoutDynInitL(); + + // load values to static editors + CAknPopupFieldText* edPriority = static_cast(Control(ELoadGenNetConnQueryPriority)); + CEikEdwin* edDestination = static_cast(Control(ELoadGenNetConnQueryDestination)); + CEikNumberEditor* edIdle = static_cast(Control(ELoadGenNetConnQueryIdle)); + CEikNumberEditor* edVariance = static_cast(Control(ELoadGenNetConnQueryVariance)); + + edPriority->SetCurrentValueIndex(iAttributes.iPriority); + edDestination->SetTextL(&iAttributes.iDestination); + edIdle->SetNumber(iAttributes.iIdle); + edVariance->SetNumber(iAttributes.iRandomVariance); + + UpdateVisibilitiesOfFieldsL(ETrue); + } + +// -------------------------------------------------------------------------------------------- + +TBool CLoadGenNetConnEditor::OkToExitL(TInt aButtonId) + { + if (aButtonId == EAknSoftkeyOk) + { + // store values from editors + CAknPopupFieldText* edPriority = static_cast(Control(ELoadGenNetConnQueryPriority)); + CEikEdwin* edDestination = static_cast(Control(ELoadGenNetConnQueryDestination)); + CEikNumberEditor* edIdle = static_cast(Control(ELoadGenNetConnQueryIdle)); + CEikNumberEditor* edVariance = static_cast(Control(ELoadGenNetConnQueryVariance)); + + iAttributes.iPriority = edPriority->CurrentValueIndex(); + edDestination->GetText(iAttributes.iDestination); + iAttributes.iIdle = edIdle->Number(); + iAttributes.iRandomVariance = edVariance->Number(); + } + + return ETrue; + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenNetConnEditor::UpdateVisibilitiesOfFieldsL(TBool /*aFormInit*/) + { + UpdateFormL(); + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenNetConnEditor::HandleControlStateChangeL(TInt aControlId) + { + CLoadGenLoadTypeEditorBase::HandleControlStateChangeL(aControlId); + } + +// -------------------------------------------------------------------------------------------- + +TBool CLoadGenNetConnEditor::RunQueryLD() + { + return CLoadGenLoadTypeEditorBase::DoRunQueryLD(R_NETCONN_FORM_DIALOG); + } + +// -------------------------------------------------------------------------------------------- + +// -------------------------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------- + +CLoadGenKeyPressEditor* CLoadGenKeyPressEditor::NewL(TKeyPressAttributes& aAttributes, TBool aEditingExisting) + { + CLoadGenKeyPressEditor* self = new(ELeave) CLoadGenKeyPressEditor(aAttributes, aEditingExisting); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// -------------------------------------------------------------------------------------------- + +CLoadGenKeyPressEditor::~CLoadGenKeyPressEditor() + { + } + +// -------------------------------------------------------------------------------------------- + +CLoadGenKeyPressEditor::CLoadGenKeyPressEditor(TKeyPressAttributes& aAttributes, TBool aEditingExisting) : + CLoadGenLoadTypeEditorBase(aEditingExisting), iAttributes(aAttributes) + { + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenKeyPressEditor::ConstructL() + { + CLoadGenLoadTypeEditorBase::ConstructL(_L("Key presses")); + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenKeyPressEditor::PreLayoutDynInitL() + { + CLoadGenLoadTypeEditorBase::PreLayoutDynInitL(); + + // load values to static editors + CAknPopupFieldText* edPriority = static_cast(Control(ELoadGenKeyPressQueryPriority)); + CEikNumberEditor* edHeartBeat = static_cast(Control(ELoadGenKeyPressQueryHeartBeat)); + CEikNumberEditor* edVariance = static_cast(Control(ELoadGenKeyPressQueryVariance)); + + edPriority->SetCurrentValueIndex(iAttributes.iPriority); + edHeartBeat->SetNumber(iAttributes.iHeartBeat); + edVariance->SetNumber(iAttributes.iRandomVariance); + + UpdateVisibilitiesOfFieldsL(ETrue); + } + +// -------------------------------------------------------------------------------------------- + +TBool CLoadGenKeyPressEditor::OkToExitL(TInt aButtonId) + { + if (aButtonId == EAknSoftkeyOk) + { + // store values from editors + CAknPopupFieldText* edPriority = static_cast(Control(ELoadGenKeyPressQueryPriority)); + CEikNumberEditor* edHeartBeat = static_cast(Control(ELoadGenKeyPressQueryHeartBeat)); + CEikNumberEditor* edVariance = static_cast(Control(ELoadGenKeyPressQueryVariance)); + + iAttributes.iPriority = edPriority->CurrentValueIndex(); + iAttributes.iHeartBeat = edHeartBeat->Number(); + iAttributes.iRandomVariance = edVariance->Number(); + } + + return ETrue; + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenKeyPressEditor::UpdateVisibilitiesOfFieldsL(TBool /*aFormInit*/) + { + UpdateFormL(); + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenKeyPressEditor::HandleControlStateChangeL(TInt aControlId) + { + CLoadGenLoadTypeEditorBase::HandleControlStateChangeL(aControlId); + } + +// -------------------------------------------------------------------------------------------- + +TBool CLoadGenKeyPressEditor::RunQueryLD() + { + return CLoadGenLoadTypeEditorBase::DoRunQueryLD(R_KEYPRESS_FORM_DIALOG); + } + +// -------------------------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------- + +CLoadGenMessagesEditor* CLoadGenMessagesEditor::NewL( TMessageAttributes& aAttributes, + TBool aEditingExisting ) + { + CLoadGenMessagesEditor* self = new(ELeave) CLoadGenMessagesEditor( aAttributes, + aEditingExisting ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// -------------------------------------------------------------------------------------------- + +CLoadGenMessagesEditor::~CLoadGenMessagesEditor() + { + } + +// -------------------------------------------------------------------------------------------- + +CLoadGenMessagesEditor::CLoadGenMessagesEditor( TMessageAttributes& aAttributes, + TBool aEditingExisting ) : + CLoadGenLoadTypeEditorBase( aEditingExisting ), + iAttributes( aAttributes ) + { + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenMessagesEditor::ConstructL() + { + CLoadGenLoadTypeEditorBase::ConstructL( _L("Messages") ); + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenMessagesEditor::PreLayoutDynInitL() + { + CLoadGenLoadTypeEditorBase::PreLayoutDynInitL(); + + // load values to static editors + CAknPopupFieldText* edPriority = + static_cast( Control( ELoadGenMessagesQueryPriority ) ); + CAknPopupFieldText* edType = + static_cast( Control( ELoadGenMessagesQueryType ) ); + CEikEdwin* edDestination = + static_cast( Control( ELoadGenMessagesQueryDestination ) ); + CEikNumberEditor* edAmount = + static_cast( Control( ELoadGenMessagesQueryAmount ) ); + CEikNumberEditor* edLength = + static_cast( Control( ELoadGenMessagesQueryLength ) ); + CEikNumberEditor* edIdle = + static_cast( Control( ELoadGenMessagesQueryIdle ) ); + CEikNumberEditor* edVariance = + static_cast( Control( ELoadGenMessagesQueryVariance ) ); + + edPriority->SetCurrentValueIndex( iAttributes.iPriority ); + edType->SetCurrentValueIndex( iAttributes.iMessageType ); + edDestination->SetTextL( &iAttributes.iDestination ); + edAmount->SetNumber( iAttributes.iAmount ); + edLength->SetNumber( iAttributes.iLength ); + edIdle->SetNumber( iAttributes.iIdle ); + edVariance->SetNumber( iAttributes.iRandomVariance ); + + UpdateVisibilitiesOfFieldsL( ETrue ); + // set type selection as dimmed if editing existing item + if (iEditingExisting) + { + SetLineDimmedNow(ELoadGenMessagesQueryType, ETrue); + } + + } + +// -------------------------------------------------------------------------------------------- + +TBool CLoadGenMessagesEditor::OkToExitL( TInt aButtonId ) + { + if ( aButtonId == EAknSoftkeyOk ) + { + // store values from editors + CAknPopupFieldText* edPriority = + static_cast( Control( ELoadGenMessagesQueryPriority ) ); + CAknPopupFieldText* edType = + static_cast( Control( ELoadGenMessagesQueryType ) ); + CEikEdwin* edDestination = + static_cast( Control( ELoadGenMessagesQueryDestination ) ); + CEikNumberEditor* edLength = + static_cast( Control( ELoadGenMessagesQueryLength ) ); + CEikNumberEditor* edAmount = + static_cast( Control( ELoadGenMessagesQueryAmount ) ); + CEikNumberEditor* edIdle = + static_cast( Control( ELoadGenMessagesQueryIdle ) ); + CEikNumberEditor* edVariance = + static_cast( Control( ELoadGenMessagesQueryVariance ) ); + + iAttributes.iPriority = edPriority->CurrentValueIndex(); + iAttributes.iMessageType = edType->CurrentValueIndex(); + edDestination->GetText( iAttributes.iDestination ); + iAttributes.iAmount = edAmount->Number(); + iAttributes.iLength = edLength->Number(); + iAttributes.iIdle = edIdle->Number(); + iAttributes.iRandomVariance = edVariance->Number(); + } + + return ETrue; + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenMessagesEditor::UpdateVisibilitiesOfFieldsL( TBool /*aFormInit*/ ) + { + UpdateFormL(); + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenMessagesEditor::HandleControlStateChangeL( TInt aControlId ) + { + CLoadGenLoadTypeEditorBase::HandleControlStateChangeL( aControlId ); + } + +// -------------------------------------------------------------------------------------------- + +TBool CLoadGenMessagesEditor::RunQueryLD() + { + return CLoadGenLoadTypeEditorBase::DoRunQueryLD( R_MESSAGES_FORM_DIALOG ); + } + +// -------------------------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------- + +CLoadGenApplicationsEditor* CLoadGenApplicationsEditor::NewL( TApplicationsAttributes& aAttributes, + TBool aEditingExisting ) + { + CLoadGenApplicationsEditor* self = new(ELeave) CLoadGenApplicationsEditor( aAttributes, + aEditingExisting ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// -------------------------------------------------------------------------------------------- + +CLoadGenApplicationsEditor::~CLoadGenApplicationsEditor() + { + } + +// -------------------------------------------------------------------------------------------- + +CLoadGenApplicationsEditor::CLoadGenApplicationsEditor( TApplicationsAttributes& aAttributes, + TBool aEditingExisting ) : + CLoadGenLoadTypeEditorBase( aEditingExisting ), + iAttributes( aAttributes ) + { + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenApplicationsEditor::ConstructL() + { + CLoadGenLoadTypeEditorBase::ConstructL( _L("Applications") ); + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenApplicationsEditor::PreLayoutDynInitL() + { + CLoadGenLoadTypeEditorBase::PreLayoutDynInitL(); + + // load values to static editors + CAknPopupFieldText* edPriority = static_cast(Control(ELoadGenApplicationsQueryPriority)); + CEikNumberEditor* edLaunchingInterval = static_cast(Control(ELoadGenApplicationsLaunchingInterval)); + CAknPopupFieldText* edKeyPressType = static_cast(Control(ELoadGenApplicationsKeyPressType)); + CEikNumberEditor* edMaxOpen = static_cast(Control(ELoadGenApplicationsMaxOpen)); + CEikNumberEditor* edHeartBeat = static_cast(Control(ELoadGenApplicationsKeyPressQueryHeartBeat)); + CEikNumberEditor* edVariance = static_cast(Control(ELoadGenApplicationsQueryVariance)); + + edPriority->SetCurrentValueIndex( iAttributes.iPriority ); + edLaunchingInterval->SetNumber( iAttributes.iLaunchingInterval ); + edKeyPressType->SetCurrentValueIndex( iAttributes.iKeyPressType ); + edMaxOpen->SetNumber( iAttributes.iMaxOpen ); + edHeartBeat->SetNumber( iAttributes.iHeartBeat ); + edVariance->SetNumber( iAttributes.iRandomVariance ); + + UpdateVisibilitiesOfFieldsL(ETrue); + } + +// -------------------------------------------------------------------------------------------- + +TBool CLoadGenApplicationsEditor::OkToExitL(TInt aButtonId) + { + if (aButtonId == EAknSoftkeyOk) + { + // store values from editors + CAknPopupFieldText* edPriority = static_cast(Control(ELoadGenApplicationsQueryPriority)); + CEikNumberEditor* edLaunchingInterval = static_cast(Control(ELoadGenApplicationsLaunchingInterval)); + CAknPopupFieldText* edKeyPressType = static_cast(Control(ELoadGenApplicationsKeyPressType)); + CEikNumberEditor* edMaxOpen = static_cast(Control(ELoadGenApplicationsMaxOpen)); + CEikNumberEditor* edHeartBeat = static_cast(Control(ELoadGenApplicationsKeyPressQueryHeartBeat)); + CEikNumberEditor* edVariance = static_cast(Control(ELoadGenApplicationsQueryVariance)); + + iAttributes.iPriority = edPriority->CurrentValueIndex(); + iAttributes.iLaunchingInterval = edLaunchingInterval->Number(); + iAttributes.iKeyPressType = edKeyPressType->CurrentValueIndex(); + iAttributes.iMaxOpen = edMaxOpen->Number(); + iAttributes.iHeartBeat = edHeartBeat->Number(); + iAttributes.iRandomVariance = edVariance->Number(); + } + + return ETrue; + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenApplicationsEditor::UpdateVisibilitiesOfFieldsL( TBool /*aFormInit*/ ) + { + UpdateFormL(); + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenApplicationsEditor::HandleControlStateChangeL( TInt aControlId ) + { + CLoadGenLoadTypeEditorBase::HandleControlStateChangeL( aControlId ); + } + +// -------------------------------------------------------------------------------------------- + +TBool CLoadGenApplicationsEditor::RunQueryLD() + { + return CLoadGenLoadTypeEditorBase::DoRunQueryLD( R_APPLICATIONS_FORM_DIALOG ); + } + +// -------------------------------------------------------------------------------------------- + +// -------------------------------------------------------------------------------------------- + +CLoadGenPhotoCaptureEditor* CLoadGenPhotoCaptureEditor::NewL(TPhotoCaptureAttributes& aAttributes, TBool aEditingExisting) + { + CLoadGenPhotoCaptureEditor* self = new(ELeave) CLoadGenPhotoCaptureEditor(aAttributes, aEditingExisting); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// -------------------------------------------------------------------------------------------- + +CLoadGenPhotoCaptureEditor::~CLoadGenPhotoCaptureEditor() + { + } + +// -------------------------------------------------------------------------------------------- + +CLoadGenPhotoCaptureEditor::CLoadGenPhotoCaptureEditor(TPhotoCaptureAttributes& aAttributes, TBool aEditingExisting) : + CLoadGenLoadTypeEditorBase(aEditingExisting), iAttributes(aAttributes) + { + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenPhotoCaptureEditor::ConstructL() + { + CLoadGenLoadTypeEditorBase::ConstructL(_L("Photo captures")); + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenPhotoCaptureEditor::PreLayoutDynInitL() + { + CLoadGenLoadTypeEditorBase::PreLayoutDynInitL(); + + // load values to static editors + CAknPopupFieldText* edPriority = static_cast(Control(ELoadGenPhotoCaptureQueryPriority)); + //CAknPopupFieldText* edDevice = static_cast(Control(ELoadGenPhotoCaptureQueryDevice)); + CEikNumberEditor* edIdle = static_cast(Control(ELoadGenPhotoCaptureQueryIdle)); + CEikNumberEditor* edVariance = static_cast(Control(ELoadGenPhotoCaptureQueryVariance)); + + edPriority->SetCurrentValueIndex(iAttributes.iPriority); + //edDevice->SetCurrentValueIndex(0); + edIdle->SetNumber(iAttributes.iIdle); + edVariance->SetNumber(iAttributes.iRandomVariance); + + LoadCamerasL(); + + UpdateVisibilitiesOfFieldsL(ETrue); + } + +void CLoadGenPhotoCaptureEditor::LoadCamerasL() + { + if (iAttributes.iCameraCount > 0) + { + // insert possibility to select which cpu the load is generated to + InsertFieldAfterL(R_PHOTOCAPTURE_DLG_LINE_DEVICE, ELoadGenPhotoCaptureQueryDevice, ELoadGenPhotoCaptureQueryPriority); + + iCamerasArray = new (ELeave) CDesCArrayFlat( iAttributes.iCameraCount ); + + // add Cameras + for (int i = 0; i < iAttributes.iCameraCount; i++) + { + TBuf<16> cam; + _LIT(KCam, "Camera %d"); + cam.Format(KCam, i); + iCamerasArray->AppendL(cam); + } + + iCameraTextArray = CAknQueryValueTextArray::NewL(); + iCameraTextArray->SetArray( *iCamerasArray ); + iCameraQueryValText = CAknQueryValueText::NewL(); + iCameraQueryValText->SetArrayL( iCameraTextArray ); + if( iAttributes.iCameraCount > 0 ) + { + iCameraQueryValText->SetCurrentValueIndex(iAttributes.iCamera); + } + CAknPopupField* popup = static_cast(Control( ELoadGenPhotoCaptureQueryDevice)); + popup->SetQueryValueL( iCameraQueryValText ); + } + } + +// -------------------------------------------------------------------------------------------- + +TBool CLoadGenPhotoCaptureEditor::OkToExitL(TInt aButtonId) + { + if (aButtonId == EAknSoftkeyOk) + { + // store values from editors + CAknPopupFieldText* edPriority = static_cast(Control(ELoadGenPhotoCaptureQueryPriority)); + CEikNumberEditor* edIdle = static_cast(Control(ELoadGenPhotoCaptureQueryIdle)); + CEikNumberEditor* edVariance = static_cast(Control(ELoadGenPhotoCaptureQueryVariance)); + + iAttributes.iPriority = edPriority->CurrentValueIndex(); + iAttributes.iIdle = edIdle->Number(); + iAttributes.iRandomVariance = edVariance->Number(); + + if (iAttributes.iCameraCount > 1) + { + iAttributes.iCamera = iCameraQueryValText->CurrentValueIndex(); + } + } + + return ETrue; + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenPhotoCaptureEditor::UpdateVisibilitiesOfFieldsL(TBool /*aFormInit*/) + { + UpdateFormL(); + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenPhotoCaptureEditor::HandleControlStateChangeL(TInt aControlId) + { + CLoadGenLoadTypeEditorBase::HandleControlStateChangeL(aControlId); + } + +// -------------------------------------------------------------------------------------------- + +TBool CLoadGenPhotoCaptureEditor::RunQueryLD() + { + return CLoadGenLoadTypeEditorBase::DoRunQueryLD(R_PHOTOCAPTURE_FORM_DIALOG); + } + + +// -------------------------------------------------------------------------------------------- + +CLoadGenBluetoothEditor* CLoadGenBluetoothEditor::NewL(TBluetoothAttributes& aAttributes, TBool aEditingExisting) + { + CLoadGenBluetoothEditor* self = new(ELeave) CLoadGenBluetoothEditor(aAttributes, aEditingExisting); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// -------------------------------------------------------------------------------------------- + +CLoadGenBluetoothEditor::~CLoadGenBluetoothEditor() + { + } + +// -------------------------------------------------------------------------------------------- + +CLoadGenBluetoothEditor::CLoadGenBluetoothEditor(TBluetoothAttributes& aAttributes, TBool aEditingExisting) : + CLoadGenLoadTypeEditorBase(aEditingExisting), iAttributes(aAttributes) + { + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenBluetoothEditor::ConstructL() + { + CLoadGenLoadTypeEditorBase::ConstructL(_L("Bluetooth")); + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenBluetoothEditor::PreLayoutDynInitL() + { + CLoadGenLoadTypeEditorBase::PreLayoutDynInitL(); + + // load values to static editors + CAknPopupFieldText* edPriority = static_cast(Control(ELoadGenBluetoothQueryPriority)); + CEikNumberEditor* edIdle = static_cast(Control(ELoadGenBluetoothQueryIdle)); + CEikNumberEditor* edVariance = static_cast(Control(ELoadGenBluetoothQueryVariance)); + + edPriority->SetCurrentValueIndex(iAttributes.iPriority); + edIdle->SetNumber(iAttributes.iIdle); + edVariance->SetNumber(iAttributes.iRandomVariance); + + UpdateVisibilitiesOfFieldsL(ETrue); + } + +// -------------------------------------------------------------------------------------------- + +TBool CLoadGenBluetoothEditor::OkToExitL(TInt aButtonId) + { + if (aButtonId == EAknSoftkeyOk) + { + // store values from editors + CAknPopupFieldText* edPriority = static_cast(Control(ELoadGenBluetoothQueryPriority)); + CEikNumberEditor* edIdle = static_cast(Control(ELoadGenBluetoothQueryIdle)); + CEikNumberEditor* edVariance = static_cast(Control(ELoadGenBluetoothQueryVariance)); + + iAttributes.iPriority = edPriority->CurrentValueIndex(); + iAttributes.iIdle = edIdle->Number(); + iAttributes.iRandomVariance = edVariance->Number(); + } + + return ETrue; + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenBluetoothEditor::UpdateVisibilitiesOfFieldsL(TBool /*aFormInit*/) + { + UpdateFormL(); + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenBluetoothEditor::HandleControlStateChangeL(TInt aControlId) + { + CLoadGenLoadTypeEditorBase::HandleControlStateChangeL(aControlId); + } + +// -------------------------------------------------------------------------------------------- + +TBool CLoadGenBluetoothEditor::RunQueryLD() + { + return CLoadGenLoadTypeEditorBase::DoRunQueryLD(R_BLUETOOTH_FORM_DIALOG); + } + +// -------------------------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------- + +CLoadGenPointerEventEditor* CLoadGenPointerEventEditor::NewL(TPointerEventAttributes& aAttributes, TBool aEditingExisting) + { + CLoadGenPointerEventEditor* self = new(ELeave) CLoadGenPointerEventEditor(aAttributes, aEditingExisting); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// -------------------------------------------------------------------------------------------- + +CLoadGenPointerEventEditor::~CLoadGenPointerEventEditor() + { + } + +// -------------------------------------------------------------------------------------------- + +CLoadGenPointerEventEditor::CLoadGenPointerEventEditor(TPointerEventAttributes& aAttributes, TBool aEditingExisting) : + CLoadGenLoadTypeEditorBase(aEditingExisting), iAttributes(aAttributes) + { + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenPointerEventEditor::ConstructL() + { + CLoadGenLoadTypeEditorBase::ConstructL(_L("Pointer events")); + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenPointerEventEditor::PreLayoutDynInitL() + { + CLoadGenLoadTypeEditorBase::PreLayoutDynInitL(); + + // load values to static editors + CAknPopupFieldText* edPriority = static_cast(Control(ELoadGenPointerEventQueryPriority)); + CEikNumberEditor* edHeartBeat = static_cast(Control(ELoadGenPointerEventQueryHeartBeat)); + CEikNumberEditor* edVariance = static_cast(Control(ELoadGenPointerEventQueryVariance)); + + edPriority->SetCurrentValueIndex(iAttributes.iPriority); + edHeartBeat->SetNumber(iAttributes.iHeartBeat); + edVariance->SetNumber(iAttributes.iRandomVariance); + + UpdateVisibilitiesOfFieldsL(ETrue); + } + +// -------------------------------------------------------------------------------------------- + +TBool CLoadGenPointerEventEditor::OkToExitL(TInt aButtonId) + { + if (aButtonId == EAknSoftkeyOk) + { + // store values from editors + CAknPopupFieldText* edPriority = static_cast(Control(ELoadGenPointerEventQueryPriority)); + CEikNumberEditor* edHeartBeat = static_cast(Control(ELoadGenPointerEventQueryHeartBeat)); + CEikNumberEditor* edVariance = static_cast(Control(ELoadGenPointerEventQueryVariance)); + + iAttributes.iPriority = edPriority->CurrentValueIndex(); + iAttributes.iHeartBeat = edHeartBeat->Number(); + iAttributes.iRandomVariance = edVariance->Number(); + } + + return ETrue; + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenPointerEventEditor::UpdateVisibilitiesOfFieldsL(TBool /*aFormInit*/) + { + UpdateFormL(); + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenPointerEventEditor::HandleControlStateChangeL(TInt aControlId) + { + CLoadGenLoadTypeEditorBase::HandleControlStateChangeL(aControlId); + } + +// -------------------------------------------------------------------------------------------- + +TBool CLoadGenPointerEventEditor::RunQueryLD() + { + return CLoadGenLoadTypeEditorBase::DoRunQueryLD(R_POINTEREVENT_FORM_DIALOG); + } + +// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/ui/avkon/src/loadgen_maincontainer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/ui/avkon/src/loadgen_maincontainer.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,457 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +// INCLUDE FILES +#include "loadgen_maincontainer.h" +#include "loadgen.hrh" +#include "loadgen_document.h" +#include "loadgen_appui.h" +#include "loadgen_model.h" +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +_LIT(KExtraIconsPath, "\\resource\\apps\\loadgen_extraicons.mif"); + +// ===================================== MEMBER FUNCTIONS ===================================== + +void CLoadGenMainContainer::ConstructL(const TRect& aRect) + { + iModel = static_cast(reinterpret_cast(iEikonEnv->AppUi())->Document())->Model(); + iModel->SetMainContainer(this); + + CreateWindowL(); + SetRect(aRect); + SetBlank(); + + // init listbox + iListBox = new(ELeave) CLoadGenCAknSingleGraphicStyleListBox; + iListBox->SetContainerWindowL(*this); + iListBox->ConstructL(this, EAknListBoxMarkableList); + iListBox->View()->SetListEmptyTextL(_L("No loads activated\n(Select new load from Options to generate new load)")); + + // create icon array and add marking indicator to it + CAknIconArray* iconArray = new(ELeave) CAknIconArray(1); + CleanupStack::PushL(iconArray); + CFbsBitmap* markBitmap = NULL; + CFbsBitmap* markBitmapMask = NULL; + + TRgb defaultColor; + defaultColor = iEikonEnv->Color(EColorControlText); + + AknsUtils::CreateColorIconL(AknsUtils::SkinInstance(), + KAknsIIDQgnIndiMarkedAdd, + KAknsIIDQsnIconColors, + EAknsCIQsnIconColorsCG13, + markBitmap, + markBitmapMask, + AknIconUtils::AvkonIconFileName(), + EMbmAvkonQgn_indi_marked_add, + EMbmAvkonQgn_indi_marked_add_mask, + defaultColor + ); + + CGulIcon* markIcon = CGulIcon::NewL(markBitmap, markBitmapMask); + iconArray->AppendL(markIcon); + + // append icons from loadgen_extraicons.mif + TFileName extraIconsPath; + extraIconsPath.Copy(KExtraIconsPath); + TParsePtrC parse((CEikonEnv::Static()->EikAppUi()->Application())->AppFullName()); // get path where this app is installed + extraIconsPath.Insert(0, parse.Drive()); // drive letter + + CFbsBitmap* redBitmap = NULL; + CFbsBitmap* redBitmapMask = NULL; + CFbsBitmap* greenBitmap = NULL; + CFbsBitmap* greenBitmapMask = NULL; + + AknIconUtils::CreateIconL(redBitmap, redBitmapMask, extraIconsPath, EMbmLoadgen_extraiconsQgn_prob_status_red, EMbmLoadgen_extraiconsQgn_prob_status_red_mask); + AknIconUtils::CreateIconL(greenBitmap, greenBitmapMask, extraIconsPath, EMbmLoadgen_extraiconsQgn_prob_status_green, EMbmLoadgen_extraiconsQgn_prob_status_green_mask); + + CGulIcon* redIcon = CGulIcon::NewL(redBitmap, redBitmapMask); + iconArray->AppendL(redIcon); + + CGulIcon* greenIcon = CGulIcon::NewL(greenBitmap, greenBitmapMask); + iconArray->AppendL(greenIcon); + + // set icon array + CleanupStack::Pop(); // iconArray + iListBox->ItemDrawer()->ColumnData()->SetIconArray(iconArray); + + iListBox->CreateScrollBarFrameL(ETrue); + iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto); + iListBox->SetListBoxObserver(this); + + // set size of the listbox + TSize outputRectSize; + AknLayoutUtils::LayoutMetricsSize(AknLayoutUtils::EMainPane, outputRectSize); + TRect outputRect(outputRectSize); + iListBox->SetRect(outputRect); + + iListBox->ActivateL(); + + ActivateL(); + } + +// -------------------------------------------------------------------------------------------- + +CLoadGenMainContainer::~CLoadGenMainContainer() + { + if (iListBox) + delete iListBox; + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenMainContainer::SizeChanged() +{ + TSize outputRectSize; + AknLayoutUtils::LayoutMetricsSize(AknLayoutUtils::EMainPane, outputRectSize); + TRect outputRect(outputRectSize); + + if (iListBox) + iListBox->SetRect(outputRect); +} + +// -------------------------------------------------------------------------------------------- + +TInt CLoadGenMainContainer::CountComponentControls() const + { + if (iListBox) + return 1; + else + return 0; + } + +// -------------------------------------------------------------------------------------------- + +CCoeControl* CLoadGenMainContainer::ComponentControl(TInt /*aIndex*/) const + { + if (iListBox) + return iListBox; + else + return NULL; + } + +// -------------------------------------------------------------------------------------------- + +TInt CLoadGenMainContainer::CurrentListBoxItemIndex() + { + if (iListBox) + { + return iListBox->CurrentItemIndex(); + } + else + return KErrNotFound; + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenMainContainer::SetListBoxTextArrayL(CDesCArray* aTextArray) + { + if (iListBox) + { + iListBox->Model()->SetItemTextArray(aTextArray); + iListBox->Model()->SetOwnershipType(ELbmOwnsItemArray); + iListBox->HandleItemAdditionL(); + iListBox->UpdateScrollBarsL(); + } + } + +// -------------------------------------------------------------------------------------------- + +const CArrayFix* CLoadGenMainContainer::ListBoxSelectionIndexes() + { + if (iListBox) + { + const CListBoxView::CSelectionIndexArray* indices = iListBox->SelectionIndexes(); + return static_cast*>(indices); + } + else + return NULL; + } + +// -------------------------------------------------------------------------------------------- + +TInt CLoadGenMainContainer::ListBoxSelectionIndexesCount() + { + if (iListBox) + { + return iListBox->SelectionIndexes()->Count(); + } + else + return KErrNotFound; + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenMainContainer::Draw(const TRect& aRect) const + { + CWindowGc& gc = SystemGc(); + gc.Clear(aRect); + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenMainContainer::HandleControlEventL(CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/) + { + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenMainContainer::SetDefaultTitlePaneTextL() + { + _LIT(KTitleText, "Load Gener."); + + CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane(); + CAknTitlePane* tp = static_cast( sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); + tp->SetTextL( KTitleText ); + } + +// -------------------------------------------------------------------------------------------- + +TKeyResponse CLoadGenMainContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType) + { + if(aType != EEventKey) + return EKeyWasNotConsumed; + + if (iListBox && iListBox->Model()->NumberOfItems() > 0) + { + /* + if (aKeyEvent.iCode == EKeyBackspace || aKeyEvent.iCode == EKeyDelete) + { + iModel->StopSelectedOrHighlightedItemsL(); + return EKeyWasConsumed; + } + else + { + return iListBox->OfferKeyEventL(aKeyEvent, aType); + } + */ + TBool shiftKeyPressed = (aKeyEvent.iModifiers & EModifierShift) || + (aKeyEvent.iModifiers & EModifierLeftShift) || + (aKeyEvent.iModifiers & EModifierRightShift); + TBool controlKeyPressed = (aKeyEvent.iModifiers & EModifierCtrl) || + (aKeyEvent.iModifiers & EModifierRightCtrl); + + + // handle OK/Enter keys + if ((aKeyEvent.iCode == EKeyOK || aKeyEvent.iCode == EKeyEnter) && (shiftKeyPressed || controlKeyPressed)) + { + return iListBox->OfferKeyEventL(aKeyEvent, aType); //send to listbox if modifiers + } + + // handle OK/Enter keys + else if (aKeyEvent.iCode == EKeyOK || aKeyEvent.iCode == EKeyEnter) + { + iModel->ShowItemActionMenuL(); + } + + // handle delete key + else if (aKeyEvent.iCode == EKeyBackspace || aKeyEvent.iCode == EKeyDelete) + { + iModel->StopSelectedOrHighlightedItemsL(); + } + + else + return iListBox->OfferKeyEventL(aKeyEvent, aType); + } + + return EKeyWasNotConsumed; + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenMainContainer::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aEventType) + { + switch (aEventType) + { + case EEventEnterKeyPressed: + case EEventItemDoubleClicked: + { + iModel->ShowItemActionMenuL(); + } + break; + default: + break; + } + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenMainContainer::HandleResourceChange(TInt aType) + { + if ( aType == KEikDynamicLayoutVariantSwitch ) + { + TRect mainPaneRect; + AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect); + SetRect(mainPaneRect); + + TSize outputRectSize; + AknLayoutUtils::LayoutMetricsSize(AknLayoutUtils::EMainPane, outputRectSize); + TRect outputRect(outputRectSize); + iListBox->SetRect(outputRect); + } + else + { + CCoeControl::HandleResourceChange(aType); + } + } + +// -------------------------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------- + +void CLoadGenCAknSingleGraphicStyleListBox::SizeChanged() + { + // call the base class function first + CAknSingleGraphicStyleListBox::SizeChanged(); + + // customize the list box + TRAP_IGNORE(SizeChangedL()); + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenCAknSingleGraphicStyleListBox::SizeChangedL() + { + const TInt KEmptySize = 2; + + // disable separator line + ItemDrawer()->ColumnData()->SetSeparatorLinePosition(ENoLine); + + // enable marquee + ItemDrawer()->ColumnData()->EnableMarqueeL(ETrue); + + // set fonts + const CFont* font = AknLayoutUtils::FontFromId(EAknLogicalFontPrimarySmallFont); + ItemDrawer()->ColumnData()->SetColumnFontL(0, font); + ItemDrawer()->ColumnData()->SetColumnFontL(1, font); + ItemDrawer()->ColumnData()->SetColumnFontL(2, font); + ItemDrawer()->ColumnData()->SetColumnFontL(3, font); + + // set row height + TInt rowHeight = font->HeightInPixels()+5; + TSize itemCellSize = View()->ItemDrawer()->ItemCellSize(); + itemCellSize.iHeight = rowHeight; + SetItemHeightL(rowHeight); + View()->ItemDrawer()->SetItemCellSize(itemCellSize); + + // set icon sizes + TInt normalIconSize = rowHeight * 0.7; + TInt markingIconSize = rowHeight * 0.8; + ItemDrawer()->ColumnData()->SetSubCellIconSize(0, TSize(normalIconSize,normalIconSize)); + ItemDrawer()->ColumnData()->SetSubCellIconSize(2, TSize(markingIconSize,markingIconSize)); + ItemDrawer()->ColumnData()->SetSubCellIconSize(3, TSize(KEmptySize,KEmptySize)); + + // set column widths + ItemDrawer()->ColumnData()->SetColumnWidthPixelL(0, normalIconSize + 2*normalIconSize * 0.15); + ItemDrawer()->ColumnData()->SetColumnWidthPixelL(1, itemCellSize.iWidth-KEmptySize-markingIconSize); + ItemDrawer()->ColumnData()->SetColumnWidthPixelL(2, markingIconSize); + ItemDrawer()->ColumnData()->SetColumnWidthPixelL(3, KEmptySize); + + // set baseline for the text + ItemDrawer()->ColumnData()->SetColumnBaselinePosL(1, font->HeightInPixels()-font->BaselineOffsetInPixels()); + + // set margins + TMargins iconMargins; + iconMargins.iBottom = 0; + iconMargins.iLeft = normalIconSize * 0.15; + iconMargins.iRight = normalIconSize * 0.15; + iconMargins.iTop = 0; + + TMargins textMargins; + textMargins.iBottom = 0; + textMargins.iLeft = markingIconSize * 0.15; + textMargins.iRight = markingIconSize * 0.15; + textMargins.iTop = 0; + + ItemDrawer()->ColumnData()->SetColumnMarginsL(0, iconMargins); + ItemDrawer()->ColumnData()->SetColumnMarginsL(1, textMargins); + ItemDrawer()->ColumnData()->SetColumnMarginsL(2, iconMargins); + ItemDrawer()->ColumnData()->SetColumnMarginsL(3, iconMargins); + +/* + const TInt KEmptySize = 2; + + // enable marquee + ItemDrawer()->ColumnData()->EnableMarqueeL(ETrue); + + // set fonts + const CFont* font = AknLayoutUtils::FontFromId(EAknLogicalFontPrimarySmallFont); + ItemDrawer()->ColumnData()->SetColumnFontL(0, font); + ItemDrawer()->ColumnData()->SetColumnFontL(1, font); + ItemDrawer()->ColumnData()->SetColumnFontL(2, font); + ItemDrawer()->ColumnData()->SetColumnFontL(3, font); + + // set row height + TInt rowHeight = font->HeightInPixels()+7; + TSize itemCellSize = View()->ItemDrawer()->ItemCellSize(); + itemCellSize.iHeight = rowHeight; + SetItemHeightL(rowHeight); + View()->ItemDrawer()->SetItemCellSize(itemCellSize); + + // set icon sizes + TInt normalIconSize = rowHeight * 0.6; + TInt markingIconSize = rowHeight * 0.8; + ItemDrawer()->ColumnData()->SetSubCellIconSize(0, TSize(normalIconSize,normalIconSize)); + ItemDrawer()->ColumnData()->SetSubCellIconSize(2, TSize(markingIconSize,markingIconSize)); + ItemDrawer()->ColumnData()->SetSubCellIconSize(3, TSize(KEmptySize,KEmptySize)); + + // set column widths + ItemDrawer()->ColumnData()->SetColumnWidthPixelL(0, normalIconSize); + ItemDrawer()->ColumnData()->SetColumnWidthPixelL(1, itemCellSize.iWidth-KEmptySize-markingIconSize); + ItemDrawer()->ColumnData()->SetColumnWidthPixelL(2, markingIconSize); + ItemDrawer()->ColumnData()->SetColumnWidthPixelL(3, KEmptySize); + + // set baseline for the text + ItemDrawer()->ColumnData()->SetColumnBaselinePosL(1, font->HeightInPixels()-font->BaselineOffsetInPixels()); + + // set margins + TMargins iconMargins; + iconMargins.iBottom = 0; + iconMargins.iLeft = 0; + iconMargins.iRight = 0; + iconMargins.iTop = 0; + + TMargins textMargins; + textMargins.iBottom = 0; + textMargins.iLeft = markingIconSize * 0.15; + textMargins.iRight = markingIconSize * 0.15; + textMargins.iTop = 0; + + ItemDrawer()->ColumnData()->SetColumnMarginsL(0, iconMargins); + ItemDrawer()->ColumnData()->SetColumnMarginsL(1, textMargins); + ItemDrawer()->ColumnData()->SetColumnMarginsL(2, iconMargins); + ItemDrawer()->ColumnData()->SetColumnMarginsL(3, iconMargins); +*/ + } + +// -------------------------------------------------------------------------------------------- + +// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/ui/avkon/src/loadgen_mainview.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/ui/avkon/src/loadgen_mainview.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,175 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +// INCLUDE FILES +#include "loadgen.hrh" +#include "loadgen_mainview.h" +#include "loadgen_maincontainer.h" +#include "loadgen_document.h" +#include "loadgen_model.h" +#include "loadgen_traces.h" +#include + +#include +#include +#include + + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CLoadGenMainView::ConstructL(const TRect& aRect) +// EPOC two-phased constructor +// --------------------------------------------------------- +// +void CLoadGenMainView::ConstructL() + { + BaseConstructL( R_LOADGEN_VIEW_MAIN ); + iModel = static_cast(reinterpret_cast(iEikonEnv->AppUi())->Document())->Model(); + } + +// --------------------------------------------------------- +// CLoadGenMainView::~CLoadGenMainView() +// --------------------------------------------------------- +// +CLoadGenMainView::~CLoadGenMainView() + { + if (iContainer) + { + AppUi()->RemoveFromViewStack( *this, iContainer ); + delete iContainer; + iContainer = NULL; + } + } + +// --------------------------------------------------------- +// TUid CLoadGenMainView::Id() +// --------------------------------------------------------- +// +TUid CLoadGenMainView::Id() const + { + return KMainViewUID; + } + +// --------------------------------------------------------- +// TUid CLoadGenMainView::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane) +// --------------------------------------------------------- +// +void CLoadGenMainView::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane) + { + AppUi()->DynInitMenuPaneL(aResourceId, aMenuPane); + } + + +// --------------------------------------------------------- +// CLoadGenMainView::HandleCommandL(TInt aCommand) +// --------------------------------------------------------- +// +void CLoadGenMainView::HandleCommandL(TInt aCommand) + { + switch ( aCommand ) + { + case ELoadGenCmdNewLoadCPULoad: + case ELoadGenCmdNewLoadEatMemory: + case ELoadGenCmdNewLoadPhoneCall: + case ELoadGenCmdNewLoadNetConn: + case ELoadGenCmdNewLoadKeyPress: + case ELoadGenCmdNewLoadMessages: + case ELoadGenCmdNewLoadApplications: + case ELoadGenCmdNewLoadPhotoCaptures: + case ELoadGenCmdNewLoadBluetooth: + case ELoadGenCmdNewLoadPointerEvent: + { + TRAPD(err, iModel->StartNewLoadL(aCommand)); + if( err != KErrNone ) + { + LOGSTRING2("LoadGen: Load (command: %d) start failed!", aCommand); + _LIT(message, "Load start failed!"); + CAknErrorNote* errorNote = new(ELeave) CAknErrorNote; + errorNote->ExecuteLD(message); + } + break; + } + case ELoadGenStopAll: + { + iModel->StopAllLoadItemsL(); + break; + } + case ELoadGenSuspendAll: + { + iModel->SuspendAllLoadItemsL(); + break; + } + case ELoadGenResumeAll: + { + iModel->ResumeAllLoadItemsL(); + break; + } + default: + { + AppUi()->HandleCommandL(aCommand); + break; + } + } + } + +// --------------------------------------------------------- +// CLoadGenMainView::HandleClientRectChange() +// --------------------------------------------------------- +// +void CLoadGenMainView::HandleClientRectChange() + { + if ( iContainer ) + { + iContainer->SetRect( ClientRect() ); + } + } + +// --------------------------------------------------------- +// CLoadGenMainView::DoActivateL(...) +// --------------------------------------------------------- +// +void CLoadGenMainView::DoActivateL( + const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/, + const TDesC8& /*aCustomMessage*/) + { + if (!iContainer) + { + iContainer = new (ELeave) CLoadGenMainContainer; + iModel->SetMainContainer(iContainer); + iContainer->SetMopParent(this); + iContainer->ConstructL( ClientRect() ); + AppUi()->AddToStackL( *this, iContainer ); + } + } + +// --------------------------------------------------------- +// CLoadGenMainView::DoDeactivate() +// --------------------------------------------------------- +// +void CLoadGenMainView::DoDeactivate() + { + if (iContainer) + { + AppUi()->RemoveFromViewStack( *this, iContainer ); + delete iContainer; + iContainer = NULL; + } + } + +// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/ui/avkon/src/loadgen_model.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/ui/avkon/src/loadgen_model.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,910 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +// INCLUDE FILES +#include "loadgen_cpuload.h" +#include "loadgen_memoryeat.h" +#include "loadgen_phonecall.h" +#include "loadgen_netconn.h" +#include "loadgen_keypress.h" +#include "loadgen_pointerevent.h" +#include "loadgen_messages.h" +#include "loadgen_applications.h" +#include "loadgen_photocapture.h" +#include "loadgen_bluetooth.h" +#include "loadgen_utils.h" + +#include "loadgen_traces.h" +#include "loadgen_editors.h" +#include "loadgen_loadattributes.h" +#include "loadgen_model.h" +#include "loadgen_app.h" +#include "loadgen_settingsviewdlg.h" +#include "loadgen_maincontainer.h" +#include "loadgen.hrh" +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +inline TInt64 INIT_SEED() +{ + TTime now; + now.HomeTime(); + return now.Int64(); +} + +TInt64 CLoadGenModel::iRandomNumberSeed = INIT_SEED(); + +// ===================================== MEMBER FUNCTIONS ===================================== + +CLoadGenModel* CLoadGenModel::NewL() + { + CLoadGenModel* self = new(ELeave) CLoadGenModel; + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +// -------------------------------------------------------------------------------------------- + +CLoadGenModel::CLoadGenModel() : CActive(EPriorityStandard) + { + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenModel::ConstructL() + { + iDrawState = EDrawStateInvalid; + iReferenceNumber = 0; + + iEnv = CEikonEnv::Static(); + User::LeaveIfError(iLs.Connect()); + + iLoadItemList = new(ELeave) CLoadItemList(64); + + User::LeaveIfError(iTimer.CreateLocal()); + CActiveScheduler::Add(this); + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenModel::ActivateModelL() + { + // load settings + //TRAP_IGNORE(LoadSettingsL()); + + // set defaults to attributes + iCpuLoadAttributes.iId = 0; + iCpuLoadAttributes.iPriority = EThreadPriorityTypeNormal; + iCpuLoadAttributes.iMode = ECpuLoadModeYielding; + iCpuLoadAttributes.iType = ECpuLoadTypePeriodic; + iCpuLoadAttributes.iLength = 4000; + iCpuLoadAttributes.iIdle = 2000; + iCpuLoadAttributes.iRandomVariance = 0; + iCpuLoadAttributes.iCpu = KCPUSelection_FreeScheduling; // set CPU as "undefined" (can be >= 0 only in SMP environments) + iCpuLoadAttributes.iCpuCount = UserSvr::HalFunction(EHalGroupKernel, KHalFunction_EKernelHalNumLogicalCpus, 0, 0); + if( iCpuLoadAttributes.iCpuCount < 1 || iCpuLoadAttributes.iCpuCount > KMaxCPUs ) + { + // HAL may not support this function, so let's use CPU count 1: + iCpuLoadAttributes.iCpuCount = 1; + } + iMemoryEatAttributes.iId = 0; + iMemoryEatAttributes.iPriority = EThreadPriorityTypeNormal; + iMemoryEatAttributes.iSource = 0; + iMemoryEatAttributes.iType = EMemoryEatTypeMemoryToBeLeft; + iMemoryEatAttributes.iBuffer = 16*1024; + iMemoryEatAttributes.iIdle = 0; + iMemoryEatAttributes.iAmount = 0; + iMemoryEatAttributes.iRandomMin = 1000000; + iMemoryEatAttributes.iRandomMax = 1500000; + iMemoryEatAttributes.iAmountDes.Copy(KNullDesC); + iMemoryEatAttributes.iRandomMinDes.Copy(KNullDesC); + iMemoryEatAttributes.iRandomMaxDes.Copy(KNullDesC); + iMemoryEatAttributes.iRandomVariance = 0; + + iPhoneCallAttributes.iId = 0; + iPhoneCallAttributes.iPriority = EThreadPriorityTypeNormal; + iPhoneCallAttributes.iDestination.Copy(_L("+358")); + iPhoneCallAttributes.iLength = 60000; + iPhoneCallAttributes.iIdle = 10000; + iPhoneCallAttributes.iRandomVariance = 0; + + iNetConnAttributes.iId = 0; + iNetConnAttributes.iPriority = EThreadPriorityTypeNormal; + iNetConnAttributes.iDestination.Copy(_L("http://www.nokia.com")); + iNetConnAttributes.iIdle = 10000; + iNetConnAttributes.iRandomVariance = 0; + + iKeyPressAttributes.iId = 0; + iKeyPressAttributes.iPriority = EThreadPriorityTypeNormal; + iKeyPressAttributes.iHeartBeat = 100; + iKeyPressAttributes.iRandomVariance = 0; + + iPointerEventAttributes.iId = 0; + iPointerEventAttributes.iPriority = EThreadPriorityTypeNormal; + iPointerEventAttributes.iHeartBeat = 1000; + iPointerEventAttributes.iRandomVariance = 0; + + iMessageAttributes.iId = 0; + iMessageAttributes.iPriority = EThreadPriorityTypeNormal; + iMessageAttributes.iMessageType = EMessageTypeSMS; + iMessageAttributes.iDestination.Copy(_L("+358")); + iMessageAttributes.iAmount = 5; + iMessageAttributes.iLength = 160; + iMessageAttributes.iIdle = 15000; + iMessageAttributes.iRandomVariance = 0; + + iApplicationsAttributes.iId = 0; + iApplicationsAttributes.iLaunchingInterval = 2000; + iApplicationsAttributes.iPriority = EThreadPriorityTypeNormal; + iApplicationsAttributes.iKeyPressType = EApplicationsKeyPressTypeNone; + iApplicationsAttributes.iMaxOpen = 20; + iApplicationsAttributes.iHeartBeat = 50; + iApplicationsAttributes.iRandomVariance = 0; + + iPhotoCaptureAttributes.iId = 0; + iPhotoCaptureAttributes.iPriority = EThreadPriorityTypeNormal; + iPhotoCaptureAttributes.iIdle = 10000; + iPhotoCaptureAttributes.iRandomVariance = 0; + iPhotoCaptureAttributes.iCameraCount = CCamera::CamerasAvailable(); + if(iPhotoCaptureAttributes.iCameraCount > 0) + { + iPhotoCaptureAttributes.iCamera = 0; // Main camera + } + else + { + iPhotoCaptureAttributes.iCamera = -1; + } + + iBluetoothAttributes.iId = 0; + iBluetoothAttributes.iPriority = EThreadPriorityTypeNormal; + iBluetoothAttributes.iIdle = 10000; + iBluetoothAttributes.iRandomVariance = 0; + iBluetoothAttributes.iBluetoothSupported = CFeatureDiscovery::IsFeatureSupportedL(KFeatureIdBt); + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenModel::DeActivateModelL() + { + Cancel(); + + // for a faster exit, send the application to background + TApaTask selfTask(iEnv->WsSession()); + selfTask.SetWgId(iEnv->RootWin().Identifier()); + selfTask.SendToBackground(); + } + +// -------------------------------------------------------------------------------------------- + +CLoadGenModel::~CLoadGenModel() + { + if (iLoadItemList) + { + DeleteAllLoadItems(); + delete iLoadItemList; + } + if ( iApplicationsAttributes.iAppsArray ) + { + delete iApplicationsAttributes.iAppsArray; + } + iTimer.Close(); + iLs.Close(); + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenModel::DoCancel() + { + iTimer.Cancel(); + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenModel::RunL() + { + // continue + //iTimer.After(iStatus, 400000); + //SetActive(); + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenModel::SetMainContainer(CLoadGenMainContainer* aContainer) + { + iMainContainer = aContainer; + iDrawState = EDrawStateMain; + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenModel::StartNewLoadL(TInt aCommand) + { + // show new load query + CLoadGenLoadTypeEditorBase* dlg = NULL; + + switch ( aCommand ) + { + case ELoadGenCmdNewLoadCPULoad: + { + dlg = CLoadGenCPULoadEditor::NewL(iCpuLoadAttributes); + break; + } + case ELoadGenCmdNewLoadEatMemory: + { + dlg = CLoadGenMemoryEatEditor::NewL(iMemoryEatAttributes); + break; + } + case ELoadGenCmdNewLoadPhoneCall: + { + dlg = CLoadGenPhoneCallEditor::NewL(iPhoneCallAttributes); + break; + } + case ELoadGenCmdNewLoadNetConn: + { + dlg = CLoadGenNetConnEditor::NewL(iNetConnAttributes); + break; + } + case ELoadGenCmdNewLoadKeyPress: + { + dlg = CLoadGenKeyPressEditor::NewL(iKeyPressAttributes); + break; + } + case ELoadGenCmdNewLoadMessages: + { + dlg = CLoadGenMessagesEditor::NewL( iMessageAttributes ); + break; + } + case ELoadGenCmdNewLoadApplications: + { + dlg = CLoadGenApplicationsEditor::NewL( iApplicationsAttributes ); + break; + } + case ELoadGenCmdNewLoadPhotoCaptures: + { + if( iPhotoCaptureAttributes.iCameraCount > 0 ) + { + dlg = CLoadGenPhotoCaptureEditor::NewL( iPhotoCaptureAttributes ); + } + else + { + _LIT(message, "Cameras not available"); + CAknErrorNote* errorNote = new(ELeave) CAknErrorNote; + errorNote->ExecuteLD(message); + return; + } + break; + } + case ELoadGenCmdNewLoadBluetooth: + { + if( iBluetoothAttributes.iBluetoothSupported ) + { + dlg = CLoadGenBluetoothEditor::NewL(iBluetoothAttributes); + } + else + { + _LIT(message, "Bluetooth device not available"); + CAknErrorNote* errorNote = new(ELeave) CAknErrorNote; + errorNote->ExecuteLD(message); + return; + } + break; + } + case ELoadGenCmdNewLoadPointerEvent: + { + dlg = CLoadGenPointerEventEditor::NewL(iPointerEventAttributes); + break; + } + + default: + { + User::Panic(_L("Wrong new load"), 111); + break; + } + } + + TBool dlgResult = dlg->RunQueryLD(); + + // set back title + if (iMainContainer) + iMainContainer->SetDefaultTitlePaneTextL(); + + // start creating new load if dialog accepted + if (dlgResult) + { + DoStartNewLoadL(aCommand); + } + + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenModel::EditLoadL(CLoadBase* aItem) + { + // suspend current + aItem->Suspend(); + + // show new load query + CLoadGenLoadTypeEditorBase* dlg = NULL; + + switch ( aItem->Type() ) + { + case ELoadGenCmdNewLoadCPULoad: + { + dlg = CLoadGenCPULoadEditor::NewL(static_cast(aItem)->Attributes(), ETrue); + break; + } + case ELoadGenCmdNewLoadEatMemory: + { + dlg = CLoadGenMemoryEatEditor::NewL(static_cast(aItem)->Attributes(), ETrue); + break; + } + case ELoadGenCmdNewLoadPhoneCall: + { + dlg = CLoadGenPhoneCallEditor::NewL(static_cast(aItem)->Attributes(), ETrue); + break; + } + case ELoadGenCmdNewLoadNetConn: + { + dlg = CLoadGenNetConnEditor::NewL(static_cast(aItem)->Attributes(), ETrue); + break; + } + case ELoadGenCmdNewLoadKeyPress: + { + dlg = CLoadGenKeyPressEditor::NewL(static_cast(aItem)->Attributes(), ETrue); + break; + } + case ELoadGenCmdNewLoadMessages: + { + dlg = CLoadGenMessagesEditor::NewL(static_cast(aItem)->Attributes(), ETrue); + break; + } + case ELoadGenCmdNewLoadApplications: + { + dlg = CLoadGenApplicationsEditor::NewL( static_cast(aItem)->Attributes(), ETrue ); + break; + } + case ELoadGenCmdNewLoadPhotoCaptures: + { + dlg = CLoadGenPhotoCaptureEditor::NewL( static_cast(aItem)->Attributes(), ETrue ); + break; + } + case ELoadGenCmdNewLoadBluetooth: + { + dlg = CLoadGenBluetoothEditor::NewL( static_cast(aItem)->Attributes(), ETrue ); + break; + } + case ELoadGenCmdNewLoadPointerEvent: + { + dlg = CLoadGenPointerEventEditor::NewL(static_cast(aItem)->Attributes(), ETrue); + break; + } + default: + { + User::Panic(_L("Wrong edit load"), 114); + break; + } + } + + TBool dlgResult = dlg->RunQueryLD(); + + // set back title + if (iMainContainer) + iMainContainer->SetDefaultTitlePaneTextL(); + + // change priority of the load item + aItem->SetPriority(); + + // resume execution the item + aItem->Resume(); + + if (dlgResult) + RefreshViewL(EFalse); + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenModel::DoStartNewLoadL(TInt aCommand) + { + CLoadBase* item = NULL; + + switch ( aCommand ) + { + case ELoadGenCmdNewLoadCPULoad: + { + if( iCpuLoadAttributes.iCpu == KCPUSelection_AllCPUs ) + { + // Call this function recursively for all CPUs: + for( TUint i = 0; i < iCpuLoadAttributes.iCpuCount; ++i ) + { + iCpuLoadAttributes.iCpu = i; + DoStartNewLoadL(aCommand); + } + // And finally set user selection back to "All CPUs" + iCpuLoadAttributes.iCpu = KCPUSelection_AllCPUs; + return; + } + else + { + item = CCPULoad::NewL(iCpuLoadAttributes, iReferenceNumber); + } + break; + } + case ELoadGenCmdNewLoadEatMemory: + { + item = CMemoryEat::NewL(iMemoryEatAttributes, iReferenceNumber); + break; + } + case ELoadGenCmdNewLoadPhoneCall: + { + item = CPhoneCall::NewL(iPhoneCallAttributes, iReferenceNumber); + break; + } + case ELoadGenCmdNewLoadNetConn: + { + item = CNetConn::NewL(iNetConnAttributes, iReferenceNumber); + break; + } + case ELoadGenCmdNewLoadKeyPress: + { + item = CKeyPress::NewL(iKeyPressAttributes, iReferenceNumber); + break; + } + case ELoadGenCmdNewLoadMessages: + { + item = CMessages::NewL( iMessageAttributes, iReferenceNumber ); + break; + } + case ELoadGenCmdNewLoadApplications: + { + iApplicationsAttributes.iAppsArray = ListOfAllAppsL(); + item = CAppLauncher::NewL( iApplicationsAttributes, iReferenceNumber ); + break; + } + case ELoadGenCmdNewLoadPhotoCaptures: + { + item = CPhotoCapture::NewL( iPhotoCaptureAttributes, iReferenceNumber); + break; + } + case ELoadGenCmdNewLoadBluetooth: + { + item = CBluetooth::NewL( iBluetoothAttributes, iReferenceNumber); + break; + } + case ELoadGenCmdNewLoadPointerEvent: + { + item = CPointerEvent::NewL(iPointerEventAttributes, iReferenceNumber); + break; + } + + default: + { + User::Panic(_L("Wrong new load"), 112); + break; + } + } + + iReferenceNumber++; + + // add item to the array + AppendToLoadItemListL(item); + + // update the listbox + RefreshViewL(EFalse); + + // set item index to the end + iMainContainer->ListBox()->SetCurrentItemIndexAndDraw( iMainContainer->ListBox()->Model()->NumberOfItems()-1 ); + + // start the load + item->Resume(); + + // refresh again + RefreshViewL(EFalse); + } + +// -------------------------------------------------------------------------------------------- + + +void CLoadGenModel::StopAllLoadItemsL() + { + DeleteAllLoadItems(); + + RefreshViewL(); + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenModel::SuspendAllLoadItemsL() + { + for (TInt i=0; iAt(i) ) + { + iLoadItemList->At(i)->Suspend(); + } + } + + RefreshViewL(); + } +// -------------------------------------------------------------------------------------------- + +void CLoadGenModel::ResumeAllLoadItemsL() + { + for (TInt i=0; iAt(i) ) + { + iLoadItemList->At(i)->Resume(); + } + } + + RefreshViewL(); + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenModel::RefreshViewL(TBool aClearSelection) + { + if (iMainContainer && iDrawState == EDrawStateMain && iMainContainer->ListBox()) + { + // clear selections if any + iMainContainer->ListBox()->ClearSelection(); + + // set item index to 0 + if (aClearSelection) + iMainContainer->ListBox()->SetCurrentItemIndex(0); + + // set text items + iMainContainer->SetListBoxTextArrayL(GenerateListBoxItemTextArrayL()); + } + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenModel::AppendToLoadItemListL(CLoadBase* aItem) + { + if (iLoadItemList) + iLoadItemList->AppendL( aItem ); + else + User::Leave(KErrNotReady); + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenModel::DeleteFromLoadItemListL(TInt aIndex) + { + if (iLoadItemList) + { + if (iLoadItemList->Count() > aIndex && aIndex >= 0) + { + // first call delete on the item + if (iLoadItemList->At(aIndex)) + { + delete iLoadItemList->At(aIndex); + iLoadItemList->At(aIndex) = NULL; + } + + // and them remove the array entry + iLoadItemList->Delete(aIndex); + iLoadItemList->Compress(); + } + else + User::Leave(KErrNotFound); + } + else + User::Leave(KErrNotReady); + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenModel::SuspendOrResumeFromLoadItemListL(TInt aIndex) + { + if (iLoadItemList) + { + if (iLoadItemList->Count() > aIndex && aIndex >= 0) + { + if (iLoadItemList->At(aIndex)) + { + if (iLoadItemList->At(aIndex)->State() == CLoadBase::ELoadStateRunning) + { + iLoadItemList->At(aIndex)->Suspend(); + } + else if (iLoadItemList->At(aIndex)->State() == CLoadBase::ELoadStateSuspended) + { + iLoadItemList->At(aIndex)->Resume(); + } + } + } + else + User::Leave(KErrNotFound); + } + else + User::Leave(KErrNotReady); + } + +// -------------------------------------------------------------------------------------------- + +TInt CLoadGenModel::LoadItemCount() const + { + TInt count(0); + + if (iLoadItemList) + count = iLoadItemList->Count(); + + return count; + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenModel::DeleteAllLoadItems() + { + // call delete for each entry and free memory allocated for the array + for (TInt i=0; iAt(i) ) + { + delete iLoadItemList->At(i); + iLoadItemList->At(i) = NULL; + } + } + + iLoadItemList->Reset(); + } + +// -------------------------------------------------------------------------------------------- + +CDesCArray* CLoadGenModel::GenerateListBoxItemTextArrayL() + { + CDesCArray* textArray = new(ELeave) CDesCArrayFlat(64); + CleanupStack::PushL(textArray); + + _LIT(KEntryTemplateRedIcon, "1\t%S\t\t"); + _LIT(KEntryTemplateGreenIcon, "2\t%S\t\t"); + + for (TInt i=0; i textEntry; + TBuf<256> description = iLoadItemList->At(i)->Description(); + + if (iLoadItemList->At(i)->State() == CLoadBase::ELoadStateRunning) + textEntry.Format(KEntryTemplateGreenIcon, &description); + else + textEntry.Format(KEntryTemplateRedIcon, &description); + + textArray->AppendL(textEntry); + } + + CleanupStack::Pop(); //textArray + return textArray; + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenModel::ShowItemActionMenuL() + { + TInt currentItemIndex = iMainContainer->CurrentListBoxItemIndex(); + + if (LoadItemCount() > currentItemIndex && currentItemIndex >= 0) + { + // show a query dialog + TInt queryIndex(0); + CAknListQueryDialog* listQueryDlg = new(ELeave) CAknListQueryDialog(&queryIndex); + + if (listQueryDlg->ExecuteLD(R_ITEM_ACTION_QUERY)) + { + // stop + if (queryIndex == EItemActionMenuTypeStop) + { + StopSelectedOrHighlightedItemsL(); + } + + // suspend or resume + else if (queryIndex == EItemActionMenuTypeSuspendResume) + { + SuspendOrResumeSelectedOrHighlightedItemsL(); + } + + // edit + else if (queryIndex == EItemActionMenuTypeEdit) + { + EditLoadL(iLoadItemList->At(currentItemIndex)); + } + } + } + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenModel::StopSelectedOrHighlightedItemsL() + { + const CArrayFix* selectionIndexes = iMainContainer->ListBoxSelectionIndexes(); + + TInt err(KErrNone); + + // by default use selected items + if (selectionIndexes && selectionIndexes->Count() > 0) + { + CAknQueryDialog* query = CAknQueryDialog::NewL(); + _LIT(KQueryMessage, "Stop %d selections?"); + TFileName queryMsg; + queryMsg.Format(KQueryMessage, selectionIndexes->Count()); + + + if (query->ExecuteLD(R_GENERAL_CONFIRMATION_QUERY, queryMsg)) + { + TInt deleteIndexCounter(0); + TInt ref(0); + TKeyArrayFix key(0, ECmpTUint16); + TInt index(0); + + TInt loadCount = LoadItemCount(); + + for (TInt i=0; iFind(ref, key, index) == 0) + { + TRAP(err, DeleteFromLoadItemListL(i-deleteIndexCounter)); + deleteIndexCounter++; // amount of indexes decreases after each delete + } + } + + RefreshViewL(); + User::LeaveIfError(err); + } + } + + // or if none selected, use the current item index + else + { + TInt currentItemIndex = iMainContainer->CurrentListBoxItemIndex(); + + if (LoadItemCount() > currentItemIndex && currentItemIndex >= 0) + { + CAknQueryDialog* query = CAknQueryDialog::NewL(); + _LIT(KQueryMessage, "Stop hightlighted item?"); + + if (query->ExecuteLD(R_GENERAL_CONFIRMATION_QUERY, KQueryMessage)) + { + TRAP(err, DeleteFromLoadItemListL(currentItemIndex)); + + RefreshViewL(); + User::LeaveIfError(err); + } + } + } + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenModel::SuspendOrResumeSelectedOrHighlightedItemsL() + { + const CArrayFix* selectionIndexes = iMainContainer->ListBoxSelectionIndexes(); + + // by default use selected items + if (selectionIndexes && selectionIndexes->Count() > 0) + { + TInt ref(0); + TKeyArrayFix key(0, ECmpTUint16); + TInt index(0); + + for (TInt i=0; iFind(ref, key, index) == 0) + { + SuspendOrResumeFromLoadItemListL(i); + } + } + + RefreshViewL(EFalse); + } + + // or if none selected, use the current item index + else + { + TInt currentItemIndex = iMainContainer->CurrentListBoxItemIndex(); + + if (LoadItemCount() > currentItemIndex && currentItemIndex >= 0) + { + SuspendOrResumeFromLoadItemListL(currentItemIndex); + + RefreshViewL(EFalse); + } + } + } +// -------------------------------------------------------------------------------------------- + +void CLoadGenModel::LoadSettingsL() + { + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenModel::SaveSettingsL() + { + } + +// -------------------------------------------------------------------------------------------- + +TInt CLoadGenModel::LaunchSettingsDialogL() + { + return 0; + } + +// -------------------------------------------------------------------------------------------- + +CDesCArray* CLoadGenModel::ListOfAllAppsL() + { + const TInt KMaxAppsArraySize=250; + RApaLsSession ls; + CleanupClosePushL(ls); + + User::LeaveIfError( ls.Connect() ); + CDesCArray* allAppsArray = new(ELeave) CDesCArrayFlat( KMaxAppsArraySize ); + CleanupStack::PushL( allAppsArray ); + // reset the apps list + allAppsArray->Reset(); + + // search all apps + TApaAppInfo appInfo; + User::LeaveIfError(ls.GetAllApps()); + + + while ( ls.GetNextApp( appInfo ) == KErrNone ) + { + allAppsArray->AppendL( appInfo.iFullName ); + } + CleanupStack::Pop( allAppsArray ); + CleanupStack::PopAndDestroy( &ls ); + + + // remove loadgen.* from the list + for ( TInt i = 0; i < allAppsArray->MdcaCount(); i++ ) + { + if ( allAppsArray->MdcaPoint(i).FindF( _L("\\loadgen.") ) != KErrNotFound ) + { + allAppsArray->Delete(i); + allAppsArray->Compress(); + break; + } + } + + // sort the elements + allAppsArray->Sort(); + + return allAppsArray; // ownership transferred + } + +// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/ui/avkon/src/loadgen_settingsviewdlg.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/ui/avkon/src/loadgen_settingsviewdlg.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,323 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +// INCLUDE FILES +#include "loadgen_settingsviewdlg.h" +#include "loadgen_model.h" +#include "loadgen.hrh" +#include "loadgen_std.h" +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +// ===================================== MEMBER FUNCTIONS ===================================== + +CLoadGenSettingsViewDlg* CLoadGenSettingsViewDlg::NewL(TLoadGenSettings& aSettings) + { + CLoadGenSettingsViewDlg* self = new(ELeave) CLoadGenSettingsViewDlg(aSettings); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// -------------------------------------------------------------------------------------------- + +CLoadGenSettingsViewDlg::~CLoadGenSettingsViewDlg() + { + // restore default navi pane + if (iNaviContainer) + iNaviContainer->Pop(); + + if (iSettingItemArray) + { + iSettingItemArray->ResetAndDestroy(); + delete iSettingItemArray; + } + + delete iDecoratedTabGroup; + } + +// -------------------------------------------------------------------------------------------- + +CLoadGenSettingsViewDlg::CLoadGenSettingsViewDlg(TLoadGenSettings& aSettings) : iSettings(aSettings) + { + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenSettingsViewDlg::ConstructL() + { + // construct a menu bar + CAknDialog::ConstructL(R_LOADGEN_SETTINGS_MENUBAR); + + CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane(); + + // set empty navi pane label + iNaviContainer = static_cast(sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi))); + //iNaviContainer->PushDefaultL(); + + // set title text + CAknTitlePane* tp = static_cast( sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); + tp->SetTextL( _L("Settings") ); + + // create a tab group + iDecoratedTabGroup = iNaviContainer->CreateTabGroupL(this); + iTabGroup = static_cast(iDecoratedTabGroup->DecoratedControl()); + iTabGroup->SetTabFixedWidthL(KTabWidthWithTwoLongTabs); + + // add tabs + //iTabGroup->AddTabL(ETabGeneral, _L("General")); + //iTabGroup->AddTabL(ETabScreenShot, _L("Screen shot")); + //iTabGroup->SetActiveTabByIndex(ETabGeneral); + + iNaviContainer->PushL( *iDecoratedTabGroup ); + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenSettingsViewDlg::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aEventType) + { + switch (aEventType) + { + case EEventEnterKeyPressed: + case EEventItemDoubleClicked: + ShowSettingPageL(EFalse); + break; + default: + break; + } + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenSettingsViewDlg::TabChangedL(TInt /*aIndex*/) + { + iListBox->SetCurrentItemIndex(0); + + SetVisibilitiesOfSettingItemsL(); + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenSettingsViewDlg::ProcessCommandL(TInt aCommandId) + { + CAknDialog::ProcessCommandL(aCommandId); + + switch (aCommandId) + { + case ELoadGenCmdSettingsChange: + ShowSettingPageL(ETrue); + break; + case ELoadGenCmdSettingsExit: + TryExitL(EAknCmdExit); + break; + default: + break; + } + } + +// -------------------------------------------------------------------------------------------- + +TKeyResponse CLoadGenSettingsViewDlg::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType) + { + if (iTabGroup == NULL) + { + return EKeyWasNotConsumed; + } + + TInt active = iTabGroup->ActiveTabIndex(); + TInt count = iTabGroup->TabCount(); + + switch ( aKeyEvent.iCode ) + { + case EKeyLeftArrow: + if (active > 0) + { + active--; + iTabGroup->SetActiveTabByIndex(active); + TabChangedL(active); + } + break; + + case EKeyRightArrow: + if((active + 1) < count) + { + active++; + iTabGroup->SetActiveTabByIndex(active); + TabChangedL(active); + } + break; + } + + return CAknDialog::OfferKeyEventL(aKeyEvent, aType); + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenSettingsViewDlg::PreLayoutDynInitL() + { + iListBox = static_cast( Control(ELoadGenSettingItemList) ); + iListBox->SetMopParent(this); + iListBox->CreateScrollBarFrameL(ETrue); + iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto); + iListBox->SetListBoxObserver(this); + + iSettingItemArray = new(ELeave) CAknSettingItemArray(16, EFalse, 0); + + CTextListBoxModel* model = iListBox->Model(); + model->SetItemTextArray(iSettingItemArray); + model->SetOwnershipType(ELbmDoesNotOwnItemArray); + + UpdateListBoxL(); + } + +// -------------------------------------------------------------------------------------------- + +TBool CLoadGenSettingsViewDlg::OkToExitL(TInt aButtonId) + { + return CAknDialog::OkToExitL(aButtonId); + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenSettingsViewDlg::ShowSettingPageL(TInt aCalledFromMenu) + { + TInt listIndex = iListBox->CurrentItemIndex(); + TInt realIndex = iSettingItemArray->ItemIndexFromVisibleIndex(listIndex); + CAknSettingItem* item = iSettingItemArray->At(realIndex); + item->EditItemL(aCalledFromMenu); + item->StoreL(); + SetVisibilitiesOfSettingItemsL(); + DrawNow(); + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenSettingsViewDlg::SetVisibilitiesOfSettingItemsL() + { + if (iSettingItemArray->Count() > 0) + { +/* + switch (iTabGroup->ActiveTabIndex()) + { + + case ETabGeneral: + { + ((*iSettingItemArray)[ESettingListDisplayModeSelection])->SetHidden(EFalse); + ((*iSettingItemArray)[ESettingListFileViewModeSelection])->SetHidden(EFalse); + break; + } + + case ETabScreenShot: + { + ((*iSettingItemArray)[ESettingListDisplayModeSelection])->SetHidden(ETrue); + ((*iSettingItemArray)[ESettingListFileViewModeSelection])->SetHidden(ETrue); + break; + } + + default: + User::Panic(_L("TabIOOB"), 50); + break; + } +*/ + iSettingItemArray->RecalculateVisibleIndicesL(); + iListBox->HandleItemAdditionL(); + iListBox->UpdateScrollBarsL(); + } + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenSettingsViewDlg::UpdateListBoxL() + { + iSettingItemArray->ResetAndDestroy(); + +/* + // create items + TInt ordinal(0); + + AddSettingItemL(ESettingListDisplayModeSelection, + R_DISPLAYMODESELECTION_SETTING_TITLE, + R_DISPLAYMODESELECTION_SETTING_PAGE, + R_DISPLAYMODESELECTION_SETTING_TEXTS, + ordinal++); + + AddSettingItemL(ESettingListFileViewModeSelection, + R_FILEVIEWMODESELECTION_SETTING_TITLE, + R_FILEVIEWMODESELECTION_SETTING_PAGE, + R_FILEVIEWMODESELECTION_SETTING_TEXTS, + ordinal++); +*/ + SetVisibilitiesOfSettingItemsL(); + } + +// -------------------------------------------------------------------------------------------- + +void CLoadGenSettingsViewDlg::AddSettingItemL(TInt aId, + TInt aTitleResource, + TInt aSettingPageResource, + TInt aAssociatedResource, + TInt aOrdinal) + { + // create a setting item + CAknSettingItem* settingItem = NULL; + + switch (aId) + { +/* + case ESettingListDisplayModeSelection: + settingItem = new(ELeave) CAknEnumeratedTextPopupSettingItem(aId, iSettings.iDisplayMode); + break; + + case ESettingListFileViewModeSelection: + settingItem = new(ELeave) CAknEnumeratedTextPopupSettingItem(aId, iSettings.iFileViewMode); + break; + + default: + User::Panic(_L("NotSetItem"), 50); + break; +*/ + } + + CleanupStack::PushL(settingItem); + + // get title text + HBufC* itemTitle = StringLoader::LoadLC(aTitleResource); + + // construct the setting item + settingItem->ConstructL(EFalse, aOrdinal, *itemTitle, NULL, aSettingPageResource, + EAknCtPopupSettingList, NULL, aAssociatedResource); + + // append the setting item to settingitem array + iSettingItemArray->InsertL(aOrdinal, settingItem); + + CleanupStack::PopAndDestroy(); //itemTitle + CleanupStack::Pop(); //settingItem + } + +// -------------------------------------------------------------------------------------------- + +// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/ui/hb/hb.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/ui/hb/hb.pro Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,110 @@ +# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# Initial Contributors: +# Nokia Corporation - initial contribution. +# Contributors: +# Description: +TEMPLATE = app +TARGET = LoadGen +DEPENDPATH += . +INCLUDEPATH += . \ + /inc +INCLUDEPATH += ./inc \ + ../../engine/inc +load(hb.prf) +symbian:CONFIG -= symbian_i18n +HEADERS += inc/mainview.h \ + inc/settingsview.h \ + inc/notifications.h \ + inc/loadgenlistitem.h \ + inc/loadgenloaditem.h +SOURCES += src/main.cpp \ + src/mainview.cpp \ + src/settingsview.cpp \ + src/notifications.cpp \ + src/loadgenlistitem.cpp \ + src/loadgenloaditem.cpp +RESOURCES += loadgen.qrc +symbian: { + MMP_RULES -= PAGED + MMP_RULES *= UNPAGEDDATA + MMP_RULES += SMPSAFE + BLD_INF_RULES.prj_exports += "./rom/loadgen.iby CORE_IBY_EXPORT_PATH(tools,loadgen.iby)" + INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE + INCLUDEPATH += /epoc32/include/mw/http + HEADERS += inc/engine.h \ + inc/enginewrapper.h + SOURCES += src/engine.cpp \ + src/enginewrapper.cpp \ + ../../engine/src/loadgen_utils.cpp \ + ../../engine/src/loadgen_loadbase.cpp \ + ../../engine/src/loadgen_cpuload.cpp \ + ../../engine/src/loadgen_memoryeat.cpp \ + ../../engine/src/loadgen_phonecall.cpp \ + ../../engine/src/loadgen_keypress.cpp \ + ../../engine/src/loadgen_messages.cpp \ + ../../engine/src/loadgen_applications.cpp \ + ../../engine/src/loadgen_photocapture.cpp \ + ../../engine/src/loadgen_bluetooth.cpp \ + ../../engine/src/loadgen_pointerevent.cpp \ + ../../engine/src/loadgen_netconn.cpp \ + ../../engine/src/loadgen_httpreceiver.cpp + RSS_RULES += "group_name = \"RnD Tools\""; + LIBS += -leuser \ + -lcommonengine \ + -lapparc \ + -lcone \ + -leikcore \ + -leikcoctl \ + -leikctl \ + -leikdlg \ + -lws32 \ + -lapgrfx \ + -lefsrv \ + -lbafl \ + -lgdi \ + -legul \ + -letel3rdparty \ + -lcommdb \ + -lflogger \ + -lestor \ + -lmsgs \ + -lsmcm \ + -lgsmu \ + -letext \ + -lsendas2 \ + -lecam \ + -lfeatdiscovery \ + -lcentralrepository \ + -lesock \ + -lbluetooth \ + -lhal \ + -lhttp \ + -linetprotutil + TARGET.CAPABILITY = swevent \ + ReadUserData \ + WriteUserData \ + NetworkServices \ + UserEnvironment \ + CAP_APPLICATION \ + AllFiles + TARGET.UID2 = 0x100039CE + TARGET.UID3 = 0x20011384 + // TARGET.SID = 0x20011384 + TARGET.VID = 0x101FB657 \ + // \ + Nokia + TARGET.EPOCHEAPSIZE = 0x10000 \ + 0x1000000 \ + // \ + Min \ + 64Kb, \ + Max \ + 16Mb + ICON = ../../icons/LoadGen_application_icon_svgt.svg +} +else:error("Only Symbian supported!") diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/ui/hb/hb_.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/ui/hb/hb_.mmp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,95 @@ +// ============================================================================== +// Generated by qmake (2.01a) (Qt 4.7.0) on: 2010-08-17T10:36:03 +// This file is generated by qmake and should not be modified by the +// user. +// Name : hb.mmp +// ============================================================================== + +TARGET LoadGen.exe +TARGETTYPE EXE + +UID +SECUREID 0 + + +SOURCEPATH . +LANG SC +START RESOURCE LoadGen.rss +HEADER +TARGETPATH /resource/apps +END + +SOURCEPATH . +START RESOURCE LoadGen_reg.rss +DEPENDS LoadGen.rsg +TARGETPATH /private/10003a3f/import/apps +END + + +// Qt Macros +MACRO UNICODE +MACRO QT_KEYPAD_NAVIGATION +MACRO QT_SOFTKEYS_ENABLED +MACRO QT_USE_MATH_H_FLOATS +MACRO HB_HAVE_QT_MOBILITY +MACRO HB_HAVE_PROTECTED_CHUNK +MACRO HB_TOUCHFEEDBACK_TYPE_IS_LONGPRESS +MACRO HB_GESTURE_FW +MACRO HB_EFFECTS +MACRO HB_TEXT_MEASUREMENT_UTILITY +MACRO HB_HAVE_QT_MOBILITY +MACRO HB_HAVE_PROTECTED_CHUNK +MACRO HB_TOUCHFEEDBACK_TYPE_IS_LONGPRESS +MACRO HB_GESTURE_FW +MACRO HB_EFFECTS +MACRO HB_TEXT_MEASUREMENT_UTILITY + +SYSTEMINCLUDE ../../../sf/mw/qt/mkspecs/common/symbian/stl-off +SYSTEMINCLUDE ../../../sf/mw/qt/mkspecs/common/symbian +SYSTEMINCLUDE /epoc32/include +SYSTEMINCLUDE /epoc32/include/stdapis +SYSTEMINCLUDE /epoc32/include/stdapis/sys +SYSTEMINCLUDE /epoc32/include/mw +SYSTEMINCLUDE /epoc32/include/platform/mw +SYSTEMINCLUDE /epoc32/include/platform +SYSTEMINCLUDE /epoc32/include/platform/loc +SYSTEMINCLUDE /epoc32/include/platform/mw/loc +SYSTEMINCLUDE /epoc32/include/platform/loc/sc +SYSTEMINCLUDE /epoc32/include/platform/mw/loc/sc +SYSTEMINCLUDE . +SYSTEMINCLUDE ../../../inc +SYSTEMINCLUDE inc +SYSTEMINCLUDE ../../engine/inc +SYSTEMINCLUDE /epoc32/include/mw/hb/hbcore +SYSTEMINCLUDE /epoc32/include/mw/hb/hbwidgets +SYSTEMINCLUDE /epoc32/include/mw/hb/hbutils + + +LIBRARY HbCore.lib +LIBRARY HbWidgets.lib +LIBRARY HbUtils.lib +LIBRARY libc.lib +LIBRARY libm.lib +LIBRARY euser.lib +LIBRARY libdl.lib + +CAPABILITY None + +OPTION CW -cwd include +OPTION ARMCC --visibility_inlines_hidden +#if defined(ARMCC_4_0) +OPTION ARMCC --import_all_vtbl +#endif +OPTION GCCE -fvisibility-inlines-hidden + +VERSION 10.0 + +ARMFPU softvfp + +PAGED + +BYTEPAIRCOMPRESSTARGET + +OPTION_REPLACE ARMCC --export_all_vtbl // don't use --export_all_vtbl + +USERINCLUDE . diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/ui/hb/inc/engine.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/ui/hb/inc/engine.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,169 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef LOADGEN_MODEL_H +#define LOADGEN_MODEL_H + +// INCLUDES +#include +#include +#include + +#include "loadgen_loadattributes.h" +#include "loadgen_loadbase.h" + +// FORWARD DECLARATIONS +class EngineWrapper; +class MainView; +class CLoadGenGraphsContainer; +class CEikonEnv; +//class CLoadBase; + + +typedef CArrayFixSeg CLoadItemList; + +const TUint KMaxCPUs = 4; + +// CLASS DECLARATIONS + +class TLoadGenSettings + { +public: + }; + +class CEngine : public CActive + { +private: + enum TLoadOperation + { + EEditLoad = 0, + ESuspResLoad, + EStopLoad + }; + + enum TContainerDrawState + { + EDrawStateInvalid = -1, + EDrawStateMain + }; + +public: + static CEngine* NewL(EngineWrapper *aEngineWrapper); + ~CEngine(); + void ActivateEngineL(); + void DeActivateEngineL(); + void LaunchPerfMonL(); + void EditLoadL(TInt aIndex); + void ExistingLoadEditedL(); + void ExistingLoadEditCancelled(); + +private: + void RunL(); + void DoCancel(); + +private: + CEngine(); + void ConstructL(EngineWrapper *aEngineWrapper); + void LoadSettingsL(); + void AppendToLoadItemListL(CLoadBase* aItem); + void DeleteFromLoadItemListL(TInt aIndex); + void SuspendOrResumeFromLoadItemListL(TInt aIndex); + void DeleteAllLoadItems(); + void RefreshViewL(TBool aClearSelection=ETrue); + CDesCArray* ListOfAllAppsL(); + + static TInt AsyncRunLoadOperation( TAny* aObject ); + +public: + void AsyncRunLoadOperationL(); + void AsyncSuspRes(); + void AsyncStopLoad( const CArrayFix* aSelectionIndexes ); + void AsyncEditLoad(); + + void StopAllLoadItemsL(); + void SuspendAllLoadItemsL(); + void ResumeAllLoadItemsL(); + + TInt LoadItemCount() const; + void StopSelectedOrHighlightedItemsL(const CArrayFix* aSelectionIndexes); + void SuspendOrResumeSelectedOrHighlightedItemsL(); + + CDesCArray* GenerateListBoxItemTextArrayL(); + void StartNewLoadL(TInt aCommand); + void DoStartNewLoadL(TInt aCommand); + void SaveSettingsL(); + TInt LaunchSettingsDialogL(); + TCPULoadAttributes GetCPULoadAttributes(); + TMemoryEatAttributes GetMemoryEatAttributes(); + TPhoneCallAttributes GetPhoneCallAttributes(); + TNetConnAttributes GetNetConnAttributes(); + TKeyPressAttributes GetKeyPressAttributes(); + TMessageAttributes GetMessageAttributes(); + TApplicationsAttributes GetApplicationsAttributes(); + TPhotoCaptureAttributes GetPhotoCaptureAttributes(); + TBluetoothAttributes GetBluetoothAttributes(); + TPointerEventAttributes GetPointerEventAttributes(); + void ChangeCPULoadAttributes(const TCPULoadAttributes& aAttributes); + void ChangeMemoryEatAttributes(const TMemoryEatAttributes& aAttributes); + void ChangePhoneCallAttributes(const TPhoneCallAttributes& aAttributes); + void ChangeNetConnAttributes(const TNetConnAttributes& aAttributes); + void ChangeKeyPressAttributes(const TKeyPressAttributes& aAttributes); + void ChangeMessageAttributes(const TMessageAttributes& aAttributes); + void ChangeApplicationsAttributes(const TApplicationsAttributes& aAttributes); + void ChangePhotoCaptureAttributes(const TPhotoCaptureAttributes& aAttributes); + void ChangeBluetoothAttributes(const TBluetoothAttributes& aAttributes); + void ChangePointerEventAttributes(const TPointerEventAttributes& aAttributes); + + inline TLoadGenSettings& Settings() { return iSettings; } + inline CEikonEnv* EikonEnv() { return iEnv; } + inline RApaLsSession& LsSession() { return iLs; } + inline TBool LoadItemsExists() { return iLoadItemList->Count() > 0; } + + +private: + RTimer iTimer; + CEikonEnv* iEnv; + TLoadGenSettings iSettings; + RApaLsSession iLs; + CLoadItemList* iLoadItemList; + TInt iReferenceNumber; + TCPULoadAttributes iCpuLoadAttributes; + TMemoryEatAttributes iMemoryEatAttributes; + TPhoneCallAttributes iPhoneCallAttributes; + TNetConnAttributes iNetConnAttributes; + TKeyPressAttributes iKeyPressAttributes; + TMessageAttributes iMessageAttributes; + TApplicationsAttributes iApplicationsAttributes; + TPhotoCaptureAttributes iPhotoCaptureAttributes; + TBluetoothAttributes iBluetoothAttributes; + TPointerEventAttributes iPointerEventAttributes; + EngineWrapper* iEngineWrapper; // used for communicating between QT and Symbian + TInt iCurrentItemIndex; + TBool iEditExistingLoad; + CLoadBase::TLoadState iLoadStatusBeforeEdit; + + CAsyncCallBack iAsyncRunLoadOperation; + + TInt iLoadOperation; + const CArrayFix* iSelectionIndexes; + + }; + + +#endif + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/ui/hb/inc/enginewrapper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/ui/hb/inc/enginewrapper.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,293 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef ENGINEWRAPPER_H +#define ENGINEWRAPPER_H + +#include +#include +#include +#include +#include "loadgen.hrh" + +#include + +class HbMainWindow; +class HbAction; +class MainView; +class SettingsView; +class CPULoadAttributes; +class MemoryEatAttributes; +class PhoneCallAttributes; +class NetConnAttributes; +class KeyPressAttributes; +class PointerEventAttributes; +class MessageAttributes; +class ApplicationsAttributes; +class PhotoCaptureAttributes; +class BluetoothAttributes; + +/** + * class that is used for communicating between Symbian and Qt code. + */ +class EngineWrapper : public QObject + { + Q_OBJECT + +public: + + /** + * Constructor + */ + EngineWrapper(HbMainWindow &mainWindow, MainView &mainView); + + /** + * Destructor + */ + ~EngineWrapper(); + + /** + * Initializes Engine Wrapper + * @return true if engine was started successfully + */ + bool init(); + +public slots: + void StopLoadYesNoDialogClosed(HbAction *action); + void StopAllLoadsYesNoDialogClosed(HbAction *action); + void loadAddedOrEdited(TLoadGenCommandIds cmdId); + void loadSettingsCanclled(); + +public: + + /* Functions that are called from UI: */ + + /** + * Start new load + */ + bool startNewLoad(int commandId); + + /** + * Launch Performance Monitor application. + */ + void launchPerfMonApp(); + + /** + * Edit operation for load settings + */ + void loadEdit(int rowIndex); + + /** + * CPU load attributes + */ + CPULoadAttributes getCpuLoadAttributes(); + + /** + * Memory eat attributes + */ + MemoryEatAttributes getMemoryEatAttributes(); + + /** + * Phone call attributes + */ + PhoneCallAttributes getPhoneCallAttributes(); + + /** + * Network connection attributes + */ + NetConnAttributes getNetConnAttributes(); + + /** + * Key presses attributes + */ + KeyPressAttributes getKeyPressAttributes(); + + /** + * Pointer event attributes + */ + PointerEventAttributes getPointerEventAttributes(); + + /** + * Message attributes + */ + MessageAttributes getMessageAttributes(); + + /** + * Applications attributes + */ + ApplicationsAttributes getApplicationsAttributes(); + + /** + * Photo capture attributes + */ + PhotoCaptureAttributes getPhotoCaptureAttributes(); + + /** + * BT attributes + */ + BluetoothAttributes getBluetoothAttributes(); + + /** + * Set attributes for CPU load + */ + void setCpuLoadAttributes(const CPULoadAttributes& attributes); + + /** + * Set attributes for memory eat + */ + void setMemoryEatAttributes(const MemoryEatAttributes& attributes); + + /** + * Set attributes for phone call + */ + void setPhoneCallAttributes(const PhoneCallAttributes& attributes); + + /** + * Set attributes for network connection + */ + void setNetConnAttributes(const NetConnAttributes& attributes); + + /** + * Set attributes for key presses + */ + void setKeyPressAttributes(const KeyPressAttributes& attributes); + + /** + * Set pointer event for messages + */ + void setPointerEventAttributes(const PointerEventAttributes& attributes); + + /** + * Set message attributes + */ + void setMessageAttributes(const MessageAttributes& attributes); + + /** + * Set applications attributes + */ + void setApplicationsAttributes(const ApplicationsAttributes& attributes); + + /** + * Set photo capture attributes + */ + void setPhotoCaptureAttributes(const PhotoCaptureAttributes& attributes); + + /** + * Set BT attributes + */ + void setBluetoothAttributes(const BluetoothAttributes& attributes); + + /** + * Stop load + */ + bool stopLoad(bool stopAll); + + /** + * Resume all loads + */ + void resumeAllLoadItems(); + + /** + * Suspend all loads + */ + void suspendAllLoadItems(); + + /** + * asynchronous call of suspend or resume selected/highlighted item from load list. + */ + void asyncSuspendOrResumeSelectedOrHighlightedItems(); + + /** + * asynchronous call stop load. + */ + void asyncStopLoad(); + + /** + * Suspend or resume selected/highlighted item from load list. + */ + void suspendOrResumeSelectedOrHighlightedItems(); + +public: + + /* Functions that are called from engine: */ + + /** + * uses Notifications class to show error message + */ + void ShowErrorMessage(const TDesC& aErrorMessage); + + /** + * uses Notifications class to show user note + */ + void ShowNote(const TDesC& aNoteMessage); + + /** + * Query item index + * @return selected row in load list view + */ + TInt QueryCurrentItemIndex(); + + /** + * selected indexes + */ + const CArrayFix* QueryListSelectedIndexesOrCurrentItemL(); + + /** + * Open settings for load. + */ + void OpenLoadSettings(TInt loadType, bool editExistingLoad); + + void ReFreshView(CDesCArray* aTextArray); + /** + * Clear load list selection(s) in Ui + */ + void ClearSelection(); + + /** + * Set current index in load list + */ + void SetCurrentItemIndex(TInt aIndex); + +public: + inline MainView& ViewReference() { return mMainView; }; + inline HbMainWindow& WindowReference() { return mMainWindow; }; + +private: + + enum LoadTypes { + Cpu, + EatMemory, + PhoneCalls, + Messages, + NWConnections, + KeyPresses, + Apps, + Photos, + BTAct, + PointerEvents + }; + + + /* LoadGen engine */ + CEngine* mEngine; + + MainView &mMainView; + HbMainWindow &mMainWindow; + bool mEditExistingLoad; +}; + +#endif //ENGINEWRAPPER_H diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/ui/hb/inc/loadgenlistitem.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/ui/hb/inc/loadgenlistitem.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,70 @@ +/* + * LoadGenListItem.h + * + * Created on: Jul 29, 2010 + * Author: sopirbo + */ + +#ifndef LOADGENLISTITEM_H_ +#define LOADGENLISTITEM_H_ + +#include "enginewrapper.h" + +#include +#include + +#include +#include + +class HbAbstractViewItem; +class HbLabel; +class HbPushButton; +class HbWidget; + +class QGraphicsLinearLayout; +class QModelIndex; +class QGraphicsItem; +class EngineWrapper; + +class LoadGenListItem : public HbListViewItem + { + Q_OBJECT +public: + LoadGenListItem( EngineWrapper& engWrapp , QGraphicsItem *parent = 0 ); + + //from HbListViewItem + virtual HbAbstractViewItem* createItem(); + virtual void updateChildItems(); + virtual ~LoadGenListItem(); + + void LoadGenListItem::setTransientState(const QHash &state); + QHash LoadGenListItem::transientState() const; + + void ChangeExpandedState(); + +signals: + + +public slots: + void EditButtonClicked(); + void StopButtonClicked(); + void SuspendButtonClicked(); +private: + void init(); + void initButtonLayout(); + void initLayoutShort(); + +private: + QGraphicsLinearLayout *hLayout; + QGraphicsLinearLayout *hButtonLayout; + QGraphicsLinearLayout *vLayout; + HbLabel *mItemText; + HbLabel *mIcon; + HbPushButton *mEditButton; + HbPushButton *mSuspendButton; + HbPushButton *mStopButton; + EngineWrapper& mEngineWrapper; + bool mExpanded; + }; + +#endif /* LOADGENLISTITEM_H_ */ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/ui/hb/inc/loadgenloaditem.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/ui/hb/inc/loadgenloaditem.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,34 @@ +/* + * LoadGenLoadItem.h + * + * Created on: Aug 5, 2010 + * Author: sopirbo + */ + +#ifndef LOADGENLOADITEM_H_ +#define LOADGENLOADITEM_H_ + +#include + +class LoadGenLoadItem : public QStandardItem + { +public: + LoadGenLoadItem(); + virtual ~LoadGenLoadItem(); + + int type () const; + QVariant data(int role = Qt::UserRole + 1) const; + void setData(const QVariant &value, int role = Qt::UserRole + 1); + + bool getExpandedState(); + void setExpanded( bool state ); + + bool getSuspendedState(); + void setSuspended( bool state ); + +private: + bool mExpanded; + bool mSuspended; + }; + +#endif /* LOADGENLOADITEM_H_ */ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/ui/hb/inc/mainview.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/ui/hb/inc/mainview.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,115 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef MAINVIEW_H +#define MAINVIEW_H + +#include "loadgenlistitem.h" +#include "loadgenloaditem.h" +#include + +class EngineWrapper; +class HbMainWindow; +class HbApplication; +class HbAction; +class HbLabel; +class HbProgressNote; +class HbListView; +class HbAbstractViewItem; + +class QStandardItemModel; +class QSignalMapper; +class QPointF; +class LoadGenListItem; +class LoadGenLoadItem; + +class MainView : public HbView +{ + Q_OBJECT + +public: + + MainView(HbMainWindow &mainWindow); + ~MainView(); + void init(HbApplication &app); + int currentItemIndex(); + void setCurrentItemIndex(int index); + void clearListSelection(); + void setLoadListData(QStringList& items); + QList listSelectionIndexes(); + +private: + void createMenu(HbApplication &app); + void loadListIinit(); + bool showItemActionPopup(int &index); + void loadListDelete(); + bool stopLoad(bool stopAll /*, int selectedLoad = 0*/); + +private slots: + void handleLoadListEvent(HbAbstractViewItem */*listViewItem*/, const QPointF &/*coords*/); + void ItemActionPopupClosed(HbAction* action ); + void loadActionPopupClosed( HbAction* action ); + void showAboutPopup(); + void stopAllLoads(); + void updateMenu(); + void launchPerfMon(); + void suspendAllLoads(); + void resumeAllLoads(); + void activated( const QModelIndex& ); + void LoadEdit(); + void NewLoad(); + + /** + * calls engine wrapper to complete service request, specified by cmd. + */ + void executeMenuCommand(int cmd); + +private: + HbMainWindow &mMainWindow; + EngineWrapper *mEngineWrapper; + HbListView *mListView; + QStandardItemModel *mListModel; + QSignalMapper *mSm; + bool mIsLoadListEmpty; + LoadGenListItem* mListItem; + LoadGenLoadItem* mLoadItem; + + HbAction *mActionAbout; + HbMenu *mLoadSubMenu1; + HbMenu *mLoadSubMenu2; + HbAction *mActionExit; + HbAction *mStopAll; + HbAction *mSuspendAll; + HbAction *mResumeAll; + HbAction *mActionPerfMon; + HbAction *mCpuLoadAction; + HbAction *mMemoryEatLoadAction; + HbAction *mPhoneCallLoadAction; + HbAction *mMessagesLoadAction; + HbAction *mNetConnLoadAction; + HbAction *mAppsLoadAction; + HbAction *mKeyPressLoadAction; + HbAction *mPhotoCapturesLoadAction; + HbAction *mBtActionsLoadAction; + HbAction *mPointerEventsLoadAction; + + QList mListItemExpanded; + int mPrevExpandedItem; +}; + +#endif // MAINVIEW_H diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/ui/hb/inc/notifications.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/ui/hb/inc/notifications.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef NOTIFICATIONS_H_ +#define NOTIFICATIONS_H_ + +#include + + +class Notifications : public HbPopup + { + + Q_OBJECT + +public: + + /** + * shows about box + */ + static void about(); + + /** + * shows error message + */ + static void error(const QString& errorMessage); + + /** + * shows global HbGlobalCommonNote type note + */ + static void showGlobalNote(const QString& text, HbMessageBox::MessageBoxType type, HbPopup::DefaultTimeout timeout = HbPopup::ConfirmationNoteTimeout); + }; + + + +#endif // NOTIFICATIONS_H_ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/ui/hb/inc/settingsview.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/ui/hb/inc/settingsview.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,253 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef SETTINGSVIEW_H +#define SETTINGSVIEW_H + +#include +#include +#include "loadgen.hrh" + +class EngineWrapper; +class HbDataFormModelItem; +class HbDataFormModel; +class HbDataForm; +class HbDataFormViewItem; +class HbRadioButtonList; + +class CPULoadAttributes + { +public: + uint mId; + uint mPriority; + uint mMode; + uint mType; + uint mLength; + uint mIdle; + uint mRandomVariance; + int mCpu; + uint mCpuCount; + }; + +class MemoryEatAttributes + { +public: + uint mId; + uint mPriority; + uint mSource; + uint mType; + uint mBuffer; + uint mIdle; + qint64 mAmount; + qint64 mRandomMin; + qint64 mRandomMax; + QString mAmountDes; + QString mRandomMinDes; + QString mRandomMaxDes; + uint mRandomVariance; + }; + +class PhoneCallAttributes + { +public: + uint mId; + uint mPriority; + QString mDestination; + uint mLength; + uint mIdle; + uint mRandomVariance; + }; + +class NetConnAttributes + { +public: + uint mId; + uint mPriority; + QString mDestination; + uint mIdle; + uint mRandomVariance; + }; + +class KeyPressAttributes + { +public: + uint mId; + uint mPriority; + uint mHeartBeat; + uint mRandomVariance; + }; + +class PointerEventAttributes + { +public: + uint mId; + uint mPriority; + uint mHeartBeat; + uint mRandomVariance; + }; + +class MessageAttributes + { +public: + uint mId; + int mMessageType; + QString mDestination; + uint mPriority; + uint mAmount; + int mLength; + uint mIdle; + uint mRandomVariance; + }; + +class ApplicationsAttributes + { +public: + uint mId; + uint mPriority; + uint mLaunchingInterval; + uint mKeyPressType; + uint mMaxOpen; + uint mHeartBeat; + uint mRandomVariance; + QStringList mAppsArray; + + }; + + +class PhotoCaptureAttributes + { +public: + uint mId; + int mPriority; + int mCameraCount; + int mCamera; + uint mIdle; + uint mRandomVariance; + }; + +class BluetoothAttributes + { +public: + uint mId; + int mPriority; + uint mIdle; + uint mRandomVariance; + bool mBluetoothSupported; + }; + + +class SettingsView : public HbView +{ + Q_OBJECT + +public: + SettingsView(HbView &mainView, HbMainWindow &parent, EngineWrapper &engine); + ~SettingsView(); + void open(const QString &settingsName, TLoadGenCommandIds cmdId); + +signals: + void loadCompleted(TLoadGenCommandIds cmdId); + void loadCanclled(); + +private slots: + void backButtonPressed(); + void okExit(); + void cancelled(); + void selectionChanged(int index); + void dataItemDisplayed(const QModelIndex &index); + +private: + void createItems(HbDataFormModel *model, HbDataFormModelItem *parent); + void createCpuLoadItems(HbDataFormModel *model, HbDataFormModelItem *parent); + void createEatMemoryItems(HbDataFormModel *model, HbDataFormModelItem *parent); + void createPhoneCallItems(HbDataFormModel *model, HbDataFormModelItem *parent); + void createNetConnItems(HbDataFormModel *model, HbDataFormModelItem *parent); + void createKeyOrPointerItems(HbDataFormModel *model, HbDataFormModelItem *parent); + void createMessageItems(HbDataFormModel *model, HbDataFormModelItem *parent); + void createAppsItems(HbDataFormModel *model, HbDataFormModelItem *parent); + void createPhotoItems(HbDataFormModel *model, HbDataFormModelItem *parent); + void createBtItems(HbDataFormModel *model, HbDataFormModelItem *parent); + void loadAttributes(); + void saveSettings(); + void saveCpuLoadSettings(); + void saveEatMemorySettings(); + void savePhoneCallSettings(); + void saveNetConnSettings(); + void saveKeyPressSettings(); + void saveMessageSettings(); + void savePointerEventSettings(); + void saveApplicationsSettings(); + void savePhotoSettings(); + void saveBtSettings(); + void exit(); + void setDefaultSettings(); + void setLoadAttributes(); + +private: + HbMainWindow &mMainWindow; + HbView &mMainView; + EngineWrapper &mEngineWrapper; + TLoadGenCommandIds mCmdId; + + /* Setting form */ + HbDataForm *mSettingForm; + + /* Model for Setting form */ + HbDataFormModel *mModel; + + /* Components for the model: */ + + /* grouped load settings */ + HbDataFormModelItem *mLoadSettings; + + HbDataFormModelItem *mPriority; + HbDataFormModelItem *mLoadMode; + HbDataFormModelItem *mSource; + HbDataFormModelItem *mType; + HbDataFormModelItem *mAmount; + HbDataFormModelItem *mMinAmountToBeLeft; + HbDataFormModelItem *mMaxAmountToBeLeft; + HbDataFormModelItem *mBuffer; + HbDataFormModelItem *mLength; + HbDataFormModelItem *mDestination; + HbDataFormModelItem *mIdle; + HbDataFormModelItem *mHeartBeat; + HbDataFormModelItem *mRandomVar; + HbDataFormModelItem *mMaxParallelApps; + HbDataFormModelItem *mLaunchingInterval; + HbDataFormModelItem *mKeyPressType; + HbDataFormModelItem *mCamera; + HbDataFormModelItem *mCpu; + + HbRadioButtonList *mModes; + HbRadioButtonList *mTypes; + + /* load attributes for each load type*/ + CPULoadAttributes mCPULoadAttributes; + MemoryEatAttributes mMemoryEatAttributes; + PhoneCallAttributes mPhoneCallAttributes; + NetConnAttributes mNetConnAttributes; + KeyPressAttributes mKeyPressAttributes; + PointerEventAttributes mPointerEventAttributes; + MessageAttributes mMessageAttributes; + ApplicationsAttributes mApplicationsAttributes; + PhotoCaptureAttributes mPhotoCaptureAttributes; + BluetoothAttributes mBluetoothAttributes; +}; + +#endif // SETTINGSVIEW_H diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/ui/hb/loadgen.qrc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/ui/hb/loadgen.qrc Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,11 @@ + + + ../../icons/qgn_menu_loadgen.svg + ../../icons/qgn_prob_status_green.svg + ../../icons/qgn_prob_status_red.svg + ../../icons/mono_stop_all.svg + ../../icons/mono_suspend_all.svg + ../../icons/mono_resume_all.svg + ../../icons/mono_new_load.svg + + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/ui/hb/rom/loadgen.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/ui/hb/rom/loadgen.iby Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef __LOADGEN_IBY__ +#define __LOADGEN_IBY__ + +S60_APP_EXE(LoadGen) +S60_APP_AIF_ICONS(LoadGen) +S60_APP_RESOURCE(LoadGen) +SCALABLE_IMAGE(APP_BITMAP_DIR,APP_BITMAP_DIR,LoadGen_ExtraIcons) +SCALABLE_IMAGE(APP_BITMAP_DIR,APP_BITMAP_DIR,LoadGen) + +//#ifdef S60_UPGRADABLE_APP_REG_RSC +// S60_UPGRADABLE_APP_REG_RSC(LoadGen) +//#else +// S60_APP_AIF_RSC(LoadGen) +//#endif + +data=ZPRIVATE\10003a3f\import\APPS\LoadGen_reg.RSC Private\10003a3f\import\Apps\LoadGen_reg.rsc + +data=ZPRIVATE\20011384\backup_registration.xml private\20011384\backup_registration.xml +data=ZSYSTEM\Install\LoadGen_stub.sis \system\install\LoadGen_stub.sis + +#endif // __LOADGEN_IBY__ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/ui/hb/src/engine.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/ui/hb/src/engine.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,1282 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +// INCLUDE FILES +#include "engine.h" +#include "enginewrapper.h" +#include "settingsview.h" +#include "loadgen_utils.h" +#include "loadgen_cpuload.h" +#include "loadgen_memoryeat.h" +#include "loadgen_phonecall.h" +#include "loadgen_netconn.h" +#include "loadgen_keypress.h" +#include "loadgen_pointerevent.h" +#include "loadgen_messages.h" +#include "loadgen_applications.h" +#include "loadgen_photocapture.h" +#include "loadgen_bluetooth.h" +#include "loadgen_traces.h" +#include "loadgen_loadattributes.h" +#include "loadgen.hrh" + +//#include "loadgen_editors.h" +//#include "loadgen_app.h" +//#include "loadgen_settingsviewdlg.h" +//#include "loadgen_maincontainer.h" + +//#include + +#include +#include +#include +//#include +#include +#include +#include +#include + +#include +//#include +#include + +const TInt KZeroIndex = 0; + +// ===================================== MEMBER FUNCTIONS ===================================== + +CEngine* CEngine::NewL(EngineWrapper *aEngineWrapper) + { + CEngine* self = new(ELeave) CEngine; + CleanupStack::PushL(self); + self->ConstructL(aEngineWrapper); + CleanupStack::Pop(); + return self; + } + +// -------------------------------------------------------------------------------------------- + +CEngine::CEngine() : CActive( EPriorityStandard ), + iAsyncRunLoadOperation( CActive::EPriorityStandard ) + { + TCallBack asyncRunSuspRes( AsyncRunLoadOperation, this ); + iAsyncRunLoadOperation.Set(asyncRunSuspRes); + } + +// -------------------------------------------------------------------------------------------- + +void CEngine::ConstructL(EngineWrapper *aEngineWrapper) + { + iEngineWrapper = aEngineWrapper; + + iReferenceNumber = 0; + iCurrentItemIndex = 0; + iEditExistingLoad = EFalse; + + iEnv = CEikonEnv::Static(); + User::LeaveIfError(iLs.Connect()); + + iLoadItemList = new(ELeave) CLoadItemList(64); + + User::LeaveIfError(iTimer.CreateLocal()); + CActiveScheduler::Add(this); + + } + +// -------------------------------------------------------------------------------------------- +TInt CEngine::AsyncRunLoadOperation( TAny* aObject ) + { + TRAPD( err, static_cast( aObject )->AsyncRunLoadOperationL() ); + return err; + } + +void CEngine::AsyncRunLoadOperationL() + { + switch(iLoadOperation) + { + case EEditLoad: + break; + case ESuspResLoad: + SuspendOrResumeSelectedOrHighlightedItemsL(); + break; + case EStopLoad: + if(iSelectionIndexes) + { + StopSelectedOrHighlightedItemsL(iSelectionIndexes); + } + break; + } + } +void CEngine::AsyncSuspRes() + { + iLoadOperation = ESuspResLoad; + iAsyncRunLoadOperation.CallBack(); + } +void CEngine::AsyncStopLoad( const CArrayFix* aSelectionIndexes ) + { + iSelectionIndexes = aSelectionIndexes; + iLoadOperation = EStopLoad; + iAsyncRunLoadOperation.CallBack(); + } +void CEngine::AsyncEditLoad() + { + iLoadOperation = EEditLoad; + iAsyncRunLoadOperation.CallBack(); + } +// -------------------------------------------------------------------------------------------- +void CEngine::ActivateEngineL() + { + // load settings + //TRAP_IGNORE(LoadSettingsL()); + + // RAM + TMemoryInfoV1Buf ramMemory; + UserHal::MemoryInfo(ramMemory); + + TInt freeRam = ramMemory().iFreeRamInBytes; + + + // set defaults to attributes + iCpuLoadAttributes.iId = 0; + iCpuLoadAttributes.iPriority = EThreadPriorityTypeNormal; + iCpuLoadAttributes.iMode = ECpuLoadModeYielding; + iCpuLoadAttributes.iType = ECpuLoadTypePeriodic; + iCpuLoadAttributes.iLength = 4000; + iCpuLoadAttributes.iIdle = 2000; + iCpuLoadAttributes.iRandomVariance = 0; + iCpuLoadAttributes.iCpu = KCPUSelection_FreeScheduling; // set CPU as "undefined" (can be >= 0 only in SMP environments) + iCpuLoadAttributes.iCpuCount = UserSvr::HalFunction(EHalGroupKernel, KHalFunction_EKernelHalNumLogicalCpus, 0, 0); + if( iCpuLoadAttributes.iCpuCount < 1 || iCpuLoadAttributes.iCpuCount > KMaxCPUs ) + { + // HAL may not support this function, so let's use CPU count 1: + iCpuLoadAttributes.iCpuCount = 1; + } + iMemoryEatAttributes.iId = 0; + iMemoryEatAttributes.iPriority = EThreadPriorityTypeNormal; + iMemoryEatAttributes.iSource = 0; + iMemoryEatAttributes.iType = EMemoryEatTypeMemoryToBeLeft; + iMemoryEatAttributes.iBuffer = 16*1024; + iMemoryEatAttributes.iIdle = 0; + iMemoryEatAttributes.iAmount = freeRam;//0; + iMemoryEatAttributes.iRandomMin = 1000000; + iMemoryEatAttributes.iRandomMax = 1500000; + iMemoryEatAttributes.iAmountDes.Copy(KNullDesC); + iMemoryEatAttributes.iRandomMinDes.Copy(KNullDesC); + iMemoryEatAttributes.iRandomMaxDes.Copy(KNullDesC); + iMemoryEatAttributes.iRandomVariance = 0; + + iPhoneCallAttributes.iId = 0; + iPhoneCallAttributes.iPriority = EThreadPriorityTypeNormal; + iPhoneCallAttributes.iDestination.Copy(_L("+358")); + iPhoneCallAttributes.iLength = 60000; + iPhoneCallAttributes.iIdle = 10000; + iPhoneCallAttributes.iRandomVariance = 0; + + iNetConnAttributes.iId = 0; + iNetConnAttributes.iPriority = EThreadPriorityTypeNormal; + iNetConnAttributes.iDestination.Copy(_L("http://www.nokia.com")); + iNetConnAttributes.iIdle = 10000; + iNetConnAttributes.iRandomVariance = 0; + + iKeyPressAttributes.iId = 0; + iKeyPressAttributes.iPriority = EThreadPriorityTypeNormal; + iKeyPressAttributes.iHeartBeat = 100; + iKeyPressAttributes.iRandomVariance = 0; + + iPointerEventAttributes.iId = 0; + iPointerEventAttributes.iPriority = EThreadPriorityTypeNormal; + iPointerEventAttributes.iHeartBeat = 1000; + iPointerEventAttributes.iRandomVariance = 0; + + iMessageAttributes.iId = 0; + iMessageAttributes.iPriority = EThreadPriorityTypeNormal; + iMessageAttributes.iMessageType = EMessageTypeSMS; + iMessageAttributes.iDestination.Copy(_L("+358")); + iMessageAttributes.iAmount = 5; + iMessageAttributes.iLength = 160; + iMessageAttributes.iIdle = 15000; + iMessageAttributes.iRandomVariance = 0; + + iApplicationsAttributes.iId = 0; + iApplicationsAttributes.iLaunchingInterval = 2000; + iApplicationsAttributes.iPriority = EThreadPriorityTypeNormal; + iApplicationsAttributes.iKeyPressType = EApplicationsKeyPressTypeNone; + iApplicationsAttributes.iMaxOpen = 20; + iApplicationsAttributes.iHeartBeat = 50; + iApplicationsAttributes.iRandomVariance = 0; + + iPhotoCaptureAttributes.iId = 0; + iPhotoCaptureAttributes.iPriority = EThreadPriorityTypeNormal; + iPhotoCaptureAttributes.iIdle = 10000; + iPhotoCaptureAttributes.iRandomVariance = 0; + iPhotoCaptureAttributes.iCameraCount = CCamera::CamerasAvailable(); + if(iPhotoCaptureAttributes.iCameraCount > 0) + { + iPhotoCaptureAttributes.iCamera = 0; // Main camera + } + else + { + iPhotoCaptureAttributes.iCamera = -1; + } + + iBluetoothAttributes.iId = 0; + iBluetoothAttributes.iPriority = EThreadPriorityTypeNormal; + iBluetoothAttributes.iIdle = 10000; + iBluetoothAttributes.iRandomVariance = 0; + iBluetoothAttributes.iBluetoothSupported = CFeatureDiscovery::IsFeatureSupportedL(KFeatureIdBt); + } + +// -------------------------------------------------------------------------------------------- + +void CEngine::DeActivateEngineL() + { + Cancel(); + + // for a faster exit, send the application to background + TApaTask selfTask(iEnv->WsSession()); + selfTask.SetWgId(iEnv->RootWin().Identifier()); + selfTask.SendToBackground(); + } + +// -------------------------------------------------------------------------------------------- + +CEngine::~CEngine() + { + if (iLoadItemList) + { + DeleteAllLoadItems(); + delete iLoadItemList; + } + if ( iApplicationsAttributes.iAppsArray ) + { + delete iApplicationsAttributes.iAppsArray; + } + iTimer.Close(); + iLs.Close(); + } + +// -------------------------------------------------------------------------------------------- + +void CEngine::DoCancel() + { + iTimer.Cancel(); + } + +// -------------------------------------------------------------------------------------------- + +void CEngine::RunL() + { + // continue + //iTimer.After(iStatus, 400000); + //SetActive(); + } + +// -------------------------------------------------------------------------------------------- + +void CEngine::StartNewLoadL(TInt aCommand) + { + // show new load query + //CLoadGenLoadTypeEditorBase* dlg = NULL; + + if(aCommand == ELoadGenCmdNewLoadPhotoCaptures && + iPhotoCaptureAttributes.iCameraCount == 0) + { + _LIT(message, "Cameras not available"); + iEngineWrapper->ShowNote(message); + return; + } + if(aCommand == ELoadGenCmdNewLoadBluetooth && + iBluetoothAttributes.iBluetoothSupported == EFalse) + { + _LIT(message, "Bluetooth device not available"); + iEngineWrapper->ShowNote(message); + return; + } + /* + switch ( aCommand ) + { + case ELoadGenCmdNewLoadCPULoad: + { + //dlg = CLoadGenCPULoadEditor::NewL(iCpuLoadAttributes); + break; + } + case ELoadGenCmdNewLoadEatMemory: + { + //dlg = CLoadGenMemoryEatEditor::NewL(iMemoryEatAttributes); + break; + } + case ELoadGenCmdNewLoadPhoneCall: + { + //dlg = CLoadGenPhoneCallEditor::NewL(iPhoneCallAttributes); + break; + } + case ELoadGenCmdNewLoadNetConn: + { + //dlg = CLoadGenNetConnEditor::NewL(iNetConnAttributes); + break; + } + case ELoadGenCmdNewLoadKeyPress: + { + //dlg = CLoadGenKeyPressEditor::NewL(iKeyPressAttributes); + break; + } + case ELoadGenCmdNewLoadMessages: + { + //dlg = CLoadGenMessagesEditor::NewL( iMessageAttributes ); + break; + } + case ELoadGenCmdNewLoadApplications: + { + //dlg = CLoadGenApplicationsEditor::NewL( iApplicationsAttributes ); + break; + } + case ELoadGenCmdNewLoadPhotoCaptures: + { + if( iPhotoCaptureAttributes.iCameraCount > 0 ) + { + //dlg = CLoadGenPhotoCaptureEditor::NewL( iPhotoCaptureAttributes ); + } + else + { + _LIT(message, "Cameras not available"); + iEngineWrapper->ShowNote(message); + //CAknErrorNote* errorNote = new(ELeave) CAknErrorNote; + //errorNote->ExecuteLD(message); + return; + } + break; + } + case ELoadGenCmdNewLoadBluetooth: + { + if( iBluetoothAttributes.iBluetoothSupported ) + { + //dlg = CLoadGenBluetoothEditor::NewL(iBluetoothAttributes); + } + else + { + _LIT(message, "Bluetooth device not available"); + iEngineWrapper->ShowNote(message); + //CAknErrorNote* errorNote = new(ELeave) CAknErrorNote; + //errorNote->ExecuteLD(message); + return; + } + break; + } + case ELoadGenCmdNewLoadPointerEvent: + { + //dlg = CLoadGenPointerEventEditor::NewL(iPointerEventAttributes); + break; + } + + default: + { + User::Panic(_L("Wrong new load"), 111); + break; + } + } + */ + iEditExistingLoad = EFalse; + iEngineWrapper->OpenLoadSettings(aCommand, EFalse); // = dlg->RunQueryLD(); + + // set back title + + //if (iMainContainer) + // iMainContainer->SetDefaultTitlePaneTextL(); + + // start creating new load if dialog accepted + //if (dlgResult) + // { + // DoStartNewLoadL(aCommand); + // } + // DoStartNewLoadL() called from engine wrapper slot function newLoadAdded() after + // load settings closed by user select: ok. + } + +// -------------------------------------------------------------------------------------------- + +void CEngine::EditLoadL(TInt aIndex) + { + CLoadBase* aItem = iLoadItemList->At(aIndex); + iCurrentItemIndex = aIndex; + iEditExistingLoad = ETrue; + // suspend current + if (aItem->State() == CLoadBase::ELoadStateRunning) + { + iLoadStatusBeforeEdit = CLoadBase::ELoadStateRunning; + aItem->Suspend(); + } + + // show new load query + + /* CLoadGenLoadTypeEditorBase* dlg = NULL; + + + switch ( aItem->Type() ) + { + case ELoadGenCmdNewLoadCPULoad: + { + //dlg = CLoadGenCPULoadEditor::NewL(static_cast(aItem)->Attributes(), ETrue); + break; + } + case ELoadGenCmdNewLoadEatMemory: + { + //dlg = CLoadGenMemoryEatEditor::NewL(static_cast(aItem)->Attributes(), ETrue); + break; + } + case ELoadGenCmdNewLoadPhoneCall: + { + //dlg = CLoadGenPhoneCallEditor::NewL(static_cast(aItem)->Attributes(), ETrue); + break; + } + case ELoadGenCmdNewLoadNetConn: + { + //dlg = CLoadGenNetConnEditor::NewL(static_cast(aItem)->Attributes(), ETrue); + break; + } + case ELoadGenCmdNewLoadKeyPress: + { + //dlg = CLoadGenKeyPressEditor::NewL(static_cast(aItem)->Attributes(), ETrue); + break; + } + case ELoadGenCmdNewLoadMessages: + { + //dlg = CLoadGenMessagesEditor::NewL(static_cast(aItem)->Attributes(), ETrue); + break; + } + case ELoadGenCmdNewLoadApplications: + { + //dlg = CLoadGenApplicationsEditor::NewL( static_cast(aItem)->Attributes(), ETrue ); + break; + } + case ELoadGenCmdNewLoadPhotoCaptures: + { + //dlg = CLoadGenPhotoCaptureEditor::NewL( static_cast(aItem)->Attributes(), ETrue ); + break; + } + case ELoadGenCmdNewLoadBluetooth: + { + //dlg = CLoadGenBluetoothEditor::NewL( static_cast(aItem)->Attributes(), ETrue ); + break; + } + case ELoadGenCmdNewLoadPointerEvent: + { + //dlg = CLoadGenPointerEventEditor::NewL(static_cast(aItem)->Attributes(), ETrue); + break; + } + default: + { + User::Panic(_L("Wrong edit load"), 114); + break; + } + } + */ + iEngineWrapper->OpenLoadSettings(aItem->Type(), iEditExistingLoad); + // ExistingLoadEditedL method called from engine wrapper when load settings view close signal received. + + //TBool dlgResult = ETrue; //dlg->RunQueryLD(); + + // set back title + // TODO: check this. + //if (iMainContainer) + // iMainContainer->SetDefaultTitlePaneTextL(); + + // change priority of the load item + //aItem->SetPriority(); + + // resume execution the item + //aItem->Resume(); + + //if (dlgResult) + // RefreshViewL(EFalse); + } + +// -------------------------------------------------------------------------------------------- + +void CEngine::ExistingLoadEditedL() + { + CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex); + // change priority of the load item + aItem->SetPriority(); + if (iLoadStatusBeforeEdit == CLoadBase::ELoadStateRunning) + { + // resume execution the item + aItem->Resume(); + RefreshViewL(EFalse); + } + // cancel: + + } + +// -------------------------------------------------------------------------------------------- + +void CEngine::ExistingLoadEditCancelled() + { + if (iLoadStatusBeforeEdit == CLoadBase::ELoadStateRunning) + { + CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex); + // resume execution due to suspend action before edit started: + aItem->Resume(); + } + RefreshViewL(EFalse); + } + +// -------------------------------------------------------------------------------------------- + +void CEngine::DoStartNewLoadL(TInt aCommand) + { + CLoadBase* item = NULL; + + switch ( aCommand ) + { + case ELoadGenCmdNewLoadCPULoad: + { + if( iCpuLoadAttributes.iCpu == KCPUSelection_AllCPUs ) + { + // Call this function recursively for all CPUs: + for( TUint i = 0; i < iCpuLoadAttributes.iCpuCount; ++i ) + { + iCpuLoadAttributes.iCpu = i; + DoStartNewLoadL(aCommand); + } + // And finally set user selection back to "All CPUs" + iCpuLoadAttributes.iCpu = KCPUSelection_AllCPUs; + return; + } + else + { + item = CCPULoad::NewL(iCpuLoadAttributes, iReferenceNumber); + } + break; + } + case ELoadGenCmdNewLoadEatMemory: + { + item = CMemoryEat::NewL(iMemoryEatAttributes, iReferenceNumber); + break; + } + case ELoadGenCmdNewLoadPhoneCall: + { + item = CPhoneCall::NewL(iPhoneCallAttributes, iReferenceNumber); + break; + } + case ELoadGenCmdNewLoadNetConn: + { + item = CNetConn::NewL(iNetConnAttributes, iReferenceNumber); + break; + } + + case ELoadGenCmdNewLoadKeyPress: + { + item = CKeyPress::NewL(iKeyPressAttributes, iReferenceNumber); + break; + } + case ELoadGenCmdNewLoadMessages: + { + item = CMessages::NewL( iMessageAttributes, iReferenceNumber ); + break; + } + case ELoadGenCmdNewLoadApplications: + { + iApplicationsAttributes.iAppsArray = ListOfAllAppsL(); + item = CAppLauncher::NewL( iApplicationsAttributes, iReferenceNumber ); + break; + } + case ELoadGenCmdNewLoadPhotoCaptures: + { + item = CPhotoCapture::NewL( iPhotoCaptureAttributes, iReferenceNumber); + break; + } + case ELoadGenCmdNewLoadBluetooth: + { + item = CBluetooth::NewL( iBluetoothAttributes, iReferenceNumber); + break; + } + case ELoadGenCmdNewLoadPointerEvent: + { + item = CPointerEvent::NewL(iPointerEventAttributes, iReferenceNumber); + break; + } + + default: + { + User::Panic(_L("Wrong new load"), 112); + break; + } + } + + iReferenceNumber++; + + // add item to the array + AppendToLoadItemListL(item); + + // update the listbox + RefreshViewL(EFalse); + + // set item index to the end + // Check this feature to be done in Orbit UI. + // iMainContainer->ListBox()->SetCurrentItemIndexAndDraw( iMainContainer->ListBox()->Model()->NumberOfItems()-1 ); + + // start the load + item->Resume(); + + // refresh again + RefreshViewL(EFalse); + } + +// -------------------------------------------------------------------------------------------- + + +void CEngine::StopAllLoadItemsL() + { + DeleteAllLoadItems(); + + RefreshViewL(); + } + +// -------------------------------------------------------------------------------------------- + +void CEngine::SuspendAllLoadItemsL() + { + for (TInt i=0; iAt(i) ) + { + iLoadItemList->At(i)->Suspend(); + } + } + + RefreshViewL(); + } +// -------------------------------------------------------------------------------------------- + +void CEngine::ResumeAllLoadItemsL() + { + for (TInt i=0; iAt(i) ) + { + iLoadItemList->At(i)->Resume(); + } + } + + RefreshViewL(); + } + +// -------------------------------------------------------------------------------------------- + +void CEngine::RefreshViewL(TBool aClearSelection) + { + // clear selections if any + iEngineWrapper->ClearSelection(); + if (aClearSelection) + { + iEngineWrapper->SetCurrentItemIndex(KZeroIndex); + } + iEngineWrapper->ReFreshView(GenerateListBoxItemTextArrayL()); + } + +// -------------------------------------------------------------------------------------------- + +CDesCArray* CEngine::GenerateListBoxItemTextArrayL() + { + CDesCArray* textArray = new(ELeave) CDesCArrayFlat(64); + CleanupStack::PushL(textArray); + + _LIT(KEntryTemplateRedIcon, "1\t%S\t\t"); + _LIT(KEntryTemplateGreenIcon, "2\t%S\t\t"); + TInt cnt = LoadItemCount(); + for (TInt i=0; i< cnt; i++) + { + // add description from each entry + TBuf<256> textEntry; + TBuf<256> description = iLoadItemList->At(i)->Description(); + + if (iLoadItemList->At(i)->State() == CLoadBase::ELoadStateRunning) + textEntry.Format(KEntryTemplateGreenIcon, &description); + else + textEntry.Format(KEntryTemplateRedIcon, &description); + + textArray->AppendL(textEntry); + } + + CleanupStack::Pop(); //textArray + return textArray; + } + +// -------------------------------------------------------------------------------------------- + +void CEngine::AppendToLoadItemListL(CLoadBase* aItem) + { + if (iLoadItemList) + iLoadItemList->AppendL( aItem ); + else + User::Leave(KErrNotReady); + } + +// -------------------------------------------------------------------------------------------- + +void CEngine::DeleteFromLoadItemListL(TInt aIndex) + { + if (iLoadItemList) + { + if (iLoadItemList->Count() > aIndex && aIndex >= 0) + { + // first call delete on the item + if (iLoadItemList->At(aIndex)) + { + delete iLoadItemList->At(aIndex); + iLoadItemList->At(aIndex) = NULL; + } + + // and them remove the array entry + iLoadItemList->Delete(aIndex); + iLoadItemList->Compress(); + } + else + User::Leave(KErrNotFound); + } + else + User::Leave(KErrNotReady); + } + +// -------------------------------------------------------------------------------------------- + +void CEngine::SuspendOrResumeFromLoadItemListL(TInt aIndex) + { + if (iLoadItemList) + { + if (iLoadItemList->Count() > aIndex && aIndex >= 0) + { + if (iLoadItemList->At(aIndex)) + { + if (iLoadItemList->At(aIndex)->State() == CLoadBase::ELoadStateRunning) + { + iLoadItemList->At(aIndex)->Suspend(); + } + else if (iLoadItemList->At(aIndex)->State() == CLoadBase::ELoadStateSuspended) + { + iLoadItemList->At(aIndex)->Resume(); + } + } + } + else + User::Leave(KErrNotFound); + } + else + User::Leave(KErrNotReady); + } + +// -------------------------------------------------------------------------------------------- + +TInt CEngine::LoadItemCount() const + { + TInt count(0); + + if (iLoadItemList) + count = iLoadItemList->Count(); + + return count; + } + +// -------------------------------------------------------------------------------------------- + +void CEngine::DeleteAllLoadItems() + { + // call delete for each entry and free memory allocated for the array + for (TInt i=0; iAt(i) ) + { + delete iLoadItemList->At(i); + iLoadItemList->At(i) = NULL; + } + } + + iLoadItemList->Reset(); + } + +// -------------------------------------------------------------------------------------------- + +void CEngine::StopSelectedOrHighlightedItemsL(const CArrayFix* aSelectionIndexes) + { + TInt err(KErrNone); + + // by default use selected items + if (aSelectionIndexes && aSelectionIndexes->Count() > 0) + { + TInt deleteIndexCounter(0); + TInt ref(0); + TKeyArrayFix key(0, ECmpTUint16); + TInt index(0); + + TInt loadCount = LoadItemCount(); + + for (TInt i=0; iFind(ref, key, index) == 0) + { + TRAP(err, DeleteFromLoadItemListL(i-deleteIndexCounter)); + deleteIndexCounter++; // amount of indexes decreases after each delete + } + } + + RefreshViewL(); + User::LeaveIfError(err); + } + } + +// -------------------------------------------------------------------------------------------- + +void CEngine::SuspendOrResumeSelectedOrHighlightedItemsL() + { + const CArrayFix* selectionIndexes = iEngineWrapper->QueryListSelectedIndexesOrCurrentItemL(); //iMainContainer->ListBoxSelectionIndexes(); + + // by default use selected items + if (selectionIndexes && selectionIndexes->Count() > 0) + { + TInt ref(0); + TKeyArrayFix key(0, ECmpTUint16); + TInt index(0); + + for (TInt i=0; iFind(ref, key, index) == 0) + { + SuspendOrResumeFromLoadItemListL(i); + } + } + + RefreshViewL(EFalse); + } + } +// -------------------------------------------------------------------------------------------- + +void CEngine::LoadSettingsL() + { + } + +// -------------------------------------------------------------------------------------------- + +void CEngine::SaveSettingsL() + { + } + +// -------------------------------------------------------------------------------------------- + +TInt CEngine::LaunchSettingsDialogL() + { + return 0; + } + +// -------------------------------------------------------------------------------------------- +CDesCArray* CEngine::ListOfAllAppsL() + { + const TInt KMaxAppsArraySize=250; + RApaLsSession ls; + CleanupClosePushL(ls); + + User::LeaveIfError( ls.Connect() ); + CDesCArray* allAppsArray = new(ELeave) CDesCArrayFlat( KMaxAppsArraySize ); + CleanupStack::PushL( allAppsArray ); + // reset the apps list + allAppsArray->Reset(); + + // search all apps + TApaAppInfo appInfo; + User::LeaveIfError(ls.GetAllApps()); + + + while ( ls.GetNextApp( appInfo ) == KErrNone ) + { + allAppsArray->AppendL( appInfo.iFullName ); + } + CleanupStack::Pop( allAppsArray ); + CleanupStack::PopAndDestroy( &ls ); + + + // remove loadgen.* from the list + for ( TInt i = 0; i < allAppsArray->MdcaCount(); i++ ) + { + if ( allAppsArray->MdcaPoint(i).FindF( _L("\\loadgen.") ) != KErrNotFound ) + { + allAppsArray->Delete(i); + allAppsArray->Compress(); + break; + } + } + + // sort the elements + allAppsArray->Sort(); + + return allAppsArray; // ownership transferred + } + +// -------------------------------------------------------------------------------------------- + +void CEngine::LaunchPerfMonL() + { + // launch Performance Monitor + const TUid KUidPerfMon = { 0x20011385 }; + + RWsSession ws; + User::LeaveIfError( ws.Connect() ); + CleanupClosePushL(ws); + + RApaLsSession ls; + User::LeaveIfError( ls.Connect() ); + CleanupClosePushL(ls); + + + // try to find the task of PerfMon + TApaTaskList tasklist(ws); + TApaTask task = tasklist.FindApp(KUidPerfMon); + + if (task.Exists()) + { + // task exists, bring it to foreground + task.BringToForeground(); + } + else + { + TApaAppInfo appInfo; + User::LeaveIfError(ls.GetAppInfo(appInfo, KUidPerfMon)); + + CApaCommandLine* cmdLine = CApaCommandLine::NewLC(); + cmdLine->SetExecutableNameL(appInfo.iFullName); + cmdLine->SetCommandL(EApaCommandBackground); + + // start the app + User::LeaveIfError(ls.StartApp(*cmdLine)); + + CleanupStack::PopAndDestroy(); //cmdLine + } + + CleanupStack::PopAndDestroy(2); //ws,ls + } + +// -------------------------------------------------------------------------------------------- + +TCPULoadAttributes CEngine::GetCPULoadAttributes() + { + if (iEditExistingLoad == EFalse) + { + return iCpuLoadAttributes; + } + else + { + CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex); + return (static_cast(aItem)->Attributes()); + } + } + +// -------------------------------------------------------------------------------------------- + +void CEngine::ChangeCPULoadAttributes(const TCPULoadAttributes& aAttributes) + { + if (iEditExistingLoad == EFalse) + { + iCpuLoadAttributes = aAttributes; + } + else + { + CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex); + static_cast(aItem)->SetAttributes(aAttributes); + } + } + +// -------------------------------------------------------------------------------------------- + +TMemoryEatAttributes CEngine::GetMemoryEatAttributes() + { + if (iEditExistingLoad == EFalse) + { + return iMemoryEatAttributes; + } + else + { + CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex); + return (static_cast(aItem)->Attributes()); + } + } + +// -------------------------------------------------------------------------------------------- + +void CEngine::ChangeMemoryEatAttributes(const TMemoryEatAttributes& aAttributes) + { + if (iEditExistingLoad == EFalse) + { + iMemoryEatAttributes = aAttributes; + } + else + { + CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex); + static_cast(aItem)->SetAttributes(aAttributes); + } + } + +// -------------------------------------------------------------------------------------------- + +TPhoneCallAttributes CEngine::GetPhoneCallAttributes() + { + if (iEditExistingLoad == EFalse) + { + return iPhoneCallAttributes; + } + else + { + CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex); + return (static_cast(aItem)->Attributes()); + } + } + +// -------------------------------------------------------------------------------------------- + +void CEngine::ChangePhoneCallAttributes(const TPhoneCallAttributes& aAttributes) + { + if (iEditExistingLoad == EFalse) + { + iPhoneCallAttributes = aAttributes; + } + else + { + CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex); + static_cast(aItem)->SetAttributes(aAttributes); + } + } + +// -------------------------------------------------------------------------------------------- + +TNetConnAttributes CEngine::GetNetConnAttributes() + { + + if (iEditExistingLoad == EFalse) + { + return iNetConnAttributes; + } + else + { + CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex); + return (static_cast(aItem)->Attributes()); + } + + } + +// -------------------------------------------------------------------------------------------- + +void CEngine::ChangeNetConnAttributes(const TNetConnAttributes& aAttributes) + { + + if (iEditExistingLoad == EFalse) + { + iNetConnAttributes = aAttributes; + } + else + { + CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex); + static_cast(aItem)->SetAttributes(aAttributes); + } + + } + +// -------------------------------------------------------------------------------------------- + +TKeyPressAttributes CEngine::GetKeyPressAttributes() + { + if (iEditExistingLoad == EFalse) + { + return iKeyPressAttributes; + } + else + { + CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex); + return (static_cast(aItem)->Attributes()); + } + } + + +// -------------------------------------------------------------------------------------------- + +void CEngine::ChangeKeyPressAttributes(const TKeyPressAttributes& aAttributes) + { + if (iEditExistingLoad == EFalse) + { + iKeyPressAttributes = aAttributes; + } + else + { + CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex); + static_cast(aItem)->SetAttributes(aAttributes); + } + } + +// -------------------------------------------------------------------------------------------- + +TMessageAttributes CEngine::GetMessageAttributes() + { + if (iEditExistingLoad == EFalse) + { + return iMessageAttributes; + } + else + { + CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex); + return (static_cast(aItem)->Attributes()); + } + } + +// -------------------------------------------------------------------------------------------- + +void CEngine::ChangeMessageAttributes(const TMessageAttributes& aAttributes) + { + if (iEditExistingLoad == EFalse) + { + iMessageAttributes = aAttributes; + } + else + { + CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex); + static_cast(aItem)->SetAttributes(aAttributes); + } + } + +// -------------------------------------------------------------------------------------------- + +TApplicationsAttributes CEngine::GetApplicationsAttributes() + { + if (iEditExistingLoad == EFalse) + { + return iApplicationsAttributes; + } + else + { + CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex); + return (static_cast(aItem)->Attributes()); + } + } + +// -------------------------------------------------------------------------------------------- + +void CEngine::ChangeApplicationsAttributes(const TApplicationsAttributes& aAttributes) + { + if (iEditExistingLoad == EFalse) + { + iApplicationsAttributes = aAttributes; + } + else + { + CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex); + static_cast(aItem)->SetAttributes(aAttributes); + } + } + +// -------------------------------------------------------------------------------------------- + +TPhotoCaptureAttributes CEngine::GetPhotoCaptureAttributes() + { + if (iEditExistingLoad == EFalse) + { + return iPhotoCaptureAttributes; + } + else + { + CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex); + return (static_cast(aItem)->Attributes()); + } + } + +// -------------------------------------------------------------------------------------------- + +void CEngine::ChangePhotoCaptureAttributes(const TPhotoCaptureAttributes& aAttributes) + { + if (iEditExistingLoad == EFalse) + { + iPhotoCaptureAttributes = aAttributes; + } + else + { + CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex); + static_cast(aItem)->SetAttributes(aAttributes); + } + } + +// -------------------------------------------------------------------------------------------- + +TBluetoothAttributes CEngine::GetBluetoothAttributes() + { + if (iEditExistingLoad == EFalse) + { + return iBluetoothAttributes; + } + else + { + CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex); + return (static_cast(aItem)->Attributes()); + } + } + + +// -------------------------------------------------------------------------------------------- + +void CEngine::ChangeBluetoothAttributes(const TBluetoothAttributes& aAttributes) + { + if (iEditExistingLoad == EFalse) + { + iBluetoothAttributes = aAttributes; + } + else + { + CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex); + static_cast(aItem)->SetAttributes(aAttributes); + } + } + +// -------------------------------------------------------------------------------------------- + +TPointerEventAttributes CEngine::GetPointerEventAttributes() + { + if (iEditExistingLoad == EFalse) + { + return iPointerEventAttributes; + } + else + { + CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex); + return (static_cast(aItem)->Attributes()); + } + } + +// -------------------------------------------------------------------------------------------- + +void CEngine::ChangePointerEventAttributes(const TPointerEventAttributes& aAttributes) + { + if (iEditExistingLoad == EFalse) + { + iPointerEventAttributes = aAttributes; + } + else + { + CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex); + static_cast(aItem)->SetAttributes(aAttributes); + } + } + +// -------------------------------------------------------------------------------------------- + +// End of File diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/ui/hb/src/enginewrapper.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/ui/hb/src/enginewrapper.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,771 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include +//#include +#include +#include + +#include + #include + +#include +#include + +#include "notifications.h" +#include "enginewrapper.h" +#include "settingsview.h" +#include "engine.h" +#include "mainview.h" + +QStringList LOADTYPES = (QStringList() << "CPU load" << "Memory eat" << "Phone calls" << "Messages" + << "Network conn." << "Key presses" << "Applications" << "Photo captures" + << "Bluetooth actions" << "Pointer events"); + +// --------------------------------------------------------------------------- + +EngineWrapper::EngineWrapper(HbMainWindow &mainWindow, MainView &mainView) +: mEngine(0), + mMainView(mainView), + mMainWindow(mainWindow), + mEditExistingLoad(false) +{ +} + +// --------------------------------------------------------------------------- + +EngineWrapper::~EngineWrapper() +{ + if (mEngine != 0) { + TRAP_IGNORE(mEngine->DeActivateEngineL()); + delete mEngine; + } +} + +// --------------------------------------------------------------------------- + +bool EngineWrapper::init() +{ + TInt err = KErrNone; + TRAP(err, mEngine = CEngine::NewL(this)); + if(err != KErrNone) { + return false; + } + else { + TRAP(err, mEngine->ActivateEngineL()); + if (err != KErrNone) { + return false; + } + else { + return true; + } + } +} + +// --------------------------------------------------------------------------- + +bool EngineWrapper::startNewLoad(int commandId) +{ + TRAPD(err, mEngine->StartNewLoadL(commandId)); + + // error handling + if(err != KErrNone) { + return false; + } + else { + return true; + } +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::launchPerfMonApp() +{ + TRAPD(err, mEngine->LaunchPerfMonL()); + // error handling + if(err != KErrNone) { + Notifications::error("Perf Mon launch failed."); + } +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::loadAddedOrEdited(TLoadGenCommandIds cmdId) +{ + if (mEditExistingLoad == false) { + TRAP_IGNORE(mEngine->DoStartNewLoadL(cmdId)); + } + else { + TRAP_IGNORE(mEngine->ExistingLoadEditedL()); + } +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::loadSettingsCanclled() +{ + if (mEditExistingLoad == true) { + TRAP_IGNORE(mEngine->ExistingLoadEditCancelled()); + } +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::loadEdit(int rowIndex) +{ + TRAPD(err, mEngine->EditLoadL(rowIndex)); + // error handling + if(err != KErrNone) { + Notifications::error("Load edit failed."); + } +} + +void EngineWrapper::StopAllLoadsYesNoDialogClosed(HbAction *action) +{ + TInt err = KErrNone; + if( action && !action->text().compare("yes", Qt::CaseInsensitive) ){ + const CArrayFix* selectionIndexes = NULL; + try{ + TRAP(err, mEngine->StopAllLoadItemsL()); + } + catch(...){ + Notifications::error("Stop load failed."); + } + } +} +// ---------------------------------------------------------------------------- +void EngineWrapper::StopLoadYesNoDialogClosed(HbAction *action) +{ + if( action && !action->text().compare("yes", Qt::CaseInsensitive) ){ + const CArrayFix* selectionIndexes = NULL; + try{ + QT_TRAP_THROWING( selectionIndexes = QueryListSelectedIndexesOrCurrentItemL() ); + if(selectionIndexes) + QT_TRAP_THROWING( mEngine->StopSelectedOrHighlightedItemsL(selectionIndexes) ); + } + catch(...){ + Notifications::error("Stop load failed."); + } + if(selectionIndexes) + delete selectionIndexes; + } +} + +// --------------------------------------------------------------------------- +bool EngineWrapper::stopLoad(bool stopAll) +{ + + if (stopAll == true) { + QString message = QString("Stop all loads?"); + HbMessageBox::question(message, this, SLOT(StopAllLoadsYesNoDialogClosed(HbAction *)), HbMessageBox::Yes|HbMessageBox::No); + //TRAP(err, mEngine->StopAllLoadItemsL()); + // error handling + return true; + } + else { + // by default use selected items + QList listIndices = mMainView.listSelectionIndexes(); + if (listIndices.count() > 0) + { + QString message = QString("Stop %1 selections?").arg( listIndices.count() ); + HbMessageBox::question(message, this, SLOT(StopLoadYesNoDialogClosed(HbAction *)), HbMessageBox::Yes|HbMessageBox::No); + } + else{ + TInt currentItemIndex = mMainView.currentItemIndex(); + if (mEngine->LoadItemCount() > currentItemIndex && currentItemIndex >= 0) + { + QString message("Stop highlighted selections?"); + HbMessageBox::question(message, this, SLOT(StopLoadYesNoDialogClosed(HbAction *)), HbMessageBox::Yes|HbMessageBox::No); + } + } + return true; + } + +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::resumeAllLoadItems() +{ + TRAPD(err, mEngine->ResumeAllLoadItemsL()); + // error handling + if(err != KErrNone) { + Notifications::error("Error in loads resume."); + } +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::suspendAllLoadItems() +{ + TRAPD(err, mEngine->SuspendAllLoadItemsL()); + // error handling + if(err != KErrNone) { + Notifications::error("Error in loads resume."); + } +} + +// --------------------------------------------------------------------------- +void EngineWrapper::asyncSuspendOrResumeSelectedOrHighlightedItems() + { + TRAPD(err, mEngine->AsyncSuspRes() ); + // error handling + if(err != KErrNone) { + Notifications::error("Error to show item action menu."); + } + } + +void EngineWrapper::asyncStopLoad() + { + const CArrayFix* selectionIndexes = NULL; + selectionIndexes = QueryListSelectedIndexesOrCurrentItemL(); + if(selectionIndexes){ + TRAPD(err, mEngine->AsyncStopLoad( selectionIndexes ) ); + // error handling + if(err != KErrNone) { + Notifications::error("Error to show item action menu."); + } + } + } + + +// --------------------------------------------------------------------------- + +void EngineWrapper::suspendOrResumeSelectedOrHighlightedItems() +{ + TRAPD(err, mEngine->SuspendOrResumeSelectedOrHighlightedItemsL()); + // error handling + if(err != KErrNone) { + Notifications::error("Error to show item action menu."); + } +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::ShowErrorMessage(const TDesC& aErrorMessage) +{ + QString errorMessage((QChar*)aErrorMessage.Ptr(),aErrorMessage.Length()); + Notifications::error(errorMessage); + +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::ShowNote(const TDesC& aNoteMessage) +{ + QString note((QChar*)aNoteMessage.Ptr(),aNoteMessage.Length()); + Notifications::showGlobalNote(note, HbMessageBox::MessageTypeInformation, HbPopup::StandardTimeout); +} + +// --------------------------------------------------------------------------- + +TInt EngineWrapper::QueryCurrentItemIndex() +{ + return mMainView.currentItemIndex(); +} + +// --------------------------------------------------------------------------- + +const CArrayFix* EngineWrapper::QueryListSelectedIndexesOrCurrentItemL() +{ + QList listIndices = mMainView.listSelectionIndexes(); + TInt cnt = listIndices.count(); + CArrayFix* indices = new(ELeave)CArrayFixFlat( cnt > 0 ? cnt : 1 ); + CleanupDeletePushL(indices); + if(cnt > 0){ + for (TInt i = 0; i < cnt; i++) { + indices->AppendL(listIndices.at(i)); + } + } + else{ + indices->AppendL(mMainView.currentItemIndex()); + } + CleanupStack::Pop(indices); + return static_cast*>(indices); +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::OpenLoadSettings(TInt loadType, bool editExistingLoad) +{ + SettingsView* settings = new SettingsView((HbView&)ViewReference(), + WindowReference(), + *this); + mEditExistingLoad = editExistingLoad; + + switch (loadType) { + case ELoadGenCmdNewLoadCPULoad: { + settings->open(LOADTYPES.at(Cpu), + (TLoadGenCommandIds)loadType); + break; + } + case ELoadGenCmdNewLoadEatMemory: { + settings->open(LOADTYPES.at(EatMemory), + (TLoadGenCommandIds)loadType); + break; + } + case ELoadGenCmdNewLoadPhoneCall: { + settings->open(LOADTYPES.at(PhoneCalls), + (TLoadGenCommandIds)loadType); + break; + } + case ELoadGenCmdNewLoadNetConn: { + settings->open(LOADTYPES.at(NWConnections), + (TLoadGenCommandIds)loadType); + break; + } + case ELoadGenCmdNewLoadKeyPress: { + settings->open(LOADTYPES.at(KeyPresses), + (TLoadGenCommandIds)loadType); + break; + } + case ELoadGenCmdNewLoadMessages: { + settings->open(LOADTYPES.at(Messages), + (TLoadGenCommandIds)loadType); + break; + } + case ELoadGenCmdNewLoadApplications: { + settings->open(LOADTYPES.at(Apps), + (TLoadGenCommandIds)loadType); + break; + } + case ELoadGenCmdNewLoadPhotoCaptures: { + settings->open(LOADTYPES.at(Photos), + (TLoadGenCommandIds)loadType); + break; + } + case ELoadGenCmdNewLoadBluetooth: { + settings->open(LOADTYPES.at(BTAct), + (TLoadGenCommandIds)loadType); + break; + } + case ELoadGenCmdNewLoadPointerEvent: { + settings->open(LOADTYPES.at(PointerEvents), + (TLoadGenCommandIds)loadType); + break; + } + default: { + User::Panic(_L("Wrong new load"), 111); + break; + } + } +} + +// --------------------------------------------------------------------------- + +CPULoadAttributes EngineWrapper::getCpuLoadAttributes() +{ + TCPULoadAttributes tCpuLoadAttributes = mEngine->GetCPULoadAttributes(); + CPULoadAttributes attributes; + + attributes.mId = tCpuLoadAttributes.iId; + attributes.mPriority = tCpuLoadAttributes.iPriority; + attributes.mMode = tCpuLoadAttributes.iMode; + attributes.mType = tCpuLoadAttributes.iType; + attributes.mLength = tCpuLoadAttributes.iLength; + attributes.mIdle = tCpuLoadAttributes.iIdle; + attributes.mRandomVariance = tCpuLoadAttributes.iRandomVariance; + attributes.mCpu = tCpuLoadAttributes.iCpu; + attributes.mCpuCount = tCpuLoadAttributes.iCpuCount; + return attributes; +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::setCpuLoadAttributes(const CPULoadAttributes& attributes) +{ + TCPULoadAttributes tCpuLoadAttributes; + + tCpuLoadAttributes.iId = attributes.mId; + tCpuLoadAttributes.iPriority = attributes.mPriority; + tCpuLoadAttributes.iMode = attributes.mMode; + tCpuLoadAttributes.iType = attributes.mType; + tCpuLoadAttributes.iLength = attributes.mLength; + tCpuLoadAttributes.iIdle = attributes.mIdle; + tCpuLoadAttributes.iRandomVariance = attributes.mRandomVariance; + tCpuLoadAttributes.iCpu = attributes.mCpu; + tCpuLoadAttributes.iCpuCount = attributes.mCpuCount; + + mEngine->ChangeCPULoadAttributes(tCpuLoadAttributes); +} + +// --------------------------------------------------------------------------- + +MemoryEatAttributes EngineWrapper::getMemoryEatAttributes() +{ + + TMemoryEatAttributes tMemoryEatAttributes = mEngine->GetMemoryEatAttributes(); + MemoryEatAttributes attributes; + + // Convert TMemoryEatAttributes to MemoryEatAttributes + attributes.mId = tMemoryEatAttributes.iId; + attributes.mPriority = tMemoryEatAttributes.iPriority; + attributes.mSource = tMemoryEatAttributes.iSource; + attributes.mType = tMemoryEatAttributes.iType; + attributes.mBuffer = tMemoryEatAttributes.iBuffer; + attributes.mIdle = tMemoryEatAttributes.iIdle; + attributes.mAmount = tMemoryEatAttributes.iAmount; + attributes.mRandomMin = tMemoryEatAttributes.iRandomMin; + attributes.mRandomMax = tMemoryEatAttributes.iRandomMax; + + TBuf<64> amount; + amount.Copy(tMemoryEatAttributes.iAmountDes); + attributes.mAmountDes = QString((QChar*)amount.Ptr(), amount.Length()); + + TBuf<64> min; + min.Copy(tMemoryEatAttributes.iRandomMinDes); + attributes.mAmountDes = QString((QChar*)min.Ptr(), min.Length()); + + TBuf<64> max; + max.Copy(tMemoryEatAttributes.iRandomMaxDes); + attributes.mAmountDes = QString((QChar*)max.Ptr(), max.Length()); + + attributes.mRandomVariance = tMemoryEatAttributes.iRandomVariance; + return attributes; +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::setMemoryEatAttributes(const MemoryEatAttributes& attributes) +{ + TMemoryEatAttributes tMemoryEatAttributes = mEngine->GetMemoryEatAttributes();//TMemoryEatAttributes tMemoryEatAttributes; + + tMemoryEatAttributes.iId = attributes.mId; + tMemoryEatAttributes.iPriority = attributes.mPriority; + tMemoryEatAttributes.iSource = attributes.mSource; + tMemoryEatAttributes.iType = attributes.mType; + tMemoryEatAttributes.iBuffer = attributes.mBuffer; + tMemoryEatAttributes.iIdle = attributes.mIdle; + tMemoryEatAttributes.iAmount = attributes.mAmount; + tMemoryEatAttributes.iRandomMin = attributes.mRandomMin; + tMemoryEatAttributes.iRandomMax = attributes.mRandomMax; + + TBuf<64> amount = attributes.mAmountDes.utf16(); + tMemoryEatAttributes.iAmountDes.Copy(amount); + + TBuf<64> min = attributes.mRandomMinDes.utf16(); + tMemoryEatAttributes.iRandomMinDes.Copy(min); + + TBuf<64> max = attributes.mRandomMaxDes.utf16(); + tMemoryEatAttributes.iRandomMaxDes.Copy(max); + + tMemoryEatAttributes.iRandomVariance = attributes.mRandomVariance; + + mEngine->ChangeMemoryEatAttributes(tMemoryEatAttributes); +} + +// --------------------------------------------------------------------------- + +PhoneCallAttributes EngineWrapper::getPhoneCallAttributes() +{ + TPhoneCallAttributes tPhoneCallAttributes = mEngine->GetPhoneCallAttributes(); + PhoneCallAttributes attributes; + + attributes.mId = tPhoneCallAttributes.iId; + attributes.mPriority = tPhoneCallAttributes.iPriority; + + TBuf<128> dest; + dest.Copy(tPhoneCallAttributes.iDestination); + attributes.mDestination = QString((QChar*)dest.Ptr(), dest.Length()); + + attributes.mLength = tPhoneCallAttributes.iLength; + attributes.mIdle = tPhoneCallAttributes.iIdle; + attributes.mRandomVariance = tPhoneCallAttributes.iRandomVariance; + return attributes; +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::setPhoneCallAttributes(const PhoneCallAttributes& attributes) +{ + TPhoneCallAttributes tPhoneCallAttributes = mEngine->GetPhoneCallAttributes(); //TPhoneCallAttributes tPhoneCallAttributes; + + tPhoneCallAttributes.iId = attributes.mId; + tPhoneCallAttributes.iPriority = attributes.mPriority; + + TBuf<128> dest = attributes.mDestination.utf16(); + tPhoneCallAttributes.iDestination.Copy(dest); + + tPhoneCallAttributes.iLength = attributes.mLength; + tPhoneCallAttributes.iIdle = attributes.mIdle; + tPhoneCallAttributes.iRandomVariance = attributes.mRandomVariance; + + mEngine->ChangePhoneCallAttributes(tPhoneCallAttributes); +} + +// --------------------------------------------------------------------------- + +NetConnAttributes EngineWrapper::getNetConnAttributes() +{ + TNetConnAttributes tNetConnAttributes = mEngine->GetNetConnAttributes(); + NetConnAttributes attributes; + + attributes.mId = tNetConnAttributes.iId; + attributes.mPriority = tNetConnAttributes.iPriority; + + attributes.mDestination = QString::fromUtf16(tNetConnAttributes.iDestination.Ptr(), tNetConnAttributes.iDestination.Length()); + + attributes.mIdle = tNetConnAttributes.iIdle; + attributes.mRandomVariance = tNetConnAttributes.iRandomVariance; + return attributes; +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::setNetConnAttributes(const NetConnAttributes& attributes) +{ + TNetConnAttributes tNetConnAttributes = mEngine->GetNetConnAttributes(); //TNetConnAttributes tNetConnAttributes; + + tNetConnAttributes.iId = attributes.mId; + tNetConnAttributes.iPriority = attributes.mPriority; + + TBuf<128> dest = attributes.mDestination.utf16(); + tNetConnAttributes.iDestination.Copy(dest); + + tNetConnAttributes.iIdle = attributes.mIdle; + tNetConnAttributes.iRandomVariance = attributes.mRandomVariance; + + mEngine->ChangeNetConnAttributes(tNetConnAttributes); +} + +// --------------------------------------------------------------------------- + +KeyPressAttributes EngineWrapper::getKeyPressAttributes() +{ + TKeyPressAttributes tKeyPressAttributes = mEngine->GetKeyPressAttributes(); + KeyPressAttributes attributes; + + attributes.mId = tKeyPressAttributes.iId; + attributes.mPriority = tKeyPressAttributes.iPriority; + attributes.mHeartBeat = tKeyPressAttributes.iHeartBeat; + attributes.mRandomVariance = tKeyPressAttributes.iRandomVariance; + return attributes; +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::setKeyPressAttributes(const KeyPressAttributes& attributes) +{ + TKeyPressAttributes tKeyPressAttributes = mEngine->GetKeyPressAttributes(); //TKeyPressAttributes tKeyPressAttributes; + + tKeyPressAttributes.iId = attributes.mId; + tKeyPressAttributes.iPriority = attributes.mPriority; + tKeyPressAttributes.iHeartBeat = attributes.mHeartBeat; + tKeyPressAttributes.iRandomVariance = attributes.mRandomVariance; + + mEngine->ChangeKeyPressAttributes(tKeyPressAttributes); +} + +// --------------------------------------------------------------------------- + +PointerEventAttributes EngineWrapper::getPointerEventAttributes() +{ + TPointerEventAttributes tPointerEventAttributes = mEngine->GetPointerEventAttributes(); + PointerEventAttributes attributes; + + attributes.mId = tPointerEventAttributes.iId; + attributes.mPriority = tPointerEventAttributes.iPriority; + attributes.mHeartBeat = tPointerEventAttributes.iHeartBeat; + attributes.mRandomVariance = tPointerEventAttributes.iRandomVariance; + return attributes; +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::setPointerEventAttributes(const PointerEventAttributes& attributes) +{ + TPointerEventAttributes tPointerEventAttributes = mEngine->GetPointerEventAttributes();//TPointerEventAttributes tPointerEventAttributes; + + tPointerEventAttributes.iId = attributes.mId; + tPointerEventAttributes.iPriority = attributes.mPriority; + tPointerEventAttributes.iHeartBeat = attributes.mHeartBeat; + tPointerEventAttributes.iRandomVariance = attributes.mRandomVariance; + + mEngine->ChangePointerEventAttributes(tPointerEventAttributes); +} + +// --------------------------------------------------------------------------- + +MessageAttributes EngineWrapper::getMessageAttributes() +{ + TMessageAttributes tMessageAttributes = mEngine->GetMessageAttributes(); + MessageAttributes attributes; + + attributes.mId = tMessageAttributes.iId; + attributes.mMessageType = tMessageAttributes.iMessageType; + + TBuf<128> dest; + dest.Copy(tMessageAttributes.iDestination); + attributes.mDestination = QString((QChar*)dest.Ptr(), dest.Length()); + + attributes.mPriority = tMessageAttributes.iPriority; + attributes.mAmount = tMessageAttributes.iAmount; + attributes.mLength = tMessageAttributes.iLength; + attributes.mIdle = tMessageAttributes.iIdle; + attributes.mRandomVariance = tMessageAttributes.iRandomVariance; + return attributes; +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::setMessageAttributes(const MessageAttributes& attributes) +{ + TMessageAttributes tMessageAttributes = mEngine->GetMessageAttributes();//TMessageAttributes tMessageAttributes; + + tMessageAttributes.iId = attributes.mId; + tMessageAttributes.iMessageType = attributes.mMessageType; + + TBuf<128> dest = attributes.mDestination.utf16(); + tMessageAttributes.iDestination.Copy(dest); + + tMessageAttributes.iPriority = attributes.mPriority; + tMessageAttributes.iAmount = attributes.mAmount; + tMessageAttributes.iLength = attributes.mLength; + tMessageAttributes.iIdle = attributes.mIdle; + tMessageAttributes.iRandomVariance = attributes.mRandomVariance; + + mEngine->ChangeMessageAttributes(tMessageAttributes); +} + +// --------------------------------------------------------------------------- + +ApplicationsAttributes EngineWrapper::getApplicationsAttributes() +{ + TApplicationsAttributes tApplicationsAttributes = mEngine->GetApplicationsAttributes(); + ApplicationsAttributes attributes; + + attributes.mId = tApplicationsAttributes.iId; + attributes.mPriority = tApplicationsAttributes.iPriority; + attributes.mLaunchingInterval = tApplicationsAttributes.iLaunchingInterval; + attributes.mKeyPressType = tApplicationsAttributes.iKeyPressType; + attributes.mMaxOpen = tApplicationsAttributes.iMaxOpen; + attributes.mHeartBeat = tApplicationsAttributes.iHeartBeat; + attributes.mRandomVariance = tApplicationsAttributes.iRandomVariance; + + return attributes; +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::setApplicationsAttributes(const ApplicationsAttributes& attributes) +{ + TApplicationsAttributes tApplicationsAttributes = mEngine->GetApplicationsAttributes(); //TApplicationsAttributes tApplicationsAttributes; + + tApplicationsAttributes.iId = attributes.mId; + tApplicationsAttributes.iPriority = attributes.mPriority; + tApplicationsAttributes.iLaunchingInterval = attributes.mLaunchingInterval; + tApplicationsAttributes.iKeyPressType = attributes.mKeyPressType; + tApplicationsAttributes.iMaxOpen = attributes.mMaxOpen; + tApplicationsAttributes.iHeartBeat = attributes.mHeartBeat; + tApplicationsAttributes.iRandomVariance = attributes.mRandomVariance; + + mEngine->ChangeApplicationsAttributes(tApplicationsAttributes); +} + + QStringList mAppsArray; + +// --------------------------------------------------------------------------- + +PhotoCaptureAttributes EngineWrapper::getPhotoCaptureAttributes() +{ + TPhotoCaptureAttributes tPhotoCaptureAttributes = mEngine->GetPhotoCaptureAttributes(); + PhotoCaptureAttributes attributes; + + attributes.mId = tPhotoCaptureAttributes.iId; + attributes.mPriority = tPhotoCaptureAttributes.iPriority; + attributes.mCameraCount = tPhotoCaptureAttributes.iCameraCount; + attributes.mCamera = tPhotoCaptureAttributes.iCamera; + attributes.mIdle = tPhotoCaptureAttributes.iIdle; + attributes.mRandomVariance = tPhotoCaptureAttributes.iRandomVariance; + return attributes; +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::setPhotoCaptureAttributes(const PhotoCaptureAttributes& attributes) +{ + TPhotoCaptureAttributes tPhotoCaptureAttributes; + + tPhotoCaptureAttributes.iId = attributes.mId; + tPhotoCaptureAttributes.iPriority = attributes.mPriority; + tPhotoCaptureAttributes.iCameraCount = attributes.mCameraCount; + tPhotoCaptureAttributes.iCamera = attributes.mCamera; + tPhotoCaptureAttributes.iIdle = attributes.mIdle; + tPhotoCaptureAttributes.iRandomVariance = attributes.mRandomVariance; + + mEngine->ChangePhotoCaptureAttributes(tPhotoCaptureAttributes); +} + +// --------------------------------------------------------------------------- + +BluetoothAttributes EngineWrapper::getBluetoothAttributes() +{ + TBluetoothAttributes tBluetoothAttributes = mEngine->GetBluetoothAttributes(); + BluetoothAttributes attributes; + + attributes.mId = tBluetoothAttributes.iId; + attributes.mPriority = tBluetoothAttributes.iPriority; + attributes.mIdle = tBluetoothAttributes.iIdle; + attributes.mRandomVariance = tBluetoothAttributes.iRandomVariance; + attributes.mBluetoothSupported = tBluetoothAttributes.iBluetoothSupported ? true : false; + return attributes; +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::setBluetoothAttributes(const BluetoothAttributes& attributes) +{ + TBluetoothAttributes tBluetoothAttributes; + + tBluetoothAttributes.iId = attributes.mId; + tBluetoothAttributes.iPriority = attributes.mPriority; + tBluetoothAttributes.iIdle = attributes.mIdle; + tBluetoothAttributes.iRandomVariance = attributes.mRandomVariance; + + mEngine->ChangeBluetoothAttributes(tBluetoothAttributes); +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::ReFreshView(CDesCArray* aTextArray) +{ + QStringList itemList; + TInt arrayCnt = aTextArray->Count(); + for (int i = 0; i < arrayCnt; i++) { + itemList.append(QString::fromUtf16( + aTextArray->MdcaPoint(i).Ptr(), + aTextArray->MdcaPoint(i).Length())); + } + mMainView.setLoadListData(itemList); +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::ClearSelection() +{ + mMainView.clearListSelection(); +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::SetCurrentItemIndex(TInt aIndex) +{ + mMainView.setCurrentItemIndex(aIndex); +} + +// --------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/ui/hb/src/loadgenlistitem.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/ui/hb/src/loadgenlistitem.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,232 @@ +/* + * LoadGenListItem.cpp + * + * Created on: Jul 29, 2010 + * Author: sopirbo + */ + +#include "loadgenlistitem.h" + + +#include +#include +#include + +#include +#include +#include + + +LoadGenListItem::LoadGenListItem( EngineWrapper& engWrapp, QGraphicsItem *parent ) : HbListViewItem( parent ), + mEngineWrapper(engWrapp), + hLayout(0), + vLayout(0), + hButtonLayout(0), + mItemText(0), + mEditButton(0), + mSuspendButton(0), + mStopButton(0), + mIcon(0), + mExpanded(false) + { + + + // TODO Auto-generated constructor stub + + } + + +LoadGenListItem::~LoadGenListItem() + { + // TODO Auto-generated destructor stub + } + +HbAbstractViewItem *LoadGenListItem::createItem() +{ + return new LoadGenListItem(*this); +} + +QHash LoadGenListItem::transientState() const + { + + QHash state; + +/* if ( mExpanded ) + { + state.insert( "myexpanded", mExpanded ); + } + else + { + state.insert( "myexpanded", false ); + }*/ + return state; + + } + +void LoadGenListItem::setTransientState(const QHash &state) + { +/* + mExpanded = state.value("myexpanded").toBool();*/ + HbAbstractViewItem::setTransientState( state ); + } + + +void LoadGenListItem::EditButtonClicked() + { + mEngineWrapper.loadEdit(modelIndex().row()); + + } + +void LoadGenListItem::StopButtonClicked() + { + + + mEngineWrapper.asyncStopLoad(); + } + +void LoadGenListItem::SuspendButtonClicked() + { + mEngineWrapper.asyncSuspendOrResumeSelectedOrHighlightedItems(); + + + + } + +void LoadGenListItem::ChangeExpandedState() + { + /* + if( mExpanded ) + { + mExpanded = false; + } + else + { + mExpanded=true; + }*/ + } + + + +void LoadGenListItem::updateChildItems( ) +{ + if(!hLayout) + { + init(); + } + + int userRole = Qt::UserRole + 1; + int userRole2 = Qt::UserRole + 2; + mExpanded = qvariant_cast( modelIndex().data( userRole ) ); + + QVariant variant = modelIndex().data(Qt::DisplayRole); + + QString itemText = qvariant_cast( variant ); + if(variant.isValid()) + { + itemText = qvariant_cast( variant ); + } + else + { + itemText = "Text tTest"; + } + + QVariant decorationRole = modelIndex().data(Qt::DecorationRole); + if (decorationRole.isValid()) + { + QIcon icon = qvariant_cast(decorationRole); + mIcon->setIcon( HbIcon(icon) ); + } + + bool suspended = qvariant_cast( modelIndex().data( userRole2 ) ); + if( suspended ) + { + mSuspendButton->setText("Resume"); + } + else + { + mSuspendButton->setText("Suspend"); + } + + if( !mExpanded ) + { + mItemText->setTextWrapping(Hb::TextNoWrap); + mItemText->setPlainText(itemText); + vLayout->removeItem(hButtonLayout); + } + else + { + mItemText->setTextWrapping(Hb::TextWordWrap); + mItemText->setPlainText(itemText); + //mItemText->setHtml( itemText ); + vLayout->addItem(hButtonLayout); + } + + +} + +void LoadGenListItem::initButtonLayout() + { + + hButtonLayout = new QGraphicsLinearLayout(); + hButtonLayout->setOrientation( Qt::Horizontal ); + + //edit button + mEditButton = new HbPushButton(); + mEditButton->setText("Edit"); + hButtonLayout->addItem( mEditButton ); + hButtonLayout->setAlignment( mEditButton, Qt::AlignLeft ); + + //pause button + mSuspendButton = new HbPushButton(); + mSuspendButton->setText("SuspRes"); + hButtonLayout->addItem( mSuspendButton ); + hButtonLayout->setAlignment( mSuspendButton , Qt::AlignLeft ); + + //pause button + mStopButton = new HbPushButton(); + mStopButton->setText("Stop"); + hButtonLayout->addItem( mStopButton ); + hButtonLayout->setAlignment( mStopButton , Qt::AlignLeft ); + + + connect( mEditButton, SIGNAL( clicked() ), this , SLOT( EditButtonClicked() ) ); + connect( mStopButton, SIGNAL( clicked() ), this , SLOT( StopButtonClicked() ) ); + connect( mSuspendButton, SIGNAL( clicked() ), this , SLOT( SuspendButtonClicked() ) ); + } + + +void LoadGenListItem::init() +{ + hLayout = new QGraphicsLinearLayout(); + hLayout->setContentsMargins(0, 0, 0, 0); + + hLayout->setOrientation( Qt::Horizontal ); + //hLayout->addItem( layout() ); + + vLayout = new QGraphicsLinearLayout(); + vLayout->setOrientation( Qt::Vertical ); + + //icon + mIcon = new HbLabel(); + hLayout->addItem( mIcon ); + hLayout->setAlignment( mIcon, Qt::AlignLeft ); + //hLayout->setStretchFactor( mIcon, 1 ); + + //text + mItemText = new HbLabel(); + HbFontSpec fontSpecPrimary( HbFontSpec::Primary ); + mItemText->setFontSpec( fontSpecPrimary ); + vLayout->addItem( mItemText ); + vLayout->setAlignment( mItemText, Qt::AlignLeft ); + + + initButtonLayout(); + + + hLayout->addItem( vLayout ); + + hLayout->setStretchFactor( vLayout, 2 ); + + setLayout(hLayout); + +} diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/ui/hb/src/loadgenloaditem.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/ui/hb/src/loadgenloaditem.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,88 @@ +/* + * LoadGenLoadItem.cpp + * + * Created on: Aug 5, 2010 + * Author: sopirbo + */ + +#include "LoadGenLoadItem.h" + +LoadGenLoadItem::LoadGenLoadItem() + { + mExpanded = false; + mSuspended = false; + // TODO Auto-generated constructor stub + + } + +bool LoadGenLoadItem::getExpandedState() + { + return mExpanded; + } + +void LoadGenLoadItem::setExpanded( bool state ) + { + mExpanded = state; + QVariant variant = QVariant( mExpanded ); + setData( variant ); + } + +bool LoadGenLoadItem::getSuspendedState() + { + return mSuspended; + } + +void LoadGenLoadItem::setSuspended( bool state ) + { + int role = Qt::UserRole + 2; + mSuspended = state; + QVariant variant = QVariant( mSuspended ); + setData( variant, role ); + } + +int LoadGenLoadItem::type () const + { + return QStandardItem::UserType; + } + +QVariant LoadGenLoadItem::data( int role ) const + { + QVariant variant; + if(role == Qt::UserRole + 1) + { + variant = QVariant(mExpanded); + } + if(role == Qt::UserRole + 2) + { + variant = QVariant(mSuspended); + } + else + { + return QStandardItem::data( role ); + } + return variant; + } + +void LoadGenLoadItem::setData( const QVariant &value, int role ) +{ + QVariant variantvalue; + if (role == Qt::UserRole + 1) + { + variantvalue = QVariant( mExpanded ); + QStandardItem::setData( variantvalue , role ); + return; + } + if (role == Qt::UserRole + 2) + { + variantvalue = QVariant( mSuspended ); + QStandardItem::setData( variantvalue , role ); + return; + } + QStandardItem::setData( value, role ); +} + + +LoadGenLoadItem::~LoadGenLoadItem() + { + // TODO Auto-generated destructor stub + } diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/ui/hb/src/main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/ui/hb/src/main.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include +#include +#include +#include "mainview.h" + + +int main(int argc, char *argv[]) +{ + HbApplication app(argc, argv); + HbMainWindow mainWindow; + + // set as system application to prevent getting shut down events + CEikonEnv::Static()->SetSystem( ETrue ); + + //Create main view + MainView* view = new MainView(mainWindow); + + //initialize main view + view->init(app); + // Add Views to main window and reveal it. + mainWindow.addView(view); + mainWindow.show(); + + return app.exec(); +} diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/ui/hb/src/mainview.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/ui/hb/src/mainview.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,570 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "mainview.h" +#include "enginewrapper.h" +#include "notifications.h" +#include "loadgen.hrh" +#include +#include +#include +#include +#include +#include +//#include +//#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +// --------------------------------------------------------------------------- + +MainView::MainView(HbMainWindow &mainWindow) : + mMainWindow(mainWindow), + mEngineWrapper(0), + mIsLoadListEmpty(true), + mStopAll(NULL), + mSuspendAll(NULL), + mResumeAll(NULL), + mPrevExpandedItem(-1) + +{ +} + +// --------------------------------------------------------------------------- + +MainView::~MainView() +{ + if (mEngineWrapper != 0) { + delete mEngineWrapper; + } + delete mListModel; + delete mListView; + delete mSm; +} + +// --------------------------------------------------------------------------- + +void MainView::init(HbApplication &app) +{ + //this->setTitle("Load Gener."); + this->setTitle("Load Generator"); + mEngineWrapper = new EngineWrapper(mMainWindow, *this); + int error = mEngineWrapper->init(); + Q_ASSERT_X(error == 1, "LoadGen", "Engine initialization failed"); + createMenu(app); + loadListIinit(); + + + //create toolbar showing launch popup + HbToolBar *toolBar = this->toolBar(); + + + HbIcon newLoadIcon(QString(":/newload.svg")); + newLoadIcon.setFlags(newLoadIcon.flags() | HbIcon::Colorized ); + HbIcon pauseIcon(QString(":/pause.svg")); + pauseIcon.setFlags(pauseIcon.flags() | HbIcon::Colorized ); + HbIcon playIcon(QString(":/play.svg")); + playIcon.setFlags(playIcon.flags() | HbIcon::Colorized ); + HbIcon stopIcon(QString(":/cross.svg")); + stopIcon.setFlags(stopIcon.flags() | HbIcon::Colorized ); + + HbAction *actionNewLoad = new HbAction(newLoadIcon,"", toolBar); + HbAction *actionSuspendAll = new HbAction(pauseIcon,"", toolBar); + HbAction *actionResumeAll = new HbAction(playIcon,"", toolBar); + HbAction *actionStopAll = new HbAction(stopIcon,"", toolBar); + + toolBar->addAction( actionNewLoad ); + toolBar->addAction( actionSuspendAll ); + toolBar->addAction( actionResumeAll ); + toolBar->addAction( actionStopAll ); + + toolBar->adjustSize(); + //toolBar->childrenBoundingRect(). //adjustSize(); + connect(actionNewLoad, SIGNAL( triggered() ), this, SLOT( NewLoad() )); + connect(actionSuspendAll, SIGNAL( triggered() ), this, SLOT( suspendAllLoads() )); + connect(actionResumeAll, SIGNAL(triggered()), this, SLOT( resumeAllLoads() )); + connect(actionStopAll, SIGNAL(triggered()), this, SLOT( stopAllLoads() )); +} + +// --------------------------------------------------------------------------- + +void MainView::createMenu(HbApplication &app) +{ + HbMenu *menu = this->menu(); + + // signal mapper for identifying the different command actions + // in executeCommand() handler function: + mSm = new QSignalMapper(this); + connect(mSm, SIGNAL(mapped(int)), this, SLOT(executeMenuCommand(int))); + + if (menu != NULL) { + // Temp work-around for menu item bug in Orbit Wk38, + // sub menu cannot contain more than 6 functional action items! + // two sub menus created to fix this problem. + mLoadSubMenu1 = menu->addMenu("New loads"); + //mLoadSubMenu2 = menu->addMenu("More new loads"); + mCpuLoadAction = mLoadSubMenu1->addAction("CPU load"); + connect(mCpuLoadAction, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mCpuLoadAction, ELoadGenCmdNewLoadCPULoad); + + mMemoryEatLoadAction = mLoadSubMenu1->addAction("Eat memory"); + connect(mMemoryEatLoadAction, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mMemoryEatLoadAction, ELoadGenCmdNewLoadEatMemory); + + mPhoneCallLoadAction = mLoadSubMenu1->addAction("Phone calls"); + connect(mPhoneCallLoadAction, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mPhoneCallLoadAction, ELoadGenCmdNewLoadPhoneCall); + + mMessagesLoadAction = mLoadSubMenu1->addAction("Messages"); + connect(mMessagesLoadAction, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mMessagesLoadAction, ELoadGenCmdNewLoadMessages); +//TODO to be fixed using replacement for downloadmanager + + mNetConnLoadAction = mLoadSubMenu1->addAction("Network conn."); + connect(mNetConnLoadAction, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mNetConnLoadAction, ELoadGenCmdNewLoadNetConn); + + //mKeyPressLoadAction = mLoadSubMenu2->addAction("Key presses"); + mKeyPressLoadAction = mLoadSubMenu1->addAction("Key presses"); + connect(mKeyPressLoadAction, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mKeyPressLoadAction, ELoadGenCmdNewLoadKeyPress); + + //mAppsLoadAction = mLoadSubMenu2->addAction("Applications"); + mAppsLoadAction = mLoadSubMenu1->addAction("Applications"); + connect(mAppsLoadAction, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mAppsLoadAction, ELoadGenCmdNewLoadApplications); + + //mPhotoCapturesLoadAction = mLoadSubMenu2->addAction("Photo captures"); + mPhotoCapturesLoadAction = mLoadSubMenu1->addAction("Photo captures"); + connect(mPhotoCapturesLoadAction, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mPhotoCapturesLoadAction, ELoadGenCmdNewLoadPhotoCaptures); + + //mBtActionsLoadAction = mLoadSubMenu2->addAction("Bluetooth actions"); + mBtActionsLoadAction = mLoadSubMenu1->addAction("Bluetooth actions"); + connect(mBtActionsLoadAction, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mBtActionsLoadAction, ELoadGenCmdNewLoadBluetooth); + + //mPointerEventsLoadAction = mLoadSubMenu2->addAction("Pointer events"); + mPointerEventsLoadAction = mLoadSubMenu1->addAction("Pointer events"); + connect(mPointerEventsLoadAction, SIGNAL( triggered() ), mSm, SLOT(map())); + mSm->setMapping(mPointerEventsLoadAction, ELoadGenCmdNewLoadPointerEvent); + + mActionPerfMon = menu->addAction("Launch PerfMon"); + connect(mActionPerfMon, SIGNAL(triggered()), this, SLOT( launchPerfMon())); + + mActionAbout = menu->addAction("About"); + connect(mActionAbout, SIGNAL(triggered()), this, SLOT( showAboutPopup())); + + mActionExit = menu->addAction("Exit"); + connect(mActionExit, SIGNAL(triggered()), &app, SLOT(quit())); + + // menu dynamic update + connect(menu, SIGNAL(aboutToShow()), this, SLOT(updateMenu())); + } +} + +// --------------------------------------------------------------------------- + +void MainView::loadListIinit() +{ + if(mListItemExpanded.count()) + { + mListItemExpanded.clear(); + } + // Create list view and model for it + mListView = new HbListView(this); + mListView->setItemPrototype( new LoadGenListItem( *mEngineWrapper, mListView ) ); + mListModel = new QStandardItemModel(this); + mListModel->setItemPrototype(new LoadGenLoadItem()); + mListView->setModel(mListModel); + mListView->setSelectionMode(HbListView::NoSelection); + mListView->setVisible( false ); //HighlightMode(HbItemHighlight::Hidden); + + connect(mListView, + SIGNAL(longPressed(HbAbstractViewItem*, QPointF)), + this, + SLOT(handleLoadListEvent(HbAbstractViewItem*, QPointF))); + + connect(mListView, SIGNAL( activated( const QModelIndex& ) ), this, SLOT( activated( const QModelIndex& ))); + + + // Create layout and add list view there: + QGraphicsLinearLayout *mainlayout = new QGraphicsLinearLayout(Qt::Vertical, this); + mainlayout->addItem(mListView); + mainlayout->setAlignment(mListView, Qt::AlignCenter); + setLayout(mainlayout); +} + +// --------------------------------------------------------------------------- + +void MainView::showAboutPopup() +{ + Notifications::about(); +} + +// --------------------------------------------------------------------------- + +void MainView::executeMenuCommand(int cmd) +{ + mEngineWrapper->startNewLoad(cmd); +} + +// --------------------------------------------------------------------------- + + + +void MainView::activated( const QModelIndex& index) + { + LoadGenListItem* listItem = qobject_cast( mListView->viewItem( index.row() ) ); + + if( listItem ) + { + if( mPrevExpandedItem == index.row() || mPrevExpandedItem == -1 ) + { + LoadGenLoadItem* item = (LoadGenLoadItem*)(mListModel->item( index.row(), index.column() )); + item->setExpanded( !item->getExpandedState() ); + mPrevExpandedItem = index.row(); + } + else + { + LoadGenLoadItem* item = (LoadGenLoadItem*)(mListModel->item( index.row(), index.column() )); + item->setExpanded( !item->getExpandedState() ); + LoadGenLoadItem* prevItem = (LoadGenLoadItem*)(mListModel->item( mPrevExpandedItem, 0 )); + if( prevItem ) //in case the load was stopped + { + if(prevItem->getExpandedState()) + { + prevItem->setExpanded( !prevItem->getExpandedState() ); + } + mPrevExpandedItem = index.row(); + } + + } + + mListView->reset(); + } + } +/* + LoadGenLoadItem* item = (LoadGenLoadItem*)(mListModel->item( index.row(), index.column() )); + item->setExpanded( !item->getExpandedState() ); + //close previous expanded item + if( mPrevExpandedItem == -1 ) + { + mPrevExpandedItem = index.row(); + } + else if( mPrevExpandedItem != index.row() ) + { + LoadGenLoadItem* prevItem = (LoadGenLoadItem*)(mListModel->item( mPrevExpandedItem, 0 )); + if( prevItem ) //in case that was stopped + { + prevItem->setExpanded( !prevItem->getExpandedState() ); + mPrevExpandedItem = index.row(); + } + else + { + mPrevExpandedItem = -1; + } + } + mListView->reset(); + */ +// --------------------------------------------------------------------------- + +void MainView::handleLoadListEvent(HbAbstractViewItem */*listViewItem*/, const QPointF &/*coords*/) +{ + const QStringList items = (QStringList() << "Stop" << "Resume/Suspend" << "Edit"); + HbSelectionDialog *dlg = new HbSelectionDialog(); + dlg->setAttribute(Qt::WA_DeleteOnClose); + dlg->setStringItems(items); + dlg->setSelectionMode(HbAbstractItemView::SingleSelection); + dlg->open(this, SLOT(ItemActionPopupClosed(HbAction*))); +} + +// --------------------------------------------------------------------------- + +void MainView::ItemActionPopupClosed(HbAction* action) +{ + HbSelectionDialog *dlg = static_cast(sender()); + if(!action && dlg->selectedItems().count()){ + int userSelectionIndex = dlg->selectedItems().at(0).toInt(); + // all operations for selected list item only. Query selected load list item index from model. + if (userSelectionIndex == 0) { + // stop selected load from the load list: + stopLoad(false); + } + else if (userSelectionIndex == 1) { + // Suspend or Resume + mEngineWrapper->suspendOrResumeSelectedOrHighlightedItems(); + } + else { + // current selected row number from the load list. + int selectedRow = mListView->selectionModel()->currentIndex().row(); + // edit load setttings: + mEngineWrapper->loadEdit(selectedRow); + } + } +} + +void MainView::LoadEdit() + { + int selectedRow = mListView->selectionModel()->currentIndex().row(); + + mEngineWrapper->loadEdit(selectedRow); + } +// -------------------------------------------------------------------------- + +void MainView::stopAllLoads() +{ + stopLoad(true); +} + +// --------------------------------------------------------------------------- + +bool MainView::stopLoad(bool stopAll) +{ + int success = false; + if (mListView != NULL) { + if (stopAll == true) { + success = mEngineWrapper->stopLoad(stopAll); + mIsLoadListEmpty = true; + } + else { + success = mEngineWrapper->stopLoad(stopAll); + } + } + return success; +} + +// --------------------------------------------------------------------------- + +void MainView::updateMenu() +{ + if (mIsLoadListEmpty != true) { + if (mStopAll == NULL) { + mStopAll = new HbAction("Stop all", menu()); + connect(mStopAll, SIGNAL(triggered()), this, SLOT(stopAllLoads())); + menu()->insertAction(mActionAbout, mStopAll); + } + else{ + mStopAll->setVisible(true); + } + if (mSuspendAll == NULL) { + mSuspendAll = new HbAction("Suspend all", menu()); + connect(mSuspendAll, SIGNAL(triggered()), this, SLOT(suspendAllLoads())); + menu()->insertAction(mActionAbout, mSuspendAll); + } + else{ + mSuspendAll->setVisible(true); + } + if (mResumeAll == NULL) { + mResumeAll = new HbAction("Resume all", menu()); + connect(mResumeAll, SIGNAL(triggered()), this, SLOT(resumeAllLoads())); + menu()->insertAction(mActionAbout, mResumeAll); + } + else{ + mResumeAll->setVisible(true); + } + } + else if (mIsLoadListEmpty == true) { + if (mStopAll != NULL && mStopAll->text() == "Stop all") { + mStopAll->setVisible(false); + } + if (mSuspendAll != NULL && mSuspendAll->text() == "Suspend all") { + mSuspendAll->setVisible(false); + } + if (mResumeAll != NULL && mResumeAll->text() == "Resume all") { + mSuspendAll->setVisible(false); + } + } +} + + +// --------------------------------------------------------------------------- + +int MainView::currentItemIndex() +{ + return mListView->selectionModel()->currentIndex().row(); +} + +// --------------------------------------------------------------------------- + +void MainView::setCurrentItemIndex(int index) +{ + QModelIndex newIndex = mListView->model()->index(index, 0); + mListView->selectionModel()->setCurrentIndex(newIndex, + QItemSelectionModel::SelectCurrent); + //mListView->setCurrentIndex( index ); //setCurrentRow(index); +} + +// --------------------------------------------------------------------------- + +void MainView::launchPerfMon() +{ + mEngineWrapper->launchPerfMonApp(); +} + +// --------------------------------------------------------------------------- + +QList MainView::listSelectionIndexes() + { + QList indices; + if (mListView != NULL) { + QItemSelectionModel *selectionModel = mListView->selectionModel(); + if (selectionModel->hasSelection()) { + QModelIndexList modelIndexes = selectionModel->selectedIndexes(); + QModelIndex index; + foreach (index, modelIndexes) { + indices.append(index.row()); + } + } + } + return indices; + } + +// -------------------------------------------------------------------------------------------- + +void MainView::NewLoad() + { + const QStringList items = (QStringList() << "CPU Load" << "Eat memory" << "Phone calls" << "Messages" << "Network conn." << "Key presses" << "Applications" << "Photo captures" << "Bluetooth actions" << "Pointer events" ); + HbSelectionDialog *dlg = new HbSelectionDialog(); + dlg->setAttribute(Qt::WA_DeleteOnClose); + dlg->setStringItems(items); + dlg->setSelectionMode(HbAbstractItemView::SingleSelection); + dlg->open(this, SLOT(loadActionPopupClosed(HbAction*))); + } + + +void MainView::loadActionPopupClosed(HbAction* action) + { + HbSelectionDialog *dlg = static_cast(sender()); + if(!action && dlg->selectedItems().count()){ + int userSelectionIndex = dlg->selectedItems().at(0).toInt(); + // all operations for selected list item only. Query selected load list item index from model. + if (userSelectionIndex == 0) { + mEngineWrapper->startNewLoad(ELoadGenCmdNewLoadCPULoad); + } + if (userSelectionIndex == 1) { + mEngineWrapper->startNewLoad(ELoadGenCmdNewLoadEatMemory); + } + if (userSelectionIndex == 2) { + mEngineWrapper->startNewLoad(ELoadGenCmdNewLoadPhoneCall); + } + if (userSelectionIndex == 3) { + mEngineWrapper->startNewLoad(ELoadGenCmdNewLoadMessages); + } + if (userSelectionIndex == 4) { + mEngineWrapper->startNewLoad(ELoadGenCmdNewLoadNetConn); + } + if (userSelectionIndex == 5) { + mEngineWrapper->startNewLoad(ELoadGenCmdNewLoadKeyPress); + } + if (userSelectionIndex == 6) { + mEngineWrapper->startNewLoad(ELoadGenCmdNewLoadApplications); + } + if (userSelectionIndex == 7) { + mEngineWrapper->startNewLoad(ELoadGenCmdNewLoadPhotoCaptures); + } + if (userSelectionIndex == 8) { + mEngineWrapper->startNewLoad(ELoadGenCmdNewLoadBluetooth); + } + if (userSelectionIndex == 9) { + mEngineWrapper->startNewLoad(ELoadGenCmdNewLoadPointerEvent); + } + + } + } + +// -------------------------------------------------------------------------------------------- +void MainView::suspendAllLoads() +{ + mEngineWrapper->suspendAllLoadItems(); +} + +// --------------------------------------------------------------------------- + +void MainView::resumeAllLoads() +{ + mEngineWrapper->resumeAllLoadItems(); +} + +void MainView::clearListSelection() +{ + if (mListView != NULL) { + mListView->clearSelection(); + } +} + +// --------------------------------------------------------------------------- + +void MainView::setLoadListData(QStringList& items) +{ + QString loadItem; + QString iconName; + mListItemExpanded.clear(); + + if (mListView) { + mListView->setSelectionMode(HbListView::MultiSelection); + mListView->setVisible(true); //setHighlightMode(HbItemHighlight::AlwaysVisible); + mListModel->clear(); + } + if (items.count() > 0) { + mIsLoadListEmpty = false; + } + else if (items.count() == 0) { + mIsLoadListEmpty = true; + } + for (int i = 0; i < items.count(); i++) { + + LoadGenLoadItem *item = new LoadGenLoadItem(); + //QStandardItem *item = new QStandardItem(); + + loadItem = items.at(i); + if (loadItem.startsWith("1")) { + iconName = ":/paused.svg"; + item->setSuspended(true); + } + else { + iconName = ":/active.svg"; + item->setSuspended(false); + } + // remove icon indicator info from string + // to show in load in load list + loadItem.remove(0,2); + item->setText(loadItem); + item->setIcon(QIcon(iconName)); + if(i == mPrevExpandedItem) + { + item->setExpanded(false); + //item->setExpanded(true); + } + else + { + item->setExpanded(false); + } + // set new load to correct row in load list + mListModel->appendRow(item); //insertRow(i, item); + } +} + +// --------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/ui/hb/src/notifications.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/ui/hb/src/notifications.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include +#include +#include + +#include "notifications.h" + + +// --------------------------------------------------------------------------- + +void Notifications::about() +{ + HbMessageBox *messageBox = new HbMessageBox(HbMessageBox::MessageTypeInformation); + messageBox->setText("Version 1.6.0 - October 8th 2010. Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. Licensed under Eclipse Public License v1.0."); + HbLabel *header = new HbLabel("About LoadGen", messageBox); + messageBox->setHeadingWidget(header); + messageBox->setAttribute(Qt::WA_DeleteOnClose); + messageBox->setTimeout(HbPopup::NoTimeout); + messageBox->open(); +} + +// --------------------------------------------------------------------------- + +void Notifications::error(const QString& errorMessage) +{ + showGlobalNote(errorMessage, HbMessageBox::MessageTypeWarning ); +} + +// --------------------------------------------------------------------------- + +void Notifications::showGlobalNote(const QString& text, HbMessageBox::MessageBoxType type, HbPopup::DefaultTimeout timeout) +{ + HbMessageBox *messageBox = new HbMessageBox(type); + messageBox->setText(text); + messageBox->setTimeout(timeout); + messageBox->setAttribute(Qt::WA_DeleteOnClose); + messageBox->open(); +} + +// --------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/loadgen/ui/hb/src/settingsview.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/loadgen/ui/hb/src/settingsview.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,1271 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "settingsview.h" +#include "enginewrapper.h" +#include "loadgen.hrh" +#include "loadgen_loadattributes.h" +#include +#include +//#include +#include +#include +#include +//#include +#include +#include +#include +#include +#include +#include +#include + + +#include + +QStringList PRIORITIES = (QStringList() << "Much less (-20)" << "Less (-10)" << "Normal (0)" << "More (10)" + << "Much more (20)" << "Real time (30)" << "Abs. very low (100)" << "Abs. low (200)" + << "Abs. backgr. (300)" << "Abs. foregr. (400)" << "Abs. high (500)"); +QStringList LOADMODES = (QStringList() << "Yielding" << "Blocking"); +QStringList CPULOADTYPES = (QStringList() << "Continuous" << "Periodic"); +QStringList MEMSOURCES = (QStringList() << "RAM" << "C:" << "D:" << "E:" << "F:" << "G:" << "H:" << "J:" << "K:" + << "L:" << "M:" << "N:"); +QStringList MEMEATTYPES = (QStringList() << "Memory to eat" << "Memory to be left" << "Alternate min/max"); +QStringList KEYPRESSTYPES = (QStringList() << "None" << "Arrow keys"); +QStringList MESSAGETYPES = (QStringList() << "SMS" << "MMS"); + + +SettingsView::SettingsView(HbView &mainView, HbMainWindow &parent, EngineWrapper &engine) + + : mMainWindow(parent), + mMainView(mainView), + mEngineWrapper(engine), + mAmount(NULL), + mMinAmountToBeLeft(NULL), + mMaxAmountToBeLeft(NULL), + mLength(NULL), + mIdle(NULL), + mRandomVar(NULL) +{ +} + +SettingsView::~SettingsView() +{ + +} + +// TODO HbDataFormModelItem data operations does not work correctly with WK38. +// Item data does not get updated correctly as set by initial settings(HbDataFormModelItem::RadioButtonListItem) +// or user settings.(HbDataFormModelItem::TextItem) + +// --------------------------------------------------------------------------- + +void SettingsView::open(const QString &settingsName, TLoadGenCommandIds cmdId) +{ + mCmdId = cmdId; + // Remove main view from main window and add this view to main window + mMainWindow.addView(this); + mMainWindow.setCurrentView(this); + setTitle(settingsName); + + //create toolbar showing launch popup + HbToolBar *toolBar = this->toolBar(); + HbAction *actionOk = new HbAction("Ok", toolBar); + HbAction *actionCancel = new HbAction("Cancel", toolBar); + toolBar->addAction( actionOk ); + toolBar->addAction( actionCancel ); + + //create setting form + mSettingForm = new HbDataForm(); + + //create a model class + mModel = new HbDataFormModel(this); + createItems(mModel, 0); + // Set created model to form + + mSettingForm->setModel(mModel); + setWidget(mSettingForm); + loadAttributes(); + + connect(actionOk, SIGNAL(triggered()), this, SLOT(okExit())); + connect(actionCancel, SIGNAL(triggered()), this, SLOT(cancelled())); + connect(this, SIGNAL(aboutToClose()), this, SLOT(backButtonPressed())); + //connect(mSettingForm, SIGNAL(activated(const QModelIndex)), this, SLOT(dataItemDisplayed(const QModelIndex))); + + show(); +} + +// --------------------------------------------------------------------------- + +void SettingsView::createItems(HbDataFormModel *model, + HbDataFormModelItem *parent) +{ + switch (mCmdId) { + case ELoadGenCmdNewLoadCPULoad: { + createCpuLoadItems(model, parent); + break; + } + case ELoadGenCmdNewLoadEatMemory: { + createEatMemoryItems(model, parent); + break; + } + case ELoadGenCmdNewLoadPhoneCall: { + createPhoneCallItems(model, parent); + break; + } + case ELoadGenCmdNewLoadNetConn: { + createNetConnItems(model, parent); + break; + } + case ELoadGenCmdNewLoadKeyPress: + case ELoadGenCmdNewLoadPointerEvent: { + createKeyOrPointerItems(model, parent); + break; + } + case ELoadGenCmdNewLoadMessages: { + createMessageItems(model, parent); + break; + } + case ELoadGenCmdNewLoadApplications: { + createAppsItems(model, parent); + break; + } + case ELoadGenCmdNewLoadPhotoCaptures: { + createPhotoItems(model, parent); + break; + } + case ELoadGenCmdNewLoadBluetooth: { + createBtItems(model, parent); + break; + } + default: { + break; + } + } +} + +// --------------------------------------------------------------------------- + +void SettingsView::createCpuLoadItems(HbDataFormModel *model, HbDataFormModelItem *parent) +{ + + mLoadSettings = parent; + //mLoadSettings = model->appendDataFormGroup(QString("CPU load settings"), parent); + + // DataFormItem for priority selection + mPriority = model->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem, + QString("Priority"), + mLoadSettings); + + mPriority->setContentWidgetData(QString("items"), PRIORITIES); + + // DataFormItem for load mode selection + mLoadMode = model->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem, + QString("Load mode"), + mLoadSettings); + mLoadMode->setContentWidgetData(QString("items"), LOADMODES); + + // DataFormItem for load type selection + mType = model->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem, + QString("Type"), + mLoadSettings); + mType->setContentWidgetData(QString("items"), CPULOADTYPES); + + mSettingForm->addConnection(mType,SIGNAL(itemSelected(int)),this,SLOT(selectionChanged(int))); +} + +// --------------------------------------------------------------------------- + +void SettingsView::createEatMemoryItems(HbDataFormModel *model, HbDataFormModelItem *parent) +{ + mLoadSettings = parent; + //mLoadSettings = model->appendDataFormGroup(QString("Eat memory settings"), parent); + + // DataFormItem for priority selection + mPriority = model->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem, + QString("Priority"), + mLoadSettings); + mPriority->setContentWidgetData(QString("items"), PRIORITIES); + + // DataFormItem for memory eat type selection + mSource = model->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem, + QString("Source"), + mLoadSettings); + mSource->setContentWidgetData(QString("items"), MEMSOURCES); + + + // DataFormItem for memory eat type selection + mType = model->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem, + QString("Type"), + mLoadSettings); + mType->setContentWidgetData(QString("items"), MEMEATTYPES); + + // DataFormItem for idle length selection + mBuffer = model->appendDataFormItem(HbDataFormModelItem::TextItem, + QString("Buffer (B)"), + mLoadSettings); + mBuffer->setContentWidgetData("maximum" , 999999999); + mBuffer->setContentWidgetData("minimum", 0); + + // DataFormItem for idle length selection + mIdle = model->appendDataFormItem(HbDataFormModelItem::TextItem, + QString("Idle after buffer (ms)"), + mLoadSettings); + mIdle->setContentWidgetData("maximum" , 999999999); + mIdle->setContentWidgetData("minimum", 0); + + mRandomVar = model->appendDataFormItem(HbDataFormModelItem::TextItem, + QString("Random variance (%)"), + mLoadSettings); + mRandomVar->setContentWidgetData("maximum" , 100); + mRandomVar->setContentWidgetData("minimum", 0); + + mSettingForm->addConnection(mType,SIGNAL(itemSelected(int)),this,SLOT(selectionChanged(int))); +} + +// --------------------------------------------------------------------------- + +void SettingsView::createPhoneCallItems(HbDataFormModel *model, HbDataFormModelItem *parent) +{ + + mLoadSettings = parent; + //mLoadSettings = model->appendDataFormGroup(QString("Phone calls settings"), parent); + + // DataFormItem for priority selection + mPriority = model->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem, + QString("Priority"), + mLoadSettings); + mPriority->setContentWidgetData(QString("items"), PRIORITIES); + + mDestination = mModel->appendDataFormItem(HbDataFormModelItem::TextItem, + QString("Phone number:"), + mLoadSettings); + mDestination->setContentWidgetData("maximum" , 99999999999999999999.0 ); + mDestination->setContentWidgetData("minimum", 0); + + mLength = mModel->appendDataFormItem(HbDataFormModelItem::TextItem, + QString("Length (ms)"), + mLoadSettings); + mLength->setContentWidgetData("maximum" , 999999999); + mLength->setContentWidgetData("minimum", 0); + + // DataFormItem for idle length selection + mIdle = model->appendDataFormItem(HbDataFormModelItem::TextItem, + QString("Idle (ms)"), + mLoadSettings); + mIdle->setContentWidgetData("maximum" , 999999999); + mIdle->setContentWidgetData("minimum", 0); + + mRandomVar = model->appendDataFormItem(HbDataFormModelItem::TextItem, + QString("Random variance (%)"), + mLoadSettings); + mRandomVar->setContentWidgetData("maximum" , 100); + mRandomVar->setContentWidgetData("minimum", 0); +} + +// --------------------------------------------------------------------------- + +void SettingsView::createNetConnItems(HbDataFormModel *model, HbDataFormModelItem *parent) +{ + + //mLoadSettings = model->appendDataFormGroup(QString("Network conn. settings"), parent); + mLoadSettings = parent; + + // DataFormItem for priority selection + mPriority = model->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem, + QString("Priority"), + mLoadSettings); + mPriority->setContentWidgetData(QString("items"), PRIORITIES); + + mDestination = mModel->appendDataFormItem(HbDataFormModelItem::TextItem, + QString("Destination URL:"), + mLoadSettings); + + // DataFormItem for idle length selection + mIdle = model->appendDataFormItem(HbDataFormModelItem::TextItem, + QString("Idle (ms)"), + mLoadSettings); + mIdle->setContentWidgetData("maximum" , 999999999); + mIdle->setContentWidgetData("minimum", 0); + + mRandomVar = model->appendDataFormItem(HbDataFormModelItem::TextItem, + QString("Random variance (%)"), + mLoadSettings); + mRandomVar->setContentWidgetData("maximum" , 100); + mRandomVar->setContentWidgetData("minimum", 0); +} + +// --------------------------------------------------------------------------- + +void SettingsView::createKeyOrPointerItems(HbDataFormModel *model, HbDataFormModelItem *parent) +{ + QString settingsName; + if (mCmdId == ELoadGenCmdNewLoadPointerEvent) { + settingsName = "Pointer events settings"; + } + else { + settingsName = "Key presses settings"; + } + //mLoadSettings = model->appendDataFormGroup(settingsName, parent); + mLoadSettings = parent; + + // DataFormItem for priority selection + mPriority = model->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem, + QString("Priority"), + mLoadSettings); + mPriority->setContentWidgetData(QString("items"), PRIORITIES); + + + // DataFormItem for heartbeat length selection + mHeartBeat = model->appendDataFormItem(HbDataFormModelItem::TextItem, + QString("Heartbeat (ms)"), + mLoadSettings); + mHeartBeat->setContentWidgetData("maximum" , 999999999); + mHeartBeat->setContentWidgetData("minimum", 0); + + // Random variance + mRandomVar = model->appendDataFormItem(HbDataFormModelItem::TextItem, + QString("Random variance (%)"), + mLoadSettings); + mRandomVar->setContentWidgetData("maximum" , 100); + mRandomVar->setContentWidgetData("minimum", 0); +} + +// --------------------------------------------------------------------------- + +void SettingsView::createMessageItems(HbDataFormModel *model, HbDataFormModelItem *parent) +{ + mLoadSettings = parent; + //mLoadSettings = model->appendDataFormGroup(QString("Messages settings"), parent); + + // DataFormItem for priority selection + mPriority = model->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem, + QString("Priority"), + mLoadSettings); + mPriority->setContentWidgetData(QString("items"), PRIORITIES); + + + mType = model->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem, + QString("Type"), + mLoadSettings); + mType->setContentWidgetData(QString("items"), MESSAGETYPES); + + + mDestination = mModel->appendDataFormItem(HbDataFormModelItem::TextItem, + QString("Phone number:"), + mLoadSettings); + mDestination->setContentWidgetData("maximum" , 99999999999999999999.0 ); + mDestination->setContentWidgetData("minimum", 0); + + mAmount = mModel->insertDataFormItem(3, HbDataFormModelItem::TextItem, + QString("Maximum amount of messages"), + mLoadSettings); + mAmount->setContentWidgetData("maximum" , 1000); + mAmount->setContentWidgetData("minimum", 0); + + mLength = mModel->appendDataFormItem(HbDataFormModelItem::TextItem, + QString("Message length"), + mLoadSettings); + mLength->setContentWidgetData("maximum" , 999999999); + mLength->setContentWidgetData("minimum", 0); + + // DataFormItem for idle length selection + mIdle = model->appendDataFormItem(HbDataFormModelItem::TextItem, + QString("Idle (ms)"), + mLoadSettings); + mIdle->setContentWidgetData("maximum" , 999999999); + mIdle->setContentWidgetData("minimum", 0); + + mRandomVar = model->appendDataFormItem(HbDataFormModelItem::TextItem, + QString("Random variance (%)"), + mLoadSettings); + mRandomVar->setContentWidgetData("maximum" , 100); + mRandomVar->setContentWidgetData("minimum", 0); +} + +// --------------------------------------------------------------------------- + +void SettingsView::createAppsItems(HbDataFormModel *model, HbDataFormModelItem *parent) +{ + //mLoadSettings = model->appendDataFormGroup(QString("Applications settings"), parent); + mLoadSettings = parent; + + // DataFormItem for priority selection + mPriority = model->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem, + QString("Priority"), + mLoadSettings); + mPriority->setContentWidgetData(QString("items"), PRIORITIES); + + mMaxParallelApps = model->appendDataFormItem(HbDataFormModelItem::TextItem, + QString("Max parallel applications"), + mLoadSettings); + mMaxParallelApps->setContentWidgetData("maximum" , 100); + mMaxParallelApps->setContentWidgetData("minimum", 0); + + + // DataFormItem for launching interval length selection + mLaunchingInterval = model->appendDataFormItem(HbDataFormModelItem::TextItem, + QString("Launching interval (ms)"), + mLoadSettings); + mLaunchingInterval->setContentWidgetData("maximum" , 999999999); + mLaunchingInterval->setContentWidgetData("minimum", 0); + + // DataFormItem for key press type selection + mKeyPressType = model->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem, + QString("Key press type"), + mLoadSettings); + mKeyPressType->setContentWidgetData(QString("items"), KEYPRESSTYPES); + + // DataFormItem for heartbeat length selection + mHeartBeat = model->appendDataFormItem(HbDataFormModelItem::TextItem, + QString("Key press interval (ms)"), + mLoadSettings); + mHeartBeat->setContentWidgetData("maximum" , 999999999); + mHeartBeat->setContentWidgetData("minimum", 0); + + // Random variance + mRandomVar = model->appendDataFormItem(HbDataFormModelItem::TextItem, + QString("Random variance (%)"), + mLoadSettings); + mRandomVar->setContentWidgetData("maximum" , 100); + mRandomVar->setContentWidgetData("minimum", 0); +} + +// --------------------------------------------------------------------------- + +void SettingsView::createPhotoItems(HbDataFormModel *model, HbDataFormModelItem *parent) +{ + //mLoadSettings = model->appendDataFormGroup(QString("Camera settings"), parent); + mLoadSettings = parent; + + // DataFormItem for priority selection + mPriority = model->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem, + QString("Priority"), + mLoadSettings); + mPriority->setContentWidgetData(QString("items"), PRIORITIES); + + + // DataFormItem for idle length selection + mIdle = model->appendDataFormItem(HbDataFormModelItem::TextItem, + QString("Idle (ms)"), + mLoadSettings); + mIdle->setContentWidgetData("maximum" , 999999999); + mIdle->setContentWidgetData("minimum", 0); + + // Random variance + mRandomVar = model->appendDataFormItem(HbDataFormModelItem::TextItem, + QString("Random variance (%)"), + mLoadSettings); + mRandomVar->setContentWidgetData("maximum" , 100); + mRandomVar->setContentWidgetData("minimum", 0); +} + +// --------------------------------------------------------------------------- + +void SettingsView::createBtItems(HbDataFormModel *model, HbDataFormModelItem *parent) +{ + //mLoadSettings = model->appendDataFormGroup(QString("Bluetooth settings"), parent); + mLoadSettings = parent; + + // DataFormItem for priority selection + mPriority = model->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem, + QString("Priority"), + mLoadSettings); + mPriority->setContentWidgetData(QString("items"), PRIORITIES); + + + // DataFormItem for idle length selection + mIdle = model->appendDataFormItem(HbDataFormModelItem::TextItem, + QString("Idle (ms)"), + mLoadSettings); + mIdle->setContentWidgetData("maximum" , 999999999); + mIdle->setContentWidgetData("minimum", 0); + + // Random variance + mRandomVar = model->appendDataFormItem(HbDataFormModelItem::TextItem, + QString("Random variance (%)"), + mLoadSettings); + mRandomVar->setContentWidgetData("maximum" , 100); + mRandomVar->setContentWidgetData("minimum", 0); +} + +// --------------------------------------------------------------------------- +// Load attributes from engine & set the data into each form model item: + +void SettingsView::loadAttributes() +{ + switch (mCmdId) + { + case ELoadGenCmdNewLoadCPULoad: { + mCPULoadAttributes = mEngineWrapper.getCpuLoadAttributes(); + mPriority->setContentWidgetData(QString("selected"), mCPULoadAttributes.mPriority); + mLoadMode->setContentWidgetData(QString("selected"), mCPULoadAttributes.mMode); + mType->setContentWidgetData(QString("selected"), mCPULoadAttributes.mType); + + if (mCPULoadAttributes.mType == ECpuLoadTypePeriodic) { //if (mCPULoadAttributes.mMode == ECpuLoadTypePeriodic) { + // Create and append to model these items: Length, Idle, Random variance, if load type is peridodic. + + // DataFormItem for load length selection + mLength = mModel->appendDataFormItem(HbDataFormModelItem::TextItem, + QString("Length (ms)"), + mLoadSettings); + mLength->setContentWidgetData("maximum" , 999999999); + mLength->setContentWidgetData("minimum", 0); + + + // DataFormItem for load length selection + mIdle = mModel->appendDataFormItem(HbDataFormModelItem::TextItem, + QString("Idle (ms)"), + mLoadSettings); + mIdle->setContentWidgetData("maximum" , 999999999); + mIdle->setContentWidgetData("minimum", 0); + + mRandomVar = mModel->appendDataFormItem(HbDataFormModelItem::TextItem, + QString("Random variance (%)"), + mLoadSettings); + mRandomVar->setContentWidgetData("maximum" , 100); + mRandomVar->setContentWidgetData("minimum", 0); + + mLength->setContentWidgetData(QString("text"), mCPULoadAttributes.mLength); + mIdle->setContentWidgetData(QString("text"), mCPULoadAttributes.mIdle); + mRandomVar->setContentWidgetData(QString("text"), mCPULoadAttributes.mRandomVariance); + } + + // if there's more than one cpu available in the system, + // insert possibility to select which cpu the load is generated to + if (mCPULoadAttributes.mCpuCount > 1) + { + QStringList cpuArray; + cpuArray.append("Free scheduling"); + // add cpus to list: + for (int i = 0; i < mCPULoadAttributes.mCpuCount; i++) + { + QString cpu = QString("CPU%1").arg(i); + cpuArray.append(cpu); + } + // "All CPUs" means that one thread is started for each CPU. + cpuArray.append("All CPUs"); + + mCpu = mModel->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem, + QString("CPU"), + mLoadSettings); + mCpu->setContentWidgetData(QString("items"), cpuArray); + + if (mCPULoadAttributes.mCpu < 0) { + mCpu->setContentWidgetData(QString("selected"), 0); + } + + else if (mCPULoadAttributes.mCpu == KCPUSelection_AllCPUs) { + mCpu->setContentWidgetData(QString("selected"), cpuArray.count()-1); + } + // CPU is defined, set the correct CPU as default selection in query list + else { + // mCpu starts from zero (i.e. CPU0 is first CPU), but index zero + // in settings Ui form item is reserved for "Free scheduling", hence iCpu+1. + mCpu->setContentWidgetData(QString("selected"), mCPULoadAttributes.mCpu+1); + } + } + break; + } + case ELoadGenCmdNewLoadEatMemory: { + mMemoryEatAttributes = mEngineWrapper.getMemoryEatAttributes(); + mPriority->setContentWidgetData(QString("selected"), mMemoryEatAttributes.mPriority); + mSource->setContentWidgetData(QString("selected"), mMemoryEatAttributes.mSource); + mType->setContentWidgetData(QString("selected"), mMemoryEatAttributes.mType); + + if (mMemoryEatAttributes.mType == EMemoryEatTypeWavy) { + mMinAmountToBeLeft = mModel->insertDataFormItem(3, HbDataFormModelItem::TextItem, + QString("Min to be left (B)"), + mLoadSettings); + mMinAmountToBeLeft->setContentWidgetData("maximum" , 99999999999999); + mMinAmountToBeLeft->setContentWidgetData("minimum", 0); + + mMaxAmountToBeLeft = mModel->insertDataFormItem(4, HbDataFormModelItem::TextItem, + QString("Max to be left (B)"), + mLoadSettings); + mMaxAmountToBeLeft->setContentWidgetData("maximum" , 99999999999999); + mMaxAmountToBeLeft->setContentWidgetData("minimum", 0); + + mMinAmountToBeLeft->setContentWidgetData(QString("text"), mMemoryEatAttributes.mRandomMinDes); + mMaxAmountToBeLeft->setContentWidgetData(QString("text"), mMemoryEatAttributes.mRandomMaxDes); + } + else if (mMemoryEatAttributes.mType == EMemoryEatTypeMemoryToEat || + mMemoryEatAttributes.mType == EMemoryEatTypeMemoryToBeLeft ) { + mAmount = mModel->insertDataFormItem(3, HbDataFormModelItem::TextItem, + QString("Amout(B)"), + mLoadSettings); + mAmount->setContentWidgetData("maximum" , 999999999999999); + mAmount->setContentWidgetData("minimum", 0); + + mAmount->setContentWidgetData(QString("text"), mMemoryEatAttributes.mAmount); + } + mBuffer->setContentWidgetData(QString("text"), mMemoryEatAttributes.mBuffer); + mIdle->setContentWidgetData(QString("text"), mMemoryEatAttributes.mIdle); + mRandomVar->setContentWidgetData(QString("text"), mMemoryEatAttributes.mRandomVariance); + break; + } + case ELoadGenCmdNewLoadPhoneCall: { + mPhoneCallAttributes = mEngineWrapper.getPhoneCallAttributes(); + mPriority->setContentWidgetData(QString("selected"), mPhoneCallAttributes.mPriority); + mDestination->setContentWidgetData(QString("text"), mPhoneCallAttributes.mDestination); + mLength->setContentWidgetData(QString("text"), mPhoneCallAttributes.mLength); + mIdle->setContentWidgetData(QString("text"), mPhoneCallAttributes.mIdle); + mRandomVar->setContentWidgetData(QString("text"), mPhoneCallAttributes.mRandomVariance); + break; + } + case ELoadGenCmdNewLoadNetConn: { + mNetConnAttributes = mEngineWrapper.getNetConnAttributes(); + mPriority->setContentWidgetData(QString("selected"), mNetConnAttributes.mPriority); + mDestination->setContentWidgetData(QString("text"), mNetConnAttributes.mDestination); + mIdle->setContentWidgetData(QString("text"), mNetConnAttributes.mIdle); + mRandomVar->setContentWidgetData(QString("text"), mNetConnAttributes.mRandomVariance); + break; + } + case ELoadGenCmdNewLoadKeyPress: { + mKeyPressAttributes = mEngineWrapper.getKeyPressAttributes(); + mPriority->setContentWidgetData(QString("selected"), mKeyPressAttributes.mPriority); + mHeartBeat->setContentWidgetData(QString("text"), mKeyPressAttributes.mHeartBeat); + mRandomVar->setContentWidgetData(QString("text"), mKeyPressAttributes.mRandomVariance); + break; + } + case ELoadGenCmdNewLoadPointerEvent: { + mPointerEventAttributes = mEngineWrapper.getPointerEventAttributes(); + mPriority->setContentWidgetData(QString("selected"), mPointerEventAttributes.mPriority); + mHeartBeat->setContentWidgetData(QString("text"), mPointerEventAttributes.mHeartBeat); + mRandomVar->setContentWidgetData(QString("text"), mPointerEventAttributes.mRandomVariance); + break; + } + case ELoadGenCmdNewLoadMessages: { + mMessageAttributes = mEngineWrapper.getMessageAttributes(); + mPriority->setContentWidgetData(QString("selected"), mMessageAttributes.mPriority); + mType->setContentWidgetData(QString("selected"), mMessageAttributes.mMessageType); + mDestination->setContentWidgetData(QString("text"), mMessageAttributes.mDestination); + mAmount->setContentWidgetData(QString("text"), mMessageAttributes.mAmount); + mLength->setContentWidgetData(QString("text"), mMessageAttributes.mLength); + mIdle->setContentWidgetData(QString("text"), mMessageAttributes.mIdle); + mRandomVar->setContentWidgetData(QString("text"), mMessageAttributes.mRandomVariance); + break; + } + case ELoadGenCmdNewLoadApplications: { + mApplicationsAttributes = mEngineWrapper.getApplicationsAttributes(); + mPriority->setContentWidgetData(QString("selected"), mApplicationsAttributes.mPriority); + mMaxParallelApps->setContentWidgetData(QString("text"), mApplicationsAttributes.mMaxOpen); + mHeartBeat->setContentWidgetData(QString("text"), mApplicationsAttributes.mHeartBeat); + mLaunchingInterval->setContentWidgetData(QString("text"), mApplicationsAttributes.mLaunchingInterval); + mKeyPressType->setContentWidgetData(QString("selected"), mApplicationsAttributes.mKeyPressType); + mRandomVar->setContentWidgetData(QString("text"), mApplicationsAttributes.mRandomVariance); + break; + } + case ELoadGenCmdNewLoadPhotoCaptures: { + mPhotoCaptureAttributes = mEngineWrapper.getPhotoCaptureAttributes(); + mPriority->setContentWidgetData(QString("selected"), mPhotoCaptureAttributes.mPriority); + mIdle->setContentWidgetData(QString("text"), mPhotoCaptureAttributes.mIdle); + mRandomVar->setContentWidgetData(QString("text"), mPhotoCaptureAttributes.mRandomVariance); + + // if there's any cameras avaialable in system, construct form item for it/them: + if (mPhotoCaptureAttributes.mCameraCount > 0) + { + QStringList devices; + // add cameras to list: + for (int i = 0; i < mPhotoCaptureAttributes.mCameraCount; i++) + { + QString cam = QString("Camera %1").arg(i); + devices.append(cam); + } + mCamera = mModel->insertDataFormItem(1, HbDataFormModelItem::RadioButtonListItem, + QString("Device"), + mLoadSettings); + mCamera->setContentWidgetData(QString("items"), devices); + mCamera->setContentWidgetData(QString("selected"), mPhotoCaptureAttributes.mCamera); + } + break; + } + case ELoadGenCmdNewLoadBluetooth: { + mBluetoothAttributes = mEngineWrapper.getBluetoothAttributes(); + mPriority->setContentWidgetData(QString("selected"), mBluetoothAttributes.mPriority); + mIdle->setContentWidgetData(QString("text"), mBluetoothAttributes.mIdle); + mRandomVar->setContentWidgetData(QString("text"), mBluetoothAttributes.mRandomVariance); + break; + } + + default: { + break; + } + } +} + +// --------------------------------------------------------------------------- + +void SettingsView::setDefaultSettings() +{ + +} + +// --------------------------------------------------------------------------- + +void SettingsView::backButtonPressed() +{ + okExit(); +} + +// --------------------------------------------------------------------------- + +void SettingsView::saveSettings() +{ + switch (mCmdId) { + case ELoadGenCmdNewLoadCPULoad: { + saveCpuLoadSettings(); + break; + } + case ELoadGenCmdNewLoadEatMemory: { + saveEatMemorySettings(); + break; + } + case ELoadGenCmdNewLoadPhoneCall: { + savePhoneCallSettings(); + break; + } + case ELoadGenCmdNewLoadNetConn: { + saveNetConnSettings(); + break; + } + case ELoadGenCmdNewLoadKeyPress: { + saveKeyPressSettings(); + break; + } + case ELoadGenCmdNewLoadPointerEvent: { + savePointerEventSettings(); + break; + } + case ELoadGenCmdNewLoadMessages: { + saveMessageSettings(); + break; + } + case ELoadGenCmdNewLoadApplications: { + saveApplicationsSettings(); + break; + } + case ELoadGenCmdNewLoadPhotoCaptures: { + savePhotoSettings(); + break; + } + case ELoadGenCmdNewLoadBluetooth: { + saveBtSettings(); + break; + } + default: { + break; + } + } +} + +// --------------------------------------------------------------------------- + +void SettingsView::saveCpuLoadSettings() +{ + mCPULoadAttributes.mPriority = mPriority->contentWidgetData("selected").toInt(); + mCPULoadAttributes.mMode = mLoadMode->contentWidgetData("selected").toInt(); + mCPULoadAttributes.mType = mType->contentWidgetData("selected").toInt(); + if (mType->contentWidgetData("selected").toInt() == ECpuLoadTypePeriodic) { + // TODO: remove temp checks if (mLength != NULL) etc. when HbDataFormModelItem bugs fixed. + if (mLength != NULL) { + mCPULoadAttributes.mLength = mLength->contentWidgetData("text").toInt(); + } + if (mIdle != NULL) { + mCPULoadAttributes.mIdle = mIdle->contentWidgetData("text").toInt(); + } + if (mRandomVar != NULL) { + int randVar = mRandomVar->contentWidgetData("text").toInt(); + if( randVar >=0 && randVar <= mRandomVar->contentWidgetData("maximum").toInt() ) + { + mCPULoadAttributes.mRandomVariance = mRandomVar->contentWidgetData("text").toInt(); + } + else + { + mCPULoadAttributes.mRandomVariance = mRandomVar->contentWidgetData("maximum").toInt(); + } + } + } + + // we are running in SMP environment + if (mCPULoadAttributes.mCpuCount > 1) + { + TInt currentValueIndex = mCpu->contentWidgetData("selected").toInt(); + // user selected a specific CPU in which the load thread should be run in. + if (currentValueIndex == 0) + { + // User selected "Free scheduling" + mCPULoadAttributes.mCpu = KCPUSelection_FreeScheduling; + } + else if( currentValueIndex == (mCpu->childCount()-1) ) + { + // User selected "All CPUs", which is the last item in the form radio button selection list + mCPULoadAttributes.mCpu = KCPUSelection_AllCPUs; + } + else + { + // mCpu should start from zero (CPU0 is the first cpu) + // but zero in Ui form item index means "Free scheduling". CPU0 in + // index of form radio button list is at index 1, hence -1. + mCPULoadAttributes.mCpu = currentValueIndex - 1; + } + } + + +} + +// --------------------------------------------------------------------------- + +void SettingsView::saveEatMemorySettings() +{ + mMemoryEatAttributes.mPriority = mPriority->contentWidgetData("selected").toInt(); + mMemoryEatAttributes.mSource = mSource->contentWidgetData("selected").toInt(); + mMemoryEatAttributes.mType = mType->contentWidgetData("selected").toInt(); + + if (mType->contentWidgetData("selected").toInt() == EMemoryEatTypeWavy) { + // TODO: remove temp checks if (mLength != NULL) etc. when HbDataFormModelItem bugs fixed. + if (mMinAmountToBeLeft != NULL) { + mMemoryEatAttributes.mRandomMin = + mMinAmountToBeLeft->contentWidgetData("text").toInt(); + } + if (mMaxAmountToBeLeft != NULL) { + mMemoryEatAttributes.mRandomMax = + mMaxAmountToBeLeft->contentWidgetData("text").toInt(); + } + } + else if (mType->contentWidgetData("selected").toInt() == EMemoryEatTypeMemoryToEat || + mType->contentWidgetData("selected").toInt() == EMemoryEatTypeMemoryToBeLeft) { + if (mAmount != NULL) { + //mMemoryEatAttributes.mAmount = mAmount->contentWidgetData("text").toInt(); + mMemoryEatAttributes.mAmount = mAmount->contentWidgetData("text").toDouble(); + } + } + mMemoryEatAttributes.mBuffer = mBuffer->contentWidgetData("text").toInt(); + mMemoryEatAttributes.mIdle = mIdle->contentWidgetData("text").toInt(); + + int randVar = mRandomVar->contentWidgetData("text").toInt(); + if( randVar >=0 && randVar <= mRandomVar->contentWidgetData("maximum").toInt() ) + { + mMemoryEatAttributes.mRandomVariance = mRandomVar->contentWidgetData("text").toInt(); + } + else + { + mMemoryEatAttributes.mRandomVariance = mRandomVar->contentWidgetData("maximum").toInt(); + } + + // swap min- & max values if they are in wrong order + if (mMemoryEatAttributes.mRandomMin > mMemoryEatAttributes.mRandomMax) + { + qint64 temp(mMemoryEatAttributes.mRandomMin); + mMemoryEatAttributes.mRandomMin = mMemoryEatAttributes.mRandomMax; + mMemoryEatAttributes.mRandomMax = temp; + } +} + +// --------------------------------------------------------------------------- + +void SettingsView::savePhoneCallSettings() +{ + mPhoneCallAttributes.mPriority = mPriority->contentWidgetData("selected").toInt(); + mPhoneCallAttributes.mLength = mLength->contentWidgetData("text").toInt(); + mPhoneCallAttributes.mIdle = mIdle->contentWidgetData("text").toInt(); + + int randVar = mRandomVar->contentWidgetData("text").toInt(); + if( randVar >=0 && randVar <= mRandomVar->contentWidgetData("maximum").toInt() ) + { + mPhoneCallAttributes.mRandomVariance = mRandomVar->contentWidgetData("text").toInt(); + } + else + { + mPhoneCallAttributes.mRandomVariance = mRandomVar->contentWidgetData("maximum").toInt(); + } + + + mPhoneCallAttributes.mDestination = mDestination->contentWidgetData("text").toString(); +} + +// --------------------------------------------------------------------------- + +void SettingsView::saveNetConnSettings() +{ + mPhoneCallAttributes.mPriority = mPriority->contentWidgetData("selected").toInt(); + mPhoneCallAttributes.mIdle = mIdle->contentWidgetData("text").toInt(); + int randVar = mRandomVar->contentWidgetData("text").toInt(); + if( randVar >=0 && randVar <= mRandomVar->contentWidgetData("maximum").toInt() ) + { + mPhoneCallAttributes.mRandomVariance = mRandomVar->contentWidgetData("text").toInt(); + } + else + { + mPhoneCallAttributes.mRandomVariance = mRandomVar->contentWidgetData("maximum").toInt(); + } + mPhoneCallAttributes.mDestination = mDestination->contentWidgetData("text").toString(); +} + +// --------------------------------------------------------------------------- + +void SettingsView::saveKeyPressSettings() +{ + mKeyPressAttributes.mPriority = mPriority->contentWidgetData("selected").toInt(); + mKeyPressAttributes.mHeartBeat = mHeartBeat->contentWidgetData("text").toInt(); + int randVar = mRandomVar->contentWidgetData("text").toInt(); + if( randVar >=0 && randVar <= mRandomVar->contentWidgetData("maximum").toInt() ) + { + mKeyPressAttributes.mRandomVariance = mRandomVar->contentWidgetData("text").toInt(); + } + else + { + mKeyPressAttributes.mRandomVariance = mRandomVar->contentWidgetData("maximum").toInt(); + } + +} + +// --------------------------------------------------------------------------- + +void SettingsView::savePointerEventSettings() +{ + mPointerEventAttributes.mPriority = mPriority->contentWidgetData("selected").toInt(); + mPointerEventAttributes.mHeartBeat = mHeartBeat->contentWidgetData("text").toInt(); + int randVar = mRandomVar->contentWidgetData("text").toInt(); + if( randVar >=0 && randVar <= mRandomVar->contentWidgetData("maximum").toInt() ) + { + mPointerEventAttributes.mRandomVariance = mRandomVar->contentWidgetData("text").toInt(); + } + else + { + mPointerEventAttributes.mRandomVariance = mRandomVar->contentWidgetData("maximum").toInt(); + } + +} + +// --------------------------------------------------------------------------- + +void SettingsView::saveMessageSettings() +{ + mMessageAttributes.mPriority = mPriority->contentWidgetData("selected").toInt(); + mMessageAttributes.mMessageType = mType->contentWidgetData("selected").toInt(); + mMessageAttributes.mDestination = mDestination->contentWidgetData("text").toString(); + int amount = mAmount->contentWidgetData("text").toInt(); + if( amount >=0 && amount <= mAmount->contentWidgetData("maximum").toInt() ) + { + mMessageAttributes.mAmount = mAmount->contentWidgetData("text").toInt(); + } + else + { + mMessageAttributes.mAmount = mAmount->contentWidgetData("maximum").toInt(); + } + mMessageAttributes.mLength = mLength->contentWidgetData("text").toInt(); + mMessageAttributes.mIdle = mIdle->contentWidgetData("text").toInt(); + int randVar = mRandomVar->contentWidgetData("text").toInt(); + if( randVar >=0 && randVar <= mRandomVar->contentWidgetData("maximum").toInt() ) + { + mMessageAttributes.mRandomVariance = mRandomVar->contentWidgetData("text").toInt(); + } + else + { + mMessageAttributes.mRandomVariance = mRandomVar->contentWidgetData("maximum").toInt(); + } + +} + +// --------------------------------------------------------------------------- + +void SettingsView::saveApplicationsSettings() +{ + mApplicationsAttributes.mPriority = mPriority->contentWidgetData("selected").toInt(); + int maxApps = mMaxParallelApps->contentWidgetData("text").toInt(); + if( maxApps >=0 && maxApps <= mMaxParallelApps->contentWidgetData("maximum").toInt() ) + { + mApplicationsAttributes.mMaxOpen = mMaxParallelApps->contentWidgetData("text").toInt(); + } + else + { + mApplicationsAttributes.mMaxOpen = mMaxParallelApps->contentWidgetData("maximum").toInt(); + } + mApplicationsAttributes.mLaunchingInterval = mLaunchingInterval->contentWidgetData("text").toInt(); + mApplicationsAttributes.mKeyPressType = mKeyPressType->contentWidgetData("selected").toInt(); + mPointerEventAttributes.mHeartBeat = mHeartBeat->contentWidgetData("text").toInt(); + int randVar = mRandomVar->contentWidgetData("text").toInt(); + if( randVar >=0 && randVar <= mRandomVar->contentWidgetData("maximum").toInt() ) + { + mApplicationsAttributes.mRandomVariance = mRandomVar->contentWidgetData("text").toInt(); + } + else + { + mApplicationsAttributes.mRandomVariance = mRandomVar->contentWidgetData("maximum").toInt(); + } +} + +// --------------------------------------------------------------------------- + +void SettingsView::savePhotoSettings() +{ + mPhotoCaptureAttributes.mPriority = mPriority->contentWidgetData("selected").toInt(); + mPhotoCaptureAttributes.mIdle = mIdle->contentWidgetData("text").toInt(); + int randVar = mRandomVar->contentWidgetData("text").toInt(); + if( randVar >=0 && randVar <= mRandomVar->contentWidgetData("maximum").toInt() ) + { + mPhotoCaptureAttributes.mRandomVariance = mRandomVar->contentWidgetData("text").toInt(); + } + else + { + mPhotoCaptureAttributes.mRandomVariance = mRandomVar->contentWidgetData("maximum").toInt(); + } + + // update only if there's more than one camera device available in the system, + // for use case of one camera available, the selection cannot be changed by user. + if (mPhotoCaptureAttributes.mCameraCount > 1) + { + mPhotoCaptureAttributes.mCamera = mCamera->contentWidgetData("selected").toInt(); + } +} + +// --------------------------------------------------------------------------- + +void SettingsView::saveBtSettings() +{ + mBluetoothAttributes.mPriority = mPriority->contentWidgetData("selected").toInt(); + mBluetoothAttributes.mIdle = mIdle->contentWidgetData("text").toInt(); + int randVar = mRandomVar->contentWidgetData("text").toInt(); + if( randVar >=0 && randVar <= mRandomVar->contentWidgetData("maximum").toInt() ) + { + mBluetoothAttributes.mRandomVariance = mRandomVar->contentWidgetData("text").toInt(); + } + else + { + mBluetoothAttributes.mRandomVariance = mRandomVar->contentWidgetData("maximum").toInt(); + } + +} + +// --------------------------------------------------------------------------- + +void SettingsView::cancelled() +{ + connect(this, + SIGNAL(loadCanclled()), + &mEngineWrapper, + SLOT(loadSettingsCanclled())); + emit loadCanclled(); + + mMainWindow.removeView(this); + mMainWindow.setCurrentView(&mMainView, true); + deleteLater(); +} + +// --------------------------------------------------------------------------- + +void SettingsView::okExit() +{ + saveSettings(); + setLoadAttributes(); + connect(this, + SIGNAL(loadCompleted(TLoadGenCommandIds)), + &mEngineWrapper, + SLOT(loadAddedOrEdited(TLoadGenCommandIds))); + emit loadCompleted(mCmdId); + + mMainWindow.removeView(this); + mMainWindow.setCurrentView(&mMainView, true); + deleteLater(); +} + +// --------------------------------------------------------------------------- + +void SettingsView::setLoadAttributes() +{ + switch (mCmdId) { + case ELoadGenCmdNewLoadCPULoad: { + mEngineWrapper.setCpuLoadAttributes(mCPULoadAttributes); + break; + } + case ELoadGenCmdNewLoadEatMemory: { + mEngineWrapper.setMemoryEatAttributes(mMemoryEatAttributes); + break; + } + case ELoadGenCmdNewLoadPhoneCall: { + mEngineWrapper.setPhoneCallAttributes(mPhoneCallAttributes); + break; + } + case ELoadGenCmdNewLoadNetConn: { + mEngineWrapper.setNetConnAttributes(mNetConnAttributes); + break; + } + case ELoadGenCmdNewLoadKeyPress: { + mEngineWrapper.setKeyPressAttributes(mKeyPressAttributes); + break; + } + case ELoadGenCmdNewLoadPointerEvent: { + mEngineWrapper.setPointerEventAttributes(mPointerEventAttributes); + break; + } + case ELoadGenCmdNewLoadMessages: { + mEngineWrapper.setMessageAttributes(mMessageAttributes); + break; + } + case ELoadGenCmdNewLoadApplications: { + mEngineWrapper.setApplicationsAttributes(mApplicationsAttributes); + break; + } + case ELoadGenCmdNewLoadPhotoCaptures: { + mEngineWrapper.setPhotoCaptureAttributes(mPhotoCaptureAttributes); + break; + } + case ELoadGenCmdNewLoadBluetooth: { + mEngineWrapper.setBluetoothAttributes(mBluetoothAttributes); + break; + } + default: { + break; + } + } +} + +// --------------------------------------------------------------------------- + +void SettingsView::dataItemDisplayed(const QModelIndex &index) +{ + HbDataFormViewItem *item = static_cast(mSettingForm->itemByIndex(index)); + HbWidget *contentWidget = static_cast(item->dataItemContentWidget()); + switch(mCmdId){ + case ELoadGenCmdNewLoadCPULoad: { + if (index.row() == 2) { // Cpu load type selection is in this row: periodic vs. continuous + mModes = static_cast(contentWidget); + connect(mModes , SIGNAL(itemSelected(int)), this, SLOT(selectionChanged(int))); + } + break; + } + case ELoadGenCmdNewLoadEatMemory: { + // Memory eat type is in this row: mem to eat/ mem to be left vs. alternate min/max + if (index.row() == 2) { + mTypes = static_cast(contentWidget ); + connect(mTypes ,SIGNAL(itemSelected(int)), this,SLOT(selectionChanged(int))); + } + break; + } + } +} + +// --------------------------------------------------------------------------- + +void SettingsView::selectionChanged(int index) +{ + switch (mCmdId) { + case ELoadGenCmdNewLoadCPULoad: { + if (index == ECpuLoadTypePeriodic) { + // if periodic selected, add Length, Idle and Random variance to settings, + // if they does not exist yet. + if (mLength == NULL) { + mLength = mModel->insertDataFormItem(3, + HbDataFormModelItem::TextItem, + QString("Length (ms)"), + mLoadSettings); + mLength->setContentWidgetData("maximum" , 999999999); + mLength->setContentWidgetData("minimum", 0); + mLength->setContentWidgetData(QString("text"), mCPULoadAttributes.mLength); + } + if (mIdle == NULL) { + // DataFormItem for load length selection + mIdle = mModel->insertDataFormItem(4, + HbDataFormModelItem::TextItem, + QString("Idle (ms)"), + mLoadSettings); + mIdle->setContentWidgetData("maximum" , 999999999); + mIdle->setContentWidgetData("minimum", 0); + mIdle->setContentWidgetData(QString("text"), mCPULoadAttributes.mIdle); + } + if (mRandomVar == NULL) { + mRandomVar = mModel->insertDataFormItem(5, + HbDataFormModelItem::TextItem, + QString("Random variance (%)"), + mLoadSettings); + mRandomVar->setContentWidgetData("maximum" , 100); + mRandomVar->setContentWidgetData("minimum", 0); + mRandomVar->setContentWidgetData(QString("text"), mCPULoadAttributes.mRandomVariance); + } + } + else if (index == ECpuLoadTypeContinuous) { + // if continuous selected, remove existing Length, Idle and Random variance from settings view: + // if they does not exist do nothing. + if (mLength != NULL) { + mModel->removeItem(mLength); + mLength = NULL; + } + if (mIdle != NULL) { + mModel->removeItem(mIdle); + mIdle = NULL; + } + if (mRandomVar != NULL) { + mModel->removeItem(mRandomVar); + mRandomVar = NULL; + } + } + break; + } + case ELoadGenCmdNewLoadEatMemory: { + if (index == EMemoryEatTypeWavy) { + // remove one item, if exists. + if (mAmount != NULL) { + mModel->removeItem(mAmount); + mAmount = NULL; + } + // insert two new item rows, if not exists. + if (mMinAmountToBeLeft == NULL) { + mMinAmountToBeLeft = mModel->insertDataFormItem(3, HbDataFormModelItem::TextItem, + QString("Min to be left (B)"), + mLoadSettings); + mMinAmountToBeLeft->setContentWidgetData("maximum" , 99999999999999); + mMinAmountToBeLeft->setContentWidgetData("minimum", 0); + mMinAmountToBeLeft->setContentWidgetData( QString("text"),mMemoryEatAttributes.mRandomMin ); + } + if (mMaxAmountToBeLeft == NULL) { + mMaxAmountToBeLeft = mModel->insertDataFormItem(4, HbDataFormModelItem::TextItem, + QString("Max to be left (B)"), + mLoadSettings); + mMaxAmountToBeLeft->setContentWidgetData("maximum" , 99999999999999); + mMaxAmountToBeLeft->setContentWidgetData("minimum", 0); + mMaxAmountToBeLeft->setContentWidgetData( QString("text"),mMemoryEatAttributes.mRandomMax ); + } + } + else if (index == EMemoryEatTypeMemoryToEat || index == EMemoryEatTypeMemoryToBeLeft) { + // remove two item rows, if exists. + if (mMinAmountToBeLeft != NULL) { + mModel->removeItem(mMinAmountToBeLeft); + mMinAmountToBeLeft = NULL; + } + if (mMaxAmountToBeLeft != NULL) { + mModel->removeItem(mMaxAmountToBeLeft); + mMaxAmountToBeLeft = NULL; + } + // insert one item, if not exists. + if (mAmount == NULL) { + mAmount = mModel->insertDataFormItem(3, HbDataFormModelItem::TextItem, + QString("Amout(B)"), + mLoadSettings); + mAmount->setContentWidgetData("maximum" , 99999999999999); + mAmount->setContentWidgetData("minimum", 0); + mAmount->setContentWidgetData( QString("text"),mMemoryEatAttributes.mAmount ); + } + } + } + default: { + break; + } + } +} + +// --------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/screengrabber/ReleaseNotes_ScreenGrabber.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/screengrabber/ReleaseNotes_ScreenGrabber.txt Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,144 @@ +=============================================================================== + +RELEASE NOTES - SCREENGRABBER v5.0.0 +RELEASED 10th March 2010 + +SUPPORTS S60 3.0+ + +=============================================================================== + +Product Description: +==================== +ScreenGrabber tool is used to capture images and video of the visible screen +area in S60 platform. Captures can be handled with the Media Gallery +application or with PC when the device is connected via PC suite. + +Main Features: +============== +- Image capture in single or in sequential mode supporting PNG, JPEG and BMP + formats +- Video capture in animated GIF format +- Configurable saving format, hotkey, time delta in sequential mode, target + memory and default filename +- Ability to change the screen mode to one of the supported more by the device + +=============================================================================== + +What's New in v5.0.0 +==================== +- Orbit UI + +=============================================================================== + +Installation Notes: +=================== +ScreenGrabber is typically preinstalled on ROM. If not, it can be added to the +ROM with the .iby file. Alternatively, the .sis file can be found under the sis- +directory, but the user need to sign it with their own developer certificate. +In Nokia R&D environment, you can use directly the R&D-signed .sis file under the +internal\sis directory. + +When signing with own developer certificate, the following capabilities are +needed: + WriteDeviceData + SwEvent + +When builing ScreenGrabber against S60 3.0 or 3.1, you may need to patch your +SDK environment first with some fixes. For more information, please refer to +the instructions under the "envpatcher" directory. + +=============================================================================== + +System Requirements: +==================== +Basic Requirements: +- Any S60 3.x device or emulator environment + +=============================================================================== + +Compatibility Issues: +===================== +N/A + +=============================================================================== + +Known Issues: +============= + +Sluggish UI when capturing video +-------------------------------- +- Video capturing requires huge amount of processing power and thus may cause + the UI to become sluggish. If supported by the device, try to decrease the + screen resolution. + +=============================================================================== + +Version History: +================ +Version 4.2.0 - 14th May 2009 +------------------------------ +- Feature: Added a new SIS file for S60 3.2 devices and newer to support the + features in newer platforms +- Feature: Added multidrive support in the settings dialog + +Version 4.1.3 - 8th March 2009 +------------------------------ +- Fix: ScreenGrabber does not work in devices which do not have Media Gallery + (Media Gallery File Manager API dependency changed from static to dynamic) + +Version 4.1.2 - 8th February 2008 +--------------------------------- +- Fix: Transparency errors in GIF animations (hopefully) finally fixed + +Version 4.1.1 - 28th January 2008 +--------------------------------- +- Feature: Added hash+* and alternative camera key into selection of capture + keys +- Change: Reimplemented settings handling so that AllFiles and WriteUserData + capabilities are no longer needed + +Version 4.1.0 - 14th January 2008 +--------------------------------- +- Feature: Added support for GIF and MBM formats although it is always + recommended to capture screens in PNG format +- Feature: JPEG format can now be selected as high quality (97%) or low quality + (60%) +- Feature: Added POC key under capturing key options +- Change: Dimensions of a video will be grown if the screen resolution of the + device will grow during capturing +- Change: Capturing is now done always from current focus screen which allows to + support secondary displays +- Change: Send key is now the default key +- Fix: Black color didn't always work correctly in GIF animation optimization + with transparency +- Fix: Capturing to JPEG format leaked memory + +Version 4.0.3 - 16th November 2007 +---------------------------------- +- Fix: Scroll bar in the main view can be scrolled on a touch UI +- Fix: Application closes automatically when closed via open applications menu + +Version 4.0.2 - 9th October 2007 +-------------------------------- +- Fix: Main screen layout in mirrored mode + +Version 4.0.1 - 14th February 2007 +---------------------------------- +- Fix: Help screen on larger displays + +Version 4.0.0 - 25th October 2006 +--------------------------------- +- Feature: Support for sequential capture mode +- Feature: Support for capturing video in animated GIF format +- Feature: Ability to change screen mode to one of the supported more by the + device + +=============================================================================== + +Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +All rights reserved. + +This component and the accompanying materials are made available +under the terms of "Eclipse Public License v1.0" +which accompanies this distribution, and is available +at the URL "http://www.eclipse.org/legal/epl-v10.html". diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/screengrabber/icons/ScreenGrabber_application_icon_final_svgt.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/screengrabber/icons/ScreenGrabber_application_icon_final_svgt.svg Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,235 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/screengrabber/icons/qgn_menu_screengrabber.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/screengrabber/icons/qgn_menu_screengrabber.svg Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,169 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/screengrabber/inc/application.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/screengrabber/inc/application.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef SGAPPLICATION_H +#define SGAPPLICATION_H + +#include +#include + +#include +class EngineWrapper; + +class SGApplication : public HbApplication +{ +public: + SGApplication(int argc, char *argv[]);//, EngineWrapper &engine); + ~SGApplication(); +#if defined(Q_WS_S60) + +#if defined(HB_QT_S60_EVENT_FILTER) + virtual bool s60EventFilter(TWsEvent *aEvent); +#else + virtual bool symbianEventFilter(const QSymbianEvent *event); +#endif // (HB_QT_S60_EVENT_FILTER) +#endif//(Q_WS_S60) + inline void SetEngineWrapper(EngineWrapper *aEngine){iEngine = aEngine;} +private: + RWsSession iWsSession_a; + RWindowGroup iRootWin_a; + + + EngineWrapper *iEngine; +}; + +#endif // SGAPPLICATION_H diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/screengrabber/inc/enginewrapper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/screengrabber/inc/enginewrapper.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,141 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef ENGINEWRAPPER_H +#define ENGINEWRAPPER_H + +#include +#include + + +class SGEngine; +class GrabSettings; +class MainView; +class TWsEvent; +class HbDeviceProgressDialog; + +/** + * class that is used for communicating between Symbian and Qt code. + */ +class EngineWrapper{ +public: + + /** + * Constructor + */ + EngineWrapper(); + + /** + * Destructor + */ + ~EngineWrapper(); + + /** + * Initializes Engine Wrapper + * @return true if engine was started successfully + */ + bool init(); + +public: + + /* Functions that are called from UI */ + + /** + * Fetches settings from engine and converts Symbian data types to Qt's types. + */ + GrabSettings getGrabSettings(); + + /** + * Converts given parameters into Symbian data types and saves them into ScreenGrabber engine + * @param settings new settings + */ + bool saveSettings(const GrabSettings& settings); + + + /* + * Sends received s60 event to engine + */ +#if defined(HB_QT_S60_EVENT_FILTER) + bool handleCaptureCommands(const TWsEvent* aEvent); +#else + bool handleCaptureCommands(const QSymbianEvent *aEvent); +#endif + + + /** + * Sends UI to background + */ + void sendUIToBackground(); + void EnableRcpOfFoc(TBool aState); + void LoadSettings(void); +public: + + /* Functions that are called from engine: */ + + /** + * uses Notifications class to show image captured note + */ + void ShowImageCapturedNote(); + + /** + * uses Notifications class to show video captured note + */ + void ShowVideoCapturedNote(); + + /** + * uses Notifications class to show seguantial images captured note + */ + void ShowSequantialImagesCapturedNote(TInt amount); + + /** + * uses Notifications class to show error message + */ + void ShowErrorMessage(const TDesC16& aErrorMessage); + + /** + * uses Notifications class to show progressbar + */ + void ShowProgressBar(int max); + + /** + * increments shown progressbar's value + */ + void IncrementProgressbarValue(); + + /** + * closes progressbar + */ + void CloseProgressbar(); + + +private: + + bool convertTBoolToBool(TBool value); + +private: + + + /* Screen grabber engine */ + SGEngine *iSGEngine; + + /* progressnote that is shown */ + HbDeviceProgressDialog *iProgressNote; + +}; + +#endif; + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/screengrabber/inc/gifanimator.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/screengrabber/inc/gifanimator.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +#ifndef __GIFANIMATOR_H__ +#define __GIFANIMATOR_H__ + +#include +#include +#include "sgengine.h" + + + +class CImageEncoder; + +class MDialogCallback + { +public: + virtual void DialogDismissedL( TInt aButtonId ) = 0; + }; + + +class CGifAnimator : public CBase + { +public: + static int CreateGifAnimation(const TDesC& aFileName, TSize aDimensions, CVideoFrameArray* aVideoFrameArray, EngineWrapper& aEngineWrapper); + ~CGifAnimator(); + +private: + CGifAnimator(); + void StartL(const TDesC& aFileName, const TSize& aDimensions, CVideoFrameArray* aVideoFrameArray, EngineWrapper& aEngineWrapper); + void WriteHeaderL(const TSize& aDimensions); + void WriteGraphicControlL(const TVideoFrame& aFrame); + void WriteImageDescriptorL(const TVideoFrame& aFrame); + CFbsBitmap* GetBitmapLC(TVideoFrame& aFrame, const TSize& aDimensions); + void WriteRasterDataL(CFbsBitmap* aBitmap); + void WriteFooterL(); + void FinishL(); + void WriteInt8L(TInt aValue); + void WriteInt16L(TInt aValue); + + + +private: + RFs iFs; + RFile iOutFile; + CImageEncoder* iImageEncoder; + HBufC8* iGIFImageData; + + }; + + + +#endif // __GIFANIMATOR_H__ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/screengrabber/inc/mainview.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/screengrabber/inc/mainview.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,119 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef MAINVIEW_H +#define MAINVIEW_H + +#include +#include + +class EngineWrapper; +class HbMainWindow; +class HbApplication; +class SettingsView; +class HbAction; + + + +/** + * Class that implements the main view of Screen Grabber + */ +class MainView : public HbView +{ + Q_OBJECT + +public: + + /** + * Constructor + */ + MainView(HbMainWindow &mainWindow, EngineWrapper &engineWrapper); + + /** + * Destructor + */ + ~MainView(); + + /** + * Initializes Engine Wrapper + * @param app application class of Screen Grabber + */ + void init(HbApplication &app); + + inline void setSettingsView(SettingsView *aSettingsView){ mSettingsView = aSettingsView; } + + +private: + + /** + * Creates menu + */ + void createMenu(HbApplication &app); + + /** + * Created info text ui components + */ + void createInfoText(); + + /** + * Creates toolbar components + */ + void createToolbar(); + +public slots: + + + /** + * Shows about pop-up + */ + void showAboutPopup(); + + /** + * Sends UI to background + */ + void sendToBackground(); + + /** + * opens settings view + */ + void showSettings(); + + void my_quit(); + + void quitYesNoQuestionClosed(HbAction*); + + +public: + + /* Main windo of Screen Grabber */ + HbMainWindow &mMainWindow; + + /* Settings view */ + SettingsView *mSettingsView; + + /* Engine Wrapper */ + EngineWrapper &mEngineWrapper; + + /* Actions that are used in toolbars and menus */ + HbAction* actionSendToBg; + HbAction* actionSettings; + HbAction* actionAbout; + HbAction* actionExit; + +}; + +#endif // MAINVIEW_H diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/screengrabber/inc/notifications.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/screengrabber/inc/notifications.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef NOTIFICATIONS_H_ +#define NOTIFICATIONS_H_ + +#include +#include + + + +class Notifications + { +public: + + /** + * shows about box + */ + static void about(); + + /** + * shows image captured note + */ + static void imageCaptured(); + + /** + * shows video captured note + */ + static void videoCaptured(); + + /** + * shows seguantial images captured note + */ + static void sequantialImagesCaptured(int amount); + + /** + * shows error message + */ + static void error(const QString& errorMessage); + + /** + * to shows progressbar + */ + static HbDeviceProgressDialog* showProgressBar(int max); + + }; + + + +#endif // NOTIFICATIONS_H_ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/screengrabber/inc/settingsview.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/screengrabber/inc/settingsview.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,187 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef SETTINGS_H +#define SETTINGS_H + +#include +#include +#include + +class EngineWrapper; +class HbDataFormModelItem; +class HbDataFormModel; +class HbDataForm; +class HbDataFormViewItem; + +const QStringList CAPTUREMODES = (QStringList() << "Single capture" << "Sequential capture" << "Video capture"); +const QStringList KEYS = (QStringList() << "Send key" << "Power key" << "Side key" << "Camera key"); +const QStringList VIDEOFORMATS = (QStringList() << "Animated GIF"); +const QStringList IMAGEFORMATS = (QStringList() << "PNG" << "JPEG high qual." << "JPEG low qual." << "BMP" << "GIF"); +const QStringList MEMORYMODES = (QStringList() << "Phone memory" << "Memory card"); + + +/** + * Settings class that is used for + */ +class GrabSettings + { +public: + int mCaptureMode; + + int mSingleCaptureHotkey; + int mSingleCaptureImageFormat; + int mSingleCaptureMemoryInUseMultiDrive; + QString mSingleCaptureFileName; + + int mSequantialCaptureHotkey; + int mSequantialCaptureImageFormat; + int mSequantialCaptureDelay; + int mSequantialCaptureMemoryInUseMultiDrive; + QString mSequantialCaptureFileName; + + int mVideoCaptureHotkey; + int mVideoCaptureVideoFormat; + int mVideoCaptureMemoryInUseMultiDrive; + QString mVideoCaptureFileName; + }; + +/** + * Class that creates settings view of Screen Grabber + */ +class SettingsView : public HbView +{ + Q_OBJECT + + enum CaptureMode{ SINGLE, SEQUENTIAL, VIDEO }; + +public: + /** + * Constuctor + * @param mainView pointer to main view + * @param mainWindow pointer to main window + */ + SettingsView(HbView &mainView, HbMainWindow &mainWindow, EngineWrapper &engineWrapper); + + /** + * destructor + */ + ~SettingsView(); + + + /** + * Loads settings from engine and formats those settings into form items + */ + void loadSettings(); + + +private slots: + + /** + * saves settings and closes view. + */ + void saveAndClose(); + + /** + * closes setting view + */ + void close(); + + /** + * Slot that is called each time capture mode is changed + */ +// void updateShownItems(); +private: + + /** + * Creates single capture related components + */ + void createSingleCaptureComponents(HbDataFormModel *model, HbDataFormModelItem *parent); + + /* + * Creates sequential capture related components. + */ + void createSequentialCaptureComponents(HbDataFormModel *model, HbDataFormModelItem *parent); + + /** + * creates video capture related components + */ + void createVideoCaptureComponents(HbDataFormModel *model, HbDataFormModelItem *parent); + + + + /** + * Reads form items and saves them into member variable mSettings + */ + void readFormItems(); + +private: + + /* Settings */ + GrabSettings mSettings; + + /* EngineWrapper */ + EngineWrapper &mEngineWrapper; + + /* Main Window of Screen Grabber */ + HbMainWindow &mMainWindow; + + /* Main View of Screen Grabber */ + HbView &mMainView; + + /* settingform */ + HbDataForm *mSettingForm; + + /* model for settingform */ + HbDataFormModel *mModel; + + /* model's components: */ + + /* mode selection item */ + HbDataFormModelItem *mModeItem; + + /* groups that contain mode specific settings */ + HbDataFormModelItem *mGroupImageCapture; + HbDataFormModelItem *mGroupSeguantialCapture; + HbDataFormModelItem *mGroupVideoCapture; + + /* Still image components */ + HbDataFormModelItem *mImageHotKeyItem; + HbDataFormModelItem *mImageFormatItem; + HbDataFormModelItem *mImageMemoryInUseItem; + HbDataFormModelItem *mImageFileNameItem; + + /* Sequential image components */ + HbDataFormModelItem *mSequantialHotKeyItem; + HbDataFormModelItem *mSequantialFormatItem; + HbDataFormModelItem *mSequantialDelayItem; + HbDataFormModelItem *mSequantialMemoryInUseItem; + HbDataFormModelItem *mSequantialFileNameItem; + + /* Video capture components */ + HbDataFormModelItem *mVideoHotKeyItem; + HbDataFormModelItem *mVideoFormatItem; + HbDataFormModelItem *mVideoMemoryInUseItem; + HbDataFormModelItem *mVideoFileNameItem; + + + + +}; + +#endif diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/screengrabber/inc/sgengine.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/screengrabber/inc/sgengine.h Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,271 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef SGENGINE_H +#define SGENGINE_H + + +// INCLUDES +#include +#include +#include +#include +#include +#include + + +class CFrameImageData; +class CDictionaryFileStore; +class CImageEncoder; +class EngineWrapper; + + +// setting keys (do not change uids of existing keys to maintain compatibility to older versions!) +const TUid KSGSettingCaptureMode = { 0x00 }; + +const TUid KSGSettingSingleCaptureHotkey = { 0x01 }; +const TUid KSGSettingSingleCaptureImageFormat = { 0x02 }; +const TUid KSGSettingSingleCaptureMemoryInUseMultiDrive = { 0x04 }; +const TUid KSGSettingSingleCaptureFileName = { 0x05 }; + +const TUid KSGSettingSequantialCaptureHotkey = { 0x06 }; +const TUid KSGSettingSequantialCaptureImageFormat = { 0x07 }; +const TUid KSGSettingSequantialCaptureDelay = { 0x08 }; +const TUid KSGSettingSequantialCaptureMemoryInUseMultiDrive = { 0x0A }; +const TUid KSGSettingSequantialCaptureFileName = { 0x0B }; + +const TUid KSGSettingVideoCaptureHotkey = { 0x0C }; +const TUid KSGSettingVideoCaptureVideoFormat = { 0x0D }; +const TUid KSGSettingVideoCaptureMemoryInUseMultiDrive = { 0x0F }; +const TUid KSGSettingVideoCaptureFileName = { 0x10 }; + +const TUid KUidScreenGrabber = { 0x101FB751 }; + + +#define TRANSPARENCY_INDEX 30 +#define TRANSPARENCY_ALTERNATIVE_INDEX 24 + +enum TScreenGrabberSettingCaptureModes + { + ECaptureModeSingleCapture = 0, + ECaptureModeSequantialCapture, + ECaptureModeVideoCapture + }; + +enum TScreenGrabberSettingHotkeys + { + EHotkeySendKey = 0, + EHotkeyPowerKey, + EHotkeySideKey, + EHotkeyCameraKey1 + }; + +enum TScreenGrabberSettingImageFormats + { + EImageFormatPNG = 0, + EImageFormatJPGHQ, + EImageFormatJPGLQ, + EImageFormatBMP, + EImageFormatGIF, + EImageFormatMBM + }; + +enum TScreenGrabberSettingVideoFormats + { + EVideoFormatAnimatedGIF = 0 + }; + +enum TScreenGrabberSettingMultiDrive + { + EPhoneMemory = 0, + EMemoryCard + }; + + +class TGrabSettings + { +public: + TInt iCaptureMode; + + TInt iSingleCaptureHotkey; + TInt iSingleCaptureImageFormat; + TInt iSingleCaptureMemoryInUseMultiDrive; + TFileName iSingleCaptureFileName; + + TInt iSequantialCaptureHotkey; + TInt iSequantialCaptureImageFormat; + TInt iSequantialCaptureDelay; + TInt iSequantialCaptureMemoryInUseMultiDrive; + TFileName iSequantialCaptureFileName; + + TInt iVideoCaptureHotkey; + TInt iVideoCaptureVideoFormat; + TInt iVideoCaptureMemoryInUseMultiDrive; + TFileName iVideoCaptureFileName; + }; + +class TVideoFrame + { +public: + TUint iWidth; + TUint iHeight; + TUint iXPos; + TUint iYPos; + TUint iDelay; // 1000 = 1 sec + TBool iEnableTransparency; + TBool iFillsWholeScreen; + TFileName iFileStorePath; + }; + + +typedef CArrayFixSeg CVideoFrameArray; + +/** + * CEngine + * + */ +class SGEngine : public CActive //, public MMdaAudioToneObserver + { + + // active object states + + enum TState + { + EIdle = 0, // do nothing + EEncodingImage, // ICL encoding of an image + ESequenceDelay, // waiting till next capture + ECancelCapturing, // asking to cancel capturing + ENextVideoFrame, // get next frame for video + ECancelVideoCapturing, // asking to cancel video capturing + EQueryDelay // waiting till to remove query + }; + +public: + // Constructors and destructor + + /** + * Destructor. + */ + ~SGEngine(); + + /** + * Two-phased constructor. + */ + static SGEngine* NewL(EngineWrapper *aEngineWrapper); + + /** + * Two-phased constructor. + */ + static SGEngine* NewLC(EngineWrapper *aEngineWrapper); + + /** + * returns current settings + */ + inline TGrabSettings GrabSettings(){ return iGrabSettings; }; + + /** + * saves settings to engine + */ + void SaveSettingsL(const TGrabSettings& aGrabSettings); + + /** + * takes one screen shot + */ + bool TakeScreenShotAndSaveL(); + + TBool DriveOK(TDriveNumber aNumber); + + TBool IsDriveMMC(TDriveNumber aDrive); + +#if defined(HB_QT_S60_EVENT_FILTER) + TBool HandleCaptureCommandsL(const TWsEvent* aEvent); +#else + TBool HandleCaptureCommandsL(const QSymbianEvent *event); +#endif + + + void ActivateModelL(); + void DeActivateModelL(); + void ActivateCaptureKeysL(TBool aChangeKey=EFalse); + void EnableRcpOfFoc(TBool aState); + void LoadSettingsL(); + +private: + + void CapturingFinishedL(TInt aErr); + + void RunL(); + void DoCancel(); + void SaveVideoL(TInt aErr); + void CleanTemporaryFilesL(); + void LoadDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, TInt& aValue); + void LoadDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, TDes& aValue); + + void SaveDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, const TInt& aValue); + void SaveDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, const TDes& aValue); + + void CancelCapturing(); + void CaptureFrameForVideoL(); + + + /** + * Constructor for performing 1st stage construction + */ + SGEngine(); + + /** + * EPOC default constructor for performing 2nd stage construction + */ + void ConstructL(EngineWrapper *aEngineWrapper); + + +private: + RFs iFileSession; + + CActiveScheduler* iActiveScheduler; + CActiveSchedulerWait* iWait; + + TGrabSettings iGrabSettings; // a simple class to store the settings used in the screen capture + RWindowGroup iRootWin; // application's window group + TInt iCapturedKey; // a handle to the key which is captured + TInt iCapturedKeyUnD; // a handle to the key which is captured, up and down + TInt iCapturedKeyHash; // a handle to the hash key which is captured + TInt iCapturedKeyHashUnD; // a handle to the hash key which is captured, up and down + TBool iHashKeyCapturingActivated; // captures hash key is activated + CFbsBitmap* iPreviouslyCapturedBitmap; // a previously captured bitmap + TFileName iSaveFileName; + CImageEncoder* iImageEncoder; // engine from ICL to do the image conversion// target filename of the taken screen shot + CFrameImageData* iFrameImageData; // frame and image block data needed by ICL + TState iState; // state of this active object + TBool iHashKeyDown; // stores state if hash key is currently down + TBool iCapturingInProgress; // boolean to check if capturing is in progress + TBool iStopCapturing; // boolean to specify if to ask capturing + TUint iNumberOfTakenShots; // a number of the taken screen shots in the sequantial mode + RTimer iTimer; // a timer for async delays + TUint iCurrentFrameNumber; // a number of taken frames in video mode + TTime iPreviousFrameTaken; // time when the last frame was taken + TSize iVideoDimensions; // dimension of the video + TSize iPreviousFrameScreenDimension; // dimension of the screen in previous frame + CVideoFrameArray* iVideoFrameArray; // the frames of the video + EngineWrapper* iEngineWrapper; // Eninewrapper that is used for communicating between QT and Symbian + }; + + + + + +#endif // SGENGINE_H diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/screengrabber/rom/backup_registration.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/screengrabber/rom/backup_registration.xml Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,8 @@ + + + + + + + + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/screengrabber/rom/screengrabber.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/screengrabber/rom/screengrabber.iby Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef __SCREENGRABBER_IBY__ +#define __SCREENGRABBER_IBY__ + +S60_APP_EXE(ScreenGrabber) +S60_APP_RESOURCE(ScreenGrabber) +SCALABLE_IMAGE(APP_BITMAP_DIR,APP_BITMAP_DIR,ScreenGrabber) +//#ifdef S60_UPGRADABLE_APP_REG_RSC +// S60_UPGRADABLE_APP_REG_RSC(ScreenGrabber) +//#else +// S60_APP_AIF_RSC(ScreenGrabber) +//#endif + +data=ZPRIVATE\10003a3f\import\APPS\ScreenGrabber_reg.RSC Private\10003a3f\import\Apps\ScreenGrabber_reg.rsc +data=ZPRIVATE\101FB751\backup_registration.xml private\101FB751\backup_registration.xml +data=ZSYSTEM\Install\ScreenGrabber_stub.sis \system\install\ScreenGrabber_stub.sis + +#endif // __SCREENGRABBER_IBY__ diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/screengrabber/screengrabber.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/screengrabber/screengrabber.pro Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,82 @@ +# +# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# +# + + +TEMPLATE = app +TARGET = ScreenGrabber +DEPENDPATH += src +INCLUDEPATH += inc +INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE +load(hb.prf) +symbian:CONFIG -= symbian_i18n + +HEADERS += inc/mainview.h \ + inc/settingsview.h \ + inc/application.h \ + inc/notifications.h + +SOURCES += main.cpp \ + mainview.cpp \ + application.cpp \ + settingsview.cpp \ + notifications.cpp + +symbian: { + BLD_INF_RULES.prj_exports += "./rom/screengrabber.iby CORE_IBY_EXPORT_PATH(tools,screengrabber.iby) + BLD_INF_RULES.prj_exports += "./rom/backup_registration.xml Z:/private/101FB751/backup_registration.xml" + + screengrabber_buildstubsis_extension = \ + "$${LITERAL_HASH}ifdef MARM" \ + " START EXTENSION app-services/buildstubsis" \ + " OPTION SRCDIR sis" \ + " OPTION SISNAME screengrabber_stub" \ + " END" \ + "$${LITERAL_HASH}endif" + + BLD_INF_RULES.prj_extensions += screengrabber_buildstubsis_extension + + LIBS += -lestor -lws32 -lPlatformEnv -limageconversion -lapgrfx -lcommonengine -lfbscli -lgdi -leikcore -lbafl -lefsrv -lapparc -lcone + + HEADERS += inc/sgengine.h \ + inc/enginewrapper.h \ + inc/gifanimator.h + + SOURCES += sgengine.cpp \ + enginewrapper.cpp \ + gifanimator.cpp + + RSS_RULES += "group_name = \"RnD Tools\""; + + TARGET.CAPABILITY = WriteDeviceData SwEvent + + TARGET.UID2 = 0x100039CE + TARGET.UID3 = 0x101FB751 + TARGET.SID = 0x101FB751 + TARGET.VID = 0x101FB657 // Nokia + + + TARGET.EPOCHEAPSIZE = 0x20000 0x1000000 // Min 128Kb, Max 16Mb + + ICON = ./icons/ScreenGrabber_application_icon_final_svgt.svg + + MMP_RULES -= PAGED + MMP_RULES *= UNPAGEDDATA + MMP_RULES += SMPSAFE + +} else { + error("Only Symbian supported!") +} diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/screengrabber/sis/ScreenGrabber_stub.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/screengrabber/sis/ScreenGrabber_stub.pkg Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,34 @@ +; +; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; + +; Language - standard language definitions +&EN + +; Standard SIS file header +#{"ScreenGrabber"},(0x101FB751),1,0,0 + +; Non-localised vendor name +:"Nokia Corporation" + +; Localised vendor names +%{"Nokia Corporation"} + +; normal stuff: +""-"z:\sys\bin\ScreenGrabber.exe" +""-"z:\Resource\Apps\ScreenGrabber.mif" +""-"z:\Resource\Apps\ScreenGrabber.rsc" +""-"z:\private\10003a3f\import\apps\ScreenGrabber_reg.rsc" +""-"z:\private\101FB751\backup_registration.xml" diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/screengrabber/src/application.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/screengrabber/src/application.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#include +#include "application.h" +#include "enginewrapper.h" + +#define KEY_CAPTURE_PRIORITY 100 + +SGApplication::SGApplication(int argc, char *argv[]) + : HbApplication(argc, argv) + { + + + } + + +SGApplication::~SGApplication() +{ + +} + +// --------------------------------------------------------------------------- + +#if defined(Q_WS_S60) +#if defined(HB_QT_S60_EVENT_FILTER) +bool SGApplication::s60EventFilter(TWsEvent *aEvent) +#else +bool SGApplication::symbianEventFilter(const QSymbianEvent *aEvent) +#endif // (HB_QT_S60_EVENT_FILTER) +{ + // pass event to engine, if engine returns true(event was not handled), + // forward it. + if(!iEngine->handleCaptureCommands(aEvent)) + { + return false; + } + else + { +#if defined(HB_QT_S60_EVENT_FILTER) + return HbApplication::s60EventFilter(aEvent); +#else + return HbApplication::symbianEventFilter(aEvent); +#endif + } + + } +#endif + +// --------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/screengrabber/src/enginewrapper.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/screengrabber/src/enginewrapper.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,250 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#include +#include +#include +#include "enginewrapper.h" + +#include "settingsview.h" +#include "sgengine.h" +#include "mainview.h" +#include "notifications.h" + + +// --------------------------------------------------------------------------- + +EngineWrapper::EngineWrapper() +: iSGEngine(0), iProgressNote(0) +{ +} + +// --------------------------------------------------------------------------- + +EngineWrapper::~EngineWrapper() +{ + if (iSGEngine) { + iSGEngine->DeActivateModelL(); + delete iSGEngine; + } + if(iProgressNote){ + delete iProgressNote; + } +} + +// --------------------------------------------------------------------------- + +bool EngineWrapper::init() +{ + TRAPD(error, iSGEngine = SGEngine::NewL(this)); + + + if (error == KErrNone) { + TRAP(error, iSGEngine->ActivateModelL()); + } + + if (error != KErrNone) { + return false; + } + else { + return true; + } + +} + +// --------------------------------------------------------------------------- + +GrabSettings EngineWrapper::getGrabSettings() +{ + TGrabSettings tSettings = iSGEngine->GrabSettings(); + GrabSettings settings; + + // Convert TGrabSettings to GrabSettings + settings.mCaptureMode = tSettings.iCaptureMode; + + // Single image settings + settings.mSingleCaptureHotkey = tSettings.iSingleCaptureHotkey; + settings.mSingleCaptureImageFormat = tSettings.iSingleCaptureImageFormat; + settings.mSingleCaptureMemoryInUseMultiDrive = tSettings.iSingleCaptureMemoryInUseMultiDrive; + settings.mSingleCaptureFileName = QString((QChar*)tSettings.iSingleCaptureFileName.Ptr(),tSettings.iSingleCaptureFileName.Length()); + + //Seguantial image settings + settings.mSequantialCaptureDelay = tSettings.iSequantialCaptureDelay; + settings.mSequantialCaptureHotkey = tSettings.iSequantialCaptureHotkey; + settings.mSequantialCaptureImageFormat = tSettings.iSequantialCaptureImageFormat; + settings.mSequantialCaptureMemoryInUseMultiDrive = tSettings.iSequantialCaptureMemoryInUseMultiDrive; + settings.mSequantialCaptureDelay = tSettings.iSequantialCaptureDelay; + //convert TFilename to QString + settings.mSequantialCaptureFileName = QString((QChar*)tSettings.iSequantialCaptureFileName.Ptr(),tSettings.iSequantialCaptureFileName.Length()); + + + // Video settings + settings.mVideoCaptureHotkey = tSettings.iVideoCaptureHotkey; + settings.mVideoCaptureVideoFormat = tSettings.iVideoCaptureVideoFormat; + settings.mVideoCaptureMemoryInUseMultiDrive = tSettings.iVideoCaptureMemoryInUseMultiDrive; + //convert TFilename to QString + settings.mVideoCaptureFileName = QString((QChar*)tSettings.iVideoCaptureFileName.Ptr(),tSettings.iVideoCaptureFileName.Length()); + + return settings; +} + +// --------------------------------------------------------------------------- + +bool EngineWrapper::saveSettings(const GrabSettings& settings) +{ + TGrabSettings tSettings; + // Convert GrabSettings to TGrabSettings + tSettings.iCaptureMode = settings.mCaptureMode; + + tSettings.iSingleCaptureHotkey = settings.mSingleCaptureHotkey; + tSettings.iSingleCaptureImageFormat = settings.mSingleCaptureImageFormat; + tSettings.iSingleCaptureMemoryInUseMultiDrive = settings.mSingleCaptureMemoryInUseMultiDrive; + //convert TFilename to QString + tSettings.iSingleCaptureFileName = TFileName(settings.mSingleCaptureFileName.utf16()); + tSettings.iSequantialCaptureDelay = settings.mSequantialCaptureDelay; + tSettings.iSequantialCaptureHotkey = settings.mSequantialCaptureHotkey; + tSettings.iSequantialCaptureImageFormat = settings.mSequantialCaptureImageFormat; + tSettings.iSequantialCaptureMemoryInUseMultiDrive = settings.mSequantialCaptureMemoryInUseMultiDrive; + tSettings.iSequantialCaptureDelay = settings.mSequantialCaptureDelay; + //convert TFilename to QString + tSettings.iSequantialCaptureFileName = TFileName(settings.mSequantialCaptureFileName.utf16()); + + tSettings.iVideoCaptureHotkey = settings.mVideoCaptureHotkey; + tSettings.iVideoCaptureVideoFormat = settings.mVideoCaptureVideoFormat; + tSettings.iVideoCaptureMemoryInUseMultiDrive = settings.mVideoCaptureMemoryInUseMultiDrive; + //convert TFilename to QString + tSettings.iVideoCaptureFileName = TFileName(settings.mVideoCaptureFileName.utf16()); + TRAPD(error, iSGEngine->SaveSettingsL(tSettings)); + + if (error == KErrNone) { + TRAP(error, iSGEngine->ActivateCaptureKeysL(true)); + } + + if (error == KErrNone) { + return true; + } + else { + return false; + } + + +} + +// --------------------------------------------------------------------------- + + +void EngineWrapper::ShowImageCapturedNote() +{ + Notifications::imageCaptured(); +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::ShowErrorMessage(const TDesC16& aErrorMessage) +{ + QString errorMessage((QChar*)aErrorMessage.Ptr(),aErrorMessage.Length()); + Notifications::error(errorMessage); + +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::sendUIToBackground() +{ + CCoeEnv* coeEnv = CCoeEnv::Static(); + TApaTask selfTask(coeEnv->WsSession()); + selfTask.SetWgId(coeEnv->RootWin().Identifier()); + selfTask.SendToBackground(); +} + +// --------------------------------------------------------------------------- + + +#if defined(HB_QT_S60_EVENT_FILTER) +bool EngineWrapper::handleCaptureCommands(const TWsEvent* aEvent) +#else +bool EngineWrapper::handleCaptureCommands(const QSymbianEvent *aEvent) +#endif +{ + TBool retVal = ETrue; + TRAPD(errorCode, retVal = iSGEngine->HandleCaptureCommandsL(aEvent)); + if (errorCode != KErrNone) { + Notifications::error("Error occured when capturing screen."); + } + + return convertTBoolToBool(retVal); + +} + +// --------------------------------------------------------------------------- + +bool EngineWrapper::convertTBoolToBool(TBool value) +{ + if (value) { + return true; + } + else { + return false; + } +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::ShowSequantialImagesCapturedNote(TInt amount) +{ + Notifications::sequantialImagesCaptured(amount); +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::ShowVideoCapturedNote() +{ + Notifications::videoCaptured(); +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::ShowProgressBar(int max) +{ + iProgressNote = Notifications::showProgressBar(max); +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::IncrementProgressbarValue() +{ + iProgressNote->setProgressValue(iProgressNote->progressValue() + 1); +} + +// --------------------------------------------------------------------------- + +void EngineWrapper::CloseProgressbar() +{ + delete iProgressNote; + iProgressNote = 0; +} + +void EngineWrapper::EnableRcpOfFoc(TBool aState) +{ + iSGEngine->EnableRcpOfFoc(aState); +} + +void EngineWrapper::LoadSettings(void) +{ + iSGEngine->LoadSettingsL(); +} + +// --------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/screengrabber/src/gifanimator.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/screengrabber/src/gifanimator.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,308 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +#include "gifanimator.h" + +#include +#include +#include +#include +#include "enginewrapper.h" + + +// --------------------------------------------------------------------------- + +TInt CGifAnimator::CreateGifAnimation(const TDesC& aFileName, TSize aDimensions, CVideoFrameArray* aVideoFrameArray, EngineWrapper& aEngineWrapper) + { + CGifAnimator* self = new(ELeave) CGifAnimator; + CleanupStack::PushL(self); + TRAPD(err, self->StartL(aFileName, aDimensions, aVideoFrameArray, aEngineWrapper)); + CleanupStack::PopAndDestroy(); + return err; + } + +// --------------------------------------------------------------------------- + +CGifAnimator::CGifAnimator() + { + } + +// --------------------------------------------------------------------------- + +void CGifAnimator::StartL(const TDesC& aFileName, const TSize& aDimensions, CVideoFrameArray* aVideoFrameArray, EngineWrapper& aEngineWrapper) + { + + __ASSERT_ALWAYS(aFileName.Length() > 0, User::Panic(_L("GifAnim"), 100)); + __ASSERT_ALWAYS(aDimensions.iHeight > 0, User::Panic(_L("GifAnim"), 101)); + __ASSERT_ALWAYS(aDimensions.iWidth > 0, User::Panic(_L("GifAnim"), 102)); + __ASSERT_ALWAYS(aVideoFrameArray != NULL, User::Panic(_L("GifAnim"), 103)); + + + // show a progress dialog + aEngineWrapper.ShowProgressBar(aVideoFrameArray->Count()-1); + + // open the file for writing + User::LeaveIfError(iFs.Connect()); + User::LeaveIfError(iOutFile.Replace(iFs, aFileName, EFileWrite)); + + // write header + WriteHeaderL(aDimensions); + + // process each frame of the animation + for (TInt i=0; iCount(); i++) + { + // write headers and raster block + TVideoFrame frame = aVideoFrameArray->At(i); + WriteGraphicControlL(frame); + CFbsBitmap* bitmap = GetBitmapLC(frame, aDimensions); + WriteImageDescriptorL(frame); + WriteRasterDataL(bitmap); + CleanupStack::PopAndDestroy(); //bitmap + + // update the progress bar + aEngineWrapper.IncrementProgressbarValue(); + } + + // write footer and finish + WriteFooterL(); + FinishL(); + + // remove the progress dialog from the screen + aEngineWrapper.CloseProgressbar(); + } + +// --------------------------------------------------------------------------- + +CGifAnimator::~CGifAnimator() + { + + if (iImageEncoder) + delete iImageEncoder; + + if (iGIFImageData) + delete iGIFImageData; + + } + +// --------------------------------------------------------------------------- + +void CGifAnimator::WriteHeaderL(const TSize& aDimensions) + { + WriteInt8L('G'); + WriteInt8L('I'); + WriteInt8L('F'); + WriteInt8L('8'); + WriteInt8L('9'); + WriteInt8L('a'); + + WriteInt16L(aDimensions.iWidth); // width of animation + WriteInt16L(aDimensions.iHeight); // height of animation + + // logical screen descriptor + TUint8 packedFlags = 0; + packedFlags |= 8 - 1; // size of colour table is number of bits in each color table minus one (bits 0-2) + packedFlags |= (8 - 1) << 4; // colour resolution ie maximum size of the original colour palette (bits 4-6) + packedFlags |= 0x80; // use global colour table (bit 7) + + WriteInt8L(packedFlags); + + WriteInt8L(TRANSPARENCY_INDEX); // background color index + + WriteInt8L(0); // pixel aspect ratio, 0=not used + + // write the Symbian default palette since that's what is used + CPalette* palette = CPalette::NewDefaultL(EColor256); + CleanupStack::PushL(palette); + + for (TInt i=0; iEntries(); i++) + { + TRgb entry = palette->GetEntry(i); + + WriteInt8L(entry.Red()); + WriteInt8L(entry.Green()); + WriteInt8L(entry.Blue()); + } + + CleanupStack::PopAndDestroy(); //palette + } + +// --------------------------------------------------------------------------- + +void CGifAnimator::WriteGraphicControlL(const TVideoFrame& aFrame) + { + TInt packedFlags(0); + + // enable transparency if needed + if (aFrame.iEnableTransparency) + packedFlags |= 0x01; + + // set disposal method: + // 0 = disposal method not specified, 1 = do not dispose of graphic, + // 2 = overwrite graphic with background color, 3 = overwrite graphic with previous graphic + TInt disposalMethod = 1; + packedFlags |= ((disposalMethod << 2) & 0x1c); + + WriteInt8L(0x21); // GIF extension + WriteInt8L(0xf9); // GIF graphic control block + WriteInt8L(0x04); // block size + WriteInt8L(packedFlags); // packed + WriteInt16L(aFrame.iDelay); // delay + WriteInt8L(TRANSPARENCY_INDEX); // transparent color index + WriteInt8L(0); // block terminator, always 0 + } + +// --------------------------------------------------------------------------- + +void CGifAnimator::WriteImageDescriptorL(const TVideoFrame& aFrame) + { + WriteInt8L(0x2c); // GIF image descriptor + WriteInt16L(aFrame.iXPos); + WriteInt16L(aFrame.iYPos); + WriteInt16L(aFrame.iWidth); + WriteInt16L(aFrame.iHeight); + WriteInt8L(0); // packed flags, none specified in this case + } + +// --------------------------------------------------------------------------- + +CFbsBitmap* CGifAnimator::GetBitmapLC(TVideoFrame& aFrame, const TSize& aDimensions) + { + CFbsBitmap* bitmap = new(ELeave) CFbsBitmap; + CleanupStack::PushL(bitmap); + + // read the bitmap from the temporary file + RFile bitmapFile; + User::LeaveIfError( bitmapFile.Open(iFs, aFrame.iFileStorePath, EFileRead) ); + RFileReadStream readStream(bitmapFile); + bitmap->InternalizeL(readStream); + readStream.Close(); + bitmapFile.Close(); + + // delete the temporary file since it's not needed anymore + iFs.Delete(aFrame.iFileStorePath); + + // resize the bitmap to match the video dimensions if it is a full screen one + if (aFrame.iFillsWholeScreen && (aFrame.iWidth != aDimensions.iWidth || aFrame.iHeight != aDimensions.iHeight)) + { + if (bitmap->Resize(aDimensions) == KErrNone) + { + // also update dimensions of this frame to match the dimensions of the video + aFrame.iWidth = aDimensions.iWidth; + aFrame.iHeight = aDimensions.iHeight; + } + } + + return bitmap; + } + +// --------------------------------------------------------------------------- + +void CGifAnimator::WriteRasterDataL(CFbsBitmap* aBitmap) + { + // reset the encoder + if (iImageEncoder) + { + delete iImageEncoder; + iImageEncoder = NULL; + } + + // make sure the buffer for conversion is empty + if (iGIFImageData) + { + delete iGIFImageData; + iGIFImageData = NULL; + } + + + TRequestStatus Stat = KRequestPending; + + // init & convert the bitmap to GIF format + iImageEncoder = CImageEncoder::DataNewL(iGIFImageData, CImageEncoder::EOptionAlwaysThread, KImageTypeGIFUid); + iImageEncoder->Convert( &Stat, *aBitmap ); + User::WaitForRequest(Stat); + + + // check any erros in converting + User::LeaveIfError( Stat.Int() ); + + // check if we have valid data + if (iGIFImageData == NULL || iGIFImageData->Des().Length()<793) + User::Leave(KErrNoMemory); + + // in GIF files generated by Symbian, the raster data always starts at offset 791, + // initial code size in GIF encoding should be 8 since we have a 8bpp image, + // also check that the second last byte is the terminator 0, + // if this check fails in newer releases of S60, proper parsing of GIF format is probably needed + TUint8* imagePtr = &iGIFImageData->Des()[0]; + if (imagePtr[791] != 8 || imagePtr[iGIFImageData->Des().Length()-2] != 0) + User::Leave(KErrNotSupported); + + // write the raster data block to the file + TUint writeLength = iGIFImageData->Des().Length() - 1 - 791; + imagePtr+=791; + TPtr8 writePtr(imagePtr, writeLength, writeLength); + User::LeaveIfError( iOutFile.Write(writePtr) ); + } + +// --------------------------------------------------------------------------- + +void CGifAnimator::WriteFooterL() + { + WriteInt8L(0x3b); // GIF trailer + } + +// --------------------------------------------------------------------------- + +void CGifAnimator::FinishL() + { + iOutFile.Close(); + iFs.Close(); + } + +// --------------------------------------------------------------------------- + +void CGifAnimator::WriteInt8L(TInt aValue) + { + HBufC8* buf = HBufC8::NewMaxLC(1); + + TUint8* ptr = &buf->Des()[0]; + ptr[0] = TUint8(aValue); + + User::LeaveIfError( iOutFile.Write(buf->Des()) ); + + CleanupStack::PopAndDestroy(); // buf + } + +// --------------------------------------------------------------------------- + +void CGifAnimator::WriteInt16L(TInt aValue) + { + HBufC8* buf = HBufC8::NewMaxLC(2); + + TUint8* ptr = &buf->Des()[0]; + ptr[0] = TUint8(aValue); + ptr[1] = TUint8(aValue>>8); + + User::LeaveIfError( iOutFile.Write(buf->Des()) ); + + CleanupStack::PopAndDestroy(); // buf + } + +// --------------------------------------------------------------------------- + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/screengrabber/src/main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/screengrabber/src/main.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,68 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include + +#include +#include +#include +#include + +#include "mainview.h" +#include "application.h" +#include "enginewrapper.h" +#include "settingsview.h" + + + +int main(int argc, char *argv[]) +{ + + SGApplication app(argc, argv); + + EngineWrapper engineWrapper; + app.SetEngineWrapper(&engineWrapper); + if (!engineWrapper.init()) { + return EXIT_FAILURE; + } + + + + HbMainWindow mainWindow; + + //Create main view + MainView* view = new MainView(mainWindow, engineWrapper); + //initialize main view + view->init(app); + + + SettingsView* settingsView = new SettingsView(*view, mainWindow, engineWrapper); + + view->setSettingsView(settingsView); + + // Add Views to main window and reveal it. + mainWindow.addView(view); + mainWindow.addView(settingsView); + + + mainWindow.show(); + + int result = app.exec(); + + return result; +} + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/screengrabber/src/mainview.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/screengrabber/src/mainview.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,173 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "enginewrapper.h" +#include "settingsview.h" +#include "mainview.h" +#include "notifications.h" +#include "hbtoolbar.h" + +// --------------------------------------------------------------------------- + +MainView::MainView(HbMainWindow &mainWindow, EngineWrapper &engineWrapper): + mMainWindow(mainWindow), + mSettingsView(0), + mEngineWrapper(engineWrapper) +{ +} + +// --------------------------------------------------------------------------- + +MainView::~MainView() +{ +} + +// --------------------------------------------------------------------------- + +void MainView::init(HbApplication &app) +{ + this->setTitle("Screen Grabber"); + createMenu(app); + createInfoText(); + createToolbar(); + +} + +void MainView::createMenu(HbApplication& app) +{ + + HbMenu* menu = this->menu(); + + if (menu != NULL) { + + actionSendToBg = menu->addAction("Send to background"); + connect(actionSendToBg, SIGNAL( triggered() ), this, SLOT( sendToBackground() ) ); + + actionSettings = menu->addAction("Settings"); + connect(actionSettings, SIGNAL( triggered() ), this, SLOT( showSettings() ) ); + + actionAbout = menu->addAction("About"); + connect(actionAbout, SIGNAL( triggered() ), this, SLOT( showAboutPopup() ) ); + + actionExit = menu->addAction("Exit"); + connect(actionExit, SIGNAL(triggered()), this, SLOT( my_quit() ) ); + + HbAction *mDefaultNavigationAction = new HbAction(Hb::QuitNaviAction, this); + connect(mDefaultNavigationAction,SIGNAL(triggered()), this, SLOT(my_quit())); + setNavigationAction(mDefaultNavigationAction); + + //setNavigationAction(actionExit); + } +} + + +void MainView::quitYesNoQuestionClosed(HbAction* action) + { + if( action && !action->text().compare("yes", Qt::CaseInsensitive) ) + { + qApp->quit(); + } + } + +void MainView::my_quit() + { + HbMessageBox::question("Do you really want to exit the Screen Grabber application?", + this, //receiver + SLOT(quitYesNoQuestionClosed(HbAction *)), //member + HbMessageBox::Yes | HbMessageBox::No, + new HbLabel("Exit Screen grabber confirm", this) + ); + } + +// --------------------------------------------------------------------------- + +void MainView::createInfoText() +{ + QGraphicsLinearLayout* layout = new QGraphicsLinearLayout(Qt::Vertical, this); + if (layout != NULL) { + HbTextEdit* edit = new HbTextEdit(this); + if(edit != NULL) { + edit->setPlainText("Please use the settings screen to define the " + "capture mode and any other related settings " + "such as capture hotkey and saving format. " + "Using the PNG format for screen shots is " + "recommended, since it is compressed but " + "lossless. The captures can be managed with " + "the Media Gallery application.\n\nYou may " + "start taking screenshots or capturing video " + "now. Please press the Applications key to go back " + "to the Application menu or send this application " + "to the background via the Options menu. To be " + "able to take screenshots or capture video, this " + "application needs to stay running in the " + "background."); + edit->setReadOnly(true); + //TODO edit->setCursorHidden(true); + //TODO edit->setAttribute(Qt::WA_InputMethodEnabled, false); + layout->addItem(edit); + layout->setContentsMargins(5, 5, 5, 5); + this->setLayout(layout); + } + + } + +} + +// --------------------------------------------------------------------------- + +void MainView::showSettings() +{ + mEngineWrapper.EnableRcpOfFoc(ETrue); + mEngineWrapper.LoadSettings(); + mSettingsView->loadSettings(); + mMainWindow.setCurrentView(mSettingsView); +} + +// --------------------------------------------------------------------------- + +void MainView::createToolbar() +{ + HbToolBar *toolbar = new HbToolBar(this); // main view takes the ownership + toolbar->addAction(actionSettings); + toolbar->addAction(actionSendToBg); + setToolBar(toolbar); +} + +// --------------------------------------------------------------------------- + +void MainView::showAboutPopup() +{ + Notifications::about(); +} + +// --------------------------------------------------------------------------- + +void MainView::sendToBackground() + { + mEngineWrapper.sendUIToBackground(); + } + + diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/screengrabber/src/notifications.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/screengrabber/src/notifications.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,85 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include +#include +#include + +#include "notifications.h" + + + +// --------------------------------------------------------------------------- + +void Notifications::imageCaptured() +{ + HbDeviceMessageBox::information("Screen shot saved to Media Gallery"); +} + +// --------------------------------------------------------------------------- + +void Notifications::about() +{ + HbMessageBox *messageBox = new HbMessageBox(HbMessageBox::MessageTypeInformation); + messageBox->setText("Version 5.0.0 - March 10th 2010. Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. Licensed under Eclipse Public License v1.0."); + HbLabel *header = new HbLabel("About Screen Grabber", messageBox); + messageBox->setHeadingWidget(header); + messageBox->setAttribute(Qt::WA_DeleteOnClose); + messageBox->setTimeout(HbPopup::NoTimeout); + messageBox->open(); +} + +// --------------------------------------------------------------------------- + +void Notifications::error(const QString& errorMessage) +{ + HbDeviceMessageBox::warning(errorMessage); + +} + +// --------------------------------------------------------------------------- + +void Notifications::sequantialImagesCaptured(int amount){ + // Code below launches a global note + QString text; + text.setNum(amount, 10); + text.append(" screen shots saved to Media Gallery"); + + HbDeviceMessageBox::information(text); + +} + +// --------------------------------------------------------------------------- + +void Notifications::videoCaptured() +{ + HbDeviceMessageBox::information("Video saved to Media Gallery"); + +} + +// --------------------------------------------------------------------------- + +HbDeviceProgressDialog* Notifications::showProgressBar(int max) +{ + HbDeviceProgressDialog *note = new HbDeviceProgressDialog(HbProgressDialog::ProgressDialog); + note->setText("Saving..."); + note->setMaximum(max); + note->show(); + return note; +} + +// --------------------------------------------------------------------------- diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/screengrabber/src/settingsview.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/screengrabber/src/settingsview.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,275 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#include "settingsview.h" +#include "enginewrapper.h" +#include "sgengine.h" +#include "hbslider.h" +#include "notifications.h" + + + +// --------------------------------------------------------------------------- + +SettingsView::SettingsView(HbView &mainView, HbMainWindow &mainWindow, EngineWrapper &engineWrapper): + mEngineWrapper(engineWrapper), + mMainWindow(mainWindow), + mMainView(mainView) +{ + // Set title and add this view to main window + setTitle("Settings"); + + HbAction *actionSaveSettings = menu()->addAction(QString("Save & close")); + HbAction *actionCancel = menu()->addAction("Cancel & close"); + + toolBar()->addAction(actionSaveSettings); + toolBar()->addAction(actionCancel); + + + //create setting form + mSettingForm = new HbDataForm(); + + //create a model class + mModel = new HbDataFormModel(this); + + // DataFormItem for mode selection + mModeItem = mModel->appendDataFormItem( + HbDataFormModelItem::RadioButtonListItem, QString("Capture mode"), 0); + mModeItem->setContentWidgetData(QString("items"), CAPTUREMODES); + + // Create setting model + createSingleCaptureComponents(mModel, 0); + createSequentialCaptureComponents(mModel, 0); + createVideoCaptureComponents(mModel, 0); + + // Set created model model to form + mSettingForm->setModel(mModel); + setWidget(mSettingForm);//takes ownership + + loadSettings(); + + // Connect signals from item modifications and close with this form's slots + connect(actionSaveSettings, SIGNAL(triggered()), this, SLOT(saveAndClose())); + connect(actionCancel, SIGNAL(triggered()), this, SLOT(close())); + + HbAction *mDefaultNavigationAction = new HbAction(Hb::QuitNaviAction, this); + connect(mDefaultNavigationAction,SIGNAL(triggered()), this, SLOT(saveAndClose())); + setNavigationAction(mDefaultNavigationAction); + + + +} + + +// --------------------------------------------------------------------------- + +SettingsView::~SettingsView() +{ + +} + +// --------------------------------------------------------------------------- + +void SettingsView::loadSettings() +{ + + // get settings from engine; + mSettings = mEngineWrapper.getGrabSettings(); + + //Capture mode + mModeItem->setContentWidgetData("selected", mSettings.mCaptureMode); + + // Still image + mImageHotKeyItem->setContentWidgetData("selected", mSettings.mSingleCaptureHotkey); + mImageFormatItem->setContentWidgetData("selected", mSettings.mSingleCaptureImageFormat); + mImageMemoryInUseItem->setContentWidgetData("selected", mSettings.mSingleCaptureMemoryInUseMultiDrive); + mImageFileNameItem->setContentWidgetData("text", mSettings.mSingleCaptureFileName); + + // Seguantial image components + mSequantialHotKeyItem->setContentWidgetData("selected", mSettings.mSequantialCaptureHotkey); + mSequantialFormatItem->setContentWidgetData("selected", mSettings.mSequantialCaptureImageFormat); + mSequantialDelayItem->setContentWidgetData("text", mSettings.mSequantialCaptureDelay); + mSequantialMemoryInUseItem->setContentWidgetData("selected", mSettings.mSequantialCaptureMemoryInUseMultiDrive); + mSequantialFileNameItem->setContentWidgetData("text", mSettings.mSequantialCaptureFileName); + + // Video capture components + mVideoHotKeyItem->setContentWidgetData("selected", mSettings.mVideoCaptureHotkey); + mVideoFormatItem->setContentWidgetData("selected", mSettings.mVideoCaptureVideoFormat); + mVideoMemoryInUseItem->setContentWidgetData("selected", mSettings.mVideoCaptureMemoryInUseMultiDrive); + mVideoFileNameItem->setContentWidgetData("text", mSettings.mVideoCaptureFileName); + + +} + +// --------------------------------------------------------------------------- + +void SettingsView::createSingleCaptureComponents(HbDataFormModel *model, HbDataFormModelItem *parent) +{ + + // Create Group for single image components + mGroupImageCapture = model->appendDataFormGroup(QString("Single image settings"), parent); + + // DataFormItem for hotkey selection + mImageHotKeyItem = model->appendDataFormItem( + HbDataFormModelItem::RadioButtonListItem, QString("Capture hotkey"), mGroupImageCapture); + mImageHotKeyItem->setContentWidgetData(QString("items"), KEYS); + + // DataFormItem for image format selection + mImageFormatItem = model->appendDataFormItem( + HbDataFormModelItem::RadioButtonListItem, QString("Image format"), mGroupImageCapture); + mImageFormatItem->setContentWidgetData(QString("items"), IMAGEFORMATS); + + // DataFormItem for memory in use selection + mImageMemoryInUseItem = model->appendDataFormItem( + HbDataFormModelItem::RadioButtonListItem, QString("Memory in use"), mGroupImageCapture); + mImageMemoryInUseItem->setContentWidgetData(QString("items"), MEMORYMODES); + + // DataFormItem for file name + mImageFileNameItem = model->appendDataFormItem( + HbDataFormModelItem::TextItem, QString("File name"), mGroupImageCapture); + mImageFileNameItem->setContentWidgetData(QString("text"), QString("Shot")); + +} + +// --------------------------------------------------------------------------- + +void SettingsView::createSequentialCaptureComponents(HbDataFormModel *model, HbDataFormModelItem *parent) +{ + + + // Create Group for sequential image components + mGroupSeguantialCapture = model->appendDataFormGroup(QString("Sequential image settings"), parent); + + // DataFormItem for hotkey selection + mSequantialHotKeyItem = model->appendDataFormItem( + HbDataFormModelItem::RadioButtonListItem, QString("Capture hotkey"), mGroupSeguantialCapture); + mSequantialHotKeyItem->setContentWidgetData(QString("items"), KEYS); + + // DataFormItem for image format selection + mSequantialFormatItem = model->appendDataFormItem( + HbDataFormModelItem::RadioButtonListItem, QString("Image format"), mGroupSeguantialCapture); + mSequantialFormatItem->setContentWidgetData(QString("items"), IMAGEFORMATS); + + // DataFormItem for delay between images selection + mSequantialDelayItem = model->appendDataFormItem( + HbDataFormModelItem::TextItem, QString("Delay between two images(ms)"), mGroupSeguantialCapture); + mSequantialDelayItem->setContentWidgetData(QString("text"), QString("Shot")); + + // DataFormItem for memory selection + mSequantialMemoryInUseItem = model->appendDataFormItem( + HbDataFormModelItem::RadioButtonListItem, QString("Memory in use"), mGroupSeguantialCapture); + mSequantialMemoryInUseItem->setContentWidgetData(QString("items"), MEMORYMODES); + + // DataFormItem for file name + mSequantialFileNameItem = model->appendDataFormItem( + HbDataFormModelItem::TextItem, QString("File name"), mGroupSeguantialCapture); + mSequantialFileNameItem->setContentWidgetData(QString("text"), QString("Shot")); + +} + +// --------------------------------------------------------------------------- + +void SettingsView::createVideoCaptureComponents(HbDataFormModel *model, HbDataFormModelItem *parent) +{ + + // Create Group for video capturing components + mGroupVideoCapture = model->appendDataFormGroup(QString("Video settings"), parent); + + // DataFormItem for hotkey selection + mVideoHotKeyItem = model->appendDataFormItem( + HbDataFormModelItem::RadioButtonListItem, QString("Start/Stop hotkey"), mGroupVideoCapture); + mVideoHotKeyItem->setContentWidgetData(QString("items"), KEYS); + + // DataFormItem for video format selection + mVideoFormatItem = model->appendDataFormItem( + HbDataFormModelItem::RadioButtonListItem, QString("Video format"), mGroupVideoCapture); + mVideoFormatItem->setContentWidgetData(QString("items"), VIDEOFORMATS); + + // DataFormItem for memory selection + mVideoMemoryInUseItem = model->appendDataFormItem( + HbDataFormModelItem::RadioButtonListItem, QString("Memory in use"), mGroupVideoCapture); + mVideoMemoryInUseItem->setContentWidgetData(QString("items"), MEMORYMODES); + + // DataFormItem for file name + mVideoFileNameItem = model->appendDataFormItem( + HbDataFormModelItem::TextItem, QString("File name"), mGroupVideoCapture); + mVideoFileNameItem->setContentWidgetData(QString("text"), QString("Video")); + +} + +// --------------------------------------------------------------------------- + +void SettingsView::saveAndClose() +{ + + readFormItems(); + if (!mEngineWrapper.saveSettings(mSettings)) { + Notifications::error("Unable to save settings"); + } + + mEngineWrapper.EnableRcpOfFoc(EFalse); + mMainWindow.setCurrentView(&mMainView); + +} + +// --------------------------------------------------------------------------- + +void SettingsView::readFormItems() +{ + + //TODO this does not work correctly with WK38 ( Text box items ) + + mSettings.mCaptureMode = mModeItem->contentWidgetData("selected").toInt(); + + mSettings.mSingleCaptureImageFormat = mImageFormatItem->contentWidgetData("selected").toInt(); + mSettings.mSingleCaptureHotkey = mImageHotKeyItem->contentWidgetData("selected").toInt(); + mSettings.mSingleCaptureMemoryInUseMultiDrive = mImageMemoryInUseItem->contentWidgetData("selected").toInt(); + mSettings.mSingleCaptureFileName = mImageFileNameItem->contentWidgetData("text").toString(); + + mSettings.mSequantialCaptureImageFormat = mSequantialFormatItem->contentWidgetData("selected").toInt(); + mSettings.mSequantialCaptureHotkey = mSequantialHotKeyItem ->contentWidgetData("selected").toInt(); + mSettings.mSequantialCaptureMemoryInUseMultiDrive = mSequantialMemoryInUseItem ->contentWidgetData("selected").toInt(); + mSettings.mSequantialCaptureFileName = mSequantialFileNameItem->contentWidgetData("text").toString(); + mSettings.mSequantialCaptureDelay = mSequantialDelayItem->contentWidgetData("text").toInt(); + + + mSettings.mVideoCaptureVideoFormat = mVideoFormatItem->contentWidgetData("selected").toInt(); + mSettings.mVideoCaptureHotkey = mVideoHotKeyItem ->contentWidgetData("selected").toInt(); + mSettings.mVideoCaptureMemoryInUseMultiDrive = mVideoMemoryInUseItem ->contentWidgetData("selected").toInt(); + mSettings.mVideoCaptureFileName = mVideoFileNameItem ->contentWidgetData("text").toString(); + + +} + +// --------------------------------------------------------------------------- + +void SettingsView::close() +{ + mEngineWrapper.EnableRcpOfFoc(EFalse); + mMainWindow.setCurrentView(&mMainView); +} diff -r 819e59dfc032 -r 2d9cac8919d3 utilityapps/screengrabber/src/sgengine.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utilityapps/screengrabber/src/sgengine.cpp Mon Oct 18 16:30:05 2010 +0300 @@ -0,0 +1,1485 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "mainview.h" +#include "sgengine.h" +#include "enginewrapper.h" +#include "gifanimator.h" + + +#define SC_PRINTS + + #ifdef SC_PRINTS + #define SC_DEBUG(a) RDebug::Print(a) + #define SC_DEBUG2(a,b) RDebug::Print(a,b) + #else + #define SC_DEBUG(a) + #define SC_DEBUG2(a,b) + #endif + + + + +_LIT(KDefaultImageFileName, "Shot"); +_LIT(KDefaultVideoFileName, "Video"); + +#define HIGH_QUALITY_JPEG 97 +#define LOW_QUALITY_JPEG 60 +#define DEFAULT_SEQ_CAPTURE_DELAY_MS 5000 // 5.000 secs +#define VIDEO_CAPTURE_DELAY 250 // 0.25 secs +#define VIDEO_CAPTURE_MINIMUM_DELAY 200 // 0.20 secs +const TInt KSettingsDrive = EDriveC; +_LIT(KSettingsFileName, "screengrabber_settings.ini"); +_LIT(KScreenShotsSubDirectory, "Screen Shots\\"); +_LIT(KSGTemporaryDirectory, "\\system\\temp\\screengrabber\\"); + + +#define KEY_CAPTURE_PRIORITY 100 // do not change, this is for window server + +// --------------------------------------------------------------------------- + +SGEngine::SGEngine() : CActive(EPriorityStandard) + { + // No implementation required + } + +// --------------------------------------------------------------------------- + +SGEngine::~SGEngine() + { + + TRAP_IGNORE( CleanTemporaryFilesL() ); + + + if (iFrameImageData) + delete iFrameImageData; + + if (iPreviouslyCapturedBitmap) + delete iPreviouslyCapturedBitmap; + + if (iImageEncoder) + delete iImageEncoder; + + delete iVideoFrameArray; + + Cancel(); + iTimer.Close(); + + iFileSession.Close(); + + } + +// --------------------------------------------------------------------------- + +SGEngine* SGEngine::NewLC(EngineWrapper *aEngineWrapper) + { + SGEngine* self = new (ELeave) SGEngine(); + CleanupStack::PushL(self); + self->ConstructL(aEngineWrapper); + return self; + } + +// --------------------------------------------------------------------------- + +SGEngine* SGEngine::NewL(EngineWrapper *aEngineWrapper) + { + SGEngine* self = SGEngine::NewLC(aEngineWrapper); + CleanupStack::Pop(); // self; + return self; + } + +// --------------------------------------------------------------------------- + +void SGEngine::ConstructL(EngineWrapper *aEngineWrapper) + { + + iEngineWrapper = aEngineWrapper; + + iHashKeyCapturingActivated = EFalse; // Check this + + User::LeaveIfError(iTimer.CreateLocal()); + + iVideoFrameArray = new(ELeave) CVideoFrameArray(10000); + + iPreviouslyCapturedBitmap = new(ELeave) CFbsBitmap; + + iCapturingInProgress = EFalse; + iStopCapturing = EFalse; + iNumberOfTakenShots = 0; + iCurrentFrameNumber = 0; + iHashKeyDown = EFalse; + + + CActiveScheduler::Add(this); + User::LeaveIfError(iFileSession.Connect()); + + // create window group. + iRootWin = CEikonEnv::Static()->RootWin(); + iRootWin.EnableReceiptOfFocus(EFalse); + + } + +// --------------------------------------------------------------------------- + +void SGEngine::RunL(){ + + + SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- RunL begin")); + + switch (iState) + { + // encoding of the image is now finished + case EEncodingImage: + { + if (iGrabSettings.iCaptureMode == ECaptureModeSingleCapture) + { + // single shot done + CapturingFinishedL( iStatus.Int() ); + } + + else if (iGrabSettings.iCaptureMode == ECaptureModeSequantialCapture) + { + // increase the counter + iNumberOfTakenShots++; + + // check if we can take more shots or just finish + if (!iStopCapturing && iStatus.Int()==KErrNone) + { + + // some delay before the next shot can be taken + iState = ESequenceDelay; + + // some checking that the value of delay is valid + TInt delay(iGrabSettings.iSequantialCaptureDelay); //ms + if (delay<0 || delay > 999999) + delay = DEFAULT_SEQ_CAPTURE_DELAY_MS; + + iTimer.After(iStatus, delay*1000); + SetActive(); + } + else + { + // finished + CapturingFinishedL( iStatus.Int() ); + } + } + else + User::Panic(_L("Wrong mode"), 32); + + break; + } + + // delay finished, ready to take the next shot + case ESequenceDelay: + { + TakeScreenShotAndSaveL(); + + break; + } + + // asked to cancel capturing + case ECancelCapturing: + { + // finished + CapturingFinishedL( iStatus.Int() ); + + break; + } + + case ENextVideoFrame: + { + // increase the counter + iCurrentFrameNumber++; + + // check if we can take more frames or just finish + if (!iStopCapturing && iStatus.Int()==KErrNone) + { + // take next frame + CaptureFrameForVideoL(); + } + else + { + // finished, save video + SaveVideoL( iStatus.Int() ); + } + } + break; + + case ECancelVideoCapturing: + { + // finished, save video + SaveVideoL( iStatus.Int() ); + } + break; + + default: + { + break; + } + } + SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- RunL end")); + + +} + + +void SGEngine::EnableRcpOfFoc(TBool aState) + { + iRootWin.EnableReceiptOfFocus(aState); + } + + +// --------------------------------------------------------------------------- + +void SGEngine::DoCancel(){ + iTimer.Cancel(); +} + +// --------------------------------------------------------------------------- + +void SGEngine::LoadDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, TInt& aValue) + { + if (aDicFS->IsPresentL(aUid)) + { + RDictionaryReadStream in; + in.OpenLC(*aDicFS, aUid); + aValue = in.ReadInt16L(); + CleanupStack::PopAndDestroy(); // in + } + } + +// --------------------------------------------------------------------------- + +void SGEngine::LoadDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, TDes& aValue) + { + if (aDicFS->IsPresentL(aUid)) + { + RDictionaryReadStream in; + in.OpenLC(*aDicFS, aUid); + TInt bufLength = in.ReadInt16L(); // get length of descriptor + in.ReadL(aValue, bufLength); // get the descriptor itself + CleanupStack::PopAndDestroy(); // in + } + } +// ---------------------------------------------------------------------------- + +void SGEngine::LoadSettingsL() + { + + // set defaults + iGrabSettings.iCaptureMode = ECaptureModeSingleCapture; + + iGrabSettings.iSingleCaptureHotkey = EHotkeySendKey; + iGrabSettings.iSingleCaptureImageFormat = EImageFormatPNG; + iGrabSettings.iSingleCaptureMemoryInUseMultiDrive = EPhoneMemory; + iGrabSettings.iSingleCaptureFileName.Copy( KDefaultImageFileName ); + + iGrabSettings.iSequantialCaptureHotkey = EHotkeySendKey; + iGrabSettings.iSequantialCaptureImageFormat = EImageFormatPNG; + iGrabSettings.iSequantialCaptureDelay = DEFAULT_SEQ_CAPTURE_DELAY_MS; + iGrabSettings.iSequantialCaptureMemoryInUseMultiDrive = EPhoneMemory; + iGrabSettings.iSequantialCaptureFileName.Copy( KDefaultImageFileName ); + + iGrabSettings.iVideoCaptureHotkey = EHotkeySendKey; + iGrabSettings.iVideoCaptureVideoFormat = EVideoFormatAnimatedGIF; + iGrabSettings.iVideoCaptureMemoryInUseMultiDrive = EPhoneMemory; + iGrabSettings.iVideoCaptureFileName.Copy( KDefaultVideoFileName ); + + + // make sure that the private path of this app in c-drive exists + + iFileSession.CreatePrivatePath( KSettingsDrive ); // c:\\private\\101fb751\\ + + // handle settings always in the private directory + + if (iFileSession.SetSessionToPrivate( KSettingsDrive ) == KErrNone) + { + // open or create a dictionary file store + CDictionaryFileStore* settingsStore = CDictionaryFileStore::OpenLC(iFileSession, KSettingsFileName, KUidScreenGrabber); + + LoadDFSValueL(settingsStore, KSGSettingCaptureMode, iGrabSettings.iCaptureMode); + + LoadDFSValueL(settingsStore, KSGSettingSingleCaptureHotkey, iGrabSettings.iSingleCaptureHotkey); + LoadDFSValueL(settingsStore, KSGSettingSingleCaptureImageFormat, iGrabSettings.iSingleCaptureImageFormat); + LoadDFSValueL(settingsStore, KSGSettingSingleCaptureMemoryInUseMultiDrive, iGrabSettings.iSingleCaptureMemoryInUseMultiDrive); + LoadDFSValueL(settingsStore, KSGSettingSingleCaptureFileName, iGrabSettings.iSingleCaptureFileName); + + LoadDFSValueL(settingsStore, KSGSettingSequantialCaptureHotkey, iGrabSettings.iSequantialCaptureHotkey); + LoadDFSValueL(settingsStore, KSGSettingSequantialCaptureImageFormat, iGrabSettings.iSequantialCaptureImageFormat); + LoadDFSValueL(settingsStore, KSGSettingSequantialCaptureDelay, iGrabSettings.iSequantialCaptureDelay); + LoadDFSValueL(settingsStore, KSGSettingSequantialCaptureMemoryInUseMultiDrive, iGrabSettings.iSequantialCaptureMemoryInUseMultiDrive); + LoadDFSValueL(settingsStore, KSGSettingSequantialCaptureFileName, iGrabSettings.iSequantialCaptureFileName); + + LoadDFSValueL(settingsStore, KSGSettingVideoCaptureHotkey, iGrabSettings.iVideoCaptureHotkey); + LoadDFSValueL(settingsStore, KSGSettingVideoCaptureVideoFormat, iGrabSettings.iVideoCaptureVideoFormat); + LoadDFSValueL(settingsStore, KSGSettingVideoCaptureMemoryInUseMultiDrive, iGrabSettings.iVideoCaptureMemoryInUseMultiDrive); + LoadDFSValueL(settingsStore, KSGSettingVideoCaptureFileName, iGrabSettings.iVideoCaptureFileName); + + CleanupStack::PopAndDestroy(); // settingsStore + } +//chesk if all settings are in range - for safety reason, not to set some controls out of range - it causes the crash + if (!(iGrabSettings.iCaptureMode >= ECaptureModeSingleCapture && iGrabSettings.iCaptureMode <= ECaptureModeVideoCapture)) + { //give it default value + iGrabSettings.iCaptureMode = ECaptureModeSingleCapture; + } + if (!(iGrabSettings.iSingleCaptureHotkey >= EHotkeySendKey && iGrabSettings.iSingleCaptureHotkey <= EHotkeyCameraKey1)) + { + iGrabSettings.iSingleCaptureHotkey = EHotkeySendKey; + } + if (!(iGrabSettings.iSingleCaptureImageFormat >= EImageFormatPNG && iGrabSettings.iSingleCaptureImageFormat <= EImageFormatGIF)) + { + iGrabSettings.iSingleCaptureImageFormat = EImageFormatPNG; + } + if (!(iGrabSettings.iSingleCaptureMemoryInUseMultiDrive >= EPhoneMemory && iGrabSettings.iSingleCaptureMemoryInUseMultiDrive <= EMemoryCard)) + { + iGrabSettings.iSingleCaptureMemoryInUseMultiDrive = EPhoneMemory; + } + + if (!(iGrabSettings.iSequantialCaptureHotkey >= EHotkeySendKey && iGrabSettings.iSequantialCaptureHotkey <= EHotkeyCameraKey1)) + { + iGrabSettings.iSequantialCaptureHotkey = EHotkeySendKey; + } + if (!(iGrabSettings.iSequantialCaptureImageFormat >= EImageFormatPNG && iGrabSettings.iSequantialCaptureImageFormat <= EImageFormatGIF)) + { + iGrabSettings.iSequantialCaptureImageFormat = EImageFormatPNG; + } + if (!(iGrabSettings.iSequantialCaptureMemoryInUseMultiDrive >= EPhoneMemory && iGrabSettings.iSequantialCaptureMemoryInUseMultiDrive <= EMemoryCard)) + { + iGrabSettings.iSequantialCaptureMemoryInUseMultiDrive = EPhoneMemory; + } + + if (!(iGrabSettings.iVideoCaptureHotkey >= EHotkeySendKey && iGrabSettings.iVideoCaptureHotkey <= EHotkeyCameraKey1)) + { + iGrabSettings.iVideoCaptureHotkey = EHotkeySendKey; + } + if (iGrabSettings.iVideoCaptureVideoFormat != EVideoFormatAnimatedGIF) + { + iGrabSettings.iVideoCaptureVideoFormat = EVideoFormatAnimatedGIF; + } + if (!(iGrabSettings.iVideoCaptureMemoryInUseMultiDrive >= EPhoneMemory && iGrabSettings.iVideoCaptureMemoryInUseMultiDrive <= EMemoryCard)) + { + iGrabSettings.iVideoCaptureMemoryInUseMultiDrive = EPhoneMemory; + } + + } + +// --------------------------------------------------------------------------- + +void SGEngine::SaveDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, const TInt& aValue) + { + RDictionaryWriteStream out; + out.AssignLC(*aDicFS, aUid); + out.WriteInt16L(aValue); + out.CommitL(); + CleanupStack::PopAndDestroy(1);// out + } + +// --------------------------------------------------------------------------- + +void SGEngine::SaveDFSValueL(CDictionaryFileStore* aDicFS, const TUid& aUid, const TDes& aValue) + { + RDictionaryWriteStream out; + out.AssignLC(*aDicFS, aUid); + out.WriteInt16L(aValue.Length()); // write length of the descriptor + out.WriteL(aValue, aValue.Length()); // write the descriptor itself + out.CommitL(); + CleanupStack::PopAndDestroy(1);// out + } + +// --------------------------------------------------------------------------- +void SGEngine::SaveSettingsL(const TGrabSettings& aGrabSettings) + { + + + // set the new settings + iGrabSettings = aGrabSettings; + + // handle settings always in c:\\private\\101fb751\\ + if (iFileSession.SetSessionToPrivate( KSettingsDrive ) == KErrNone) + { + // delete existing store to make sure that it is clean and not eg corrupted + if (BaflUtils::FileExists(iFileSession, KSettingsFileName)) + { + iFileSession.Delete(KSettingsFileName); + } + + // create a dictionary file store + CDictionaryFileStore* settingsStore = CDictionaryFileStore::OpenLC(iFileSession, KSettingsFileName, KUidScreenGrabber); + + SaveDFSValueL(settingsStore, KSGSettingCaptureMode, iGrabSettings.iCaptureMode); + + SaveDFSValueL(settingsStore, KSGSettingSingleCaptureHotkey, iGrabSettings.iSingleCaptureHotkey); + SaveDFSValueL(settingsStore, KSGSettingSingleCaptureImageFormat, iGrabSettings.iSingleCaptureImageFormat); + SaveDFSValueL(settingsStore, KSGSettingSingleCaptureMemoryInUseMultiDrive, iGrabSettings.iSingleCaptureMemoryInUseMultiDrive); + SaveDFSValueL(settingsStore, KSGSettingSingleCaptureFileName, iGrabSettings.iSingleCaptureFileName); + + SaveDFSValueL(settingsStore, KSGSettingSequantialCaptureHotkey, iGrabSettings.iSequantialCaptureHotkey); + SaveDFSValueL(settingsStore, KSGSettingSequantialCaptureImageFormat, iGrabSettings.iSequantialCaptureImageFormat); + SaveDFSValueL(settingsStore, KSGSettingSequantialCaptureDelay, iGrabSettings.iSequantialCaptureDelay); + SaveDFSValueL(settingsStore, KSGSettingSequantialCaptureMemoryInUseMultiDrive, iGrabSettings.iSequantialCaptureMemoryInUseMultiDrive); + SaveDFSValueL(settingsStore, KSGSettingSequantialCaptureFileName, iGrabSettings.iSequantialCaptureFileName); + + SaveDFSValueL(settingsStore, KSGSettingVideoCaptureHotkey, iGrabSettings.iVideoCaptureHotkey); + SaveDFSValueL(settingsStore, KSGSettingVideoCaptureVideoFormat, iGrabSettings.iVideoCaptureVideoFormat); + SaveDFSValueL(settingsStore, KSGSettingVideoCaptureMemoryInUseMultiDrive, iGrabSettings.iVideoCaptureMemoryInUseMultiDrive); + SaveDFSValueL(settingsStore, KSGSettingVideoCaptureFileName, iGrabSettings.iVideoCaptureFileName); + + settingsStore->CommitL(); + CleanupStack::PopAndDestroy(); // settingsStore + } + + } + +// --------------------------------------------------------------------------- + +void SGEngine::ActivateCaptureKeysL(TBool aChangeKey) + { + + // if changing the capture key, capturing needs to be cancelled first + if (aChangeKey) + { + CancelCapturing(); + } + + // get hotkey of the capture + TInt captureHotkey(0); + if (iGrabSettings.iCaptureMode == ECaptureModeSingleCapture) + captureHotkey = iGrabSettings.iSingleCaptureHotkey; + else if (iGrabSettings.iCaptureMode == ECaptureModeSequantialCapture) + captureHotkey = iGrabSettings.iSequantialCaptureHotkey; + else if (iGrabSettings.iCaptureMode == ECaptureModeVideoCapture) + captureHotkey = iGrabSettings.iVideoCaptureHotkey; + else + User::Panic(_L("Wrong mode"), 40); + + + + // start capturing based on user selected key + switch (captureHotkey) + { + case EHotkeySendKey: + { + iCapturedKey = iRootWin.CaptureKey(EStdKeyYes, EModifierCtrl|EModifierShift|EModifierFunc, 0, KEY_CAPTURE_PRIORITY); + iCapturedKeyUnD = iRootWin.CaptureKeyUpAndDowns(EStdKeyYes, EModifierCtrl|EModifierShift|EModifierFunc, 0, KEY_CAPTURE_PRIORITY); + break; + } + case EHotkeyPowerKey: + { + iCapturedKey = iRootWin.CaptureKey(EStdKeyDevice2, EModifierCtrl|EModifierShift|EModifierFunc, 0, KEY_CAPTURE_PRIORITY); + iCapturedKeyUnD = iRootWin.CaptureKeyUpAndDowns(EStdKeyDevice2, EModifierCtrl|EModifierShift|EModifierFunc, 0, KEY_CAPTURE_PRIORITY); + break; + } + case EHotkeySideKey: + { + iCapturedKey = iRootWin.CaptureKey(EStdKeyDevice6, EModifierCtrl|EModifierShift|EModifierFunc, 0, KEY_CAPTURE_PRIORITY); + iCapturedKeyUnD = iRootWin.CaptureKeyUpAndDowns(EStdKeyDevice6, EModifierCtrl|EModifierShift|EModifierFunc, 0, KEY_CAPTURE_PRIORITY); + break; + } + case EHotkeyCameraKey1: + { + iCapturedKey = iRootWin.CaptureKey(EStdKeyDevice7, EModifierCtrl|EModifierShift|EModifierFunc, 0, KEY_CAPTURE_PRIORITY); + iCapturedKeyUnD = iRootWin.CaptureKeyUpAndDowns(EStdKeyDevice7, EModifierCtrl|EModifierShift|EModifierFunc, 0, KEY_CAPTURE_PRIORITY); + break; + } + default: + { + User::Panic(_L("Key not supported"), 100); + break; + } + } + + } + +// --------------------------------------------------------------------------- + + +void SGEngine::CancelCapturing() + { + + SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- CancelCapturing start")); + // cancel all captures + iRootWin.CancelCaptureKey(iCapturedKey); + iRootWin.CancelCaptureKeyUpAndDowns(iCapturedKeyUnD); + + if (iHashKeyCapturingActivated) + { + iRootWin.CancelCaptureKey(iCapturedKeyHash); + iRootWin.CancelCaptureKeyUpAndDowns(iCapturedKeyHashUnD); + + iHashKeyCapturingActivated = EFalse; + } + + SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- CancelCapturing end")); + + } + +// --------------------------------------------------------------------------- + +bool SGEngine::TakeScreenShotAndSaveL() + { + + SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- TakeSsAndSave start")); + if ( IsActive() ) + { + SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- TakeSsAndSave already active, ignored")); + return false; + } + + // take a screen shot + CWsScreenDevice* screenDevice = new( ELeave ) CWsScreenDevice(CEikonEnv::Static()->WsSession() ); + CleanupStack::PushL( screenDevice ); + + User::LeaveIfError( screenDevice->Construct( CEikonEnv::Static()->WsSession().GetFocusScreen() ) ); + + + User::LeaveIfError( iPreviouslyCapturedBitmap->Create(screenDevice->SizeInPixels(), screenDevice->DisplayMode()) ); + User::LeaveIfError( screenDevice->CopyScreenToBitmap(iPreviouslyCapturedBitmap) ); + CleanupStack::PopAndDestroy(); // screenDevice + + + // get memory in use & image format of the screen capture + TDriveNumber memoryInUse(EDriveC); + TInt intMemInUse(0); + TInt imageFormat(0); + TFileName fileName; + + if (iGrabSettings.iCaptureMode == ECaptureModeSingleCapture) + { +// memoryInUse = iGrabSettings.iSingleCaptureMemoryInUseMultiDrive; + intMemInUse = iGrabSettings.iSingleCaptureMemoryInUseMultiDrive; + + imageFormat = iGrabSettings.iSingleCaptureImageFormat; + fileName = iGrabSettings.iSingleCaptureFileName; + } + else if (iGrabSettings.iCaptureMode == ECaptureModeSequantialCapture) + { +// memoryInUse = iGrabSettings.iSequantialCaptureMemoryInUseMultiDrive; + intMemInUse = iGrabSettings.iSequantialCaptureMemoryInUseMultiDrive; + + imageFormat = iGrabSettings.iSequantialCaptureImageFormat; + fileName = iGrabSettings.iSequantialCaptureFileName; + } + else + User::Panic(_L("Wrong mode"), 30); + + + // init the path for saving the file + + iSaveFileName.Copy( PathInfo::PhoneMemoryRootPath() ); + +// if (memoryInUse != EDriveC)//something different as PhoneMemory (memory card or mass memory) + if (intMemInUse != 0)//something different as PhoneMemory (memory card or mass memory) + { + memoryInUse = EDriveY; + if (PathInfo::GetRootPath(iSaveFileName, memoryInUse) != KErrNone || !DriveOK(memoryInUse)) + { + //we need to find first available memory card in EDriveE - EDriveY range + for (TInt i = EDriveY; i>=EDriveE; i--) + { + if ( DriveOK((TDriveNumber)(i))) + { + if (IsDriveMMC((TDriveNumber)(i))) + { + PathInfo::GetRootPath(iSaveFileName, (TDriveNumber)(i)); + break; + } + } + } + } + } + + iSaveFileName.Append( PathInfo::ImagesPath() ); + iSaveFileName.Append( KScreenShotsSubDirectory ); + + + // a quick check that filename is valid + if (fileName.Length() > 0 && fileName.Length() <= 255) + iSaveFileName.Append( fileName ); + else + iSaveFileName.Append( KDefaultImageFileName ); + + iSaveFileName.Append( _L(".") ); + + + // reset the encoder + if (iImageEncoder) + { + delete iImageEncoder; + iImageEncoder = NULL; + } + + + switch (imageFormat) + { + case EImageFormatPNG: + { + // set filename + iSaveFileName.Append(_L("png")); + CApaApplication::GenerateFileName(iFileSession, iSaveFileName ); // unique filename + + // init & convert + iImageEncoder = CImageEncoder::FileNewL(iFileSession, iSaveFileName, CImageEncoder::EOptionAlwaysThread, KImageTypePNGUid); + + iImageEncoder->Convert( &iStatus, *iPreviouslyCapturedBitmap ); + } + break; + + case EImageFormatJPGHQ: + case EImageFormatJPGLQ: + { + // reset frameimagedata + if (iFrameImageData) + { + delete iFrameImageData; + iFrameImageData = NULL; + } + + // set filename + iSaveFileName.Append(_L("jpg")); + CApaApplication::GenerateFileName(iFileSession, iSaveFileName ); // unique filename + + // init + iImageEncoder = CImageEncoder::FileNewL(iFileSession, iSaveFileName, CImageEncoder::EOptionAlwaysThread, KImageTypeJPGUid); + + // JPEG properties + TJpegImageData* imageData = new(ELeave) TJpegImageData; + imageData->iSampleScheme = TJpegImageData::EColor444; + imageData->iQualityFactor = (imageFormat==EImageFormatJPGHQ) ? HIGH_QUALITY_JPEG : LOW_QUALITY_JPEG; + iFrameImageData = CFrameImageData::NewL(); + User::LeaveIfError(iFrameImageData->AppendImageData(imageData)); //ownership of imageData is transferred + + // convert + iImageEncoder->Convert( &iStatus, *iPreviouslyCapturedBitmap, iFrameImageData ); + } + break; + + case EImageFormatBMP: + { + // set filename + iSaveFileName.Append(_L("bmp")); + CApaApplication::GenerateFileName(iFileSession, iSaveFileName ); // unique filename + + // init & convert + iImageEncoder = CImageEncoder::FileNewL(iFileSession, iSaveFileName, CImageEncoder::EOptionAlwaysThread, KImageTypeBMPUid); + iImageEncoder->Convert( &iStatus, *iPreviouslyCapturedBitmap ); + } + break; + + case EImageFormatGIF: + { + // set filename + iSaveFileName.Append(_L("gif")); + CApaApplication::GenerateFileName(iFileSession, iSaveFileName ); // unique filename + + // init & convert + iImageEncoder = CImageEncoder::FileNewL(iFileSession, iSaveFileName, CImageEncoder::EOptionAlwaysThread, KImageTypeGIFUid); + iImageEncoder->Convert( &iStatus, *iPreviouslyCapturedBitmap ); + } + break; + + case EImageFormatMBM: + { + // set filename + iSaveFileName.Append(_L("mbm")); + CApaApplication::GenerateFileName(iFileSession, iSaveFileName ); // unique filename + + // init & convert + iImageEncoder = CImageEncoder::FileNewL(iFileSession, iSaveFileName, CImageEncoder::EOptionAlwaysThread, KImageTypeMBMUid); + iImageEncoder->Convert( &iStatus, *iPreviouslyCapturedBitmap ); + } + break; + + default: + { + User::Panic(_L("Invalid Img Type"), 20); + } + } + + // set the state of the active object + iState = EEncodingImage; + + // indicate an outstanding request + SetActive(); + SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- TakeSsAndSave end")); + return true; + } + +// --------------------------------------------------------------------------- + + +TBool SGEngine::DriveOK(TDriveNumber aNumber) + { + + SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- Driveok start")); + TBool isOK(EFalse); + + TVolumeInfo vInfo; + + // check if we can access the drive + if (iFileSession.Volume(vInfo, aNumber) == KErrNone) + isOK = ETrue; + + // returns ETrue if memory card working properly + SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- DriveOK end")); + return isOK; + + } +// --------------------------------------------------------------------------- + + +TBool SGEngine::IsDriveMMC(TDriveNumber aDrive) + { + SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- IsDriveMMC start")); + TBool isOK(EFalse); + + TDriveInfo ii; + if (iFileSession.Drive(ii, aDrive)==KErrNone) + { + if (ii.iType!=EMediaNotPresent && + ii.iType!=EMediaUnknown && + ii.iType!=EMediaCdRom && + ii.iType!=EMediaRom) + { // memory card + isOK=ETrue; + } + } + + + SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- IsDriveMMC end")); + return isOK; + } + + +void SGEngine::CapturingFinishedL(TInt aErr) + { + + SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- CapturingFinished start")); + // display a global query to show the results + + if (aErr == KErrNone) + { + switch (iGrabSettings.iCaptureMode) + { + case ECaptureModeSingleCapture: + { + iEngineWrapper->ShowImageCapturedNote(); + } + break; + + case ECaptureModeSequantialCapture: + { + iEngineWrapper->ShowSequantialImagesCapturedNote(iNumberOfTakenShots); + } + break; + + case ECaptureModeVideoCapture: + { + iEngineWrapper->ShowVideoCapturedNote(); + } + break; + + default: + User::Panic(_L("Inv.capt.mode"), 51); + break; + } + + } + else + { + + // Get error message with CTextResolver + CTextResolver* textResolver = CTextResolver::NewLC(); + iEngineWrapper->ShowErrorMessage(textResolver->ResolveErrorString(aErr)); + + CleanupStack::PopAndDestroy(); //textResolver + + } + + // capturing can now be restarted + iState = EIdle; + iCapturingInProgress = EFalse; + iStopCapturing = EFalse; + + // reset values + iNumberOfTakenShots = 0; + iCurrentFrameNumber = 0; + iVideoFrameArray->Reset(); + + + iState = EQueryDelay; + iTimer.After(iStatus, 2000000); + SetActive(); + + SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- capturingfinished end")); + + } + + +#if defined(HB_QT_S60_EVENT_FILTER) + TBool SGEngine::HandleCaptureCommandsL(const TWsEvent* aEvent) + { +#else + TBool SGEngine::HandleCaptureCommandsL(const QSymbianEvent *event) + { + if (event->type() != QSymbianEvent::WindowServerEvent) { + return ETrue; //continueEventLoop + } + const TWsEvent *aEvent = event->windowServerEvent(); +#endif + + SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- HandleCaptureCommand start")); + + + TBool continueEventLoop(ETrue); + + // get hotkey of the capture + TInt captureHotkey(0); + if (iGrabSettings.iCaptureMode == ECaptureModeSingleCapture) + captureHotkey = iGrabSettings.iSingleCaptureHotkey; + else if (iGrabSettings.iCaptureMode == ECaptureModeSequantialCapture) + captureHotkey = iGrabSettings.iSequantialCaptureHotkey; + else if (iGrabSettings.iCaptureMode == ECaptureModeVideoCapture) + captureHotkey = iGrabSettings.iVideoCaptureHotkey; + else + User::Panic(_L("Wrong mode"), 41); + + // ignore any errors + if (aEvent->Type()==EEventErrorMessage) + { + // error + } + + + // handle captured keys, we are interested here only of the keydown events + else + + if ( + ( captureHotkey == EHotkeySendKey && + aEvent->Type()==EEventKeyDown && aEvent->Key()->iScanCode==EStdKeyYes ) + || + ( captureHotkey == EHotkeyPowerKey && + aEvent->Type()==EEventKeyDown && aEvent->Key()->iScanCode==EStdKeyDevice2 ) + || + ( captureHotkey == EHotkeySideKey && + aEvent->Type()==EEventKeyDown && aEvent->Key()->iScanCode==EStdKeyDevice6 ) + || + ( captureHotkey == EHotkeyCameraKey1 && + aEvent->Type()==EEventKeyDown && aEvent->Key()->iScanCode==EStdKeyDevice7 ) + ) + { + + // check if already capturing images in sequence + if ( iCapturingInProgress && !iStopCapturing && iNumberOfTakenShots!=0 && iGrabSettings.iCaptureMode == ECaptureModeSequantialCapture ) + { + // asking to stop capturing + iStopCapturing = ETrue; + + // cancel the active object, this will cancel any timer delays and ICL stuff + Cancel(); + + // set status + iState = ECancelCapturing; + + // jump smoothly to RunL() + iTimer.After(iStatus, 50); + SetActive(); + + // do not continue the event loop in HandleWsEventL for these events + continueEventLoop = EFalse; + } + + // check if already capturing video + else if ( iCapturingInProgress && !iStopCapturing && iGrabSettings.iCaptureMode == ECaptureModeVideoCapture ) + { + // asking to stop capturing + iStopCapturing = ETrue; + + // cancel the active object, this will cancel any timer delays and ICL stuff + Cancel(); + + // set status + iState = ECancelVideoCapturing; + + // jump smoothly to RunL() + iTimer.After(iStatus, 50); + SetActive(); + + // do not continue the event loop in HandleWsEventL for these events + continueEventLoop = EFalse; + } + else if (!iCapturingInProgress && (iGrabSettings.iCaptureMode == ECaptureModeSingleCapture || iGrabSettings.iCaptureMode == ECaptureModeSequantialCapture )) + { + + // take a screen shot and save it + if( TakeScreenShotAndSaveL()) + { + // not capturing anything, so start doing that + iCapturingInProgress = ETrue; + // do not continue the event loop in HandleWsEventL for these events + continueEventLoop = EFalse; + } + } + + else if (!iCapturingInProgress && iGrabSettings.iCaptureMode == ECaptureModeVideoCapture ) + { + // not capturing anything, so start doing that + iCapturingInProgress = ETrue; + + // clean temporary files + TRAP_IGNORE( CleanTemporaryFilesL() ); + + // get initial dimensions for the video + CWsScreenDevice* screenDevice = new(ELeave) CWsScreenDevice ( CEikonEnv::Static()->WsSession() ); + CleanupStack::PushL(screenDevice); + + User::LeaveIfError( screenDevice->Construct( CEikonEnv::Static()->WsSession().GetFocusScreen() ) ); + + iVideoDimensions = screenDevice->SizeInPixels(); + iPreviousFrameScreenDimension = screenDevice->SizeInPixels(); + CleanupStack::PopAndDestroy(); // screenDevice + + // capture the first frame + CaptureFrameForVideoL(); + + // do not continue the event loop in HandleWsEventL for these events + continueEventLoop = EFalse; + } + + } + + // catch other event types as well so that we can ignore them + else if ( + ( captureHotkey == EHotkeySendKey && + aEvent->Key()->iScanCode==EStdKeyYes ) + || + ( captureHotkey == EHotkeyPowerKey && + aEvent->Key()->iScanCode==EStdKeyDevice2 ) + || + ( captureHotkey == EHotkeySideKey && + aEvent->Key()->iScanCode==EStdKeyDevice6 ) + || + ( captureHotkey == EHotkeyCameraKey1 && + aEvent->Key()->iScanCode==EStdKeyDevice7 ) + ) + { + // do not continue the event loop in HandleWsEventL for these events + continueEventLoop = EFalse; + } + + SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- HandleCapturcommand end")); + + + return continueEventLoop; + + } + +// --------------------------------------------------------------------------- + +void SGEngine::CleanTemporaryFilesL() + { + + SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- CleanTempFiles start")); + + // delete temporary files from C and D drives + CFileMan* fileMan = CFileMan::NewL(iFileSession); + + TFileName delFilesPath; + + for (TInt i=0; i<1; i++) + { + delFilesPath.Copy(KNullDesC); + delFilesPath.Append('C'+i); + delFilesPath.Append(_L(":")); + delFilesPath.Append(KSGTemporaryDirectory); + delFilesPath.Append(_L("*.$$$")); + + fileMan->Delete(delFilesPath); + } + + delete fileMan; + SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- CleanTempfile end")); + + } + +// --------------------------------------------------------------------------- + +void SGEngine::ActivateModelL() + { + // clean temporary files + TRAP_IGNORE( CleanTemporaryFilesL() ); + + // load settings + TRAP_IGNORE( LoadSettingsL() ); + + // start capturing + ActivateCaptureKeysL(); + } + +// --------------------------------------------------------------------------- + +void SGEngine::DeActivateModelL() + { + + CancelCapturing(); + + // for a faster exit, send the application to background + TApaTask selfTask(CEikonEnv::Static()->WsSession()); + selfTask.SetWgId(iRootWin.Identifier()); + selfTask.SendToBackground(); + + + } + +// --------------------------------------------------------------------------- + + +void SGEngine::CaptureFrameForVideoL() + { + + SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- CaptureFrameforvide start")); + // record time + TTime timeNow; + timeNow.HomeTime(); + + // take a screen shot + CFbsBitmap* currentCapturedBitmap = new(ELeave) CFbsBitmap; + CleanupStack::PushL(currentCapturedBitmap); + + CWsScreenDevice* screenDevice = new(ELeave) CWsScreenDevice( CEikonEnv::Static()->WsSession() ); + CleanupStack::PushL( screenDevice ); + User::LeaveIfError( screenDevice->Construct( CEikonEnv::Static()->WsSession().GetFocusScreen() ) ); + + TSize currentScreenSize = screenDevice->SizeInPixels(); + + User::LeaveIfError( currentCapturedBitmap->Create(currentScreenSize, EColor256) ); + User::LeaveIfError( screenDevice->CopyScreenToBitmap(currentCapturedBitmap) ); + CleanupStack::PopAndDestroy(); // screenDevice + + // grow video's dimensions if the size has changed + if (currentScreenSize.iWidth > iVideoDimensions.iWidth) + { + iVideoDimensions.iWidth = currentScreenSize.iWidth; + } + if (currentScreenSize.iHeight > iVideoDimensions.iHeight) + { + iVideoDimensions.iHeight = currentScreenSize.iHeight; + } + + TInt64 currentDelay(0); + + + // create a new frame + TVideoFrame frame; + frame.iDelay = 500; // use default delay 5.00 secs + + // get info of the RAM drive + TDriveNumber ramDrive = EDriveD; + TVolumeInfo ramDriveInfo; + iFileSession.Volume(ramDriveInfo, ramDrive); + + // init the directory for saving the file, preferably use ram drive if there is enough disk space, otherwise use always C drive + TFileName tempDirectory; + TFileName sessionPath; + + if (ramDriveInfo.iFree > (iVideoDimensions.iWidth*iVideoDimensions.iHeight+50000)) + sessionPath.Copy( _L("D:") ); + else + sessionPath.Copy( _L("C:") ); + + sessionPath.Append(KSGTemporaryDirectory); + tempDirectory.Copy(KSGTemporaryDirectory); + + iFileSession.MkDirAll(sessionPath); + iFileSession.SetSessionPath(sessionPath); + + // create a temp file, path to the bitmap is saved automatically to frame.iFileStorePath + RFile file; + User::LeaveIfError( file.Temp(iFileSession, tempDirectory, frame.iFileStorePath, EFileWrite) ); + RFileWriteStream writeStream(file); + + TBool ignoreFrame(EFalse); + + // check if is this the first frame + if (iCurrentFrameNumber == 0) + { + // first frame is always the full one + frame.iWidth = currentScreenSize.iWidth; + frame.iHeight = currentScreenSize.iHeight; + frame.iXPos = 0; + frame.iYPos = 0; + frame.iEnableTransparency = EFalse; + frame.iFillsWholeScreen = ETrue; + + currentCapturedBitmap->ExternalizeL(writeStream); + + } + + else + { + // next frame is a difference between the previous one + currentDelay = timeNow.MicroSecondsFrom(iPreviousFrameTaken).Int64(); + + // get reference to previos frame + TVideoFrame& prevFrame = iVideoFrameArray->At(iVideoFrameArray->Count()-1); + + + // check if video dimensions have changed + if (currentScreenSize.iWidth != iPreviousFrameScreenDimension.iWidth + || currentScreenSize.iHeight != iPreviousFrameScreenDimension.iHeight) + { + // dimensions have changed -> save a full bitmap + frame.iWidth = currentScreenSize.iWidth; + frame.iHeight = currentScreenSize.iHeight; + frame.iXPos = 0; + frame.iYPos = 0; + frame.iEnableTransparency = EFalse; + frame.iFillsWholeScreen = ETrue; + + currentCapturedBitmap->ExternalizeL(writeStream); + + // update the previous frame to contain the new delay value + prevFrame.iDelay = TUint( (double) currentDelay / 10000 ); + } + + else + { + // compare the bitmaps + TUint bufSize = currentScreenSize.iWidth*3; + HBufC8* curImgScanLineBuf = HBufC8::NewLC(bufSize); + TPtr8 curImgScanLinePtr = curImgScanLineBuf->Des(); + HBufC8* prevImgScanLineBuf = HBufC8::NewLC(bufSize); + TPtr8 prevImgScanLinePtr = prevImgScanLineBuf->Des(); + + TPoint pt(0,0); + TBool differenceFound(EFalse); + TPoint leftTopDifferencePoint(0,0); + TPoint rightBottomDifferencePoint(currentScreenSize.iWidth,currentScreenSize.iHeight); + + // scan the image from top to bottom + for (TInt i=0; iGetScanLine(curImgScanLinePtr, pt, currentScreenSize.iWidth, EColor256); + iPreviouslyCapturedBitmap->GetScanLine(prevImgScanLinePtr, pt, currentScreenSize.iWidth, EColor256); + + if (curImgScanLinePtr != prevImgScanLinePtr) + { + differenceFound = ETrue; + + // get the y-coordinate + leftTopDifferencePoint.iY = i; + + break; + } + } + + if (differenceFound) + { + // now we know that there is some difference between those two captured frames, + // get the bottom value by scaning from bottom to top + for (TInt i=currentScreenSize.iHeight-1; i>=0; i--) + { + pt.iY = i; + + currentCapturedBitmap->GetScanLine(curImgScanLinePtr, pt, currentScreenSize.iWidth, EColor256); + iPreviouslyCapturedBitmap->GetScanLine(prevImgScanLinePtr, pt, currentScreenSize.iWidth, EColor256); + + if (curImgScanLinePtr != prevImgScanLinePtr) + { + // get the y-coordinate + rightBottomDifferencePoint.iY = i+1; + + break; + } + } + + // check that the height of the cropped image will be at least 1 + if (rightBottomDifferencePoint.iY <= leftTopDifferencePoint.iY) + rightBottomDifferencePoint.iY = leftTopDifferencePoint.iY+1; + + + // get also the x-coordinates by scanning vertical scan lines + bufSize = currentScreenSize.iHeight*3; + HBufC8* curImgVerticalScanLineBuf = HBufC8::NewLC(bufSize); + TPtr8 curImgVerticalScanLinePtr = curImgVerticalScanLineBuf->Des(); + HBufC8* prevImgVerticalScanLineBuf = HBufC8::NewLC(bufSize); + TPtr8 prevImgVerticalScanLinePtr = prevImgVerticalScanLineBuf->Des(); + + // first scan by from left to right + for (TInt i=0; iGetVerticalScanLine(curImgVerticalScanLinePtr, i, EColor256); + iPreviouslyCapturedBitmap->GetVerticalScanLine(prevImgVerticalScanLinePtr, i, EColor256); + + if (curImgVerticalScanLinePtr != prevImgVerticalScanLinePtr) + { + leftTopDifferencePoint.iX = i; + break; + } + } + + // finally scan from right to left + for (TInt i=currentScreenSize.iWidth-1; i>=0; i--) + { + currentCapturedBitmap->GetVerticalScanLine(curImgVerticalScanLinePtr, i, EColor256); + iPreviouslyCapturedBitmap->GetVerticalScanLine(prevImgVerticalScanLinePtr, i, EColor256); + + if (curImgVerticalScanLinePtr != prevImgVerticalScanLinePtr) + { + rightBottomDifferencePoint.iX = i+1; + break; + } + } + + CleanupStack::PopAndDestroy(2); //curImgVerticalScanLineBuf,prevImgVerticalScanLineBuf + + + // check that the width of the cropped image will be at least 1 + if (rightBottomDifferencePoint.iX <= leftTopDifferencePoint.iX) + rightBottomDifferencePoint.iX = leftTopDifferencePoint.iX+1; + + + // record dimensions and position of the image + frame.iWidth = rightBottomDifferencePoint.iX - leftTopDifferencePoint.iX; + frame.iHeight = rightBottomDifferencePoint.iY - leftTopDifferencePoint.iY; + frame.iXPos = leftTopDifferencePoint.iX; + frame.iYPos = leftTopDifferencePoint.iY; + frame.iEnableTransparency = ETrue; + frame.iFillsWholeScreen = EFalse; + + + // take a copy of the current frame + CFbsBitmap* workingBitmap = new(ELeave) CFbsBitmap; + CleanupStack::PushL(workingBitmap); + User::LeaveIfError( workingBitmap->Create(currentScreenSize, EColor256) ); + + bufSize = currentScreenSize.iWidth*3; + HBufC8* tempScanLineBuf = HBufC8::NewLC(bufSize); + TPtr8 tempScanLinePtr = tempScanLineBuf->Des(); + + for (TInt i=0; iGetScanLine(tempScanLinePtr, pt, currentScreenSize.iWidth, EColor256); + workingBitmap->SetScanLine(tempScanLinePtr, i); + } + + CleanupStack::PopAndDestroy(); //tempScanLineBuf + + + // mark the non-changed areas with transparency color + TUint8* curPtr = NULL; + TUint8* prevPtr = NULL; + for (TInt i=frame.iYPos; iGetScanLine(curImgScanLinePtr, pt, currentScreenSize.iWidth, EColor256); + iPreviouslyCapturedBitmap->GetScanLine(prevImgScanLinePtr, pt, currentScreenSize.iWidth, EColor256); + + // check single pixels in the scanline + for (TInt j=frame.iXPos; jSetScanLine(curImgScanLinePtr, i); + } + + + // externalize the bitmap + TRect changedRect(leftTopDifferencePoint, rightBottomDifferencePoint); + workingBitmap->ExternalizeRectangleL(writeStream, changedRect); + + CleanupStack::PopAndDestroy(); //workingBitmap + + // update the previous frame to contain the new delay value + prevFrame.iDelay = TUint( (double) currentDelay / 10000 ); + } + + else + { + // frames are identical, we can just ignore this one + ignoreFrame = ETrue; + } + + CleanupStack::PopAndDestroy(2); //curImgScanLineBuf,prevImgScanLineBuf + + } // if (videoDimensionsHaveChanged) + + } //if (iCurrentFrameNumber == 0) + + // close the stream + writeStream.CommitL(); + writeStream.Close(); + file.Close(); + + + if (ignoreFrame) + { + // delete the temp file since we don't need that + iFileSession.Delete(frame.iFileStorePath); + } + else + { + // remember for the next frame when this frame was taken + iPreviousFrameTaken = timeNow; + + // take a copy of currentCapturedBitmap to iPreviouslyCapturedBitmap + User::LeaveIfError( iPreviouslyCapturedBitmap->Create(iVideoDimensions, EColor256) ); + + TPoint pt(0,0); + HBufC8* tempScanLineBuf = HBufC8::NewMaxLC(iVideoDimensions.iWidth); + TPtr8 tempScanLinePtr = tempScanLineBuf->Des(); + + for (TInt i=0; iGetScanLine(tempScanLinePtr, pt, iVideoDimensions.iWidth, EColor256); + iPreviouslyCapturedBitmap->SetScanLine(tempScanLinePtr, i); + } + + CleanupStack::PopAndDestroy(); //tempScanLineBuf + + // append frame information to the array + iVideoFrameArray->AppendL(frame); + + // remember screen size + iPreviousFrameScreenDimension = currentScreenSize; + } + + + CleanupStack::PopAndDestroy(); //currentCapturedBitmap + + + // set the state of the active object + iState = ENextVideoFrame; + + // check time spent on the work above (probably this is not so important) + TTime timeNow2; + timeNow2.HomeTime(); + TInt64 handlingDelay = timeNow2.MicroSecondsFrom(timeNow).Int64(); + + // calculate delay till next frame + TUint idealDelay = VIDEO_CAPTURE_DELAY*1000; + TInt usedDelay; + if (currentDelay > idealDelay) + usedDelay = idealDelay - (currentDelay - idealDelay) - handlingDelay; + else + usedDelay = idealDelay - handlingDelay; + + // check that the delay is atleast minimum delay anyway + if (usedDelay < VIDEO_CAPTURE_MINIMUM_DELAY*1000) + usedDelay = VIDEO_CAPTURE_MINIMUM_DELAY*1000; + + iTimer.After(iStatus, usedDelay); + + // indicate an outstanding request + SetActive(); + + SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- Captureframeforvideo end")); + + } + +// --------------------------------------------------------------------------- + +void SGEngine::SaveVideoL(TInt aErr) + { + + SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- SaveVideo start")); + + if (aErr) + CapturingFinishedL(aErr); + + else if (iGrabSettings.iVideoCaptureVideoFormat == EVideoFormatAnimatedGIF) + { + TInt err(KErrNone); + + + iSaveFileName.Copy( PathInfo::PhoneMemoryRootPath() ); + if (iGrabSettings.iVideoCaptureMemoryInUseMultiDrive != 0)//something different as PhoneMemory (memory card or mass memory) + { + if (PathInfo::GetRootPath(iSaveFileName,EDriveY) != KErrNone || !DriveOK(EDriveY)) + { + //we need to find first available memory card in EDriveE - EDriveY range + for (TInt i = EDriveY; i>=EDriveE; i--) + { + if ( DriveOK((TDriveNumber)(i))) + { + if (IsDriveMMC((TDriveNumber)(i))) + { + PathInfo::GetRootPath(iSaveFileName, (TDriveNumber)(i)); + break; + } + } + } + } + } + + + iSaveFileName.Append( PathInfo::ImagesPath() ); // animated gif is actually an image, not a video + iSaveFileName.Append( KScreenShotsSubDirectory ); + + // a quick check that filename is valid + if (iGrabSettings.iVideoCaptureFileName.Length() > 0 && iGrabSettings.iVideoCaptureFileName.Length() <= 255) + iSaveFileName.Append( iGrabSettings.iVideoCaptureFileName ); + else + iSaveFileName.Append( KDefaultVideoFileName ); + + iSaveFileName.Append( _L(".gif") ); + + CApaApplication::GenerateFileName(iFileSession, iSaveFileName ); // unique filename + + // create and save the gif animation + err = CGifAnimator::CreateGifAnimation(iSaveFileName, iVideoDimensions, iVideoFrameArray, *iEngineWrapper); + + // remove the saved file in case of errors since it's likely corrupted + if (err != KErrNone) + iFileSession.Delete(iSaveFileName); + + CapturingFinishedL(err); + } + + else + CapturingFinishedL(KErrNotSupported); + + SC_DEBUG(_L("SCREENGRABBER ------------------------------------------------------- SaveVideo end")); + } +// --------------------------------------------------------------------------- +