コード例 #1
0
    def signal_notebook_switch_page(self, notebook, current_page, index):
        previous_page = notebook.get_nth_page(self.last_page_id)
        self.last_page_id = index
        config_tab = self.tabs.get('config')
        edit_tab = self.tabs.get('edit')
        preview_tab = self.tabs.get('preview')

        if config_tab and previous_page == config_tab.box:
            config_tab.objects_save_to_config()
        elif edit_tab and previous_page == edit_tab.box:
            for _ in xrange(1):
                html_file = self.config.get('mailer.html_file')
                if not html_file:
                    break
                text = edit_tab.textbuffer.get_text(
                    edit_tab.textbuffer.get_start_iter(),
                    edit_tab.textbuffer.get_end_iter(), False)
                if not text:
                    break
                old_text = open(html_file, 'r').read()
                if old_text == text:
                    break
                if not gui_utilities.show_dialog_yes_no(
                        'Save HTML the file?', self.parent):
                    break
                html_file_h = open(html_file, 'w')
                html_file_h.write(text)
                html_file_h.close()

        if config_tab and current_page == config_tab.box:
            config_tab.objects_load_from_config()
        if edit_tab and current_page == edit_tab.box:
            html_file = self.config.get('mailer.html_file')
            if not (html_file and os.path.isfile(html_file)
                    and os.access(html_file, os.R_OK)):
                edit_tab.button_save_html_file.set_sensitive(False)
                edit_tab.textview.set_property('editable', False)
                return
            edit_tab.button_save_html_file.set_sensitive(True)
            edit_tab.textview.set_property('editable', True)
            with open(html_file, 'rb') as file_h:
                html_data = file_h.read()
            html_data = str(html_data.decode('utf-8', 'ignore'))
            edit_tab.textbuffer.set_text(html_data)
        elif preview_tab and current_page == preview_tab.box:
            html_file = self.config.get('mailer.html_file')
            if not (html_file and os.path.isfile(html_file)
                    and os.access(html_file, os.R_OK)):
                return
            with open(html_file, 'rb') as file_h:
                html_data = file_h.read()
            html_data = str(html_data.decode('utf-8', 'ignore'))
            html_data = mailer.format_message(html_data, self.config)
            html_file_uri = urllib.parse.urlparse(html_file, 'file').geturl()
            if not html_file_uri.startswith('file://'):
                html_file_uri = 'file://' + html_file_uri
            preview_tab.webview.load_html_string(html_data, html_file_uri)
コード例 #2
0
ファイル: mail.py プロジェクト: coldfusion39/king-phisher
	def load_html_file(self):
		"""
		Load the configured HTML file into the WebKit engine so the contents can
		be previewed.
		"""
		html_file = self.config.get('mailer.html_file')
		if not (html_file and os.path.isfile(html_file) and os.access(html_file, os.R_OK)):
			return
		with codecs.open(html_file, 'r', encoding='utf-8') as file_h:
			html_data = file_h.read()
		html_data = mailer.format_message(html_data, self.config)
		html_file_uri = urllib.parse.urlparse(html_file, 'file').geturl()
		self.load_html_data(html_data, html_file_uri)
コード例 #3
0
	def load_html_file(self):
		html_file = self.config.get('mailer.html_file')
		if not (html_file and os.path.isfile(html_file) and os.access(html_file, os.R_OK)):
			return
		with codecs.open(html_file, 'r', encoding='utf-8') as file_h:
			html_data = file_h.read()
		html_data = mailer.format_message(html_data, self.config)
		html_file_uri = urllib.parse.urlparse(html_file, 'file').geturl()
		if not html_file_uri.startswith('file://'):
			html_file_uri = 'file://' + html_file_uri
		if has_webkit2:
			self.webview.load_html(html_data, html_file_uri)
		else:
			self.webview.load_html_string(html_data, html_file_uri)
コード例 #4
0
 def load_html_file(self):
     html_file = self.config.get('mailer.html_file')
     if not (html_file and os.path.isfile(html_file)
             and os.access(html_file, os.R_OK)):
         return
     with codecs.open(html_file, 'r', encoding='utf-8') as file_h:
         html_data = file_h.read()
     html_data = mailer.format_message(html_data, self.config)
     html_file_uri = urllib.parse.urlparse(html_file, 'file').geturl()
     if not html_file_uri.startswith('file://'):
         html_file_uri = 'file://' + html_file_uri
     if has_webkit2:
         self.webview.load_html(html_data, html_file_uri)
     else:
         self.webview.load_html_string(html_data, html_file_uri)
コード例 #5
0
ファイル: mail.py プロジェクト: baubaubau/king-phisher
	def show_tab(self):
		"""Configure the webview to preview the the message HTML file."""
		html_file = self.config.get('mailer.html_file')
		if not (html_file and os.path.isfile(html_file) and os.access(html_file, os.R_OK)):
			return
		with open(html_file, 'rb') as file_h:
			html_data = file_h.read()
		html_data = str(html_data.decode('utf-8', 'ignore'))
		html_data = mailer.format_message(html_data, self.config)
		html_file_uri = urllib.parse.urlparse(html_file, 'file').geturl()
		if not html_file_uri.startswith('file://'):
			html_file_uri = 'file://' + html_file_uri
		if has_webkit2:
			self.webview.load_html(html_data, html_file_uri)
		else:
			self.webview.load_html_string(html_data, html_file_uri)
コード例 #6
0
	def _tab_changed(self, notebook, current_page, index):
		previous_page = notebook.get_nth_page(self.last_page_id)
		self.last_page_id = index
		config_tab = self.tabs.get('config')
		edit_tab = self.tabs.get('edit')
		preview_tab = self.tabs.get('preview')
		progress_tab = self.tabs.get('progress')

		if config_tab and previous_page == config_tab.box:
			config_tab.objects_save_to_config()
		elif edit_tab and previous_page == edit_tab.box:
			for i in xrange(1):
				html_file = self.config.get('mailer.html_file')
				if not html_file:
					break
				text = edit_tab.textbuffer.get_text(edit_tab.textbuffer.get_start_iter(), edit_tab.textbuffer.get_end_iter(), False)
				if not text:
					break
				old_text = open(html_file, 'r').read()
				if old_text == text:
					break
				if not gui_utilities.show_dialog_yes_no("Save HTML File?", self.parent):
					break
				html_file_h = open(html_file, 'w')
				html_file_h.write(text)
				html_file_h.close()

		if config_tab and current_page == config_tab.box:
			config_tab.objects_load_from_config()
		if edit_tab and current_page == edit_tab.box:
			html_file = self.config.get('mailer.html_file')
			if not (html_file and os.path.isfile(html_file) and os.access(html_file, os.R_OK)):
				edit_tab.button_save_html_file.set_sensitive(False)
				edit_tab.textview.set_property('editable', False)
				return
			edit_tab.button_save_html_file.set_sensitive(True)
			edit_tab.textview.set_property('editable', True)
			edit_tab.textbuffer.set_text(open(html_file, 'r').read())
		elif preview_tab and current_page == preview_tab.box:
			html_file = self.config.get('mailer.html_file')
			if not (html_file and os.path.isfile(html_file) and os.access(html_file, os.R_OK)):
				return
			html_file_uri = urlparse.urlparse(html_file, 'file').geturl()
			html_data = open(html_file, 'r').read()
			html_data = format_message(html_data, self.config)
			preview_tab.webview.load_html_string(html_data, html_file_uri)
コード例 #7
0
 def show_tab(self):
     """Configure the webview to preview the the message HTML file."""
     html_file = self.config.get('mailer.html_file')
     if not (html_file and os.path.isfile(html_file)
             and os.access(html_file, os.R_OK)):
         return
     with open(html_file, 'rb') as file_h:
         html_data = file_h.read()
     html_data = str(html_data.decode('utf-8', 'ignore'))
     html_data = mailer.format_message(html_data, self.config)
     html_file_uri = urllib.parse.urlparse(html_file, 'file').geturl()
     if not html_file_uri.startswith('file://'):
         html_file_uri = 'file://' + html_file_uri
     if has_webkit2:
         self.webview.load_html(html_data, html_file_uri)
     else:
         self.webview.load_html_string(html_data, html_file_uri)
コード例 #8
0
ファイル: mail.py プロジェクト: xujun10110/king-phisher
	def load_html_file(self):
		"""
		Load the configured HTML file into the WebKit engine so the contents can
		be previewed.
		"""
		html_file = self.config.get('mailer.html_file')
		if not (html_file and os.path.isfile(html_file) and os.access(html_file, os.R_OK)):
			return
		with codecs.open(html_file, 'r', encoding='utf-8') as file_h:
			html_data = file_h.read()
		try:
			html_data = mailer.format_message(html_data, self.config)
		except jinja2.TemplateSyntaxError as error:
			self.info_bar_label.set_text("Template syntax error: {error.message} on line {error.lineno}.".format(error=error))
			self.info_bar.show()
		except jinja2.UndefinedError as error:
			self.info_bar_label.set_text("Template undefined error: {error.message}.".format(error=error))
			self.info_bar.show()
		else:
			html_file_uri = urllib.parse.urlparse(html_file, 'file').geturl()
			self.load_html_data(html_data, html_file_uri)
			self.info_bar.hide()