-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#143 共有ドライブ内のオブジェクトの一覧表示に対応。まだ表示する以上の対応はしていない。各所の問題は後日修正する
- Loading branch information
1 parent
761e52f
commit 4ab5607
Showing
4 changed files
with
114 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# -*- coding: utf-8 -*- | ||
#Falcon networkResource list object | ||
#Copyright (C) 2020 yamahubuki <[email protected]> | ||
#Note: All comments except these top lines will be written in Japanese. | ||
|
||
import wx | ||
import win32wnet | ||
|
||
import misc | ||
import browsableObjects | ||
import globalVars | ||
import errorCodes | ||
|
||
from simpleDialog import dialog | ||
from .base import * | ||
from .constants import * | ||
from win32com.shell import shell, shellcon | ||
|
||
class NetworkResourceList(FalconListBase): | ||
"""ネットワークリソースの一覧を扱うクラス。""" | ||
def __init__(self): | ||
super().__init__() | ||
self.supportedSorts=[] #ソート不可 | ||
self.columns={ | ||
_("名前"):wx.LIST_FORMAT_LEFT, | ||
} | ||
self.resources=[] | ||
self.lists=[self.resources] | ||
|
||
def Update(self): | ||
return self.Initialize(self.rootDirectory,True) | ||
|
||
def Initialize(self,path,silent=False): | ||
"""リソースの情報を取得し、リストを初期化する。""" | ||
self.log.debug("Getting resources list...") | ||
self.rootDirectory=path | ||
t=misc.Timer() | ||
if isinstance(path,list):#パラメータがリストなら、browsableObjects のリストとして処理刷る(ファイルリストを取得しないでコピーする) | ||
self.resources=path | ||
return errorCodes.OK | ||
#end copy | ||
self.resources.clear() | ||
if not silent: | ||
globalVars.app.say(path[2:]) | ||
|
||
#取得対象を構造体にセット | ||
rootResource=win32wnet.NETRESOURCE() | ||
rootResource.lpRemoteName=path | ||
|
||
#リソースリストの取得 | ||
try: | ||
h=win32wnet.WNetOpenEnum(2,1,0,rootResource) | ||
#2=RESOURCE_GLOBALNET | ||
#1=RESOURCETYPE_DISK | ||
lst=win32wnet.WNetEnumResource(h,64) #65以上の指定不可 | ||
win32wnet.WNetCloseEnum(h); | ||
except win32net.error as er: | ||
dialog(_("エラー"), _("ネットワーク上のリソース一覧を取得できませんでした(%(error)s)") % {"error": str(er)}) | ||
return errorCodes.ACCESS_DENIED | ||
|
||
for l in lst: | ||
ret, shfileinfo=shell.SHGetFileInfo(l.lpRemoteName,0,shellcon.SHGFI_ICON) | ||
s=browsableObjects.NetworkResource() | ||
self.log.debug("network resource found and check IP address:"+l.lpRemoteName[2:]) | ||
s.Initialize(l.lpRemoteName[len(path)+1:],l.lpRemoteName,"",shfileinfo[0]) | ||
self.resources.append(s) | ||
|
||
self.log.debug("Network resource list created in %d seconds." % t.elapsed) | ||
self.log.debug(str(len(self.resources))+" resources found.") | ||
return errorCodes.OK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
# -*- coding: utf-8 -*- | ||
#Falcon NetworkResource List tab | ||
#Copyright (C) 2020 yamahubuki <[email protected]> | ||
#Falcon network resource List tab | ||
#Copyright (C)2020 yamahubuki <[email protected]> | ||
#Note: All comments except these top lines will be written in Japanese. | ||
|
||
""" | ||
ネットワークリソースリストです。ファイルリストと比べると、機能が制限されます。 | ||
ネットワークリソースリストです。ファイル操作関連は一切できません。 | ||
""" | ||
|
||
import os | ||
|
@@ -34,80 +34,54 @@ class NetworkResourceListTab(base.FalconTabBase): | |
"FILE_DELETE", | ||
"FILE_MKDIR", | ||
"EDIT_CUT", | ||
"EDIT_PAST", | ||
"EDIT_SEARCH", | ||
"MOVE_BACKWARD", | ||
"MOVE_FORWARD_TAB", | ||
"MOVE_TOPFILE", | ||
"TOOL_DIRCALC", | ||
"TOOL_HASHCALC", | ||
"TOOL_ADDPATH", | ||
"READ_CONTENT_PREVIEW" | ||
"TOOL_EXEC_PROGRAM", | ||
"READ_CONTENT_PREVIEW", | ||
"READ_CONTENT_READHEADER", | ||
"READ_CONTENT_READFOOTER", | ||
] | ||
|
||
def Update(self,cursor=""): | ||
"""指定された要素をタブに適用する。""" | ||
self._cancelBackgroundTasks() | ||
lst=lists.NetworkDeviceList() | ||
lst.Initialize(None) | ||
self.hListCtrl.DeleteAllItems() | ||
self.SetListColumns(lst) | ||
self.listObject=lst | ||
self.UpdateListContent(self.listObject.GetItems()) | ||
if cursor!="": | ||
c=lst.Search(cursor,0) | ||
self.hListCtrl.Select(c) | ||
self.hListCtrl.Focus(c) | ||
#end カーソル初期位置を設定 | ||
#end Update | ||
|
||
def GoBackward(self): | ||
"""ドライブ一覧に戻る""" | ||
return self.Move(""," ") | ||
"""ドライブ一覧へ戻る""" | ||
target="" | ||
cursorTarget=self.listObject.rootDirectory[0] | ||
return self.Move(target,cursorTarget) | ||
|
||
def MakeShortcut(self,option): | ||
prm="" | ||
dir="" | ||
if option["type"]=="shortcut": | ||
prm=option["parameter"] | ||
dir=option["directory"] | ||
target=self.parent.activeTab.GetSelectedItems().GetElement(0).fullpath | ||
dest=option["destination"] | ||
if not os.path.isabs(dest): #早退の場合は絶対に直す | ||
dest=os.path.normpath(os.path.join(os.path.dirname(target),dest)) | ||
|
||
#TODO: | ||
#相対パスでの作成に後日対応する必要がある | ||
#ハードリンクはドライブをまたげないのでバリデーションする | ||
#ファイルシステムを確認し、対応してない種類のものは作れないようにバリデーションする | ||
#作業フォルダの指定に対応する(ファイルオペレータ側の修正も必用) | ||
|
||
if option["type"]=="shortcut": | ||
inst={"operation":option["type"], "target": [(dest,target,prm)]} | ||
else: | ||
inst={"operation":option["type"], "from": [target], "to": [dest]} | ||
#end ショートカットかそれ以外 | ||
op=fileOperator.FileOperator(inst) | ||
ret=op.Execute() | ||
if op.CheckSucceeded()==0: | ||
dialog(_("エラー"),_("ショートカットの作成に失敗しました。")) | ||
return | ||
#end error | ||
self.UpdateFilelist(silence=True) | ||
|
||
def FileOperationTest(self): | ||
if self.task: | ||
self.task.Cancel() | ||
else: | ||
self.task=workerThreads.RegisterTask(workerThreadTasks.DebugBeep) | ||
#TODO:リネームを拒否 | ||
def OnLabelEditEnd(self,event): | ||
evt.Veto() | ||
return | ||
|
||
def ShowProperties(self): | ||
index=self.GetFocusedItem() | ||
shell.ShellExecuteEx(shellcon.SEE_MASK_INVOKEIDLIST,0,"properties",self.listObject.GetElement(index).fullpath) | ||
|
||
def ReadCurrentFolder(self): | ||
globalVars.app.say(_("現在は、ネットワーク上のリソースの洗濯"), interrupt=True) | ||
globalVars.app.say(_("現在は、"+self.listObject.rootDirectory), interrupt=True) | ||
|
||
def ReadListItemNumber(self): | ||
globalVars.app.say(_("ネットワークリソース %(drives)d個") % {'drives': len(self.listObject)}, interrupt=True) | ||
def ReadListItemNumber(self,short=False): | ||
#shortもlongも関係ない | ||
globalVars.app.say(_("項目数 %(count)d") % {'count': len(self.listObject)}) | ||
|
||
def ReadListInfo(self): | ||
globalVars.app.say(_("ネットワークリソース一覧を %(sortkind)sの%(sortad)sで一覧中、 %(max)d個中 %(current)d個目") %{'sortkind': self.listObject.GetSortKindString(), 'sortad': self.listObject.GetSortAdString(), 'max': len(self.listObject), 'current': self.GetFocusedItem()+1}, interrupt=True) | ||
globalVars.app.say(_("ネットワークリソースの一覧を一覧中、 %(max)d個中 %(current)d個目") %{'max': len(self.listObject), 'current': self.GetFocusedItem()+1}, interrupt=True) | ||
|
||
def GetTabName(self): | ||
"""タブコントロールに表示する名前""" | ||
return self.listObject.rootDirectory | ||
|
||
#TODO: def OpenContextMenu(self,event): | ||
|
||
def GetRootObject(self): | ||
"""ドライブ詳細情報表示で用いる""" | ||
#TODO:IPアドレス入れる | ||
return browsableObjects.NetworkResource(self.listObject.rootDirectory[2:],self.listObject.rootDirectory,None) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters