Method: Rho::Application.processApplicationEvent

Defined in:
lib/commonAPI/coreapi/RhoApplicationApi.rb

.processApplicationEvent(params) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/commonAPI/coreapi/RhoApplicationApi.rb', line 65

def self.processApplicationEvent(params)
  applicationEvent = params['applicationEvent'] 
  eventData = params['eventData']
  eventData = {} unless eventData

  case applicationEvent
  when 'Activated'
    puts "AppEvent #{applicationEvent}"

  when 'Deactivated'
    puts "AppEvent #{applicationEvent}"

  when 'UICreated'
    start_url = Rho::Application.startURI
    start_url = "" unless start_url

    if System.get_property('platform') != 'WP8'

      invalid_security_token_start_path = Rho::Application.invalidSecurityTokenStartPath
      
      if Rho::Application.securityTokenNotPassed
        if invalid_security_token_start_path && invalid_security_token_start_path.length() > 0
          start_url = invalid_security_token_start_path
        else
          # exit from application - old way
          puts 'security_token is not passed - application will closed'
          System.exit
        end
      end
    end

    puts "on_ui_created.navigate to start url: '#{start_url}'"
    WebView.navigate(start_url)

  when 'UIDestroyed'
    puts "AppEvent #{applicationEvent}"

  when 'SyncUserChanged'
    Rhom::Rhom.database_full_reset(false, false)    
    #::Rho::RHO.get_user_db().execute_sql("UPDATE client_info SET client_id=?", "")

  when 'ConfigConflict'
    puts "on_reinstall_config_update: #{eventData.conflicts}"

  when 'DBMigrateSource'
    puts "default on_migrate_source - do nothing; old_version :#{eventData.old_version}; new_src : #{eventData.new_src}"
    #if new_src['schema']
    #    db = ::Rho::RHO.get_src_db(new_src['name'])
    #    db.delete_table(new_src['name'])

    #    return false  #create new table
    #end
    return true
  end
end