From 4f7f4cf5c473495941329d1bcf415d2b519e25ab Mon Sep 17 00:00:00 2001 From: Marcos Pinto Date: Wed, 30 May 2007 22:40:54 +0000 Subject: [PATCH] enc stuff --- encryption/msgfmt.pyc | Bin 5012 -> 4965 bytes encryption/src/core.py | 49 +++++---------------------------- encryption/src/deluge_core.cpp | 12 ++++---- 3 files changed, 13 insertions(+), 48 deletions(-) diff --git a/encryption/msgfmt.pyc b/encryption/msgfmt.pyc index d228148561cb1801970671966c83d5ff1f590771..4c515765d1231f327779f49f0f915780982bfc92 100644 GIT binary patch literal 4965 zcmai2|8m>L5#9qSQlv>mzbqxTVom75Wf;f_~o~NokzSR1TJVd$)Ugi{0-Q8T_|d@2nmCt|OB_ z55J$`DgF);i97-|^32F1ql_nyJY`DqsH99;9+j1ulSgwBVL?TXM8c{>SWuQ9pgS+o zocsW5HHj+9)FrAab3vkcWf~GUC926&PqGVQ;)c8uF{u#)2liTZI`vn$SHB;paUR;( zf0CqOKK2K3QG~tN?}Rq&XFb20X9M5H$95FBCg9wmi8 z%(Gq|4*X7*zKC;M_~A_Rn>6WW`DoBC?6@EQXqVQ;F!Q@fKYq_oQk&JosXO;~znQtx z+89h0ZTP-!h&|zMoZ2Mp_s70Hiv1!S#C~^_cGStRps-FWgQC|R*r|`V{iEz<3@>l{ ziS=P8^owLL?8mvUKLZ%mbK-2@Fd$nK0~^D!|M~Lh;JmDuKD(14iVcbc&&ULp)ZTdFzU*-v3i_LJ@ovxn^5^Lk=wm(_* zGU@mIUdDyt%oi0bjt#Mz^`Kb)ETI>!rv z8bUNpjWCV;_&Bjsy>BOah-QIon5k|j#jqca{fQiJ7AY`r*>h%Nwm4v zhR+d)dig95%C~OqxxvhddJdCo=;h|2$mMufZuvoet z(@KjD1XK$+*}~(9-2k_Flnvs|L6|=qKgphK7BAAxDDIDX@n)QM^06kCnaLqfz@1f)h^~*}GyGuxt90DB2)Cjch>$a2^5sSaHDvF6dEz z1zkP==TYQ`ewwB2?&$mPk)-F!A9=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Anza@?LymNt%f(6aTwt zy&p1X>j%NxsE4=yBMM@|b}FT1<$}Jz5~DqlwJs>4*yBoB(m=qKpq_Z>VdstT%i z)e_1ksGctZuJiaZ-b>DPr-5X(in58z0gtnR(WY8)FuzpCF4rKh%Nnp7__}+9N8i9n zjkhH^lej_v1LD^~fM9%(9SFUT8=*vBfO7yC1q#0fTp%(*s9LwD?j!^optT}H-@_2nKM+312&l)A^Ywr(n+jc8 za8(xYjkUljB+J2bfZS+!<3h?(v7SX<;YJ9+FrA)%Wb?XJ!gYk8#!UpyWIIl(>VRjp zR^cm)aLICyUuHWJt^7GB!8rR4(+pgjU)T>)!Fu~xa{#v6Jl(PaW2602GZfnGVllVo zUnF*ArkN$$mp^i~D3jrnZ~mz%-&L9;`8ocZ;SW}ZXZO3~0r}nl=)e4txMjcHM2*YZ zUF!ZH?JkXci&8B~?%2wHWU`?V1`rnodH+<9D6Hgj^!Zy{@ZN?wuG5)0pwqE*!I9bG zi6Q{fEE7SJ79{&Wh~pDzx7mkV~E^$l~S5TMU)@b^&6L^AV1 sBs$)Yo${6YaFB(gB>MR^NY$LMSHK~&KiFC+HQai=zFGf${iCM(50+~DvH$=8 diff --git a/encryption/src/core.py b/encryption/src/core.py index 0bb0d01d9..6fea3089e 100644 --- a/encryption/src/core.py +++ b/encryption/src/core.py @@ -36,7 +36,7 @@ # time to calculate, so we do if efficiently # 3. supp_torrent_state - supplementary torrent data, from Deluge -import deluge_core, common, pref +import deluge_core import os, os.path, shutil, statvfs import pickle import time @@ -118,6 +118,7 @@ class InsufficientFreeSpaceError(DelugeError): return "%d %d bytes needed"%(self.free_space, self.needed_space) # A cached data item + class cached_data: def __init__(self, get_method, key): self.get_method = get_method @@ -166,16 +167,6 @@ class Manager: # completely fresh. When quitting, the old files will be overwritten def __init__(self, client_ID, version, user_agent, base_dir, blank_slate=False): self.base_dir = base_dir - self.conf_file = os.path.join(common.CONFIG_DIR, 'deluge.conf') - if os.path.isdir(self.conf_file): - print 'Weird, the file I was trying to write to, %s, is an existing directory'%(self.conf_file) - sys.exit(0) - if not os.path.isfile(self.conf_file): - f = open(self.conf_file, mode='w') - f.flush() - f.close() - self.config = pref.Preferences(self.conf_file) - # Ensure directories exist if not TORRENTS_SUBDIR in os.listdir(self.base_dir): @@ -228,34 +219,6 @@ class Manager: # Apply preferences. Note that this is before any torrents are added self.apply_prefs() - #encryption - - if(self.config.get("encout_disabled") == "True"): - out_policy = "0" - elif(self.config.get("encout_enabled") == "True"): - out_policy = "1" - elif(self.config.get("encout_forced") == "True"): - out_policy = "2" - if(self.config.get("encin_disabled") == "True"): - in_policy = "0" - elif(self.config.get("encin_enabled") == "True"): - in_policy = "1" - elif(self.config.get("encin_forced") == "True"): - in_policy = "2" - if(self.config.get("level_plaintext") == "True"): - level_policy = "0" - elif(self.config.get("level_both") == "True"): - level_policy = "1" - elif(self.config.get("level_rc4") == "True"): - level_policy = "2" - if(self.config.get("prefer_rc4") == "True"): - prefer_rc4 = "1" - elif(self.config.get("prefer_rc4") == "False"): - prefer_rc4 = "0" - ret = self.pe_settings(out_policy, in_policy, level_policy, prefer_rc4) - return ret - - # Apply DHT, if needed. Note that this is before any torrents are added if self.get_pref('use_DHT'): if not blank_slate: @@ -785,8 +748,10 @@ class Manager: def create_torrent(self, filename, source_directory, trackers, comments=None, - pieces=256, author="Deluge"): + pieces=256, author="Deluge"): + return deluge_core.create_torrent(filename, source_directory, trackers, comments, pieces, author) - def pe_settings(self, out_enc_policy, in_enc_policy, allowed_enc_level, prefer_rc4): - return deluge_core.pe_settings(out_enc_policy, in_enc_policy, allowed_enc_level, prefer_rc4) + def pe_settings(self, out_enc_policy, in_enc_policy, allowed_enc_level, prefer_rc4): + return deluge_core.pe_settings(out_enc_policy, in_enc_policy, allowed_enc_level, prefer_rc4) + diff --git a/encryption/src/deluge_core.cpp b/encryption/src/deluge_core.cpp index 3285bf857..5249ee657 100644 --- a/encryption/src/deluge_core.cpp +++ b/encryption/src/deluge_core.cpp @@ -1221,12 +1221,12 @@ static PyObject *torrent_apply_IP_filter(PyObject *self, PyObject *args) static PyObject *torrent_pe_settings(PyObject *self, PyObject *args) { - pe_settings p = pe_settings(); - return Py_BuildValue("{p:l,p:l,p:l,p:l}", - "out_enc_policy", char(p.out_enc_policy), - "in_enc_policy", char(p.in_enc_policy), - "allowed_enc_level", char(p.allowed_enc_level), - "prefer_rc4", bool(p.prefer_rc4)); + pe_settings s = pe_settings(); + return Py_BuildValue("{s:i,s:i,s:i,s:i}", + "out_enc_policy", int(s.out_enc_policy), + "in_enc_policy", int(s.in_enc_policy), + "allowed_enc_level", int(s.allowed_enc_level), + "prefer_rc4", bool(s.prefer_rc4)); } //====================