PlistHelper.rbbas 3.27 KB
Newer Older
Rusty Myers's avatar
Rusty Myers committed
1
#tag Module
Protected Module PlistHelper
	#tag Method, Flags = &h0
		Function readPlist(paramPathToPlist as String, paramNameofPlist as String, paramPlistKey as String, byRef paramFoundDataString as String) As Boolean
		  dim mXMLtreeToFollow(-1) as string
		  dim mPrefKeyFoundData(-1) as string
		  
		  LogToFile(CurrentMethodName + ": --->")
		  // LogToFile("paramPathToPlist: " + paramPathToPlist)
		  // LogToFile("paramPlistKey: " + paramPlistKey)
		  // Read the default values to start with
		  
		  Globals.gXMLprefsData = new XmlDocument
		  
		  // paramPathToPlist = "/Library/CLMadmin/Config/"
		  Globals.gIdleLogoutPrefsFile = GetFolderItem( paramPathToPlist + paramNameofPlist, FolderItem.PathTypeShell )
		  
		  if ( Globals.gIdleLogoutPrefsFile = nil ) then
		    
		    // The folder path does not exist, so set the bare minimium defaults...
		    
		    LogToFile(CurrentMethodName + ": ERROR! The file variable is NIL.")
		    LogToFile(CurrentMethodName + ": <----")
		    return false
		    
		  elseif ( not ( Globals.gIdleLogoutPrefsFile.IsReadable ) ) then
		    
		    LogToFile(CurrentMethodName + ": ERROR! The file is not readable, or does not exist!")
		    LogToFile(CurrentMethodName + ": <----")
		    return false
		    
		  else
		    
		    // Read the XML data next:
		    
		    LogToFile (CurrentMethodName + ": Found the plist data file. Reading it next...")
		    
		    Globals.gXMLprefsData.LoadXml(Globals.gIdleLogoutPrefsFile)
		    
		    redim mXMLtreeToFollow(-1)
		    mXMLtreeToFollow.Append("<plist>")
		    mXMLtreeToFollow.Append("<dict>")
		    mXMLtreeToFollow.Append("<key>" + paramPlistKey + "</key>")
		    mXMLtreeToFollow.Append("<string>")
		    
		    if ( myXMLTools.getXMLPlistData( Globals.gXMLprefsData.ToString ,mXMLtreeToFollow,mPrefKeyFoundData) ) then
		      
		      if ( UBound (mPrefKeyFoundData) > -1 ) then
		        
		        LogToFile(CurrentMethodName + ": Success! " + paramPlistKey + " = '" + mPrefKeyFoundData(0) + "'")
		        
		        paramFoundDataString = mPrefKeyFoundData(0)
		        
		        LogToFile(CurrentMethodName + ": <----")
		        return true
		        
		      else
		        
		        LogToFile(CurrentMethodName + ": ERROR: Returned data is EMPTY! Returning FALSE.")
		        LogToFile(CurrentMethodName + ": <----")
		        return false
		        
		      end if
		      
		    else
		      
		      LogToFile(CurrentMethodName + ": ERROR! Returning FALSE.")
		      LogToFile(CurrentMethodName + ": <----")
		      return false
		      
		    end if
		    
		  end if
		  
		End Function
	#tag EndMethod


	#tag ViewBehavior
		#tag ViewProperty
			Name="Index"
			Visible=true
			Group="ID"
			InitialValue="-2147483648"
			InheritedFrom="Object"
		#tag EndViewProperty
		#tag ViewProperty
			Name="Left"
			Visible=true
			Group="Position"
			InitialValue="0"
			InheritedFrom="Object"
		#tag EndViewProperty
		#tag ViewProperty
			Name="Name"
			Visible=true
			Group="ID"
			InheritedFrom="Object"
		#tag EndViewProperty
		#tag ViewProperty
			Name="Super"
			Visible=true
			Group="ID"
			InheritedFrom="Object"
		#tag EndViewProperty
		#tag ViewProperty
			Name="Top"
			Visible=true
			Group="Position"
			InitialValue="0"
			InheritedFrom="Object"
		#tag EndViewProperty
	#tag EndViewBehavior
End Module
#tag EndModule