SlideShare a Scribd company logo
Hacking Titanium


     David Bankier
        Director
       YY Digital
     @davidbankier

   david@yydigital.com
Code is (mostly)
evaluated at runtime
TiHighlight


      tabGroup.setActiveTab(1);
  try {
    if(current && current.close !== undefined) {
       current.close();
    }
    current = eval(message.code);
    if(current && current.open !== undefined) {
                 tabGroup.activeTab.open(current);
    }
  } catch (e) {
    if(Ti.Platform.osname === 'android') {
       alert(e.toString());
    } else { //iOS Error
       alert("Line: " + e.line + "n" + e.message);
    }
  }
TiShadow




                     websockets
                     (socket.io)



  tishadow app                     tishadow
   TiSDK (partial)                  server
                                     node.js
                                     express
                                    socket.io
                                       Ace
TiShadow


 try {
   if(current && current.close !== undefined) {
     current.close();
   }
   current = eval(message.code);
   if(current && current.open !== undefined) {
     current.open();
   }
   log.info("Deployed");
 } catch (e) {
   log.error(utils.extractExceptionData(e));
 }




                               For More: Forging Titanium - Episode 23
Code in Transit
Cornwall


     $('#native').click(function() {
    Cornwall.execute(function() {
      Titanium.Contacts.showContacts({});
    });
  });



     var start = new Date();
  $('#variables').click(function() {
    var text = 'Hello World';
    Cornwall.execute(function(start, text) {
      alert("Started: " + start +
                          "nText: " + text);
    },start, text);
  });
Cornwall


var web_popup = function(a) {
  alert("Returned 'a' from Native: " + a.a);
};

$('#bounce').click(function() {
  Cornwall.execute(function() {
    alert("Hello From Native");
    Cornwall.callback(web_popup)({a: "A"});
  });
});
Cornwall


Cornwall.execute = function (fn, arg) {
  try {
    var args = [];
    for (var i = 1, length = arguments.length; i< length; i++) {
      args.push(arguments[i]);
    }
    Ti.App.fireEvent("cornwall:" + Cornwall.id, {
           fn: fn.toString(),
           args: args
       });
  } catch (e) {
    alert(e);
  }
}
Cornwall

function evalFn(o) {
   try{
     eval("(" + o.fn.replace(/Cornwall.callback(([^)]*))/g, "(function(o) {
__web.evalJS('$1(' + JSON.stringify(o) + ');');})") + ")("+
JSON.stringify(o.args).substring(1).replace("]","") +")");
   } catch (e) {
     alert(e);
   }
};
Cornwall


var web_popup = function(a) {
  alert("Returned 'a' from Native: " + a.a);
};

$('#bounce').click(function() {
  Cornwall.execute(function() {
    alert("Hello From Native");
    Cornwall.callback(web_popup)({a: "A"});
  });
});
Cornwall


  (function() {
    alert("Hello From Native");
    Cornwall.callback(web_popup)({a: "A"});
  })()
Cornwall

function evalFn(o) {
   try{
     eval("(" + o.fn.replace(/Cornwall.callback(([^)]*))/g, "(function(o) {
__web.evalJS('$1(' + JSON.stringify(o) + ');');})") + ")("+
JSON.stringify(o.args).substring(1).replace("]","") +")");
   } catch (e) {
     alert(e);
   }
};
Cornwall


  (function() {
    alert("Hello From Native");
    Cornwall.callback(web_popup)({a: "A"});
  })()
Cornwall


  (function() {
    alert("Hello From Native");
    (function(o) {
      __web.evalJS('web_popup('+
         JSON.stringify(o) + ');');
    })({a: "A"});
  })()
Apps in Transit
TiShadow



           • Bundles source and assets

           • Send bundle to device/s

           • Unpack

           • Execute
Tweaking TiSDK




                      • Allow require from the
                        applicationDataDirectory

                      • Do not cache CommonJS
                        modules loaded from
                        applicationDataDirectory



                 For More:
                 Commit: Allows CommonJS from
                 applicationDataDirectory
TiShadow




                      websockets
                      (socket.io)



  tishadow app
   TiSDK (partial)                  tishadow cli
  Built with Custom
                                     rewrites, bundles
    Titanium SDK
                                    and sends off your
                                           code.
TiShadow


 16      + fs.readFileSync(src).toString()
 17
.replace(/Ti(tanium)?.Filesystem.(resourcesDirectory|getResourcesDirectory(
))/g, "Ti.Filesystem.applicationDataDirectory + '"+app_name.replace(/
/g,"_")+"/'")




                               Redirect Resources
TiShadow


18   .replace(/require(/g, "__p.require(")




                               Redirect Require
                               Function
TiShadow


20   .replace(/([ :=(])(['"])/(.*?)(['"])/g, "$1__p.file($2$3$4)")




                                 Redirect Assets
TiShadow


21   .replace(/Ti(tanium)?.API/g, "__log");




                              Redirect Logs
TiShadow

15 var src_text = "try { var __p = require('/api/PlatformRequire'), __log =
require('/api/Log'), assert = require('/api/Assert'), L =
require('/api/Localisation').fetchString;n"

//...

26 src_text += '} catch(e) { e.file="' + src + '";
__log.error(require("/api/Utils").extractExceptionData(e)); }';




                                  Better Error Handling
TiShadow


19   .replace(/Ti.Locale.getString/g, "L”)




                               Dynamic Localisation
TiShadow


 22 if (src.match("_spec.js$")) {
 23     src_text = "var jasmine = require('/lib/jasmine-1.2.0');var methods =
['spyOn','it','xit','expect','runs','waits','waitsFor','beforeEach','afterEach','describ
e','xdescribe'];methods.forEach(function(method) {this[method] =
jasmine[method];});"
 24      +src_text;
 25 }




                                    Fast(er) Testing
                                    Iterations
#TiLondon




                      websockets
                      (socket.io)



  tishadow app
   TiSDK (partial)                  tishadow cli
  Built with Custom
                                     rewrites, bundles
    Titanium SDK
                                    and sends off your
                                           code.
@TiLondon
@Codestrong




              Coding on ANY
              device
David Bankier
  @davidbankier

david@yydigital.com
Section Title Slide
Prelude to next
section
Lorem Ipsum


•   Item 1    Lorem ipsum dolor sit
•   Item 2    amet, consectetur adipiscing elit.
              Morbi pretium scelerisque nisl, sit
•   Item 3
              amet viverra mauris mollis nec.
•   Item 4
              Aliquam sem sem, rutrum non
•   Item 5    pellentesque id, tempus sit amet
              nibh. Morbi nisi ante, elementum vel
              facilisis a, gravida eu libero. In eget
              porttitor.
Lorem Ipsum


              • Item 1

              • Item 2

              • Item 3

              • Item 4

              • Item 5
Lorem Ipsum


              • Item 1

              • Item 2

              • Item 3

              • Item 4

              • Highlight Item
Codestrong 2012 breakout session   hacking titanium
Lorem Ipsum


              • Item 1

              • Item 2

              • Item 3

              • Item 4

              • Item 5
Lorem Ipsum


              • Item 1

              • Item 2

              • Item 3

              • Item 4

              • Item 5
Lorem Ipsum


       Jeff Haynie   “Appcelerator Titanium is the first
  CEO & Co-founder
      Appcelerator   mobile platform to combine the
                     flexibility of open source
                     development technologies with the
                     power of cloud services.”
Codestrong 2012 breakout session   hacking titanium
Codestrong 2012 breakout session   hacking titanium
Codestrong 2012 breakout session   hacking titanium
Codestrong 2012 breakout session   hacking titanium

More Related Content

What's hot (20)

Letswift19-clean-architecture
Letswift19-clean-architectureLetswift19-clean-architecture
Letswift19-clean-architecture
Jung Kim
 
The Ring programming language version 1.2 book - Part 79 of 84
The Ring programming language version 1.2 book - Part 79 of 84The Ring programming language version 1.2 book - Part 79 of 84
The Ring programming language version 1.2 book - Part 79 of 84
Mahmoud Samir Fayed
 
Letswift18 워크숍#1 스위프트 클린코드와 코드리뷰
Letswift18 워크숍#1 스위프트 클린코드와 코드리뷰Letswift18 워크숍#1 스위프트 클린코드와 코드리뷰
Letswift18 워크숍#1 스위프트 클린코드와 코드리뷰
Jung Kim
 
Aaron Bedra - Effective Software Security Teams
Aaron Bedra - Effective Software Security TeamsAaron Bedra - Effective Software Security Teams
Aaron Bedra - Effective Software Security Teams
centralohioissa
 
科特林λ學
科特林λ學科特林λ學
科特林λ學
彥彬 洪
 
Wprowadzenie do technologi Big Data i Apache Hadoop
Wprowadzenie do technologi Big Data i Apache HadoopWprowadzenie do technologi Big Data i Apache Hadoop
Wprowadzenie do technologi Big Data i Apache Hadoop
Sages
 
Advanced Object-Oriented JavaScript
Advanced Object-Oriented JavaScriptAdvanced Object-Oriented JavaScript
Advanced Object-Oriented JavaScript
ecker
 
The Ring programming language version 1.10 book - Part 102 of 212
The Ring programming language version 1.10 book - Part 102 of 212The Ring programming language version 1.10 book - Part 102 of 212
The Ring programming language version 1.10 book - Part 102 of 212
Mahmoud Samir Fayed
 
Concurrency Concepts in Java
Concurrency Concepts in JavaConcurrency Concepts in Java
Concurrency Concepts in Java
Doug Hawkins
 
Node.js extensions in C++
Node.js extensions in C++Node.js extensions in C++
Node.js extensions in C++
Kenneth Geisshirt
 
Wprowadzenie do technologii Big Data / Intro to Big Data Ecosystem
Wprowadzenie do technologii Big Data / Intro to Big Data EcosystemWprowadzenie do technologii Big Data / Intro to Big Data Ecosystem
Wprowadzenie do technologii Big Data / Intro to Big Data Ecosystem
Sages
 
JJUG CCC 2011 Spring
JJUG CCC 2011 SpringJJUG CCC 2011 Spring
JJUG CCC 2011 Spring
Kiyotaka Oku
 
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash courseCodepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
Sages
 
Compose Async with RxJS
Compose Async with RxJSCompose Async with RxJS
Compose Async with RxJS
Kyung Yeol Kim
 
2011-03-29 London - drools
2011-03-29 London - drools2011-03-29 London - drools
2011-03-29 London - drools
Geoffrey De Smet
 
The Ring programming language version 1.5.2 book - Part 13 of 181
The Ring programming language version 1.5.2 book - Part 13 of 181The Ring programming language version 1.5.2 book - Part 13 of 181
The Ring programming language version 1.5.2 book - Part 13 of 181
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.1 book - Part 9 of 180
The Ring programming language version 1.5.1 book - Part 9 of 180The Ring programming language version 1.5.1 book - Part 9 of 180
The Ring programming language version 1.5.1 book - Part 9 of 180
Mahmoud Samir Fayed
 
Innovative Specifications for Better Performance Logging and Monitoring
Innovative Specifications for Better Performance Logging and MonitoringInnovative Specifications for Better Performance Logging and Monitoring
Innovative Specifications for Better Performance Logging and Monitoring
Cary Millsap
 
Annotation processing and code gen
Annotation processing and code genAnnotation processing and code gen
Annotation processing and code gen
koji lin
 
Testing a 2D Platformer with Spock
Testing a 2D Platformer with SpockTesting a 2D Platformer with Spock
Testing a 2D Platformer with Spock
Alexander Tarlinder
 
Letswift19-clean-architecture
Letswift19-clean-architectureLetswift19-clean-architecture
Letswift19-clean-architecture
Jung Kim
 
The Ring programming language version 1.2 book - Part 79 of 84
The Ring programming language version 1.2 book - Part 79 of 84The Ring programming language version 1.2 book - Part 79 of 84
The Ring programming language version 1.2 book - Part 79 of 84
Mahmoud Samir Fayed
 
Letswift18 워크숍#1 스위프트 클린코드와 코드리뷰
Letswift18 워크숍#1 스위프트 클린코드와 코드리뷰Letswift18 워크숍#1 스위프트 클린코드와 코드리뷰
Letswift18 워크숍#1 스위프트 클린코드와 코드리뷰
Jung Kim
 
Aaron Bedra - Effective Software Security Teams
Aaron Bedra - Effective Software Security TeamsAaron Bedra - Effective Software Security Teams
Aaron Bedra - Effective Software Security Teams
centralohioissa
 
科特林λ學
科特林λ學科特林λ學
科特林λ學
彥彬 洪
 
Wprowadzenie do technologi Big Data i Apache Hadoop
Wprowadzenie do technologi Big Data i Apache HadoopWprowadzenie do technologi Big Data i Apache Hadoop
Wprowadzenie do technologi Big Data i Apache Hadoop
Sages
 
Advanced Object-Oriented JavaScript
Advanced Object-Oriented JavaScriptAdvanced Object-Oriented JavaScript
Advanced Object-Oriented JavaScript
ecker
 
The Ring programming language version 1.10 book - Part 102 of 212
The Ring programming language version 1.10 book - Part 102 of 212The Ring programming language version 1.10 book - Part 102 of 212
The Ring programming language version 1.10 book - Part 102 of 212
Mahmoud Samir Fayed
 
Concurrency Concepts in Java
Concurrency Concepts in JavaConcurrency Concepts in Java
Concurrency Concepts in Java
Doug Hawkins
 
Wprowadzenie do technologii Big Data / Intro to Big Data Ecosystem
Wprowadzenie do technologii Big Data / Intro to Big Data EcosystemWprowadzenie do technologii Big Data / Intro to Big Data Ecosystem
Wprowadzenie do technologii Big Data / Intro to Big Data Ecosystem
Sages
 
JJUG CCC 2011 Spring
JJUG CCC 2011 SpringJJUG CCC 2011 Spring
JJUG CCC 2011 Spring
Kiyotaka Oku
 
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash courseCodepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
Sages
 
Compose Async with RxJS
Compose Async with RxJSCompose Async with RxJS
Compose Async with RxJS
Kyung Yeol Kim
 
2011-03-29 London - drools
2011-03-29 London - drools2011-03-29 London - drools
2011-03-29 London - drools
Geoffrey De Smet
 
The Ring programming language version 1.5.2 book - Part 13 of 181
The Ring programming language version 1.5.2 book - Part 13 of 181The Ring programming language version 1.5.2 book - Part 13 of 181
The Ring programming language version 1.5.2 book - Part 13 of 181
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.1 book - Part 9 of 180
The Ring programming language version 1.5.1 book - Part 9 of 180The Ring programming language version 1.5.1 book - Part 9 of 180
The Ring programming language version 1.5.1 book - Part 9 of 180
Mahmoud Samir Fayed
 
Innovative Specifications for Better Performance Logging and Monitoring
Innovative Specifications for Better Performance Logging and MonitoringInnovative Specifications for Better Performance Logging and Monitoring
Innovative Specifications for Better Performance Logging and Monitoring
Cary Millsap
 
Annotation processing and code gen
Annotation processing and code genAnnotation processing and code gen
Annotation processing and code gen
koji lin
 
Testing a 2D Platformer with Spock
Testing a 2D Platformer with SpockTesting a 2D Platformer with Spock
Testing a 2D Platformer with Spock
Alexander Tarlinder
 

Similar to Codestrong 2012 breakout session hacking titanium (20)

20110525[Taipei GTUG] titanium mobile簡介
20110525[Taipei GTUG] titanium mobile簡介20110525[Taipei GTUG] titanium mobile簡介
20110525[Taipei GTUG] titanium mobile簡介
Justin Lee
 
Cross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App EngineCross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App Engine
Andy McKay
 
Event-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineEvent-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 Engine
Ricardo Silva
 
huhu
huhuhuhu
huhu
Dung Trương
 
CouchDB on Android
CouchDB on AndroidCouchDB on Android
CouchDB on Android
Sven Haiges
 
mobl
moblmobl
mobl
zefhemel
 
Dartprogramming
DartprogrammingDartprogramming
Dartprogramming
Ali Parmaksiz
 
JavaScript Web Workers
JavaScript Web WorkersJavaScript Web Workers
JavaScript Web Workers
Tobias Pfeiffer
 
Kinect de-theremin
Kinect de-thereminKinect de-theremin
Kinect de-theremin
Kazuyuki Honda
 
Spicy javascript: Create your first Chrome extension for web analytics QA
Spicy javascript: Create your first Chrome extension for web analytics QASpicy javascript: Create your first Chrome extension for web analytics QA
Spicy javascript: Create your first Chrome extension for web analytics QA
Alban Gérôme
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
Tom Croucher
 
iPhone Development Intro
iPhone Development IntroiPhone Development Intro
iPhone Development Intro
Luis Azevedo
 
Phone Gap
Phone GapPhone Gap
Phone Gap
Yiguang Hu
 
Eric Lafortune - The Jack and Jill build system
Eric Lafortune - The Jack and Jill build systemEric Lafortune - The Jack and Jill build system
Eric Lafortune - The Jack and Jill build system
GuardSquare
 
Javascript Everywhere
Javascript EverywhereJavascript Everywhere
Javascript Everywhere
Pascal Rettig
 
Automated malware analysis
Automated malware analysisAutomated malware analysis
Automated malware analysis
Ibrahim Baliç
 
Node.js - async for the rest of us.
Node.js - async for the rest of us.Node.js - async for the rest of us.
Node.js - async for the rest of us.
Mike Brevoort
 
Painless Persistence in a Disconnected World
Painless Persistence in a Disconnected WorldPainless Persistence in a Disconnected World
Painless Persistence in a Disconnected World
Christian Melchior
 
Online Meetup: Why should container system / platform builders care about con...
Online Meetup: Why should container system / platform builders care about con...Online Meetup: Why should container system / platform builders care about con...
Online Meetup: Why should container system / platform builders care about con...
Docker, Inc.
 
Eric Lafortune - The Jack and Jill build system
Eric Lafortune - The Jack and Jill build systemEric Lafortune - The Jack and Jill build system
Eric Lafortune - The Jack and Jill build system
GuardSquare
 
20110525[Taipei GTUG] titanium mobile簡介
20110525[Taipei GTUG] titanium mobile簡介20110525[Taipei GTUG] titanium mobile簡介
20110525[Taipei GTUG] titanium mobile簡介
Justin Lee
 
Cross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App EngineCross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App Engine
Andy McKay
 
Event-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineEvent-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 Engine
Ricardo Silva
 
CouchDB on Android
CouchDB on AndroidCouchDB on Android
CouchDB on Android
Sven Haiges
 
Spicy javascript: Create your first Chrome extension for web analytics QA
Spicy javascript: Create your first Chrome extension for web analytics QASpicy javascript: Create your first Chrome extension for web analytics QA
Spicy javascript: Create your first Chrome extension for web analytics QA
Alban Gérôme
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
Tom Croucher
 
iPhone Development Intro
iPhone Development IntroiPhone Development Intro
iPhone Development Intro
Luis Azevedo
 
Eric Lafortune - The Jack and Jill build system
Eric Lafortune - The Jack and Jill build systemEric Lafortune - The Jack and Jill build system
Eric Lafortune - The Jack and Jill build system
GuardSquare
 
Javascript Everywhere
Javascript EverywhereJavascript Everywhere
Javascript Everywhere
Pascal Rettig
 
Automated malware analysis
Automated malware analysisAutomated malware analysis
Automated malware analysis
Ibrahim Baliç
 
Node.js - async for the rest of us.
Node.js - async for the rest of us.Node.js - async for the rest of us.
Node.js - async for the rest of us.
Mike Brevoort
 
Painless Persistence in a Disconnected World
Painless Persistence in a Disconnected WorldPainless Persistence in a Disconnected World
Painless Persistence in a Disconnected World
Christian Melchior
 
Online Meetup: Why should container system / platform builders care about con...
Online Meetup: Why should container system / platform builders care about con...Online Meetup: Why should container system / platform builders care about con...
Online Meetup: Why should container system / platform builders care about con...
Docker, Inc.
 
Eric Lafortune - The Jack and Jill build system
Eric Lafortune - The Jack and Jill build systemEric Lafortune - The Jack and Jill build system
Eric Lafortune - The Jack and Jill build system
GuardSquare
 

More from Axway Appcelerator (20)

Axway Appcelerator - Titanium SDK 6.1.0 - Status, Releases & Roadmap
Axway Appcelerator - Titanium SDK 6.1.0 - Status, Releases & RoadmapAxway Appcelerator - Titanium SDK 6.1.0 - Status, Releases & Roadmap
Axway Appcelerator - Titanium SDK 6.1.0 - Status, Releases & Roadmap
Axway Appcelerator
 
2014 Dublin Web Summit by Jeff Haynie
2014 Dublin Web Summit by Jeff Haynie2014 Dublin Web Summit by Jeff Haynie
2014 Dublin Web Summit by Jeff Haynie
Axway Appcelerator
 
Making the Mobile Mind Shift
Making the Mobile Mind ShiftMaking the Mobile Mind Shift
Making the Mobile Mind Shift
Axway Appcelerator
 
Stop Debating, Start Measuring
Stop Debating, Start MeasuringStop Debating, Start Measuring
Stop Debating, Start Measuring
Axway Appcelerator
 
Mobile & The New Experience Economy (And What it Means for IT)
Mobile & The New Experience Economy  (And What it Means for IT)Mobile & The New Experience Economy  (And What it Means for IT)
Mobile & The New Experience Economy (And What it Means for IT)
Axway Appcelerator
 
Apps, APIs & Analytics: What "Mobile First" Really Means
Apps, APIs & Analytics: What "Mobile First" Really MeansApps, APIs & Analytics: What "Mobile First" Really Means
Apps, APIs & Analytics: What "Mobile First" Really Means
Axway Appcelerator
 
Appcelerator Presentation Template
Appcelerator Presentation TemplateAppcelerator Presentation Template
Appcelerator Presentation Template
Axway Appcelerator
 
Codestrong 2012 keynote jonathan rende, appcelerator's vp of products
Codestrong 2012 keynote   jonathan rende, appcelerator's vp of productsCodestrong 2012 keynote   jonathan rende, appcelerator's vp of products
Codestrong 2012 keynote jonathan rende, appcelerator's vp of products
Axway Appcelerator
 
Codestrong 2012 keynote jeff haynie, appcelerator's ceo
Codestrong 2012 keynote   jeff haynie, appcelerator's ceoCodestrong 2012 keynote   jeff haynie, appcelerator's ceo
Codestrong 2012 keynote jeff haynie, appcelerator's ceo
Axway Appcelerator
 
Codestrong 2012 keynote how to build a top ten app
Codestrong 2012 keynote   how to build a top ten appCodestrong 2012 keynote   how to build a top ten app
Codestrong 2012 keynote how to build a top ten app
Axway Appcelerator
 
Codestrong 2012 breakout session at&t api platform and trends
Codestrong 2012 breakout session  at&t api platform and trendsCodestrong 2012 breakout session  at&t api platform and trends
Codestrong 2012 breakout session at&t api platform and trends
Axway Appcelerator
 
Codestrong 2012 breakout session what's new in titanium studio
Codestrong 2012 breakout session   what's new in titanium studioCodestrong 2012 breakout session   what's new in titanium studio
Codestrong 2012 breakout session what's new in titanium studio
Axway Appcelerator
 
Codestrong 2012 breakout session using appcelerator cloud services in your ...
Codestrong 2012 breakout session   using appcelerator cloud services in your ...Codestrong 2012 breakout session   using appcelerator cloud services in your ...
Codestrong 2012 breakout session using appcelerator cloud services in your ...
Axway Appcelerator
 
Codestrong 2012 breakout session the role of cloud services in your next ge...
Codestrong 2012 breakout session   the role of cloud services in your next ge...Codestrong 2012 breakout session   the role of cloud services in your next ge...
Codestrong 2012 breakout session the role of cloud services in your next ge...
Axway Appcelerator
 
Codestrong 2012 breakout session new device platform support for titanium
Codestrong 2012 breakout session   new device platform support for titaniumCodestrong 2012 breakout session   new device platform support for titanium
Codestrong 2012 breakout session new device platform support for titanium
Axway Appcelerator
 
Codestrong 2012 breakout session mobile platform and infrastructure
Codestrong 2012 breakout session   mobile platform and infrastructureCodestrong 2012 breakout session   mobile platform and infrastructure
Codestrong 2012 breakout session mobile platform and infrastructure
Axway Appcelerator
 
Codestrong 2012 breakout session making money on appcelerator's marketplace
Codestrong 2012 breakout session   making money on appcelerator's marketplaceCodestrong 2012 breakout session   making money on appcelerator's marketplace
Codestrong 2012 breakout session making money on appcelerator's marketplace
Axway Appcelerator
 
Codestrong 2012 breakout session live multi-platform testing
Codestrong 2012 breakout session   live multi-platform testingCodestrong 2012 breakout session   live multi-platform testing
Codestrong 2012 breakout session live multi-platform testing
Axway Appcelerator
 
Codestrong 2012 breakout session leveraging titanium as part of your mobile...
Codestrong 2012 breakout session   leveraging titanium as part of your mobile...Codestrong 2012 breakout session   leveraging titanium as part of your mobile...
Codestrong 2012 breakout session leveraging titanium as part of your mobile...
Axway Appcelerator
 
Codestrong 2012 breakout session i os internals and best practices
Codestrong 2012 breakout session   i os internals and best practicesCodestrong 2012 breakout session   i os internals and best practices
Codestrong 2012 breakout session i os internals and best practices
Axway Appcelerator
 
Axway Appcelerator - Titanium SDK 6.1.0 - Status, Releases & Roadmap
Axway Appcelerator - Titanium SDK 6.1.0 - Status, Releases & RoadmapAxway Appcelerator - Titanium SDK 6.1.0 - Status, Releases & Roadmap
Axway Appcelerator - Titanium SDK 6.1.0 - Status, Releases & Roadmap
Axway Appcelerator
 
2014 Dublin Web Summit by Jeff Haynie
2014 Dublin Web Summit by Jeff Haynie2014 Dublin Web Summit by Jeff Haynie
2014 Dublin Web Summit by Jeff Haynie
Axway Appcelerator
 
Stop Debating, Start Measuring
Stop Debating, Start MeasuringStop Debating, Start Measuring
Stop Debating, Start Measuring
Axway Appcelerator
 
Mobile & The New Experience Economy (And What it Means for IT)
Mobile & The New Experience Economy  (And What it Means for IT)Mobile & The New Experience Economy  (And What it Means for IT)
Mobile & The New Experience Economy (And What it Means for IT)
Axway Appcelerator
 
Apps, APIs & Analytics: What "Mobile First" Really Means
Apps, APIs & Analytics: What "Mobile First" Really MeansApps, APIs & Analytics: What "Mobile First" Really Means
Apps, APIs & Analytics: What "Mobile First" Really Means
Axway Appcelerator
 
Appcelerator Presentation Template
Appcelerator Presentation TemplateAppcelerator Presentation Template
Appcelerator Presentation Template
Axway Appcelerator
 
Codestrong 2012 keynote jonathan rende, appcelerator's vp of products
Codestrong 2012 keynote   jonathan rende, appcelerator's vp of productsCodestrong 2012 keynote   jonathan rende, appcelerator's vp of products
Codestrong 2012 keynote jonathan rende, appcelerator's vp of products
Axway Appcelerator
 
Codestrong 2012 keynote jeff haynie, appcelerator's ceo
Codestrong 2012 keynote   jeff haynie, appcelerator's ceoCodestrong 2012 keynote   jeff haynie, appcelerator's ceo
Codestrong 2012 keynote jeff haynie, appcelerator's ceo
Axway Appcelerator
 
Codestrong 2012 keynote how to build a top ten app
Codestrong 2012 keynote   how to build a top ten appCodestrong 2012 keynote   how to build a top ten app
Codestrong 2012 keynote how to build a top ten app
Axway Appcelerator
 
Codestrong 2012 breakout session at&t api platform and trends
Codestrong 2012 breakout session  at&t api platform and trendsCodestrong 2012 breakout session  at&t api platform and trends
Codestrong 2012 breakout session at&t api platform and trends
Axway Appcelerator
 
Codestrong 2012 breakout session what's new in titanium studio
Codestrong 2012 breakout session   what's new in titanium studioCodestrong 2012 breakout session   what's new in titanium studio
Codestrong 2012 breakout session what's new in titanium studio
Axway Appcelerator
 
Codestrong 2012 breakout session using appcelerator cloud services in your ...
Codestrong 2012 breakout session   using appcelerator cloud services in your ...Codestrong 2012 breakout session   using appcelerator cloud services in your ...
Codestrong 2012 breakout session using appcelerator cloud services in your ...
Axway Appcelerator
 
Codestrong 2012 breakout session the role of cloud services in your next ge...
Codestrong 2012 breakout session   the role of cloud services in your next ge...Codestrong 2012 breakout session   the role of cloud services in your next ge...
Codestrong 2012 breakout session the role of cloud services in your next ge...
Axway Appcelerator
 
Codestrong 2012 breakout session new device platform support for titanium
Codestrong 2012 breakout session   new device platform support for titaniumCodestrong 2012 breakout session   new device platform support for titanium
Codestrong 2012 breakout session new device platform support for titanium
Axway Appcelerator
 
Codestrong 2012 breakout session mobile platform and infrastructure
Codestrong 2012 breakout session   mobile platform and infrastructureCodestrong 2012 breakout session   mobile platform and infrastructure
Codestrong 2012 breakout session mobile platform and infrastructure
Axway Appcelerator
 
Codestrong 2012 breakout session making money on appcelerator's marketplace
Codestrong 2012 breakout session   making money on appcelerator's marketplaceCodestrong 2012 breakout session   making money on appcelerator's marketplace
Codestrong 2012 breakout session making money on appcelerator's marketplace
Axway Appcelerator
 
Codestrong 2012 breakout session live multi-platform testing
Codestrong 2012 breakout session   live multi-platform testingCodestrong 2012 breakout session   live multi-platform testing
Codestrong 2012 breakout session live multi-platform testing
Axway Appcelerator
 
Codestrong 2012 breakout session leveraging titanium as part of your mobile...
Codestrong 2012 breakout session   leveraging titanium as part of your mobile...Codestrong 2012 breakout session   leveraging titanium as part of your mobile...
Codestrong 2012 breakout session leveraging titanium as part of your mobile...
Axway Appcelerator
 
Codestrong 2012 breakout session i os internals and best practices
Codestrong 2012 breakout session   i os internals and best practicesCodestrong 2012 breakout session   i os internals and best practices
Codestrong 2012 breakout session i os internals and best practices
Axway Appcelerator
 

Codestrong 2012 breakout session hacking titanium

  • 1. Hacking Titanium David Bankier Director YY Digital @davidbankier david@yydigital.com
  • 3. TiHighlight tabGroup.setActiveTab(1); try { if(current && current.close !== undefined) { current.close(); } current = eval(message.code); if(current && current.open !== undefined) { tabGroup.activeTab.open(current); } } catch (e) { if(Ti.Platform.osname === 'android') { alert(e.toString()); } else { //iOS Error alert("Line: " + e.line + "n" + e.message); } }
  • 4. TiShadow websockets (socket.io) tishadow app tishadow TiSDK (partial) server node.js express socket.io Ace
  • 5. TiShadow try { if(current && current.close !== undefined) { current.close(); } current = eval(message.code); if(current && current.open !== undefined) { current.open(); } log.info("Deployed"); } catch (e) { log.error(utils.extractExceptionData(e)); } For More: Forging Titanium - Episode 23
  • 7. Cornwall $('#native').click(function() { Cornwall.execute(function() { Titanium.Contacts.showContacts({}); }); }); var start = new Date(); $('#variables').click(function() { var text = 'Hello World'; Cornwall.execute(function(start, text) { alert("Started: " + start + "nText: " + text); },start, text); });
  • 8. Cornwall var web_popup = function(a) { alert("Returned 'a' from Native: " + a.a); }; $('#bounce').click(function() { Cornwall.execute(function() { alert("Hello From Native"); Cornwall.callback(web_popup)({a: "A"}); }); });
  • 9. Cornwall Cornwall.execute = function (fn, arg) { try { var args = []; for (var i = 1, length = arguments.length; i< length; i++) { args.push(arguments[i]); } Ti.App.fireEvent("cornwall:" + Cornwall.id, { fn: fn.toString(), args: args }); } catch (e) { alert(e); } }
  • 10. Cornwall function evalFn(o) { try{ eval("(" + o.fn.replace(/Cornwall.callback(([^)]*))/g, "(function(o) { __web.evalJS('$1(' + JSON.stringify(o) + ');');})") + ")("+ JSON.stringify(o.args).substring(1).replace("]","") +")"); } catch (e) { alert(e); } };
  • 11. Cornwall var web_popup = function(a) { alert("Returned 'a' from Native: " + a.a); }; $('#bounce').click(function() { Cornwall.execute(function() { alert("Hello From Native"); Cornwall.callback(web_popup)({a: "A"}); }); });
  • 12. Cornwall (function() { alert("Hello From Native"); Cornwall.callback(web_popup)({a: "A"}); })()
  • 13. Cornwall function evalFn(o) { try{ eval("(" + o.fn.replace(/Cornwall.callback(([^)]*))/g, "(function(o) { __web.evalJS('$1(' + JSON.stringify(o) + ');');})") + ")("+ JSON.stringify(o.args).substring(1).replace("]","") +")"); } catch (e) { alert(e); } };
  • 14. Cornwall (function() { alert("Hello From Native"); Cornwall.callback(web_popup)({a: "A"}); })()
  • 15. Cornwall (function() { alert("Hello From Native"); (function(o) { __web.evalJS('web_popup('+ JSON.stringify(o) + ');'); })({a: "A"}); })()
  • 17. TiShadow • Bundles source and assets • Send bundle to device/s • Unpack • Execute
  • 18. Tweaking TiSDK • Allow require from the applicationDataDirectory • Do not cache CommonJS modules loaded from applicationDataDirectory For More: Commit: Allows CommonJS from applicationDataDirectory
  • 19. TiShadow websockets (socket.io) tishadow app TiSDK (partial) tishadow cli Built with Custom rewrites, bundles Titanium SDK and sends off your code.
  • 20. TiShadow 16 + fs.readFileSync(src).toString() 17 .replace(/Ti(tanium)?.Filesystem.(resourcesDirectory|getResourcesDirectory( ))/g, "Ti.Filesystem.applicationDataDirectory + '"+app_name.replace(/ /g,"_")+"/'") Redirect Resources
  • 21. TiShadow 18 .replace(/require(/g, "__p.require(") Redirect Require Function
  • 22. TiShadow 20 .replace(/([ :=(])(['"])/(.*?)(['"])/g, "$1__p.file($2$3$4)") Redirect Assets
  • 23. TiShadow 21 .replace(/Ti(tanium)?.API/g, "__log"); Redirect Logs
  • 24. TiShadow 15 var src_text = "try { var __p = require('/api/PlatformRequire'), __log = require('/api/Log'), assert = require('/api/Assert'), L = require('/api/Localisation').fetchString;n" //... 26 src_text += '} catch(e) { e.file="' + src + '"; __log.error(require("/api/Utils").extractExceptionData(e)); }'; Better Error Handling
  • 25. TiShadow 19 .replace(/Ti.Locale.getString/g, "L”) Dynamic Localisation
  • 26. TiShadow 22 if (src.match("_spec.js$")) { 23 src_text = "var jasmine = require('/lib/jasmine-1.2.0');var methods = ['spyOn','it','xit','expect','runs','waits','waitsFor','beforeEach','afterEach','describ e','xdescribe'];methods.forEach(function(method) {this[method] = jasmine[method];});" 24 +src_text; 25 } Fast(er) Testing Iterations
  • 27. #TiLondon websockets (socket.io) tishadow app TiSDK (partial) tishadow cli Built with Custom rewrites, bundles Titanium SDK and sends off your code.
  • 29. @Codestrong Coding on ANY device
  • 30. David Bankier @davidbankier david@yydigital.com
  • 31. Section Title Slide Prelude to next section
  • 32. Lorem Ipsum • Item 1 Lorem ipsum dolor sit • Item 2 amet, consectetur adipiscing elit. Morbi pretium scelerisque nisl, sit • Item 3 amet viverra mauris mollis nec. • Item 4 Aliquam sem sem, rutrum non • Item 5 pellentesque id, tempus sit amet nibh. Morbi nisi ante, elementum vel facilisis a, gravida eu libero. In eget porttitor.
  • 33. Lorem Ipsum • Item 1 • Item 2 • Item 3 • Item 4 • Item 5
  • 34. Lorem Ipsum • Item 1 • Item 2 • Item 3 • Item 4 • Highlight Item
  • 36. Lorem Ipsum • Item 1 • Item 2 • Item 3 • Item 4 • Item 5
  • 37. Lorem Ipsum • Item 1 • Item 2 • Item 3 • Item 4 • Item 5
  • 38. Lorem Ipsum Jeff Haynie “Appcelerator Titanium is the first CEO & Co-founder Appcelerator mobile platform to combine the flexibility of open source development technologies with the power of cloud services.”
  翻译: