Permalink
Browse files

Add BlueCal

  • Loading branch information...
1 parent 39f65fb commit fc60f83b2a4b7641587395c52f0f6e23c7df2713 Brian Moore committed Oct 15, 2010
Showing with 3,547 additions and 0 deletions.
  1. +28 −0 BlueCal/Rakefile
  2. +10 −0 BlueCal/app/Cal/cal.rb
  3. +211 −0 BlueCal/app/Cal/cal_controller.rb
  4. +24 −0 BlueCal/app/Cal/edit.bb.erb
  5. +27 −0 BlueCal/app/Cal/edit.erb
  6. +21 −0 BlueCal/app/Cal/index.bb.erb
  7. +20 −0 BlueCal/app/Cal/index.erb
  8. +24 −0 BlueCal/app/Cal/new.bb.erb
  9. +25 −0 BlueCal/app/Cal/new.erb
  10. +1 −0 BlueCal/app/Cal/send.erb
  11. +21 −0 BlueCal/app/Cal/show.bb.erb
  12. +23 −0 BlueCal/app/Cal/show.erb
  13. +75 −0 BlueCal/app/Settings/controller.rb
  14. +17 −0 BlueCal/app/Settings/home.bb.erb
  15. +20 −0 BlueCal/app/Settings/home.erb
  16. +32 −0 BlueCal/app/Settings/index.bb.erb
  17. +30 −0 BlueCal/app/Settings/index.erb
  18. +35 −0 BlueCal/app/Settings/login.bb.erb
  19. +27 −0 BlueCal/app/Settings/login.erb
  20. +15 −0 BlueCal/app/Settings/reset.bb.erb
  21. +17 −0 BlueCal/app/Settings/reset.erb
  22. +3 −0 BlueCal/app/Settings/wait.bb.erb
  23. +5 −0 BlueCal/app/Settings/wait.erb
  24. +16 −0 BlueCal/app/application.rb
  25. +126 −0 BlueCal/app/helpers/application_helper.rb
  26. +18 −0 BlueCal/app/helpers/browser_helper.rb
  27. +26 −0 BlueCal/app/index.bb.erb
  28. +26 −0 BlueCal/app/index.erb
  29. +114 −0 BlueCal/app/layout.erb
  30. +11 −0 BlueCal/app/loading.html
  31. +7 −0 BlueCal/app/test/cal_spec.rb
  32. +19 −0 BlueCal/build.yml
  33. BIN BlueCal/icon/icon.ico
  34. BIN BlueCal/icon/icon.png
  35. +330 −0 BlueCal/public/css/android.css
  36. +115 −0 BlueCal/public/css/blackberry.css
  37. +410 −0 BlueCal/public/css/iphone.css
  38. +222 −0 BlueCal/public/css/windows_mobile.css
  39. +21 −0 BlueCal/public/images/IUI_LICENSE.txt
  40. BIN BlueCal/public/images/android/btn_check_off.png
  41. BIN BlueCal/public/images/android/btn_check_on.png
  42. BIN BlueCal/public/images/android/btn_radio_off.png
  43. BIN BlueCal/public/images/android/btn_radio_on.png
  44. BIN BlueCal/public/images/android/disclosure.png
  45. BIN BlueCal/public/images/android/ic_menu_more.png
  46. BIN BlueCal/public/images/backButton.png
  47. BIN BlueCal/public/images/blueButton.png
  48. BIN BlueCal/public/images/calpad.jpg
  49. BIN BlueCal/public/images/cancel.png
  50. BIN BlueCal/public/images/cells.png
  51. BIN BlueCal/public/images/grayButton.png
  52. BIN BlueCal/public/images/iphone/disclosure.png
  53. BIN BlueCal/public/images/iphone/disclosure_detail.png
  54. BIN BlueCal/public/images/iphone/jqtouch/backButton.png
  55. BIN BlueCal/public/images/iphone/jqtouch/blueButton.png
  56. BIN BlueCal/public/images/iphone/jqtouch/cancel.png
  57. BIN BlueCal/public/images/iphone/jqtouch/chevron.png
  58. BIN BlueCal/public/images/iphone/jqtouch/grayButton.png
  59. BIN BlueCal/public/images/iphone/jqtouch/listArrowSel.png
  60. BIN BlueCal/public/images/iphone/jqtouch/listGroup.png
  61. BIN BlueCal/public/images/iphone/jqtouch/loading.gif
  62. BIN BlueCal/public/images/iphone/jqtouch/on_off.png
  63. BIN BlueCal/public/images/iphone/jqtouch/pinstripes.png
  64. BIN BlueCal/public/images/iphone/jqtouch/selection.png
  65. BIN BlueCal/public/images/iphone/jqtouch/thumb.png
  66. BIN BlueCal/public/images/iphone/jqtouch/toggle.png
  67. BIN BlueCal/public/images/iphone/jqtouch/toggleOn.png
  68. BIN BlueCal/public/images/iphone/jqtouch/toolButton.png
  69. BIN BlueCal/public/images/iphone/jqtouch/toolbar.png
  70. BIN BlueCal/public/images/iphone/jqtouch/whiteButton.png
  71. BIN BlueCal/public/images/iphone/radiobutton.png
  72. BIN BlueCal/public/images/iphone/select.png
  73. BIN BlueCal/public/images/iphone/switch.png
  74. BIN BlueCal/public/images/iui-logo-touch-icon.png
  75. BIN BlueCal/public/images/listArrow.png
  76. BIN BlueCal/public/images/listArrowDown.png
  77. BIN BlueCal/public/images/listArrowSel.png
  78. BIN BlueCal/public/images/listGroup.png
  79. BIN BlueCal/public/images/loading.gif
  80. BIN BlueCal/public/images/pinstripes.png
  81. BIN BlueCal/public/images/popup.png
  82. BIN BlueCal/public/images/right_button.png
  83. BIN BlueCal/public/images/selection.png
  84. BIN BlueCal/public/images/thumb.png
  85. BIN BlueCal/public/images/toggle.png
  86. BIN BlueCal/public/images/toggleOn.png
  87. BIN BlueCal/public/images/toolButton.png
  88. BIN BlueCal/public/images/toolButton_new.png
  89. BIN BlueCal/public/images/toolbar.png
  90. BIN BlueCal/public/images/whiteButton.png
  91. +9 −0 BlueCal/public/jqtouch/jqtouch-iphone.css
  92. +374 −0 BlueCal/public/jqtouch/jqtouch.css
  93. +742 −0 BlueCal/public/jqtouch/jqtouch.js
  94. +60 −0 BlueCal/public/jqtouch/jqtouch.transitions.js
  95. +19 −0 BlueCal/public/jqtouch/jquery.1.3.2.min.js
  96. +1 −0 BlueCal/public/js/application.js
  97. +57 −0 BlueCal/public/js/coda.js
  98. +7 −0 BlueCal/public/js/jquery-1.3.min.js
  99. +4 −0 BlueCal/public/js/rho.js
  100. +59 −0 BlueCal/public/js/rhogeolocation-wm.js
  101. +11 −0 BlueCal/public/js/rhogeolocation.js
  102. +32 −0 BlueCal/rhoconfig.txt
View
@@ -0,0 +1,28 @@
+require 'yaml'
+
+unless File.exists? "build.yml"
+ puts "Cannot find build.yml"
+ exit 1
+end
+
+
+$app_config = YAML::load_file("build.yml")
+$app_path = File.expand_path(File.dirname(__FILE__))
+
+if ENV["RHO_HOME"].nil?
+ rakefilepath = "#{$app_config["sdk"]}/Rakefile"
+else
+ rakefilepath = "#{ENV["RHO_HOME"]}/Rakefile"
+end
+
+unless File.exists? rakefilepath
+ puts "\nCannot find your Rhodes gem or source path: #{rakefilepath}"
+ puts "\nIf you have the sdk on your path or have installed the gem this"
+ puts "can be resolved by running 'set-rhodes-sdk'"
+ puts "\nYou can also set this manually by modifying your build.yml or"
+ puts "setting the environment variable RHO_HOME"
+ exit 1
+end
+
+load rakefilepath
+
View
@@ -0,0 +1,10 @@
+# The model has already been created by the framework, and extends Rhom::RhomObject
+# You can add more methods here
+class Cal
+ include Rhom::PropertyBag
+
+ # Uncomment the following line to enable sync with Cal.
+ # enable :sync
+
+ #add model specifc code here
+end
@@ -0,0 +1,211 @@
+require 'rho/rhocontroller'
+require 'helpers/browser_helper'
+require 'rho/rhoevent.rb'
+require 'rho/rhobluetooth'
+
+require 'date'
+
+class CalController < Rho::RhoController
+ include BrowserHelper
+ MONTHS = ["January", "February", "March", "April", "May", "June", "July", "August", "September","October","November","December"]
+
+ def event_on_day?(day)
+ @@events.each do |e|
+ eventday = Date.civil(e['start_date'].year,e['start_date'].mon,e['start_date'].day)
+ return true if eventday == day
+ end
+ false
+ end
+
+ def events_for_day(day)
+ events = []
+ @@events.each do |e|
+ eventday = Date.civil(e['start_date'].year,e['start_date'].mon,e['start_date'].day)
+ events << e if eventday == day
+ end
+ events
+ end
+
+ def class_for_day(day)
+ klass = ""
+ if event_on_day? day
+ klass= 'class="date_has_event"'
+ else
+ klass= 'class="today"' if Date.today == day
+ end
+ klass
+ end
+
+ def text_for_day(day)
+ text = day.mday.to_s
+ if event_on_day? day
+ text << '<div class="events"><ul>'
+ events_for_day(day).each do |e|
+ text << "<li><span class=\"title\">#{e['title']} at #{e['start_date'].strftime("%I:%M%p")}</span>"
+ text << "<span class=\"desc\">#{e['notes']}</span>"
+ text << "<span><input style=\"font-size:20px;\" type=\"submit\" value=\"Send Meeting\" onclick=\"javascript:window.location='#{url_for :action => 'send_day', :id => e['id']}';\"/></span></li>"
+ end
+ text << '</ul></div>'
+ end
+ text
+ end
+
+ def gencal(month,year)
+
+
+ first = Date.civil(year, month, 1)
+ last = Date.civil(year, month, -1)
+ today = Date.today
+ cal = ""
+ day = first
+
+ @@events = Rho::RhoEvent.find(:all, :start_date => first, :end_date => last, :find_type => 'starting',
+ :include_repeating => true)
+
+
+ #first week
+ cal << "<tr>\n"
+ cal << "<td class=\"padding\" colspan=\"#{first.cwday - 1}\"></td>\n"
+ (8-first.cwday).times do |x|
+
+ cal << "<td #{class_for_day(day)}>#{text_for_day(day)}</td>\n"
+ day = day + 1
+ end
+ cal << "</tr>"
+ oweek = day.cweek
+ cal << "<tr>"
+ while day.mday <= last.mday && day.mon == last.mon do
+ if day.cweek != oweek
+ cal <<"</tr><tr>"
+ oweek = day.cweek
+ end
+
+ cal << "<td #{class_for_day(day)}>#{text_for_day(day)}</td>\n"
+ day = day + 1
+ end
+ cal << "<td class=\"padding\" colspan=\"#{7- last.cwday}\"></td>\n" if last.cwday < 7
+ cal << "</tr>"
+ cal
+ end
+
+ #GET /Cal
+ def index
+ @month = 10
+ @caltext = gencal(10,2010)
+ @cals = Cal.find(:all)
+ render
+ end
+
+ @@connected_device = ""
+ @@id_to_send = nil
+ @@sender = false
+ def send_day
+ @@sender = true
+ @@id_to_send = @params["id"]
+ if Rho::BluetoothManager.is_bluetooth_available then
+ Rho::BluetoothManager.set_device_name('BlueCal Sender')
+ Rho::BluetoothManager.create_session(Rho::BluetoothManager::ROLE_SERVER, url_for( :action => :connection_callback))
+ end
+ render
+ end
+
+ def receive_day
+ if Rho::BluetoothManager.is_bluetooth_available then
+ Rho::BluetoothManager.set_device_name('BlueCal')
+ Rho::BluetoothManager.create_session(Rho::BluetoothManager::ROLE_CLIENT, url_for( :action => :connection_callback))
+ end
+ render :action => :send_day
+ end
+
+ def connection_callback
+ if @params['status'] == Rho::BluetoothManager::OK
+ @@connected_device = @params['connected_device_name']
+ puts "CONNECTED: " + @@connected_device
+ Rho::BluetoothSession.set_callback(@@connected_device, url_for( :action => :session_callback))
+ if @@sender
+ puts "id to send: #{@@id_to_send}"
+ @@events.each do |e|
+ puts "id: #{e['id']}"
+ if "{#{e['id']}}" == @@id_to_send
+ str = Rho::RhoSupport.url_encode(Marshal.dump(e))
+ Rho::BluetoothSession.write_string(@@connected_device, str)
+ break
+ end
+ end
+ end
+ end
+ WebView.navigate(url_for :action => :index)
+ end
+
+
+
+ def session_callback
+ puts "SESSION CALLBACK"
+ unless @@sender
+ if @params['connected_device_name'] == @@connected_device
+ if @params['event_type'] == Rho::BluetoothSession::SESSION_INPUT_DATA_RECEIVED
+ puts "DATA RECEIVE"
+ while Rho::BluetoothSession.get_status(@@connected_device) > 0
+ str = Rho::BluetoothSession.read_string(@@connected_device)
+ puts "GOT STRING: #{str}"
+ e = Marshal.load(Rho::RhoSupport.url_decode(str))
+ puts "E: #{e.inspect}"
+ e['id'] = nil
+ Rho::RhoEvent.create!(e)
+ Alert.show_popup("Added: " + e['title'])
+ WebView.navigate(url_for :action => :index)
+
+ # use readed string
+
+ end
+ end
+ end
+
+ end
+ end
+ # GET /Cal/{1}
+ def show
+ @cal = Cal.find(@params['id'])
+ if @cal
+ render :action => :show
+ else
+ redirect :action => :index
+ end
+ end
+
+ # GET /Cal/new
+ def new
+ @cal = Cal.new
+ render :action => :new
+ end
+
+ # GET /Cal/{1}/edit
+ def edit
+ @cal = Cal.find(@params['id'])
+ if @cal
+ render :action => :edit
+ else
+ redirect :action => :index
+ end
+ end
+
+ # POST /Cal/create
+ def create
+ @cal = Cal.create(@params['cal'])
+ redirect :action => :index
+ end
+
+ # POST /Cal/{1}/update
+ def update
+ @cal = Cal.find(@params['id'])
+ @cal.update_attributes(@params['cal']) if @cal
+ redirect :action => :index
+ end
+
+ # POST /Cal/{1}/delete
+ def delete
+ @cal = Cal.find(@params['id'])
+ @cal.destroy if @cal
+ redirect :action => :index
+ end
+end
@@ -0,0 +1,24 @@
+<div id="pageTitle">
+ <h1>Edit <%= @cal.name%></h1>
+</div>
+
+<div id="toolbar">
+ <%= link_to "Back", :action => :show, :id => @cal.object %>
+ <%= link_to "Delete", :action => :delete, :id => @cal.object %>
+</div>
+
+
+<div id="content">
+ <form method="POST" action="<%= url_for :action => :update %>">
+ <input type="hidden" name="id" value="<%= @cal.object %>"/>
+ <table>
+
+ <tr>
+ <td class="itemLabel">Name: </td>
+ <td class="itemValue"><input type="text" name="cal[name]" value="<%= @cal.name %>"/></td>
+ </tr>
+
+ </table>
+ <input type="submit" class="standardButton" value="Update" />
+ </form>
+</div>
View
@@ -0,0 +1,27 @@
+<div class="pageTitle">
+ <h1>Edit <%= @cal.name %></h1>
+</div>
+
+<div class="toolbar">
+ <div class="leftItem backButton">
+ <a href="<%= url_for :action => :show, :id => @cal.object %>">Cancel</a>
+ </div>
+ <div class="rightItem regularButton">
+ <a class="button" href="<%= url_for :action => :delete, :id => @cal.object %>">Delete</a>
+ </div>
+</div>
+
+<div class="content">
+ <form method="POST" action="<%= url_for :action => :update %>">
+ <input type="hidden" name="id" value="<%= @cal.object %>"/>
+ <ul>
+
+ <li>
+ <label for="cal[name]" class="fieldLabel">Name</label>
+ <input type="text" name="cal[name]" value="<%= @cal.name %>" <%= placeholder( "Name" ) %> />
+ </li>
+
+ </ul>
+ <input type="submit" class="standardButton" value="Update"/>
+ </form>
+</div>
@@ -0,0 +1,21 @@
+<div id="pageTitle">
+ <h1>Cals</h1>
+</div>
+
+
+<div id="toolbar">
+ <%= link_to "New", :action => :new %>
+ <%= link_to "Home", RhoConfig::start_path %>
+</div>
+
+<div id="content">
+ <table>
+ <tr>
+ <% @cals.each do |obj| %>
+
+ <td class="recordLabel"><%= link_to "#{obj.name}", :action => :show, :id => obj.object %></td>
+
+ <% end %>
+ </tr>
+ </table>
+</div>
View
@@ -0,0 +1,20 @@
+<h1><%= CalController::MONTHS[@month-1]%></h1>
+<table cellspacing="0">
+ <thead>
+ <tr>
+ <th>Mon</th><th>Tue</th><th>Wed</th>
+ <th>Thu</th><th>Fri</th><th>Sat</th>
+ <th>Sun</th>
+ </tr>
+ </thead>
+ <tbody>
+<%=@caltext%>
+ </tbody>
+ <tfoot>
+ <th>Mon</th><th>Tue</th><th>Wed</th>
+ <th>Thu</th><th>Fri</th><th>Sat</th>
+ <th>Sun</th>
+ </tfoot>
+</table>
+<br/>
+<input style="font-size:20px;" type="submit" value="Recieve Meeting" onclick="javascript:window.location='<%= url_for :action => 'receive_day'%>';"/>
View
@@ -0,0 +1,24 @@
+<div id="pageTitle">
+ <h1>New Cal</h1>
+</div>
+
+<div id="toolbar">
+ <%= link_to "Back", :action => :index %>
+</div>
+
+
+<div id="content">
+
+ <form method="POST" action="<%= url_for :action => :create %>">
+ <input type="hidden" name="id" value="<%= @cal.object %>"/>
+ <table>
+
+ <tr>
+ <td class="itemLabel">Name: </td>
+ <td class="itemValue"><input type="text" name="cal[name]"/></td>
+ </tr>
+
+ </table>
+ <input type="submit" class="standardButton" value="Create" />
+ </form>
+</div>
Oops, something went wrong.

0 comments on commit fc60f83

Please sign in to comment.