diff -r 000000000000 -r ca70ae20a155 src/extras/fileserver/fileclient.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/extras/fileserver/fileclient.py Tue Feb 16 10:07:05 2010 +0530 @@ -0,0 +1,158 @@ +# +# fileclient.py +# +# A client library for the simple file transfer server for Series 60 Python environment. +# +# Copyright (c) 2005 Nokia Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +import os +import sys +import binascii +import ntpath + +symbianbasename=ntpath.basename + +class fileclient: + def __init__(self,sock,verbose=0): + self.sock=sock + self.verbose=verbose + if verbose: + self.log=sys.stdout.write + else: + self.log=lambda x:0 + def recvdata(self): + #self.log("Waiting for content length..." + header_lines=[self.readline() for x in range(2)] + header=dict([x.rstrip().split(': ') for x in header_lines]) + content_length=int(header['Content-Length']) + crc32=int(header['CRC32']) + self.log("Content-Length: %d"%content_length+"\n") + recvbytes=0 + content=[] + #self.log("Receiving data...") + while recvbytes