Skip to content

Commit

Permalink
Merge pull request #17 from sinmentis/15-feature-automatic-parsing-wi…
Browse files Browse the repository at this point in the history
…th-time-setting

Add automatic email parsing with times
  • Loading branch information
sinmentis authored Sep 24, 2023
2 parents d8613dd + e8d2a83 commit 41576ce
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/EmailAll
Submodule EmailAll updated 1 files
+13 −1 emailall.py
2 changes: 1 addition & 1 deletion src/Frisbee
Submodule Frisbee updated 1 files
+23 −3 Frisbee.py
47 changes: 33 additions & 14 deletions src/gui/ItemEmailParser.qml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,20 @@ GroupBox{
height: parent.height
spacing: 40

Button {
height: parent.height
Layout.fillWidth: true
anchors.verticalCenter: parent.verticalCenter
text: "Load Local"
enabled: backend.emailWorkerState !== 2
onClicked: function() {
fileDialog.open()
}
}

Text {
text: "Domain to search: (i.e. gmail.com)"
width: 150
text: "Domain to search:"
width: 70
height: parent.height
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
Expand All @@ -47,28 +58,36 @@ GroupBox{
onTextChanged: checkSearchButtonState()
}

Button {
id: searchButton
Text {
text: "times: "
width: 15
height: parent.height
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
color: "white"
}

TextField {
id: searchTimes
text: "1"
width: 30
height: parent.height
Layout.fillWidth: true
anchors.verticalCenter: parent.verticalCenter
text: "Start Searching"
onClicked: function() {
backend.startSearchingEmail(targetDomin.text)
checkSearchButtonState()
}
enabled: false
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}

Button {
id: searchButton
height: parent.height
Layout.fillWidth: true
anchors.verticalCenter: parent.verticalCenter
text: "Load Local Email Address"
enabled: backend.emailWorkerState !== 2
text: "Start Searching"
onClicked: function() {
fileDialog.open()
backend.startSearchingEmail(targetDomin.text, parseInt(searchTimes.text))
checkSearchButtonState()
}
enabled: false
}

Button {
Expand Down
2 changes: 1 addition & 1 deletion src/gui/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Window {
color: "#3c3d22"
visible: true

title: "Massive Email Sender"
title: "Massive Email Sender v2.1"


property bool debug: false
Expand Down
23 changes: 17 additions & 6 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,17 +178,23 @@ def __init__(self, engine):

self.domain_name_to_search = "fromLocal"
self.state = SystemState.IDLE
self.search_thread = QThread()
self.search_worker = None

self.sender_list = SenderEmailQT("./config_json/sender.json")
self.engine = engine
self.engine.rootContext().setContextProperty("senderList", self.sender_list)

# For Sending engine
self.email_worker = MES.EmailWorker(debug_only=False)
self.email_worker.add_sender_list(self.sender_list)
self.email_worker.select_sender(0)

# For Searching engine
self.search_thread = QThread()
self.target_search_times = 0
self.search_worker = None



def update_destination_list(self, new_parser_results):
result_emails = [MES.jsonParser.target(email_address=email, name="", source="", phone="") for email in
new_parser_results]
Expand All @@ -211,7 +217,7 @@ def set_system_state(self, new_state: SystemState):
emailSendFinished = Signal(int)

# Functions - QML -> Python
startSearchingEmail = Signal(str)
startSearchingEmail = Signal(str, int)
exportEmailListToLocal = Signal()
loadEMLFromFile = Signal(str)
loadDestinationFromFiles = Signal(list)
Expand Down Expand Up @@ -240,9 +246,10 @@ def getEmailWorkerStateStr(self):
emailWorkerState = Property(int, getEmailWorkerState, notify=emailWorkerStateChanged)
emailWorkerStateStr = Property(str, getEmailWorkerStateStr, notify=emailWorkerStateChanged)

@Slot(str)
def startSearchingEmail(self, target_domain):
@Slot(str, int)
def startSearchingEmail(self, target_domain, search_times=1):
self.domain_name_to_search = target_domain
self.target_search_times = search_times
self.set_system_state(SystemState.PARSING_EMAIL)

# Check if a previous search thread is running
Expand All @@ -267,9 +274,13 @@ def startSearchingEmail(self, target_domain):
@Slot(list)
def onSearchCompleted(self, search_results):
self.update_destination_list(search_results)
self.set_system_state(SystemState.PARSING_EMAIL_FINISHED)
self.destinationEmailListChanged.emit()

if self.target_search_times > 1:
self.startSearchingEmail(self.domain_name_to_search, self.target_search_times - 1)
else:
self.set_system_state(SystemState.PARSING_EMAIL_FINISHED)

@Slot()
def exportEmailListToLocal(self):
current_time = datetime.datetime.now()
Expand Down

0 comments on commit 41576ce

Please sign in to comment.