Esempio n. 1
0
	def _add_mount(self, widget, data=None):
		"""Present dialog to user for creating a new mount"""
		keyring_manager = self._parent._application.keyring_manager

		# create dialog and get response from user
		dialog = DavInputDialog(self._window)
		dialog.set_keyring_available(keyring_manager.is_available())
		response = dialog.get_response()

		if response[0] == gtk.RESPONSE_OK:
			name = response[1][DavResult.NAME]
			uri = self.__form_uri(
				response[1][DavResult.SERVER],
				response[1][DavResult.SERVER_TYPE],
				response[1][DavResult.USERNAME],
				response[1][DavResult.DIRECTORY]
			)
			requires_login = response[1][DavResult.PASSWORD] != ''

			if requires_login:
				if keyring_manager.is_available():
					try:
						# prepare attributes
						attributes = {
						'server': uri,
						'user': response[1][DavResult.USERNAME]
						}
						# first, try to store password with keyring
						keyring_manager.store_password(
							name,
							response[1][DavResult.PASSWORD],
							attributes,
							entry_type=EntryType.NETWORK
						)

					except KeyringCreateError:
						# show error message
						print "Keyring create error, we need it to store this option"

					else:
						# store entry
						self.__store_mount(response[1], uri)

				else:
					# show error message
					print "Keyring is not available but it's needed!"

			else:
				# no login required, just store
				self.__store_mount(response[1], uri)

			# save mounts to config file
			self.__save_list()
Esempio n. 2
0
    def _add_mount(self, widget, data=None):
        """Present dialog to user for creating a new mount"""
        keyring_manager = self._parent._application.keyring_manager

        # create dialog and get response from user
        dialog = DavInputDialog(self._window)
        dialog.set_keyring_available(keyring_manager.is_available())
        response = dialog.get_response()

        if response[0] == gtk.RESPONSE_OK:
            name = response[1][DavResult.NAME]
            uri = self.__form_uri(response[1][DavResult.SERVER],
                                  response[1][DavResult.SERVER_TYPE],
                                  response[1][DavResult.USERNAME],
                                  response[1][DavResult.DIRECTORY])
            requires_login = response[1][DavResult.PASSWORD] != ''

            if requires_login:
                if keyring_manager.is_available():
                    try:
                        # prepare attributes
                        attributes = {
                            'server': uri,
                            'user': response[1][DavResult.USERNAME]
                        }
                        # first, try to store password with keyring
                        keyring_manager.store_password(
                            name,
                            response[1][DavResult.PASSWORD],
                            attributes,
                            entry_type=EntryType.NETWORK)

                    except KeyringCreateError:
                        # show error message
                        print "Keyring create error, we need it to store this option"

                    else:
                        # store entry
                        self.__store_mount(response[1], uri)

                else:
                    # show error message
                    print "Keyring is not available but it's needed!"

            else:
                # no login required, just store
                self.__store_mount(response[1], uri)

            # save mounts to config file
            self.__save_list()
Esempio n. 3
0
	def _edit_mount(self, widget, data=None):
		"""Present dialog to user for editing existing mount"""
		keyring_manager = self._parent._application.keyring_manager
		selection = self._list.get_selection()
		item_list, selected_iter = selection.get_selected()

		if selected_iter is not None:
			dialog = DavInputDialog(self._window)
			old_name = item_list.get_value(selected_iter, DavColumn.NAME)

			# set dialog parameters
			dialog.set_keyring_available(keyring_manager.is_available())
			dialog.set_name(old_name)
			dialog.set_server(item_list.get_value(selected_iter, DavColumn.SERVER))
			dialog.set_directory(item_list.get_value(selected_iter, DavColumn.DIRECTORY))
			dialog.set_username(item_list.get_value(selected_iter, DavColumn.USERNAME))

			# show editing dialog
			response = dialog.get_response()

			if response[0] == gtk.RESPONSE_OK:
				new_name = response[1][DavResult.NAME]

				# modify list store
				item_list.set_value(selected_iter, DavColumn.NAME, new_name)
				item_list.set_value(selected_iter, DavColumn.SERVER, response[1][DavResult.SERVER])
				item_list.set_value(selected_iter, DavColumn.SERVER_TYPE, response[1][DavResult.SERVER_TYPE])
				item_list.set_value(selected_iter, DavColumn.DIRECTORY, response[1][DavResult.DIRECTORY])
				item_list.set_value(selected_iter, DavColumn.USERNAME, response[1][DavResult.USERNAME])

				# rename entry if needed
				if new_name != old_name:
					keyring_manager.rename_entry(old_name, new_name)

				# form URI
				uri = self.__form_uri(
					response[1][DavResult.SERVER],
					response[1][DavResult.SERVER_TYPE],
					response[1][DavResult.USERNAME],
					response[1][DavResult.DIRECTORY]
				)

				item_list.set_value(selected_iter, DavColumn.URI, uri)

				# save changes
				self.__save_list()
Esempio n. 4
0
    def _edit_mount(self, widget, data=None):
        """Present dialog to user for editing existing mount"""
        keyring_manager = self._parent._application.keyring_manager
        selection = self._list.get_selection()
        item_list, selected_iter = selection.get_selected()

        if selected_iter is not None:
            dialog = DavInputDialog(self._window)
            old_name = item_list.get_value(selected_iter, DavColumn.NAME)

            # set dialog parameters
            dialog.set_keyring_available(keyring_manager.is_available())
            dialog.set_name(old_name)
            dialog.set_server(
                item_list.get_value(selected_iter, DavColumn.SERVER))
            dialog.set_directory(
                item_list.get_value(selected_iter, DavColumn.DIRECTORY))
            dialog.set_username(
                item_list.get_value(selected_iter, DavColumn.USERNAME))

            # show editing dialog
            response = dialog.get_response()

            if response[0] == gtk.RESPONSE_OK:
                new_name = response[1][DavResult.NAME]

                # modify list store
                item_list.set_value(selected_iter, DavColumn.NAME, new_name)
                item_list.set_value(selected_iter, DavColumn.SERVER,
                                    response[1][DavResult.SERVER])
                item_list.set_value(selected_iter, DavColumn.SERVER_TYPE,
                                    response[1][DavResult.SERVER_TYPE])
                item_list.set_value(selected_iter, DavColumn.DIRECTORY,
                                    response[1][DavResult.DIRECTORY])
                item_list.set_value(selected_iter, DavColumn.USERNAME,
                                    response[1][DavResult.USERNAME])

                # rename entry if needed
                if new_name != old_name:
                    keyring_manager.rename_entry(old_name, new_name)

                # form URI
                uri = self.__form_uri(response[1][DavResult.SERVER],
                                      response[1][DavResult.SERVER_TYPE],
                                      response[1][DavResult.USERNAME],
                                      response[1][DavResult.DIRECTORY])

                item_list.set_value(selected_iter, DavColumn.URI, uri)

                # save changes
                self.__save_list()