''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'' MessageAPI用サブルーチン
'
' Sub papiMessageGetMessage $argDBID $argMID
' var $localLID = $Login.ID
' var Set $localMessageTop = $Command.Message.GetMessageTop $argDBID
' Set $globalMessage = $localMessageTop.PrivateMessages.$argMID
' Set $globalFollows = $globalMessage.Follows
' $globalOutReceiver = $Command.Message.IsOutReceiver $argDBID $argMID $localLID
' var $localContains = $globalMessage.UIDs.Contains $localLID
' If ! $localContains and ($globalMessage.UID != $localLID) and ! $globalOutReceiver
' $Command.PApi.ThrowError 14807
' EndIf
' If $globalOutReceiver
' var $localOutTime = $globalMessage.OutTimes.$localLID
' Set $globalMessage = $globalMessage.DeleteMessages.$localOutTime
' EndIf
' If ! $globalMessage
' $Command.PApi.ThrowError 14808
' EndIf
' EndSub
'
' Sub papiMessageShowContent $argItem
' For Each $localFileID in $argItem.FileIDs
' Call papiMessageShowFile $localFileID
' Next
' EndSub
'
' Sub papiMessageShowFile $argFileID
' var Set $localFile = $Cabinet.Files.$argFileID
' var $localInTrush = $Cabinet.Trush.Contains $argFileID
' If $localFile and ( ! $localInTrush )
' $MIME.FileName = $localFile.FileName
' EndIf
' EndSub
'
' Sub papiMessageShowProfiles $argValue
' var $localUseTrash = $Command.MyFolder.CanUseTrash
' var $localDusts = $Personal.Cabinet.Dusts
' Init $localDusts = 5
' If $argValue == "true"
' EndIf
' EndSub
'
' Sub papiMessageShowThreads $argItems
' If $argItems.IsEmpty
' Exit
' EndIf
' For Each $localItem in $argItems
' var $localDBID = $localItem.DBID
' var $localMID = $localItem.MID
' If $localDBID >= 0
' Call papiMessageGetMessage $localDBID $localMID
' If $globalMessage.Version and ( $globalMessage.Version > $globalMessage.MTime )
' var $localVersion = $Command.String.StrMidLong $globalMessage.Version 3
' Else
' var $localVersion = $Command.String.StrMidLong $globalMessage.MTime 3
' EndIf
' var $localConfirm = $globalMessage.IsConfirmMessage
' For Each $localUID in $globalMessage.UIDs
' var $localAlreadyRead = 0
' If $localConfirm
' $localAlreadyRead = $Command.Message.AlreadyRead $globalMessage $localUID
' EndIf
' Next
' For Each $localUID in $globalMessage.OutUIDs
' Next
' Call papiMessageShowContent $globalMessage
' For Each $localFollow in $globalFollows
' If $globalOutReceiver and ( $localFollow.ID > $globalMessage.LastFollowID )
' Continue
' EndIf
' Next
' var $localCTime = $globalMessage.CTime
' var $localPrevFID = 0
' For Each $localElement in $Personal.Cabinet.Elements.$localCTime
' If ($localElement.EID = $localMID) and ( ! $localElement.DBID or ($localElement.DBID = $localDBID) )
' If $localPrevFID == $localElement.Folder.ID
' Continue
' EndIf
' $localPrevFID = $localElement.Folder.ID
' Call cmShowTagAttr "folder" "id" $localElement.Folder.ID
' EndIf
' Next
' If $globalMessage.ContentsMTime
' Else
' EndIf
' Else
'' 下書きの場合
' var Set $localElement = $System.GetObject $localMID Personal
' var $localVersion = $Command.String.StrMidLong $localElement.MTime 3
' For Each $localUID in $localElement.UIDs
' Next
' Call papiMessageShowContent $localElement
' Call cmShowTagAttr "folder" "id" $localElement.Folder.ID
' EndIf
' Next
' EndSub
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'' レスポンスサブルーチン
'
' Sub responseMessageAddFollows $argItems
' Call papiMessageShowThreads $argItems
' EndSub
'
' Sub responseMessageConfirmThreads $argItems
' Call papiMessageShowThreads $argItems
' EndSub
'
' Sub responseMessageCreateThreads $argItems
' Call papiMessageShowThreads $argItems
' EndSub
'
' Sub responseMessageFileDownload $argValue
$argValue.ScalarValue
' EndSub
'
' Sub responseMessageGetFolderVersions $argItems
' If $argItems.IsEmpty
' Exit
' EndIf
' For Each $localItem in $argItems
' Call cmShowVersionOperation "folder_item" $localItem.ID $localItem.Version $localItem.Operation
' Next
' EndSub
'
' Sub responseMessageGetFoldersById $argItems
' For Each $localItem in $argItems
' var $localFID = $localItem.ID
' var Set $localFolder = $Personal.Cabinet.Folders.$localFID
' var $localVersion = 0
' var $localName = ""
' var $localOrder = 0
' var $localPID = 0
' var $localFolderType = ""
' If $localFolder.MTime
' $localVersion = $Command.String.StrMidLong $localFolder.MTime 3
' EndIf
' If $localFID == 1
' $localName = "(ルートフォルダ)"
' $localOrder = 0
' $localPID = 0
' $localFolderType = "root"
' Elif $localFID == $Personal.Cabinet.Inbox.ID
' $localName = "[受信箱]"
' $localOrder = 1
' $localPID = 1
' $localFolderType = "received"
' Elif $localFID == $Personal.Cabinet.Sent.ID
' $localName = "[送信箱]"
' $localOrder = 2
' $localPID = 1
' $localFolderType = "sent"
' Elif $localFID == $Personal.Cabinet.Unsent.ID
' $localName = "[下書き]"
' $localOrder = 3
' $localPID = 1
' $localFolderType = "draft"
' Elif $localFID == $Personal.Cabinet.Trash.ID
' $localName = "[ごみ箱]"
' $localOrder = 2147483647
' $localPID = 1
' $localFolderType = "trash"
' Else
' If ! $localFolder
' $Command.PApi.ThrowError 14603
' EndIf
' $localName = $localFolder.Name
' If $localFolder.Parent.ID == $Personal.Cabinet.Root.ID
' $localOrder = 4
' $localPID = 1
' Else
' $localOrder = 1
' $localPID = $localFolder.Parent.ID
' EndIf
' For Each $tmpFolder in $localFolder.Parent.Folders
' If $localFID == $tmpFolder.ID
' Exit
' EndIf
' Inc $localOrder
' Next
' $localFolderType = "user_folder"
' EndIf
' If $localFID == 1
' Call cmShowTagAttr "folder" "id" $Personal.Cabinet.Inbox.ID
' Call cmShowTagAttr "folder" "id" $Personal.Cabinet.Sent.ID
' Call cmShowTagAttr "folder" "id" $Personal.Cabinet.Unsent.ID
' For Each $localSubFolder in $Personal.Cabinet.Root.Folders
' Call cmShowTagAttr "folder" "id" $localSubFolder.ID
' Next
' Call cmShowTagAttr "folder" "id" $Personal.Cabinet.Trash.ID
' Elif $localFolder.Folders
' For Each $localSubFolder in $localFolder.Folders
' Next
' EndIf
' var Set $localThreads = $localItem.Threads
' If $localThreads.Count
' For Each $localThread in $localThreads
' Next
' EndIf
' Next
' EndSub
'
' Sub responseMessageGetFollows $argValue
' var $localDBID = $argValue.DBID
' var $localMID = $argValue.MID
' Call papiMessageGetMessage $localDBID $localMID
' var $localOffset = $argValue.offset
' var $localLimit = $argValue.limit
' For Each $localFollow in $globalFollows
' If $globalOutReceiver and ( $localFollow.ID > $globalMessage.LastFollowID )
' Continue
' EndIf
' If $localOffset > 0
' Inc $localOffset -1
' Continue
' EndIf
' If $localLimit <= 0
' Exit
' EndIf
' If $localFollow.FileID
' Call papiMessageShowFile $localFollow.FileID
' EndIf
' Inc $localLimit -1
' Next
' EndSub
'
' Sub responseMessageGetProfiles $argValue
' Call papiMessageShowProfiles $argValue.ScalarValue
' EndSub
'
' Sub responseMessageGetThreadVersions $argItems
' If $argItems.Count
' For Each $localItem in $argItems
' Call cmShowVersionOperation "thread_item" $localItem.ID $localItem.Version $localItem.Operation
' Next
' EndIf
' EndSub
'
' Sub responseMessageGetThreadsById $argItems
' Call papiMessageShowThreads $argItems
' EndSub
'
' Sub responseMessageModifyThreads $argItems
' Call papiMessageShowThreads $argItems
' EndSub
'
' Sub responseMessageSaveDraftThreads $argItems
' Call papiMessageShowThreads $argItems
' EndSub
'
' Sub responseMessageSearchThreads $argItems
' Call papiMessageShowThreads $argItems
' EndSub
'
' Sub responseMessageSetProfiles $argItems
' Call papiMessageShowProfiles "false"
' EndSub
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'' エントリーポイント
'
' Call soapInit
'
' $Action = $Command.PApi.GetAction
'
' Call soapBeginResponse Message
' Call cmShowActionResponseBegin message $Action
'
' Select $Action
' Case MessageAddFollows
' Set $localItems = $Command.PApi.MessageAddFollows
' Call responseMessageAddFollows $localItems
'
' Case MessageConfirmThreads
' Set $localItems = $Command.PApi.MessageConfirmThreads
' Call responseMessageConfirmThreads $localItems
'
' Case MessageCreateThreads
' Set $localItems = $Command.PApi.MessageCreateThreads
' Call responseMessageCreateThreads $localItems
'
' Case MessageFileDownload
' Set $localValue = $Command.PApi.MessageFileDownload
' Call responseMessageFileDownload $localValue
'
' Case MessageGetFolderVersions
' Set $localItems = $Command.PApi.MessageGetFolderVersions
' Call responseMessageGetFolderVersions $localItems
'
' Case MessageGetFoldersById
' Set $localItems = $Command.PApi.MessageGetFoldersById
' Call responseMessageGetFoldersById $localItems
'
' Case MessageGetFollows
' Set $localValue = $Command.PApi.MessageGetFollows
' Call responseMessageGetFollows $localValue
'
' Case MessageGetProfiles
' Set $localValue = $Command.PApi.MessageGetProfiles
' Call responseMessageGetProfiles $localValue
'
' Case MessageGetThreadVersions
' Set $localItems = $Command.PApi.MessageGetThreadVersions
' Call responseMessageGetThreadVersions $localItems
'
' Case MessageGetThreadsById
' Set $localItems = $Command.PApi.MessageGetThreadsById
' Call responseMessageGetThreadsById $localItems
'
' Case MessageModifyThreads
' Set $localItems = $Command.PApi.MessageModifyThreads
' Call responseMessageModifyThreads $localItems
'
' Case MessageRemoveFollows
' Set $localItems = $Command.PApi.MessageRemoveFollows
'
' Case MessageRemoveThreads
' Set $localItems = $Command.PApi.MessageRemoveThreads
'
' Case MessageSaveDraftThreads
' Set $localItems = $Command.PApi.MessageSaveDraftThreads
' Call responseMessageSaveDraftThreads $localItems
'
' Case MessageSearchThreads
' Set $localItems = $Command.PApi.MessageSearchThreads
' Call responseMessageSearchThreads $localItems
'
' Case MessageSetProfiles
' Set $localItems = $Command.PApi.MessageSetProfiles
' Call responseMessageSetProfiles $localItems
'
' Default
' $Command.PApi.ThrowError 19103
' EndSelect
'
' Call cmShowActionResponseEnd message $Action
' Call soapEndResponse