Permalink
Browse files

Merge pull request #7032 from dscravag/nightly2

Nightly 2012-12-17
  • Loading branch information...
2 parents 16006ea + 1711341 commit df14f48088e107a180811ff73357e76e95acf776 @dscravag dscravag committed Dec 17, 2012
Showing with 1,622 additions and 1,922 deletions.
  1. +4 −2 Makefile
  2. +35 −7 apps/calendar/js/app.js
  3. +74 −5 apps/calendar/js/controllers/alarm.js
  4. +4 −0 apps/calendar/js/controllers/sync.js
  5. +454 −373 apps/calendar/js/ext/ical.js
  6. +12 −5 apps/calendar/js/service/caldav.js
  7. +20 −1 apps/calendar/js/store/setting.js
  8. +3 −1 apps/calendar/js/template.js
  9. +85 −0 apps/calendar/test/unit/app_test.js
  10. +109 −1 apps/calendar/test/unit/controllers/alarm_test.js
  11. +5 −0 apps/calendar/test/unit/controllers/sync_test.js
  12. +5 −2 apps/calendar/test/unit/service/caldav_test.js
  13. +5 −0 apps/calendar/test/unit/template_test.js
  14. +68 −34 apps/clock/js/onring.js
  15. +2 −2 apps/clock/style/clock.css
  16. +1 −1 apps/communications/contacts/fb_import.html
  17. +1 −1 apps/communications/contacts/fb_link.html
  18. +9 −3 apps/communications/contacts/js/fb/fb_import.js
  19. +4 −1 apps/communications/contacts/js/fb/fb_link.js
  20. +9 −6 apps/communications/contacts/js/fb/friends_list.js
  21. +8 −5 apps/communications/contacts/js/fb_extensions.js
  22. +65 −31 apps/communications/contacts/js/utilities/image_loader.js
  23. +6 −6 apps/communications/contacts/js/utilities/templates.js
  24. +6 −4 apps/communications/dialer/js/oncall.js
  25. +9 −1 apps/communications/facebook/js/curtain.js
  26. BIN apps/communications/ftu/css/images/import_fb.png
  27. BIN apps/communications/ftu/css/images/import_sim.png
  28. +11 −1 apps/communications/ftu/css/style.css
  29. +23 −22 apps/communications/ftu/index.html
  30. +1 −1 apps/communications/ftu/js/navigation.js
  31. +7 −7 apps/communications/ftu/locales/ftu.en-US.properties
  32. +3 −0 apps/gallery/index.html
  33. +133 −103 apps/gallery/js/gallery.js
  34. +33 −0 apps/gallery/style/gallery.css
  35. BIN apps/gallery/style/images/spinner.png
  36. +23 −21 apps/homescreen/everything.me/modules/BackgroundImage/BackgroundImage.js
  37. +5 −4 apps/homescreen/js/homescreen.js
  38. +1 −1 apps/homescreen/js/page.js
  39. +2 −2 apps/settings/index.html
  40. +3 −0 apps/settings/js/simcard_dialog.js
  41. +0 −27 apps/settings/js/simcard_unlock.js
  42. +3 −0 apps/settings/js/utils.js
  43. +0 −8 apps/settings/manifest.webapp
  44. +0 −88 apps/settings/unlock_simpin.html
  45. +19 −0 apps/sms/js/sms.js
  46. +4 −0 apps/sms/style/sms.css
  47. +20 −6 apps/system/js/app_install_manager.js
  48. +14 −41 apps/system/js/attention_screen.js
  49. +6 −2 apps/system/js/battery_manager.js
  50. +3 −1 apps/system/js/updatable.js
  51. +2 −2 apps/system/js/value_selector/value_picker.js
  52. +76 −22 apps/system/js/window_manager.js
  53. +3 −1 apps/system/locales/system.en-US.properties
  54. +1 −0 apps/system/style/lockscreen/lockscreen.css
  55. +73 −71 apps/system/test/unit/app_install_manager_test.js
  56. +1 −1 apps/system/test/unit/mock_app.js
  57. +17 −1 build/webapp-manifests.js
  58. +0 −977 shared/js/media_db.js
  59. +115 −18 shared/js/mediadb.js
  60. +17 −2 shared/js/visibility_monitor.js
View
@@ -604,8 +604,10 @@ reset-gaia: purge install-gaia install-settings-defaults
# remove the memories and apps on the phone
purge:
$(ADB) shell stop b2g
- $(ADB) shell rm -r $(MSYS_FIX)/data/local/*
- $(ADB) shell mkdir -p $(MSYS_FIX)/data/local/tmp
+ @(for FILE in `$(ADB) shell ls $(MSYS_FIX)/data/local | tr -d '\r'`; \
+ do \
+ [ $$FILE != 'tmp' ] && $(ADB) shell rm -r $(MSYS_FIX)/data/local/$$FILE; \
+ done);
$(ADB) shell rm -r $(MSYS_FIX)/cache/*
$(ADB) shell rm -r $(MSYS_FIX)/data/b2g/*
$(ADB) shell rm -r $(MSYS_FIX)$(GAIA_INSTALL_PARENT)/webapps
View
@@ -8,6 +8,12 @@ Calendar.App = (function(window) {
* location to reference database.
*/
var App = {
+ //XXX: always assumes that app is never lazy loaded
+ startingURL: window.location.href,
+
+ _location: window.location,
+
+ _mozTimeRefreshTimeout: 3000,
// Dependency map for loading
cssBase: '/style/',
@@ -97,6 +103,16 @@ Calendar.App = (function(window) {
},
/**
+ * Internally restarts the application.
+ */
+ forceRestart: function() {
+ if (!this.restartPending) {
+ this.restartPending = true;
+ this._location.href = this.startingURL;
+ }
+ },
+
+ /**
* Navigates app to a new location.
*
* @param {String} url new view url.
@@ -368,13 +384,25 @@ Calendar.App = (function(window) {
}
};
+ // Restart the calendar when the timezone changes.
+ // We do this on a timer because this event may fire
+ // many times. Refreshing the url of the calendar frequently
+ // can result in crashes so we attempt to do this only after
+ // the user has completed their selection.
+ var _changeTimerId;
+ window.addEventListener('moztimechange', function onMozTimeChange() {
+ clearTimeout(_changeTimerId);
+
+ _changeTimerId = setTimeout(function() {
+ App.forceRestart();
+ }, App._mozTimeRefreshTimeout);
+ });
+
+ window.addEventListener('load', function onLoad() {
+ window.removeEventListener('load', onLoad);
+ App.init();
+ });
+
return App;
}(this));
-
-window.addEventListener('load', function onLoad() {
- window.removeEventListener('load', onLoad);
-
- Calendar.App.init();
-});
-
@@ -5,6 +5,7 @@ Calendar.ns('Controllers').Alarm = (function() {
function Alarm(app) {
this.app = app;
this.store = app.store('Alarm');
+ this.settings = app.store('Setting');
}
Alarm.prototype = {
@@ -14,6 +15,17 @@ Calendar.ns('Controllers').Alarm = (function() {
observe: function() {
var self = this;
+ this._wifiLock = null;
+ this.app.syncController.on('syncComplete', function() {
+ if (self._wifiLock !== null)
+ self._wifiLock.unlock();
+ });
+
+ this._nextPeriodicSync = this.settings.syncAlarm;
+
+ if (this._nextPeriodicSync.alarmId === null)
+ this._resetSyncAlarm(false);
+
if (navigator.mozSetMessageHandler) {
debug('set message handler');
navigator.mozSetMessageHandler('alarm', function(msg) {
@@ -22,15 +34,21 @@ Calendar.ns('Controllers').Alarm = (function() {
} else {
debug('mozSetMessageHandler is mising!');
}
+
+ this.settings.on('syncFrequencyChange', function() {
+ self._resetSyncAlarm(false);
+ });
},
handleAlarmMessage: function(message) {
debug('got message', message);
- // XXX: this method only wraps handleAlarm
- // right now because period sync is not implemented.
- // In the future we could have many types of system
- // messages related to alarms and we handle them here.
- this.handleAlarm(message.data);
+ switch (message.data.type) {
+ case 'sync':
+ this._handleSyncMessage();
+ break;
+ default:
+ this.handleAlarm(message.data);
+ }
},
_sendAlarmNotification: function(alarm, event, busytime) {
@@ -131,6 +149,57 @@ Calendar.ns('Controllers').Alarm = (function() {
busytimeStore.get(alarm.busytimeId, trans, function(err, record) {
busytime = record;
});
+ },
+
+ /**
+ * Resets or sets the periodic sync alarm
+ *
+ * @param {Boolean} triggered indicates that the alarm fired.
+ */
+ _resetSyncAlarm: function(triggered) {
+ if (this._nextPeriodicSync.alarmId) {
+ navigator.mozAlarms.remove(this._nextPeriodicSync.alarmId);
+ this._nextPeriodicSync.alarmId = null;
+ }
+
+ var duration = this.settings.syncFrequency;
+ if (duration === null) {
+ this.settings.set('syncAlarm', this._nextPeriodicSync);
+ return;
+ }
+ duration *= 60 * 1000; // Convert minutes to milliseconds
+
+ var start = new Date();
+ var end = new Date(start.getTime() + duration);
+
+ // We're resetting the sync alarm after a settings change and times are still in range
+ if (!triggered &&
+ this._nextPeriodicSync.end > start &&
+ this._nextPeriodicSync.start.getTime() + duration > start) {
+ start = this._nextPeriodicSync.start;
+ end = new Date(start.getTime() + duration);
+ }
+
+ var request = navigator.mozAlarms.add(end, 'ignoreTimezone', {type: 'sync'});
+ var self = this;
+ request.onsuccess = function(e) {
+ self._nextPeriodicSync.alarmId = e.target.result;
+ self._nextPeriodicSync.start = start;
+ self._nextPeriodicSync.end = end;
+ self.settings.set('syncAlarm', self._nextPeriodicSync)
+ };
+ request.onerror = function(e) {
+ debug('Error setting alarm:', e.target.error.name);
+ };
+ },
+
+ /**
+ * Handles an sync alarm firing
+ */
+ _handleSyncMessage: function() {
+ this._wifiLock = navigator.requestWakeLock('wifi');
+ this.app.syncController.all();
+ this._resetSyncAlarm(true);
}
};
@@ -46,6 +46,10 @@ Calendar.ns('Controllers').Sync = (function() {
for (var key in account.cached) {
this.account(account.cached[key]);
}
+
+ // If we have nothing to sync
+ if (!this.pending)
+ this.emit('syncComplete');
},
/**
Oops, something went wrong.

0 comments on commit df14f48

Please sign in to comment.