Module: Rho::RhoEvent

Defined in:
lib/framework/rho/rhoevent.rb,
lib/framework/rho/rhoevent_c.rb,
lib/framework/rho/rhoevent_bb.rb,
lib/framework/autocomplete/Rho.rb

Constant Summary collapse

AUTHORIZATION_STATUS_NOT_DETERMINED =
'Not Determined'
AUTHORIZATION_STATUS_RESTRICTED =
'Restricted'
AUTHORIZATION_STATUS_DENIED =
'Denied'
AUTHORIZATION_STATUS_AUTHORIZED =
'Authorized'
MIN_TIME =
Time.utc(1900, 'jan', 1, 0, 0, 0)
MAX_TIME =
Time.utc(2100, 'dec', 31, 23, 59, 59)

Class Method Summary collapse

Class Method Details

.create!(event) ⇒ Object



70
71
72
73
74
75
76
77
# File 'lib/framework/rho/rhoevent_c.rb', line 70

def self.create!(event)
  event['id'] = nil #indicate that event should be created
  event['reminder'] = event['reminder'].to_i if event['reminder'] != nil
  event['recurrence']['end'] = nil if event['recurrence'] and event['recurrence']['end'] == ""
  new_id = Rho::Calendar.save(event)
  event['id'] = new_id
  return event
end

.destroy(id) ⇒ Object



79
80
81
82
# File 'lib/framework/rho/rhoevent_c.rb', line 79

def self.destroy(id)
  id = $1 if id.is_a?(String) and id =~ /^{(.*)}$/
  Rho::Calendar.delete(id)
end

.find(args) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/framework/rho/rhoevent_c.rb', line 32

def self.find(*args)
  if args.first == :all
    params = {}
    if args.length >= 2 and args[1].is_a? Hash
      puts "Event find params: #{args[1].inspect}"
      args[1].each do |k,v|
        params[k.to_s] = v
        puts "#{k.to_s} => #{v}"
      end
    end

    params['start_date'] = params['start_date'].to_time if !params['start_date'].nil? and !params['start_date'].is_a?(Time)
    params['end_date'] = params['end_date'].to_time if !params['end_date'].nil? and !params['end_date'].is_a?(Time)
    
    params['start_date'] = MIN_TIME if params['start_date'].nil? #or params['start_date'] < MIN_TIME
    params['end_date'] = MAX_TIME if params['end_date'].nil? #or params['end_date'] > MAX_TIME
    
    if params['start_date'] == MIN_TIME or params['end_date'] == MAX_TIME
      params['include_repeating'] = false
      puts "Resetting 'include_repeating' param to false"
    end
    
    puts "Rho::Calendar.fetch(params) : #{params}"
    events = Rho::Calendar.fetch(params)
    #puts "events : #{events}"
    #ret = {}
    #events.each do |e|
    #  ret[e[Rho::RhoEvent::ID]] = e
    #end
    #ret
    events
  else
    id = args.first.to_s
    id = $1 if id.is_a?(String) and id =~ /^{(.*)}$/
    Rho::Calendar.fetch_by_id(id)
  end
end

.get_authorization_statusObject



44
45
46
47
48
49
50
# File 'lib/framework/rho/rhoevent.rb', line 44

def self.get_authorization_status
        result = AUTHORIZATION_STATUS_AUTHORIZED
        if System::get_property('platform') == "ANDROID" or System::get_property('platform') == "APPLE"
            result = Rho::Calendar.calendar_get_authorization_status()
        end
        result
end

.select(index, block) ⇒ Object

> returns all records of the Test User from the company rhomobile



70
71
72
73
74
75
76
77
78
79
80
# File 'lib/framework/rho/rhoevent.rb', line 70

def self.select(index, &block)
  key, value = index.keys[0], index.values[0]
  if @events.nil? or @key != key
    @key, @events = key, find(:all).to_a.sort! {|x,y| x[1][key] <=> y[1][key] }
  end
  found = @events[@events.bsearch_range {|x| x[1][key] <=> value}]
  unless found.nil? or block.nil?
    return found.select(&block)
  end
  return found
end

.update_attributes(event) ⇒ Object



84
85
86
87
# File 'lib/framework/rho/rhoevent_c.rb', line 84

def self.update_attributes(event)
  puts "update_attributes: #{event}"
  Rho::Calendar.save(event)
end