Ejemplo n.º 1
0
	def get_credentials(self):
		store = oauth2client.file.Storage(os.path.join(utils.userpath, 'calendar-quickstart'+utils.username+'.json'))		
		credentials = store.get()
		if not credentials or credentials.invalid:
			print "2"
			client_id = '987683463712-se9dhv6gteobsmlpkgvqptub59fajuiq.apps.googleusercontent.com'
			print "3"
			client_secret = os.path.join(utils.addonpath,'client_secret.json')
			print "4"
			scope = 'https://www.googleapis.com/auth/calendar'
			redirect_uri='urn:ietf:wg:oauth:2.0:oob'
			flow = oauth2client.client.flow_from_clientsecrets(client_secret, scope, redirect_uri)
			auth_uri = flow.step1_get_authorize_url()
			webbrowser.open(auth_uri)
			auth_code = utils.getKeyboardResults("", 'Code')
			credentials = flow.step2_exchange(auth_code)
			store.put(credentials)
		return credentials
Ejemplo n.º 2
0
	def onControl(self, control):
		# Change the selected control info
		self.change_selection(control)
		
		value = self.control_to_data[control.getId()]
		
		ctrl_data = self.control_to_data[control.getId()]
		if ctrl_data != None and type(ctrl_data) is utils.Data:
			if ctrl_data.type == utils.CONTROL_TYPE_EVENT_SUMMARY:
				self.event['summary'] = utils.getKeyboardResults(control.getLabel(), 'Task Summary')
				control.setLabel(self.event['summary'])
				
			if ctrl_data.type == utils.CONTROL_TYPE_EVENT_DESCRIPTION:
				self.event['description'] = utils.getKeyboardResults(control.getLabel(), 'Task Description')
				control.setLabel(self.event['description'])
				
			if ctrl_data.type == utils.CONTROL_TYPE_TIMEZONE:
				dialog = timezoneselection.TimezoneDialog(utils.addon.getSetting('timezone'))
				dialog.doModal()
				if dialog.selected != None:
					self.event['start']['timeZone'] = dialog.selected
					self.event['end']['timeZone'] = dialog.selected
					control.setLabel(dialog.selected)
				
			if  ctrl_data.type == utils.CONTROL_TYPE_EVENT_LOCATION:
				self.event['location'] = utils.getKeyboardResults(control.getLabel(), 'Task Location')
				control.setLabel(self.event['location'])
				
			if value.type =='start_day':
				dialog = dayselection.DaySelectionDialog(utils.formatDateTime(self.event, 'start'))
				dialog.doModal()
		
				control.setLabel(str(dialog.selection_date))
				self.event['start']['dateTime']= utils.formatDateTime_get_iso(dialog.selection_date)
				
			if value.type =='end_day':
				dialog = dayselection.DaySelectionDialog(utils.formatDateTime(self.event, 'end'))
				dialog.doModal()
				
				control.setLabel(str(dialog.selection_date))
				self.event['end']['dateTime']= utils.formatDateTime_get_iso(dialog.selection_date)
			
			if ctrl_data.type == utils.CONTROL_TYPE_ACTION:
				if ctrl_data.value == utils.CONTROL_VALUE_ACTION_DELETE:
					self.calCon.deleteEvent(self.event)
					self.close()
					
				if ctrl_data.value == utils.CONTROL_VALUE_ACTION_OK:
					print str(self.event)
					if 'timeZone' in self.event['start'] and self.event['start']['timeZone'] in pytz.all_timezones and self.event['end']['timeZone'] in pytz.all_timezones:
						if self.is_new:
							self.calCon.createEvent(self.event)
						else:
							self.calCon.updateEvent(self.event)
						
						self.close()
					
					else:
						utils.message("You must select time zone from the list of timezones")
					
				if ctrl_data.value == utils.CONTROL_VALUE_ACTION_CANCEL:
					self.close()
					
			if value.type == "action" and value.value == "cancel":
				self.close()