JVc@sddlZddlZddlZddlZddlZddlZddlTddlTddlm Z ddl m Z m Z m Z ddlmZddlmZddlmZmZmZydd lmZWnek rnXyddlZWnek rejd nXddlZejd ed ZdZd Z dZ!dZ"dZ#dZ$dZ%dZ&dZ'dZ(dZ)dZ*dZ+dZ,dZ-dZ.d Z/dZ0dZ1dZ2de fdYZ3de4fdYZ5d e j6fd!YZ7ddde9e:d"Z;d Z<dZ=d#Z>d$Z?d%Z@d&ZAd'ZBd(ZCd)ZDd*ZEd+ZFd,ZEd-ZGd.ZHd/ZId0ejJfd1YZKdS(2iN(t*(t LDIFParser(tdevicetutilstvcard(tcups(tBytesIO(t to_bytes_utf8tto_longt to_unicodei(t coverpagess!dbus is required for PC send fax.tignoreiiiiiiiii i i i i iiit FaxLDIFParsercBseZdZdZRS(cCstj||||_dS(N(Rt__init__tdb(tselftinputR((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pyR sc Cs|ry|dd}Wn=tk rWy|dd}WqXtk rSd}qXXnXy|dd}Wntk rd}nXy|dd}Wntk r|d|}nXy|dd}Wn=tk r y|d d}Wq tk rd}q XnXg}y|d }Wntk r1nX|jtd g|D]}|rL|^qL} |rtjd ||d j| |f|jj|t|||| |qndS(Nt givenNameit givennamettsntcnt tfacsimiletelephonenumbertfaxtoutAlls.Import: name=%s, fax=%s, group(s)=%s, notes=%st,( tKeyErrortappendR tlogtdebugtjoinRtsetttitle( Rtdntentryt firstnametlastnametnicknameRtgrpstgtgroups((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pythandlesB        &(t__name__t __module__R R+(((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pyR s tFaxAddressBookcBseZdZdZdZeZdZdZeZdZ dZ dZ dZ d Z d Zd Zd Zd ZdZdZdZdZdZdZdZRS(cCsi|_|jdS(N(t_datatload(R((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pyR s cCsd|_tjdkrtjjtjd|_tjj|jryt|jd}t j ||_ |j q|j ndS(Ns /dev/nulls fab.pickletrb(t_fabtproptuser_dirtNonetostpathR texiststopentpickleR0R/tclosetsave(Rt pickle_file((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pyR0s  c Csg|D]}t|^q} it|d6t|d6t|d6t|d6t|d6t|d6| d6|jt|<|jdS(NtnameR"R%R&RtnotesR*(R R/R<( RR>R"R%R&RR*R?tsR(((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pyR!s     cCs%||jt||<|jdS(N(R/R R<(RR>tkeytvalue((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pyt set_key_valuescCs|jj|dS(N(R/tgetR5(RR>((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pyRDscCsy|j|Wntk r#dSXy|j|WnPtk r|j|j|j|<||j|d<|j|=|jnXdS(NR>(R/RtcopyR<(Rtold_nametnew_name((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pytrenames   cCsag}xTt|jjD]=\}}x.|dD]"}||kr3|j|q3q3WqW|S(NR*(tlistR/titemsR(Rt all_groupstetvR)((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pytget_all_groups s " cCs|jS(N(R/(R((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pytget_all_recordsscCst|jjS(N(RIR/tkeys(R((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pyt get_all_namesscCs^y9t|jd}tj|j|dd|jWntk rYtjdnXdS(NtwbtprotocolisI/O error saving fab file.( R9R2R:tdumpR/R;tIOErrorRterror(RR=((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pyR<s  cCsi|_|jdS(N(R/R<(R((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pytclear&s cCs+||jkr'|j|=|jtStS(N(R/R<tTruetFalse(RR>((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pytdelete+s   cCs0ytj|jjSWntk r+dSXdS(Ni(R6tstatR2tst_mtimetOSError(R((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pytlast_modification_time4s cCsxt|jjD]s\}}|d|kr_||dkr|djt|qq||dkr|djt|qqW|jdS(NR>R*(RIR/RJRR tremoveR<(RtgrouptmembersRLRM((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pyt update_groups;s"cCs^xMt|jjD]6\}}||dkr|djt|qqW|jdS(NR*(RIR/RJR_R R<(RR`RLRM((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pyt delete_groupFs"cCsPg}xCt|jjD],\}}||dkr|j|qqW|S(NR*(RIR/RJR(RR`RaRLRM((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pyt group_membersMs "cCsZ|j|}g}x*|D]"}||kr|j|qqW|j|||dS(N(RdRRb(RR`RaRdtnew_group_memberstm((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pyt add_to_groupUs   cCsV|j|}g}x*|D]"}||kr|j|qqW|j||dS(N(RdRRb(RR`tremove_membersRdReRf((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pytremove_from_group_s   cCs3|j|}|j|g|j||dS(N(RdRb(Rt old_groupt new_groupRa((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pyt rename_groupiscCsy_t|dj}tj||tt|d|}|j|jtdfSWntk r~}t |j fSXdS(NtrR( R9treadRt debug_blockR tparseR<RXt ValueErrorRYtmessage(RtfilenametdatatparserRL((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pyt import_ldifos  c Cst|dj}tj||xtjtjtj|D]}tj||drGd}x}t ddD]l}|dkrd}n d|}y ||Wnt k rPqzXd||d krz||d }PqzqzW|j d d}|r|g}n*|j d dj d }|s8g}n|j tdg|D]}|rR|^qR} |d} |j dtd} tjd| |dj| | f|j| tdtdtd|| | qGqGWtdfS(NRmR>Rii'tphonesphone%dRttypetnumbert organisationt categoriest;RR?s,Import: name=%s, fax=%s group(s)=%s notes=%sR(R9RnRRoRtVCardstVFilet opentextfileRtrangeRRDtsplitRR R R!RX( RRsRttcardRtxR@torgtoR*R>R?((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pyt import_vcard{s<(          &8(R,R-R R0R!tinsertRCRDtselectRHRNRORQR<RWRZR^RbRcRdRgRiRlRvR(((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pyR.s.              t FaxDevicecBseZd d d eedZdZdZeeeZ dZ dZ ee e Z dZ dZdZdZd d d ed d d d Zd Zd ZRS(cCsqtjj|||d||d|_d|_||_|sdtj}|j dd|_ n d|_ dS(Nscom.hplip.StatusServices/com/hplip/StatusService( RtDeviceR R5tsend_fax_threadtupload_log_threadtfax_typetdbust SessionBust get_objecttservice(Rt device_urit printer_nametcallbackRt disable_dbust session_bus((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pyR s     cCs tdS(N(tAttributeError(Rtnum((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pyt setPhoneNumscCs tdS(N(R(R((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pyt getPhoneNumscCs tdS(N(R(RR>((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pytsetStationNamescCs tdS(N(R(R((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pytgetStationNamescCs tdS(N(R(R((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pytsetDateAndTimescCs tdS(N(R(R((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pyt uploadLogscCs tdS(N(R(R((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pytisUploadLogActivescCs tdS(N(R(R((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pytwaitForUploadLogThreadsRc Cs tdS(N(R( Rtphone_num_listt fax_file_listt cover_messagetcover_ret cover_functpreserve_formattingRt update_queuet event_queue((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pyt sendFaxesscCs$|jdk r|jjStSdS(N(RR5tisAliveRY(R((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pytisSendFaxActives cCsJ|jdk rF|jjrFy|jjWqFtk rBqFXndS(N(RR5RR tKeyboardInterrupt(R((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pytwaitForSendFaxThreads  N(R,R-R5t FAX_TYPE_NONERYR RRtpropertyt phone_numRRt station_nameRRRRRRR(((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pyRs&           c Cs|tkr|dkrx|dk rxtj}xE|D].}|jj|jkr7|j}Pq7q7Wttn|dk rt j |}|d}qnt j d||t tfkrddlm}||||||S|tkrddlm} | |||||S|tkrPddlm} | |||||S|tkrddlm} | |||||S|tkrddlm} | |||||SttdS( Nsfax-types fax-type=%di(t PMLFaxDevice(t SOAPFaxDevice(tLEDMSOAPFaxDevice(tMarvellFaxDevice(t LEDMFaxDevice(RR5Rt getPrintersR>tlowerRtErrortERROR_DEVICE_NOT_FOUNDRtqueryModelByURIRRtFAX_TYPE_BLACK_SEND_EARLY_OPENtFAX_TYPE_BLACK_SEND_LATE_OPENtpmlfaxRt FAX_TYPE_SOAPtsoapfaxRtFAX_TYPE_LEDMSOAPt ledmsoapfaxRtFAX_TYPE_MARVELLt marvellfaxRt FAX_TYPE_LEDMtledmfaxRt'ERROR_DEVICE_DOES_NOT_SUPPORT_OPERATION( RRRRRtprinterstptmqRRRRR((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pyt getFaxDevices8         iiii(i2i<iFiPiZidinixit FaxSendThreadcBseZdddeddddZdZdZdZdZdZ dZ dZ d Z d Z ed Zd Zd ZdZdZRS(Rc Cstjj|||_||_||_||_| |_| |_||_ ||_ ||_ | |_ t |_d|_t|_||_i|_t|_g|_d|_d|_d|_d|_d|_d|_d|_dS(NRi(t threadingtThreadR tdevRRRRRRRRtcurrent_printerRtstreamt prev_updateRYtremove_temp_fileRtresultstcover_page_presenttrecipient_file_listR5tft job_hort_dpit job_vert_dpit job_page_sizetjob_resolutiont job_encoding( RRRRRRRRRRRR((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pyR 6s2                       cCst|_tj|jx|jD]}|\}}}}}|dkrct|_tjdn3|jj|dd|ftjd||f|jr#t }q#q#Wtj|j|jrt }n|S(Nsapplication/hplip-fax-coverpagesSkipping coverpagesapplication/hplip-faxsHP Faxs+Processing pre-rendered file: %s (%d pages)( RYRRRRRXtrendered_file_listRtcheck_for_cancelt STATE_ABORTED(Rtstatetfax_filet fax_file_namet fax_file_typet fax_file_desctfax_file_titletfax_file_pages((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pyt pre_renderVs"         c Cso|j|_tjdd|_tj|jd}x|jD]}|d}tjd|tjj|rt|j |Magic=%s Ver=%d Pages=%d hDPI=%d vDPI=%d Size=%d Res=%d Enc=%dsUnable to find HP Fax file: %ssTotal fax pages=%d(RRRRtjob_total_pagesR6R7R8t ERROR_SUCCESSRR9RntFILE_HEADER_SIZEtdecode_fax_headerRVtERROR_FAX_INVALID_FAX_FILEt STATE_ERRORRRRRRtERROR_FAX_INCOMPATIBLE_OPTIONSR;tERROR_FAX_FILE_NOT_FOUNDRRR(RRtiRRt fax_file_fdtheadertmagictversiont total_pagesthort_dpitvert_dpit page_sizet resolutiontencodingt reserved1t reserved2((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pyt count_pageswsZ     -   3         c Cs0ytjd|SWntjk r+dSXdS(Ns >8sBIHHBBBIIi( iiiiiiiiii(tstructtunpackRV(RR((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pyRscCs0ytjd|SWntjk r+dSXdS(Ns>IIIIIIi(iiiiii(RRRV(RR((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pytdecode_page_headerscCs|jdkrt}nt}|jrtjd|d|j|\}}|r`t}q|sot}q|j j d|dddftjd|t |j |isapplication/hplip-faxsHP Faxs Cover PagesCover page G3 file: %s( RtSTATE_MERGE_FILEStSTATE_SINGLE_FILERRRtrender_cover_pageRRRRRR(Rt recipientRRtcanceled((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pyt cover_pages     c Cs t}tjd|jdd|_yt|jd}Wn+tk rjtjd|jt}nX|j t }|j |\ }}}}}} } } } } t |j |j<|dkrtjdt|j |jMagic=%s Ver=%d Pages=%d hDPI=%d vDPI=%d Size=%d Res=%d Enc=%d(tSTATE_SEND_FAXRRRRR9RURVRRnRRRRRR;(RRtf_fdRRRRRRRRRRR((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pyt single_files(   -     c Cstjddtj|jtjdt|_|jrtj\}|_tjd|jt j ddt d|j|j |j |j|j|jt d t d  }tj||d}x |jD]}|d }tjd ||j|tkrt|d }|jt}|j|\ } } } } } }}}}}| dkr|tjd t}Pntjd | | | | | |||fxt| D]}|jt}|j|\}}}}}}|dkr tjd|tPnt j d|||||t d }tj|||jt|dftjd|||||ftj||j||d7}qW|j |j!rt"}Pqqtjd|qqWtj |tjd|jn|S(Ns%s State: Merge multiple filesRisMerging g3 files...s Temp file=%ss >8sBIHHBBBIIRiisProcessing file: %s...R1sInvalid file header. Bad magic.s>Magic=%s Ver=%d Pages=%d hDPI=%d vDPI=%d Size=%d Res=%d Enc=%disPage header errors>IIIIIIRs%Page=%d PPR=%d RPP=%d BPP=%d Thumb=%ssSkipping file: %ssTotal pages=%ds********************(#RRRRXRRRtmake_temp_fileRRtpackRRRRRRR6twriteRRR9RnRRRVRRtPAGE_HEADER_SIZERt write_queuetSTATUS_PROCESSING_FILESR;RR(RRR Rtt job_page_numRRRRRRRRRRRRRRRtpage_numtpprtrppt bytes_to_readtthumbnail_bytes((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pyt merge_filessb     -    !  '    ccsx|jD] }|Vq WdS(N(R(Rta((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pytnext_recipient_genPsccsx|jD] }|Vq WdS(N(R(RR((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pyt next_file_genTscCst}d}d}d}tj|dkr>tjd n|dkr^tjd |n|rttjd ntj|j||} tjtjd | d} tj dd} t } tjd} xtj| krtjdt |j j t|jj|j j tj| }t|d} tjd| | rZPn|jrtjd| tj| dtfStj dqWtjd| tj| dt fS| t fS(NRiisapplication/x-cshellsapplication/x-perlsapplication/x-pythonsapplication/x-shellsapplication/x-shs text/plaint prettyprints number-up=%ds page-ranges=1s Job ID=%dgr@sWaiting for fax... type =%sis Fax file=%ss%Render canceled. Canceling job #%d...s3Timeout waiting for rendering. Canceling job #%d...(sapplication/x-cshellsapplication/x-perlsapplication/x-pythonsapplication/x-shellsapplication/x-shs text/plain(RXRt resetOptionst addOptiont printFileRRRttimetsleepRYRxRRRIRtCheckForWaitingFaxR3tusernametstrRRVt cancelJob(RR7R"t mime_typetforce_single_paget all_pagest page_rangetpage_settnupt sent_job_idtjob_idRtcompletetend_timetresult((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pyt render_fileYsP     '     cCstt}xg|jjroy<|jjd}|dtkrSt}tjdnWq tj k rkPq Xq W|S(NisCancel pressed!( RYRtqsizeRDtEVENT_FAX_SEND_CANCELEDRXRRtQueuetEmpty(RRtevent((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pyRs cCstjdtj|jdtjd|jd|dddd|d d |jd tj d d d |j dtj d dd|j d|j d|j }tjd||j|dddt\}}ytj|Wntk rnX||fS(NsCreating cover page...RRtrecipient_nameR>trecipient_phoneRt recipient_faxRt sender_namet sender_phonet voice_phonet sender_faxt sender_emailt email_addresst regardingRrRs PDF File=%ss Cover Pagesapplication/pdfR&(RRt user_confRnRR tPAGE_SIZE_LETTERRR9RDR<RRRR0RXR6R_RU(RRtpdfRR((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pyRs,           cCsK|jdk rG||jkrG|jj|tjd||_ndS(Ni(RR5RtputRR (RRr((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pyRs cCsdS(N((R((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pytrunsN(R,R-R5RYR RRRRRR RRRR0RRRRD(((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pyR5s   ! H    ! L   = # (LtsysR6RR:RRtbase.gt base.codest base.ldifRtbaseRRRtprntRt base.sixextRRRR RR t ImportErrorRRRVtwarningst simplefiltertDeprecationWarningt STATUS_IDLERtSTATUS_SENDING_TO_RECIPIENTtSTATUS_DIALINGtSTATUS_CONNECTINGtSTATUS_SENDINGtSTATUS_COMPLETEDtSTATUS_CREATING_COVER_PAGEt STATUS_ERRORt STATUS_BUSYtSTATUS_CLEANUPtSTATUS_ERROR_IN_CONNECTINGtSTATUS_ERROR_IN_TRANSMITTINGtSTATUS_ERROR_PROBLEM_IN_FAXLINEtSTATUS_JOB_CANCELR2tRESOLUTION_STDtRESOLUTION_FINEtRESOLUTION_300DPIRRR tobjectR.RRR5RRYRt STATE_DONERt STATE_SUCCESSt STATE_BUSYtSTATE_READ_SENDER_INFOtSTATE_PRERENDERtSTATE_COUNT_PAGEStSTATE_NEXT_RECIPIENTtSTATE_COVER_PAGERRRt STATE_CLEANUPRRR(((sW/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/fax/fax.pyts           ;1K 0