fclient-commit Mailing List for fclient (Page 12)
Status: Pre-Alpha
Brought to you by:
jurner
You can subscribe to this list here.
| 2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(23) |
Nov
(54) |
Dec
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2008 |
Jan
(17) |
Feb
(209) |
Mar
(63) |
Apr
(31) |
May
(7) |
Jun
(39) |
Jul
(390) |
Aug
(122) |
Sep
(6) |
Oct
|
Nov
|
Dec
|
|
From: <jU...@us...> - 2008-07-20 11:50:41
|
Revision: 695
http://fclient.svn.sourceforge.net/fclient/?rev=695&view=rev
Author: jUrner
Date: 2008-07-20 11:49:59 +0000 (Sun, 20 Jul 2008)
Log Message:
-----------
bit of an overkill when handling filename collisions
Modified Paths:
--------------
trunk/fclient/src/fclient/lib/fcp2/client.py
Modified: trunk/fclient/src/fclient/lib/fcp2/client.py
===================================================================
--- trunk/fclient/src/fclient/lib/fcp2/client.py 2008-07-20 11:46:26 UTC (rev 694)
+++ trunk/fclient/src/fclient/lib/fcp2/client.py 2008-07-20 11:49:59 UTC (rev 695)
@@ -350,7 +350,7 @@
del self._requests[request['Identifier']]
- def _registerRequest(self,
+ def registerRequest(self,
msg,
requestType,
userData=None,
@@ -672,21 +672,17 @@
# handle filename collisions
elif code == consts.ConstProtocolError.DiskTargetExists:
- handleCollision = initialRequest.get('HandleFilenameCollision', None)
- if handleCollision is not None: # looks like one of our requests
- collisionHandled = initialRequest.get('FilenameCollisionHandled', None)
- if collisionHandled is not None: # one more hint that it is one of our requests
- if handleCollision:
- # rename file and resend request
- initialRequest['FilenameCollisionHandled'] = True
- filename = initialRequest['Filename']
- newFilename = namespace.unique_filename(filename, extensions=1, ispostfixed=collisionHandled)
- initialRequest['Filename'] = newFilename
- initialRequest['Modified'] = {consts.ConstRequestModified.Filename: filename}
- initialRequest.updatePersistentParams()
- self.sendMessage(initialRequest)
- self.events.RequestModified(initialRequest)
- return True
+ if initialRequest['HandleFilenameCollision']:
+ # rename file and resend request
+ filename = initialRequest['Filename']
+ newFilename = namespace.unique_filename(filename, extensions=1, ispostfixed=initialRequest['FilenameCollisionHandled'])
+ initialRequest['FilenameCollisionHandled'] = True
+ initialRequest['Filename'] = newFilename
+ initialRequest['Modified'] = {consts.ConstRequestModified.Filename: filename}
+ initialRequest.updatePersistentParams()
+ self.sendMessage(initialRequest)
+ self.events.RequestModified(initialRequest)
+ return True
# handle plugin related request failures
elif code == consts.ConstProtocolError.NoSuchPlugin or code == consts.ConstProtocolError.AccessDenied:
@@ -1297,7 +1293,7 @@
if value is not None:
msg[paramName] = value
- self._registerRequest(
+ self.registerRequest(
msg,
requestType,
handleFilenameCollision=handleFilenameCollision,
@@ -1527,7 +1523,7 @@
URI=uri,
DontPoll=dontPoll,
)
- self._registerRequest(msg, consts.ConstRequestType.SubscribeUSK)
+ self.registerRequest(msg, consts.ConstRequestType.SubscribeUSK)
msg['RequestStatus'] |= consts.ConstRequestStatus.Completed
self.sendMessage(msg)
return msg['Identifier']
@@ -1680,7 +1676,7 @@
msg.data = data
# finally
- self._registerRequest(
+ self.registerRequest(
msg,
requestType,
persistentUserData=persistentUserData,
@@ -2156,7 +2152,7 @@
PluginName=pluginName,
Detailed=detailed,
)
- self._registerRequest(msg, consts.ConstRequestType.PluginInfo)
+ self.registerRequest(msg, consts.ConstRequestType.PluginInfo)
self.sendMessage(msg)
return msg['Identifier']
@@ -2206,7 +2202,7 @@
requestType = consts.ConstRequestType.GenerateSSKKeypair if keypairType == consts.ConstKeyType.SSK else consts.ConstRequestType.GenerateUSKKeypair
msg = message.MsgGenerateSSK()
- self._registerRequest(msg, requestType)
+ self.registerRequest(msg, requestType)
self.sendMessage(msg)
return msg['Identifier']
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-07-20 11:47:13
|
Revision: 694
http://fclient.svn.sourceforge.net/fclient/?rev=694&view=rev
Author: jUrner
Date: 2008-07-20 11:46:26 +0000 (Sun, 20 Jul 2008)
Log Message:
-----------
permanent redirect are now handled automatically (if desired)
(should work in theory)
Modified Paths:
--------------
trunk/fclient/src/fclient/lib/fcp2/client.py
trunk/fclient/src/fclient/lib/fcp2/consts.py
trunk/fclient/src/fclient/lib/fcp2/test/test_client.py
Modified: trunk/fclient/src/fclient/lib/fcp2/client.py
===================================================================
--- trunk/fclient/src/fclient/lib/fcp2/client.py 2008-07-20 10:50:47 UTC (rev 693)
+++ trunk/fclient/src/fclient/lib/fcp2/client.py 2008-07-20 11:46:26 UTC (rev 694)
@@ -358,6 +358,7 @@
initTime=None,
persistentUserData='',
handleFilenameCollision=False,
+ handlePermanentRedirect=False,
):
"""Registers a request
@param msg: message to register
@@ -368,7 +369,8 @@
@param initTime: (int) init time of the request or None to set it to now
@param persistentUserData: (str) anyuser defined persistent data
@param userData: (any) any user defined non persistent data
-
+ @param handlePermanentRedirect: (bool) if True, permanent redirect are handled automatically. for example USK@.../-1
+ will look for the current edition. if handlePermanentRedirect is True, the request is automatically resend to retrieve the current edition
@return: (str) identifer of therequest
@note: the identifier returned is unique to the client but may not be unique to the node
"""
@@ -382,6 +384,7 @@
msg['InitTime'] = time.time() if initTime is None else initTime
if requestType & consts.ConstRequestType.MaskGet:
msg['HandleFilenameCollision'] = handleFilenameCollision
+ msg['HandlePermanentRedirect'] = handlePermanentRedirect
msg['UserData'] = userData
msg['PersistentUserData'] = persistentUserData
msg['ClientToken'] = ''
@@ -855,16 +858,27 @@
self.events.RequestRemoved(initialRequest)
return True
+ if code == consts.ConstFetchError.PermanentRedirect:
+ if initialRequest['HandlePermanentRedirect']:
+ initialRequest['PermanentRedirectHandled'] = True
+ initialRequest['Modified'] = {consts.ConstRequestModified.PermanentRedirect: initialRequest['URI']}
+ initialRequest['URI'] = msg['RedirectURI']
+ initialRequest.updatePersistentParams()
+ self.events.RequestModified(initialRequest)
+ self.sendMessage(initialRequest)
+ return True
+
# check if it is one of our requests for key information
if code == consts.ConstFetchError.TooBig and initialRequest['RequestType'] & consts.ConstRequestType.GetKeyInfo:
initialRequest['MetadataContentType'] = msg.get('ExpectedMetadata.ContentType', '')
initialRequest['DataLength'] = msg.get('ExpectedDataLength', -1)
initialRequest['RequestStatus'] |= consts.ConstRequestStatus.Success
self._finalizeRequest(msg, initialRequest, self.events.RequestCompleted)
- else:
- initialRequest['ErrorMessage'] = msg
- initialRequest['RequestStatus'] |= consts.ConstRequestStatus.Error
- self._finalizeRequest(msg, initialRequest, self.events.RequestFailed)
+ return True
+
+ initialRequest['ErrorMessage'] = msg
+ initialRequest['RequestStatus'] |= consts.ConstRequestStatus.Error
+ self._finalizeRequest(msg, initialRequest, self.events.RequestFailed)
return True
@@ -1261,6 +1275,7 @@
userData,
persistentUserData,
handleFilenameCollision=False,
+ handlePermanentRedirect=False,
**messageParams
):
"""Requests a key from the node
@@ -1270,6 +1285,8 @@
@param persistentUserData: any string to associate to the request as persistent data or None
@param handleFilenameCollision: (bool) if True, the file is automatically renamed if "filename" collides
with a file object already present on disk
+ @param handlePermanentRedirect: (bool) if True, permanent redirect are handled automatically. for example USK@.../-1
+ will look for the current edition. if handlePermanentRedirect is True, the request is automatically resend to retrieve the current edition
@param messageParams: keyword arguments to pass along with the ClientGet message (uppercase first letter!!).
If the value of a keyword is None, it is ignored.
@@ -1284,6 +1301,7 @@
msg,
requestType,
handleFilenameCollision=handleFilenameCollision,
+ handlePermanentRedirect=handlePermanentRedirect,
persistentUserData=persistentUserData,
userData=userData,
)
@@ -1305,6 +1323,7 @@
userData=None,
persistentUserData='',
+ handlePermanentRedirect=False,
):
"""Requests datae from the node
@@ -1320,6 +1339,8 @@
@param priorityClass: (L{consts.ConstPriority}) priority of the request
@param userData: any non persistent data to associate to the request
@param persistentUserData: any string to associate to the request as persistent data
+ @param handlePermanentRedirect: (bool) if True, permanent redirect are handled automatically. for example USK@.../-1
+ will look for the current edition. if handlePermanentRedirect is True, the request is automatically resend to retrieve the current edition
@return: (str) request identifier
@@ -1338,6 +1359,7 @@
consts.ConstRequestType.GetData,
userData,
persistentUserData,
+ handlePermanentRedirect=handlePermanentRedirect,
# Fcp params
AllowedMimeTypes = allowedMimeTypes,
@@ -1371,6 +1393,7 @@
userData=None,
persistentUserData='',
handleFilenameCollision=False,
+ handlePermanentRedirect=False,
):
"""Requests a file from the node
@@ -1385,11 +1408,14 @@
@param maxSize: (int) maximum size of the file in bytes or None to set no limited
@param persistence: (L{consts.ConstPersistence}) persistence of the request
@param priorityClass: (L{consts.ConstPriority}) priority of the request
+ @param userData: any non persistent data to associate to the request
+ @param persistentUserData: any string to associate to the request as persistent data
@param handleFilenameCollision: (bool) if True, the file is automatically renamed if "filename" collides
with a file object already present on disk
- @param userData: any non persistent data to associate to the request
- @param persistentUserData: any string to associate to the request as persistent data
+ @param handlePermanentRedirect: (bool) if True, permanent redirect are handled automatically. for example USK@.../-1
+ will look for the current edition. if handlePermanentRedirect is True, the request is automatically resend to retrieve the current edition
+
@return: (str) request identifier
@event: (L{events.Events.RequestCompleted}) triggered when the request is complete
@@ -1407,6 +1433,7 @@
userData,
persistentUserData,
handleFilenameCollision=handleFilenameCollision,
+ handlePermanentRedirect=handlePermanentRedirect,
# Fcp params
AllowedMimeTypes = allowedMimeTypes,
@@ -1436,6 +1463,7 @@
userData=None,
persistentUserData='',
+ handlePermanentRedirect=False,
):
"""Requests info about a key
@@ -1448,6 +1476,8 @@
@param priorityClass: (L{consts.ConstPriority}) priority of the request
@param userData: any non persistent data to associate to the request
@param persistentUserData: any string to associate to the request as persistent data
+ @param handlePermanentRedirect: (bool) if True, permanent redirect are handled automatically. for example USK@.../-1
+ will look for the current edition. if handlePermanentRedirect is True, the request is automatically resend to retrieve the current edition
@return: (str) request identifier
@@ -1466,6 +1496,7 @@
consts.ConstRequestType.GetKeyInfo,
userData,
persistentUserData,
+ handlePermanentRedirect=handlePermanentRedirect,
# Fcp params
Global=False,
Modified: trunk/fclient/src/fclient/lib/fcp2/consts.py
===================================================================
--- trunk/fclient/src/fclient/lib/fcp2/consts.py 2008-07-20 10:50:47 UTC (rev 693)
+++ trunk/fclient/src/fclient/lib/fcp2/consts.py 2008-07-20 11:46:26 UTC (rev 694)
@@ -418,15 +418,17 @@
@cvar Identifier: the identifier has been moodified
@cvar PersistentUserData: persistent user data has been modified
@cvar PriorityClass: the priority class has been modified
+ @cvar PermanentRedirect: url of a request has been modified because of a redirect
@note: the FcModified member of the params dict of a request may contain
one or more of the bitflags
"""
Null = 0x0
- Filename = 0x8
+ Filename = 0x2
Identifier = 0x4
- PersistentUserData = 0x1
- PriorityClass = 0x2
+ PersistentUserData = 0x8
+ PriorityClass = 0x10
+ PermanentRedirect = 0x20
class ConstRequestStatus(_BaseBitFlags):
"""Request status flags
Modified: trunk/fclient/src/fclient/lib/fcp2/test/test_client.py
===================================================================
--- trunk/fclient/src/fclient/lib/fcp2/test/test_client.py 2008-07-20 10:50:47 UTC (rev 693)
+++ trunk/fclient/src/fclient/lib/fcp2/test/test_client.py 2008-07-20 11:46:26 UTC (rev 694)
@@ -2607,7 +2607,88 @@
self.assertHasNextMessage(None)
self.failIf(requestsAll)
+#***********************************************************************************
+#
+#***********************************************************************************
+class TestHandlePermanentRedirect(BaseTestClient):
+
+ def test_doHandleRedirect(self):
+ self.connectClient()
+
+# request a file
+ myKey = fcp2.Key('USK@blah,blah,blah/foo/-1')
+ myIdentifier = self.client.getData(
+ myKey,
+ handlePermanentRedirect=True,
+ )
+ myRequest = self.client.getRequest(myIdentifier)
+ requestsAll = self.client.getRequests()
+ # client schould send a ClientGet
+ self.assertHasNextMessage(fcp2.MsgClientGet)
+
+ # respond with a Getfailed
+ self.sendResponseMessage(
+ 'GetFailed',
+ Identifier=myIdentifier,
+ Code=27, # PermanentRedirect
+ RedirectURI=fcp2.Key('USK@blah,blah,blah/foo/99'),
+ )
+
+ # check if RequestModified event has been triggered
+ msg = self.assertHasNextEvent(
+ self.client.events.RequestModified,
+ fcp2.MsgClientGet,
+ )
+
+ modified = msg['Modified'][fcp2.ConstRequestModified.PermanentRedirect]
+ self.assertEqual(modified, myKey)
+
+ # check flags
+ self.failUnless(myRequest['HandlePermanentRedirect'])
+ self.failUnless(myRequest['PermanentRedirectHandled'])
+
+ # client should resend request
+ self.assertHasNextMessage(fcp2.MsgClientGet)
+ self.assertHasNextEvent(None)
+ self.assertHasNextMessage(None)
+
+
+ def test_doNotHandleRedirect(self):
+ self.connectClient()
+
+# request a file
+ myKey = fcp2.Key('USK@blah,blah,blah/foo/-1')
+ myIdentifier = self.client.getData(
+ myKey,
+ handlePermanentRedirect=False,
+ )
+ myRequest = self.client.getRequest(myIdentifier)
+ requestsAll = self.client.getRequests()
+
+ # client schould send a ClientGet
+ self.assertHasNextMessage(fcp2.MsgClientGet)
+
+ # respond with a Getfailed
+ self.sendResponseMessage(
+ 'GetFailed',
+ Identifier=myIdentifier,
+ Code=27, # PermanentRedirect
+ RedirectURI=fcp2.Key('USK@blah,blah,blah/foo/99'),
+ )
+
+ # check if RequestModified event has been triggered
+ msg = self.assertHasNextEvent(
+ self.client.events.RequestFailed,
+ fcp2.MsgClientGet,
+ )
+
+ # check flags
+ self.failIf(myRequest['HandlePermanentRedirect'])
+ self.failIf(myRequest['PermanentRedirectHandled'])
+ self.assertHasNextEvent(None)
+ self.assertHasNextMessage(None)
+
#***********************************************************************************
#
#***********************************************************************************
@@ -2996,6 +3077,7 @@
Test_DDA,
TestCollisions,
+ TestHandlePermanentRedirect,
Test_getPluginInfo,
Test_sendPluginMessage,
Test_generateKeypair,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-07-20 10:50:52
|
Revision: 693
http://fclient.svn.sourceforge.net/fclient/?rev=693&view=rev
Author: jUrner
Date: 2008-07-20 10:50:47 +0000 (Sun, 20 Jul 2008)
Log Message:
-----------
filenameCollision consts no longer needed
Modified Paths:
--------------
trunk/fclient/src/fclient/lib/fcp2/client.py
Modified: trunk/fclient/src/fclient/lib/fcp2/client.py
===================================================================
--- trunk/fclient/src/fclient/lib/fcp2/client.py 2008-07-20 10:39:36 UTC (rev 692)
+++ trunk/fclient/src/fclient/lib/fcp2/client.py 2008-07-20 10:50:47 UTC (rev 693)
@@ -1968,11 +1968,14 @@
Global=False,
)
if persistentUserData is not None:
+ oldClientToken = initialRequest['ClientToken']
initialRequest['PersistentUserData'] = persistentUserData
- msg['ClientToken'] = initialRequest.updatePersistentParams()
+ initialRequest.updatePersistentParams()
+ msg['ClientToken'] = initialRequest['ClientToken']
+ initialRequest['ClientToken'] = oldClientToken
if priorityClass is not None:
msg['PriorityClass'] = priorityClass
-
+
self.sendMessage(msg)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-07-20 10:39:36
|
Revision: 692
http://fclient.svn.sourceforge.net/fclient/?rev=692&view=rev
Author: jUrner
Date: 2008-07-20 10:39:36 +0000 (Sun, 20 Jul 2008)
Log Message:
-----------
filenameCollision consts no longer needed
Modified Paths:
--------------
trunk/fclient/src/fclient/lib/fcp2/__init__.py
trunk/fclient/src/fclient/lib/fcp2/consts.py
Modified: trunk/fclient/src/fclient/lib/fcp2/__init__.py
===================================================================
--- trunk/fclient/src/fclient/lib/fcp2/__init__.py 2008-07-20 10:38:14 UTC (rev 691)
+++ trunk/fclient/src/fclient/lib/fcp2/__init__.py 2008-07-20 10:39:36 UTC (rev 692)
@@ -17,7 +17,7 @@
from .client import Client
from .config import (Config, ConfigDataType, ConfigItem, ConfigKeySep, ConfigValueClass)
from .consts import (ConstByteAmountPostfix, ConstConnectReason, ConstDebugVerbosity, ConstDisconnectReason,
- ConstFetchError, ConstFilenameCollision, ConstInsertError, ConstKeyType, ConstLogMessages,
+ ConstFetchError, ConstInsertError, ConstKeyType, ConstLogMessages,
ConstLogger, ConstMessage, ConstPeerNodeStatus, ConstPeerNoteType, ConstPersistence,
ConstPriority, ConstProtocolError, ConstPutDirType, ConstRequestModified, ConstRequestStatus,
ConstRequestType, ConstReturnType, ConstTimeDeltaPostfix, ConstUploadFrom, ConstVerbosity,
Modified: trunk/fclient/src/fclient/lib/fcp2/consts.py
===================================================================
--- trunk/fclient/src/fclient/lib/fcp2/consts.py 2008-07-20 10:38:14 UTC (rev 691)
+++ trunk/fclient/src/fclient/lib/fcp2/consts.py 2008-07-20 10:39:36 UTC (rev 692)
@@ -175,19 +175,6 @@
PermanentRedirect = 27 # 'USK@.../-1/' for example will always fail and return a key pointing to the current edition
NotAllDataFound = 28
-class ConstFilenameCollision(_BaseBitFlags):
- """Filename collision flags
- @cvar HandleNever: don't handle filename collisions
- @cvar HandleRename: rename file on collisions
- @cvar MaskHandle: bitmask indicating if collisions are hadled or not
- @cvar CollisonHandled: if this bit is set, a collision has actually been handled
- """
- HandleNever = 0x0
- HandleRename = 0x1
-
- MaskHandle = HandleRename
-
- CollisionHandled = 0x10000000 # a filename collision has already been handled
class ConstInsertError(Exception):
"""All insert errors supported by the client"""
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-07-20 10:38:16
|
Revision: 691
http://fclient.svn.sourceforge.net/fclient/?rev=691&view=rev
Author: jUrner
Date: 2008-07-20 10:38:14 +0000 (Sun, 20 Jul 2008)
Log Message:
-----------
filenameCollision is now handleFilenameCollision (bool)
Modified Paths:
--------------
trunk/fclient/src/fclient/lib/fcp2/client.py
trunk/fclient/src/fclient/lib/fcp2/test/test_client.py
Modified: trunk/fclient/src/fclient/lib/fcp2/client.py
===================================================================
--- trunk/fclient/src/fclient/lib/fcp2/client.py 2008-07-20 10:35:34 UTC (rev 690)
+++ trunk/fclient/src/fclient/lib/fcp2/client.py 2008-07-20 10:38:14 UTC (rev 691)
@@ -357,13 +357,13 @@
identifier=None,
initTime=None,
persistentUserData='',
- filenameCollision=consts.ConstFilenameCollision.HandleNever,
+ handleFilenameCollision=False,
):
"""Registers a request
@param msg: message to register
@param requestType: (L{consts.ConstRequestType}) type of request to register
- @param filenameCollision: (L{consts.ConstFilenameCollision}) how to handle filename collisions.
- Default is L{consts.ConstFilenameCollision.HandleNever}
+ @param handleFilenameCollision: (bool) if True, the file is automatically renamed if "filename" collides
+ with a file object already present on disk
@param identifier: (str) identifier of the request or None to create a new one
@param initTime: (int) init time of the request or None to set it to now
@param persistentUserData: (str) anyuser defined persistent data
@@ -381,7 +381,7 @@
msg['RequestType'] = requestType
msg['InitTime'] = time.time() if initTime is None else initTime
if requestType & consts.ConstRequestType.MaskGet:
- msg['FilenameCollision'] = filenameCollision
+ msg['HandleFilenameCollision'] = handleFilenameCollision
msg['UserData'] = userData
msg['PersistentUserData'] = persistentUserData
msg['ClientToken'] = ''
@@ -669,25 +669,22 @@
# handle filename collisions
elif code == consts.ConstProtocolError.DiskTargetExists:
- handleCollision = initialRequest.get('FilenameCollision', consts.ConstFilenameCollision.HandleNever)
- collisionHandled = bool(handleCollision & consts.ConstFilenameCollision.CollisionHandled)
-
- # rename filename
- if handleCollision & consts.ConstFilenameCollision.HandleRename:
- filename = initialRequest['Filename']
- initialRequest['FilenameCollision'] |= consts.ConstFilenameCollision.CollisionHandled
- newFilename = namespace.unique_filename(filename, extensions=1, ispostfixed=collisionHandled)
- initialRequest['Filename'] = newFilename
- initialRequest['Modified'] = {consts.ConstRequestModified.Filename: filename}
- self.sendMessage(initialRequest)
- self.events.RequestModified(initialRequest)
- return True
-
- # don't handle
- else:
- initialRequest['FilenameCollision'] &= ~consts.ConstFilenameCollision.CollisionHandled
-
-
+ handleCollision = initialRequest.get('HandleFilenameCollision', None)
+ if handleCollision is not None: # looks like one of our requests
+ collisionHandled = initialRequest.get('FilenameCollisionHandled', None)
+ if collisionHandled is not None: # one more hint that it is one of our requests
+ if handleCollision:
+ # rename file and resend request
+ initialRequest['FilenameCollisionHandled'] = True
+ filename = initialRequest['Filename']
+ newFilename = namespace.unique_filename(filename, extensions=1, ispostfixed=collisionHandled)
+ initialRequest['Filename'] = newFilename
+ initialRequest['Modified'] = {consts.ConstRequestModified.Filename: filename}
+ initialRequest.updatePersistentParams()
+ self.sendMessage(initialRequest)
+ self.events.RequestModified(initialRequest)
+ return True
+
# handle plugin related request failures
elif code == consts.ConstProtocolError.NoSuchPlugin or code == consts.ConstProtocolError.AccessDenied:
if initialRequest == message.MsgGetPluginInfo:
@@ -1263,7 +1260,7 @@
requestType,
userData,
persistentUserData,
- filenameCollision,
+ handleFilenameCollision=False,
**messageParams
):
"""Requests a key from the node
@@ -1271,7 +1268,8 @@
@param requestType: (L{consts.ConstRequestType}) sub type of the message
@param userData: any non persistent data to associate to the request or None
@param persistentUserData: any string to associate to the request as persistent data or None
- @param filenameCollision: what to do if the disk target alreaady exists. One of the FilenameCollision.* consts
+ @param handleFilenameCollision: (bool) if True, the file is automatically renamed if "filename" collides
+ with a file object already present on disk
@param messageParams: keyword arguments to pass along with the ClientGet message (uppercase first letter!!).
If the value of a keyword is None, it is ignored.
@@ -1285,7 +1283,7 @@
self._registerRequest(
msg,
requestType,
- filenameCollision=filenameCollision,
+ handleFilenameCollision=handleFilenameCollision,
persistentUserData=persistentUserData,
userData=userData,
)
@@ -1340,8 +1338,7 @@
consts.ConstRequestType.GetData,
userData,
persistentUserData,
- consts.ConstFilenameCollision.HandleNever,
-
+
# Fcp params
AllowedMimeTypes = allowedMimeTypes,
BinaryBlob=binaryBlob,
@@ -1373,7 +1370,7 @@
userData=None,
persistentUserData='',
- filenameCollision=consts.ConstFilenameCollision.HandleNever,
+ handleFilenameCollision=False,
):
"""Requests a file from the node
@@ -1388,7 +1385,8 @@
@param maxSize: (int) maximum size of the file in bytes or None to set no limited
@param persistence: (L{consts.ConstPersistence}) persistence of the request
@param priorityClass: (L{consts.ConstPriority}) priority of the request
- @param filenameCollision: what to do if the disk target alreaady exists. One of the FilenameCollision.* consts
+ @param handleFilenameCollision: (bool) if True, the file is automatically renamed if "filename" collides
+ with a file object already present on disk
@param userData: any non persistent data to associate to the request
@param persistentUserData: any string to associate to the request as persistent data
@@ -1408,7 +1406,7 @@
consts.ConstRequestType.GetFile,
userData,
persistentUserData,
- filenameCollision,
+ handleFilenameCollision=handleFilenameCollision,
# Fcp params
AllowedMimeTypes = allowedMimeTypes,
@@ -1468,8 +1466,7 @@
consts.ConstRequestType.GetKeyInfo,
userData,
persistentUserData,
- consts.ConstFilenameCollision.HandleNever,
-
+
# Fcp params
Global=False,
DSOnly=dsOnly,
Modified: trunk/fclient/src/fclient/lib/fcp2/test/test_client.py
===================================================================
--- trunk/fclient/src/fclient/lib/fcp2/test/test_client.py 2008-07-20 10:35:34 UTC (rev 690)
+++ trunk/fclient/src/fclient/lib/fcp2/test/test_client.py 2008-07-20 10:38:14 UTC (rev 691)
@@ -2507,7 +2507,7 @@
self.failIf(requestsAll)
- def test_filenameCollision_HandleRename(self):
+ def test_filenameCollision_doHandle(self):
self.connectClient()
# request a file
@@ -2519,7 +2519,7 @@
myIdentifier = self.client.getFile(
myKey,
fpath,
- filenameCollision=fcp2.ConstFilenameCollision.HandleRename,
+ handleFilenameCollision=True,
)
myRequest = self.client.getRequest(myIdentifier)
requestsAll = self.client.getRequests()
@@ -2549,12 +2549,8 @@
self.assertNotEqual(msg['Filename'], fpath)
# check flags
- filenameCollision = msg['FilenameCollision']
- self.assertEqual(
- filenameCollision & fcp2.ConstFilenameCollision.MaskHandle,
- fcp2.ConstFilenameCollision.HandleRename
- )
- self.failUnless(filenameCollision & fcp2.ConstFilenameCollision.CollisionHandled)
+ self.failUnless(myRequest['HandleFilenameCollision'])
+ self.failUnless(myRequest['FilenameCollisionHandled'])
self.assertHasNextEvent(None)
self.assertHasNextMessage(None)
@@ -2563,7 +2559,7 @@
self.failIf(requestsAll)
- def test_filenameCollision_HandleNever(self):
+ def test_filenameCollision_doNotHandle(self):
self.connectClient()
# request a file
@@ -2575,7 +2571,7 @@
myIdentifier = self.client.getFile(
myKey,
fpath,
- filenameCollision=fcp2.ConstFilenameCollision.HandleNever,
+ handleFilenameCollision=False,
)
myRequest = self.client.getRequest(myIdentifier)
requestsAll = self.client.getRequests()
@@ -2597,6 +2593,10 @@
Global='false',
)
+ # check flags
+ self.failIf(myRequest['HandleFilenameCollision'])
+ self.failIf(myRequest['FilenameCollisionHandled'])
+
# client schould send no messages and trigger a RequestFailed event
self.assertHasNextEvent(self.client.events.RequestFailed)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-07-20 10:35:33
|
Revision: 690
http://fclient.svn.sourceforge.net/fclient/?rev=690&view=rev
Author: jUrner
Date: 2008-07-20 10:35:34 +0000 (Sun, 20 Jul 2008)
Log Message:
-----------
bit betterr persistent params handling
Modified Paths:
--------------
trunk/fclient/src/fclient/lib/fcp2/message.py
Modified: trunk/fclient/src/fclient/lib/fcp2/message.py
===================================================================
--- trunk/fclient/src/fclient/lib/fcp2/message.py 2008-07-20 10:34:07 UTC (rev 689)
+++ trunk/fclient/src/fclient/lib/fcp2/message.py 2008-07-20 10:35:34 UTC (rev 690)
@@ -13,7 +13,7 @@
from . import config
from . import types
from . import key
-from .lib import node
+from .lib import node, pmstruct
#********************************************************************************
# consts
#********************************************************************************
@@ -170,30 +170,6 @@
pass
- def _setPersistentParams(self, persistentData):
- """updates message with persisten params
- @param persistentData: (str)
- """
- params = persistentData.split(PersistentParamsSep)
- if len(params) > len(self._persistent_params_):
- raise ValueError('Too many parameters in persistentData')
- elif len(params) < len(self._persistent_params_):
- raise ValueError('Too few parameters in persistentData')
- for n, (getter, setter) in enumerate(self._persistent_params_):
- setter(self, params[n])
-
-
- def _getPersistentParams(self):
- """retrieves persisten params from the message
- @return: (str) persistent params
- """
- out = []
- for n, (getter, setter) in enumerate(self._persistent_params_):
- #TODO: check if PersistentParamsSep is in data returned
- out.append(getter(self))
- return PersistentParamsSep.join(out)
-
-
def _restoreParams(self, params):
"""updates the message with mesasage params
@param params: (dict) containing message params
@@ -221,12 +197,15 @@
#********************************************************************************
_AdditionalGetParams = {
- # persistent params that will go into identifier
+ # persistent params
_PrivateParam('RequestType'): consts.ConstRequestType.Null, # identifies sub message types
_PrivateParam('InitTime'): 0, # when was the request started?
- _PrivateParam('FilenameCollision'): consts.ConstFilenameCollision.HandleNever, # handle fielanem collisions?
_PrivateParam('PersistentUserData'): '', # any user defined persistent data
-
+ _PrivateParam('HandleFilenameCollision'): False,
+ _PrivateParam('FilenameCollisionHandled'): False,
+ _PrivateParam('HandlePermanentRedirect'): False,
+ _PrivateParam('PermanentRedirectHandled'): False,
+
# non persistent params
_PrivateParam('RequestStatus'): consts.ConstRequestStatus.Null,
_PrivateParam('ErrorMessage'): None, # error message in case an error occured
@@ -253,11 +232,9 @@
_AdditionalPutParams = {
- # persistent params that will go into identifier
+ # persistent params
_PrivateParam('RequestType'): consts.ConstRequestType.Null, # identifies sub message types
_PrivateParam('InitTime'): 0, # when was the request started?
-
- #TODO: not really necessary, but we need it for persistent params
_PrivateParam('PersistentUserData'): '', # any user defined persistent data
# non persistent params
@@ -309,39 +286,26 @@
# these params are stored in ClientToken
#
#********************************************************************************
-_PersistentParamsGet = (
- (
- lambda msg: str(msg.__getitem__('RequestType')),
- lambda msg, value: msg.__setitem__('RequestType', int(value)),
- ),
- (
- lambda msg: str(msg.__getitem__('InitTime')),
- lambda msg, value: msg.__setitem__('InitTime', float(value)),
- ),
- (
- lambda msg: str(msg.__getitem__('FilenameCollision')),
- lambda msg, value: msg.__setitem__('FilenameCollision', int(value)),
- ),
- (
- lambda msg: base64.b64encode(msg.__getitem__('PersistentUserData')),
- lambda msg, value: msg.__setitem__('PersistentUserData', base64.b64decode(value)),
- ),
- )
+class PersistentParamsGet(pmstruct.PMStruct):
+ _fields_ = (
+ ('Version', pmstruct.INT),
+ ('RequestType', pmstruct.INT),
+ ('InitTime', pmstruct.FLOAT),
+ ('PersistentUserData', pmstruct.STRING),
+ ('HandleFilenameCollision', pmstruct.BOOL),
+ ('FilenameCollisionHandled', pmstruct.BOOL),
+ ('HandlePermanentRedirect', pmstruct.BOOL),
+ ('PermanentRedirectHandled', pmstruct.BOOL),
+ )
-_PersistentParamsPut = (
- (
- lambda msg: str(msg.__getitem__('RequestType')),
- lambda msg, value: msg.__setitem__('RequestType', int(value)),
- ),
- (
- lambda msg: str(msg.__getitem__('InitTime')),
- lambda msg, value: msg.__setitem__('InitTime', float(value)),
- ),
- (
- lambda msg: base64.b64encode(msg.__getitem__('PersistentUserData')),
- lambda msg, value: msg.__setitem__('PersistentUserData', base64.b64decode(value)),
- ),
- )
+class PersistentParamsPut(pmstruct.PMStruct):
+ _fields_ = (
+ ('Version', pmstruct.INT),
+ ('RequestType', pmstruct.INT),
+ ('InitTime', pmstruct.FLOAT),
+ ('PersistentUserData', pmstruct.STRING),
+ )
+
#********************************************************************************
#
#********************************************************************************
@@ -444,7 +408,6 @@
class MsgClientGet(_MessageBase):
name = consts.ConstMessage.ClientGet
_additional_params_ = _AdditionalGetParams
- _persistent_params_ = _PersistentParamsGet
_param_types_ = {
'BinaryBlob': types.TypeBool,
'DSOnly': types.TypeBool,
@@ -460,14 +423,25 @@
def _restoreParams(self, params):
_MessageBase._restoreParams(self, params)
try:
- _MessageBase._setPersistentParams(self, self['ClientToken'])
- except Exception, d:
- #print Exception, d
+ params = PersistentParamsGet.load(self['ClientToken'])
+ except pmstruct.PMStructError:
return False
+ self.params.update(params.values)
return True
+
def updatePersistentParams(self):
- self['ClientToken'] = _MessageBase._getPersistentParams(self)
+ params = PersistentParamsGet(
+ Version=1,
+ RequestType=self['RequestType'],
+ InitTime=self['InitTime'],
+ PersistentUserData=self['PersistentUserData'],
+ HandleFilenameCollision=self['HandleFilenameCollision'],
+ FilenameCollisionHandled=self['FilenameCollisionHandled'],
+ HandlePermanentRedirect=self['HandlePermanentRedirect'],
+ PermanentRedirectHandled=self['PermanentRedirectHandled'],
+ )
+ self['ClientToken'] = params.dump()
class MsgClientHello(_MessageBase):
@@ -481,7 +455,6 @@
class MsgClientPut(_MessageBase):
name = consts.ConstMessage.ClientPut
_additional_params_ = _AdditionalPutParams
- _persistent_params_ = _PersistentParamsPut
_param_types_ = {
'BinaryBlob': types.TypeBool,
'DataLength': types.TypeInt,
@@ -494,20 +467,27 @@
'Verbosity': types.TypeInt,
}
+
def _getDataLength(self):
return self['DataLength']
def _restoreParams(self, params):
_MessageBase._restoreParams(self, params)
try:
- _MessageBase._setPersistentParams(self, self['ClientToken'])
- except Exception, d:
- #print Exception, d
+ params = PersistentParamsPut.load(self['ClientToken'])
+ except pmstruct.PMStructError:
return False
+ self.params.update(params.values)
return True
-
+
def updatePersistentParams(self):
- self['ClientToken'] = _MessageBase._getPersistentParams(self)
+ params = PersistentParamsPut(
+ Version=1,
+ RequestType=self['RequestType'],
+ InitTime=self['InitTime'],
+ PersistentUserData=self['PersistentUserData'],
+ )
+ self['ClientToken'] = params.dump()
class MsgClientPutComplexDir(MsgClientPut):
@@ -886,50 +866,29 @@
}
-class MsgPersistentGet(_MessageBase):
+class MsgPersistentGet(MsgClientGet):
name = consts.ConstMessage.PersistentGet
_additional_params_ = _AdditionalGetParams
- _persistent_params_ = _PersistentParamsGet
_param_types_ = MsgClientGet._param_types_.copy()
_param_types_['Started'] = types.TypeBool
- def _restoreParams(self, params):
- _MessageBase._restoreParams(self, params)
- try:
- _MessageBase._setPersistentParams(self, self['ClientToken'])
- except Exception, d:
- #print Exception, d
- return False
- return True
-
-
-class MsgPersistentPut(_MessageBase):
+
+class MsgPersistentPut(MsgClientPut):
name = consts.ConstMessage.PersistentPut
_additional_params_ = _AdditionalPutParams
- _persistent_params_ = _PersistentParamsPut
_param_types_ = MsgClientPut._param_types_.copy()
_param_types_['Started'] = types.TypeBool
- def _restoreParams(self, params):
- _MessageBase._restoreParams(self, params)
- try:
- _MessageBase._setPersistentParams(self, self['ClientToken'])
- except Exception, d:
- #print Exception, d
- return False
- return True
-
-class MsgPersistentPutDir(_MessageBase):
+class MsgPersistentPutDir(MsgClientPut):
name = consts.ConstMessage.PersistentPutDir
_additional_params_ = _AdditionalPutParams
- _persistent_params_ = _PersistentParamsPut
_param_types_ = MsgClientPutDiskDir._param_types_.copy()
_param_types_['Started'] = types.TypeBool
def _restoreParams(self, params):
- _MessageBase._restoreParams(self, params)
+ MsgClientPut._restoreParams(self, params)
for paramName, paramValue in self.params.items():
tmp_paramName = paramName.split('.')
@@ -937,14 +896,7 @@
if tmp_paramName[-1] == 'DataLength':
n = types.TypeInt.fcpToPython(paramValue)
self[paramName] = n
-
- try:
- _MessageBase._setPersistentParams(self, self['ClientToken'])
- except Exception, d:
- #print Exception, d
- return False
- return True
-
+
class MsgPersistentRequestModified(_MessageBase):
name = consts.ConstMessage.PersistentRequestModified
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-07-20 10:34:07
|
Revision: 689
http://fclient.svn.sourceforge.net/fclient/?rev=689&view=rev
Author: jUrner
Date: 2008-07-20 10:34:07 +0000 (Sun, 20 Jul 2008)
Log Message:
-----------
support for persistent params handling
Added Paths:
-----------
trunk/fclient/src/fclient/lib/fcp2/lib/pmstruct.py
Added: trunk/fclient/src/fclient/lib/fcp2/lib/pmstruct.py
===================================================================
--- trunk/fclient/src/fclient/lib/fcp2/lib/pmstruct.py (rev 0)
+++ trunk/fclient/src/fclient/lib/fcp2/lib/pmstruct.py 2008-07-20 10:34:07 UTC (rev 689)
@@ -0,0 +1,215 @@
+"""poor mans struct
+
+simple structure with (safe) serializing support
+
+
+@requires: python >= 2.5 (L is never removed from str(nL) )
+"""
+
+import base64
+#*******************************************************************
+#
+#*******************************************************************
+class PMStructError(Exception): pass
+
+SEP = '|'
+HEADER = 'PMS'
+
+class BOOL(object):
+ _typecode_ = 'B'
+ @classmethod
+ def default(clss):
+ return False
+ @classmethod
+ def from_data(clss, data):
+ if data:
+ typecode, data = data[ :1], data [ 1: ]
+ if typecode == clss._typecode_:
+ try:
+ return data == '1'
+ except: pass
+ raise PMStructError('invalid bool')
+ @classmethod
+ def to_data(clss, value):
+ return clss._typecode_ + ('1' if value else '0')
+ @classmethod
+ def is_type(self, value):
+ return type(value) is bool
+
+
+class FLOAT(object):
+ _typecode_ = 'F'
+ @classmethod
+ def default(clss):
+ return 0.0
+ @classmethod
+ def from_data(clss, data):
+ if data:
+ typecode, data = data[ :1], data [ 1: ]
+ if typecode == clss._typecode_:
+ try:
+ return float(data)
+ except: pass
+ raise PMStructError('invalid int')
+ @classmethod
+ def to_data(clss, value):
+ return clss._typecode_ + str(value)
+ @classmethod
+ def is_type(self, value):
+ return type(value) is float
+
+
+class INT(object):
+ _typecode_ = 'I'
+ @classmethod
+ def default(clss):
+ return 0
+ @classmethod
+ def from_data(clss, data):
+ if data:
+ typecode, data = data[ :1], data [ 1: ]
+ if typecode == clss._typecode_:
+ try:
+ return int(data)
+ except: pass
+ raise PMStructError('invalid int')
+ @classmethod
+ def to_data(clss, value):
+ return clss._typecode_ + str(value)
+ @classmethod
+ def is_type(self, value):
+ return type(value) in (int, long)
+
+
+class STRING(object):
+ _typecode_ = 'S'
+ @classmethod
+ def default(clss):
+ return ''
+ @classmethod
+ def from_data(clss, data):
+ if data:
+ typecode, data = data[ :1], data [ 1: ]
+ if typecode == clss._typecode_:
+ try:
+ return base64.b64decode(data)
+ except: pass
+ raise PMStructError('invalid string')
+ @classmethod
+ def to_data(clss, value):
+ return clss._typecode_ + base64.b64encode(value)
+ @classmethod
+ def is_type(self, value):
+ return type(value) in (str, unicode)
+
+
+class PMStruct(object):
+ _fields_ = ()
+
+ def __init__(self, **kws):
+ self._fielddict_ = dict(self._fields_)
+ self.values = {}
+ for name, fieldtype in self._fields_:
+ value = kws.get(name, None)
+ if value is None:
+ value = fieldtype.default()
+ else:
+ if not fieldtype.is_type(value):
+ raise TypeError('invalid type for field: %r' % name)
+ del kws[name]
+ self.values[name] = value
+ if kws:
+ raise ValueError('no such field: %r' % kws.keys()[0])
+
+
+ def __getitem__(self, name):
+ return self.values[name]
+
+ def __setitem__(self, name, value):
+ fieldtype = self._fielddict_ [name]
+ if not fieldtype.is_type(value):
+ raise TypeError('invalid type for field: %r' % name)
+ self.values[name] = value
+
+
+ def __str__(self):
+ return self.__repr__()
+
+ def __repr__(self):
+ return '<PMS' + repr(self.values) + '>'
+
+ @classmethod
+ def load(clss, data):
+ data = data.split(SEP, 1)
+ if len(data) != 2:
+ raise PMStructError('invalid data')
+ header, data = data
+ if header != HEADER:
+ raise PMStructError('invalid data header')
+ #data = base64.b64decode(data)
+ data = data.split(SEP)
+ if len(data) != len(clss._fields_):
+ raise PMStructError('too few or too many fields')
+ kws = {}
+ for i, (name, fieldtype) in enumerate(clss._fields_):
+ kws[name] = fieldtype.from_data(data[i])
+ return clss(**kws)
+
+ def dump(self):
+ p = []
+ for name, fieldtype in self._fields_:
+ value = fieldtype.to_data(self.values[name])
+ p.append(value)
+ data = SEP.join(p)
+ #data = base64.b64encode(data)
+ return HEADER + SEP + data
+
+
+
+def foo():
+ class PersistentParamsGet(PMStruct):
+ _fields_ = (
+ ('Version', INT),
+ ('InitTime', FLOAT),
+ ('PersistentUserData', STRING),
+ ('HandleFilenameCollision', BOOL),
+ ('FilenameCollisionHandled', BOOL),
+ ('HandlePermanentRedirect', BOOL),
+ ('PermanentRedirectHandled', BOOL),
+ )
+
+
+ p = PersistentParamsGet()
+ print p.dump()
+ print p
+
+#foo()
+#print {1: 1, 2: 2}
+#print repr({1: 1, 2: 2})
+
+def test():
+
+ class MyStruct(PMStruct):
+ _fields_ = (
+ ('Foo', INT),
+ ('Bar', BOOL),
+ ('Baz', STRING),
+ ('Muu', FLOAT)
+ )
+
+
+
+ p = MyStruct(Foo=100000000000L, Bar=True, Baz=u'abcdefg', Muu=1.2345678)
+ x = p.dump()
+ print x
+ print p.load(x)
+ print p['Foo']
+ print p['Bar']
+ print p['Baz']
+ print p['Muu']
+
+ p['Muu'] = 123
+
+
+
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-07-19 12:53:29
|
Revision: 688
http://fclient.svn.sourceforge.net/fclient/?rev=688&view=rev
Author: jUrner
Date: 2008-07-19 12:53:32 +0000 (Sat, 19 Jul 2008)
Log Message:
-----------
register object
Modified Paths:
--------------
trunk/fclient/src/fclient/Ui_ViewDownloads.py
Modified: trunk/fclient/src/fclient/Ui_ViewDownloads.py
===================================================================
--- trunk/fclient/src/fclient/Ui_ViewDownloads.py 2008-07-19 12:53:07 UTC (rev 687)
+++ trunk/fclient/src/fclient/Ui_ViewDownloads.py 2008-07-19 12:53:32 UTC (rev 688)
@@ -67,11 +67,19 @@
self._isCreated = False
self.setupUi(self)
+ config.ObjectRegistry.register(self)
self.fcViewObject = DownloadsViewObject(self)
def viewClose(self):
pass
+
+ #########################################
+ ## methods
+ #########################################
+ def controlById(idGlobalFeedback, idControl):
+ return getattr(idGlobalFeedback, idControl)
+
#**********************************************************************************
#
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-07-19 12:53:03
|
Revision: 687
http://fclient.svn.sourceforge.net/fclient/?rev=687&view=rev
Author: jUrner
Date: 2008-07-19 12:53:07 +0000 (Sat, 19 Jul 2008)
Log Message:
-----------
ups, rename error
Modified Paths:
--------------
trunk/fclient/src/fclient/Ui_ViewConnection.py
Modified: trunk/fclient/src/fclient/Ui_ViewConnection.py
===================================================================
--- trunk/fclient/src/fclient/Ui_ViewConnection.py 2008-07-19 12:52:44 UTC (rev 686)
+++ trunk/fclient/src/fclient/Ui_ViewConnection.py 2008-07-19 12:53:07 UTC (rev 687)
@@ -30,33 +30,33 @@
class GlobalFeedback(config.GlobalFeedbackBase):
"""wrapper for global statusbar widgets, menus"""
- def __init__(idGlobalFeedback, parent, idFeedbackParent):
- config.GlobalFeedbackBase.__init__(idGlobalFeedback, parent, idFeedbackParent)
+ def __init__(self, parent,idGlobalFeedback):
+ config.GlobalFeedbackBase.__init__(self, parent,idGlobalFeedback)
# menus
- idGlobalFeedback.menus = []
- if idGlobalFeedback.menuBar is not None and hasattr(parent, 'fcViewObject'):
- menu = QtGui.QMenu(parent.fcViewObject.displayName, idGlobalFeedback.menuBar)
+ self.menus = []
+ if self.menuBar is not None and hasattr(parent, 'fcViewObject'):
+ menu = QtGui.QMenu(parent.fcViewObject.displayName, self.menuBar)
parent.populateMenu(menu)
- idGlobalFeedback.menus.append(menu)
- idGlobalFeedback.menuBar.addViewMenu(menu)
+ self.menus.append(menu)
+ self.menuBar.addViewMenu(menu)
# status bar widgets
- idGlobalFeedback.label1 = None
- #if idGlobalFeedback.statusBar is not None:
- # idGlobalFeedback.label1 = QtGui.QLabel('foo here', idGlobalFeedback.statusBar)
+ self.label1 = None
+ #if self.statusBar is not None:
+ # self.label1 = QtGui.QLabel('foo here', self.statusBar)
- def setVisible(idGlobalFeedback, flag):
- for menu in idGlobalFeedback.menus:
+ def setVisible(self, flag):
+ for menu in self.menus:
menu.children()[0].setVisible(flag)
- if idGlobalFeedback.label1 is not None:
- idGlobalFeedback.label1.setVisible(flag)
+ if self.label1 is not None:
+ self.label1.setVisible(flag)
class Settings(config.SettingsBase):
_key_ = config.IdViewConnectionWidget
_settings_ = (
- ('ConnectionTimerTimeout', 'UInt', 800, config.SettingScopeExpert),
+ ('ConnectionTimerTimeout', 'UInt', 500, config.SettingScopeExpert),
('ConnectionTimerMaxDuration', 'UInt', 20, config.SettingScopeExpert),
('PollTimerTimeout', 'UInt', 200, config.SettingScopeExpert),
@@ -68,12 +68,12 @@
class ConnectionViewObject(config.ViewObject):
- def __init__(idGlobalFeedback, parent):
- config.ViewObject. __init__(idGlobalFeedback, parent)
+ def __init__(self, parent):
+ config.ViewObject. __init__(self, parent)
- idGlobalFeedback.name=parent.objectName()
- idGlobalFeedback.displayName=idGlobalFeedback.trUtf8('Connection')
- idGlobalFeedback.icon=QtGui.QIcon()
+ self.name=parent.objectName()
+ self.displayName=self.trUtf8('Connection')
+ self.icon=QtGui.QIcon()
#**********************************************************************************
@@ -81,27 +81,27 @@
#**********************************************************************************
class ConnectionTimer(QtCore.QTimer):
- def __init__(idGlobalFeedback,parent):
- QtCore.QTimer.__init__(idGlobalFeedback, parent)
- idGlobalFeedback.fcpIterConnect = None
- idGlobalFeedback.connect(idGlobalFeedback, QtCore.SIGNAL('timeout()'), idGlobalFeedback.onNext)
+ def __init__(self,parent):
+ QtCore.QTimer.__init__(self, parent)
+ self.fcpIterConnect = None
+ self.connect(self, QtCore.SIGNAL('timeout()'), self.onNext)
- def start(idGlobalFeedback, settings):
- idGlobalFeedback.fcpIterConnect = config.fcpClient.iterConnect(
+ def start(self, settings):
+ self.fcpIterConnect = config.fcpClient.iterConnect(
duration=settings.value('ConnectionTimerMaxDuration'),
timeout=0
)
- if not idGlobalFeedback.onNext():
- QtCore.QTimer.start(idGlobalFeedback, settings.value('ConnectionTimerTimeout'))
+ if not self.onNext():
+ QtCore.QTimer.start(self, settings.value('ConnectionTimerTimeout'))
- def onNext(idGlobalFeedback):
+ def onNext(self):
try:
- result = idGlobalFeedback.fcpIterConnect.next()
+ result = self.fcpIterConnect.next()
except StopIteration:
- idGlobalFeedback.stop()
+ self.stop()
else:
if result is not None:
- idGlobalFeedback.stop()
+ self.stop()
# 1st thing todo after connect is to query the config from the node so all
# listeners right away so not everyone has to query it so. needs more details
# or joins the gui later.. feel free to query again
@@ -112,14 +112,14 @@
class PollTimer(QtCore.QTimer):
- def __init__(idGlobalFeedback,parent):
- QtCore.QTimer.__init__(idGlobalFeedback, parent)
- idGlobalFeedback.connect(idGlobalFeedback, QtCore.SIGNAL('timeout()'), idGlobalFeedback.onNext)
+ def __init__(self,parent):
+ QtCore.QTimer.__init__(self, parent)
+ self.connect(self, QtCore.SIGNAL('timeout()'), self.onNext)
- def start(idGlobalFeedback, settings):
- QtCore.QTimer.start(idGlobalFeedback, settings.value('PollTimerTimeout'))
+ def start(self, settings):
+ QtCore.QTimer.start(self, settings.value('PollTimerTimeout'))
- def onNext(idGlobalFeedback):
+ def onNext(self):
if config.fcpClient.isConnected():
result = config.fcpClient.next()
@@ -133,119 +133,119 @@
IdEdConnectionHost = 'edConnectionHost' #TODO: combobox? validate input.
IdSpinConnectionPort = 'spinConnectionPort'
- def __init__(idGlobalFeedback, parent, idFeedbackParent=config.IdMainWindow):
- QtGui.QWidget.__init__(idGlobalFeedback, parent)
+ def __init__(self, parent,idGlobalFeedback=config.IdMainWindow):
+ QtGui.QWidget.__init__(self, parent)
- idGlobalFeedback._isCreated = False
- idGlobalFeedback._connectionTimer = ConnectionTimer(idGlobalFeedback)
- idGlobalFeedback._pollTimer = PollTimer(idGlobalFeedback)
- idGlobalFeedback._fcpEventonrs = (
- (config.fcpClient.events.ClientConnected, idGlobalFeedback.onFcpClientConected),
- (config.fcpClient.events.ClientDisconnected, idGlobalFeedback.onFcpClientDisconected),
+ self._isCreated = False
+ self._connectionTimer = ConnectionTimer(self)
+ self._pollTimer = PollTimer(self)
+ self._fcpEventonrs = (
+ (config.fcpClient.events.ClientConnected, self.onFcpClientConected),
+ (config.fcpClient.events.ClientDisconnected, self.onFcpClientDisconected),
)
- config.fcpClient.events += idGlobalFeedback._fcpEventonrs
- idGlobalFeedback._mainWindowMenus = ()
+ config.fcpClient.events += self._fcpEventonrs
+ self._mainWindowMenus = ()
- idGlobalFeedback.setupUi(idGlobalFeedback)
- config.ObjectRegistry.register(idGlobalFeedback)
- idGlobalFeedback.fcSettings = Settings().restore()
- idGlobalFeedback.fcActions = Actions(idGlobalFeedback)
- idGlobalFeedback.fcViewObject = ConnectionViewObject(idGlobalFeedback)
- idGlobalFeedback.fcGlobalFeedback = GlobalFeedback(idGlobalFeedback, idFeedbackParent)
+ self.setupUi(self)
+ config.ObjectRegistry.register(self)
+ self.fcSettings = Settings().restore()
+ self.fcActions = Actions(self)
+ self.fcViewObject = ConnectionViewObject(self)
+ self.fcGlobalFeedback = GlobalFeedback(self,idGlobalFeedback)
#########################################
## methods
#########################################
- def controlById(idGlobalFeedback, idControl):
- return getattr(idGlobalFeedback, idControl)
+ def controlById(self, idControl):
+ return getattr(self, idControl)
- def populateMenu(idGlobalFeedback, menu):
+ def populateMenu(self, menu):
return menu
#########################################
## view methods
#########################################
- def viewClose(idGlobalFeedback):
- config.fcpClient.events -= idGlobalFeedback._fcpEventonrs
+ def viewClose(self):
+ config.fcpClient.events -= self._fcpEventonrs
#########################################
## overwritten events
#########################################
- def closeEvent(idGlobalFeedback, event):
- idGlobalFeedback.viewClose()
+ def closeEvent(self, event):
+ self.viewClose()
- def hideEvent(idGlobalFeedback, event):
- idGlobalFeedback.fcGlobalFeedback.setVisible(False)
+ def hideEvent(self, event):
+ self.fcGlobalFeedback.setVisible(False)
- def showEvent(idGlobalFeedback, event):
- idGlobalFeedback.fcGlobalFeedback.setVisible(True)
- if idGlobalFeedback._isCreated:
+ def showEvent(self, event):
+ self.fcGlobalFeedback.setVisible(True)
+ if self._isCreated:
return
- idGlobalFeedback._isCreated = True
+ self._isCreated = True
# setup host / port boxes
- edHost = idGlobalFeedback.controlById(idGlobalFeedback.IdEdConnectionHost)
- edHost.setText(idGlobalFeedback.fcSettings.value('ConnectionHost'))
+ edHost = self.controlById(self.IdEdConnectionHost)
+ edHost.setText(self.fcSettings.value('ConnectionHost'))
- spinPort = idGlobalFeedback.controlById(idGlobalFeedback.IdSpinConnectionPort)
+ spinPort = self.controlById(self.IdSpinConnectionPort)
spinPort.setRange(0, 0xFFFF) #TODO: no idea if port range (0, 0xFFFF) this is reasonable
- spinPort.setValue(idGlobalFeedback.fcSettings.value('ConnectionPort'))
+ spinPort.setValue(self.fcSettings.value('ConnectionPort'))
# setup Connect button and AutoConnect checkbox
- doAutoConnect = idGlobalFeedback.fcSettings.value('AutoConnect')
- ck = idGlobalFeedback.controlById(idGlobalFeedback.IdckAutoConnect)
+ doAutoConnect = self.fcSettings.value('AutoConnect')
+ ck = self.controlById(self.IdckAutoConnect)
ck.setChecked(doAutoConnect)
- idGlobalFeedback.connect(ck, QtCore.SIGNAL('stateChanged(int)'), idGlobalFeedback.onCkAutoConnectStateChanged)
+ self.connect(ck, QtCore.SIGNAL('stateChanged(int)'), self.onCkAutoConnectStateChanged)
- bt = idGlobalFeedback.controlById(idGlobalFeedback.IdBtConnect)
- idGlobalFeedback.connect(bt, QtCore.SIGNAL('clicked(bool)'), idGlobalFeedback.onBtConnectClicked)
+ bt = self.controlById(self.IdBtConnect)
+ self.connect(bt, QtCore.SIGNAL('clicked(bool)'), self.onBtConnectClicked)
if doAutoConnect:
- idGlobalFeedback.controlById(idGlobalFeedback.IdBtConnect).click()
+ self.controlById(self.IdBtConnect).click()
########################################
## overwritten methods
#########################################
- def retranslateUi(idGlobalFeedback, w):
- Ui_ViewConnectionWidget.retranslateUi(idGlobalFeedback, w)
- bt = idGlobalFeedback.controlById(idGlobalFeedback.IdBtConnect)
- bt.setText(idGlobalFeedback.trUtf8('Disconnect') if bt.isChecked() else idGlobalFeedback.trUtf8('Connect'))
+ def retranslateUi(self, w):
+ Ui_ViewConnectionWidget.retranslateUi(self, w)
+ bt = self.controlById(self.IdBtConnect)
+ bt.setText(self.trUtf8('Disconnect') if bt.isChecked() else self.trUtf8('Connect'))
#########################################
## event onrs
#########################################
- def onBtConnectClicked(idGlobalFeedback, isChecked):
- bt = idGlobalFeedback.controlById(idGlobalFeedback.IdBtConnect)
- bt.setText(idGlobalFeedback.trUtf8('Disconnect') if isChecked else idGlobalFeedback.trUtf8('Connect'))
+ def onBtConnectClicked(self, isChecked):
+ bt = self.controlById(self.IdBtConnect)
+ bt.setText(self.trUtf8('Disconnect') if isChecked else self.trUtf8('Connect'))
if isChecked:
if config.fcpClient.isConnected():
config.fcpClient.close()
- idGlobalFeedback._connectionTimer.start(idGlobalFeedback.fcSettings)
+ self._connectionTimer.start(self.fcSettings)
else:
- idGlobalFeedback._connectionTimer.stop()
+ self._connectionTimer.stop()
if config.fcpClient.isConnected():
- idGlobalFeedback._pollTimer.stop()
+ self._pollTimer.stop()
config.fcpClient.close()
- def onCkAutoConnectStateChanged(idGlobalFeedback, state):
- idGlobalFeedback.fcSettings.setValues(AutoConnect=state == QtCore.Qt.Checked)
+ def onCkAutoConnectStateChanged(self, state):
+ self.fcSettings.setValues(AutoConnect=state == QtCore.Qt.Checked)
#########################################
## fcp event onrs
#########################################
- def onFcpClientDisconected(idGlobalFeedback, event, msg):
- bt = idGlobalFeedback.controlById(idGlobalFeedback.IdBtConnect)
+ def onFcpClientDisconected(self, event, msg):
+ bt = self.controlById(self.IdBtConnect)
if bt.isChecked():
bt.click()
- def onFcpClientConected(idGlobalFeedback, event, msg):
- idGlobalFeedback._pollTimer.start(idGlobalFeedback.fcSettings)
+ def onFcpClientConected(self, event, msg):
+ self._pollTimer.start(self.fcSettings)
#**********************************************************************************
#
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-07-19 12:52:40
|
Revision: 686
http://fclient.svn.sourceforge.net/fclient/?rev=686&view=rev
Author: jUrner
Date: 2008-07-19 12:52:44 +0000 (Sat, 19 Jul 2008)
Log Message:
-----------
init order of widgets
Modified Paths:
--------------
trunk/fclient/src/fclient/fclient.py
Modified: trunk/fclient/src/fclient/fclient.py
===================================================================
--- trunk/fclient/src/fclient/fclient.py 2008-07-19 10:57:04 UTC (rev 685)
+++ trunk/fclient/src/fclient/fclient.py 2008-07-19 12:52:44 UTC (rev 686)
@@ -23,13 +23,14 @@
viewWidget = ViewWidget(mainWindow)
mainWindow.setCentralWidget(viewWidget)
+ viewWidget.addBottomViews(ViewLoggerWidget(mainWindow))
viewWidget.addTopViews(
ViewConnectionWidget(mainWindow),
ViewBrowserWidget(mainWindow),
ViewDownloadsWidget(mainWindow),
)
- viewWidget.addBottomViews(ViewLoggerWidget(mainWindow))
+
mainWindow.show()
res = app.exec_()
sys.exit(res)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-07-19 10:56:57
|
Revision: 685
http://fclient.svn.sourceforge.net/fclient/?rev=685&view=rev
Author: jUrner
Date: 2008-07-19 10:57:04 +0000 (Sat, 19 Jul 2008)
Log Message:
-----------
add basic code for downloads widget to the gui
Modified Paths:
--------------
trunk/fclient/src/fclient/config.py
trunk/fclient/src/fclient/fclient.py
Added Paths:
-----------
trunk/fclient/src/fclient/Ui_ViewDownloads.py
trunk/fclient/src/fclient/tpls/Ui_ViewDownloadsWidgetTpl.py
trunk/fclient/src/fclient/tpls/ViewDownloadsWidgetTpl.ui
Added: trunk/fclient/src/fclient/Ui_ViewDownloads.py
===================================================================
--- trunk/fclient/src/fclient/Ui_ViewDownloads.py (rev 0)
+++ trunk/fclient/src/fclient/Ui_ViewDownloads.py 2008-07-19 10:57:04 UTC (rev 685)
@@ -0,0 +1,96 @@
+""""""
+
+#**************************************************************************************************************
+#TODO:
+#
+# x. prtty tricky to get dls right when the node or client may disconnect unexpectedly
+# problem: dls that we send and that have not reached the node
+# problem: what to do when the user wants to quit and we still have dls to push to the node
+#
+# solution would require keeping track of all requests
+# a. keep identifiers of requests that reached the node (have to do it anyways)
+# b. keep track of requests ahead of sending them to the node (feels not too good doubeling downloads.dat.gz)
+#
+# best idea seems to be to ignore the problem
+# 1. wait till (if ever) freenet devels fdrop node keeping track of client requests
+#
+# 2. a box thrown to the user (x. do not show this message again) to inform him about pendings
+# should be enough. maybe along with a separate widget or some separate color code for pendings
+#
+# x. performance
+# start with a standard model and improve it over time. no need to set any hard
+# limits. the user will find out by himself how many dls his machine can handle.
+# have to be carefrul though when adding dls, like from a *.frdx to provide appropriate
+# warnings
+#**************************************************************************************************************
+from __future__ import absolute_import
+if __name__ == '__main__': # see --> http://bugs.python.org/issue1510172 . works only current dir and below
+ import os; __path__ = [os.path.dirname(__file__)]
+
+from PyQt4 import QtCore, QtGui
+
+from . import config
+from .lib import fcp2
+
+from .tpls.Ui_ViewDownloadsWidgetTpl import Ui_ViewDownloadsWidget
+#**********************************************************************************
+#
+#**********************************************************************************
+class DownloadsViewObject(config.ViewObject):
+
+ def __init__(self, parent):
+ config.ViewObject. __init__(self, parent)
+
+ self.name=parent.objectName()
+ self.displayName=self.trUtf8('Downloads')
+ self.icon=QtGui.QIcon()
+
+
+#**********************************************************************************
+#
+#**********************************************************************************
+class Model(QtGui.QStandardItemModel):
+
+ def __init__(self, parent=None):
+ pass
+
+#**********************************************************************************
+#
+#**********************************************************************************
+class ViewDownloadsWidget(QtGui.QWidget, Ui_ViewDownloadsWidget):
+
+ IdTreeView = 'treeView'
+
+
+ def __init__(self, parent, idGlobalFeedback=config.IdMainWindow):
+ QtGui.QWidget.__init__(self, parent)
+ self._isCreated = False
+
+ self.setupUi(self)
+
+ self.fcViewObject = DownloadsViewObject(self)
+
+ def viewClose(self):
+ pass
+
+#**********************************************************************************
+#
+#**********************************************************************************
+if __name__ == '__main__':
+ import sys
+ from . import Ui_View
+ from . import Ui_ViewConnection
+ from . import Ui_ViewLogger
+
+
+ app = QtGui.QApplication(sys.argv)
+ w = Ui_View.ViewWidget(None)
+ w.addTopViews(
+ Ui_ViewConnection.ViewConnectionWidget(None),
+ ViewDownloadsWidget(None),
+ )
+ w.addBottomViews(Ui_ViewLogger.ViewLoggerWidget(None))
+
+ w.show()
+ res = app.exec_()
+ sys.exit(res)
\ No newline at end of file
Modified: trunk/fclient/src/fclient/config.py
===================================================================
--- trunk/fclient/src/fclient/config.py 2008-07-19 10:55:05 UTC (rev 684)
+++ trunk/fclient/src/fclient/config.py 2008-07-19 10:57:04 UTC (rev 685)
@@ -35,6 +35,7 @@
IdViewWidget = 'ViewWidget'
IdViewBrowserWidget = 'ViewBrowserWidget'
IdViewConnectionWidget = 'ViewConnectionWidget'
+IdViewLoggerWidget = 'ViewDownloadsWidget'
IdViewLoggerWidget = 'ViewLoggerWidget'
Modified: trunk/fclient/src/fclient/fclient.py
===================================================================
--- trunk/fclient/src/fclient/fclient.py 2008-07-19 10:55:05 UTC (rev 684)
+++ trunk/fclient/src/fclient/fclient.py 2008-07-19 10:57:04 UTC (rev 685)
@@ -10,6 +10,7 @@
from .Ui_View import ViewWidget
from .Ui_ViewBrowser import ViewBrowserWidget
from .Ui_ViewConnection import ViewConnectionWidget
+from .Ui_ViewDownloads import ViewDownloadsWidget
from .Ui_ViewLogger import ViewLoggerWidget
#*************************************************************
#
@@ -25,6 +26,7 @@
viewWidget.addTopViews(
ViewConnectionWidget(mainWindow),
ViewBrowserWidget(mainWindow),
+ ViewDownloadsWidget(mainWindow),
)
viewWidget.addBottomViews(ViewLoggerWidget(mainWindow))
Added: trunk/fclient/src/fclient/tpls/Ui_ViewDownloadsWidgetTpl.py
===================================================================
--- trunk/fclient/src/fclient/tpls/Ui_ViewDownloadsWidgetTpl.py (rev 0)
+++ trunk/fclient/src/fclient/tpls/Ui_ViewDownloadsWidgetTpl.py 2008-07-19 10:57:04 UTC (rev 685)
@@ -0,0 +1,37 @@
+# -*- coding: utf-8 -*-
+
+# Form implementation generated from reading ui file '/home/me/src/proj/fclient/trunk/fclient/src/fclient/tpls/ViewDownloadsWidgetTpl.ui'
+#
+# Created: Sat Jul 19 12:46:32 2008
+# by: PyQt4 UI code generator 4.4.3-snapshot-20080705
+#
+# WARNING! All changes made in this file will be lost!
+
+from PyQt4 import QtCore, QtGui
+
+class Ui_ViewDownloadsWidget(object):
+ def setupUi(self, ViewDownloadsWidget):
+ ViewDownloadsWidget.setObjectName("ViewDownloadsWidget")
+ ViewDownloadsWidget.resize(400, 300)
+ self.gridLayout = QtGui.QGridLayout(ViewDownloadsWidget)
+ self.gridLayout.setObjectName("gridLayout")
+ self.treeView = QtGui.QTreeView(ViewDownloadsWidget)
+ self.treeView.setObjectName("treeView")
+ self.gridLayout.addWidget(self.treeView, 0, 0, 1, 1)
+
+ self.retranslateUi(ViewDownloadsWidget)
+ QtCore.QMetaObject.connectSlotsByName(ViewDownloadsWidget)
+
+ def retranslateUi(self, ViewDownloadsWidget):
+ ViewDownloadsWidget.setWindowTitle(QtGui.QApplication.translate("ViewDownloadsWidget", "Form", None, QtGui.QApplication.UnicodeUTF8))
+
+
+if __name__ == "__main__":
+ import sys
+ app = QtGui.QApplication(sys.argv)
+ ViewDownloadsWidget = QtGui.QWidget()
+ ui = Ui_ViewDownloadsWidget()
+ ui.setupUi(ViewDownloadsWidget)
+ ViewDownloadsWidget.show()
+ sys.exit(app.exec_())
+
Added: trunk/fclient/src/fclient/tpls/ViewDownloadsWidgetTpl.ui
===================================================================
--- trunk/fclient/src/fclient/tpls/ViewDownloadsWidgetTpl.ui (rev 0)
+++ trunk/fclient/src/fclient/tpls/ViewDownloadsWidgetTpl.ui 2008-07-19 10:57:04 UTC (rev 685)
@@ -0,0 +1,23 @@
+<ui version="4.0" >
+ <class>ViewDownloadsWidget</class>
+ <widget class="QWidget" name="ViewDownloadsWidget" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>Form</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout" >
+ <item row="0" column="0" >
+ <widget class="QTreeView" name="treeView" />
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-07-19 10:54:56
|
Revision: 684
http://fclient.svn.sourceforge.net/fclient/?rev=684&view=rev
Author: jUrner
Date: 2008-07-19 10:55:05 +0000 (Sat, 19 Jul 2008)
Log Message:
-----------
more todos
Modified Paths:
--------------
trunk/fclient/src/fclient/Ui_ViewBrowser.py
Modified: trunk/fclient/src/fclient/Ui_ViewBrowser.py
===================================================================
--- trunk/fclient/src/fclient/Ui_ViewBrowser.py 2008-07-19 09:48:57 UTC (rev 683)
+++ trunk/fclient/src/fclient/Ui_ViewBrowser.py 2008-07-19 10:55:05 UTC (rev 684)
@@ -13,6 +13,7 @@
# x. fProxy is a bit tight-lipped when it comes to feedback. no idea
# x. give feedback on tabs about load / finisched / error. maybe some color code. wait for new QTabWidget features (qt4.5)
# x. close button on tabs. wait for new QTabWidget features (qt4.5)
+# x. zoom in/out
#
#******************************************************************************************
from __future__ import absolute_import
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-07-19 09:48:50
|
Revision: 683
http://fclient.svn.sourceforge.net/fclient/?rev=683&view=rev
Author: jUrner
Date: 2008-07-19 09:48:57 +0000 (Sat, 19 Jul 2008)
Log Message:
-----------
some notes
Modified Paths:
--------------
trunk/fclient/src/fclient/Ui_ViewBrowser.py
Modified: trunk/fclient/src/fclient/Ui_ViewBrowser.py
===================================================================
--- trunk/fclient/src/fclient/Ui_ViewBrowser.py 2008-07-19 09:48:44 UTC (rev 682)
+++ trunk/fclient/src/fclient/Ui_ViewBrowser.py 2008-07-19 09:48:57 UTC (rev 683)
@@ -1,7 +1,19 @@
#******************************************************************************************
#TODO:
+# x. someday. maybe. reimpl to browse via fcp.
+# x. page history is cleared if we get an error on loading a page. reimpl page history?
+# x. back-is-close like behaviour
+# x. always open links in new tabs
+# x. backand forward buttons suck somehow. sometimes fwd is enabled even if no fwd is available. reimpl page history?
+# x. save page / image whatever
+# x. download. idea is to add dls to global download widget and mark them (some color code) as new content.
+# alt would be to to do it firefox like in a separate widget. maybe an option to adjust if browser dls should be
+# persistent or not
+# x. tool buttons do not adjust their size to icon size. maybe it is some global setting via qt-config
+# x. fProxy is a bit tight-lipped when it comes to feedback. no idea
+# x. give feedback on tabs about load / finisched / error. maybe some color code. wait for new QTabWidget features (qt4.5)
+# x. close button on tabs. wait for new QTabWidget features (qt4.5)
#
-#
#******************************************************************************************
from __future__ import absolute_import
if __name__ == '__main__': # see --> http://bugs.python.org/issue1510172 . works only current dir and below
@@ -272,15 +284,8 @@
self.connect(self, QtCore.SIGNAL('iconChanged()'), self.onIconChanged)
self.connect(self.pageAction(QtWebKit.QWebPage.Stop), QtCore.SIGNAL('triggered()'), self.onActionStopTriggered)
-
- #TODO:
- #
- # x. page history is cleared if we get an error on loading a page. reimpl page history?
- # x. back-is close like behaviour
- # x. always open links in new tabs
- # x. backand forward buttons sucks somehow. sometimed fwd is enabled even if no fwd is available. reimpl page history?
+
-
# not needed. we handle OpenLinkInNewWindow et al in contextMenuEvent
#def createWindow(self, typeWindow):
# pass
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-07-19 09:48:37
|
Revision: 682
http://fclient.svn.sourceforge.net/fclient/?rev=682&view=rev
Author: jUrner
Date: 2008-07-19 09:48:44 +0000 (Sat, 19 Jul 2008)
Log Message:
-----------
some notes
Modified Paths:
--------------
trunk/fclient/src/fclient/Ui_ViewConnection.py
Modified: trunk/fclient/src/fclient/Ui_ViewConnection.py
===================================================================
--- trunk/fclient/src/fclient/Ui_ViewConnection.py 2008-07-19 09:19:07 UTC (rev 681)
+++ trunk/fclient/src/fclient/Ui_ViewConnection.py 2008-07-19 09:48:44 UTC (rev 682)
@@ -1,7 +1,18 @@
+#*********************************************************************
+#NOTES:
+#
+# current handling is:
+# 1. connect to fcp client
+# 2. query config
+#
+# all listebners interested in fcp client should take arrival of config
+# as signal to start doing whatever
+#
+#*********************************************************************
+
from __future__ import absolute_import
if __name__ == '__main__': # see --> http://bugs.python.org/issue1510172 . works only current dir and below
import os; __path__ = [os.path.dirname(__file__)]
-
from PyQt4 import QtCore, QtGui
@@ -241,7 +252,7 @@
#**********************************************************************************
if __name__ == '__main__':
import sys
- from . import Ui_ViewLogger
+ from . import Ui_View, Ui_ViewLogger
app = QtGui.QApplication(sys.argv)
w = Ui_View.ViewWidget(None)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-07-19 09:19:04
|
Revision: 681
http://fclient.svn.sourceforge.net/fclient/?rev=681&view=rev
Author: jUrner
Date: 2008-07-19 09:19:07 +0000 (Sat, 19 Jul 2008)
Log Message:
-----------
added "close all tabs" action ++ this and that
Modified Paths:
--------------
trunk/fclient/src/fclient/Ui_ViewBrowser.py
Modified: trunk/fclient/src/fclient/Ui_ViewBrowser.py
===================================================================
--- trunk/fclient/src/fclient/Ui_ViewBrowser.py 2008-07-19 09:02:08 UTC (rev 680)
+++ trunk/fclient/src/fclient/Ui_ViewBrowser.py 2008-07-19 09:19:07 UTC (rev 681)
@@ -44,23 +44,29 @@
config.ActionsBase.__init__(self, parent)
self.action(
- name='ActionCloseCurrentBrowser',
- text=self.trUtf8('&Close tab'),
- trigger=parent.onActionCloseCurrentBrowser,
+ name='ActionCloseCurrentTab',
+ text=self.trUtf8('Close ¤t tab'),
+ trigger=parent.onActionCloseCurrentTab,
#isEnabled=False,
)
self.action( # context menu only
name='ActionCloseBrowserUnderMouse',
- text=self.trUtf8('&Close tab'),
+ text=self.trUtf8('&Close tab under mouse'),
trigger=None,
#isEnabled=False,
)
self.action(
name='ActionGoToFProxy',
- text=self.trUtf8('F&Proxy homepage'),
+ text=self.trUtf8('Go to f&Proxy homepage'),
trigger=parent.onActionGoToFProxy,
isEnabled=True,
)
+ self.action(
+ name='ActionCloseAllTabs',
+ text=self.trUtf8('Close &all tabs'),
+ trigger=parent.onActionCloseAllTabs,
+ isEnabled=True,
+ )
class GlobalFeedback(config.GlobalFeedbackBase):
@@ -255,8 +261,6 @@
act = self.pageAction(a)
act.setIcon(config.resources.getIcon(iconName, iconSize, iconTheme=iconTheme))
- self.connect(self.pageAction(QtWebKit.QWebPage.Stop), QtCore.SIGNAL('triggered()'), self.onActionStopTriggered)
-
# connect actions
#TODO: download action
self.connect(self, QtCore.SIGNAL('loadStarted()'), self.onLoadStarted)
@@ -267,12 +271,14 @@
self.connect(self, QtCore.SIGNAL('titleChanged(const QString &)'), self.onTitleChanged)
self.connect(self, QtCore.SIGNAL('iconChanged()'), self.onIconChanged)
+ self.connect(self.pageAction(QtWebKit.QWebPage.Stop), QtCore.SIGNAL('triggered()'), self.onActionStopTriggered)
+
#TODO:
#
- # x. set busy cursor if loading
- # x. page history is cleared if we get an error on loading a page. reimpl page history
+ # x. page history is cleared if we get an error on loading a page. reimpl page history?
# x. back-is close like behaviour
# x. always open links in new tabs
+ # x. backand forward buttons sucks somehow. sometimed fwd is enabled even if no fwd is available. reimpl page history?
# not needed. we handle OpenLinkInNewWindow et al in contextMenuEvent
@@ -581,7 +587,8 @@
#TODO: rework. we need more then one menu
def populateMenu(self, menu):
menu.addAction(self.fcActions['ActionGoToFProxy'])
- menu.addAction(self.fcActions['ActionCloseCurrentBrowser'])
+ menu.addAction(self.fcActions['ActionCloseCurrentTab'])
+ menu.addAction(self.fcActions['ActionCloseAllTabs'])
return menu
#########################################
@@ -602,7 +609,6 @@
def closeEvent(self):
self.viewClose()
-
#########################################
## fcp event onrs
#########################################
@@ -646,7 +652,7 @@
#########################################
##
#########################################
- def onActionCloseCurrentBrowser(self, action):
+ def onActionCloseCurrentTab(self, action):
tabWidget = self.controlById(self.IdTabBrowsers)
tabWidget.removeTab(tabWidget.currentIndex())
@@ -688,10 +694,14 @@
tabWidget = self.controlById(self.IdTabBrowsers)
if not tabWidget.count():
self.newTab(tabText=self.trUtf8(''))
-
self.load(ed.text())
+ def onActionCloseAllTabs(self, action):
+ tabWidget = self.controlById(self.IdTabBrowsers)
+ tabWidget.clear()
+
+
def onActionGoToFProxy(self, action):
if self.fproxyHost is None:
#TODO: on
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-07-19 09:02:14
|
Revision: 680
http://fclient.svn.sourceforge.net/fclient/?rev=680&view=rev
Author: jUrner
Date: 2008-07-19 09:02:08 +0000 (Sat, 19 Jul 2008)
Log Message:
-----------
some nice icons
Added Paths:
-----------
trunk/fclient/src/fclient/res/
trunk/fclient/src/fclient/res/icons/
trunk/fclient/src/fclient/res/icons/crystal/
trunk/fclient/src/fclient/res/icons/crystal/16x16/
trunk/fclient/src/fclient/res/icons/crystal/16x16/back.png
trunk/fclient/src/fclient/res/icons/crystal/16x16/back2.png
trunk/fclient/src/fclient/res/icons/crystal/16x16/forward.png
trunk/fclient/src/fclient/res/icons/crystal/16x16/reload_page.png
trunk/fclient/src/fclient/res/icons/crystal/16x16/stop.png
trunk/fclient/src/fclient/res/icons/crystal/32x32/
trunk/fclient/src/fclient/res/icons/crystal/32x32/back.png
trunk/fclient/src/fclient/res/icons/crystal/32x32/back2.png
trunk/fclient/src/fclient/res/icons/crystal/32x32/forward.png
trunk/fclient/src/fclient/res/icons/crystal/32x32/reload_page.png
trunk/fclient/src/fclient/res/icons/crystal/32x32/stop.png
trunk/fclient/src/fclient/res/icons/crystal/48x48/
trunk/fclient/src/fclient/res/icons/crystal/48x48/back.png
trunk/fclient/src/fclient/res/icons/crystal/48x48/back2.png
trunk/fclient/src/fclient/res/icons/crystal/48x48/forward.png
trunk/fclient/src/fclient/res/icons/crystal/48x48/reload_page.png
trunk/fclient/src/fclient/res/icons/crystal/48x48/stop.png
Property changes on: trunk/fclient/src/fclient/res/icons/crystal/16x16/back.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Property changes on: trunk/fclient/src/fclient/res/icons/crystal/16x16/back2.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Property changes on: trunk/fclient/src/fclient/res/icons/crystal/16x16/forward.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Property changes on: trunk/fclient/src/fclient/res/icons/crystal/16x16/reload_page.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Property changes on: trunk/fclient/src/fclient/res/icons/crystal/16x16/stop.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Property changes on: trunk/fclient/src/fclient/res/icons/crystal/32x32/back.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Property changes on: trunk/fclient/src/fclient/res/icons/crystal/32x32/back2.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Property changes on: trunk/fclient/src/fclient/res/icons/crystal/32x32/forward.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Property changes on: trunk/fclient/src/fclient/res/icons/crystal/32x32/reload_page.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Property changes on: trunk/fclient/src/fclient/res/icons/crystal/32x32/stop.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Property changes on: trunk/fclient/src/fclient/res/icons/crystal/48x48/back.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Property changes on: trunk/fclient/src/fclient/res/icons/crystal/48x48/back2.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Property changes on: trunk/fclient/src/fclient/res/icons/crystal/48x48/forward.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Property changes on: trunk/fclient/src/fclient/res/icons/crystal/48x48/reload_page.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Property changes on: trunk/fclient/src/fclient/res/icons/crystal/48x48/stop.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-07-19 08:59:54
|
Revision: 679
http://fclient.svn.sourceforge.net/fclient/?rev=679&view=rev
Author: jUrner
Date: 2008-07-19 08:59:59 +0000 (Sat, 19 Jul 2008)
Log Message:
-----------
icon size and theme is user adjustable
Modified Paths:
--------------
trunk/fclient/src/fclient/Ui_ViewBrowser.py
Modified: trunk/fclient/src/fclient/Ui_ViewBrowser.py
===================================================================
--- trunk/fclient/src/fclient/Ui_ViewBrowser.py 2008-07-19 08:59:28 UTC (rev 678)
+++ trunk/fclient/src/fclient/Ui_ViewBrowser.py 2008-07-19 08:59:59 UTC (rev 679)
@@ -189,6 +189,7 @@
('AlwaysOpenLinksInNewTab', 'Bool', False, config.SettingScopeUser),
('BackIsClose', 'Bool', False, config.SettingScopeUser),
('MaxTabText', 'UInt', 20, config.SettingScopeUser),
+ ('IconSize', 'UInt', 32, config.SettingScopeUser)
)
@@ -240,9 +241,24 @@
act = self.pageAction(page.OpenFrameInNewWindow)
act.setText(self.trUtf8('Open frame in new tab'))
+ # adjust action icons
+ #TODO: tool buttons do not adjust themselves to huge icons. how to adjust?
+ iconSize = self.fcSettings.value('IconSize')
+ iconTheme = config.settings.value('IconTheme')
+ acts = (
+ (page.Back, 'back'),
+ (page.Forward, 'forward'),
+ (page.Reload, 'reload_page'),
+ (page.Stop, 'stop'),
+ )
+ for a, iconName in acts:
+ act = self.pageAction(a)
+ act.setIcon(config.resources.getIcon(iconName, iconSize, iconTheme=iconTheme))
+
self.connect(self.pageAction(QtWebKit.QWebPage.Stop), QtCore.SIGNAL('triggered()'), self.onActionStopTriggered)
-
+ # connect actions
+ #TODO: download action
self.connect(self, QtCore.SIGNAL('loadStarted()'), self.onLoadStarted)
self.connect(self, QtCore.SIGNAL('loadProgress(int)'), self.onLoadProgress)
self.connect(self, QtCore.SIGNAL('loadFinished(bool)'), self.onLoadFinished)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-07-19 08:59:28
|
Revision: 678
http://fclient.svn.sourceforge.net/fclient/?rev=678&view=rev
Author: jUrner
Date: 2008-07-19 08:59:28 +0000 (Sat, 19 Jul 2008)
Log Message:
-----------
added icon theme support
Modified Paths:
--------------
trunk/fclient/src/fclient/config.py
Modified: trunk/fclient/src/fclient/config.py
===================================================================
--- trunk/fclient/src/fclient/config.py 2008-07-19 07:49:30 UTC (rev 677)
+++ trunk/fclient/src/fclient/config.py 2008-07-19 08:59:28 UTC (rev 678)
@@ -10,7 +10,7 @@
from PyQt4 import QtCore
from .lib import fcp2
-from .lib.qt4ex.lib import actions, settings
+from .lib.qt4ex.lib import actions, settings, resources
#**********************************************************************************
#
#**********************************************************************************
@@ -22,7 +22,10 @@
FclientCopyright = '(c) 2008 Juergen Urner'
FclientHomepage = 'http://fclient.sourceforge.net/'
-SettingsDir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'settings')
+FclientDir = os.path.dirname(os.path.abspath(__file__))
+FclientDocDir = os.path.join(FclientDir, 'doc')
+FclientResDir = os.path.join(FclientDir, 'res')
+FclientSettingsDir = os.path.join(FclientDir, 'settings')
#**********************************************************************************
# looks like QObject.findChild() does not always work. docs mention troubles
# with MSVC 6 where you should use qFindChild(). can not test this. so keep
@@ -88,8 +91,9 @@
class Settings(SettingsBase):
_key_ = 'ConfigSettings'
_settings_ = (
- ('SettingsDir', 'String', QtCore.QString(SettingsDir), SettingScopeUser), # if not None, settings are stored locally in the app folder
- ('SettingsAllUsers', 'Bool', False, SettingScopeUser), # store settings for all users?
+ ('SettingsDir', 'String', QtCore.QString(FclientSettingsDir), SettingScopeUser), # if not None, settings are stored locally in the app folder
+ ('SettingsAllUsers', 'Bool', False, SettingScopeUser), # store settings for all users?
+ ('IconTheme', 'String', 'crystal', SettingScopeUser),
)
SettingsBase._config_settings_ = Settings()
@@ -98,6 +102,7 @@
#**********************************************************************************
fcpClient = fcp2.Client() # global fcp client
settings = Settings(None) # global settings class
+resources = resources.Resources([FclientResDir, ], )
#**********************************************************************************
#
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-07-19 07:49:22
|
Revision: 677
http://fclient.svn.sourceforge.net/fclient/?rev=677&view=rev
Author: jUrner
Date: 2008-07-19 07:49:30 +0000 (Sat, 19 Jul 2008)
Log Message:
-----------
set busy cursor if necessary
Modified Paths:
--------------
trunk/fclient/src/fclient/Ui_ViewBrowser.py
Modified: trunk/fclient/src/fclient/Ui_ViewBrowser.py
===================================================================
--- trunk/fclient/src/fclient/Ui_ViewBrowser.py 2008-07-19 06:48:49 UTC (rev 676)
+++ trunk/fclient/src/fclient/Ui_ViewBrowser.py 2008-07-19 07:49:30 UTC (rev 677)
@@ -192,8 +192,6 @@
)
-
-
class Page(QtWebKit.QWebPage):
def __init__(self, parent):
QtWebKit.QWebPage.__init__(self, parent)
@@ -242,6 +240,9 @@
act = self.pageAction(page.OpenFrameInNewWindow)
act.setText(self.trUtf8('Open frame in new tab'))
+ self.connect(self.pageAction(QtWebKit.QWebPage.Stop), QtCore.SIGNAL('triggered()'), self.onActionStopTriggered)
+
+
self.connect(self, QtCore.SIGNAL('loadStarted()'), self.onLoadStarted)
self.connect(self, QtCore.SIGNAL('loadProgress(int)'), self.onLoadProgress)
self.connect(self, QtCore.SIGNAL('loadFinished(bool)'), self.onLoadFinished)
@@ -281,8 +282,8 @@
page = self.page()
hitTest = frame.hitTestContent(event.pos())
- #if not hitTest.isNull(): #TODO: hitTest.isNull() returns alwas True?
-
+ #if not hitTest.isNull(): #TODO: looks like hitTest.isNull() alwas returns True
+
menu = QtGui.QMenu()
menu.addAction(self.pageAction(page.OpenLink))
@@ -334,9 +335,15 @@
def hideEvent(self, event):
self.fcGlobalFeedback.setVisible(False)
- #################################
- ## overwritten events
+ def mouseMoveEvent(self, event):
+ if self.lastProgress < 100:
+ self.setCursor(QtCore.Qt.BusyCursor)
+ else:
+ QtWebKit.QWebView.mouseMoveEvent(self, event)
+
################################
+ ## methods
+ ################################
def isCurrentBrowser(self):
if self.tabWidget is not None:
return self.tabWidget.currentWidget() == self
@@ -363,6 +370,20 @@
##############################################
## event handlers
##############################################
+ def onActionStopTriggered(self):
+ # check wich cursor to set cos we may have busy cursor set
+ pt = self.mapFromGlobal(self.cursor().pos()) #TODO: self.mapFromGlobal(self.viewPort().cursor().pos()) ??
+ frame = self.page().currentFrame()
+ hitTest = frame.hitTestContent(pt)
+
+ #if not hitTest.isNull(): #TODO: looks like hitTest.isNull() alwas returns True
+
+ if hitTest.linkUrl().isValid() or hitTest.imageUrl().isValid():
+ self.setCursor(QtCore.Qt.PointingHandCursor)
+ else:
+ self.setCursor(QtCore.Qt.ArrowCursor)
+
+
def onIconChanged(self):
i = self.tabIndex()
if i > -1:
@@ -390,6 +411,7 @@
def onLoadFinished(self, ok):
+ self.onActionStopTriggered()
self.setProgress(100)
if ok:
self.setStatusMessage(self.trUtf8('Complete'))
@@ -420,6 +442,7 @@
def onLoadStarted(self):
+ self.setCursor(QtCore.Qt.BusyCursor)
self.setProgress(0)
self.setStatusMessage(self.trUtf8('Loading'))
@@ -427,8 +450,8 @@
def onStatusBarMessage(self, text):
if not text.isEmpty():
self.setStatusMessage(text)
+
-
def onUrlChanged(self, url):
self.lastUrl = QtCore.QUrl(url) # copy url. qt nukes it on return
if self.navBar is not None and self.isCurrentBrowser():
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-07-19 06:48:40
|
Revision: 676
http://fclient.svn.sourceforge.net/fclient/?rev=676&view=rev
Author: jUrner
Date: 2008-07-19 06:48:49 +0000 (Sat, 19 Jul 2008)
Log Message:
-----------
fix global feedback for browser
Modified Paths:
--------------
trunk/fclient/src/fclient/Ui_ViewBrowser.py
Modified: trunk/fclient/src/fclient/Ui_ViewBrowser.py
===================================================================
--- trunk/fclient/src/fclient/Ui_ViewBrowser.py 2008-07-19 06:37:43 UTC (rev 675)
+++ trunk/fclient/src/fclient/Ui_ViewBrowser.py 2008-07-19 06:48:49 UTC (rev 676)
@@ -61,8 +61,8 @@
trigger=parent.onActionGoToFProxy,
isEnabled=True,
)
-
+
class GlobalFeedback(config.GlobalFeedbackBase):
"""wrapper for global statusbar widgets, menus"""
@@ -77,39 +77,14 @@
self.menus.append(menu)
self.menuBar.addViewMenu(menu)
- # status bar widgets
- self.label1 = None
- self.progress = None
- if self.statusBar is not None:
- self.label1 = QtGui.QLabel(parent.trUtf8('progress: '), self.statusBar)
- self.statusBar.addWidget(self.label1)
- self.progress = QtGui.QProgressBar(self.statusBar)
- self.progress.setRange(0, 100)
- self.progress.setValue(0)
- self.statusBar.addWidget(self.progress)
-
- self.labelStatus = QtGui.QLabel(QtCore.QString(), self.statusBar)
- self.statusBar.addWidget(self.labelStatus)
-
-
def setVisible(self, flag):
if self.menuBar is not None:
for menu in self.menus:
menu.children()[0].setVisible(flag)
- if self.statusBar is not None:
- self.label1.setVisible(flag)
- self.progress.setVisible(flag)
- self.labelStatus.setVisible(flag)
-
- def setProgress(self, n):
- if self.progress is not None:
- self.progress.setValue(n)
-
- def setStatusMessage(self, text):
- if self.labelStatus is not None:
- self.labelStatus.setText(text)
+
+
class Settings(config.SettingsBase):
_key_ = config.IdViewBrowserWidget
_settings_ = (
@@ -159,6 +134,55 @@
def __init__(self, webView):
config.ActionsBase.__init__(self, webView)
+
+class BrowserGlobalFeedback(config.GlobalFeedbackBase):
+ """wrapper for global statusbar widgets, menus"""
+
+ def __init__(self, parent, idGlobalFeedback):
+ config.GlobalFeedbackBase.__init__(self, parent, idGlobalFeedback)
+
+ # menus
+ self.menus = []
+ if self.menuBar is not None and hasattr(parent, 'fcViewObject'):
+ menu = QtGui.QMenu(parent.fcViewObject.displayName, self.menuBar)
+ parent.populateMenu(menu)
+ self.menus.append(menu)
+ self.menuBar.addViewMenu(menu)
+
+ # status bar widgets
+ self.label1 = None
+ self.progress = None
+ if self.statusBar is not None:
+ self.label1 = QtGui.QLabel(parent.trUtf8('progress: '), self.statusBar)
+ self.statusBar.addWidget(self.label1)
+
+ self.progress = QtGui.QProgressBar(self.statusBar)
+ self.progress.setRange(0, 100)
+ self.progress.setValue(0)
+ self.statusBar.addWidget(self.progress)
+
+ self.labelStatus = QtGui.QLabel(QtCore.QString(), self.statusBar)
+ self.statusBar.addWidget(self.labelStatus)
+
+
+ def setVisible(self, flag):
+ if self.menuBar is not None:
+ for menu in self.menus:
+ menu.children()[0].setVisible(flag)
+ if self.statusBar is not None:
+ self.label1.setVisible(flag)
+ self.progress.setVisible(flag)
+ self.labelStatus.setVisible(flag)
+
+ def setProgress(self, n):
+ if self.progress is not None:
+ self.progress.setValue(n)
+
+ def setStatusMessage(self, text):
+ if self.labelStatus is not None:
+ self.labelStatus.setText(text)
+
+
class BrowserSettings(config.SettingsBase):
_key_ = config.IdViewBrowserWidget
_settings_ = (
@@ -169,6 +193,7 @@
+
class Page(QtWebKit.QWebPage):
def __init__(self, parent):
QtWebKit.QWebPage.__init__(self, parent)
@@ -185,7 +210,7 @@
self.fcActions = BrowserActions(self)
self.fcSettings = BrowserSettings(self)
- self.fcGlobalFeedback = GlobalFeedback(self, idGlobalFeedback)
+ self.fcGlobalFeedback = BrowserGlobalFeedback(self, idGlobalFeedback)
self.navBar = navBar
self.tabWidget = tabWidget
@@ -299,11 +324,16 @@
def showEvent(self, event):
+ self.fcGlobalFeedback.setVisible(True)
self.setProgress(self.lastProgress)
self.setStatusMessage(self.lastStatusMessage)
if self.navBar is not None:
self.navBar.setText(self.lastUrl.toString())
+
+ def hideEvent(self, event):
+ self.fcGlobalFeedback.setVisible(False)
+
#################################
## overwritten events
################################
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-07-19 06:37:38
|
Revision: 675
http://fclient.svn.sourceforge.net/fclient/?rev=675&view=rev
Author: jUrner
Date: 2008-07-19 06:37:43 +0000 (Sat, 19 Jul 2008)
Log Message:
-----------
continued working on browser impl
Modified Paths:
--------------
trunk/fclient/src/fclient/Ui_ViewBrowser.py
Modified: trunk/fclient/src/fclient/Ui_ViewBrowser.py
===================================================================
--- trunk/fclient/src/fclient/Ui_ViewBrowser.py 2008-07-19 06:37:06 UTC (rev 674)
+++ trunk/fclient/src/fclient/Ui_ViewBrowser.py 2008-07-19 06:37:43 UTC (rev 675)
@@ -1,4 +1,8 @@
-
+#******************************************************************************************
+#TODO:
+#
+#
+#******************************************************************************************
from __future__ import absolute_import
if __name__ == '__main__': # see --> http://bugs.python.org/issue1510172 . works only current dir and below
import os; __path__ = [os.path.dirname(__file__)]
@@ -51,23 +55,23 @@
trigger=None,
#isEnabled=False,
)
-
self.action(
name='ActionGoToFProxy',
text=self.trUtf8('F&Proxy homepage'),
trigger=parent.onActionGoToFProxy,
isEnabled=True,
)
+
class GlobalFeedback(config.GlobalFeedbackBase):
"""wrapper for global statusbar widgets, menus"""
- def __init__(self, parent, idFeedbackParent):
- config.GlobalFeedbackBase.__init__(self, parent, idFeedbackParent)
+ def __init__(self, parent, idGlobalFeedback):
+ config.GlobalFeedbackBase.__init__(self, parent, idGlobalFeedback)
# menus
self.menus = []
- if self.menuBar is not None:
+ if self.menuBar is not None and hasattr(parent, 'fcViewObject'):
menu = QtGui.QMenu(parent.fcViewObject.displayName, self.menuBar)
parent.populateMenu(menu)
self.menus.append(menu)
@@ -109,7 +113,6 @@
class Settings(config.SettingsBase):
_key_ = config.IdViewBrowserWidget
_settings_ = (
- ('MaxTabText', 'UInt', 20, config.SettingScopeUser),
)
@@ -151,43 +154,69 @@
#**********************************************************************************
#
#**********************************************************************************
+class BrowserActions(config.ActionsBase):
+
+ def __init__(self, webView):
+ config.ActionsBase.__init__(self, webView)
+
+class BrowserSettings(config.SettingsBase):
+ _key_ = config.IdViewBrowserWidget
+ _settings_ = (
+ ('AlwaysOpenLinksInNewTab', 'Bool', False, config.SettingScopeUser),
+ ('BackIsClose', 'Bool', False, config.SettingScopeUser),
+ ('MaxTabText', 'UInt', 20, config.SettingScopeUser),
+ )
+
+
+
class Page(QtWebKit.QWebPage):
def __init__(self, parent):
QtWebKit.QWebPage.__init__(self, parent)
- def acceptNavigationRequest(self, frame, request, type):
- #print frame, request, type
- #print request.url()
-
- # have to on query here: "?forcedownload" for dl. "?force=abcdef" for app exec on the link
-
+ def acceptNavigationRequest(self, frame, request, typeRequest):
return True
class Browser(QtWebKit.QWebView):
- def __init__(self, parent, tabWidget=None, navBar=None, globalFeedback=None, browserSettings=None, browserActions=None):
+ def __init__(self, parent, idGlobalFeedback=config.IdMainWindow, tabWidget=None, navBar=None):
QtWebKit.QWebView.__init__(self, parent)
- self.browserActions = browserActions
- self.browserSettings = browserSettings
- self.globalFeedback = globalFeedback
+ self.fcActions = BrowserActions(self)
+ self.fcSettings = BrowserSettings(self)
+ self.fcGlobalFeedback = GlobalFeedback(self, idGlobalFeedback)
+
self.navBar = navBar
self.tabWidget = tabWidget
- self.lastProgress = 0
- self.lastStatusMessage = self.trUtf8('Waiting')
-
- #TODO: set start page, otherwise the view is never updated
+
settings = self.settings()
settings.setAttribute(settings.PluginsEnabled, False)
#settings.setAttribute(settings.AutoLoadImages, False)
-
+
page = Page(self)
self.setPage(page)
#page = self.page()
- #page.setLinkDelegationPolicy(page.DelegateAllLinks)
+ self.lastProgress = 0
+ self.lastStatusMessage = self.trUtf8('Waiting')
+ #NOTE: opening a browser in a new tab may take a while to load.
+ # self.url() will return '' untill the page is found, so we handle
+ # it ourself and keep track of the last known url in self.lastUrl
+ # to give feedback to the user on the navbar. downside is we have
+ # to reimplement contextMenuEvent() :-(
+ self.lastUrl = QtCore.QUrl()
+ #self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
+ page.setLinkDelegationPolicy(page.DelegateAllLinks)
+
+ # adjust actions
+ act = self.pageAction(page.OpenLinkInNewWindow)
+ act.setText(self.trUtf8('Open page in new tab'))
+ act = self.pageAction(page.OpenImageInNewWindow)
+ act.setText(self.trUtf8('Open image in new tab'))
+ act = self.pageAction(page.OpenFrameInNewWindow)
+ act.setText(self.trUtf8('Open frame in new tab'))
+
self.connect(self, QtCore.SIGNAL('loadStarted()'), self.onLoadStarted)
self.connect(self, QtCore.SIGNAL('loadProgress(int)'), self.onLoadProgress)
self.connect(self, QtCore.SIGNAL('loadFinished(bool)'), self.onLoadFinished)
@@ -195,47 +224,89 @@
self.connect(self, QtCore.SIGNAL('urlChanged(const QUrl &)'), self.onUrlChanged)
self.connect(self, QtCore.SIGNAL('titleChanged(const QString &)'), self.onTitleChanged)
self.connect(self, QtCore.SIGNAL('iconChanged()'), self.onIconChanged)
-
- self.setStatusMessage(self.lastStatusMessage)
- self.setProgress(self.lastProgress)
+
+ #TODO:
+ #
+ # x. set busy cursor if loading
+ # x. page history is cleared if we get an error on loading a page. reimpl page history
+ # x. back-is close like behaviour
+ # x. always open links in new tabs
- def createWindow(self, typeWindow=QtWebKit.QWebPage.WebBrowserWindow):
-
- if typeWindow == QtWebKit.QWebPage.WebBrowserWindow:
- if self.tabWidget is None:
- return self
-
- browser = self.__class__(self.tabWidget,
- tabWidget=self.tabWidget,
- navBar=self.navBar,
- globalFeedback=self.globalFeedback,
- browserSettings=self.browserSettings,
- browserActions=self.browserActions,
- )
- self.tabWidget.addTab(browser, self.trUtf8('Loading'))
- n = self.tabWidget.count()
- self.tabWidget.tabBar().setVisible(n)
- return browser
-
+ # not needed. we handle OpenLinkInNewWindow et al in contextMenuEvent
+ #def createWindow(self, typeWindow):
+ # pass
def load(self, url):
+ self.lastUrl = QtCore.QUrl(url)
if self.isCurrentBrowser():
- if self.navBar is not None:
- self.navBar.setText(url.toString())
+ if self.fcGlobalFeedback is not None and self.isCurrentBrowser():
+ self.navBar.setText(self.lastUrl.toString())
QtWebKit.QWebView.load(self, url)
+
+ setUrl = load
+
+
+ #################################
+ ## overwritten events
+ ################################
+ def contextMenuEvent(self, event):
+
+ frame = self.page().currentFrame()
+ page = self.page()
+ hitTest = frame.hitTestContent(event.pos())
+
+ #if not hitTest.isNull(): #TODO: hitTest.isNull() returns alwas True?
+ menu = QtGui.QMenu()
+
+ menu.addAction(self.pageAction(page.OpenLink))
+ menu.addAction(self.pageAction(page.OpenLinkInNewWindow))
+ menu.addAction(self.pageAction(page.CopyLinkToClipboard))
+ ##menu.addAction(DownloadLinkToDisk))
+
+ menu.addSeparator()
+ menu.addAction(self.pageAction(page.OpenImageInNewWindow))
+ menu.addAction(self.pageAction(page.DownloadImageToDisk))
+ menu.addAction(self.pageAction(page.CopyImageToClipboard))
+
+ menu.addSeparator()
+ menu.addAction(self.pageAction(page.OpenFrameInNewWindow))
+
+ menu.addSeparator()
+ menu.addAction(self.pageAction(page.Copy))
+
+ action = menu.exec_(event.globalPos())
+ if action in (self.pageAction(page.OpenLinkInNewWindow), self.pageAction(page.OpenImageInNewWindow), self.pageAction(page.OpenFrameInNewWindow)):
+ if self.tabWidget is not None:
+ browser = self.__class__(self.tabWidget,
+ idGlobalFeedback=self.fcGlobalFeedback.id,
+ tabWidget=self.tabWidget,
+ navBar=self.navBar,
+ )
+ self.tabWidget.addTab(browser, self.trUtf8('Loading'))
+ self.tabWidget.tabBar().setVisible(self.tabWidget.count())
+ if action == self.pageAction(page.OpenLinkInNewWindow):
+ browser.load(hitTest.linkUrl())
+ elif action == self.pageAction(page.OpenImageInNewWindow):
+ browser.load(hitTest.imageUrl())
+ elif action == self.pageAction(page.OpenFrameInNewWindow):
+ browser.load(hitTest.frame().url())
+ elif self.pageAction(page.DownloadImageToDisk):
+ #TODO: implement
+ pass
+
+
def showEvent(self, event):
self.setProgress(self.lastProgress)
self.setStatusMessage(self.lastStatusMessage)
if self.navBar is not None:
- self.navBar.setText(self.url().toString())
-
-
- def hideEvent(self, event):
- pass
-
+ self.navBar.setText(self.lastUrl.toString())
+
+ #################################
+ ## overwritten events
+ ################################
def isCurrentBrowser(self):
if self.tabWidget is not None:
return self.tabWidget.currentWidget() == self
@@ -250,25 +321,44 @@
def setStatusMessage(self, text):
self.lastStatusMessage = text
- if self.globalFeedback is not None and self.isCurrentBrowser():
- self.globalFeedback.setStatusMessage(text)
+ if self.fcGlobalFeedback is not None and self.isCurrentBrowser():
+ self.fcGlobalFeedback.setStatusMessage(text)
def setProgress(self, percent):
self.lastProgress = percent
- if self.globalFeedback is not None and self.isCurrentBrowser():
- self.globalFeedback.setProgress(percent)
+ if self.fcGlobalFeedback is not None and self.isCurrentBrowser():
+ self.fcGlobalFeedback.setProgress(percent)
-
- def onLoadStarted(self):
- self.setProgress(0)
- self.setStatusMessage(self.trUtf8('Loading'))
-
+ ##############################################
+ ## event handlers
+ ##############################################
+ def onIconChanged(self):
+ i = self.tabIndex()
+ if i > -1:
+ self.tabWidget.setTabIcon(i, self.icon)
- def onLoadProgress(self, percent):
- self.setProgress(percent)
-
-
+
+ def onTitleChanged(self, text):
+ # add title to tab
+ if self.tabWidget is not None:
+ i = self.tabIndex()
+ if i > -1:
+ # truncate text if necessary
+ maxText = self.fcSettings.value('MaxTabText')
+
+ ellipsis = self.trUtf8('..')
+ if text.count() > maxText and text.count() > ellipsis.count() * 2: #TODO: * 2 ???
+ n = maxText - ellipsis.count()
+ if n < 0:
+ n = 0
+ text.truncate(n)
+ text.append(ellipsis)
+ if text.isEmpty():
+ text = self.trUtf8('<untitled>')
+ self.tabWidget.setTabText(i, text)
+
+
def onLoadFinished(self, ok):
self.setProgress(100)
if ok:
@@ -284,7 +374,7 @@
page = htmlPage(
self.trUtf8('Error'),
'<h3>%s</h3>' % self.trUtf8('Request failed'),
- self.trUtf8('''most likely fProxy can not be reached. check your if fProxy is running
+ self.trUtf8('''one reason may be fProxy can not be reached. check your if fProxy is running
and check your node config if host and port are ok. hint: this browser can currently
not deal with ipv6 addresses'''),
@@ -294,44 +384,26 @@
)
self.setHtml(page)
+
+ def onLoadProgress(self, percent):
+ self.setProgress(percent)
+
+
+ def onLoadStarted(self):
+ self.setProgress(0)
+ self.setStatusMessage(self.trUtf8('Loading'))
+
-
def onStatusBarMessage(self, text):
if not text.isEmpty():
self.setStatusMessage(text)
def onUrlChanged(self, url):
+ self.lastUrl = QtCore.QUrl(url) # copy url. qt nukes it on return
if self.navBar is not None and self.isCurrentBrowser():
- self.navBar.setText(url.toString())
+ self.navBar.setText(self.lastUrl.toString())
-
- def onIconChanged(self):
- i = self.tabIndex()
- if i > -1:
- self.tabWidget.setTabIcon(i, self.icon)
-
-
- def onTitleChanged(self, text):
- # add title to tab
- if self.tabWidget is not None:
- i = self.tabIndex()
- if i > -1:
- # truncate text if necessary
- maxText = self.browserSettings.value('MaxTabText')
-
- ellipsis = self.trUtf8('..')
- if text.count() > maxText and text.count() > ellipsis.count() * 2: #TODO: * 2 ???
- n = maxText - ellipsis.count()
- if n < 0:
- n = 0
- text.truncate(n)
- text.append(ellipsis)
- if text.isEmpty():
- text = self.trUtf8('<untitled>')
- self.tabWidget.setTabText(i, text)
-
-
#***********************************************************************
#
#***********************************************************************
@@ -348,7 +420,7 @@
IdBtStop = 'btStop'
- def __init__(self, parent, idFeedbackParent=config.IdMainWindow):
+ def __init__(self, parent, idGlobalFeedback=config.IdMainWindow):
QtGui.QWidget.__init__(self, parent)
self._isCreated = False
@@ -360,7 +432,7 @@
self.fcActions = Actions(self)
self.fcSettings = Settings()
self.fcViewObject = BrowserViewObject(self)
- self.fcGlobalFeedback = GlobalFeedback(self, idFeedbackParent)
+ self.fcGlobalFeedback = GlobalFeedback(self, idGlobalFeedback)
self.fproxyHost = None
@@ -394,11 +466,9 @@
"""creates a new tab"""
tabWidget = self.controlById(self.IdTabBrowsers)
browser = Browser(self,
+ idGlobalFeedback=self.fcGlobalFeedback.id,
tabWidget=self.controlById(self.IdTabBrowsers),
navBar=self.controlById(self.IdEdNavBar),
- globalFeedback=self.fcGlobalFeedback,
- browserSettings=self.fcSettings,
- browserActions=self.fcActions,
)
tabWidget.addTab(browser, tabText)
return browser
@@ -542,10 +612,8 @@
for idControl, webAction in actions:
bt = self.controlById(idControl)
bt.setDefaultAction(browser.pageAction(webAction))
-
- ed = self.controlById(self.IdEdNavBar).setText(browser.url().toString())
+
-
def onNavBarReturnPressed(self):
ed = self.controlById(self.IdEdNavBar)
tabWidget = self.controlById(self.IdTabBrowsers)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-07-19 06:36:57
|
Revision: 674
http://fclient.svn.sourceforge.net/fclient/?rev=674&view=rev
Author: jUrner
Date: 2008-07-19 06:37:06 +0000 (Sat, 19 Jul 2008)
Log Message:
-----------
naming
Modified Paths:
--------------
trunk/fclient/src/fclient/Ui_ViewLogger.py
Modified: trunk/fclient/src/fclient/Ui_ViewLogger.py
===================================================================
--- trunk/fclient/src/fclient/Ui_ViewLogger.py 2008-07-19 06:36:58 UTC (rev 673)
+++ trunk/fclient/src/fclient/Ui_ViewLogger.py 2008-07-19 06:37:06 UTC (rev 674)
@@ -71,13 +71,12 @@
class GlobalFeedback(config.GlobalFeedbackBase):
"""wrapper for global statusbar widgets, menus"""
- def __init__(self, parent, idFeedbackParent):
- config.GlobalFeedbackBase.__init__(self, parent, idFeedbackParent)
+ def __init__(self, parent, idGlobalFeedback):
+ config.GlobalFeedbackBase.__init__(self, parent, idGlobalFeedback)
-
# menus
self.menus = []
- if self.menuBar is not None:
+ if self.menuBar is not None and hasattr(parent, 'fcViewObject'):
menu = QtGui.QMenu(parent.fcViewObject.displayName, self.menuBar)
parent.populateMenu(menu)
self.menus.append(menu)
@@ -145,7 +144,7 @@
IdEdLogger = 'edLogger'
- def __init__(self, parent, idFeedbackParent=config.IdMainWindow):
+ def __init__(self, parent, idGlobalFeedback=config.IdMainWindow):
QtGui.QWidget.__init__(self, parent)
self._isCreated = False
self._mainWindowMenus = {} #TODO: wrap along with toolbars to a handy class MainWindowStuff
@@ -156,7 +155,7 @@
self.fcActions = Actions(self)
self.fcSettings = Settings(self).restore()
self.fcViewObject = LoggerViewObject(self)
- self.fcGlobalFeedback = GlobalFeedback(self, idFeedbackParent)
+ self.fcGlobalFeedback = GlobalFeedback(self, idGlobalFeedback)
# setup editbox
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-07-19 06:36:50
|
Revision: 673
http://fclient.svn.sourceforge.net/fclient/?rev=673&view=rev
Author: jUrner
Date: 2008-07-19 06:36:58 +0000 (Sat, 19 Jul 2008)
Log Message:
-----------
naming
Modified Paths:
--------------
trunk/fclient/src/fclient/Ui_ViewConnection.py
Modified: trunk/fclient/src/fclient/Ui_ViewConnection.py
===================================================================
--- trunk/fclient/src/fclient/Ui_ViewConnection.py 2008-07-19 06:36:49 UTC (rev 672)
+++ trunk/fclient/src/fclient/Ui_ViewConnection.py 2008-07-19 06:36:58 UTC (rev 673)
@@ -19,28 +19,27 @@
class GlobalFeedback(config.GlobalFeedbackBase):
"""wrapper for global statusbar widgets, menus"""
- def __init__(self, parent, idFeedbackParent):
- config.GlobalFeedbackBase.__init__(self, parent, idFeedbackParent)
+ def __init__(idGlobalFeedback, parent, idFeedbackParent):
+ config.GlobalFeedbackBase.__init__(idGlobalFeedback, parent, idFeedbackParent)
-
# menus
- self.menus = []
- if self.menuBar is not None:
- menu = QtGui.QMenu(parent.fcViewObject.displayName, self.menuBar)
+ idGlobalFeedback.menus = []
+ if idGlobalFeedback.menuBar is not None and hasattr(parent, 'fcViewObject'):
+ menu = QtGui.QMenu(parent.fcViewObject.displayName, idGlobalFeedback.menuBar)
parent.populateMenu(menu)
- self.menus.append(menu)
- self.menuBar.addViewMenu(menu)
+ idGlobalFeedback.menus.append(menu)
+ idGlobalFeedback.menuBar.addViewMenu(menu)
# status bar widgets
- self.label1 = None
- #if self.statusBar is not None:
- # self.label1 = QtGui.QLabel('foo here', self.statusBar)
+ idGlobalFeedback.label1 = None
+ #if idGlobalFeedback.statusBar is not None:
+ # idGlobalFeedback.label1 = QtGui.QLabel('foo here', idGlobalFeedback.statusBar)
- def setVisible(self, flag):
- for menu in self.menus:
+ def setVisible(idGlobalFeedback, flag):
+ for menu in idGlobalFeedback.menus:
menu.children()[0].setVisible(flag)
- if self.label1 is not None:
- self.label1.setVisible(flag)
+ if idGlobalFeedback.label1 is not None:
+ idGlobalFeedback.label1.setVisible(flag)
class Settings(config.SettingsBase):
@@ -58,12 +57,12 @@
class ConnectionViewObject(config.ViewObject):
- def __init__(self, parent):
- config.ViewObject. __init__(self, parent)
+ def __init__(idGlobalFeedback, parent):
+ config.ViewObject. __init__(idGlobalFeedback, parent)
- self.name=parent.objectName()
- self.displayName=self.trUtf8('Connection')
- self.icon=QtGui.QIcon()
+ idGlobalFeedback.name=parent.objectName()
+ idGlobalFeedback.displayName=idGlobalFeedback.trUtf8('Connection')
+ idGlobalFeedback.icon=QtGui.QIcon()
#**********************************************************************************
@@ -71,27 +70,27 @@
#**********************************************************************************
class ConnectionTimer(QtCore.QTimer):
- def __init__(self,parent):
- QtCore.QTimer.__init__(self, parent)
- self.fcpIterConnect = None
- self.connect(self, QtCore.SIGNAL('timeout()'), self.onNext)
+ def __init__(idGlobalFeedback,parent):
+ QtCore.QTimer.__init__(idGlobalFeedback, parent)
+ idGlobalFeedback.fcpIterConnect = None
+ idGlobalFeedback.connect(idGlobalFeedback, QtCore.SIGNAL('timeout()'), idGlobalFeedback.onNext)
- def start(self, settings):
- self.fcpIterConnect = config.fcpClient.iterConnect(
+ def start(idGlobalFeedback, settings):
+ idGlobalFeedback.fcpIterConnect = config.fcpClient.iterConnect(
duration=settings.value('ConnectionTimerMaxDuration'),
timeout=0
)
- if not self.onNext():
- QtCore.QTimer.start(self, settings.value('ConnectionTimerTimeout'))
+ if not idGlobalFeedback.onNext():
+ QtCore.QTimer.start(idGlobalFeedback, settings.value('ConnectionTimerTimeout'))
- def onNext(self):
+ def onNext(idGlobalFeedback):
try:
- result = self.fcpIterConnect.next()
+ result = idGlobalFeedback.fcpIterConnect.next()
except StopIteration:
- self.stop()
+ idGlobalFeedback.stop()
else:
if result is not None:
- self.stop()
+ idGlobalFeedback.stop()
# 1st thing todo after connect is to query the config from the node so all
# listeners right away so not everyone has to query it so. needs more details
# or joins the gui later.. feel free to query again
@@ -102,14 +101,14 @@
class PollTimer(QtCore.QTimer):
- def __init__(self,parent):
- QtCore.QTimer.__init__(self, parent)
- self.connect(self, QtCore.SIGNAL('timeout()'), self.onNext)
+ def __init__(idGlobalFeedback,parent):
+ QtCore.QTimer.__init__(idGlobalFeedback, parent)
+ idGlobalFeedback.connect(idGlobalFeedback, QtCore.SIGNAL('timeout()'), idGlobalFeedback.onNext)
- def start(self, settings):
- QtCore.QTimer.start(self, settings.value('PollTimerTimeout'))
+ def start(idGlobalFeedback, settings):
+ QtCore.QTimer.start(idGlobalFeedback, settings.value('PollTimerTimeout'))
- def onNext(self):
+ def onNext(idGlobalFeedback):
if config.fcpClient.isConnected():
result = config.fcpClient.next()
@@ -123,119 +122,119 @@
IdEdConnectionHost = 'edConnectionHost' #TODO: combobox? validate input.
IdSpinConnectionPort = 'spinConnectionPort'
- def __init__(self, parent, idFeedbackParent=config.IdMainWindow):
- QtGui.QWidget.__init__(self, parent)
+ def __init__(idGlobalFeedback, parent, idFeedbackParent=config.IdMainWindow):
+ QtGui.QWidget.__init__(idGlobalFeedback, parent)
- self._isCreated = False
- self._connectionTimer = ConnectionTimer(self)
- self._pollTimer = PollTimer(self)
- self._fcpEventonrs = (
- (config.fcpClient.events.ClientConnected, self.onFcpClientConected),
- (config.fcpClient.events.ClientDisconnected, self.onFcpClientDisconected),
+ idGlobalFeedback._isCreated = False
+ idGlobalFeedback._connectionTimer = ConnectionTimer(idGlobalFeedback)
+ idGlobalFeedback._pollTimer = PollTimer(idGlobalFeedback)
+ idGlobalFeedback._fcpEventonrs = (
+ (config.fcpClient.events.ClientConnected, idGlobalFeedback.onFcpClientConected),
+ (config.fcpClient.events.ClientDisconnected, idGlobalFeedback.onFcpClientDisconected),
)
- config.fcpClient.events += self._fcpEventonrs
- self._mainWindowMenus = ()
+ config.fcpClient.events += idGlobalFeedback._fcpEventonrs
+ idGlobalFeedback._mainWindowMenus = ()
- self.setupUi(self)
- config.ObjectRegistry.register(self)
- self.fcSettings = Settings().restore()
- self.fcActions = Actions(self)
- self.fcViewObject = ConnectionViewObject(self)
- self.fcGlobalFeedback = GlobalFeedback(self, idFeedbackParent)
+ idGlobalFeedback.setupUi(idGlobalFeedback)
+ config.ObjectRegistry.register(idGlobalFeedback)
+ idGlobalFeedback.fcSettings = Settings().restore()
+ idGlobalFeedback.fcActions = Actions(idGlobalFeedback)
+ idGlobalFeedback.fcViewObject = ConnectionViewObject(idGlobalFeedback)
+ idGlobalFeedback.fcGlobalFeedback = GlobalFeedback(idGlobalFeedback, idFeedbackParent)
#########################################
## methods
#########################################
- def controlById(self, idControl):
- return getattr(self, idControl)
+ def controlById(idGlobalFeedback, idControl):
+ return getattr(idGlobalFeedback, idControl)
- def populateMenu(self, menu):
+ def populateMenu(idGlobalFeedback, menu):
return menu
#########################################
## view methods
#########################################
- def viewClose(self):
- config.fcpClient.events -= self._fcpEventonrs
+ def viewClose(idGlobalFeedback):
+ config.fcpClient.events -= idGlobalFeedback._fcpEventonrs
#########################################
## overwritten events
#########################################
- def closeEvent(self, event):
- self.viewClose()
+ def closeEvent(idGlobalFeedback, event):
+ idGlobalFeedback.viewClose()
- def hideEvent(self, event):
- self.fcGlobalFeedback.setVisible(False)
+ def hideEvent(idGlobalFeedback, event):
+ idGlobalFeedback.fcGlobalFeedback.setVisible(False)
- def showEvent(self, event):
- self.fcGlobalFeedback.setVisible(True)
- if self._isCreated:
+ def showEvent(idGlobalFeedback, event):
+ idGlobalFeedback.fcGlobalFeedback.setVisible(True)
+ if idGlobalFeedback._isCreated:
return
- self._isCreated = True
+ idGlobalFeedback._isCreated = True
# setup host / port boxes
- edHost = self.controlById(self.IdEdConnectionHost)
- edHost.setText(self.fcSettings.value('ConnectionHost'))
+ edHost = idGlobalFeedback.controlById(idGlobalFeedback.IdEdConnectionHost)
+ edHost.setText(idGlobalFeedback.fcSettings.value('ConnectionHost'))
- spinPort = self.controlById(self.IdSpinConnectionPort)
+ spinPort = idGlobalFeedback.controlById(idGlobalFeedback.IdSpinConnectionPort)
spinPort.setRange(0, 0xFFFF) #TODO: no idea if port range (0, 0xFFFF) this is reasonable
- spinPort.setValue(self.fcSettings.value('ConnectionPort'))
+ spinPort.setValue(idGlobalFeedback.fcSettings.value('ConnectionPort'))
# setup Connect button and AutoConnect checkbox
- doAutoConnect = self.fcSettings.value('AutoConnect')
- ck = self.controlById(self.IdckAutoConnect)
+ doAutoConnect = idGlobalFeedback.fcSettings.value('AutoConnect')
+ ck = idGlobalFeedback.controlById(idGlobalFeedback.IdckAutoConnect)
ck.setChecked(doAutoConnect)
- self.connect(ck, QtCore.SIGNAL('stateChanged(int)'), self.onCkAutoConnectStateChanged)
+ idGlobalFeedback.connect(ck, QtCore.SIGNAL('stateChanged(int)'), idGlobalFeedback.onCkAutoConnectStateChanged)
- bt = self.controlById(self.IdBtConnect)
- self.connect(bt, QtCore.SIGNAL('clicked(bool)'), self.onBtConnectClicked)
+ bt = idGlobalFeedback.controlById(idGlobalFeedback.IdBtConnect)
+ idGlobalFeedback.connect(bt, QtCore.SIGNAL('clicked(bool)'), idGlobalFeedback.onBtConnectClicked)
if doAutoConnect:
- self.controlById(self.IdBtConnect).click()
+ idGlobalFeedback.controlById(idGlobalFeedback.IdBtConnect).click()
########################################
## overwritten methods
#########################################
- def retranslateUi(self, w):
- Ui_ViewConnectionWidget.retranslateUi(self, w)
- bt = self.controlById(self.IdBtConnect)
- bt.setText(self.trUtf8('Disconnect') if bt.isChecked() else self.trUtf8('Connect'))
+ def retranslateUi(idGlobalFeedback, w):
+ Ui_ViewConnectionWidget.retranslateUi(idGlobalFeedback, w)
+ bt = idGlobalFeedback.controlById(idGlobalFeedback.IdBtConnect)
+ bt.setText(idGlobalFeedback.trUtf8('Disconnect') if bt.isChecked() else idGlobalFeedback.trUtf8('Connect'))
#########################################
## event onrs
#########################################
- def onBtConnectClicked(self, isChecked):
- bt = self.controlById(self.IdBtConnect)
- bt.setText(self.trUtf8('Disconnect') if isChecked else self.trUtf8('Connect'))
+ def onBtConnectClicked(idGlobalFeedback, isChecked):
+ bt = idGlobalFeedback.controlById(idGlobalFeedback.IdBtConnect)
+ bt.setText(idGlobalFeedback.trUtf8('Disconnect') if isChecked else idGlobalFeedback.trUtf8('Connect'))
if isChecked:
if config.fcpClient.isConnected():
config.fcpClient.close()
- self._connectionTimer.start(self.fcSettings)
+ idGlobalFeedback._connectionTimer.start(idGlobalFeedback.fcSettings)
else:
- self._connectionTimer.stop()
+ idGlobalFeedback._connectionTimer.stop()
if config.fcpClient.isConnected():
- self._pollTimer.stop()
+ idGlobalFeedback._pollTimer.stop()
config.fcpClient.close()
- def onCkAutoConnectStateChanged(self, state):
- self.fcSettings.setValues(AutoConnect=state == QtCore.Qt.Checked)
+ def onCkAutoConnectStateChanged(idGlobalFeedback, state):
+ idGlobalFeedback.fcSettings.setValues(AutoConnect=state == QtCore.Qt.Checked)
#########################################
## fcp event onrs
#########################################
- def onFcpClientDisconected(self, event, msg):
- bt = self.controlById(self.IdBtConnect)
+ def onFcpClientDisconected(idGlobalFeedback, event, msg):
+ bt = idGlobalFeedback.controlById(idGlobalFeedback.IdBtConnect)
if bt.isChecked():
bt.click()
- def onFcpClientConected(self, event, msg):
- self._pollTimer.start(self.fcSettings)
+ def onFcpClientConected(idGlobalFeedback, event, msg):
+ idGlobalFeedback._pollTimer.start(idGlobalFeedback.fcSettings)
#**********************************************************************************
#
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-07-19 06:36:41
|
Revision: 672
http://fclient.svn.sourceforge.net/fclient/?rev=672&view=rev
Author: jUrner
Date: 2008-07-19 06:36:49 +0000 (Sat, 19 Jul 2008)
Log Message:
-----------
naming
Modified Paths:
--------------
trunk/fclient/src/fclient/Ui_View.py
Modified: trunk/fclient/src/fclient/Ui_View.py
===================================================================
--- trunk/fclient/src/fclient/Ui_View.py 2008-07-19 06:36:29 UTC (rev 671)
+++ trunk/fclient/src/fclient/Ui_View.py 2008-07-19 06:36:49 UTC (rev 672)
@@ -38,13 +38,12 @@
class GlobalFeedback(config.GlobalFeedbackBase):
"""wrapper for global statusbar widgets, menus"""
- def __init__(self, parent, idFeedbackParent):
- config.GlobalFeedbackBase.__init__(self, parent, idFeedbackParent)
+ def __init__(self, parent, idGlobalFeedback):
+ config.GlobalFeedbackBase.__init__(self, parent, idGlobalFeedback)
- print self.menuBar
# menus
self.menus = []
- if self.menuBar is not None:
+ if self.menuBar is not None and hasattr(parent, 'fcViewObject'):
menu = QtGui.QMenu(parent.fcViewObject.displayName, self.menuBar)
parent.populateMenu(menu)
self.menus.append(menu)
@@ -86,7 +85,7 @@
IdTabBottom = 'tabBottom'
- def __init__(self, parent, idFeedbackParent=config.IdMainWindow):
+ def __init__(self, parent, idGlobalFeedback=config.IdMainWindow):
QtGui.QWidget.__init__(self, parent)
self._isCreated = False
@@ -98,7 +97,7 @@
self.fcActions = Actions(self)
self.fcSettings = Settings().restore()
self.fcViewObject = ViewObject(self)
- self.fcGlobalFeedback = GlobalFeedback(self, idFeedbackParent)
+ self.fcGlobalFeedback = GlobalFeedback(self, idGlobalFeedback)
# setup tab widgets
tabWidgetTop = self.controlById(self.IdTabTop)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-07-19 06:36:21
|
Revision: 671
http://fclient.svn.sourceforge.net/fclient/?rev=671&view=rev
Author: jUrner
Date: 2008-07-19 06:36:29 +0000 (Sat, 19 Jul 2008)
Log Message:
-----------
naming
Modified Paths:
--------------
trunk/fclient/src/fclient/config.py
Modified: trunk/fclient/src/fclient/config.py
===================================================================
--- trunk/fclient/src/fclient/config.py 2008-07-19 06:36:05 UTC (rev 670)
+++ trunk/fclient/src/fclient/config.py 2008-07-19 06:36:29 UTC (rev 671)
@@ -109,12 +109,13 @@
class GlobalFeedbackBase(object):
"""application wide base class for feedback (statusbar widgets, menus)"""
- def __init__(self, parent, idFeedbackParent):
+ def __init__(self, parent, idGlobalFeedback):
+ self.id = idGlobalFeedback
self.menuBar = None
self.statusBar = None
- feedbackParent = ObjectRegistry.get(idFeedbackParent, None)
+ feedbackParent = ObjectRegistry.get(idGlobalFeedback, None)
if feedbackParent is not None:
mthd = getattr(feedbackParent, 'menuBar', None)
if mthd is not None:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|