diff --git a/toxygen/history.py b/toxygen/history.py
index 792b1de..4134d54 100644
--- a/toxygen/history.py
+++ b/toxygen/history.py
@@ -1,4 +1,4 @@
-from sqlite3 import connect
+from sqlite3 import connect, dbapi2
import settings
from os import chdir
import os.path
@@ -77,7 +77,7 @@ class History:
db.commit()
except:
db.rollback()
- raise
+ self.unlock_db()
finally:
db.close()
@@ -91,7 +91,7 @@ class History:
db.commit()
except:
db.rollback()
- raise
+ self.unlock_db()
finally:
db.close()
@@ -114,7 +114,7 @@ class History:
db.commit()
except:
db.rollback()
- raise
+ self.unlock_db()
finally:
db.close()
@@ -128,7 +128,7 @@ class History:
db.commit()
except:
db.rollback()
- raise
+ self.unlock_db()
finally:
db.close()
pass
@@ -142,7 +142,7 @@ class History:
db.commit()
except:
db.rollback()
- raise
+ self.unlock_db()
finally:
db.close()
@@ -155,10 +155,15 @@ class History:
db.commit()
except:
db.rollback()
- raise
+ self.unlock_db()
finally:
db.close()
+ def unlock_db(self):
+ connection = dbapi2.connect(self._name)
+ connection.commit()
+ connection.close()
+
def messages_getter(self, tox_id):
return History.MessageGetter(self._name, tox_id)
diff --git a/toxygen/profile.py b/toxygen/profile.py
index e34a723..a81528f 100644
--- a/toxygen/profile.py
+++ b/toxygen/profile.py
@@ -554,6 +554,8 @@ class Profile(contact.Contact, Singleton):
friend.name if data[1] == MESSAGE_OWNER['FRIEND'] else self.name,
data[0]))
s = new_line.join(arr)
+ if not as_text:
+ s = '
{}{}'.format(friend.name, s)
return s
# -----------------------------------------------------------------------------------------------------------------
@@ -1135,6 +1137,7 @@ class Profile(contact.Contact, Singleton):
if not os.path.isfile(avatar_path): # reset image
avatar_path = None
sa = SendAvatar(avatar_path, self._tox, friend_number)
+ sa.set_transfer_finished_handler(self.transfer_finished)
self._file_transfers[(friend_number, sa.get_file_number())] = sa
def incoming_avatar(self, friend_number, file_number, size):
diff --git a/toxygen/updater.py b/toxygen/updater.py
new file mode 100644
index 0000000..bc515b7
--- /dev/null
+++ b/toxygen/updater.py
@@ -0,0 +1,25 @@
+import util
+import requests
+
+
+def check_for_updates():
+ current_version = util.program_version
+ major, minor, patch = list(map(lambda x: int(x), current_version.split('.')))
+ versions = generate_versions(major, minor, patch)
+ for version in versions:
+ if send_request(version):
+ return version
+ return None
+
+
+def send_request(version):
+ # TODO: proxy support
+ request = requests.get('https://github.com/toxygen-project/toxygen/releases/tag/v' + version)
+ return request.status_code == 200
+
+
+def generate_versions(major, minor, patch):
+ new_major = '.'.join([str(major + 1), '0', '0'])
+ new_minor = '.'.join([str(major), str(minor + 1), '0'])
+ new_patch = '.'.join([str(major), str(minor), str(patch + 1)])
+ return new_major, new_minor, new_patch
\ No newline at end of file
diff --git a/toxygen/util.py b/toxygen/util.py
index 93ba7a7..0d1a48f 100644
--- a/toxygen/util.py
+++ b/toxygen/util.py
@@ -2,7 +2,7 @@ import os
import time
import shutil
-program_version = '0.2.5'
+program_version = '0.2.6'
def log(data):