device connect
commit
d13ff11793
|
@ -0,0 +1,246 @@
|
|||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
|
||||
# User-specific files
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
*.dll
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
[Xx]64/
|
||||
[Xx]86/
|
||||
[Bb]uild/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
|
||||
# Visual Studio 2015 cache/options directory
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
# NUNIT
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# DNX
|
||||
project.lock.json
|
||||
artifacts/
|
||||
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_i.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
*.VC.db
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.sap
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# JustCode is a .NET coding add-in
|
||||
.JustCode
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
nCrunchTemp_*
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
|
||||
# TODO: Un-comment the next line if you do not want to checkin
|
||||
# your web deploy settings because they may include unencrypted
|
||||
# passwords
|
||||
#*.pubxml
|
||||
*.publishproj
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/packages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/packages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/packages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignoreable files
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Microsoft Azure Emulator
|
||||
ecf/
|
||||
rcf/
|
||||
|
||||
# Microsoft Azure ApplicationInsights config file
|
||||
ApplicationInsights.config
|
||||
|
||||
# Windows Store app package directory
|
||||
AppPackages/
|
||||
BundleArtifacts/
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!*.[Cc]ache/
|
||||
|
||||
# Others
|
||||
ClientBin/
|
||||
[Ss]tyle[Cc]op.*
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
node_modules/
|
||||
orleans.codegen.cs
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/ModelManifest.xml
|
||||
**/*.Server/GeneratedArtifacts
|
||||
**/*.Server/ModelManifest.xml
|
||||
_Pvt_Extensions
|
||||
|
||||
# LightSwitch generated files
|
||||
GeneratedArtifacts/
|
||||
ModelManifest.xml
|
||||
|
||||
# Paket dependency manager
|
||||
.paket/paket.exe
|
||||
|
||||
# FAKE - F# Make
|
||||
.fake/
|
|
@ -0,0 +1,31 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.29709.97
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Brokenithm-Evolved-iOS", "Brokenithm-Evolved-iOS\Brokenithm-Evolved-iOS.vcxproj", "{F3C0C748-308E-4243-B2B7-D0498196D76E}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{F3C0C748-308E-4243-B2B7-D0498196D76E}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{F3C0C748-308E-4243-B2B7-D0498196D76E}.Debug|x64.Build.0 = Debug|x64
|
||||
{F3C0C748-308E-4243-B2B7-D0498196D76E}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{F3C0C748-308E-4243-B2B7-D0498196D76E}.Debug|x86.Build.0 = Debug|Win32
|
||||
{F3C0C748-308E-4243-B2B7-D0498196D76E}.Release|x64.ActiveCfg = Release|x64
|
||||
{F3C0C748-308E-4243-B2B7-D0498196D76E}.Release|x64.Build.0 = Release|x64
|
||||
{F3C0C748-308E-4243-B2B7-D0498196D76E}.Release|x86.ActiveCfg = Release|Win32
|
||||
{F3C0C748-308E-4243-B2B7-D0498196D76E}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {EA572FF9-3472-4D0B-8190-7131BED0F20A}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,151 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<ProjectGuid>{F3C0C748-308E-4243-B2B7-D0498196D76E}</ProjectGuid>
|
||||
<RootNamespace>BrokenithmEvolvediOS</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<ReferencePath>$(VC_ReferencesPath_x64);</ReferencePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\dep;</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Library Include="libimobiledevice.lib" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="源文件">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="头文件">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="资源文件">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Library Include="libimobiledevice.lib">
|
||||
<Filter>资源文件</Filter>
|
||||
</Library>
|
||||
</ItemGroup>
|
||||
</Project>
|
Binary file not shown.
|
@ -0,0 +1,54 @@
|
|||
#include <cstdio>
|
||||
#include <conio.h>
|
||||
#include <map>
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
#include <libimobiledevice\libimobiledevice.h>
|
||||
|
||||
#pragma comment(lib, "libimobiledevice.lib")
|
||||
|
||||
void device_event_callback(const idevice_event_t* event, void* user_data);
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
idevice_error_t status;
|
||||
status = idevice_event_subscribe(device_event_callback, NULL);
|
||||
if (status) {
|
||||
printf("Subscribe for device failed\n");
|
||||
}
|
||||
while (_getch() != 'q') {}
|
||||
return 0;
|
||||
}
|
||||
|
||||
map<string, idevice_t*> device_map;
|
||||
void device_event_callback(const idevice_event_t* event, void* user_data)
|
||||
{
|
||||
idevice_error_t status;
|
||||
bool isAdd = event->event == IDEVICE_DEVICE_ADD;
|
||||
printf("device %s\tudid: %s\n", isAdd ? "add" : "remove", event->udid);
|
||||
if (isAdd) {
|
||||
string udid = event->udid;
|
||||
//idevice_t* device = (idevice_t*)malloc(sizeof(idevice_t));
|
||||
idevice_t* device = new idevice_t;
|
||||
device_map[udid] = device;
|
||||
status = idevice_new(device, udid.c_str());
|
||||
if (status) {
|
||||
printf("Create device failed\n");
|
||||
device_map.erase(udid);
|
||||
delete device;
|
||||
}
|
||||
}
|
||||
else {
|
||||
string udid = event->udid;
|
||||
idevice_t* device = device_map[udid];
|
||||
if (device) {
|
||||
device_map.erase(udid);
|
||||
status = idevice_free(*device);
|
||||
if (status) {
|
||||
printf("Free device failed\n");
|
||||
}
|
||||
delete device;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,375 @@
|
|||
/**
|
||||
* @file libimobiledevice/afc.h
|
||||
* @brief Access the filesystem on the device.
|
||||
* \internal
|
||||
*
|
||||
* Copyright (c) 2010-2014 Martin Szulecki All Rights Reserved.
|
||||
* Copyright (c) 2009-2010 Nikias Bassen All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef IAFC_H
|
||||
#define IAFC_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <libimobiledevice/libimobiledevice.h>
|
||||
#include <libimobiledevice/lockdown.h>
|
||||
|
||||
#define AFC_SERVICE_NAME "com.apple.afc"
|
||||
|
||||
/** Error Codes */
|
||||
typedef enum {
|
||||
AFC_E_SUCCESS = 0,
|
||||
AFC_E_UNKNOWN_ERROR = 1,
|
||||
AFC_E_OP_HEADER_INVALID = 2,
|
||||
AFC_E_NO_RESOURCES = 3,
|
||||
AFC_E_READ_ERROR = 4,
|
||||
AFC_E_WRITE_ERROR = 5,
|
||||
AFC_E_UNKNOWN_PACKET_TYPE = 6,
|
||||
AFC_E_INVALID_ARG = 7,
|
||||
AFC_E_OBJECT_NOT_FOUND = 8,
|
||||
AFC_E_OBJECT_IS_DIR = 9,
|
||||
AFC_E_PERM_DENIED = 10,
|
||||
AFC_E_SERVICE_NOT_CONNECTED = 11,
|
||||
AFC_E_OP_TIMEOUT = 12,
|
||||
AFC_E_TOO_MUCH_DATA = 13,
|
||||
AFC_E_END_OF_DATA = 14,
|
||||
AFC_E_OP_NOT_SUPPORTED = 15,
|
||||
AFC_E_OBJECT_EXISTS = 16,
|
||||
AFC_E_OBJECT_BUSY = 17,
|
||||
AFC_E_NO_SPACE_LEFT = 18,
|
||||
AFC_E_OP_WOULD_BLOCK = 19,
|
||||
AFC_E_IO_ERROR = 20,
|
||||
AFC_E_OP_INTERRUPTED = 21,
|
||||
AFC_E_OP_IN_PROGRESS = 22,
|
||||
AFC_E_INTERNAL_ERROR = 23,
|
||||
AFC_E_MUX_ERROR = 30,
|
||||
AFC_E_NO_MEM = 31,
|
||||
AFC_E_NOT_ENOUGH_DATA = 32,
|
||||
AFC_E_DIR_NOT_EMPTY = 33,
|
||||
AFC_E_FORCE_SIGNED_TYPE = -1
|
||||
} afc_error_t;
|
||||
|
||||
/** Flags for afc_file_open */
|
||||
typedef enum {
|
||||
AFC_FOPEN_RDONLY = 0x00000001, /**< r O_RDONLY */
|
||||
AFC_FOPEN_RW = 0x00000002, /**< r+ O_RDWR | O_CREAT */
|
||||
AFC_FOPEN_WRONLY = 0x00000003, /**< w O_WRONLY | O_CREAT | O_TRUNC */
|
||||
AFC_FOPEN_WR = 0x00000004, /**< w+ O_RDWR | O_CREAT | O_TRUNC */
|
||||
AFC_FOPEN_APPEND = 0x00000005, /**< a O_WRONLY | O_APPEND | O_CREAT */
|
||||
AFC_FOPEN_RDAPPEND = 0x00000006 /**< a+ O_RDWR | O_APPEND | O_CREAT */
|
||||
} afc_file_mode_t;
|
||||
|
||||
/** Type of link for afc_make_link() calls */
|
||||
typedef enum {
|
||||
AFC_HARDLINK = 1,
|
||||
AFC_SYMLINK = 2
|
||||
} afc_link_type_t;
|
||||
|
||||
/** Lock operation flags */
|
||||
typedef enum {
|
||||
AFC_LOCK_SH = 1 | 4, /**< shared lock */
|
||||
AFC_LOCK_EX = 2 | 4, /**< exclusive lock */
|
||||
AFC_LOCK_UN = 8 | 4 /**< unlock */
|
||||
} afc_lock_op_t;
|
||||
|
||||
typedef struct afc_client_private afc_client_private;
|
||||
typedef afc_client_private *afc_client_t; /**< The client handle. */
|
||||
|
||||
/* Interface */
|
||||
|
||||
/**
|
||||
* Makes a connection to the AFC service on the device.
|
||||
*
|
||||
* @param device The device to connect to.
|
||||
* @param service The service descriptor returned by lockdownd_start_service.
|
||||
* @param client Pointer that will be set to a newly allocated afc_client_t
|
||||
* upon successful return.
|
||||
*
|
||||
* @return AFC_E_SUCCESS on success, AFC_E_INVALID_ARG if device or service is
|
||||
* invalid, AFC_E_MUX_ERROR if the connection cannot be established,
|
||||
* or AFC_E_NO_MEM if there is a memory allocation problem.
|
||||
*/
|
||||
afc_error_t afc_client_new(idevice_t device, lockdownd_service_descriptor_t service, afc_client_t *client);
|
||||
|
||||
/**
|
||||
* Starts a new AFC service on the specified device and connects to it.
|
||||
*
|
||||
* @param device The device to connect to.
|
||||
* @param client Pointer that will point to a newly allocated afc_client_t upon
|
||||
* successful return. Must be freed using afc_client_free() after use.
|
||||
* @param label The label to use for communication. Usually the program name.
|
||||
* Pass NULL to disable sending the label in requests to lockdownd.
|
||||
*
|
||||
* @return AFC_E_SUCCESS on success, or an AFC_E_* error code otherwise.
|
||||
*/
|
||||
afc_error_t afc_client_start_service(idevice_t device, afc_client_t* client, const char* label);
|
||||
|
||||
/**
|
||||
* Frees up an AFC client. If the connection was created by the client itself,
|
||||
* the connection will be closed.
|
||||
*
|
||||
* @param client The client to free.
|
||||
*/
|
||||
afc_error_t afc_client_free(afc_client_t client);
|
||||
|
||||
/**
|
||||
* Get device information for a connected client. The device information
|
||||
* returned is the device model as well as the free space, the total capacity
|
||||
* and blocksize on the accessed disk partition.
|
||||
*
|
||||
* @param client The client to get device info for.
|
||||
* @param device_information A char list of device information terminated by an
|
||||
* empty string or NULL if there was an error. Free with
|
||||
* afc_dictionary_free().
|
||||
*
|
||||
* @return AFC_E_SUCCESS on success or an AFC_E_* error value.
|
||||
*/
|
||||
afc_error_t afc_get_device_info(afc_client_t client, char ***device_information);
|
||||
|
||||
/**
|
||||
* Gets a directory listing of the directory requested.
|
||||
*
|
||||
* @param client The client to get a directory listing from.
|
||||
* @param path The directory for listing. (must be a fully-qualified path)
|
||||
* @param directory_information A char list of files in the directory
|
||||
* terminated by an empty string or NULL if there was an error. Free with
|
||||
* afc_dictionary_free().
|
||||
*
|
||||
* @return AFC_E_SUCCESS on success or an AFC_E_* error value.
|
||||
*/
|
||||
afc_error_t afc_read_directory(afc_client_t client, const char *path, char ***directory_information);
|
||||
|
||||
/**
|
||||
* Gets information about a specific file.
|
||||
*
|
||||
* @param client The client to use to get the information of the file.
|
||||
* @param path The fully-qualified path to the file.
|
||||
* @param file_information Pointer to a buffer that will be filled with a
|
||||
* NULL-terminated list of strings with the file information. Set to NULL
|
||||
* before calling this function. Free with afc_dictionary_free().
|
||||
*
|
||||
* @return AFC_E_SUCCESS on success or an AFC_E_* error value.
|
||||
*/
|
||||
afc_error_t afc_get_file_info(afc_client_t client, const char *filename, char ***file_information);
|
||||
|
||||
/**
|
||||
* Opens a file on the device.
|
||||
*
|
||||
* @param client The client to use to open the file.
|
||||
* @param filename The file to open. (must be a fully-qualified path)
|
||||
* @param file_mode The mode to use to open the file.
|
||||
* @param handle Pointer to a uint64_t that will hold the handle of the file
|
||||
*
|
||||
* @return AFC_E_SUCCESS on success or an AFC_E_* error value.
|
||||
*/
|
||||
afc_error_t afc_file_open(afc_client_t client, const char *filename, afc_file_mode_t file_mode, uint64_t *handle);
|
||||
|
||||
/**
|
||||
* Closes a file on the device.
|
||||
*
|
||||
* @param client The client to close the file with.
|
||||
* @param handle File handle of a previously opened file.
|
||||
*/
|
||||
afc_error_t afc_file_close(afc_client_t client, uint64_t handle);
|
||||
|
||||
/**
|
||||
* Locks or unlocks a file on the device.
|
||||
*
|
||||
* Makes use of flock on the device.
|
||||
* @see http://developer.apple.com/documentation/Darwin/Reference/ManPages/man2/flock.2.html
|
||||
*
|
||||
* @param client The client to lock the file with.
|
||||
* @param handle File handle of a previously opened file.
|
||||
* @param operation the lock or unlock operation to perform, this is one of
|
||||
* AFC_LOCK_SH (shared lock), AFC_LOCK_EX (exclusive lock), or
|
||||
* AFC_LOCK_UN (unlock).
|
||||
*/
|
||||
afc_error_t afc_file_lock(afc_client_t client, uint64_t handle, afc_lock_op_t operation);
|
||||
|
||||
/**
|
||||
* Attempts to the read the given number of bytes from the given file.
|
||||
*
|
||||
* @param client The relevant AFC client
|
||||
* @param handle File handle of a previously opened file
|
||||
* @param data The pointer to the memory region to store the read data
|
||||
* @param length The number of bytes to read
|
||||
* @param bytes_read The number of bytes actually read.
|
||||
*
|
||||
* @return AFC_E_SUCCESS on success or an AFC_E_* error value.
|
||||
*/
|
||||
afc_error_t afc_file_read(afc_client_t client, uint64_t handle, char *data, uint32_t length, uint32_t *bytes_read);
|
||||
|
||||
/**
|
||||
* Writes a given number of bytes to a file.
|
||||
*
|
||||
* @param client The client to use to write to the file.
|
||||
* @param handle File handle of previously opened file.
|
||||
* @param data The data to write to the file.
|
||||
* @param length How much data to write.
|
||||
* @param bytes_written The number of bytes actually written to the file.
|
||||
*
|
||||
* @return AFC_E_SUCCESS on success or an AFC_E_* error value.
|
||||
*/
|
||||
afc_error_t afc_file_write(afc_client_t client, uint64_t handle, const char *data, uint32_t length, uint32_t *bytes_written);
|
||||
|
||||
/**
|
||||
* Seeks to a given position of a pre-opened file on the device.
|
||||
*
|
||||
* @param client The client to use to seek to the position.
|
||||
* @param handle File handle of a previously opened.
|
||||
* @param offset Seek offset.
|
||||
* @param whence Seeking direction, one of SEEK_SET, SEEK_CUR, or SEEK_END.
|
||||
*
|
||||
* @return AFC_E_SUCCESS on success or an AFC_E_* error value.
|
||||
*/
|
||||
afc_error_t afc_file_seek(afc_client_t client, uint64_t handle, int64_t offset, int whence);
|
||||
|
||||
/**
|
||||
* Returns current position in a pre-opened file on the device.
|
||||
*
|
||||
* @param client The client to use.
|
||||
* @param handle File handle of a previously opened file.
|
||||
* @param position Position in bytes of indicator
|
||||
*
|
||||
* @return AFC_E_SUCCESS on success or an AFC_E_* error value.
|
||||
*/
|
||||
afc_error_t afc_file_tell(afc_client_t client, uint64_t handle, uint64_t *position);
|
||||
|
||||
/**
|
||||
* Sets the size of a file on the device.
|
||||
*
|
||||
* @param client The client to use to set the file size.
|
||||
* @param handle File handle of a previously opened file.
|
||||
* @param newsize The size to set the file to.
|
||||
*
|
||||
* @return AFC_E_SUCCESS on success or an AFC_E_* error value.
|
||||
*
|
||||
* @note This function is more akin to ftruncate than truncate, and truncate
|
||||
* calls would have to open the file before calling this, sadly.
|
||||
*/
|
||||
afc_error_t afc_file_truncate(afc_client_t client, uint64_t handle, uint64_t newsize);
|
||||
|
||||
/**
|
||||
* Deletes a file or directory.
|
||||
*
|
||||
* @param client The client to use.
|
||||
* @param path The path to delete. (must be a fully-qualified path)
|
||||
*
|
||||
* @return AFC_E_SUCCESS on success or an AFC_E_* error value.
|
||||
*/
|
||||
afc_error_t afc_remove_path(afc_client_t client, const char *path);
|
||||
|
||||
/**
|
||||
* Renames a file or directory on the device.
|
||||
*
|
||||
* @param client The client to have rename.
|
||||
* @param from The name to rename from. (must be a fully-qualified path)
|
||||
* @param to The new name. (must also be a fully-qualified path)
|
||||
*
|
||||
* @return AFC_E_SUCCESS on success or an AFC_E_* error value.
|
||||
*/
|
||||
afc_error_t afc_rename_path(afc_client_t client, const char *from, const char *to);
|
||||
|
||||
/**
|
||||
* Creates a directory on the device.
|
||||
*
|
||||
* @param client The client to use to make a directory.
|
||||
* @param path The directory's path. (must be a fully-qualified path, I assume
|
||||
* all other mkdir restrictions apply as well)
|
||||
*
|
||||
* @return AFC_E_SUCCESS on success or an AFC_E_* error value.
|
||||
*/
|
||||
afc_error_t afc_make_directory(afc_client_t client, const char *path);
|
||||
|
||||
/**
|
||||
* Sets the size of a file on the device without prior opening it.
|
||||
*
|
||||
* @param client The client to use to set the file size.
|
||||
* @param path The path of the file to be truncated.
|
||||
* @param newsize The size to set the file to.
|
||||
*
|
||||
* @return AFC_E_SUCCESS on success or an AFC_E_* error value.
|
||||
*/
|
||||
afc_error_t afc_truncate(afc_client_t client, const char *path, uint64_t newsize);
|
||||
|
||||
/**
|
||||
* Creates a hard link or symbolic link on the device.
|
||||
*
|
||||
* @param client The client to use for making a link
|
||||
* @param linktype 1 = hard link, 2 = symlink
|
||||
* @param target The file to be linked.
|
||||
* @param linkname The name of link.
|
||||
*
|
||||
* @return AFC_E_SUCCESS on success or an AFC_E_* error value.
|
||||
*/
|
||||
afc_error_t afc_make_link(afc_client_t client, afc_link_type_t linktype, const char *target, const char *linkname);
|
||||
|
||||
/**
|
||||
* Sets the modification time of a file on the device.
|
||||
*
|
||||
* @param client The client to use to set the file size.
|
||||
* @param path Path of the file for which the modification time should be set.
|
||||
* @param mtime The modification time to set in nanoseconds since epoch.
|
||||
*
|
||||
* @return AFC_E_SUCCESS on success or an AFC_E_* error value.
|
||||
*/
|
||||
afc_error_t afc_set_file_time(afc_client_t client, const char *path, uint64_t mtime);
|
||||
|
||||
/**
|
||||
* Deletes a file or directory including possible contents.
|
||||
*
|
||||
* @param client The client to use.
|
||||
* @param path The path to delete. (must be a fully-qualified path)
|
||||
* @since libimobiledevice 1.1.7
|
||||
* @note Only available in iOS 6 and later.
|
||||
*
|
||||
* @return AFC_E_SUCCESS on success or an AFC_E_* error value.
|
||||
*/
|
||||
afc_error_t afc_remove_path_and_contents(afc_client_t client, const char *path);
|
||||
|
||||
/* Helper functions */
|
||||
|
||||
/**
|
||||
* Get a specific key of the device info list for a client connection.
|
||||
* Known key values are: Model, FSTotalBytes, FSFreeBytes and FSBlockSize.
|
||||
* This is a helper function for afc_get_device_info().
|
||||
*
|
||||
* @param client The client to get device info for.
|
||||
* @param key The key to get the value of.
|
||||
* @param value The value for the key if successful or NULL otherwise.
|
||||
*
|
||||
* @return AFC_E_SUCCESS on success or an AFC_E_* error value.
|
||||
*/
|
||||
afc_error_t afc_get_device_info_key(afc_client_t client, const char *key, char **value);
|
||||
|
||||
/**
|
||||
* Frees up a char dictionary as returned by some AFC functions.
|
||||
*
|
||||
* @param dictionary The char array terminated by an empty string.
|
||||
*
|
||||
* @return AFC_E_SUCCESS on success or an AFC_E_* error value.
|
||||
*/
|
||||
afc_error_t afc_dictionary_free(char **dictionary);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,246 @@
|
|||
/**
|
||||
* @file libimobiledevice/debugserver.h
|
||||
* @brief Communicate with debugserver on the device.
|
||||
* \internal
|
||||
*
|
||||
* Copyright (c) 2014 Martin Szulecki All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef IDEBUGSERVER_H
|
||||
#define IDEBUGSERVER_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <libimobiledevice/libimobiledevice.h>
|
||||
#include <libimobiledevice/lockdown.h>
|
||||
|
||||
#define DEBUGSERVER_SERVICE_NAME "com.apple.debugserver"
|
||||
|
||||
/** Error Codes */
|
||||
typedef enum {
|
||||
DEBUGSERVER_E_SUCCESS = 0,
|
||||
DEBUGSERVER_E_INVALID_ARG = -1,
|
||||
DEBUGSERVER_E_MUX_ERROR = -2,
|
||||
DEBUGSERVER_E_SSL_ERROR = -3,
|
||||
DEBUGSERVER_E_RESPONSE_ERROR = -4,
|
||||
DEBUGSERVER_E_UNKNOWN_ERROR = -256
|
||||
} debugserver_error_t;
|
||||
|
||||
typedef struct debugserver_client_private debugserver_client_private;
|
||||
typedef debugserver_client_private *debugserver_client_t; /**< The client handle. */
|
||||
|
||||
typedef struct debugserver_command_private debugserver_command_private;
|
||||
typedef debugserver_command_private *debugserver_command_t; /**< The command handle. */
|
||||
|
||||
/* Interface */
|
||||
|
||||
/**
|
||||
* Connects to the debugserver service on the specified device.
|
||||
*
|
||||
* @param device The device to connect to.
|
||||
* @param service The service descriptor returned by lockdownd_start_service.
|
||||
* @param client Pointer that will point to a newly allocated
|
||||
* debugserver_client_t upon successful return. Must be freed using
|
||||
* debugserver_client_free() after use.
|
||||
*
|
||||
* @return DEBUGSERVER_E_SUCCESS on success, DEBUGSERVER_E_INVALID_ARG when
|
||||
* client is NULL, or an DEBUGSERVER_E_* error code otherwise.
|
||||
*/
|
||||
debugserver_error_t debugserver_client_new(idevice_t device, lockdownd_service_descriptor_t service, debugserver_client_t * client);
|
||||
|
||||
/**
|
||||
* Starts a new debugserver service on the specified device and connects to it.
|
||||
*
|
||||
* @param device The device to connect to.
|
||||
* @param client Pointer that will point to a newly allocated
|
||||
* debugserver_client_t upon successful return. Must be freed using
|
||||
* debugserver_client_free() after use.
|
||||
* @param label The label to use for communication. Usually the program name.
|
||||
* Pass NULL to disable sending the label in requests to lockdownd.
|
||||
*
|
||||
* @return DEBUGSERVER_E_SUCCESS on success, or an DEBUGSERVER_E_* error
|
||||
* code otherwise.
|
||||
*/
|
||||
debugserver_error_t debugserver_client_start_service(idevice_t device, debugserver_client_t * client, const char* label);
|
||||
|
||||
/**
|
||||
* Disconnects a debugserver client from the device and frees up the
|
||||
* debugserver client data.
|
||||
*
|
||||
* @param client The debugserver client to disconnect and free.
|
||||
*
|
||||
* @return DEBUGSERVER_E_SUCCESS on success, DEBUGSERVER_E_INVALID_ARG when
|
||||
* client is NULL, or an DEBUGSERVER_E_* error code otherwise.
|
||||
*/
|
||||
debugserver_error_t debugserver_client_free(debugserver_client_t client);
|
||||
|
||||
/**
|
||||
* Sends raw data using the given debugserver service client.
|
||||
*
|
||||
* @param client The debugserver client to use for sending
|
||||
* @param data Data to send
|
||||
* @param size Size of the data to send
|
||||
* @param sent Number of bytes sent (can be NULL to ignore)
|
||||
*
|
||||
* @return DEBUGSERVER_E_SUCCESS on success,
|
||||
* DEBUGSERVER_E_INVALID_ARG when one or more parameters are
|
||||
* invalid, or DEBUGSERVER_E_UNKNOWN_ERROR when an unspecified
|
||||
* error occurs.
|
||||
*/
|
||||
debugserver_error_t debugserver_client_send(debugserver_client_t client, const char* data, uint32_t size, uint32_t *sent);
|
||||
|
||||
/**
|
||||
* Receives raw data using the given debugserver client with specified timeout.
|
||||
*
|
||||
* @param client The debugserver client to use for receiving
|
||||
* @param data Buffer that will be filled with the data received
|
||||
* @param size Number of bytes to receive
|
||||
* @param received Number of bytes received (can be NULL to ignore)
|
||||
* @param timeout Maximum time in milliseconds to wait for data.
|
||||
*
|
||||
* @return DEBUGSERVER_E_SUCCESS on success,
|
||||
* DEBUGSERVER_E_INVALID_ARG when one or more parameters are
|
||||
* invalid, DEBUGSERVER_E_MUX_ERROR when a communication error
|
||||
* occurs, or DEBUGSERVER_E_UNKNOWN_ERROR when an unspecified
|
||||
* error occurs.
|
||||
*/
|
||||
debugserver_error_t debugserver_client_receive_with_timeout(debugserver_client_t client, char *data, uint32_t size, uint32_t *received, unsigned int timeout);
|
||||
|
||||
/**
|
||||
* Receives raw data from the debugserver service.
|
||||
*
|
||||
* @param client The debugserver client
|
||||
* @param data Buffer that will be filled with the data received
|
||||
* @param size Number of bytes to receive
|
||||
* @param received Number of bytes received (can be NULL to ignore)
|
||||
* @note The default read timeout is 10 seconds.
|
||||
*
|
||||
* @return DEBUGSERVER_E_SUCCESS on success,
|
||||
* DEBUGSERVER_E_INVALID_ARG when client or plist is NULL
|
||||
*/
|
||||
debugserver_error_t debugserver_client_receive(debugserver_client_t client, char *data, uint32_t size, uint32_t *received);
|
||||
|
||||
/**
|
||||
* Sends a command to the debugserver service.
|
||||
*
|
||||
* @param client The debugserver client
|
||||
* @param command Command to process and send
|
||||
* @param response Response received for the command (can be NULL to ignore)
|
||||
*
|
||||
* @return DEBUGSERVER_E_SUCCESS on success,
|
||||
* DEBUGSERVER_E_INVALID_ARG when client or command is NULL
|
||||
*/
|
||||
debugserver_error_t debugserver_client_send_command(debugserver_client_t client, debugserver_command_t command, char** response);
|
||||
|
||||
/**
|
||||
* Receives and parses response of debugserver service.
|
||||
*
|
||||
* @param client The debugserver client
|
||||
* @param response Response received for last command (can be NULL to ignore)
|
||||
*
|
||||
* @return DEBUGSERVER_E_SUCCESS on success,
|
||||
* DEBUGSERVER_E_INVALID_ARG when client is NULL
|
||||
*/
|
||||
debugserver_error_t debugserver_client_receive_response(debugserver_client_t client, char** response);
|
||||
|
||||
/**
|
||||
* Controls status of ACK mode when sending commands or receiving responses.
|
||||
*
|
||||
* @see debugserver_client_send_command, debugserver_client_receive_response
|
||||
*
|
||||
* @param client The debugserver client
|
||||
* @param enabled A boolean flag indicating whether the internal ACK mode
|
||||
* handling should be enabled or disabled.
|
||||
*
|
||||
* @return DEBUGSERVER_E_SUCCESS on success, or an DEBUGSERVER_E_* error
|
||||
* code otherwise.
|
||||
*/
|
||||
debugserver_error_t debugserver_client_set_ack_mode(debugserver_client_t client, int enabled);
|
||||
|
||||
/**
|
||||
* Sets the argv which launches an app.
|
||||
*
|
||||
* @param client The debugserver client
|
||||
* @param argc Number of arguments
|
||||
* @param argv Array starting with the executable to be run followed by it's arguments
|
||||
* @param response Response received for the command (can be NULL to ignore)
|
||||
*
|
||||
* @return DEBUGSERVER_E_SUCCESS on success,
|
||||
* DEBUGSERVER_E_INVALID_ARG when client is NULL
|
||||
*/
|
||||
debugserver_error_t debugserver_client_set_argv(debugserver_client_t client, int argc, char* argv[], char** response);
|
||||
|
||||
/**
|
||||
* Adds or sets an environment variable.
|
||||
*
|
||||
* @param client The debugserver client
|
||||
* @param env The environment variable in "KEY=VALUE" notation
|
||||
* @param response Response received for the command (can be NULL to ignore)
|
||||
*
|
||||
* @return DEBUGSERVER_E_SUCCESS on success,
|
||||
* DEBUGSERVER_E_INVALID_ARG when client is NULL
|
||||
*/
|
||||
debugserver_error_t debugserver_client_set_environment_hex_encoded(debugserver_client_t client, const char* env, char** response);
|
||||
|
||||
/**
|
||||
* Creates and initializes a new command object.
|
||||
*
|
||||
* @param name The name of the command which is sent in plain text
|
||||
* @param argv Array of tokens for the command ment to be encoded
|
||||
* @param argc Number of items in the token array
|
||||
* @param command New command object
|
||||
*
|
||||
* @return DEBUGSERVER_E_SUCCESS on success,
|
||||
* DEBUGSERVER_E_INVALID_ARG when name or command is NULL
|
||||
*/
|
||||
debugserver_error_t debugserver_command_new(const char* name, int argc, char* argv[], debugserver_command_t* command);
|
||||
|
||||
/**
|
||||
* Frees memory of command object.
|
||||
*
|
||||
* @param command The command object
|
||||
*
|
||||
* @return DEBUGSERVER_E_SUCCESS on success,
|
||||
* DEBUGSERVER_E_INVALID_ARG when command is NULL
|
||||
*/
|
||||
debugserver_error_t debugserver_command_free(debugserver_command_t command);
|
||||
|
||||
/**
|
||||
* Encodes a string into hex notation.
|
||||
*
|
||||
* @param buffer String to encode into hex notiation
|
||||
* @param encoded_buffer The buffer receives a hex encoded string
|
||||
* @param encoded_length Length of the hex encoded string
|
||||
*/
|
||||
void debugserver_encode_string(const char* buffer, char** encoded_buffer, uint32_t* encoded_length);
|
||||
|
||||
/**
|
||||
* Decodes a hex encoded string.
|
||||
*
|
||||
* @param encoded_buffer The buffer with a hex encoded string
|
||||
* @param encoded_length Length of the encoded buffer
|
||||
* @param buffer Decoded string to be freed by the caller
|
||||
*/
|
||||
void debugserver_decode_string(const char *encoded_buffer, size_t encoded_length, char** buffer);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,185 @@
|
|||
/**
|
||||
* @file libimobiledevice/diagnostics_relay.h
|
||||
* @brief Request iOS diagnostic information from device.
|
||||
* \internal
|
||||
*
|
||||
* Copyright (c) 2012-2014 Martin Szulecki, All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef IDIAGNOSTICS_RELAY_H
|
||||
#define IDIAGNOSTICS_RELAY_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <libimobiledevice/libimobiledevice.h>
|
||||
#include <libimobiledevice/lockdown.h>
|
||||
|
||||
#define DIAGNOSTICS_RELAY_SERVICE_NAME "com.apple.mobile.diagnostics_relay"
|
||||
|
||||
/** Error Codes */
|
||||
typedef enum {
|
||||
DIAGNOSTICS_RELAY_E_SUCCESS = 0,
|
||||
DIAGNOSTICS_RELAY_E_INVALID_ARG = -1,
|
||||
DIAGNOSTICS_RELAY_E_PLIST_ERROR = -2,
|
||||
DIAGNOSTICS_RELAY_E_MUX_ERROR = -3,
|
||||
DIAGNOSTICS_RELAY_E_UNKNOWN_REQUEST = -4,
|
||||
DIAGNOSTICS_RELAY_E_UNKNOWN_ERROR = -256
|
||||
} diagnostics_relay_error_t;
|
||||
|
||||
#define DIAGNOSTICS_RELAY_ACTION_FLAG_WAIT_FOR_DISCONNECT (1 << 1)
|
||||
#define DIAGNOSTICS_RELAY_ACTION_FLAG_DISPLAY_PASS (1 << 2)
|
||||
#define DIAGNOSTICS_RELAY_ACTION_FLAG_DISPLAY_FAIL (1 << 3)
|
||||
|
||||
#define DIAGNOSTICS_RELAY_REQUEST_TYPE_ALL "All"
|
||||
#define DIAGNOSTICS_RELAY_REQUEST_TYPE_WIFI "WiFi"
|
||||
#define DIAGNOSTICS_RELAY_REQUEST_TYPE_GAS_GAUGE "GasGauge"
|
||||
#define DIAGNOSTICS_RELAY_REQUEST_TYPE_NAND "NAND"
|
||||
|
||||
typedef struct diagnostics_relay_client_private diagnostics_relay_client_private;
|
||||
typedef diagnostics_relay_client_private *diagnostics_relay_client_t; /**< The client handle. */
|
||||
|
||||
/**
|
||||
* Connects to the diagnostics_relay service on the specified device.
|
||||
*
|
||||
* @param device The device to connect to.
|
||||
* @param service The service descriptor returned by lockdownd_start_service.
|
||||
* @param client Reference that will point to a newly allocated
|
||||
* diagnostics_relay_client_t upon successful return.
|
||||
*
|
||||
* @return DIAGNOSTICS_RELAY_E_SUCCESS on success,
|
||||
* DIAGNOSTICS_RELAY_E_INVALID_ARG when one of the parameters is invalid,
|
||||
* or DIAGNOSTICS_RELAY_E_MUX_ERROR when the connection failed.
|
||||
*/
|
||||
diagnostics_relay_error_t diagnostics_relay_client_new(idevice_t device, lockdownd_service_descriptor_t service, diagnostics_relay_client_t *client);
|
||||
|
||||
/**
|
||||
* Starts a new diagnostics_relay service on the specified device and connects to it.
|
||||
*
|
||||
* @param device The device to connect to.
|
||||
* @param client Pointer that will point to a newly allocated
|
||||
* diagnostics_relay_client_t upon successful return. Must be freed using
|
||||
* diagnostics_relay_client_free() after use.
|
||||
* @param label The label to use for communication. Usually the program name.
|
||||
* Pass NULL to disable sending the label in requests to lockdownd.
|
||||
*
|
||||
* @return DIAGNOSTICS_RELAY_E_SUCCESS on success, or an DIAGNOSTICS_RELAY_E_* error
|
||||
* code otherwise.
|
||||
*/
|
||||
diagnostics_relay_error_t diagnostics_relay_client_start_service(idevice_t device, diagnostics_relay_client_t* client, const char* label);
|
||||
|
||||
/**
|
||||
* Disconnects a diagnostics_relay client from the device and frees up the
|
||||
* diagnostics_relay client data.
|
||||
*
|
||||
* @param client The diagnostics_relay client to disconnect and free.
|
||||
*
|
||||
* @return DIAGNOSTICS_RELAY_E_SUCCESS on success,
|
||||
* DIAGNOSTICS_RELAY_E_INVALID_ARG when one of client or client->parent
|
||||
* is invalid, or DIAGNOSTICS_RELAY_E_UNKNOWN_ERROR when the was an
|
||||
* error freeing the parent property_list_service client.
|
||||
*/
|
||||
diagnostics_relay_error_t diagnostics_relay_client_free(diagnostics_relay_client_t client);
|
||||
|
||||
|
||||
/**
|
||||
* Sends the Goodbye request signaling the end of communication.
|
||||
*
|
||||
* @param client The diagnostics_relay client
|
||||
*
|
||||
* @return DIAGNOSTICS_RELAY_E_SUCCESS on success,
|
||||
* DIAGNOSTICS_RELAY_E_INVALID_ARG when client is NULL,
|
||||
* DIAGNOSTICS_RELAY_E_PLIST_ERROR if the device did not acknowledge the
|
||||
* request
|
||||
*/
|
||||
diagnostics_relay_error_t diagnostics_relay_goodbye(diagnostics_relay_client_t client);
|
||||
|
||||
/**
|
||||
* Puts the device into deep sleep mode and disconnects from host.
|
||||
*
|
||||
* @param client The diagnostics_relay client
|
||||
*
|
||||
* @return DIAGNOSTICS_RELAY_E_SUCCESS on success,
|
||||
* DIAGNOSTICS_RELAY_E_INVALID_ARG when client is NULL,
|
||||
* DIAGNOSTICS_RELAY_E_PLIST_ERROR if the device did not acknowledge the
|
||||
* request
|
||||
*/
|
||||
diagnostics_relay_error_t diagnostics_relay_sleep(diagnostics_relay_client_t client);
|
||||
|
||||
/**
|
||||
* Restart the device and optionally show a user notification.
|
||||
*
|
||||
* @param client The diagnostics_relay client
|
||||
* @param flags A binary flag combination of
|
||||
* DIAGNOSTICS_RELAY_ACTION_FLAG_WAIT_FOR_DISCONNECT to wait until
|
||||
* diagnostics_relay_client_free() disconnects before execution and
|
||||
* DIAGNOSTICS_RELAY_ACTION_FLAG_DISPLAY_FAIL to show a "FAIL" dialog
|
||||
* or DIAGNOSTICS_RELAY_ACTION_FLAG_DISPLAY_PASS to show an "OK" dialog
|
||||
*
|
||||
* @return DIAGNOSTICS_RELAY_E_SUCCESS on success,
|
||||
* DIAGNOSTICS_RELAY_E_INVALID_ARG when client is NULL,
|
||||
* DIAGNOSTICS_RELAY_E_PLIST_ERROR if the device did not acknowledge the
|
||||
* request
|
||||
*/
|
||||
diagnostics_relay_error_t diagnostics_relay_restart(diagnostics_relay_client_t client, int flags);
|
||||
|
||||
/**
|
||||
* Shutdown of the device and optionally show a user notification.
|
||||
*
|
||||
* @param client The diagnostics_relay client
|
||||
* @param flags A binary flag combination of
|
||||
* DIAGNOSTICS_RELAY_ACTION_FLAG_WAIT_FOR_DISCONNECT to wait until
|
||||
* diagnostics_relay_client_free() disconnects before execution and
|
||||
* DIAGNOSTICS_RELAY_ACTION_FLAG_DISPLAY_FAIL to show a "FAIL" dialog
|
||||
* or DIAGNOSTICS_RELAY_ACTION_FLAG_DISPLAY_PASS to show an "OK" dialog
|
||||
*
|
||||
* @return DIAGNOSTICS_RELAY_E_SUCCESS on success,
|
||||
* DIAGNOSTICS_RELAY_E_INVALID_ARG when client is NULL,
|
||||
* DIAGNOSTICS_RELAY_E_PLIST_ERROR if the device did not acknowledge the
|
||||
* request
|
||||
*/
|
||||
diagnostics_relay_error_t diagnostics_relay_shutdown(diagnostics_relay_client_t client, int flags);
|
||||
|
||||
/**
|
||||
* Shutdown of the device and optionally show a user notification.
|
||||
*
|
||||
* @param client The diagnostics_relay client
|
||||
* @param flags A binary flag combination of
|
||||
* DIAGNOSTICS_RELAY_ACTION_FLAG_WAIT_FOR_DISCONNECT to wait until
|
||||
* diagnostics_relay_client_free() disconnects before execution and
|
||||
* DIAGNOSTICS_RELAY_ACTION_FLAG_DISPLAY_FAIL to show a "FAIL" dialog
|
||||
* or DIAGNOSTICS_RELAY_ACTION_FLAG_DISPLAY_PASS to show an "OK" dialog
|
||||
*
|
||||
* @return DIAGNOSTICS_RELAY_E_SUCCESS on success,
|
||||
* DIAGNOSTICS_RELAY_E_INVALID_ARG when client is NULL,
|
||||
* DIAGNOSTICS_RELAY_E_PLIST_ERROR if the device did not acknowledge the
|
||||
* request
|
||||
*/
|
||||
diagnostics_relay_error_t diagnostics_relay_request_diagnostics(diagnostics_relay_client_t client, const char* type, plist_t* diagnostics);
|
||||
|
||||
diagnostics_relay_error_t diagnostics_relay_query_mobilegestalt(diagnostics_relay_client_t client, plist_t keys, plist_t* result);
|
||||
|
||||
diagnostics_relay_error_t diagnostics_relay_query_ioregistry_entry(diagnostics_relay_client_t client, const char* name, const char* class, plist_t* result);
|
||||
|
||||
diagnostics_relay_error_t diagnostics_relay_query_ioregistry_plane(diagnostics_relay_client_t client, const char* plane, plist_t* result);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,165 @@
|
|||
/**
|
||||
* @file libimobiledevice/file_relay.h
|
||||
* @brief Retrieve compressed CPIO archives.
|
||||
* \internal
|
||||
*
|
||||
* Copyright (c) 2010-2014 Martin Szulecki All Rights Reserved.
|
||||
* Copyright (c) 2014 Aaron Burghardt All Rights Reserved.
|
||||
* Copyright (c) 2010 Nikias Bassen All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef IFILE_RELAY_H
|
||||
#define IFILE_RELAY_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <libimobiledevice/libimobiledevice.h>
|
||||
#include <libimobiledevice/lockdown.h>
|
||||
|
||||
#define FILE_RELAY_SERVICE_NAME "com.apple.mobile.file_relay"
|
||||
|
||||
/** Error Codes */
|
||||
typedef enum {
|
||||
FILE_RELAY_E_SUCCESS = 0,
|
||||
FILE_RELAY_E_INVALID_ARG = -1,
|
||||
FILE_RELAY_E_PLIST_ERROR = -2,
|
||||
FILE_RELAY_E_MUX_ERROR = -3,
|
||||
FILE_RELAY_E_INVALID_SOURCE = -4,
|
||||
FILE_RELAY_E_STAGING_EMPTY = -5,
|
||||
FILE_RELAY_E_PERMISSION_DENIED = -6,
|
||||
FILE_RELAY_E_UNKNOWN_ERROR = -256
|
||||
} file_relay_error_t;
|
||||
|
||||
typedef struct file_relay_client_private file_relay_client_private;
|
||||
typedef file_relay_client_private *file_relay_client_t; /**< The client handle. */
|
||||
|
||||
/**
|
||||
* Connects to the file_relay service on the specified device.
|
||||
*
|
||||
* @param device The device to connect to.
|
||||
* @param service The service descriptor returned by lockdownd_start_service.
|
||||
* @param client Reference that will point to a newly allocated
|
||||
* file_relay_client_t upon successful return.
|
||||
*
|
||||
* @return FILE_RELAY_E_SUCCESS on success,
|
||||
* FILE_RELAY_E_INVALID_ARG when one of the parameters is invalid,
|
||||
* or FILE_RELAY_E_MUX_ERROR when the connection failed.
|
||||
*/
|
||||
file_relay_error_t file_relay_client_new(idevice_t device, lockdownd_service_descriptor_t service, file_relay_client_t *client);
|
||||
|
||||
/**
|
||||
* Starts a new file_relay service on the specified device and connects to it.
|
||||
*
|
||||
* @param device The device to connect to.
|
||||
* @param client Pointer that will point to a newly allocated
|
||||
* file_relay_client_t upon successful return. Must be freed using
|
||||
* file_relay_client_free() after use.
|
||||
* @param label The label to use for communication. Usually the program name.
|
||||
* Pass NULL to disable sending the label in requests to lockdownd.
|
||||
*
|
||||
* @return FILE_RELAY_E_SUCCESS on success, or an FILE_RELAY_E_* error
|
||||
* code otherwise.
|
||||
*/
|
||||
file_relay_error_t file_relay_client_start_service(idevice_t device, file_relay_client_t* client, const char* label);
|
||||
|
||||
/**
|
||||
* Disconnects a file_relay client from the device and frees up the file_relay
|
||||
* client data.
|
||||
*
|
||||
* @param client The file_relay client to disconnect and free.
|
||||
*
|
||||
* @return FILE_RELAY_E_SUCCESS on success,
|
||||
* FILE_RELAY_E_INVALID_ARG when one of client or client->parent
|
||||
* is invalid, or FILE_RELAY_E_UNKNOWN_ERROR when the was an error
|
||||
* freeing the parent property_list_service client.
|
||||
*/
|
||||
file_relay_error_t file_relay_client_free(file_relay_client_t client);
|
||||
|
||||
|
||||
/**
|
||||
* Request data for the given sources.
|
||||
*
|
||||
* @param client The connected file_relay client.
|
||||
* @param sources A NULL-terminated list of sources to retrieve.
|
||||
* Valid sources are:
|
||||
* - AppleSupport
|
||||
* - Network
|
||||
* - VPN
|
||||
* - WiFi
|
||||
* - UserDatabases
|
||||
* - CrashReporter
|
||||
* - tmp
|
||||
* - SystemConfiguration
|
||||
* @param connection The connection that has to be used for receiving the
|
||||
* data using idevice_connection_receive(). The connection will be closed
|
||||
* automatically by the device, but use file_relay_client_free() to clean
|
||||
* up properly.
|
||||
* @param timeout Maximum time in milliseconds to wait for data.
|
||||
*
|
||||
* @note WARNING: Don't call this function without reading the data afterwards.
|
||||
* A directory mobile_file_relay.XXXX used for creating the archive will
|
||||
* remain in the /tmp directory otherwise.
|
||||
*
|
||||
* @return FILE_RELAY_E_SUCCESS on succes, FILE_RELAY_E_INVALID_ARG when one or
|
||||
* more parameters are invalid, FILE_RELAY_E_MUX_ERROR if a communication
|
||||
* error occurs, FILE_RELAY_E_PLIST_ERROR when the received result is NULL
|
||||
* or is not a valid plist, FILE_RELAY_E_INVALID_SOURCE if one or more
|
||||
* sources are invalid, FILE_RELAY_E_STAGING_EMPTY if no data is available
|
||||
* for the given sources, or FILE_RELAY_E_UNKNOWN_ERROR otherwise.
|
||||
*/
|
||||
file_relay_error_t file_relay_request_sources(file_relay_client_t client, const char **sources, idevice_connection_t *connection);
|
||||
|
||||
/**
|
||||
* Request data for the given sources. Calls file_relay_request_sources_timeout() with
|
||||
* a timeout of 60000 milliseconds (60 seconds).
|
||||
*
|
||||
* @param client The connected file_relay client.
|
||||
* @param sources A NULL-terminated list of sources to retrieve.
|
||||
* Valid sources are:
|
||||
* - AppleSupport
|
||||
* - Network
|
||||
* - VPN
|
||||
* - WiFi
|
||||
* - UserDatabases
|
||||
* - CrashReporter
|
||||
* - tmp
|
||||
* - SystemConfiguration
|
||||
* @param connection The connection that has to be used for receiving the
|
||||
* data using idevice_connection_receive(). The connection will be closed
|
||||
* automatically by the device, but use file_relay_client_free() to clean
|
||||
* up properly.
|
||||
*
|
||||
* @note WARNING: Don't call this function without reading the data afterwards.
|
||||
* A directory mobile_file_relay.XXXX used for creating the archive will
|
||||
* remain in the /tmp directory otherwise.
|
||||
*
|
||||
* @return FILE_RELAY_E_SUCCESS on succes, FILE_RELAY_E_INVALID_ARG when one or
|
||||
* more parameters are invalid, FILE_RELAY_E_MUX_ERROR if a communication
|
||||
* error occurs, FILE_RELAY_E_PLIST_ERROR when the received result is NULL
|
||||
* or is not a valid plist, FILE_RELAY_E_INVALID_SOURCE if one or more
|
||||
* sources are invalid, FILE_RELAY_E_STAGING_EMPTY if no data is available
|
||||
* for the given sources, or FILE_RELAY_E_UNKNOWN_ERROR otherwise.
|
||||
*/
|
||||
file_relay_error_t file_relay_request_sources_timeout(file_relay_client_t client, const char **sources, idevice_connection_t *connection, unsigned int timeout);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,132 @@
|
|||
/**
|
||||
* @file libimobiledevice/heartbeat.h
|
||||
* @brief Send "heartbeat" to device to allow service connections over network.
|
||||
* \internal
|
||||
*
|
||||
* Copyright (c) 2013-2014 Martin Szulecki All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef IHEARTBEAT_H
|
||||
#define IHEARTBEAT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <libimobiledevice/libimobiledevice.h>
|
||||
#include <libimobiledevice/lockdown.h>
|
||||
|
||||
#define HEARTBEAT_SERVICE_NAME "com.apple.mobile.heartbeat"
|
||||
|
||||
/** Error Codes */
|
||||
typedef enum {
|
||||
HEARTBEAT_E_SUCCESS = 0,
|
||||
HEARTBEAT_E_INVALID_ARG = -1,
|
||||
HEARTBEAT_E_PLIST_ERROR = -2,
|
||||
HEARTBEAT_E_MUX_ERROR = -3,
|
||||
HEARTBEAT_E_SSL_ERROR = -4,
|
||||
HEARTBEAT_E_UNKNOWN_ERROR = -256
|
||||
} heartbeat_error_t;
|
||||
|
||||
typedef struct heartbeat_client_private heartbeat_client_private;
|
||||
typedef heartbeat_client_private *heartbeat_client_t; /**< The client handle. */
|
||||
|
||||
/**
|
||||
* Connects to the heartbeat service on the specified device.
|
||||
*
|
||||
* @param device The device to connect to.
|
||||
* @param service The service descriptor returned by lockdownd_start_service.
|
||||
* @param client Pointer that will point to a newly allocated
|
||||
* heartbeat_client_t upon successful return. Must be freed using
|
||||
* heartbeat_client_free() after use.
|
||||
*
|
||||
* @return HEARTBEAT_E_SUCCESS on success, HEARTBEAT_E_INVALID_ARG when
|
||||
* client is NULL, or an HEARTBEAT_E_* error code otherwise.
|
||||
*/
|
||||
heartbeat_error_t heartbeat_client_new(idevice_t device, lockdownd_service_descriptor_t service, heartbeat_client_t * client);
|
||||
|
||||
/**
|
||||
* Starts a new heartbeat service on the specified device and connects to it.
|
||||
*
|
||||
* @param device The device to connect to.
|
||||
* @param client Pointer that will point to a newly allocated
|
||||
* heartbeat_client_t upon successful return. Must be freed using
|
||||
* heartbeat_client_free() after use.
|
||||
* @param label The label to use for communication. Usually the program name.
|
||||
* Pass NULL to disable sending the label in requests to lockdownd.
|
||||
*
|
||||
* @return HEARTBEAT_E_SUCCESS on success, or an HEARTBEAT_E_* error
|
||||
* code otherwise.
|
||||
*/
|
||||
heartbeat_error_t heartbeat_client_start_service(idevice_t device, heartbeat_client_t * client, const char* label);
|
||||
|
||||
/**
|
||||
* Disconnects a heartbeat client from the device and frees up the
|
||||
* heartbeat client data.
|
||||
*
|
||||
* @param client The heartbeat client to disconnect and free.
|
||||
*
|
||||
* @return HEARTBEAT_E_SUCCESS on success, HEARTBEAT_E_INVALID_ARG when
|
||||
* client is NULL, or an HEARTBEAT_E_* error code otherwise.
|
||||
*/
|
||||
heartbeat_error_t heartbeat_client_free(heartbeat_client_t client);
|
||||
|
||||
|
||||
/**
|
||||
* Sends a plist to the service.
|
||||
*
|
||||
* @param client The heartbeat client
|
||||
* @param plist The plist to send
|
||||
*
|
||||
* @return HEARTBEAT_E_SUCCESS on success,
|
||||
* HEARTBEAT_E_INVALID_ARG when client or plist is NULL
|
||||
*/
|
||||
heartbeat_error_t heartbeat_send(heartbeat_client_t client, plist_t plist);
|
||||
|
||||
/**
|
||||
* Receives a plist from the service.
|
||||
*
|
||||
* @param client The heartbeat client
|
||||
* @param plist The plist to store the received data
|
||||
*
|
||||
* @return HEARTBEAT_E_SUCCESS on success,
|
||||
* HEARTBEAT_E_INVALID_ARG when client or plist is NULL
|
||||
*/
|
||||
heartbeat_error_t heartbeat_receive(heartbeat_client_t client, plist_t * plist);
|
||||
|
||||
/**
|
||||
* Receives a plist using the given heartbeat client.
|
||||
*
|
||||
* @param client The heartbeat client to use for receiving
|
||||
* @param plist pointer to a plist_t that will point to the received plist
|
||||
* upon successful return
|
||||
* @param timeout Maximum time in milliseconds to wait for data.
|
||||
*
|
||||
* @return HEARTBEAT_E_SUCCESS on success,
|
||||
* HEARTBEAT_E_INVALID_ARG when client or *plist is NULL,
|
||||
* HEARTBEAT_E_PLIST_ERROR when the received data cannot be
|
||||
* converted to a plist, HEARTBEAT_E_MUX_ERROR when a
|
||||
* communication error occurs, or HEARTBEAT_E_UNKNOWN_ERROR
|
||||
* when an unspecified error occurs.
|
||||
*/
|
||||
heartbeat_error_t heartbeat_receive_with_timeout(heartbeat_client_t client, plist_t * plist, uint32_t timeout_ms);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,179 @@
|
|||
/**
|
||||
* @file libimobiledevice/house_arrest.h
|
||||
* @brief Access app folders and their contents.
|
||||
* \internal
|
||||
*
|
||||
* Copyright (c) 2013-2014 Martin Szulecki All Rights Reserved.
|
||||
* Copyright (c) 2010 Nikias Bassen, All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef IHOUSE_ARREST_H
|
||||
#define IHOUSE_ARREST_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <libimobiledevice/libimobiledevice.h>
|
||||
#include <libimobiledevice/lockdown.h>
|
||||
#include <libimobiledevice/afc.h>
|
||||
|
||||
#define HOUSE_ARREST_SERVICE_NAME "com.apple.mobile.house_arrest"
|
||||
|
||||
/** Error Codes */
|
||||
typedef enum {
|
||||
HOUSE_ARREST_E_SUCCESS = 0,
|
||||
HOUSE_ARREST_E_INVALID_ARG = -1,
|
||||
HOUSE_ARREST_E_PLIST_ERROR = -2,
|
||||
HOUSE_ARREST_E_CONN_FAILED = -3,
|
||||
HOUSE_ARREST_E_INVALID_MODE = -4,
|
||||
HOUSE_ARREST_E_UNKNOWN_ERROR = -256
|
||||
} house_arrest_error_t;
|
||||
|
||||
typedef struct house_arrest_client_private house_arrest_client_private;
|
||||
typedef house_arrest_client_private *house_arrest_client_t; /**< The client handle. */
|
||||
|
||||
/* Interface */
|
||||
|
||||
/**
|
||||
* Connects to the house_arrest service on the specified device.
|
||||
*
|
||||
* @param device The device to connect to.
|
||||
* @param service The service descriptor returned by lockdownd_start_service.
|
||||
* @param client Pointer that will point to a newly allocated
|
||||
* housearrest_client_t upon successful return.
|
||||
*
|
||||
* @return HOUSE_ARREST_E_SUCCESS on success, HOUSE_ARREST_E_INVALID_ARG when
|
||||
* client is NULL, or an HOUSE_ARREST_E_* error code otherwise.
|
||||
*/
|
||||
house_arrest_error_t house_arrest_client_new(idevice_t device, lockdownd_service_descriptor_t service, house_arrest_client_t *client);
|
||||
|
||||
/**
|
||||
* Starts a new house_arrest service on the specified device and connects to it.
|
||||
*
|
||||
* @param device The device to connect to.
|
||||
* @param client Pointer that will point to a newly allocated
|
||||
* house_arrest_client_t upon successful return. Must be freed using
|
||||
* house_arrest_client_free() after use.
|
||||
* @param label The label to use for communication. Usually the program name.
|
||||
* Pass NULL to disable sending the label in requests to lockdownd.
|
||||
*
|
||||
* @return HOUSE_ARREST_E_SUCCESS on success, or an HOUSE_ARREST_E_* error
|
||||
* code otherwise.
|
||||
*/
|
||||
house_arrest_error_t house_arrest_client_start_service(idevice_t device, house_arrest_client_t* client, const char* label);
|
||||
|
||||
/**
|
||||
* Disconnects an house_arrest client from the device and frees up the
|
||||
* house_arrest client data.
|
||||
*
|
||||
* @note After using afc_client_new_from_house_arrest_client(), make sure
|
||||
* you call afc_client_free() before calling this function to ensure
|
||||
* a proper cleanup. Do not call this function if you still need to
|
||||
* perform AFC operations since it will close the connection.
|
||||
*
|
||||
* @param client The house_arrest client to disconnect and free.
|
||||
*
|
||||
* @return HOUSE_ARREST_E_SUCCESS on success, HOUSE_ARREST_E_INVALID_ARG when
|
||||
* client is NULL, or an HOUSE_ARREST_E_* error code otherwise.
|
||||
*/
|
||||
house_arrest_error_t house_arrest_client_free(house_arrest_client_t client);
|
||||
|
||||
|
||||
/**
|
||||
* Sends a generic request to the connected house_arrest service.
|
||||
*
|
||||
* @param client The house_arrest client to use.
|
||||
* @param dict The request to send as a plist of type PLIST_DICT.
|
||||
*
|
||||
* @note If this function returns HOUSE_ARREST_E_SUCCESS it does not mean
|
||||
* that the request was successful. To check for success or failure you
|
||||
* need to call house_arrest_get_result().
|
||||
* @see house_arrest_get_result
|
||||
*
|
||||
* @return HOUSE_ARREST_E_SUCCESS if the request was successfully sent,
|
||||
* HOUSE_ARREST_E_INVALID_ARG if client or dict is invalid,
|
||||
* HOUSE_ARREST_E_PLIST_ERROR if dict is not a plist of type PLIST_DICT,
|
||||
* HOUSE_ARREST_E_INVALID_MODE if the client is not in the correct mode,
|
||||
* or HOUSE_ARREST_E_CONN_FAILED if a connection error occured.
|
||||
*/
|
||||
house_arrest_error_t house_arrest_send_request(house_arrest_client_t client, plist_t dict);
|
||||
|
||||
/**
|
||||
* Send a command to the connected house_arrest service.
|
||||
* Calls house_arrest_send_request() internally.
|
||||
*
|
||||
* @param client The house_arrest client to use.
|
||||
* @param command The command to send. Currently, only VendContainer and
|
||||
* VendDocuments are known.
|
||||
* @param appid The application identifier to pass along with the .
|
||||
*
|
||||
* @note If this function returns HOUSE_ARREST_E_SUCCESS it does not mean
|
||||
* that the command was successful. To check for success or failure you
|
||||
* need to call house_arrest_get_result().
|
||||
* @see house_arrest_get_result
|
||||
*
|
||||
* @return HOUSE_ARREST_E_SUCCESS if the command was successfully sent,
|
||||
* HOUSE_ARREST_E_INVALID_ARG if client, command, or appid is invalid,
|
||||
* HOUSE_ARREST_E_INVALID_MODE if the client is not in the correct mode,
|
||||
* or HOUSE_ARREST_E_CONN_FAILED if a connection error occured.
|
||||
*/
|
||||
house_arrest_error_t house_arrest_send_command(house_arrest_client_t client, const char *command, const char *appid);
|
||||
|
||||
/**
|
||||
* Retrieves the result of a previously sent house_arrest_request_* request.
|
||||
*
|
||||
* @param client The house_arrest client to use
|
||||
* @param dict Pointer that will be set to a plist containing the result to
|
||||
* the last performed operation. It holds a key 'Status' with the value
|
||||
* 'Complete' on success or a key 'Error' with an error description as
|
||||
* value. The caller is responsible for freeing the returned plist.
|
||||
*
|
||||
* @return HOUSE_ARREST_E_SUCCESS if a result plist was retrieved,
|
||||
* HOUSE_ARREST_E_INVALID_ARG if client is invalid,
|
||||
* HOUSE_ARREST_E_INVALID_MODE if the client is not in the correct mode,
|
||||
* or HOUSE_ARREST_E_CONN_FAILED if a connection error occured.
|
||||
*/
|
||||
house_arrest_error_t house_arrest_get_result(house_arrest_client_t client, plist_t *dict);
|
||||
|
||||
|
||||
/**
|
||||
* Creates an AFC client using the given house_arrest client's connection
|
||||
* allowing file access to a specific application directory requested by
|
||||
* functions like house_arrest_request_vendor_documents().
|
||||
*
|
||||
* @param client The house_arrest client to use.
|
||||
* @param afc_client Pointer that will be set to a newly allocated afc_client_t
|
||||
* upon successful return.
|
||||
*
|
||||
* @note After calling this function the house_arrest client will go in an
|
||||
* AFC mode that will only allow calling house_arrest_client_free().
|
||||
* Only call house_arrest_client_free() if all AFC operations have
|
||||
* completed since it will close the connection.
|
||||
*
|
||||
* @return AFC_E_SUCCESS if the afc client was successfully created,
|
||||
* AFC_E_INVALID_ARG if client is invalid or was already used to create
|
||||
* an afc client, or an AFC_E_* error code returned by
|
||||
* afc_client_new_with_service_client().
|
||||
*/
|
||||
afc_error_t afc_client_new_from_house_arrest_client(house_arrest_client_t client, afc_client_t *afc_client);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,504 @@
|
|||
/**
|
||||
* @file libimobiledevice/installation_proxy.h
|
||||
* @brief Manage applications on a device.
|
||||
* \internal
|
||||
*
|
||||
* Copyright (c) 2010-2015 Martin Szulecki All Rights Reserved.
|
||||
* Copyright (c) 2014 Christophe Fergeau All Rights Reserved.
|
||||
* Copyright (c) 2009-2012 Nikias Bassen All Rights Reserved.
|
||||
* Copyright (c) 2010 Bryan Forbes All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef IINSTALLATION_PROXY_H
|
||||
#define IINSTALLATION_PROXY_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <libimobiledevice/libimobiledevice.h>
|
||||
#include <libimobiledevice/lockdown.h>
|
||||
|
||||
#define INSTPROXY_SERVICE_NAME "com.apple.mobile.installation_proxy"
|
||||
|
||||
/** Error Codes */
|
||||
typedef enum {
|
||||
/* custom */
|
||||
INSTPROXY_E_SUCCESS = 0,
|
||||
INSTPROXY_E_INVALID_ARG = -1,
|
||||
INSTPROXY_E_PLIST_ERROR = -2,
|
||||
INSTPROXY_E_CONN_FAILED = -3,
|
||||
INSTPROXY_E_OP_IN_PROGRESS = -4,
|
||||
INSTPROXY_E_OP_FAILED = -5,
|
||||
INSTPROXY_E_RECEIVE_TIMEOUT = -6,
|
||||
/* native */
|
||||
INSTPROXY_E_ALREADY_ARCHIVED = -7,
|
||||
INSTPROXY_E_API_INTERNAL_ERROR = -8,
|
||||
INSTPROXY_E_APPLICATION_ALREADY_INSTALLED = -9,
|
||||
INSTPROXY_E_APPLICATION_MOVE_FAILED = -10,
|
||||
INSTPROXY_E_APPLICATION_SINF_CAPTURE_FAILED = -11,
|
||||
INSTPROXY_E_APPLICATION_SANDBOX_FAILED = -12,
|
||||
INSTPROXY_E_APPLICATION_VERIFICATION_FAILED = -13,
|
||||
INSTPROXY_E_ARCHIVE_DESTRUCTION_FAILED = -14,
|
||||
INSTPROXY_E_BUNDLE_VERIFICATION_FAILED = -15,
|
||||
INSTPROXY_E_CARRIER_BUNDLE_COPY_FAILED = -16,
|
||||
INSTPROXY_E_CARRIER_BUNDLE_DIRECTORY_CREATION_FAILED = -17,
|
||||
INSTPROXY_E_CARRIER_BUNDLE_MISSING_SUPPORTED_SIMS = -18,
|
||||
INSTPROXY_E_COMM_CENTER_NOTIFICATION_FAILED = -19,
|
||||
INSTPROXY_E_CONTAINER_CREATION_FAILED = -20,
|
||||
INSTPROXY_E_CONTAINER_P0WN_FAILED = -21,
|
||||
INSTPROXY_E_CONTAINER_REMOVAL_FAILED = -22,
|
||||
INSTPROXY_E_EMBEDDED_PROFILE_INSTALL_FAILED = -23,
|
||||
INSTPROXY_E_EXECUTABLE_TWIDDLE_FAILED = -24,
|
||||
INSTPROXY_E_EXISTENCE_CHECK_FAILED = -25,
|
||||
INSTPROXY_E_INSTALL_MAP_UPDATE_FAILED = -26,
|
||||
INSTPROXY_E_MANIFEST_CAPTURE_FAILED = -27,
|
||||
INSTPROXY_E_MAP_GENERATION_FAILED = -28,
|
||||
INSTPROXY_E_MISSING_BUNDLE_EXECUTABLE = -29,
|
||||
INSTPROXY_E_MISSING_BUNDLE_IDENTIFIER = -30,
|
||||
INSTPROXY_E_MISSING_BUNDLE_PATH = -31,
|
||||
INSTPROXY_E_MISSING_CONTAINER = -32,
|
||||
INSTPROXY_E_NOTIFICATION_FAILED = -33,
|
||||
INSTPROXY_E_PACKAGE_EXTRACTION_FAILED = -34,
|
||||
INSTPROXY_E_PACKAGE_INSPECTION_FAILED = -35,
|
||||
INSTPROXY_E_PACKAGE_MOVE_FAILED = -36,
|
||||
INSTPROXY_E_PATH_CONVERSION_FAILED = -37,
|
||||
INSTPROXY_E_RESTORE_CONTAINER_FAILED = -38,
|
||||
INSTPROXY_E_SEATBELT_PROFILE_REMOVAL_FAILED = -39,
|
||||
INSTPROXY_E_STAGE_CREATION_FAILED = -40,
|
||||
INSTPROXY_E_SYMLINK_FAILED = -41,
|
||||
INSTPROXY_E_UNKNOWN_COMMAND = -42,
|
||||
INSTPROXY_E_ITUNES_ARTWORK_CAPTURE_FAILED = -43,
|
||||
INSTPROXY_E_ITUNES_METADATA_CAPTURE_FAILED = -44,
|
||||
INSTPROXY_E_DEVICE_OS_VERSION_TOO_LOW = -45,
|
||||
INSTPROXY_E_DEVICE_FAMILY_NOT_SUPPORTED = -46,
|
||||
INSTPROXY_E_PACKAGE_PATCH_FAILED = -47,
|
||||
INSTPROXY_E_INCORRECT_ARCHITECTURE = -48,
|
||||
INSTPROXY_E_PLUGIN_COPY_FAILED = -49,
|
||||
INSTPROXY_E_BREADCRUMB_FAILED = -50,
|
||||
INSTPROXY_E_BREADCRUMB_UNLOCK_FAILED = -51,
|
||||
INSTPROXY_E_GEOJSON_CAPTURE_FAILED = -52,
|
||||
INSTPROXY_E_NEWSSTAND_ARTWORK_CAPTURE_FAILED = -53,
|
||||
INSTPROXY_E_MISSING_COMMAND = -54,
|
||||
INSTPROXY_E_NOT_ENTITLED = -55,
|
||||
INSTPROXY_E_MISSING_PACKAGE_PATH = -56,
|
||||
INSTPROXY_E_MISSING_CONTAINER_PATH = -57,
|
||||
INSTPROXY_E_MISSING_APPLICATION_IDENTIFIER = -58,
|
||||
INSTPROXY_E_MISSING_ATTRIBUTE_VALUE = -59,
|
||||
INSTPROXY_E_LOOKUP_FAILED = -60,
|
||||
INSTPROXY_E_DICT_CREATION_FAILED = -61,
|
||||
INSTPROXY_E_INSTALL_PROHIBITED = -62,
|
||||
INSTPROXY_E_UNINSTALL_PROHIBITED = -63,
|
||||
INSTPROXY_E_MISSING_BUNDLE_VERSION = -64,
|
||||
INSTPROXY_E_UNKNOWN_ERROR = -256
|
||||
} instproxy_error_t;
|
||||
|
||||
typedef struct instproxy_client_private instproxy_client_private;
|
||||
typedef instproxy_client_private *instproxy_client_t; /**< The client handle. */
|
||||
|
||||
/** Reports the status response of the given command */
|
||||
typedef void (*instproxy_status_cb_t) (plist_t command, plist_t status, void *user_data);
|
||||
|
||||
/* Interface */
|
||||
|
||||
/**
|
||||
* Connects to the installation_proxy service on the specified device.
|
||||
*
|
||||
* @param device The device to connect to
|
||||
* @param service The service descriptor returned by lockdownd_start_service.
|
||||
* @param client Pointer that will be set to a newly allocated
|
||||
* instproxy_client_t upon successful return.
|
||||
*
|
||||
* @return INSTPROXY_E_SUCCESS on success, or an INSTPROXY_E_* error value
|
||||
* when an error occured.
|
||||
*/
|
||||
instproxy_error_t instproxy_client_new(idevice_t device, lockdownd_service_descriptor_t service, instproxy_client_t *client);
|
||||
|
||||
/**
|
||||
* Starts a new installation_proxy service on the specified device and connects to it.
|
||||
*
|
||||
* @param device The device to connect to.
|
||||
* @param client Pointer that will point to a newly allocated
|
||||
* instproxy_client_t upon successful return. Must be freed using
|
||||
* instproxy_client_free() after use.
|
||||
* @param label The label to use for communication. Usually the program name.
|
||||
* Pass NULL to disable sending the label in requests to lockdownd.
|
||||
*
|
||||
* @return INSTPROXY_E_SUCCESS on success, or an INSTPROXY_E_* error
|
||||
* code otherwise.
|
||||
*/
|
||||
instproxy_error_t instproxy_client_start_service(idevice_t device, instproxy_client_t * client, const char* label);
|
||||
|
||||
/**
|
||||
* Disconnects an installation_proxy client from the device and frees up the
|
||||
* installation_proxy client data.
|
||||
*
|
||||
* @param client The installation_proxy client to disconnect and free.
|
||||
*
|
||||
* @return INSTPROXY_E_SUCCESS on success
|
||||
* or INSTPROXY_E_INVALID_ARG if client is NULL.
|
||||
*/
|
||||
instproxy_error_t instproxy_client_free(instproxy_client_t client);
|
||||
|
||||
/**
|
||||
* List installed applications. This function runs synchronously.
|
||||
*
|
||||
* @param client The connected installation_proxy client
|
||||
* @param client_options The client options to use, as PLIST_DICT, or NULL.
|
||||
* Valid client options include:
|
||||
* "ApplicationType" -> "System"
|
||||
* "ApplicationType" -> "User"
|
||||
* "ApplicationType" -> "Internal"
|
||||
* "ApplicationType" -> "Any"
|
||||
* @param result Pointer that will be set to a plist that will hold an array
|
||||
* of PLIST_DICT holding information about the applications found.
|
||||
*
|
||||
* @return INSTPROXY_E_SUCCESS on success or an INSTPROXY_E_* error value if
|
||||
* an error occured.
|
||||
*/
|
||||
instproxy_error_t instproxy_browse(instproxy_client_t client, plist_t client_options, plist_t *result);
|
||||
|
||||
/**
|
||||
* List pages of installed applications in a callback.
|
||||
*
|
||||
* @param client The connected installation_proxy client
|
||||
* @param client_options The client options to use, as PLIST_DICT, or NULL.
|
||||
* Valid client options include:
|
||||
* "ApplicationType" -> "System"
|
||||
* "ApplicationType" -> "User"
|
||||
* "ApplicationType" -> "Internal"
|
||||
* "ApplicationType" -> "Any"
|
||||
* @param status_cb Callback function to process each page of application
|
||||
* information. Passing a callback is required.
|
||||
* @param user_data Callback data passed to status_cb.
|
||||
*
|
||||
* @return INSTPROXY_E_SUCCESS on success or an INSTPROXY_E_* error value if
|
||||
* an error occured.
|
||||
*/
|
||||
instproxy_error_t instproxy_browse_with_callback(instproxy_client_t client, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data);
|
||||
|
||||
/**
|
||||
* Lookup information about specific applications from the device.
|
||||
*
|
||||
* @param client The connected installation_proxy client
|
||||
* @param appids An array of bundle identifiers that MUST have a terminating
|
||||
* NULL entry or NULL to lookup all.
|
||||
* @param client_options The client options to use, as PLIST_DICT, or NULL.
|
||||
* Currently there are no known client options, so pass NULL here.
|
||||
* @param result Pointer that will be set to a plist containing a PLIST_DICT
|
||||
* holding requested information about the application or NULL on errors.
|
||||
*
|
||||
* @return INSTPROXY_E_SUCCESS on success or an INSTPROXY_E_* error value if
|
||||
* an error occured.
|
||||
*/
|
||||
instproxy_error_t instproxy_lookup(instproxy_client_t client, const char** appids, plist_t client_options, plist_t *result);
|
||||
|
||||
/**
|
||||
* Install an application on the device.
|
||||
*
|
||||
* @param client The connected installation_proxy client
|
||||
* @param pkg_path Path of the installation package (inside the AFC jail)
|
||||
* @param client_options The client options to use, as PLIST_DICT, or NULL.
|
||||
* Valid options include:
|
||||
* "iTunesMetadata" -> PLIST_DATA
|
||||
* "ApplicationSINF" -> PLIST_DATA
|
||||
* "PackageType" -> "Developer"
|
||||
* If PackageType -> Developer is specified, then pkg_path points to
|
||||
* an .app directory instead of an install package.
|
||||
* @param status_cb Callback function for progress and status information. If
|
||||
* NULL is passed, this function will run synchronously.
|
||||
* @param user_data Callback data passed to status_cb.
|
||||
*
|
||||
* @return INSTPROXY_E_SUCCESS on success or an INSTPROXY_E_* error value if
|
||||
* an error occured.
|
||||
*
|
||||
* @note If a callback function is given (async mode), this function returns
|
||||
* INSTPROXY_E_SUCCESS immediately if the status updater thread has been
|
||||
* created successfully; any error occuring during the command has to be
|
||||
* handled inside the specified callback function.
|
||||
*/
|
||||
instproxy_error_t instproxy_install(instproxy_client_t client, const char *pkg_path, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data);
|
||||
|
||||
/**
|
||||
* Upgrade an application on the device. This function is nearly the same as
|
||||
* instproxy_install; the difference is that the installation progress on the
|
||||
* device is faster if the application is already installed.
|
||||
*
|
||||
* @param client The connected installation_proxy client
|
||||
* @param pkg_path Path of the installation package (inside the AFC jail)
|
||||
* @param client_options The client options to use, as PLIST_DICT, or NULL.
|
||||
* Valid options include:
|
||||
* "iTunesMetadata" -> PLIST_DATA
|
||||
* "ApplicationSINF" -> PLIST_DATA
|
||||
* "PackageType" -> "Developer"
|
||||
* If PackageType -> Developer is specified, then pkg_path points to
|
||||
* an .app directory instead of an install package.
|
||||
* @param status_cb Callback function for progress and status information. If
|
||||
* NULL is passed, this function will run synchronously.
|
||||
* @param user_data Callback data passed to status_cb.
|
||||
*
|
||||
* @return INSTPROXY_E_SUCCESS on success or an INSTPROXY_E_* error value if
|
||||
* an error occured.
|
||||
*
|
||||
* @note If a callback function is given (async mode), this function returns
|
||||
* INSTPROXY_E_SUCCESS immediately if the status updater thread has been
|
||||
* created successfully; any error occuring during the command has to be
|
||||
* handled inside the specified callback function.
|
||||
*/
|
||||
instproxy_error_t instproxy_upgrade(instproxy_client_t client, const char *pkg_path, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data);
|
||||
|
||||
/**
|
||||
* Uninstall an application from the device.
|
||||
*
|
||||
* @param client The connected installation proxy client
|
||||
* @param appid ApplicationIdentifier of the app to uninstall
|
||||
* @param client_options The client options to use, as PLIST_DICT, or NULL.
|
||||
* Currently there are no known client options, so pass NULL here.
|
||||
* @param status_cb Callback function for progress and status information. If
|
||||
* NULL is passed, this function will run synchronously.
|
||||
* @param user_data Callback data passed to status_cb.
|
||||
*
|
||||
* @return INSTPROXY_E_SUCCESS on success or an INSTPROXY_E_* error value if
|
||||
* an error occured.
|
||||
*
|
||||
* @note If a callback function is given (async mode), this function returns
|
||||
* INSTPROXY_E_SUCCESS immediately if the status updater thread has been
|
||||
* created successfully; any error occuring during the command has to be
|
||||
* handled inside the specified callback function.
|
||||
*/
|
||||
instproxy_error_t instproxy_uninstall(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data);
|
||||
|
||||
/**
|
||||
* List archived applications. This function runs synchronously.
|
||||
*
|
||||
* @see instproxy_archive
|
||||
*
|
||||
* @param client The connected installation_proxy client
|
||||
* @param client_options The client options to use, as PLIST_DICT, or NULL.
|
||||
* Currently there are no known client options, so pass NULL here.
|
||||
* @param result Pointer that will be set to a plist containing a PLIST_DICT
|
||||
* holding information about the archived applications found.
|
||||
*
|
||||
* @return INSTPROXY_E_SUCCESS on success or an INSTPROXY_E_* error value if
|
||||
* an error occured.
|
||||
*/
|
||||
instproxy_error_t instproxy_lookup_archives(instproxy_client_t client, plist_t client_options, plist_t *result);
|
||||
|
||||
/**
|
||||
* Archive an application on the device.
|
||||
* This function tells the device to make an archive of the specified
|
||||
* application. This results in the device creating a ZIP archive in the
|
||||
* 'ApplicationArchives' directory and uninstalling the application.
|
||||
*
|
||||
* @param client The connected installation proxy client
|
||||
* @param appid ApplicationIdentifier of the app to archive.
|
||||
* @param client_options The client options to use, as PLIST_DICT, or NULL.
|
||||
* Valid options include:
|
||||
* "SkipUninstall" -> Boolean
|
||||
* "ArchiveType" -> "ApplicationOnly"
|
||||
* @param status_cb Callback function for progress and status information. If
|
||||
* NULL is passed, this function will run synchronously.
|
||||
* @param user_data Callback data passed to status_cb.
|
||||
*
|
||||
* @return INSTPROXY_E_SUCCESS on success or an INSTPROXY_E_* error value if
|
||||
* an error occured.
|
||||
*
|
||||
* @note If a callback function is given (async mode), this function returns
|
||||
* INSTPROXY_E_SUCCESS immediately if the status updater thread has been
|
||||
* created successfully; any error occuring during the command has to be
|
||||
* handled inside the specified callback function.
|
||||
*/
|
||||
instproxy_error_t instproxy_archive(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data);
|
||||
|
||||
/**
|
||||
* Restore a previously archived application on the device.
|
||||
* This function is the counterpart to instproxy_archive.
|
||||
* @see instproxy_archive
|
||||
*
|
||||
* @param client The connected installation proxy client
|
||||
* @param appid ApplicationIdentifier of the app to restore.
|
||||
* @param client_options The client options to use, as PLIST_DICT, or NULL.
|
||||
* Valid options include:
|
||||
* "ArchiveType" -> "DocumentsOnly"
|
||||
* @param status_cb Callback function for progress and status information. If
|
||||
* NULL is passed, this function will run synchronously.
|
||||
* @param user_data Callback data passed to status_cb.
|
||||
*
|
||||
* @return INSTPROXY_E_SUCCESS on success or an INSTPROXY_E_* error value if
|
||||
* an error occured.
|
||||
*
|
||||
* @note If a callback function is given (async mode), this function returns
|
||||
* INSTPROXY_E_SUCCESS immediately if the status updater thread has been
|
||||
* created successfully; any error occuring during the command has to be
|
||||
* handled inside the specified callback function.
|
||||
*/
|
||||
instproxy_error_t instproxy_restore(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data);
|
||||
|
||||
/**
|
||||
* Removes a previously archived application from the device.
|
||||
* This function removes the ZIP archive from the 'ApplicationArchives'
|
||||
* directory.
|
||||
*
|
||||
* @param client The connected installation proxy client
|
||||
* @param appid ApplicationIdentifier of the archived app to remove.
|
||||
* @param client_options The client options to use, as PLIST_DICT, or NULL.
|
||||
* Currently there are no known client options, so passing NULL is fine.
|
||||
* @param status_cb Callback function for progress and status information. If
|
||||
* NULL is passed, this function will run synchronously.
|
||||
* @param user_data Callback data passed to status_cb.
|
||||
*
|
||||
* @return INSTPROXY_E_SUCCESS on success or an INSTPROXY_E_* error value if
|
||||
* an error occured.
|
||||
*
|
||||
* @note If a callback function is given (async mode), this function returns
|
||||
* INSTPROXY_E_SUCCESS immediately if the status updater thread has been
|
||||
* created successfully; any error occuring during the command has to be
|
||||
* handled inside the specified callback function.
|
||||
*/
|
||||
instproxy_error_t instproxy_remove_archive(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data);
|
||||
|
||||
/**
|
||||
* Checks a device for certain capabilities.
|
||||
*
|
||||
* @param client The connected installation_proxy client
|
||||
* @param capabilities An array of char* with capability names that MUST have a
|
||||
* terminating NULL entry.
|
||||
* @param client_options The client options to use, as PLIST_DICT, or NULL.
|
||||
* Currently there are no known client options, so pass NULL here.
|
||||
* @param result Pointer that will be set to a plist containing a PLIST_DICT
|
||||
* holding information if the capabilities matched or NULL on errors.
|
||||
*
|
||||
* @return INSTPROXY_E_SUCCESS on success or an INSTPROXY_E_* error value if
|
||||
* an error occured.
|
||||
*/
|
||||
instproxy_error_t instproxy_check_capabilities_match(instproxy_client_t client, const char** capabilities, plist_t client_options, plist_t *result);
|
||||
|
||||
/* Helper */
|
||||
|
||||
/**
|
||||
* Gets the name from a command dictionary.
|
||||
*
|
||||
* @param command The dictionary describing the command.
|
||||
* @param name Pointer to store the name of the command.
|
||||
*/
|
||||
void instproxy_command_get_name(plist_t command, char** name);
|
||||
|
||||
/**
|
||||
* Gets the name of a status.
|
||||
*
|
||||
* @param status The dictionary status response to use.
|
||||
* @param name Pointer to store the name of the status.
|
||||
*/
|
||||
void instproxy_status_get_name(plist_t status, char **name);
|
||||
|
||||
/**
|
||||
* Gets error name, code and description from a response if available.
|
||||
*
|
||||
* @param status The dictionary status response to use.
|
||||
* @param name Pointer to store the name of an error.
|
||||
* @param description Pointer to store error description text if available.
|
||||
* The caller is reponsible for freeing the allocated buffer after use.
|
||||
* If NULL is passed no description will be returned.
|
||||
* @param code Pointer to store the returned error code if available.
|
||||
* If NULL is passed no error code will be returned.
|
||||
*
|
||||
* @return INSTPROXY_E_SUCCESS if no error is found or an INSTPROXY_E_* error
|
||||
* value matching the error that ẃas found in the status.
|
||||
*/
|
||||
instproxy_error_t instproxy_status_get_error(plist_t status, char **name, char** description, uint64_t* code);
|
||||
|
||||
/**
|
||||
* Gets total and current item information from a browse response if available.
|
||||
*
|
||||
* @param status The dictionary status response to use.
|
||||
* @param total Pointer to store the total number of items.
|
||||
* @param current_index Pointer to store the current index of all browsed items.
|
||||
* @param current_amount Pointer to store the amount of items in the
|
||||
* current list.
|
||||
* @param list Pointer to store a newly allocated plist with items.
|
||||
* The caller is reponsible for freeing the list after use.
|
||||
* If NULL is passed no list will be returned. If NULL is returned no
|
||||
* list was found in the status.
|
||||
*/
|
||||
void instproxy_status_get_current_list(plist_t status, uint64_t* total, uint64_t* current_index, uint64_t* current_amount, plist_t* list);
|
||||
|
||||
|
||||
/**
|
||||
* Gets progress in percentage from a status if available.
|
||||
*
|
||||
* @param status The dictionary status response to use.
|
||||
* @param name Pointer to store the progress in percent (0-100) or -1 if not
|
||||
* progress was found in the status.
|
||||
*/
|
||||
void instproxy_status_get_percent_complete(plist_t status, int *percent);
|
||||
|
||||
/**
|
||||
* Creates a new client_options plist.
|
||||
*
|
||||
* @return A new plist_t of type PLIST_DICT.
|
||||
*/
|
||||
plist_t instproxy_client_options_new(void);
|
||||
|
||||
/**
|
||||
* Adds one or more new key:value pairs to the given client_options.
|
||||
*
|
||||
* @param client_options The client options to modify.
|
||||
* @param ... KEY, VALUE, [KEY, VALUE], NULL
|
||||
*
|
||||
* @note The keys and values passed are expected to be strings, except for the
|
||||
* keys "ApplicationSINF", "iTunesMetadata", "ReturnAttributes" which are
|
||||
* expecting a plist_t node as value and "SkipUninstall" expects int.
|
||||
*/
|
||||
void instproxy_client_options_add(plist_t client_options, ...);
|
||||
|
||||
/**
|
||||
* Adds attributes to the given client_options to filter browse results.
|
||||
*
|
||||
* @param client_options The client options to modify.
|
||||
* @param ... VALUE, VALUE, [VALUE], NULL
|
||||
*
|
||||
* @note The values passed are expected to be strings.
|
||||
*/
|
||||
void instproxy_client_options_set_return_attributes(plist_t client_options, ...);
|
||||
|
||||
/**
|
||||
* Frees client_options plist.
|
||||
*
|
||||
* @param client_options The client options plist to free. Does nothing if NULL
|
||||
* is passed.
|
||||
*/
|
||||
void instproxy_client_options_free(plist_t client_options);
|
||||
|
||||
/**
|
||||
* Queries the device for the path of an application.
|
||||
*
|
||||
* @param client The connected installation proxy client.
|
||||
* @param appid ApplicationIdentifier of app to retrieve the path for.
|
||||
* @param path Pointer to store the device path for the application
|
||||
* which is set to NULL if it could not be determined.
|
||||
*
|
||||
* @return INSTPROXY_E_SUCCESS on success, INSTPROXY_E_OP_FAILED if
|
||||
* the path could not be determined or an INSTPROXY_E_* error
|
||||
* value if an error occured.
|
||||
*/
|
||||
instproxy_error_t instproxy_client_get_path_for_bundle_identifier(instproxy_client_t client, const char* bundle_id, char** path);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,259 @@
|
|||
/**
|
||||
* @file libimobiledevice/libimobiledevice.h
|
||||
* @brief Device/Connection handling and communication
|
||||
* \internal
|
||||
*
|
||||
* Copyright (c) 2010-2014 Martin Szulecki All Rights Reserved.
|
||||
* Copyright (c) 2014 Christophe Fergeau All Rights Reserved.
|
||||
* Copyright (c) 2008 Jonathan Beck All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef IMOBILEDEVICE_H
|
||||
#define IMOBILEDEVICE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <plist/plist.h>
|
||||
|
||||
/** Error Codes */
|
||||
typedef enum {
|
||||
IDEVICE_E_SUCCESS = 0,
|
||||
IDEVICE_E_INVALID_ARG = -1,
|
||||
IDEVICE_E_UNKNOWN_ERROR = -2,
|
||||
IDEVICE_E_NO_DEVICE = -3,
|
||||
IDEVICE_E_NOT_ENOUGH_DATA = -4,
|
||||
IDEVICE_E_BAD_HEADER = -5,
|
||||
IDEVICE_E_SSL_ERROR = -6
|
||||
} idevice_error_t;
|
||||
|
||||
typedef struct idevice_private idevice_private;
|
||||
typedef idevice_private *idevice_t; /**< The device handle. */
|
||||
|
||||
typedef struct idevice_connection_private idevice_connection_private;
|
||||
typedef idevice_connection_private *idevice_connection_t; /**< The connection handle. */
|
||||
|
||||
/* discovery (events/asynchronous) */
|
||||
/** The event type for device add or removal */
|
||||
enum idevice_event_type {
|
||||
IDEVICE_DEVICE_ADD = 1,
|
||||
IDEVICE_DEVICE_REMOVE
|
||||
};
|
||||
|
||||
/* event data structure */
|
||||
/** Provides information about the occured event. */
|
||||
typedef struct {
|
||||
enum idevice_event_type event; /**< The event type. */
|
||||
const char *udid; /**< The device unique id. */
|
||||
int conn_type; /**< The connection type. Currently only 1 for usbmuxd. */
|
||||
} idevice_event_t;
|
||||
|
||||
/* event callback function prototype */
|
||||
/** Callback to notifiy if a device was added or removed. */
|
||||
typedef void (*idevice_event_cb_t) (const idevice_event_t *event, void *user_data);
|
||||
|
||||
/* functions */
|
||||
|
||||
/**
|
||||
* Set the level of debugging.
|
||||
*
|
||||
* @param level Set to 0 for no debug output or 1 to enable debug output.
|
||||
*/
|
||||
void idevice_set_debug_level(int level);
|
||||
|
||||
/**
|
||||
* Register a callback function that will be called when device add/remove
|
||||
* events occur.
|
||||
*
|
||||
* @param callback Callback function to call.
|
||||
* @param user_data Application-specific data passed as parameter
|
||||
* to the registered callback function.
|
||||
*
|
||||
* @return IDEVICE_E_SUCCESS on success or an error value when an error occured.
|
||||
*/
|
||||
idevice_error_t idevice_event_subscribe(idevice_event_cb_t callback, void *user_data);
|
||||
|
||||
/**
|
||||
* Release the event callback function that has been registered with
|
||||
* idevice_event_subscribe().
|
||||
*
|
||||
* @return IDEVICE_E_SUCCESS on success or an error value when an error occured.
|
||||
*/
|
||||
idevice_error_t idevice_event_unsubscribe(void);
|
||||
|
||||
/* discovery (synchronous) */
|
||||
|
||||
/**
|
||||
* Get a list of currently available devices.
|
||||
*
|
||||
* @param devices List of udids of devices that are currently available.
|
||||
* This list is terminated by a NULL pointer.
|
||||
* @param count Number of devices found.
|
||||
*
|
||||
* @return IDEVICE_E_SUCCESS on success or an error value when an error occured.
|
||||
*/
|
||||
idevice_error_t idevice_get_device_list(char ***devices, int *count);
|
||||
|
||||
/**
|
||||
* Free a list of device udids.
|
||||
*
|
||||
* @param devices List of udids to free.
|
||||
*
|
||||
* @return Always returnes IDEVICE_E_SUCCESS.
|
||||
*/
|
||||
idevice_error_t idevice_device_list_free(char **devices);
|
||||
|
||||
/* device structure creation and destruction */
|
||||
|
||||
/**
|
||||
* Creates an idevice_t structure for the device specified by udid,
|
||||
* if the device is available.
|
||||
*
|
||||
* @note The resulting idevice_t structure has to be freed with
|
||||
* idevice_free() if it is no longer used.
|
||||
*
|
||||
* @param device Upon calling this function, a pointer to a location of type
|
||||
* idevice_t. On successful return, this location will be populated.
|
||||
* @param udid The UDID to match.
|
||||
*
|
||||
* @return IDEVICE_E_SUCCESS if ok, otherwise an error code.
|
||||
*/
|
||||
idevice_error_t idevice_new(idevice_t *device, const char *udid);
|
||||
|
||||
/**
|
||||
* Cleans up an idevice structure, then frees the structure itself.
|
||||
* This is a library-level function; deals directly with the device to tear
|
||||
* down relations, but otherwise is mostly internal.
|
||||
*
|
||||
* @param device idevice_t to free.
|
||||
*/
|
||||
idevice_error_t idevice_free(idevice_t device);
|
||||
|
||||
/* connection/disconnection */
|
||||
|
||||
/**
|
||||
* Set up a connection to the given device.
|
||||
*
|
||||
* @param device The device to connect to.
|
||||
* @param port The destination port to connect to.
|
||||
* @param connection Pointer to an idevice_connection_t that will be filled
|
||||
* with the necessary data of the connection.
|
||||
*
|
||||
* @return IDEVICE_E_SUCCESS if ok, otherwise an error code.
|
||||
*/
|
||||
idevice_error_t idevice_connect(idevice_t device, uint16_t port, idevice_connection_t *connection);
|
||||
|
||||
/**
|
||||
* Disconnect from the device and clean up the connection structure.
|
||||
*
|
||||
* @param connection The connection to close.
|
||||
*
|
||||
* @return IDEVICE_E_SUCCESS if ok, otherwise an error code.
|
||||
*/
|
||||
idevice_error_t idevice_disconnect(idevice_connection_t connection);
|
||||
|
||||
/* communication */
|
||||
|
||||
/**
|
||||
* Send data to a device via the given connection.
|
||||
*
|
||||
* @param connection The connection to send data over.
|
||||
* @param data Buffer with data to send.
|
||||
* @param len Size of the buffer to send.
|
||||
* @param sent_bytes Pointer to an uint32_t that will be filled
|
||||
* with the number of bytes actually sent.
|
||||
*
|
||||
* @return IDEVICE_E_SUCCESS if ok, otherwise an error code.
|
||||
*/
|
||||
idevice_error_t idevice_connection_send(idevice_connection_t connection, const char *data, uint32_t len, uint32_t *sent_bytes);
|
||||
|
||||
/**
|
||||
* Receive data from a device via the given connection.
|
||||
* This function will return after the given timeout even if no data has been
|
||||
* received.
|
||||
*
|
||||
* @param connection The connection to receive data from.
|
||||
* @param data Buffer that will be filled with the received data.
|
||||
* This buffer has to be large enough to hold len bytes.
|
||||
* @param len Buffer size or number of bytes to receive.
|
||||
* @param recv_bytes Number of bytes actually received.
|
||||
* @param timeout Timeout in milliseconds after which this function should
|
||||
* return even if no data has been received.
|
||||
*
|
||||
* @return IDEVICE_E_SUCCESS if ok, otherwise an error code.
|
||||
*/
|
||||
idevice_error_t idevice_connection_receive_timeout(idevice_connection_t connection, char *data, uint32_t len, uint32_t *recv_bytes, unsigned int timeout);
|
||||
|
||||
/**
|
||||
* Receive data from a device via the given connection.
|
||||
* This function is like idevice_connection_receive_timeout, but with a
|
||||
* predefined reasonable timeout.
|
||||
*
|
||||
* @param connection The connection to receive data from.
|
||||
* @param data Buffer that will be filled with the received data.
|
||||
* This buffer has to be large enough to hold len bytes.
|
||||
* @param len Buffer size or number of bytes to receive.
|
||||
* @param recv_bytes Number of bytes actually received.
|
||||
*
|
||||
* @return IDEVICE_E_SUCCESS if ok, otherwise an error code.
|
||||
*/
|
||||
idevice_error_t idevice_connection_receive(idevice_connection_t connection, char *data, uint32_t len, uint32_t *recv_bytes);
|
||||
|
||||
/**
|
||||
* Enables SSL for the given connection.
|
||||
*
|
||||
* @param connection The connection to enable SSL for.
|
||||
*
|
||||
* @return IDEVICE_E_SUCCESS on success, IDEVICE_E_INVALID_ARG when connection
|
||||
* is NULL or connection->ssl_data is non-NULL, or IDEVICE_E_SSL_ERROR when
|
||||
* SSL initialization, setup, or handshake fails.
|
||||
*/
|
||||
idevice_error_t idevice_connection_enable_ssl(idevice_connection_t connection);
|
||||
|
||||
/**
|
||||
* Disable SSL for the given connection.
|
||||
*
|
||||
* @param connection The connection to disable SSL for.
|
||||
*
|
||||
* @return IDEVICE_E_SUCCESS on success, IDEVICE_E_INVALID_ARG when connection
|
||||
* is NULL. This function also returns IDEVICE_E_SUCCESS when SSL is not
|
||||
* enabled and does no further error checking on cleanup.
|
||||
*/
|
||||
idevice_error_t idevice_connection_disable_ssl(idevice_connection_t connection);
|
||||
|
||||
/* misc */
|
||||
|
||||
/**
|
||||
* Gets the handle of the device. Depends on the connection type.
|
||||
*/
|
||||
idevice_error_t idevice_get_handle(idevice_t device, uint32_t *handle);
|
||||
|
||||
/**
|
||||
* Gets the unique id for the device.
|
||||
*/
|
||||
idevice_error_t idevice_get_udid(idevice_t device, char **udid);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,448 @@
|
|||
/**
|
||||
* @file libimobiledevice/lockdown.h
|
||||
* @brief Manage device preferences, start services, pairing and activation.
|
||||
* \internal
|
||||
*
|
||||
* Copyright (c) 2009-2014 Martin S. All Rights Reserved.
|
||||
* Copyright (c) 2014 Koby Boyango All Rights Reserved.
|
||||
* Copyright (c) 2010 Bryan Forbes All Rights Reserved.
|
||||
* Copyright (c) 2008 Zach C. All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef ILOCKDOWN_H
|
||||
#define ILOCKDOWN_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <libimobiledevice/libimobiledevice.h>
|
||||
#include <libimobiledevice/lockdown.h>
|
||||
|
||||
/** Error Codes */
|
||||
typedef enum {
|
||||
/* custom */
|
||||
LOCKDOWN_E_SUCCESS = 0,
|
||||
LOCKDOWN_E_INVALID_ARG = -1,
|
||||
LOCKDOWN_E_INVALID_CONF = -2,
|
||||
LOCKDOWN_E_PLIST_ERROR = -3,
|
||||
LOCKDOWN_E_PAIRING_FAILED = -4,
|
||||
LOCKDOWN_E_SSL_ERROR = -5,
|
||||
LOCKDOWN_E_DICT_ERROR = -6,
|
||||
LOCKDOWN_E_NOT_ENOUGH_DATA = -7,
|
||||
LOCKDOWN_E_MUX_ERROR = -8,
|
||||
LOCKDOWN_E_NO_RUNNING_SESSION = -9,
|
||||
/* native */
|
||||
LOCKDOWN_E_INVALID_RESPONSE = -10,
|
||||
LOCKDOWN_E_MISSING_KEY = -11,
|
||||
LOCKDOWN_E_MISSING_VALUE = -12,
|
||||
LOCKDOWN_E_GET_PROHIBITED = -13,
|
||||
LOCKDOWN_E_SET_PROHIBITED = -14,
|
||||
LOCKDOWN_E_REMOVE_PROHIBITED = -15,
|
||||
LOCKDOWN_E_IMMUTABLE_VALUE = -16,
|
||||
LOCKDOWN_E_PASSWORD_PROTECTED = -17,
|
||||
LOCKDOWN_E_USER_DENIED_PAIRING = -18,
|
||||
LOCKDOWN_E_PAIRING_DIALOG_RESPONSE_PENDING = -19,
|
||||
LOCKDOWN_E_MISSING_HOST_ID = -20,
|
||||
LOCKDOWN_E_INVALID_HOST_ID = -21,
|
||||
LOCKDOWN_E_SESSION_ACTIVE = -22,
|
||||
LOCKDOWN_E_SESSION_INACTIVE = -23,
|
||||
LOCKDOWN_E_MISSING_SESSION_ID = -24,
|
||||
LOCKDOWN_E_INVALID_SESSION_ID = -25,
|
||||
LOCKDOWN_E_MISSING_SERVICE = -26,
|
||||
LOCKDOWN_E_INVALID_SERVICE = -27,
|
||||
LOCKDOWN_E_SERVICE_LIMIT = -28,
|
||||
LOCKDOWN_E_MISSING_PAIR_RECORD = -29,
|
||||
LOCKDOWN_E_SAVE_PAIR_RECORD_FAILED = -30,
|
||||
LOCKDOWN_E_INVALID_PAIR_RECORD = -31,
|
||||
LOCKDOWN_E_INVALID_ACTIVATION_RECORD = -32,
|
||||
LOCKDOWN_E_MISSING_ACTIVATION_RECORD = -33,
|
||||
LOCKDOWN_E_SERVICE_PROHIBITED = -34,
|
||||
LOCKDOWN_E_ESCROW_LOCKED = -35,
|
||||
LOCKDOWN_E_UNKNOWN_ERROR = -256
|
||||
} lockdownd_error_t;
|
||||
|
||||
typedef struct lockdownd_client_private lockdownd_client_private;
|
||||
typedef lockdownd_client_private *lockdownd_client_t; /**< The client handle. */
|
||||
|
||||
struct lockdownd_pair_record {
|
||||
char *device_certificate; /**< The device certificate */
|
||||
char *host_certificate; /**< The host certificate */
|
||||
char *root_certificate; /**< The root certificate */
|
||||
char *host_id; /**< A unique HostID for the host computer */
|
||||
char *system_buid; /**< A unique system id */
|
||||
};
|
||||
/** A pair record holding device, host and root certificates along the host_id */
|
||||
typedef struct lockdownd_pair_record *lockdownd_pair_record_t;
|
||||
|
||||
struct lockdownd_service_descriptor {
|
||||
uint16_t port;
|
||||
uint8_t ssl_enabled;
|
||||
};
|
||||
typedef struct lockdownd_service_descriptor *lockdownd_service_descriptor_t;
|
||||
|
||||
/* Interface */
|
||||
|
||||
/**
|
||||
* Creates a new lockdownd client for the device.
|
||||
*
|
||||
* @note This function does not pair with the device or start a session. This
|
||||
* has to be done manually by the caller after the client is created.
|
||||
* The device disconnects automatically if the lockdown connection idles
|
||||
* for more than 10 seconds. Make sure to call lockdownd_client_free() as soon
|
||||
* as the connection is no longer needed.
|
||||
*
|
||||
* @param device The device to create a lockdownd client for
|
||||
* @param client The pointer to the location of the new lockdownd_client
|
||||
* @param label The label to use for communication. Usually the program name.
|
||||
*
|
||||
* @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client is NULL
|
||||
*/
|
||||
lockdownd_error_t lockdownd_client_new(idevice_t device, lockdownd_client_t *client, const char *label);
|
||||
|
||||
/**
|
||||
* Creates a new lockdownd client for the device and starts initial handshake.
|
||||
* The handshake consists out of query_type, validate_pair, pair and
|
||||
* start_session calls. It uses the internal pairing record management.
|
||||
*
|
||||
* @note The device disconnects automatically if the lockdown connection idles
|
||||
* for more than 10 seconds. Make sure to call lockdownd_client_free() as soon
|
||||
* as the connection is no longer needed.
|
||||
*
|
||||
* @param device The device to create a lockdownd client for
|
||||
* @param client The pointer to the location of the new lockdownd_client
|
||||
* @param label The label to use for communication. Usually the program name.
|
||||
* Pass NULL to disable sending the label in requests to lockdownd.
|
||||
*
|
||||
* @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client is NULL,
|
||||
* LOCKDOWN_E_INVALID_CONF if configuration data is wrong
|
||||
*/
|
||||
lockdownd_error_t lockdownd_client_new_with_handshake(idevice_t device, lockdownd_client_t *client, const char *label);
|
||||
|
||||
/**
|
||||
* Closes the lockdownd client session if one is running and frees up the
|
||||
* lockdownd_client struct.
|
||||
*
|
||||
* @param client The lockdown client
|
||||
*
|
||||
* @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client is NULL
|
||||
*/
|
||||
lockdownd_error_t lockdownd_client_free(lockdownd_client_t client);
|
||||
|
||||
|
||||
/**
|
||||
* Query the type of the service daemon. Depending on whether the device is
|
||||
* queried in normal mode or restore mode, different types will be returned.
|
||||
*
|
||||
* @param client The lockdownd client
|
||||
* @param type The type returned by the service daemon. Pass NULL to ignore.
|
||||
*
|
||||
* @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client is NULL
|
||||
*/
|
||||
lockdownd_error_t lockdownd_query_type(lockdownd_client_t client, char **type);
|
||||
|
||||
/**
|
||||
* Retrieves a preferences plist using an optional domain and/or key name.
|
||||
*
|
||||
* @param client An initialized lockdownd client.
|
||||
* @param domain The domain to query on or NULL for global domain
|
||||
* @param key The key name to request or NULL to query for all keys
|
||||
* @param value A plist node representing the result value node
|
||||
*
|
||||
* @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client is NULL
|
||||
*/
|
||||
lockdownd_error_t lockdownd_get_value(lockdownd_client_t client, const char *domain, const char *key, plist_t *value);
|
||||
|
||||
/**
|
||||
* Sets a preferences value using a plist and optional by domain and/or key name.
|
||||
*
|
||||
* @param client an initialized lockdownd client.
|
||||
* @param domain the domain to query on or NULL for global domain
|
||||
* @param key the key name to set the value or NULL to set a value dict plist
|
||||
* @param value a plist node of any node type representing the value to set
|
||||
*
|
||||
* @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client or
|
||||
* value is NULL
|
||||
*/
|
||||
lockdownd_error_t lockdownd_set_value(lockdownd_client_t client, const char *domain, const char *key, plist_t value);
|
||||
|
||||
/**
|
||||
* Removes a preference node by domain and/or key name.
|
||||
*
|
||||
* @note: Use with caution as this could remove vital information on the device
|
||||
*
|
||||
* @param client An initialized lockdownd client.
|
||||
* @param domain The domain to query on or NULL for global domain
|
||||
* @param key The key name to remove or NULL remove all keys for the current domain
|
||||
*
|
||||
* @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client is NULL
|
||||
*/
|
||||
lockdownd_error_t lockdownd_remove_value(lockdownd_client_t client, const char *domain, const char *key);
|
||||
|
||||
/**
|
||||
* Requests to start a service and retrieve it's port on success.
|
||||
*
|
||||
* @param client The lockdownd client
|
||||
* @param identifier The identifier of the service to start
|
||||
* @param descriptor The service descriptor on success or NULL on failure
|
||||
*
|
||||
* @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG if a parameter
|
||||
* is NULL, LOCKDOWN_E_INVALID_SERVICE if the requested service is not known
|
||||
* by the device, LOCKDOWN_E_START_SERVICE_FAILED if the service could not be
|
||||
* started by the device
|
||||
*/
|
||||
lockdownd_error_t lockdownd_start_service(lockdownd_client_t client, const char *identifier, lockdownd_service_descriptor_t *service);
|
||||
|
||||
/**
|
||||
* Requests to start a service and retrieve it's port on success.
|
||||
* Sends the escrow bag from the device's pair record.
|
||||
*
|
||||
* @param client The lockdownd client
|
||||
* @param identifier The identifier of the service to start
|
||||
* @param descriptor The service descriptor on success or NULL on failure
|
||||
*
|
||||
* @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG if a parameter
|
||||
* is NULL, LOCKDOWN_E_INVALID_SERVICE if the requested service is not known
|
||||
* by the device, LOCKDOWN_E_START_SERVICE_FAILED if the service could not because
|
||||
* started by the device, LOCKDOWN_E_INVALID_CONF if the host id or escrow bag are
|
||||
* missing from the device record.
|
||||
*/
|
||||
lockdownd_error_t lockdownd_start_service_with_escrow_bag(lockdownd_client_t client, const char *identifier, lockdownd_service_descriptor_t *service);
|
||||
|
||||
/**
|
||||
* Opens a session with lockdownd and switches to SSL mode if device wants it.
|
||||
*
|
||||
* @param client The lockdownd client
|
||||
* @param host_id The HostID of the computer
|
||||
* @param session_id The new session_id of the created session
|
||||
* @param ssl_enabled Whether SSL communication is used in the session
|
||||
*
|
||||
* @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when a client
|
||||
* or host_id is NULL, LOCKDOWN_E_PLIST_ERROR if the response plist had errors,
|
||||
* LOCKDOWN_E_INVALID_HOST_ID if the device does not know the supplied HostID,
|
||||
* LOCKDOWN_E_SSL_ERROR if enabling SSL communication failed
|
||||
*/
|
||||
lockdownd_error_t lockdownd_start_session(lockdownd_client_t client, const char *host_id, char **session_id, int *ssl_enabled);
|
||||
|
||||
/**
|
||||
* Closes the lockdownd session by sending the StopSession request.
|
||||
*
|
||||
* @see lockdownd_start_session
|
||||
*
|
||||
* @param client The lockdown client
|
||||
* @param session_id The id of a running session
|
||||
*
|
||||
* @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client is NULL
|
||||
*/
|
||||
lockdownd_error_t lockdownd_stop_session(lockdownd_client_t client, const char *session_id);
|
||||
|
||||
/**
|
||||
* Sends a plist to lockdownd.
|
||||
*
|
||||
* @note This function is low-level and should only be used if you need to send
|
||||
* a new type of message.
|
||||
*
|
||||
* @param client The lockdownd client
|
||||
* @param plist The plist to send
|
||||
*
|
||||
* @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client or
|
||||
* plist is NULL
|
||||
*/
|
||||
lockdownd_error_t lockdownd_send(lockdownd_client_t client, plist_t plist);
|
||||
|
||||
/**
|
||||
* Receives a plist from lockdownd.
|
||||
*
|
||||
* @param client The lockdownd client
|
||||
* @param plist The plist to store the received data
|
||||
*
|
||||
* @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client or
|
||||
* plist is NULL
|
||||
*/
|
||||
lockdownd_error_t lockdownd_receive(lockdownd_client_t client, plist_t *plist);
|
||||
|
||||
/**
|
||||
* Pairs the device using the supplied pair record.
|
||||
*
|
||||
* @param client The lockdown client
|
||||
* @param pair_record The pair record to use for pairing. If NULL is passed, then
|
||||
* the pair records from the current machine are used. New records will be
|
||||
* generated automatically when pairing is done for the first time.
|
||||
*
|
||||
* @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client is NULL,
|
||||
* LOCKDOWN_E_PLIST_ERROR if the pair_record certificates are wrong,
|
||||
* LOCKDOWN_E_PAIRING_FAILED if the pairing failed,
|
||||
* LOCKDOWN_E_PASSWORD_PROTECTED if the device is password protected,
|
||||
* LOCKDOWN_E_INVALID_HOST_ID if the device does not know the caller's host id
|
||||
*/
|
||||
lockdownd_error_t lockdownd_pair(lockdownd_client_t client, lockdownd_pair_record_t pair_record);
|
||||
|
||||
/**
|
||||
* Validates if the device is paired with the given HostID. If successful the
|
||||
* specified host will become trusted host of the device indicated by the
|
||||
* lockdownd preference named TrustedHostAttached. Otherwise the host must be
|
||||
* paired using lockdownd_pair() first.
|
||||
*
|
||||
* @param client The lockdown client
|
||||
* @param pair_record The pair record to validate pairing with. If NULL is
|
||||
* passed, then the pair record is read from the internal pairing record
|
||||
* management.
|
||||
*
|
||||
* @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client is NULL,
|
||||
* LOCKDOWN_E_PLIST_ERROR if the pair_record certificates are wrong,
|
||||
* LOCKDOWN_E_PAIRING_FAILED if the pairing failed,
|
||||
* LOCKDOWN_E_PASSWORD_PROTECTED if the device is password protected,
|
||||
* LOCKDOWN_E_INVALID_HOST_ID if the device does not know the caller's host id
|
||||
*/
|
||||
lockdownd_error_t lockdownd_validate_pair(lockdownd_client_t client, lockdownd_pair_record_t pair_record);
|
||||
|
||||
/**
|
||||
* Unpairs the device with the given HostID and removes the pairing records
|
||||
* from the device and host if the internal pairing record management is used.
|
||||
*
|
||||
* @param client The lockdown client
|
||||
* @param pair_record The pair record to use for unpair. If NULL is passed, then
|
||||
* the pair records from the current machine are used.
|
||||
*
|
||||
* @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client is NULL,
|
||||
* LOCKDOWN_E_PLIST_ERROR if the pair_record certificates are wrong,
|
||||
* LOCKDOWN_E_PAIRING_FAILED if the pairing failed,
|
||||
* LOCKDOWN_E_PASSWORD_PROTECTED if the device is password protected,
|
||||
* LOCKDOWN_E_INVALID_HOST_ID if the device does not know the caller's host id
|
||||
*/
|
||||
lockdownd_error_t lockdownd_unpair(lockdownd_client_t client, lockdownd_pair_record_t pair_record);
|
||||
|
||||
/**
|
||||
* Activates the device. Only works within an open session.
|
||||
* The ActivationRecord plist dictionary must be obtained using the
|
||||
* activation protocol requesting from Apple's https webservice.
|
||||
*
|
||||
* @param client The lockdown client
|
||||
* @param activation_record The activation record plist dictionary
|
||||
*
|
||||
* @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client or
|
||||
* activation_record is NULL, LOCKDOWN_E_NO_RUNNING_SESSION if no session is
|
||||
* open, LOCKDOWN_E_PLIST_ERROR if the received plist is broken,
|
||||
* LOCKDOWN_E_ACTIVATION_FAILED if the activation failed,
|
||||
* LOCKDOWN_E_INVALID_ACTIVATION_RECORD if the device reports that the
|
||||
* activation_record is invalid
|
||||
*/
|
||||
lockdownd_error_t lockdownd_activate(lockdownd_client_t client, plist_t activation_record);
|
||||
|
||||
/**
|
||||
* Deactivates the device, returning it to the locked “Activate with iTunes”
|
||||
* screen.
|
||||
*
|
||||
* @param client The lockdown client
|
||||
*
|
||||
* @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client is NULL,
|
||||
* LOCKDOWN_E_NO_RUNNING_SESSION if no session is open,
|
||||
* LOCKDOWN_E_PLIST_ERROR if the received plist is broken
|
||||
*/
|
||||
lockdownd_error_t lockdownd_deactivate(lockdownd_client_t client);
|
||||
|
||||
/**
|
||||
* Tells the device to immediately enter recovery mode.
|
||||
*
|
||||
* @param client The lockdown client
|
||||
*
|
||||
* @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client is NULL
|
||||
*/
|
||||
lockdownd_error_t lockdownd_enter_recovery(lockdownd_client_t client);
|
||||
|
||||
/**
|
||||
* Sends the Goodbye request to lockdownd signaling the end of communication.
|
||||
*
|
||||
* @param client The lockdown client
|
||||
*
|
||||
* @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client
|
||||
* is NULL, LOCKDOWN_E_PLIST_ERROR if the device did not acknowledge the
|
||||
* request
|
||||
*/
|
||||
lockdownd_error_t lockdownd_goodbye(lockdownd_client_t client);
|
||||
|
||||
/* Helper */
|
||||
|
||||
/**
|
||||
* Sets the label to send for requests to lockdownd.
|
||||
*
|
||||
* @param client The lockdown client
|
||||
* @param label The label to set or NULL to disable sending a label
|
||||
*
|
||||
*/
|
||||
void lockdownd_client_set_label(lockdownd_client_t client, const char *label);
|
||||
|
||||
/**
|
||||
* Returns the unique id of the device from lockdownd.
|
||||
*
|
||||
* @param client An initialized lockdownd client.
|
||||
* @param udid Holds the unique id of the device. The caller is responsible
|
||||
* for freeing the memory.
|
||||
*
|
||||
* @return LOCKDOWN_E_SUCCESS on success
|
||||
*/
|
||||
lockdownd_error_t lockdownd_get_device_udid(lockdownd_client_t control, char **udid);
|
||||
|
||||
/**
|
||||
* Retrieves the name of the device from lockdownd set by the user.
|
||||
*
|
||||
* @param client An initialized lockdownd client.
|
||||
* @param device_name Holds the name of the device. The caller is
|
||||
* responsible for freeing the memory.
|
||||
*
|
||||
* @return LOCKDOWN_E_SUCCESS on success
|
||||
*/
|
||||
lockdownd_error_t lockdownd_get_device_name(lockdownd_client_t client, char **device_name);
|
||||
|
||||
/**
|
||||
* Calculates and returns the data classes the device supports from lockdownd.
|
||||
*
|
||||
* @param client An initialized lockdownd client.
|
||||
* @param classes A pointer to store an array of class names. The caller is responsible
|
||||
* for freeing the memory which can be done using mobilesync_data_classes_free().
|
||||
* @param count The number of items in the classes array.
|
||||
*
|
||||
* @return LOCKDOWN_E_SUCCESS on success,
|
||||
* LOCKDOWN_E_INVALID_ARG when client is NULL,
|
||||
* LOCKDOWN_E_NO_RUNNING_SESSION if no session is open,
|
||||
* LOCKDOWN_E_PLIST_ERROR if the received plist is broken
|
||||
*/
|
||||
lockdownd_error_t lockdownd_get_sync_data_classes(lockdownd_client_t client, char ***classes, int *count);
|
||||
|
||||
/**
|
||||
* Frees memory of an allocated array of data classes as returned by lockdownd_get_sync_data_classes()
|
||||
*
|
||||
* @param classes An array of class names to free.
|
||||
*
|
||||
* @return LOCKDOWN_E_SUCCESS on success
|
||||
*/
|
||||
lockdownd_error_t lockdownd_data_classes_free(char **classes);
|
||||
|
||||
/**
|
||||
* Frees memory of a service descriptor as returned by lockdownd_start_service()
|
||||
*
|
||||
* @param sevice A service descriptor instance to free.
|
||||
*
|
||||
* @return LOCKDOWN_E_SUCCESS on success
|
||||
*/
|
||||
lockdownd_error_t lockdownd_service_descriptor_free(lockdownd_service_descriptor_t service);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,145 @@
|
|||
/**
|
||||
* @file libimobiledevice/misagent.h
|
||||
* @brief Manage provisioning profiles.
|
||||
* \internal
|
||||
*
|
||||
* Copyright (c) 2013-2014 Martin Szulecki All Rights Reserved.
|
||||
* Copyright (c) 2012 Nikias Bassen All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef IMISAGENT_H
|
||||
#define IMISAGENT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <libimobiledevice/libimobiledevice.h>
|
||||
#include <libimobiledevice/lockdown.h>
|
||||
|
||||
#define MISAGENT_SERVICE_NAME "com.apple.misagent"
|
||||
|
||||
/** Error Codes */
|
||||
typedef enum {
|
||||
MISAGENT_E_SUCCESS = 0,
|
||||
MISAGENT_E_INVALID_ARG = -1,
|
||||
MISAGENT_E_PLIST_ERROR = -2,
|
||||
MISAGENT_E_CONN_FAILED = -3,
|
||||
MISAGENT_E_REQUEST_FAILED = -4,
|
||||
MISAGENT_E_UNKNOWN_ERROR = -256
|
||||
} misagent_error_t;
|
||||
|
||||
typedef struct misagent_client_private misagent_client_private;
|
||||
typedef misagent_client_private *misagent_client_t; /**< The client handle. */
|
||||
|
||||
/* Interface */
|
||||
|
||||
/**
|
||||
* Connects to the misagent service on the specified device.
|
||||
*
|
||||
* @param device The device to connect to.
|
||||
* @param service The service descriptor returned by lockdownd_start_service.
|
||||
* @param client Pointer that will point to a newly allocated
|
||||
* misagent_client_t upon successful return.
|
||||
*
|
||||
* @return MISAGENT_E_SUCCESS on success, MISAGENT_E_INVALID_ARG when
|
||||
* client is NULL, or an MISAGENT_E_* error code otherwise.
|
||||
*/
|
||||
misagent_error_t misagent_client_new(idevice_t device, lockdownd_service_descriptor_t service, misagent_client_t *client);
|
||||
|
||||
/**
|
||||
* Starts a new misagent service on the specified device and connects to it.
|
||||
*
|
||||
* @param device The device to connect to.
|
||||
* @param client Pointer that will point to a newly allocated
|
||||
* misagent_client_t upon successful return. Must be freed using
|
||||
* misagent_client_free() after use.
|
||||
* @param label The label to use for communication. Usually the program name.
|
||||
* Pass NULL to disable sending the label in requests to lockdownd.
|
||||
*
|
||||
* @return MISAGENT_E_SUCCESS on success, or an MISAGENT_E_* error
|
||||
* code otherwise.
|
||||
*/
|
||||
misagent_error_t misagent_client_start_service(idevice_t device, misagent_client_t* client, const char* label);
|
||||
|
||||
/**
|
||||
* Disconnects an misagent client from the device and frees up the
|
||||
* misagent client data.
|
||||
*
|
||||
* @param client The misagent client to disconnect and free.
|
||||
*
|
||||
* @return MISAGENT_E_SUCCESS on success, MISAGENT_E_INVALID_ARG when
|
||||
* client is NULL, or an MISAGENT_E_* error code otherwise.
|
||||
*/
|
||||
misagent_error_t misagent_client_free(misagent_client_t client);
|
||||
|
||||
|
||||
/**
|
||||
* Installs the given provisioning profile. Only works with valid profiles.
|
||||
*
|
||||
* @param client The connected misagent to use for installation
|
||||
* @param profile The valid provisioning profile to install. This has to be
|
||||
* passed as a PLIST_DATA, otherwise the function will fail.
|
||||
*
|
||||
* @return MISAGENT_E_SUCCESS on success, MISAGENT_E_INVALID_ARG when
|
||||
* client is invalid, or an MISAGENT_E_* error code otherwise.
|
||||
*/
|
||||
misagent_error_t misagent_install(misagent_client_t client, plist_t profile);
|
||||
|
||||
/**
|
||||
* Retrieves an array of all installed provisioning profiles.
|
||||
*
|
||||
* @param client The connected misagent to use.
|
||||
* @param profiles Pointer to a plist_t that will be set to a PLIST_ARRAY
|
||||
* if the function is successful.
|
||||
*
|
||||
* @return MISAGENT_E_SUCCESS on success, MISAGENT_E_INVALID_ARG when
|
||||
* client is invalid, or an MISAGENT_E_* error code otherwise.
|
||||
*
|
||||
* @note If no provisioning profiles are installed on the device, this function
|
||||
* still returns MISAGENT_E_SUCCESS and profiles will just point to an
|
||||
* empty array.
|
||||
*/
|
||||
misagent_error_t misagent_copy(misagent_client_t client, plist_t* profiles);
|
||||
|
||||
/**
|
||||
* Removes a given provisioning profile.
|
||||
*
|
||||
* @param client The connected misagent to use.
|
||||
* @param profileID Identifier of the provisioning profile to remove.
|
||||
* This is a UUID that can be obtained from the provisioning profile data.
|
||||
* @see misagent_copy
|
||||
*
|
||||
* @return MISAGENT_E_SUCCESS on success, MISAGENT_E_INVALID_ARG when
|
||||
* client is invalid, or an MISAGENT_E_* error code otherwise.
|
||||
*/
|
||||
misagent_error_t misagent_remove(misagent_client_t client, const char* profileID);
|
||||
|
||||
/**
|
||||
* Retrieves the status code from the last operation.
|
||||
*
|
||||
* @param client The misagent to use.
|
||||
*
|
||||
* @return -1 if client is invalid, or the status code from the last operation
|
||||
*/
|
||||
int misagent_get_status_code(misagent_client_t client);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,170 @@
|
|||
/**
|
||||
* @file libimobiledevice/mobile_image_mounter.h
|
||||
* @brief Mount developer/debug disk images on the device.
|
||||
* \internal
|
||||
*
|
||||
* Copyright (c) 2010-2014 Martin Szulecki All Rights Reserved.
|
||||
* Copyright (c) 2010-2014 Nikias Bassen All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef IMOBILE_IMAGE_MOUNTER_H
|
||||
#define IMOBILE_IMAGE_MOUNTER_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <libimobiledevice/libimobiledevice.h>
|
||||
#include <libimobiledevice/lockdown.h>
|
||||
|
||||
#define MOBILE_IMAGE_MOUNTER_SERVICE_NAME "com.apple.mobile.mobile_image_mounter"
|
||||
|
||||
/** Error Codes */
|
||||
typedef enum {
|
||||
MOBILE_IMAGE_MOUNTER_E_SUCCESS = 0,
|
||||
MOBILE_IMAGE_MOUNTER_E_INVALID_ARG = -1,
|
||||
MOBILE_IMAGE_MOUNTER_E_PLIST_ERROR = -2,
|
||||
MOBILE_IMAGE_MOUNTER_E_CONN_FAILED = -3,
|
||||
MOBILE_IMAGE_MOUNTER_E_COMMAND_FAILED = -4,
|
||||
MOBILE_IMAGE_MOUNTER_E_UNKNOWN_ERROR = -256
|
||||
} mobile_image_mounter_error_t;
|
||||
|
||||
typedef struct mobile_image_mounter_client_private mobile_image_mounter_client_private;
|
||||
typedef mobile_image_mounter_client_private *mobile_image_mounter_client_t; /**< The client handle. */
|
||||
|
||||
/** callback for image upload */
|
||||
typedef ssize_t (*mobile_image_mounter_upload_cb_t) (void* buffer, size_t length, void *user_data);
|
||||
|
||||
/* Interface */
|
||||
|
||||
/**
|
||||
* Connects to the mobile_image_mounter service on the specified device.
|
||||
*
|
||||
* @param device The device to connect to.
|
||||
* @param service The service descriptor returned by lockdownd_start_service.
|
||||
* @param client Pointer that will be set to a newly allocated
|
||||
* mobile_image_mounter_client_t upon successful return.
|
||||
*
|
||||
* @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on success,
|
||||
* MOBILE_IMAGE_MOUNTER_E_INVALID_ARG if device is NULL,
|
||||
* or MOBILE_IMAGE_MOUNTER_E_CONN_FAILED if the connection to the
|
||||
* device could not be established.
|
||||
*/
|
||||
mobile_image_mounter_error_t mobile_image_mounter_new(idevice_t device, lockdownd_service_descriptor_t service, mobile_image_mounter_client_t *client);
|
||||
|
||||
/**
|
||||
* Starts a new mobile_image_mounter service on the specified device and connects to it.
|
||||
*
|
||||
* @param device The device to connect to.
|
||||
* @param client Pointer that will point to a newly allocated
|
||||
* mobile_image_mounter_t upon successful return. Must be freed using
|
||||
* mobile_image_mounter_free() after use.
|
||||
* @param label The label to use for communication. Usually the program name.
|
||||
* Pass NULL to disable sending the label in requests to lockdownd.
|
||||
*
|
||||
* @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on success, or an MOBILE_IMAGE_MOUNTER_E_* error
|
||||
* code otherwise.
|
||||
*/
|
||||
mobile_image_mounter_error_t mobile_image_mounter_start_service(idevice_t device, mobile_image_mounter_client_t* client, const char* label);
|
||||
|
||||
/**
|
||||
* Disconnects a mobile_image_mounter client from the device and frees up the
|
||||
* mobile_image_mounter client data.
|
||||
*
|
||||
* @param client The mobile_image_mounter client to disconnect and free.
|
||||
*
|
||||
* @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on success,
|
||||
* or MOBILE_IMAGE_MOUNTER_E_INVALID_ARG if client is NULL.
|
||||
*/
|
||||
mobile_image_mounter_error_t mobile_image_mounter_free(mobile_image_mounter_client_t client);
|
||||
|
||||
|
||||
/**
|
||||
* Tells if the image of ImageType is already mounted.
|
||||
*
|
||||
* @param client The client use
|
||||
* @param image_type The type of the image to look up
|
||||
* @param result Pointer to a plist that will receive the result of the
|
||||
* operation.
|
||||
*
|
||||
* @note This function may return MOBILE_IMAGE_MOUNTER_E_SUCCESS even if the
|
||||
* operation has failed. Check the resulting plist for further information.
|
||||
*
|
||||
* @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on success, or an error code on error
|
||||
*/
|
||||
mobile_image_mounter_error_t mobile_image_mounter_lookup_image(mobile_image_mounter_client_t client, const char *image_type, plist_t *result);
|
||||
|
||||
/**
|
||||
* Uploads an image with an optional signature to the device.
|
||||
*
|
||||
* @param client The connected mobile_image_mounter client.
|
||||
* @param image_type Type of image that is being uploaded.
|
||||
* @param image_size Total size of the image.
|
||||
* @param signature Buffer with a signature of the image being uploaded. If
|
||||
* NULL, no signature will be used.
|
||||
* @param signature_size Total size of the image signature buffer. If 0, no
|
||||
* signature will be used.
|
||||
* @param upload_cb Callback function that gets the data chunks for uploading
|
||||
* the image.
|
||||
* @param userdata User defined data for the upload callback function.
|
||||
*
|
||||
* @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on succes, or a
|
||||
* MOBILE_IMAGE_MOUNTER_E_* error code otherwise.
|
||||
*/
|
||||
mobile_image_mounter_error_t mobile_image_mounter_upload_image(mobile_image_mounter_client_t client, const char *image_type, size_t image_size, const char *signature, uint16_t signature_size, mobile_image_mounter_upload_cb_t upload_cb, void* userdata);
|
||||
|
||||
/**
|
||||
* Mounts an image on the device.
|
||||
*
|
||||
* @param client The connected mobile_image_mounter client.
|
||||
* @param image_path The absolute path of the image to mount. The image must
|
||||
* be present before calling this function.
|
||||
* @param signature Pointer to a buffer holding the images' signature
|
||||
* @param signature_size Length of the signature image_signature points to
|
||||
* @param image_type Type of image to mount
|
||||
* @param result Pointer to a plist that will receive the result of the
|
||||
* operation.
|
||||
*
|
||||
* @note This function may return MOBILE_IMAGE_MOUNTER_E_SUCCESS even if the
|
||||
* operation has failed. Check the resulting plist for further information.
|
||||
* Note that there is no unmounting function. The mount persists until the
|
||||
* device is rebooted.
|
||||
*
|
||||
* @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on success,
|
||||
* MOBILE_IMAGE_MOUNTER_E_INVALID_ARG if on ore more parameters are
|
||||
* invalid, or another error code otherwise.
|
||||
*/
|
||||
mobile_image_mounter_error_t mobile_image_mounter_mount_image(mobile_image_mounter_client_t client, const char *image_path, const char *signature, uint16_t signature_size, const char *image_type, plist_t *result);
|
||||
|
||||
/**
|
||||
* Hangs up the connection to the mobile_image_mounter service.
|
||||
* This functions has to be called before freeing up a mobile_image_mounter
|
||||
* instance. If not, errors appear in the device's syslog.
|
||||
*
|
||||
* @param client The client to hang up
|
||||
*
|
||||
* @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on success,
|
||||
* MOBILE_IMAGE_MOUNTER_E_INVALID_ARG if client is invalid,
|
||||
* or another error code otherwise.
|
||||
*/
|
||||
mobile_image_mounter_error_t mobile_image_mounter_hangup(mobile_image_mounter_client_t client);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,242 @@
|
|||
/**
|
||||
* @file libimobiledevice/mobilebackup.h
|
||||
* @brief Backup and restore of all device data.
|
||||
* \internal
|
||||
*
|
||||
* Copyright (c) 2009-2014 Martin Szulecki All Rights Reserved.
|
||||
* Copyright (c) 2010 Nikias Bassen All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef IMOBILEBACKUP_H
|
||||
#define IMOBILEBACKUP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <libimobiledevice/libimobiledevice.h>
|
||||
#include <libimobiledevice/lockdown.h>
|
||||
|
||||
#define MOBILEBACKUP_SERVICE_NAME "com.apple.mobilebackup"
|
||||
|
||||
/** Error Codes */
|
||||
typedef enum {
|
||||
MOBILEBACKUP_E_SUCCESS = 0,
|
||||
MOBILEBACKUP_E_INVALID_ARG = -1,
|
||||
MOBILEBACKUP_E_PLIST_ERROR = -2,
|
||||
MOBILEBACKUP_E_MUX_ERROR = -3,
|
||||
MOBILEBACKUP_E_BAD_VERSION = -4,
|
||||
MOBILEBACKUP_E_REPLY_NOT_OK = -5,
|
||||
MOBILEBACKUP_E_UNKNOWN_ERROR = -256
|
||||
} mobilebackup_error_t;
|
||||
|
||||
typedef struct mobilebackup_client_private mobilebackup_client_private;
|
||||
typedef mobilebackup_client_private *mobilebackup_client_t; /**< The client handle. */
|
||||
|
||||
typedef enum {
|
||||
MB_RESTORE_NOTIFY_SPRINGBOARD = 1 << 0,
|
||||
MB_RESTORE_PRESERVE_SETTINGS = 1 << 1,
|
||||
MB_RESTORE_PRESERVE_CAMERA_ROLL = 1 << 2
|
||||
} mobilebackup_flags_t;
|
||||
|
||||
/**
|
||||
* Connects to the mobilebackup service on the specified device.
|
||||
*
|
||||
* @param device The device to connect to.
|
||||
* @param service The service descriptor returned by lockdownd_start_service.
|
||||
* @param client Pointer that will be set to a newly allocated
|
||||
* mobilebackup_client_t upon successful return.
|
||||
*
|
||||
* @return MOBILEBACKUP_E_SUCCESS on success, MOBILEBACKUP_E_INVALID ARG if one
|
||||
* or more parameters are invalid, or DEVICE_LINK_SERVICE_E_BAD_VERSION if
|
||||
* the mobilebackup version on the device is newer.
|
||||
*/
|
||||
mobilebackup_error_t mobilebackup_client_new(idevice_t device, lockdownd_service_descriptor_t service, mobilebackup_client_t * client);
|
||||
|
||||
/**
|
||||
* Starts a new mobilebackup service on the specified device and connects to it.
|
||||
*
|
||||
* @param device The device to connect to.
|
||||
* @param client Pointer that will point to a newly allocated
|
||||
* mobilebackup_client_t upon successful return. Must be freed using
|
||||
* mobilebackup_client_free() after use.
|
||||
* @param label The label to use for communication. Usually the program name.
|
||||
* Pass NULL to disable sending the label in requests to lockdownd.
|
||||
*
|
||||
* @return MOBILEBACKUP_E_SUCCESS on success, or an MOBILEBACKUP_E_* error
|
||||
* code otherwise.
|
||||
*/
|
||||
mobilebackup_error_t mobilebackup_client_start_service(idevice_t device, mobilebackup_client_t* client, const char* label);
|
||||
|
||||
/**
|
||||
* Disconnects a mobilebackup client from the device and frees up the
|
||||
* mobilebackup client data.
|
||||
*
|
||||
* @param client The mobilebackup client to disconnect and free.
|
||||
*
|
||||
* @return MOBILEBACKUP_E_SUCCESS on success, or MOBILEBACKUP_E_INVALID_ARG
|
||||
* if client is NULL.
|
||||
*/
|
||||
mobilebackup_error_t mobilebackup_client_free(mobilebackup_client_t client);
|
||||
|
||||
|
||||
/**
|
||||
* Polls the device for mobilebackup data.
|
||||
*
|
||||
* @param client The mobilebackup client
|
||||
* @param plist A pointer to the location where the plist should be stored
|
||||
*
|
||||
* @return an error code
|
||||
*/
|
||||
mobilebackup_error_t mobilebackup_receive(mobilebackup_client_t client, plist_t *plist);
|
||||
|
||||
/**
|
||||
* Sends mobilebackup data to the device
|
||||
*
|
||||
* @note This function is low-level and should only be used if you need to send
|
||||
* a new type of message.
|
||||
*
|
||||
* @param client The mobilebackup client
|
||||
* @param plist The location of the plist to send
|
||||
*
|
||||
* @return an error code
|
||||
*/
|
||||
mobilebackup_error_t mobilebackup_send(mobilebackup_client_t client, plist_t plist);
|
||||
|
||||
/**
|
||||
* Request a backup from the connected device.
|
||||
*
|
||||
* @param client The connected MobileBackup client to use.
|
||||
* @param backup_manifest The backup manifest, a plist_t of type PLIST_DICT
|
||||
* containing the backup state of the last backup. For a first-time backup
|
||||
* set this parameter to NULL.
|
||||
* @param base_path The base path on the device to use for the backup
|
||||
* operation, usually "/".
|
||||
* @param proto_version A string denoting the version of the backup protocol
|
||||
* to use. Latest known version is "1.6"
|
||||
*
|
||||
* @return MOBILEBACKUP_E_SUCCESS on success, MOBILEBACKUP_E_INVALID_ARG if
|
||||
* one of the parameters is invalid, MOBILEBACKUP_E_PLIST_ERROR if
|
||||
* backup_manifest is not of type PLIST_DICT, MOBILEBACKUP_E_MUX_ERROR
|
||||
* if a communication error occurs, MOBILEBACKUP_E_REPLY_NOT_OK
|
||||
*/
|
||||
mobilebackup_error_t mobilebackup_request_backup(mobilebackup_client_t client, plist_t backup_manifest, const char *base_path, const char *proto_version);
|
||||
|
||||
/**
|
||||
* Sends a confirmation to the device that a backup file has been received.
|
||||
*
|
||||
* @param client The connected MobileBackup client to use.
|
||||
*
|
||||
* @return MOBILEBACKUP_E_SUCCESS on success, MOBILEBACKUP_E_INVALID_ARG if
|
||||
* client is invalid, or MOBILEBACKUP_E_MUX_ERROR if a communication error
|
||||
* occurs.
|
||||
*/
|
||||
mobilebackup_error_t mobilebackup_send_backup_file_received(mobilebackup_client_t client);
|
||||
|
||||
/**
|
||||
* Request that a backup should be restored to the connected device.
|
||||
*
|
||||
* @param client The connected MobileBackup client to use.
|
||||
* @param backup_manifest The backup manifest, a plist_t of type PLIST_DICT
|
||||
* containing the backup state to be restored.
|
||||
* @param flags Flags to send with the request. Currently this is a combination
|
||||
* of the following mobilebackup_flags_t:
|
||||
* MB_RESTORE_NOTIFY_SPRINGBOARD - let SpringBoard show a 'Restore' screen
|
||||
* MB_RESTORE_PRESERVE_SETTINGS - do not overwrite any settings
|
||||
* MB_RESTORE_PRESERVE_CAMERA_ROLL - preserve the photos of the camera roll
|
||||
* @param proto_version A string denoting the version of the backup protocol
|
||||
* to use. Latest known version is "1.6". Ideally this value should be
|
||||
* extracted from the given manifest plist.
|
||||
*
|
||||
* @return MOBILEBACKUP_E_SUCCESS on success, MOBILEBACKUP_E_INVALID_ARG if
|
||||
* one of the parameters is invalid, MOBILEBACKUP_E_PLIST_ERROR if
|
||||
* backup_manifest is not of type PLIST_DICT, MOBILEBACKUP_E_MUX_ERROR
|
||||
* if a communication error occurs, or MOBILEBACKUP_E_REPLY_NOT_OK
|
||||
* if the device did not accept the request.
|
||||
*/
|
||||
mobilebackup_error_t mobilebackup_request_restore(mobilebackup_client_t client, plist_t backup_manifest, mobilebackup_flags_t flags, const char *proto_version);
|
||||
|
||||
/**
|
||||
* Receive a confirmation from the device that it successfully received
|
||||
* a restore file.
|
||||
*
|
||||
* @param client The connected MobileBackup client to use.
|
||||
* @param result Pointer to a plist_t that will be set to the received plist
|
||||
* for further processing. The caller has to free it using plist_free().
|
||||
* Note that it will be set to NULL if the operation itself fails due to
|
||||
* a communication or plist error.
|
||||
* If this parameter is NULL, it will be ignored.
|
||||
*
|
||||
* @return MOBILEBACKUP_E_SUCCESS on success, MOBILEBACKUP_E_INVALID_ARG if
|
||||
* client is invalid, MOBILEBACKUP_E_REPLY_NOT_OK if the expected
|
||||
* 'BackupMessageRestoreFileReceived' message could not be received,
|
||||
* MOBILEBACKUP_E_PLIST_ERROR if the received message is not a valid backup
|
||||
* message plist, or MOBILEBACKUP_E_MUX_ERROR if a communication error
|
||||
* occurs.
|
||||
*/
|
||||
mobilebackup_error_t mobilebackup_receive_restore_file_received(mobilebackup_client_t client, plist_t *result);
|
||||
|
||||
/**
|
||||
* Receive a confirmation from the device that it successfully received
|
||||
* application data file.
|
||||
*
|
||||
* @param client The connected MobileBackup client to use.
|
||||
* @param result Pointer to a plist_t that will be set to the received plist
|
||||
* for further processing. The caller has to free it using plist_free().
|
||||
* Note that it will be set to NULL if the operation itself fails due to
|
||||
* a communication or plist error.
|
||||
* If this parameter is NULL, it will be ignored.
|
||||
*
|
||||
* @return MOBILEBACKUP_E_SUCCESS on success, MOBILEBACKUP_E_INVALID_ARG if
|
||||
* client is invalid, MOBILEBACKUP_E_REPLY_NOT_OK if the expected
|
||||
* 'BackupMessageRestoreApplicationReceived' message could not be received,
|
||||
* MOBILEBACKUP_E_PLIST_ERROR if the received message is not a valid backup
|
||||
* message plist, or MOBILEBACKUP_E_MUX_ERROR if a communication error
|
||||
* occurs.
|
||||
*/
|
||||
mobilebackup_error_t mobilebackup_receive_restore_application_received(mobilebackup_client_t client, plist_t *result);
|
||||
|
||||
/**
|
||||
* Tells the device that the restore process is complete and waits for the
|
||||
* device to close the connection. After that, the device should reboot.
|
||||
*
|
||||
* @param client The connected MobileBackup client to use.
|
||||
*
|
||||
* @return MOBILEBACKUP_E_SUCCESS on success, MOBILEBACKUP_E_INVALID_ARG if
|
||||
* client is invalid, MOBILEBACKUP_E_PLIST_ERROR if the received disconnect
|
||||
* message plist is invalid, or MOBILEBACKUP_E_MUX_ERROR if a communication
|
||||
* error occurs.
|
||||
*/
|
||||
mobilebackup_error_t mobilebackup_send_restore_complete(mobilebackup_client_t client);
|
||||
|
||||
/**
|
||||
* Sends a backup error message to the device.
|
||||
*
|
||||
* @param client The connected MobileBackup client to use.
|
||||
* @param reason A string describing the reason for the error message.
|
||||
*
|
||||
* @return MOBILEBACKUP_E_SUCCESS on success, MOBILEBACKUP_E_INVALID_ARG if
|
||||
* one of the parameters is invalid, or MOBILEBACKUP_E_MUX_ERROR if a
|
||||
* communication error occurs.
|
||||
*/
|
||||
mobilebackup_error_t mobilebackup_send_error(mobilebackup_client_t client, const char *reason);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,211 @@
|
|||
/**
|
||||
* @file libimobiledevice/mobilebackup2.h
|
||||
* @brief Backup and restore of all device data (mobilebackup2, iOS4+ only)
|
||||
* \internal
|
||||
*
|
||||
* Copyright (c) 2011-2014 Martin Szulecki All Rights Reserved.
|
||||
* Copyright (c) 2010-2012 Nikias Bassen All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef IMOBILEBACKUP2_H
|
||||
#define IMOBILEBACKUP2_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <libimobiledevice/libimobiledevice.h>
|
||||
#include <libimobiledevice/lockdown.h>
|
||||
|
||||
#define MOBILEBACKUP2_SERVICE_NAME "com.apple.mobilebackup2"
|
||||
|
||||
/** Error Codes */
|
||||
typedef enum {
|
||||
MOBILEBACKUP2_E_SUCCESS = 0,
|
||||
MOBILEBACKUP2_E_INVALID_ARG = -1,
|
||||
MOBILEBACKUP2_E_PLIST_ERROR = -2,
|
||||
MOBILEBACKUP2_E_MUX_ERROR = -3,
|
||||
MOBILEBACKUP2_E_BAD_VERSION = -4,
|
||||
MOBILEBACKUP2_E_REPLY_NOT_OK = -5,
|
||||
MOBILEBACKUP2_E_NO_COMMON_VERSION = -6,
|
||||
MOBILEBACKUP2_E_UNKNOWN_ERROR = -256
|
||||
} mobilebackup2_error_t;
|
||||
|
||||
typedef struct mobilebackup2_client_private mobilebackup2_client_private;
|
||||
typedef mobilebackup2_client_private *mobilebackup2_client_t; /**< The client handle. */
|
||||
|
||||
|
||||
/**
|
||||
* Connects to the mobilebackup2 service on the specified device.
|
||||
*
|
||||
* @param device The device to connect to.
|
||||
* @param service The service descriptor returned by lockdownd_start_service.
|
||||
* @param client Pointer that will be set to a newly allocated
|
||||
* mobilebackup2_client_t upon successful return.
|
||||
*
|
||||
* @return MOBILEBACKUP2_E_SUCCESS on success, MOBILEBACKUP2_E_INVALID ARG
|
||||
* if one or more parameter is invalid, or MOBILEBACKUP2_E_BAD_VERSION
|
||||
* if the mobilebackup2 version on the device is newer.
|
||||
*/
|
||||
mobilebackup2_error_t mobilebackup2_client_new(idevice_t device, lockdownd_service_descriptor_t service, mobilebackup2_client_t * client);
|
||||
|
||||
/**
|
||||
* Starts a new mobilebackup2 service on the specified device and connects to it.
|
||||
*
|
||||
* @param device The device to connect to.
|
||||
* @param client Pointer that will point to a newly allocated
|
||||
* mobilebackup2_client_t upon successful return. Must be freed using
|
||||
* mobilebackup2_client_free() after use.
|
||||
* @param label The label to use for communication. Usually the program name.
|
||||
* Pass NULL to disable sending the label in requests to lockdownd.
|
||||
*
|
||||
* @return MOBILEBACKUP2_E_SUCCESS on success, or an MOBILEBACKUP2_E_* error
|
||||
* code otherwise.
|
||||
*/
|
||||
mobilebackup2_error_t mobilebackup2_client_start_service(idevice_t device, mobilebackup2_client_t* client, const char* label);
|
||||
|
||||
/**
|
||||
* Disconnects a mobilebackup2 client from the device and frees up the
|
||||
* mobilebackup2 client data.
|
||||
*
|
||||
* @param client The mobilebackup2 client to disconnect and free.
|
||||
*
|
||||
* @return MOBILEBACKUP2_E_SUCCESS on success, or MOBILEBACKUP2_E_INVALID_ARG
|
||||
* if client is NULL.
|
||||
*/
|
||||
mobilebackup2_error_t mobilebackup2_client_free(mobilebackup2_client_t client);
|
||||
|
||||
|
||||
/**
|
||||
* Sends a backup message plist.
|
||||
*
|
||||
* @param client The connected MobileBackup client to use.
|
||||
* @param message The message to send. This will be inserted into the request
|
||||
* plist as value for MessageName. If this parameter is NULL,
|
||||
* the plist passed in the options parameter will be sent directly.
|
||||
* @param options Additional options as PLIST_DICT to add to the request.
|
||||
* The MessageName key with the value passed in the message parameter
|
||||
* will be inserted into this plist before sending it. This parameter
|
||||
* can be NULL if message is not NULL.
|
||||
*/
|
||||
mobilebackup2_error_t mobilebackup2_send_message(mobilebackup2_client_t client, const char *message, plist_t options);
|
||||
|
||||
/**
|
||||
* Receives a DL* message plist from the device.
|
||||
* This function is a wrapper around device_link_service_receive_message.
|
||||
*
|
||||
* @param client The connected MobileBackup client to use.
|
||||
* @param msg_plist Pointer to a plist that will be set to the contents of the
|
||||
* message plist upon successful return.
|
||||
* @param dlmessage A pointer that will be set to a newly allocated char*
|
||||
* containing the DL* string from the given plist. It is up to the caller
|
||||
* to free the allocated memory. If this parameter is NULL
|
||||
* it will be ignored.
|
||||
*
|
||||
* @return MOBILEBACKUP2_E_SUCCESS if a DL* message was received,
|
||||
* MOBILEBACKUP2_E_INVALID_ARG if client or message is invalid,
|
||||
* MOBILEBACKUP2_E_PLIST_ERROR if the received plist is invalid
|
||||
* or is not a DL* message plist, or MOBILEBACKUP2_E_MUX_ERROR if
|
||||
* receiving from the device failed.
|
||||
*/
|
||||
mobilebackup2_error_t mobilebackup2_receive_message(mobilebackup2_client_t client, plist_t *msg_plist, char **dlmessage);
|
||||
|
||||
/**
|
||||
* Send binary data to the device.
|
||||
*
|
||||
* @note This function returns MOBILEBACKUP2_E_SUCCESS even if less than the
|
||||
* requested length has been sent. The fourth parameter is required and
|
||||
* must be checked to ensure if the whole data has been sent.
|
||||
*
|
||||
* @param client The MobileBackup client to send to.
|
||||
* @param data Pointer to the data to send
|
||||
* @param length Number of bytes to send
|
||||
* @param bytes Number of bytes actually sent
|
||||
*
|
||||
* @return MOBILEBACKUP2_E_SUCCESS if any data was successfully sent,
|
||||
* MOBILEBACKUP2_E_INVALID_ARG if one of the parameters is invalid,
|
||||
* or MOBILEBACKUP2_E_MUX_ERROR if sending of the data failed.
|
||||
*/
|
||||
mobilebackup2_error_t mobilebackup2_send_raw(mobilebackup2_client_t client, const char *data, uint32_t length, uint32_t *bytes);
|
||||
|
||||
/**
|
||||
* Receive binary from the device.
|
||||
*
|
||||
* @note This function returns MOBILEBACKUP2_E_SUCCESS even if no data
|
||||
* has been received (unless a communication error occured).
|
||||
* The fourth parameter is required and must be checked to know how
|
||||
* many bytes were actually received.
|
||||
*
|
||||
* @param client The MobileBackup client to receive from.
|
||||
* @param data Pointer to a buffer that will be filled with the received data.
|
||||
* @param length Number of bytes to receive. The data buffer needs to be large
|
||||
* enough to store this amount of data.
|
||||
* @paran bytes Number of bytes actually received.
|
||||
*
|
||||
* @return MOBILEBACKUP2_E_SUCCESS if any or no data was received,
|
||||
* MOBILEBACKUP2_E_INVALID_ARG if one of the parameters is invalid,
|
||||
* or MOBILEBACKUP2_E_MUX_ERROR if receiving the data failed.
|
||||
*/
|
||||
mobilebackup2_error_t mobilebackup2_receive_raw(mobilebackup2_client_t client, char *data, uint32_t length, uint32_t *bytes);
|
||||
|
||||
/**
|
||||
* Performs the mobilebackup2 protocol version exchange.
|
||||
*
|
||||
* @param client The MobileBackup client to use.
|
||||
* @param local_versions An array of supported versions to send to the remote.
|
||||
* @param count The number of items in local_versions.
|
||||
* @param remote_version Holds the protocol version of the remote on success.
|
||||
*
|
||||
* @return MOBILEBACKUP2_E_SUCCESS on success, or a MOBILEBACKUP2_E_* error
|
||||
* code otherwise.
|
||||
*/
|
||||
mobilebackup2_error_t mobilebackup2_version_exchange(mobilebackup2_client_t client, double local_versions[], char count, double *remote_version);
|
||||
|
||||
/**
|
||||
* Send a request to the connected mobilebackup2 service.
|
||||
*
|
||||
* @param client
|
||||
* @param request The request to send to the backup service.
|
||||
* Currently, this is one of "Backup", "Restore", "Info", or "List".
|
||||
* @param target_identifier UDID of the target device.
|
||||
* @param source_identifier UDID of backup data?
|
||||
* @param options Additional options in a plist of type PLIST_DICT.
|
||||
*
|
||||
* @return MOBILEBACKUP2_E_SUCCESS if the request was successfully sent,
|
||||
* or a MOBILEBACKUP2_E_* error value otherwise.
|
||||
*/
|
||||
mobilebackup2_error_t mobilebackup2_send_request(mobilebackup2_client_t client, const char *request, const char *target_identifier, const char *source_identifier, plist_t options);
|
||||
|
||||
/**
|
||||
* Sends a DLMessageStatusResponse to the device.
|
||||
*
|
||||
* @param client The MobileBackup client to use.
|
||||
* @param status_code The status code to send.
|
||||
* @param status1 A status message to send. Can be NULL if not required.
|
||||
* @param status2 An additional status plist to attach to the response.
|
||||
* Can be NULL if not required.
|
||||
*
|
||||
* @return MOBILEBACKUP2_E_SUCCESS on success, MOBILEBACKUP2_E_INVALID_ARG
|
||||
* if client is invalid, or another MOBILEBACKUP2_E_* otherwise.
|
||||
*/
|
||||
mobilebackup2_error_t mobilebackup2_send_status_response(mobilebackup2_client_t client, int status_code, const char *status1, plist_t status2);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,354 @@
|
|||
/**
|
||||
* @file libimobiledevice/mobilesync.h
|
||||
* @brief Synchronize data classes with a device and computer.
|
||||
* \internal
|
||||
*
|
||||
* Copyright (c) 2010-2014 Martin Szulecki All Rights Reserved.
|
||||
* Copyright (c) 2010-2011 Nikias Bassen All Rights Reserved.
|
||||
* Copyright (c) 2014 Christophe Fergeau All Rights Reserved.
|
||||
* Copyright (c) 2010 Bryan Forbes All Rights Reserved.
|
||||
* Copyright (c) 2009 Jonathan Beck All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef IMOBILESYNC_H
|
||||
#define IMOBILESYNC_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <libimobiledevice/libimobiledevice.h>
|
||||
#include <libimobiledevice/lockdown.h>
|
||||
|
||||
#define MOBILESYNC_SERVICE_NAME "com.apple.mobilesync"
|
||||
|
||||
/** Error Codes */
|
||||
typedef enum {
|
||||
MOBILESYNC_E_SUCCESS = 0,
|
||||
MOBILESYNC_E_INVALID_ARG = -1,
|
||||
MOBILESYNC_E_PLIST_ERROR = -2,
|
||||
MOBILESYNC_E_MUX_ERROR = -3,
|
||||
MOBILESYNC_E_BAD_VERSION = -4,
|
||||
MOBILESYNC_E_SYNC_REFUSED = -5,
|
||||
MOBILESYNC_E_CANCELLED = -6,
|
||||
MOBILESYNC_E_WRONG_DIRECTION = -7,
|
||||
MOBILESYNC_E_NOT_READY = -8,
|
||||
MOBILESYNC_E_UNKNOWN_ERROR = -256
|
||||
} mobilesync_error_t;
|
||||
|
||||
/** The sync type of the current sync session. */
|
||||
typedef enum {
|
||||
MOBILESYNC_SYNC_TYPE_FAST, /**< Fast-sync requires that only the changes made since the last synchronization should be reported by the computer. */
|
||||
MOBILESYNC_SYNC_TYPE_SLOW, /**< Slow-sync requires that all data from the computer needs to be synchronized/sent. */
|
||||
MOBILESYNC_SYNC_TYPE_RESET /**< Reset-sync signals that the computer should send all data again. */
|
||||
} mobilesync_sync_type_t;
|
||||
|
||||
typedef struct mobilesync_client_private mobilesync_client_private;
|
||||
typedef mobilesync_client_private *mobilesync_client_t; /**< The client handle */
|
||||
|
||||
typedef struct {
|
||||
char *device_anchor;
|
||||
char *computer_anchor;
|
||||
} mobilesync_anchors;
|
||||
typedef mobilesync_anchors *mobilesync_anchors_t; /**< Anchors used by the device and computer. */
|
||||
|
||||
/* Interface */
|
||||
|
||||
/**
|
||||
* Connects to the mobilesync service on the specified device.
|
||||
*
|
||||
* @param device The device to connect to.
|
||||
* @param service The service descriptor returned by lockdownd_start_service.
|
||||
* @param client Pointer that will be set to a newly allocated
|
||||
* #mobilesync_client_t upon successful return.
|
||||
*
|
||||
* @retval MOBILESYNC_E_SUCCESS on success
|
||||
* @retval MOBILESYNC_E_INVALID_ARG if one or more parameters are invalid
|
||||
* @retval DEVICE_LINK_SERVICE_E_BAD_VERSION if the mobilesync version on
|
||||
* the device is newer.
|
||||
*/
|
||||
mobilesync_error_t mobilesync_client_new(idevice_t device, lockdownd_service_descriptor_t service, mobilesync_client_t * client);
|
||||
|
||||
/**
|
||||
* Starts a new mobilesync service on the specified device and connects to it.
|
||||
*
|
||||
* @param device The device to connect to.
|
||||
* @param client Pointer that will point to a newly allocated
|
||||
* mobilesync_client_t upon successful return. Must be freed using
|
||||
* mobilesync_client_free() after use.
|
||||
* @param label The label to use for communication. Usually the program name.
|
||||
* Pass NULL to disable sending the label in requests to lockdownd.
|
||||
*
|
||||
* @return MOBILESYNC_E_SUCCESS on success, or an MOBILESYNC_E_* error
|
||||
* code otherwise.
|
||||
*/
|
||||
mobilesync_error_t mobilesync_client_start_service(idevice_t device, mobilesync_client_t* client, const char* label);
|
||||
|
||||
/**
|
||||
* Disconnects a mobilesync client from the device and frees up the
|
||||
* mobilesync client data.
|
||||
*
|
||||
* @param client The mobilesync client to disconnect and free.
|
||||
*
|
||||
* @retval MOBILESYNC_E_SUCCESS on success
|
||||
* @retval MOBILESYNC_E_INVALID_ARG if \a client is NULL.
|
||||
*/
|
||||
mobilesync_error_t mobilesync_client_free(mobilesync_client_t client);
|
||||
|
||||
|
||||
/**
|
||||
* Polls the device for mobilesync data.
|
||||
*
|
||||
* @param client The mobilesync client
|
||||
* @param plist A pointer to the location where the plist should be stored
|
||||
*
|
||||
* @return an error code
|
||||
*/
|
||||
mobilesync_error_t mobilesync_receive(mobilesync_client_t client, plist_t *plist);
|
||||
|
||||
/**
|
||||
* Sends mobilesync data to the device
|
||||
*
|
||||
* @note This function is low-level and should only be used if you need to send
|
||||
* a new type of message.
|
||||
*
|
||||
* @param client The mobilesync client
|
||||
* @param plist The location of the plist to send
|
||||
*
|
||||
* @return an error code
|
||||
*/
|
||||
mobilesync_error_t mobilesync_send(mobilesync_client_t client, plist_t plist);
|
||||
|
||||
|
||||
/**
|
||||
* Requests starting synchronization of a data class with the device
|
||||
*
|
||||
* @param client The mobilesync client
|
||||
* @param data_class The data class identifier to sync
|
||||
* @param anchors The anchors required to exchange with the device. The anchors
|
||||
* allow the device to tell if the synchronization information on the computer
|
||||
* and device are consistent to determine what sync type is required.
|
||||
* @param computer_data_class_version The version of the data class storage on the computer
|
||||
* @param sync_type A pointer to store the sync type reported by the device_anchor
|
||||
* @param device_data_class_version The version of the data class storage on the device
|
||||
* @param error_description A pointer to store an error message if reported by the device
|
||||
*
|
||||
* @retval MOBILESYNC_E_SUCCESS on success
|
||||
* @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
|
||||
* @retval MOBILESYNC_E_PLIST_ERROR if the received plist is not of valid form
|
||||
* @retval MOBILESYNC_E_SYNC_REFUSED if the device refused to sync
|
||||
* @retval MOBILESYNC_E_CANCELLED if the device explicitly cancelled the
|
||||
* sync request
|
||||
*/
|
||||
mobilesync_error_t mobilesync_start(mobilesync_client_t client, const char *data_class, mobilesync_anchors_t anchors, uint64_t computer_data_class_version, mobilesync_sync_type_t *sync_type, uint64_t *device_data_class_version, char** error_description);
|
||||
|
||||
/**
|
||||
* Cancels a running synchronization session with a device at any time.
|
||||
*
|
||||
* @param client The mobilesync client
|
||||
* @param reason The reason to supply to the device for cancelling
|
||||
*
|
||||
* @retval MOBILESYNC_E_SUCCESS on success
|
||||
* @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
|
||||
*/
|
||||
mobilesync_error_t mobilesync_cancel(mobilesync_client_t client, const char* reason);
|
||||
|
||||
/**
|
||||
* Finish a synchronization session of a data class on the device.
|
||||
* A session must have previously been started using mobilesync_start().
|
||||
*
|
||||
* @param client The mobilesync client
|
||||
*
|
||||
* @retval MOBILESYNC_E_SUCCESS on success
|
||||
* @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
|
||||
* @retval MOBILESYNC_E_PLIST_ERROR if the received plist is not of valid
|
||||
* form
|
||||
*/
|
||||
mobilesync_error_t mobilesync_finish(mobilesync_client_t client);
|
||||
|
||||
|
||||
/**
|
||||
* Requests to receive all records of the currently set data class from the device.
|
||||
* The actually changes are retrieved using mobilesync_receive_changes() after this
|
||||
* request has been successful.
|
||||
*
|
||||
* @param client The mobilesync client
|
||||
*
|
||||
* @retval MOBILESYNC_E_SUCCESS on success
|
||||
* @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
|
||||
*/
|
||||
mobilesync_error_t mobilesync_get_all_records_from_device(mobilesync_client_t client);
|
||||
|
||||
/**
|
||||
* Requests to receive only changed records of the currently set data class from the device.
|
||||
* The actually changes are retrieved using mobilesync_receive_changes() after this
|
||||
* request has been successful.
|
||||
*
|
||||
* @param client The mobilesync client
|
||||
*
|
||||
* @retval MOBILESYNC_E_SUCCESS on success
|
||||
* @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
|
||||
*/
|
||||
mobilesync_error_t mobilesync_get_changes_from_device(mobilesync_client_t client);
|
||||
|
||||
/**
|
||||
* Requests the device to delete all records of the current data class
|
||||
*
|
||||
* @note The operation must be called after starting synchronization.
|
||||
*
|
||||
* @param client The mobilesync client
|
||||
*
|
||||
* @retval MOBILESYNC_E_SUCCESS on success
|
||||
* @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
|
||||
* @retval MOBILESYNC_E_PLIST_ERROR if the received plist is not of valid form
|
||||
*/
|
||||
mobilesync_error_t mobilesync_clear_all_records_on_device(mobilesync_client_t client);
|
||||
|
||||
|
||||
/**
|
||||
* Receives changed entitites of the currently set data class from the device
|
||||
*
|
||||
* @param client The mobilesync client
|
||||
* @param entities A pointer to store the changed entity records as a PLIST_DICT
|
||||
* @param is_last_record A pointer to store a flag indicating if this submission is the last one
|
||||
* @param actions A pointer to additional flags the device is sending or NULL to ignore
|
||||
*
|
||||
* @retval MOBILESYNC_E_SUCCESS on success
|
||||
* @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
|
||||
* @retval MOBILESYNC_E_CANCELLED if the device explicitly cancelled the
|
||||
* session
|
||||
*/
|
||||
mobilesync_error_t mobilesync_receive_changes(mobilesync_client_t client, plist_t *entities, uint8_t *is_last_record, plist_t *actions);
|
||||
|
||||
/**
|
||||
* Acknowledges to the device that the changes have been merged on the computer
|
||||
*
|
||||
* @param client The mobilesync client
|
||||
*
|
||||
* @retval MOBILESYNC_E_SUCCESS on success
|
||||
* @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
|
||||
*/
|
||||
mobilesync_error_t mobilesync_acknowledge_changes_from_device(mobilesync_client_t client);
|
||||
|
||||
|
||||
/**
|
||||
* Verifies if the device is ready to receive changes from the computer.
|
||||
* This call changes the synchronization direction so that mobilesync_send_changes()
|
||||
* can be used to send changes to the device.
|
||||
*
|
||||
* @param client The mobilesync client
|
||||
*
|
||||
* @retval MOBILESYNC_E_SUCCESS on success
|
||||
* @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
|
||||
* @retval MOBILESYNC_E_PLIST_ERROR if the received plist is not of valid form
|
||||
* @retval MOBILESYNC_E_WRONG_DIRECTION if the current sync direction does
|
||||
* not permit this call
|
||||
* @retval MOBILESYNC_E_CANCELLED if the device explicitly cancelled the
|
||||
* session
|
||||
* @retval MOBILESYNC_E_NOT_READY if the device is not ready to start
|
||||
* receiving any changes
|
||||
*/
|
||||
mobilesync_error_t mobilesync_ready_to_send_changes_from_computer(mobilesync_client_t client);
|
||||
|
||||
|
||||
/**
|
||||
* Sends changed entities of the currently set data class to the device
|
||||
*
|
||||
* @param client The mobilesync client
|
||||
* @param entities The changed entity records as a PLIST_DICT
|
||||
* @param is_last_record A flag indicating if this submission is the last one
|
||||
* @param actions Additional actions for the device created with mobilesync_actions_new()
|
||||
* or NULL if no actions should be passed
|
||||
*
|
||||
* @retval MOBILESYNC_E_SUCCESS on success
|
||||
* @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid,
|
||||
* @retval MOBILESYNC_E_WRONG_DIRECTION if the current sync direction does
|
||||
* not permit this call
|
||||
*/
|
||||
mobilesync_error_t mobilesync_send_changes(mobilesync_client_t client, plist_t entities, uint8_t is_last_record, plist_t actions);
|
||||
|
||||
/**
|
||||
* Receives any remapped identifiers reported after the device merged submitted changes.
|
||||
*
|
||||
* @param client The mobilesync client
|
||||
* @param mapping A pointer to an array plist containing a dict of identifier remappings
|
||||
*
|
||||
* @retval MOBILESYNC_E_SUCCESS on success
|
||||
* @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid
|
||||
* @retval MOBILESYNC_E_PLIST_ERROR if the received plist is not of valid
|
||||
* form
|
||||
* @retval MOBILESYNC_E_WRONG_DIRECTION if the current sync direction does
|
||||
* not permit this call
|
||||
* @retval MOBILESYNC_E_CANCELLED if the device explicitly cancelled the
|
||||
* session
|
||||
*/
|
||||
mobilesync_error_t mobilesync_remap_identifiers(mobilesync_client_t client, plist_t *mapping);
|
||||
|
||||
/* Helper */
|
||||
|
||||
/**
|
||||
* Allocates memory for a new anchors struct initialized with the passed anchors.
|
||||
*
|
||||
* @param device_anchor An anchor the device reported the last time or NULL
|
||||
* if none is known yet which for instance is true on first synchronization.
|
||||
* @param computer_anchor An arbitrary string to use as anchor for the computer.
|
||||
*
|
||||
* @return A new #mobilesync_anchors_t struct. Must be freed using mobilesync_anchors_free().
|
||||
*/
|
||||
mobilesync_anchors_t mobilesync_anchors_new(const char *device_anchor, const char *computer_anchor);
|
||||
|
||||
/**
|
||||
* Free memory used by anchors.
|
||||
*
|
||||
* @param anchors The anchors to free.
|
||||
*/
|
||||
void mobilesync_anchors_free(mobilesync_anchors_t anchors);
|
||||
|
||||
|
||||
/**
|
||||
* Create a new actions plist to use in mobilesync_send_changes().
|
||||
*
|
||||
* @return A new plist_t of type PLIST_DICT.
|
||||
*/
|
||||
plist_t mobilesync_actions_new(void);
|
||||
|
||||
/**
|
||||
* Add one or more new key:value pairs to the given actions plist.
|
||||
*
|
||||
* @param actions The actions to modify.
|
||||
* @param ... KEY, VALUE, [KEY, VALUE], NULL
|
||||
*
|
||||
* @note The known keys so far are "SyncDeviceLinkEntityNamesKey" which expects
|
||||
* an array of entity names, followed by a count paramter as well as
|
||||
* "SyncDeviceLinkAllRecordsOfPulledEntityTypeSentKey" which expects an
|
||||
* integer to use as a boolean value indicating that the device should
|
||||
* link submitted changes and report remapped identifiers.
|
||||
*/
|
||||
void mobilesync_actions_add(plist_t actions, ...);
|
||||
|
||||
/**
|
||||
* Free actions plist.
|
||||
*
|
||||
* @param actions The actions plist to free. Does nothing if NULL is passed.
|
||||
*/
|
||||
void mobilesync_actions_free(plist_t actions);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,196 @@
|
|||
/**
|
||||
* @file libimobiledevice/notification_proxy.h
|
||||
* @brief Observe and post notifications.
|
||||
* \internal
|
||||
*
|
||||
* Copyright (c) 2010-2014 Martin Szulecki All Rights Reserved.
|
||||
* Copyright (c) 2009-2010 Nikias Bassen All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef INOTIFICATION_PROXY_H
|
||||
#define INOTIFICATION_PROXY_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <libimobiledevice/libimobiledevice.h>
|
||||
#include <libimobiledevice/lockdown.h>
|
||||
|
||||
#define NP_SERVICE_NAME "com.apple.mobile.notification_proxy"
|
||||
|
||||
/** Error Codes */
|
||||
typedef enum {
|
||||
NP_E_SUCCESS = 0,
|
||||
NP_E_INVALID_ARG = -1,
|
||||
NP_E_PLIST_ERROR = -2,
|
||||
NP_E_CONN_FAILED = -3,
|
||||
NP_E_UNKNOWN_ERROR = -256
|
||||
} np_error_t;
|
||||
|
||||
/**
|
||||
* @name Notifications that can be send
|
||||
*
|
||||
* For use with np_post_notification() (client --> device)
|
||||
*/
|
||||
#define NP_SYNC_WILL_START "com.apple.itunes-mobdev.syncWillStart"
|
||||
#define NP_SYNC_DID_START "com.apple.itunes-mobdev.syncDidStart"
|
||||
#define NP_SYNC_DID_FINISH "com.apple.itunes-mobdev.syncDidFinish"
|
||||
#define NP_SYNC_LOCK_REQUEST "com.apple.itunes-mobdev.syncLockRequest"
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* @name Notifications that can be received
|
||||
*
|
||||
* For use with np_observe_notification() (device --> client)
|
||||
*/
|
||||
/*@{*/
|
||||
#define NP_SYNC_CANCEL_REQUEST "com.apple.itunes-client.syncCancelRequest"
|
||||
#define NP_SYNC_SUSPEND_REQUEST "com.apple.itunes-client.syncSuspendRequest"
|
||||
#define NP_SYNC_RESUME_REQUEST "com.apple.itunes-client.syncResumeRequest"
|
||||
#define NP_PHONE_NUMBER_CHANGED "com.apple.mobile.lockdown.phone_number_changed"
|
||||
#define NP_DEVICE_NAME_CHANGED "com.apple.mobile.lockdown.device_name_changed"
|
||||
#define NP_TIMEZONE_CHANGED "com.apple.mobile.lockdown.timezone_changed"
|
||||
#define NP_TRUSTED_HOST_ATTACHED "com.apple.mobile.lockdown.trusted_host_attached"
|
||||
#define NP_HOST_DETACHED "com.apple.mobile.lockdown.host_detached"
|
||||
#define NP_HOST_ATTACHED "com.apple.mobile.lockdown.host_attached"
|
||||
#define NP_REGISTRATION_FAILED "com.apple.mobile.lockdown.registration_failed"
|
||||
#define NP_ACTIVATION_STATE "com.apple.mobile.lockdown.activation_state"
|
||||
#define NP_BRICK_STATE "com.apple.mobile.lockdown.brick_state"
|
||||
#define NP_DISK_USAGE_CHANGED "com.apple.mobile.lockdown.disk_usage_changed" /**< iOS 4.0+ */
|
||||
#define NP_DS_DOMAIN_CHANGED "com.apple.mobile.data_sync.domain_changed"
|
||||
#define NP_BACKUP_DOMAIN_CHANGED "com.apple.mobile.backup.domain_changed"
|
||||
#define NP_APP_INSTALLED "com.apple.mobile.application_installed"
|
||||
#define NP_APP_UNINSTALLED "com.apple.mobile.application_uninstalled"
|
||||
#define NP_DEV_IMAGE_MOUNTED "com.apple.mobile.developer_image_mounted"
|
||||
#define NP_ATTEMPTACTIVATION "com.apple.springboard.attemptactivation"
|
||||
#define NP_ITDBPREP_DID_END "com.apple.itdbprep.notification.didEnd"
|
||||
#define NP_LANGUAGE_CHANGED "com.apple.language.changed"
|
||||
#define NP_ADDRESS_BOOK_PREF_CHANGED "com.apple.AddressBook.PreferenceChanged"
|
||||
/*@}*/
|
||||
|
||||
typedef struct np_client_private np_client_private;
|
||||
typedef np_client_private *np_client_t; /**< The client handle. */
|
||||
|
||||
/** Reports which notification was received. */
|
||||
typedef void (*np_notify_cb_t) (const char *notification, void *user_data);
|
||||
|
||||
/* Interface */
|
||||
|
||||
/**
|
||||
* Connects to the notification_proxy on the specified device.
|
||||
*
|
||||
* @param device The device to connect to.
|
||||
* @param service The service descriptor returned by lockdownd_start_service.
|
||||
* @param client Pointer that will be set to a newly allocated np_client_t
|
||||
* upon successful return.
|
||||
*
|
||||
* @return NP_E_SUCCESS on success, NP_E_INVALID_ARG when device is NULL,
|
||||
* or NP_E_CONN_FAILED when the connection to the device could not be
|
||||
* established.
|
||||
*/
|
||||
np_error_t np_client_new(idevice_t device, lockdownd_service_descriptor_t service, np_client_t *client);
|
||||
|
||||
/**
|
||||
* Starts a new notification proxy service on the specified device and connects to it.
|
||||
*
|
||||
* @param device The device to connect to.
|
||||
* @param client Pointer that will point to a newly allocated
|
||||
* np_client_t upon successful return. Must be freed using
|
||||
* np_client_free() after use.
|
||||
* @param label The label to use for communication. Usually the program name.
|
||||
* Pass NULL to disable sending the label in requests to lockdownd.
|
||||
*
|
||||
* @return NP_E_SUCCESS on success, or an NP_E_* error
|
||||
* code otherwise.
|
||||
*/
|
||||
np_error_t np_client_start_service(idevice_t device, np_client_t* client, const char* label);
|
||||
|
||||
/**
|
||||
* Disconnects a notification_proxy client from the device and frees up the
|
||||
* notification_proxy client data.
|
||||
*
|
||||
* @param client The notification_proxy client to disconnect and free.
|
||||
*
|
||||
* @return NP_E_SUCCESS on success, or NP_E_INVALID_ARG when client is NULL.
|
||||
*/
|
||||
np_error_t np_client_free(np_client_t client);
|
||||
|
||||
|
||||
/**
|
||||
* Sends a notification to the device's notification_proxy.
|
||||
*
|
||||
* @param client The client to send to
|
||||
* @param notification The notification message to send
|
||||
*
|
||||
* @return NP_E_SUCCESS on success, or an error returned by np_plist_send
|
||||
*/
|
||||
np_error_t np_post_notification(np_client_t client, const char *notification);
|
||||
|
||||
/**
|
||||
* Tells the device to send a notification on the specified event.
|
||||
*
|
||||
* @param client The client to send to
|
||||
* @param notification The notifications that should be observed.
|
||||
*
|
||||
* @return NP_E_SUCCESS on success, NP_E_INVALID_ARG when client or
|
||||
* notification are NULL, or an error returned by np_plist_send.
|
||||
*/
|
||||
np_error_t np_observe_notification(np_client_t client, const char *notification);
|
||||
|
||||
/**
|
||||
* Tells the device to send a notification on specified events.
|
||||
*
|
||||
* @param client The client to send to
|
||||
* @param notification_spec Specification of the notifications that should be
|
||||
* observed. This is expected to be an array of const char* that MUST have a
|
||||
* terminating NULL entry.
|
||||
*
|
||||
* @return NP_E_SUCCESS on success, NP_E_INVALID_ARG when client is null,
|
||||
* or an error returned by np_observe_notification.
|
||||
*/
|
||||
np_error_t np_observe_notifications(np_client_t client, const char **notification_spec);
|
||||
|
||||
/**
|
||||
* This function allows an application to define a callback function that will
|
||||
* be called when a notification has been received.
|
||||
* It will start a thread that polls for notifications and calls the callback
|
||||
* function if a notification has been received.
|
||||
* In case of an error condition when polling for notifications - e.g. device
|
||||
* disconnect - the thread will call the callback function with an empty
|
||||
* notification "" and terminate itself.
|
||||
*
|
||||
* @param client the NP client
|
||||
* @param notify_cb pointer to a callback function or NULL to de-register a
|
||||
* previously set callback function.
|
||||
* @param user_data Pointer that will be passed to the callback function as
|
||||
* user data. If notify_cb is NULL, this parameter is ignored.
|
||||
*
|
||||
* @note Only one callback function can be registered at the same time;
|
||||
* any previously set callback function will be removed automatically.
|
||||
*
|
||||
* @return NP_E_SUCCESS when the callback was successfully registered,
|
||||
* NP_E_INVALID_ARG when client is NULL, or NP_E_UNKNOWN_ERROR when
|
||||
* the callback thread could no be created.
|
||||
*/
|
||||
np_error_t np_set_notify_callback(np_client_t client, np_notify_cb_t notify_cb, void *userdata);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,169 @@
|
|||
/**
|
||||
* @file libimobiledevice/property_list_service.h
|
||||
* @brief Definitions for the PropertyList service
|
||||
* \internal
|
||||
*
|
||||
* Copyright (c) 2010-2014 Martin Szulecki All Rights Reserved.
|
||||
* Copyright (c) 2010-2014 Nikias Bassen, All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef IPROPERTY_LIST_SERVICE_H
|
||||
#define IPROPERTY_LIST_SERVICE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <libimobiledevice/lockdown.h>
|
||||
|
||||
/* Error Codes */
|
||||
typedef enum {
|
||||
PROPERTY_LIST_SERVICE_E_SUCCESS = 0,
|
||||
PROPERTY_LIST_SERVICE_E_INVALID_ARG = -1,
|
||||
PROPERTY_LIST_SERVICE_E_PLIST_ERROR = -2,
|
||||
PROPERTY_LIST_SERVICE_E_MUX_ERROR = -3,
|
||||
PROPERTY_LIST_SERVICE_E_SSL_ERROR = -4,
|
||||
PROPERTY_LIST_SERVICE_E_RECEIVE_TIMEOUT = -5,
|
||||
PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR = -256
|
||||
} property_list_service_error_t;
|
||||
|
||||
typedef struct property_list_service_client_private property_list_service_private;
|
||||
typedef property_list_service_private* property_list_service_client_t; /**< The client handle. */
|
||||
|
||||
/* Interface */
|
||||
|
||||
/**
|
||||
* Creates a new property list service for the specified port.
|
||||
*
|
||||
* @param device The device to connect to.
|
||||
* @param service The service descriptor returned by lockdownd_start_service.
|
||||
* @param client Pointer that will be set to a newly allocated
|
||||
* property_list_service_client_t upon successful return.
|
||||
*
|
||||
* @return PROPERTY_LIST_SERVICE_E_SUCCESS on success,
|
||||
* PROPERTY_LIST_SERVICE_E_INVALID_ARG when one of the arguments is invalid,
|
||||
* or PROPERTY_LIST_SERVICE_E_MUX_ERROR when connecting to the device failed.
|
||||
*/
|
||||
property_list_service_error_t property_list_service_client_new(idevice_t device, lockdownd_service_descriptor_t service, property_list_service_client_t *client);
|
||||
|
||||
/**
|
||||
* Frees a PropertyList service.
|
||||
*
|
||||
* @param client The property list service to free.
|
||||
*
|
||||
* @return PROPERTY_LIST_SERVICE_E_SUCCESS on success,
|
||||
* PROPERTY_LIST_SERVICE_E_INVALID_ARG when client is invalid, or a
|
||||
* PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR when another error occured.
|
||||
*/
|
||||
property_list_service_error_t property_list_service_client_free(property_list_service_client_t client);
|
||||
|
||||
/**
|
||||
* Sends an XML plist.
|
||||
*
|
||||
* @param client The property list service client to use for sending.
|
||||
* @param plist plist to send
|
||||
*
|
||||
* @return PROPERTY_LIST_SERVICE_E_SUCCESS on success,
|
||||
* PROPERTY_LIST_SERVICE_E_INVALID_ARG when client or plist is NULL,
|
||||
* PROPERTY_LIST_SERVICE_E_PLIST_ERROR when dict is not a valid plist,
|
||||
* or PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR when an unspecified error occurs.
|
||||
*/
|
||||
property_list_service_error_t property_list_service_send_xml_plist(property_list_service_client_t client, plist_t plist);
|
||||
|
||||
/**
|
||||
* Sends a binary plist.
|
||||
*
|
||||
* @param client The property list service client to use for sending.
|
||||
* @param plist plist to send
|
||||
*
|
||||
* @return PROPERTY_LIST_SERVICE_E_SUCCESS on success,
|
||||
* PROPERTY_LIST_SERVICE_E_INVALID_ARG when client or plist is NULL,
|
||||
* PROPERTY_LIST_SERVICE_E_PLIST_ERROR when dict is not a valid plist,
|
||||
* or PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR when an unspecified error occurs.
|
||||
*/
|
||||
property_list_service_error_t property_list_service_send_binary_plist(property_list_service_client_t client, plist_t plist);
|
||||
|
||||
/**
|
||||
* Receives a plist using the given property list service client with specified
|
||||
* timeout.
|
||||
* Binary or XML plists are automatically handled.
|
||||
*
|
||||
* @param client The property list service client to use for receiving
|
||||
* @param plist pointer to a plist_t that will point to the received plist
|
||||
* upon successful return
|
||||
* @param timeout Maximum time in milliseconds to wait for data.
|
||||
*
|
||||
* @return PROPERTY_LIST_SERVICE_E_SUCCESS on success,
|
||||
* PROPERTY_LIST_SERVICE_E_INVALID_ARG when connection or *plist is NULL,
|
||||
* PROPERTY_LIST_SERVICE_E_PLIST_ERROR when the received data cannot be
|
||||
* converted to a plist, PROPERTY_LIST_SERVICE_E_MUX_ERROR when a
|
||||
* communication error occurs, or PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR when
|
||||
* an unspecified error occurs.
|
||||
*/
|
||||
property_list_service_error_t property_list_service_receive_plist_with_timeout(property_list_service_client_t client, plist_t *plist, unsigned int timeout);
|
||||
|
||||
/**
|
||||
* Receives a plist using the given property list service client.
|
||||
* Binary or XML plists are automatically handled.
|
||||
*
|
||||
* This function is like property_list_service_receive_plist_with_timeout
|
||||
* using a timeout of 10 seconds.
|
||||
* @see property_list_service_receive_plist_with_timeout
|
||||
*
|
||||
* @param client The property list service client to use for receiving
|
||||
* @param plist pointer to a plist_t that will point to the received plist
|
||||
* upon successful return
|
||||
*
|
||||
* @return PROPERTY_LIST_SERVICE_E_SUCCESS on success,
|
||||
* PROPERTY_LIST_SERVICE_E_INVALID_ARG when client or *plist is NULL,
|
||||
* PROPERTY_LIST_SERVICE_E_PLIST_ERROR when the received data cannot be
|
||||
* converted to a plist, PROPERTY_LIST_SERVICE_E_MUX_ERROR when a
|
||||
* communication error occurs, or PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR when
|
||||
* an unspecified error occurs.
|
||||
*/
|
||||
property_list_service_error_t property_list_service_receive_plist(property_list_service_client_t client, plist_t *plist);
|
||||
|
||||
/**
|
||||
* Enable SSL for the given property list service client.
|
||||
*
|
||||
* @param client The connected property list service client for which SSL
|
||||
* should be enabled.
|
||||
*
|
||||
* @return PROPERTY_LIST_SERVICE_E_SUCCESS on success,
|
||||
* PROPERTY_LIST_SERVICE_E_INVALID_ARG if client or client->connection is
|
||||
* NULL, PROPERTY_LIST_SERVICE_E_SSL_ERROR when SSL could not be enabled,
|
||||
* or PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR otherwise.
|
||||
*/
|
||||
property_list_service_error_t property_list_service_enable_ssl(property_list_service_client_t client);
|
||||
|
||||
/**
|
||||
* Disable SSL for the given property list service client.
|
||||
*
|
||||
* @param client The connected property list service client for which SSL
|
||||
* should be disabled.
|
||||
*
|
||||
* @return PROPERTY_LIST_SERVICE_E_SUCCESS on success,
|
||||
* PROPERTY_LIST_SERVICE_E_INVALID_ARG if client or client->connection is
|
||||
* NULL, or PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR otherwise.
|
||||
*/
|
||||
property_list_service_error_t property_list_service_disable_ssl(property_list_service_client_t client);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,182 @@
|
|||
/**
|
||||
* @file libimobiledevice/restore.h
|
||||
* @brief Initiate restore process or reboot device.
|
||||
* @note This service is only available if the device is in restore mode.
|
||||
* \internal
|
||||
*
|
||||
* Copyright (c) 2010-2014 Martin Szulecki All Rights Reserved.
|
||||
* Copyright (c) 2010 Joshua Hill. All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef IRESTORE_H
|
||||
#define IRESTORE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <libimobiledevice/libimobiledevice.h>
|
||||
|
||||
/** Error Codes */
|
||||
typedef enum {
|
||||
RESTORE_E_SUCCESS = 0,
|
||||
RESTORE_E_INVALID_ARG = -1,
|
||||
RESTORE_E_INVALID_CONF = -2,
|
||||
RESTORE_E_PLIST_ERROR = -3,
|
||||
RESTORE_E_DICT_ERROR = -4,
|
||||
RESTORE_E_NOT_ENOUGH_DATA = -5,
|
||||
RESTORE_E_MUX_ERROR = -6,
|
||||
RESTORE_E_START_RESTORE_FAILED = -7,
|
||||
RESTORE_E_DEVICE_ERROR = -8,
|
||||
RESTORE_E_UNKNOWN_ERROR = -256
|
||||
} restored_error_t;
|
||||
|
||||
typedef struct restored_client_private restored_client_private;
|
||||
typedef restored_client_private *restored_client_t; /**< The client handle. */
|
||||
|
||||
/* Interface */
|
||||
|
||||
/**
|
||||
* Creates a new restored client for the device.
|
||||
*
|
||||
* @param device The device to create a restored client for
|
||||
* @param client The pointer to the location of the new restored_client
|
||||
* @param label The label to use for communication. Usually the program name.
|
||||
*
|
||||
* @return RESTORE_E_SUCCESS on success, RESTORE_E_INVALID_ARG when client is NULL
|
||||
*/
|
||||
restored_error_t restored_client_new(idevice_t device, restored_client_t *client, const char *label);
|
||||
|
||||
/**
|
||||
* Closes the restored client session if one is running and frees up the
|
||||
* restored_client struct.
|
||||
*
|
||||
* @param client The restore client
|
||||
*
|
||||
* @return RESTORE_E_SUCCESS on success, RESTORE_E_INVALID_ARG when client is NULL
|
||||
*/
|
||||
restored_error_t restored_client_free(restored_client_t client);
|
||||
|
||||
|
||||
/**
|
||||
* Query the type of the service daemon. Depending on whether the device is
|
||||
* queried in normal mode or restore mode, different types will be returned.
|
||||
*
|
||||
* @param client The restored client
|
||||
* @param type The type returned by the service daemon. Pass NULL to ignore.
|
||||
* @param version The restore protocol version. Pass NULL to ignore.
|
||||
*
|
||||
* @return RESTORE_E_SUCCESS on success, RESTORE_E_INVALID_ARG when client is NULL
|
||||
*/
|
||||
restored_error_t restored_query_type(restored_client_t client, char **type, uint64_t *version);
|
||||
|
||||
/**
|
||||
* Queries a value from the device specified by a key.
|
||||
*
|
||||
* @param client An initialized restored client.
|
||||
* @param key The key name to request
|
||||
* @param value A plist node representing the result value node
|
||||
*
|
||||
* @return RESTORE_E_SUCCESS on success, RESTORE_E_INVALID_ARG when client is NULL, RESTORE_E_PLIST_ERROR if value for key can't be found
|
||||
*/
|
||||
restored_error_t restored_query_value(restored_client_t client, const char *key, plist_t *value);
|
||||
|
||||
/**
|
||||
* Retrieves a value from information plist specified by a key.
|
||||
*
|
||||
* @param client An initialized restored client.
|
||||
* @param key The key name to request or NULL to query for all keys
|
||||
* @param value A plist node representing the result value node
|
||||
*
|
||||
* @return RESTORE_E_SUCCESS on success, RESTORE_E_INVALID_ARG when client is NULL, RESTORE_E_PLIST_ERROR if value for key can't be found
|
||||
*/
|
||||
restored_error_t restored_get_value(restored_client_t client, const char *key, plist_t *value) ;
|
||||
|
||||
/**
|
||||
* Sends a plist to restored.
|
||||
*
|
||||
* @note This function is low-level and should only be used if you need to send
|
||||
* a new type of message.
|
||||
*
|
||||
* @param client The restored client
|
||||
* @param plist The plist to send
|
||||
*
|
||||
* @return RESTORE_E_SUCCESS on success, RESTORE_E_INVALID_ARG when client or
|
||||
* plist is NULL
|
||||
*/
|
||||
restored_error_t restored_send(restored_client_t client, plist_t plist);
|
||||
|
||||
/**
|
||||
* Receives a plist from restored.
|
||||
*
|
||||
* @param client The restored client
|
||||
* @param plist The plist to store the received data
|
||||
*
|
||||
* @return RESTORE_E_SUCCESS on success, RESTORE_E_INVALID_ARG when client or
|
||||
* plist is NULL
|
||||
*/
|
||||
restored_error_t restored_receive(restored_client_t client, plist_t *plist);
|
||||
|
||||
/**
|
||||
* Sends the Goodbye request to restored signaling the end of communication.
|
||||
*
|
||||
* @param client The restore client
|
||||
*
|
||||
* @return RESTORE_E_SUCCESS on success, RESTORE_E_INVALID_ARG when client is NULL,
|
||||
* RESTORE_E_PLIST_ERROR if the device did not acknowledge the request
|
||||
*/
|
||||
restored_error_t restored_goodbye(restored_client_t client);
|
||||
|
||||
|
||||
/**
|
||||
* Requests to start a restore and retrieve it's port on success.
|
||||
*
|
||||
* @param client The restored client
|
||||
* @param options PLIST_DICT with options for the restore process or NULL
|
||||
* @param version the restore protocol version, see restored_query_type()
|
||||
*
|
||||
* @return RESTORE_E_SUCCESS on success, RESTORE_E_INVALID_ARG if a parameter
|
||||
* is NULL, RESTORE_E_START_RESTORE_FAILED if the request fails
|
||||
*/
|
||||
restored_error_t restored_start_restore(restored_client_t client, plist_t options, uint64_t version);
|
||||
|
||||
/**
|
||||
* Requests device to reboot.
|
||||
*
|
||||
* @param client The restored client
|
||||
*
|
||||
* @return RESTORE_E_SUCCESS on success, RESTORE_E_INVALID_ARG if a parameter
|
||||
* is NULL
|
||||
*/
|
||||
restored_error_t restored_reboot(restored_client_t client);
|
||||
|
||||
/* Helper */
|
||||
|
||||
/**
|
||||
* Sets the label to send for requests to restored.
|
||||
*
|
||||
* @param client The restore client
|
||||
* @param label The label to set or NULL to disable sending a label
|
||||
*
|
||||
*/
|
||||
void restored_client_set_label(restored_client_t client, const char *label);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,176 @@
|
|||
/**
|
||||
* @file libimobiledevice/sbservices.h
|
||||
* @brief Manage SpringBoard icons and retrieve icon images.
|
||||
* \internal
|
||||
*
|
||||
* Copyright (c) 2010-2014 Martin Szulecki All Rights Reserved.
|
||||
* Copyright (c) 2009-2010 Nikias Bassen All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef ISB_SERVICES_H
|
||||
#define ISB_SERVICES_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <libimobiledevice/libimobiledevice.h>
|
||||
#include <libimobiledevice/lockdown.h>
|
||||
|
||||
#define SBSERVICES_SERVICE_NAME "com.apple.springboardservices"
|
||||
|
||||
/** Error Codes */
|
||||
typedef enum {
|
||||
SBSERVICES_E_SUCCESS = 0,
|
||||
SBSERVICES_E_INVALID_ARG = -1,
|
||||
SBSERVICES_E_PLIST_ERROR = -2,
|
||||
SBSERVICES_E_CONN_FAILED = -3,
|
||||
SBSERVICES_E_UNKNOWN_ERROR = -256
|
||||
} sbservices_error_t;
|
||||
|
||||
/** @name Orientation of the user interface on the device */
|
||||
/*@{*/
|
||||
typedef enum {
|
||||
SBSERVICES_INTERFACE_ORIENTATION_UNKNOWN = 0,
|
||||
SBSERVICES_INTERFACE_ORIENTATION_PORTRAIT = 1,
|
||||
SBSERVICES_INTERFACE_ORIENTATION_PORTRAIT_UPSIDE_DOWN = 2,
|
||||
SBSERVICES_INTERFACE_ORIENTATION_LANDSCAPE_RIGHT = 3,
|
||||
SBSERVICES_INTERFACE_ORIENTATION_LANDSCAPE_LEFT = 4
|
||||
} sbservices_interface_orientation_t;
|
||||
/*@}*/
|
||||
|
||||
typedef struct sbservices_client_private sbservices_client_private;
|
||||
typedef sbservices_client_private *sbservices_client_t; /**< The client handle. */
|
||||
|
||||
/* Interface */
|
||||
|
||||
/**
|
||||
* Connects to the springboardservices service on the specified device.
|
||||
*
|
||||
* @param device The device to connect to.
|
||||
* @param service The service descriptor returned by lockdownd_start_service.
|
||||
* @param client Pointer that will point to a newly allocated
|
||||
* sbservices_client_t upon successful return.
|
||||
*
|
||||
* @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when
|
||||
* client is NULL, or an SBSERVICES_E_* error code otherwise.
|
||||
*/
|
||||
sbservices_error_t sbservices_client_new(idevice_t device, lockdownd_service_descriptor_t service, sbservices_client_t *client);
|
||||
|
||||
/**
|
||||
* Starts a new sbservices service on the specified device and connects to it.
|
||||
*
|
||||
* @param device The device to connect to.
|
||||
* @param client Pointer that will point to a newly allocated
|
||||
* sbservices_client_t upon successful return. Must be freed using
|
||||
* sbservices_client_free() after use.
|
||||
* @param label The label to use for communication. Usually the program name.
|
||||
* Pass NULL to disable sending the label in requests to lockdownd.
|
||||
*
|
||||
* @return SBSERVICES_E_SUCCESS on success, or an SBSERVICES_E_* error
|
||||
* code otherwise.
|
||||
*/
|
||||
sbservices_error_t sbservices_client_start_service(idevice_t device, sbservices_client_t* client, const char* label);
|
||||
|
||||
/**
|
||||
* Disconnects an sbservices client from the device and frees up the
|
||||
* sbservices client data.
|
||||
*
|
||||
* @param client The sbservices client to disconnect and free.
|
||||
*
|
||||
* @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when
|
||||
* client is NULL, or an SBSERVICES_E_* error code otherwise.
|
||||
*/
|
||||
sbservices_error_t sbservices_client_free(sbservices_client_t client);
|
||||
|
||||
|
||||
/**
|
||||
* Gets the icon state of the connected device.
|
||||
*
|
||||
* @param client The connected sbservices client to use.
|
||||
* @param state Pointer that will point to a newly allocated plist containing
|
||||
* the current icon state. It is up to the caller to free the memory.
|
||||
* @param format_version A string to be passed as formatVersion along with
|
||||
* the request, or NULL if no formatVersion should be passed. This is only
|
||||
* supported since iOS 4.0 so for older firmware versions this must be set
|
||||
* to NULL.
|
||||
*
|
||||
* @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when
|
||||
* client or state is invalid, or an SBSERVICES_E_* error code otherwise.
|
||||
*/
|
||||
sbservices_error_t sbservices_get_icon_state(sbservices_client_t client, plist_t *state, const char *format_version);
|
||||
|
||||
/**
|
||||
* Sets the icon state of the connected device.
|
||||
*
|
||||
* @param client The connected sbservices client to use.
|
||||
* @param newstate A plist containing the new iconstate.
|
||||
*
|
||||
* @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when
|
||||
* client or newstate is NULL, or an SBSERVICES_E_* error code otherwise.
|
||||
*/
|
||||
sbservices_error_t sbservices_set_icon_state(sbservices_client_t client, plist_t newstate);
|
||||
|
||||
/**
|
||||
* Get the icon of the specified app as PNG data.
|
||||
*
|
||||
* @param client The connected sbservices client to use.
|
||||
* @param bundleId The bundle identifier of the app to retrieve the icon for.
|
||||
* @param pngdata Pointer that will point to a newly allocated buffer
|
||||
* containing the PNG data upon successful return. It is up to the caller
|
||||
* to free the memory.
|
||||
* @param pngsize Pointer to a uint64_t that will be set to the size of the
|
||||
* buffer pngdata points to upon successful return.
|
||||
*
|
||||
* @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when
|
||||
* client, bundleId, or pngdata are invalid, or an SBSERVICES_E_* error
|
||||
* code otherwise.
|
||||
*/
|
||||
sbservices_error_t sbservices_get_icon_pngdata(sbservices_client_t client, const char *bundleId, char **pngdata, uint64_t *pngsize);
|
||||
|
||||
/**
|
||||
* Gets the interface orientation of the device.
|
||||
*
|
||||
* @param client The connected sbservices client to use.
|
||||
* @param interface_orientation The interface orientation upon successful return.
|
||||
*
|
||||
* @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when
|
||||
* client or state is invalid, or an SBSERVICES_E_* error code otherwise.
|
||||
*/
|
||||
sbservices_error_t sbservices_get_interface_orientation(sbservices_client_t client, sbservices_interface_orientation_t* interface_orientation);
|
||||
|
||||
/**
|
||||
* Get the home screen wallpaper as PNG data.
|
||||
*
|
||||
* @param client The connected sbservices client to use.
|
||||
* @param pngdata Pointer that will point to a newly allocated buffer
|
||||
* containing the PNG data upon successful return. It is up to the caller
|
||||
* to free the memory.
|
||||
* @param pngsize Pointer to a uint64_t that will be set to the size of the
|
||||
* buffer pngdata points to upon successful return.
|
||||
*
|
||||
* @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when
|
||||
* client or pngdata are invalid, or an SBSERVICES_E_* error
|
||||
* code otherwise.
|
||||
*/
|
||||
sbservices_error_t sbservices_get_home_screen_wallpaper_pngdata(sbservices_client_t client, char **pngdata, uint64_t *pngsize);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,115 @@
|
|||
/**
|
||||
* @file libimobiledevice/screenshotr.h
|
||||
* @brief Retrieve a screenshot from device.
|
||||
* @note Requires a mounted developer image.
|
||||
* \internal
|
||||
*
|
||||
* Copyright (c) 2010-2014 Martin Szulecki All Rights Reserved.
|
||||
* Copyright (c) 2010 Nikias Bassen All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef ISCREENSHOTR_H
|
||||
#define ISCREENSHOTR_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <libimobiledevice/libimobiledevice.h>
|
||||
#include <libimobiledevice/lockdown.h>
|
||||
|
||||
#define SCREENSHOTR_SERVICE_NAME "com.apple.mobile.screenshotr"
|
||||
|
||||
/** Error Codes */
|
||||
typedef enum {
|
||||
SCREENSHOTR_E_SUCCESS = 0,
|
||||
SCREENSHOTR_E_INVALID_ARG = -1,
|
||||
SCREENSHOTR_E_PLIST_ERROR = -2,
|
||||
SCREENSHOTR_E_MUX_ERROR = -3,
|
||||
SCREENSHOTR_E_BAD_VERSION = -4,
|
||||
SCREENSHOTR_E_UNKNOWN_ERROR = -256
|
||||
} screenshotr_error_t;
|
||||
|
||||
typedef struct screenshotr_client_private screenshotr_client_private;
|
||||
typedef screenshotr_client_private *screenshotr_client_t; /**< The client handle. */
|
||||
|
||||
|
||||
/**
|
||||
* Connects to the screenshotr service on the specified device.
|
||||
*
|
||||
* @param device The device to connect to.
|
||||
* @param service The service descriptor returned by lockdownd_start_service.
|
||||
* @param client Pointer that will be set to a newly allocated
|
||||
* screenshotr_client_t upon successful return.
|
||||
*
|
||||
* @note This service is only available if a developer disk image has been
|
||||
* mounted.
|
||||
*
|
||||
* @return SCREENSHOTR_E_SUCCESS on success, SCREENSHOTR_E_INVALID ARG if one
|
||||
* or more parameters are invalid, or SCREENSHOTR_E_CONN_FAILED if the
|
||||
* connection to the device could not be established.
|
||||
*/
|
||||
screenshotr_error_t screenshotr_client_new(idevice_t device, lockdownd_service_descriptor_t service, screenshotr_client_t * client);
|
||||
|
||||
/**
|
||||
* Starts a new screenshotr service on the specified device and connects to it.
|
||||
*
|
||||
* @param device The device to connect to.
|
||||
* @param client Pointer that will point to a newly allocated
|
||||
* screenshotr_client_t upon successful return. Must be freed using
|
||||
* screenshotr_client_free() after use.
|
||||
* @param label The label to use for communication. Usually the program name.
|
||||
* Pass NULL to disable sending the label in requests to lockdownd.
|
||||
*
|
||||
* @return SCREENSHOTR_E_SUCCESS on success, or an SCREENSHOTR_E_* error
|
||||
* code otherwise.
|
||||
*/
|
||||
screenshotr_error_t screenshotr_client_start_service(idevice_t device, screenshotr_client_t* client, const char* label);
|
||||
|
||||
/**
|
||||
* Disconnects a screenshotr client from the device and frees up the
|
||||
* screenshotr client data.
|
||||
*
|
||||
* @param client The screenshotr client to disconnect and free.
|
||||
*
|
||||
* @return SCREENSHOTR_E_SUCCESS on success, or SCREENSHOTR_E_INVALID_ARG
|
||||
* if client is NULL.
|
||||
*/
|
||||
screenshotr_error_t screenshotr_client_free(screenshotr_client_t client);
|
||||
|
||||
|
||||
/**
|
||||
* Get a screen shot from the connected device.
|
||||
*
|
||||
* @param client The connection screenshotr service client.
|
||||
* @param imgdata Pointer that will point to a newly allocated buffer
|
||||
* containing TIFF image data upon successful return. It is up to the
|
||||
* caller to free the memory.
|
||||
* @param imgsize Pointer to a uint64_t that will be set to the size of the
|
||||
* buffer imgdata points to upon successful return.
|
||||
*
|
||||
* @return SCREENSHOTR_E_SUCCESS on success, SCREENSHOTR_E_INVALID_ARG if
|
||||
* one or more parameters are invalid, or another error code if an
|
||||
* error occured.
|
||||
*/
|
||||
screenshotr_error_t screenshotr_take_screenshot(screenshotr_client_t client, char **imgdata, uint64_t *imgsize);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,169 @@
|
|||
/**
|
||||
* @file libimobiledevice/service.h
|
||||
* @brief Generic basic service implementation to inherit.
|
||||
* \internal
|
||||
*
|
||||
* Copyright (c) 2013-2014 Martin Szulecki All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef ISERVICE_H
|
||||
#define ISERVICE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <libimobiledevice/libimobiledevice.h>
|
||||
#include <libimobiledevice/lockdown.h>
|
||||
|
||||
/** Error Codes */
|
||||
typedef enum {
|
||||
SERVICE_E_SUCCESS = 0,
|
||||
SERVICE_E_INVALID_ARG = -1,
|
||||
SERVICE_E_MUX_ERROR = -3,
|
||||
SERVICE_E_SSL_ERROR = -4,
|
||||
SERVICE_E_START_SERVICE_ERROR = -5,
|
||||
SERVICE_E_UNKNOWN_ERROR = -256
|
||||
} service_error_t;
|
||||
|
||||
typedef struct service_client_private service_client_private;
|
||||
typedef service_client_private* service_client_t; /**< The client handle. */
|
||||
|
||||
#define SERVICE_CONSTRUCTOR(x) (int32_t (*)(idevice_t, lockdownd_service_descriptor_t, void**))(x)
|
||||
|
||||
/* Interface */
|
||||
|
||||
/**
|
||||
* Creates a new service for the specified service descriptor.
|
||||
*
|
||||
* @param device The device to connect to.
|
||||
* @param service The service descriptor returned by lockdownd_start_service.
|
||||
* @param client Pointer that will be set to a newly allocated
|
||||
* service_client_t upon successful return.
|
||||
*
|
||||
* @return SERVICE_E_SUCCESS on success,
|
||||
* SERVICE_E_INVALID_ARG when one of the arguments is invalid,
|
||||
* or SERVICE_E_MUX_ERROR when connecting to the device failed.
|
||||
*/
|
||||
service_error_t service_client_new(idevice_t device, lockdownd_service_descriptor_t service, service_client_t *client);
|
||||
|
||||
/**
|
||||
* Starts a new service on the specified device with given name and
|
||||
* connects to it.
|
||||
*
|
||||
* @param device The device to connect to.
|
||||
* @param service_name The name of the service to start.
|
||||
* @param client Pointer that will point to a newly allocated service_client_t
|
||||
* upon successful return. Must be freed using service_client_free() after
|
||||
* use.
|
||||
* @param label The label to use for communication. Usually the program name.
|
||||
* Pass NULL to disable sending the label in requests to lockdownd.
|
||||
*
|
||||
* @return SERVICE_E_SUCCESS on success, or a SERVICE_E_* error code
|
||||
* otherwise.
|
||||
*/
|
||||
service_error_t service_client_factory_start_service(idevice_t device, const char* service_name, void **client, const char* label, int32_t (*constructor_func)(idevice_t, lockdownd_service_descriptor_t, void**), int32_t *error_code);
|
||||
|
||||
/**
|
||||
* Frees a service instance.
|
||||
*
|
||||
* @param client The service instance to free.
|
||||
*
|
||||
* @return SERVICE_E_SUCCESS on success,
|
||||
* SERVICE_E_INVALID_ARG when client is invalid, or a
|
||||
* SERVICE_E_UNKNOWN_ERROR when another error occured.
|
||||
*/
|
||||
service_error_t service_client_free(service_client_t client);
|
||||
|
||||
|
||||
/**
|
||||
* Sends data using the given service client.
|
||||
*
|
||||
* @param client The service client to use for sending.
|
||||
* @param data Data to send
|
||||
* @param size Size of the data to send
|
||||
* @param sent Number of bytes sent (can be NULL to ignore)
|
||||
*
|
||||
* @return SERVICE_E_SUCCESS on success,
|
||||
* SERVICE_E_INVALID_ARG when one or more parameters are
|
||||
* invalid, or SERVICE_E_UNKNOWN_ERROR when an unspecified
|
||||
* error occurs.
|
||||
*/
|
||||
service_error_t service_send(service_client_t client, const char *data, uint32_t size, uint32_t *sent);
|
||||
|
||||
/**
|
||||
* Receives data using the given service client with specified timeout.
|
||||
*
|
||||
* @param client The service client to use for receiving
|
||||
* @param data Buffer that will be filled with the data received
|
||||
* @param size Number of bytes to receive
|
||||
* @param received Number of bytes received (can be NULL to ignore)
|
||||
* @param timeout Maximum time in milliseconds to wait for data.
|
||||
*
|
||||
* @return SERVICE_E_SUCCESS on success,
|
||||
* SERVICE_E_INVALID_ARG when one or more parameters are
|
||||
* invalid, SERVICE_E_MUX_ERROR when a communication error
|
||||
* occurs, or SERVICE_E_UNKNOWN_ERROR when an unspecified
|
||||
* error occurs.
|
||||
*/
|
||||
service_error_t service_receive_with_timeout(service_client_t client, char *data, uint32_t size, uint32_t *received, unsigned int timeout);
|
||||
|
||||
/**
|
||||
* Receives data using the given service client.
|
||||
*
|
||||
* @param client The service client to use for receiving
|
||||
* @param data Buffer that will be filled with the data received
|
||||
* @param size Number of bytes to receive
|
||||
* @param received Number of bytes received (can be NULL to ignore)
|
||||
*
|
||||
* @return SERVICE_E_SUCCESS on success,
|
||||
* SERVICE_E_INVALID_ARG when one or more parameters are
|
||||
* invalid, SERVICE_E_MUX_ERROR when a communication error
|
||||
* occurs, or SERVICE_E_UNKNOWN_ERROR when an unspecified
|
||||
* error occurs.
|
||||
*/
|
||||
service_error_t service_receive(service_client_t client, char *data, uint32_t size, uint32_t *received);
|
||||
|
||||
|
||||
/**
|
||||
* Enable SSL for the given service client.
|
||||
*
|
||||
* @param client The connected service client for that SSL should be enabled.
|
||||
*
|
||||
* @return SERVICE_E_SUCCESS on success,
|
||||
* SERVICE_E_INVALID_ARG if client or client->connection is
|
||||
* NULL, SERVICE_E_SSL_ERROR when SSL could not be enabled,
|
||||
* or SERVICE_E_UNKNOWN_ERROR otherwise.
|
||||
*/
|
||||
service_error_t service_enable_ssl(service_client_t client);
|
||||
|
||||
/**
|
||||
* Disable SSL for the given service client.
|
||||
*
|
||||
* @param client The connected service client for that SSL should be disabled.
|
||||
*
|
||||
* @return SERVICE_E_SUCCESS on success,
|
||||
* SERVICE_E_INVALID_ARG if client or client->connection is
|
||||
* NULL, or SERVICE_E_UNKNOWN_ERROR otherwise.
|
||||
*/
|
||||
service_error_t service_disable_ssl(service_client_t client);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,160 @@
|
|||
/**
|
||||
* @file libimobiledevice/syslog_relay.h
|
||||
* @brief Capture the syslog output from a device.
|
||||
* \internal
|
||||
*
|
||||
* Copyright (c) 2013-2014 Martin Szulecki All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef ISYSLOG_RELAY_H
|
||||
#define ISYSLOG_RELAY_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <libimobiledevice/libimobiledevice.h>
|
||||
#include <libimobiledevice/lockdown.h>
|
||||
|
||||
#define SYSLOG_RELAY_SERVICE_NAME "com.apple.syslog_relay"
|
||||
|
||||
/** Error Codes */
|
||||
typedef enum {
|
||||
SYSLOG_RELAY_E_SUCCESS = 0,
|
||||
SYSLOG_RELAY_E_INVALID_ARG = -1,
|
||||
SYSLOG_RELAY_E_MUX_ERROR = -2,
|
||||
SYSLOG_RELAY_E_SSL_ERROR = -3,
|
||||
SYSLOG_RELAY_E_UNKNOWN_ERROR = -256
|
||||
} syslog_relay_error_t;
|
||||
|
||||
typedef struct syslog_relay_client_private syslog_relay_client_private;
|
||||
typedef syslog_relay_client_private *syslog_relay_client_t; /**< The client handle. */
|
||||
|
||||
/** Receives each character received from the device. */
|
||||
typedef void (*syslog_relay_receive_cb_t)(char c, void *user_data);
|
||||
|
||||
/* Interface */
|
||||
|
||||
/**
|
||||
* Connects to the syslog_relay service on the specified device.
|
||||
*
|
||||
* @param device The device to connect to.
|
||||
* @param service The service descriptor returned by lockdownd_start_service.
|
||||
* @param client Pointer that will point to a newly allocated
|
||||
* syslog_relay_client_t upon successful return. Must be freed using
|
||||
* syslog_relay_client_free() after use.
|
||||
*
|
||||
* @return SYSLOG_RELAY_E_SUCCESS on success, SYSLOG_RELAY_E_INVALID_ARG when
|
||||
* client is NULL, or an SYSLOG_RELAY_E_* error code otherwise.
|
||||
*/
|
||||
syslog_relay_error_t syslog_relay_client_new(idevice_t device, lockdownd_service_descriptor_t service, syslog_relay_client_t * client);
|
||||
|
||||
/**
|
||||
* Starts a new syslog_relay service on the specified device and connects to it.
|
||||
*
|
||||
* @param device The device to connect to.
|
||||
* @param client Pointer that will point to a newly allocated
|
||||
* syslog_relay_client_t upon successful return. Must be freed using
|
||||
* syslog_relay_client_free() after use.
|
||||
* @param label The label to use for communication. Usually the program name.
|
||||
* Pass NULL to disable sending the label in requests to lockdownd.
|
||||
*
|
||||
* @return SYSLOG_RELAY_E_SUCCESS on success, or an SYSLOG_RELAY_E_* error
|
||||
* code otherwise.
|
||||
*/
|
||||
syslog_relay_error_t syslog_relay_client_start_service(idevice_t device, syslog_relay_client_t * client, const char* label);
|
||||
|
||||
/**
|
||||
* Disconnects a syslog_relay client from the device and frees up the
|
||||
* syslog_relay client data.
|
||||
*
|
||||
* @param client The syslog_relay client to disconnect and free.
|
||||
*
|
||||
* @return SYSLOG_RELAY_E_SUCCESS on success, SYSLOG_RELAY_E_INVALID_ARG when
|
||||
* client is NULL, or an SYSLOG_RELAY_E_* error code otherwise.
|
||||
*/
|
||||
syslog_relay_error_t syslog_relay_client_free(syslog_relay_client_t client);
|
||||
|
||||
|
||||
/**
|
||||
* Starts capturing the syslog of the device using a callback.
|
||||
*
|
||||
* Use syslog_relay_stop_capture() to stop receiving the syslog.
|
||||
*
|
||||
* @param client The syslog_relay client to use
|
||||
* @param callback Callback to receive each character from the syslog.
|
||||
* @param user_data Custom pointer passed to the callback function.
|
||||
*
|
||||
* @return SYSLOG_RELAY_E_SUCCESS on success,
|
||||
* SYSLOG_RELAY_E_INVALID_ARG when one or more parameters are
|
||||
* invalid or SYSLOG_RELAY_E_UNKNOWN_ERROR when an unspecified
|
||||
* error occurs or a syslog capture has already been started.
|
||||
*/
|
||||
syslog_relay_error_t syslog_relay_start_capture(syslog_relay_client_t client, syslog_relay_receive_cb_t callback, void* user_data);
|
||||
|
||||
/**
|
||||
* Stops capturing the syslog of the device.
|
||||
*
|
||||
* Use syslog_relay_start_capture() to start receiving the syslog.
|
||||
*
|
||||
* @param client The syslog_relay client to use
|
||||
*
|
||||
* @return SYSLOG_RELAY_E_SUCCESS on success,
|
||||
* SYSLOG_RELAY_E_INVALID_ARG when one or more parameters are
|
||||
* invalid or SYSLOG_RELAY_E_UNKNOWN_ERROR when an unspecified
|
||||
* error occurs or a syslog capture has already been started.
|
||||
*/
|
||||
syslog_relay_error_t syslog_relay_stop_capture(syslog_relay_client_t client);
|
||||
|
||||
/* Receiving */
|
||||
|
||||
/**
|
||||
* Receives data using the given syslog_relay client with specified timeout.
|
||||
*
|
||||
* @param client The syslog_relay client to use for receiving
|
||||
* @param data Buffer that will be filled with the data received
|
||||
* @param size Number of bytes to receive
|
||||
* @param received Number of bytes received (can be NULL to ignore)
|
||||
* @param timeout Maximum time in milliseconds to wait for data.
|
||||
*
|
||||
* @return SYSLOG_RELAY_E_SUCCESS on success,
|
||||
* SYSLOG_RELAY_E_INVALID_ARG when one or more parameters are
|
||||
* invalid, SYSLOG_RELAY_E_MUX_ERROR when a communication error
|
||||
* occurs, or SYSLOG_RELAY_E_UNKNOWN_ERROR when an unspecified
|
||||
* error occurs.
|
||||
*/
|
||||
syslog_relay_error_t syslog_relay_receive_with_timeout(syslog_relay_client_t client, char *data, uint32_t size, uint32_t *received, unsigned int timeout);
|
||||
|
||||
/**
|
||||
* Receives data from the service.
|
||||
*
|
||||
* @param client The syslog_relay client
|
||||
* @param data Buffer that will be filled with the data received
|
||||
* @param size Number of bytes to receive
|
||||
* @param received Number of bytes received (can be NULL to ignore)
|
||||
* @param timeout Maximum time in milliseconds to wait for data.
|
||||
*
|
||||
* @return SYSLOG_RELAY_E_SUCCESS on success,
|
||||
* SYSLOG_RELAY_E_INVALID_ARG when client or plist is NULL
|
||||
*/
|
||||
syslog_relay_error_t syslog_relay_receive(syslog_relay_client_t client, char *data, uint32_t size, uint32_t *received);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,134 @@
|
|||
/**
|
||||
* @file libimobiledevice/webinspector.h
|
||||
* @brief WebKit Remote Debugging.
|
||||
* \internal
|
||||
*
|
||||
* Copyright (c) 2013-2014 Martin Szulecki All Rights Reserved.
|
||||
* Copyright (c) 2013 Yury Melnichek All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef IWEBINSPECTOR_H
|
||||
#define IWEBINSPECTOR_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <libimobiledevice/libimobiledevice.h>
|
||||
#include <libimobiledevice/lockdown.h>
|
||||
|
||||
#define WEBINSPECTOR_SERVICE_NAME "com.apple.webinspector"
|
||||
|
||||
/** Error Codes */
|
||||
typedef enum {
|
||||
WEBINSPECTOR_E_SUCCESS = 0,
|
||||
WEBINSPECTOR_E_INVALID_ARG = -1,
|
||||
WEBINSPECTOR_E_PLIST_ERROR = -2,
|
||||
WEBINSPECTOR_E_MUX_ERROR = -3,
|
||||
WEBINSPECTOR_E_SSL_ERROR = -4,
|
||||
WEBINSPECTOR_E_UNKNOWN_ERROR = -256
|
||||
} webinspector_error_t;
|
||||
|
||||
typedef struct webinspector_client_private webinspector_client_private;
|
||||
typedef webinspector_client_private *webinspector_client_t; /**< The client handle. */
|
||||
|
||||
|
||||
/**
|
||||
* Connects to the webinspector service on the specified device.
|
||||
*
|
||||
* @param device The device to connect to.
|
||||
* @param service The service descriptor returned by lockdownd_start_service.
|
||||
* @param client Pointer that will point to a newly allocated
|
||||
* webinspector_client_t upon successful return. Must be freed using
|
||||
* webinspector_client_free() after use.
|
||||
*
|
||||
* @return WEBINSPECTOR_E_SUCCESS on success, WEBINSPECTOR_E_INVALID_ARG when
|
||||
* client is NULL, or an WEBINSPECTOR_E_* error code otherwise.
|
||||
*/
|
||||
webinspector_error_t webinspector_client_new(idevice_t device, lockdownd_service_descriptor_t service, webinspector_client_t * client);
|
||||
|
||||
/**
|
||||
* Starts a new webinspector service on the specified device and connects to it.
|
||||
*
|
||||
* @param device The device to connect to.
|
||||
* @param client Pointer that will point to a newly allocated
|
||||
* webinspector_client_t upon successful return. Must be freed using
|
||||
* webinspector_client_free() after use.
|
||||
* @param label The label to use for communication. Usually the program name.
|
||||
* Pass NULL to disable sending the label in requests to lockdownd.
|
||||
*
|
||||
* @return WEBINSPECTOR_E_SUCCESS on success, or an WEBINSPECTOR_E_* error
|
||||
* code otherwise.
|
||||
*/
|
||||
webinspector_error_t webinspector_client_start_service(idevice_t device, webinspector_client_t * client, const char* label);
|
||||
|
||||
/**
|
||||
* Disconnects a webinspector client from the device and frees up the
|
||||
* webinspector client data.
|
||||
*
|
||||
* @param client The webinspector client to disconnect and free.
|
||||
*
|
||||
* @return WEBINSPECTOR_E_SUCCESS on success, WEBINSPECTOR_E_INVALID_ARG when
|
||||
* client is NULL, or an WEBINSPECTOR_E_* error code otherwise.
|
||||
*/
|
||||
webinspector_error_t webinspector_client_free(webinspector_client_t client);
|
||||
|
||||
|
||||
/**
|
||||
* Sends a plist to the service.
|
||||
*
|
||||
* @param client The webinspector client
|
||||
* @param plist The plist to send
|
||||
*
|
||||
* @return DIAGNOSTICS_RELAY_E_SUCCESS on success,
|
||||
* DIAGNOSTICS_RELAY_E_INVALID_ARG when client or plist is NULL
|
||||
*/
|
||||
webinspector_error_t webinspector_send(webinspector_client_t client, plist_t plist);
|
||||
|
||||
/**
|
||||
* Receives a plist from the service.
|
||||
*
|
||||
* @param client The webinspector client
|
||||
* @param plist The plist to store the received data
|
||||
*
|
||||
* @return DIAGNOSTICS_RELAY_E_SUCCESS on success,
|
||||
* DIAGNOSTICS_RELAY_E_INVALID_ARG when client or plist is NULL
|
||||
*/
|
||||
webinspector_error_t webinspector_receive(webinspector_client_t client, plist_t * plist);
|
||||
|
||||
/**
|
||||
* Receives a plist using the given webinspector client.
|
||||
*
|
||||
* @param client The webinspector client to use for receiving
|
||||
* @param plist pointer to a plist_t that will point to the received plist
|
||||
* upon successful return
|
||||
* @param timeout Maximum time in milliseconds to wait for data.
|
||||
*
|
||||
* @return WEBINSPECTOR_E_SUCCESS on success,
|
||||
* WEBINSPECTOR_E_INVALID_ARG when client or *plist is NULL,
|
||||
* WEBINSPECTOR_E_PLIST_ERROR when the received data cannot be
|
||||
* converted to a plist, WEBINSPECTOR_E_MUX_ERROR when a
|
||||
* communication error occurs, or WEBINSPECTOR_E_UNKNOWN_ERROR
|
||||
* when an unspecified error occurs.
|
||||
*/
|
||||
webinspector_error_t webinspector_receive_with_timeout(webinspector_client_t client, plist_t * plist, uint32_t timeout_ms);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* Array.h
|
||||
* Array node type for C++ binding
|
||||
*
|
||||
* Copyright (c) 2009 Jonathan Beck All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef PLIST_ARRAY_H
|
||||
#define PLIST_ARRAY_H
|
||||
|
||||
#include <plist/Structure.h>
|
||||
#include <vector>
|
||||
|
||||
namespace PList
|
||||
{
|
||||
|
||||
class Array : public Structure
|
||||
{
|
||||
public :
|
||||
Array(Node* parent = NULL);
|
||||
Array(plist_t node, Node* parent = NULL);
|
||||
Array(const Array& a);
|
||||
Array& operator=(Array& a);
|
||||
virtual ~Array();
|
||||
|
||||
Node* Clone() const;
|
||||
|
||||
Node* operator[](unsigned int index);
|
||||
void Append(Node* node);
|
||||
void Insert(Node* node, unsigned int pos);
|
||||
void Remove(Node* node);
|
||||
void Remove(unsigned int pos);
|
||||
unsigned int GetNodeIndex(Node* node) const;
|
||||
|
||||
private :
|
||||
std::vector<Node*> _array;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif // PLIST_ARRAY_H
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Boolean.h
|
||||
* Boolean node type for C++ binding
|
||||
*
|
||||
* Copyright (c) 2009 Jonathan Beck All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef PLIST_BOOLEAN_H
|
||||
#define PLIST_BOOLEAN_H
|
||||
|
||||
#include <plist/Node.h>
|
||||
|
||||
namespace PList
|
||||
{
|
||||
|
||||
class Boolean : public Node
|
||||
{
|
||||
public :
|
||||
Boolean(Node* parent = NULL);
|
||||
Boolean(plist_t node, Node* parent = NULL);
|
||||
Boolean(const Boolean& b);
|
||||
Boolean& operator=(Boolean& b);
|
||||
Boolean(bool b);
|
||||
virtual ~Boolean();
|
||||
|
||||
Node* Clone() const;
|
||||
|
||||
void SetValue(bool b);
|
||||
bool GetValue() const;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif // PLIST_BOOLEAN_H
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Data.h
|
||||
* Data node type for C++ binding
|
||||
*
|
||||
* Copyright (c) 2009 Jonathan Beck All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef PLIST_DATA_H
|
||||
#define PLIST_DATA_H
|
||||
|
||||
#include <plist/Node.h>
|
||||
#include <vector>
|
||||
|
||||
namespace PList
|
||||
{
|
||||
|
||||
class Data : public Node
|
||||
{
|
||||
public :
|
||||
Data(Node* parent = NULL);
|
||||
Data(plist_t node, Node* parent = NULL);
|
||||
Data(const Data& d);
|
||||
Data& operator=(Data& d);
|
||||
Data(const std::vector<char>& buff);
|
||||
virtual ~Data();
|
||||
|
||||
Node* Clone() const;
|
||||
|
||||
void SetValue(const std::vector<char>& buff);
|
||||
std::vector<char> GetValue() const;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif // PLIST_DATA_H
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Date.h
|
||||
* Date node type for C++ binding
|
||||
*
|
||||
* Copyright (c) 2009 Jonathan Beck All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef PLIST_DATE_H
|
||||
#define PLIST_DATE_H
|
||||
|
||||
#include <plist/Node.h>
|
||||
#include <ctime>
|
||||
#include <sys/time.h>
|
||||
|
||||
namespace PList
|
||||
{
|
||||
|
||||
class Date : public Node
|
||||
{
|
||||
public :
|
||||
Date(Node* parent = NULL);
|
||||
Date(plist_t node, Node* parent = NULL);
|
||||
Date(const Date& d);
|
||||
Date& operator=(Date& d);
|
||||
Date(timeval t);
|
||||
virtual ~Date();
|
||||
|
||||
Node* Clone() const;
|
||||
|
||||
void SetValue(timeval t);
|
||||
timeval GetValue() const;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif // PLIST_DATE_H
|
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* Dictionary.h
|
||||
* Dictionary node type for C++ binding
|
||||
*
|
||||
* Copyright (c) 2009 Jonathan Beck All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef PLIST_DICTIONARY_H
|
||||
#define PLIST_DICTIONARY_H
|
||||
|
||||
#include <plist/Structure.h>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
namespace PList
|
||||
{
|
||||
|
||||
class Dictionary : public Structure
|
||||
{
|
||||
public :
|
||||
Dictionary(Node* parent = NULL);
|
||||
Dictionary(plist_t node, Node* parent = NULL);
|
||||
Dictionary(const Dictionary& d);
|
||||
Dictionary& operator=(Dictionary& d);
|
||||
virtual ~Dictionary();
|
||||
|
||||
Node* Clone() const;
|
||||
|
||||
typedef std::map<std::string,Node*>::iterator iterator;
|
||||
typedef std::map<std::string,Node*>::const_iterator const_iterator;
|
||||
|
||||
Node* operator[](const std::string& key);
|
||||
iterator Begin();
|
||||
iterator End();
|
||||
iterator Find(const std::string& key);
|
||||
const_iterator Begin() const;
|
||||
const_iterator End() const;
|
||||
const_iterator Find(const std::string& key) const;
|
||||
iterator Set(const std::string& key, const Node* node);
|
||||
iterator Set(const std::string& key, const Node& node);
|
||||
iterator Insert(const std::string& key, Node* node) PLIST_WARN_DEPRECATED("use Set() instead");
|
||||
void Remove(Node* node);
|
||||
void Remove(const std::string& key);
|
||||
std::string GetNodeKey(Node* key);
|
||||
|
||||
private :
|
||||
std::map<std::string,Node*> _map;
|
||||
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif // PLIST_DICTIONARY_H
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Integer.h
|
||||
* Integer node type for C++ binding
|
||||
*
|
||||
* Copyright (c) 2009 Jonathan Beck All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef PLIST_INTEGER_H
|
||||
#define PLIST_INTEGER_H
|
||||
|
||||
#include <plist/Node.h>
|
||||
|
||||
namespace PList
|
||||
{
|
||||
|
||||
class Integer : public Node
|
||||
{
|
||||
public :
|
||||
Integer(Node* parent = NULL);
|
||||
Integer(plist_t node, Node* parent = NULL);
|
||||
Integer(const Integer& i);
|
||||
Integer& operator=(Integer& i);
|
||||
Integer(uint64_t i);
|
||||
virtual ~Integer();
|
||||
|
||||
Node* Clone() const;
|
||||
|
||||
void SetValue(uint64_t i);
|
||||
uint64_t GetValue() const;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif // PLIST_INTEGER_H
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Key.h
|
||||
* Key node type for C++ binding
|
||||
*
|
||||
* Copyright (c) 2012 Nikias Bassen, All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef PLIST_KEY_H
|
||||
#define PLIST_KEY_H
|
||||
|
||||
#include <plist/Node.h>
|
||||
#include <string>
|
||||
|
||||
namespace PList
|
||||
{
|
||||
|
||||
class Key : public Node
|
||||
{
|
||||
public :
|
||||
Key(Node* parent = NULL);
|
||||
Key(plist_t node, Node* parent = NULL);
|
||||
Key(const Key& s);
|
||||
Key& operator=(Key& s);
|
||||
Key(const std::string& s);
|
||||
virtual ~Key();
|
||||
|
||||
Node* Clone() const;
|
||||
|
||||
void SetValue(const std::string& s);
|
||||
std::string GetValue() const;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif // PLIST_KEY_H
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* Node.h
|
||||
* Abstract node type for C++ binding
|
||||
*
|
||||
* Copyright (c) 2009 Jonathan Beck All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef PLIST_NODE_H
|
||||
#define PLIST_NODE_H
|
||||
|
||||
#include <plist/plist.h>
|
||||
#include <cstddef>
|
||||
|
||||
namespace PList
|
||||
{
|
||||
|
||||
class Node
|
||||
{
|
||||
public :
|
||||
virtual ~Node();
|
||||
|
||||
virtual Node* Clone() const = 0;
|
||||
|
||||
Node * GetParent() const;
|
||||
plist_type GetType() const;
|
||||
plist_t GetPlist() const;
|
||||
|
||||
static Node* FromPlist(plist_t node, Node* parent = NULL);
|
||||
|
||||
protected:
|
||||
Node(Node* parent = NULL);
|
||||
Node(plist_t node, Node* parent = NULL);
|
||||
Node(plist_type type, Node* parent = NULL);
|
||||
plist_t _node;
|
||||
|
||||
private:
|
||||
Node* _parent;
|
||||
friend class Structure;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif // PLIST_NODE_H
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Real.h
|
||||
* Real node type for C++ binding
|
||||
*
|
||||
* Copyright (c) 2009 Jonathan Beck All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef PLIST_REAL_H
|
||||
#define PLIST_REAL_H
|
||||
|
||||
#include <plist/Node.h>
|
||||
|
||||
namespace PList
|
||||
{
|
||||
|
||||
class Real : public Node
|
||||
{
|
||||
public :
|
||||
Real(Node* parent = NULL);
|
||||
Real(plist_t node, Node* parent = NULL);
|
||||
Real(const Real& d);
|
||||
Real& operator=(Real& d);
|
||||
Real(double d);
|
||||
virtual ~Real();
|
||||
|
||||
Node* Clone() const;
|
||||
|
||||
void SetValue(double d);
|
||||
double GetValue() const;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif // PLIST_REAL_H
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* String.h
|
||||
* String node type for C++ binding
|
||||
*
|
||||
* Copyright (c) 2009 Jonathan Beck All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef PLIST_STRING_H
|
||||
#define PLIST_STRING_H
|
||||
|
||||
#include <plist/Node.h>
|
||||
#include <string>
|
||||
|
||||
namespace PList
|
||||
{
|
||||
|
||||
class String : public Node
|
||||
{
|
||||
public :
|
||||
String(Node* parent = NULL);
|
||||
String(plist_t node, Node* parent = NULL);
|
||||
String(const String& s);
|
||||
String& operator=(String& s);
|
||||
String(const std::string& s);
|
||||
virtual ~String();
|
||||
|
||||
Node* Clone() const;
|
||||
|
||||
void SetValue(const std::string& s);
|
||||
std::string GetValue() const;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif // PLIST_STRING_H
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Structure.h
|
||||
* Structure node type for C++ binding
|
||||
*
|
||||
* Copyright (c) 2009 Jonathan Beck All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef PLIST_STRUCTURE_H
|
||||
#define PLIST_STRUCTURE_H
|
||||
|
||||
#include <plist/Node.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace PList
|
||||
{
|
||||
|
||||
class Structure : public Node
|
||||
{
|
||||
public :
|
||||
virtual ~Structure();
|
||||
|
||||
uint32_t GetSize() const;
|
||||
|
||||
std::string ToXml() const;
|
||||
std::vector<char> ToBin() const;
|
||||
|
||||
virtual void Remove(Node* node) = 0;
|
||||
|
||||
static Structure* FromXml(const std::string& xml);
|
||||
static Structure* FromBin(const std::vector<char>& bin);
|
||||
|
||||
protected:
|
||||
Structure(Node* parent = NULL);
|
||||
Structure(plist_type type, Node* parent = NULL);
|
||||
void UpdateNodeParent(Node* node);
|
||||
|
||||
private:
|
||||
Structure(Structure& s);
|
||||
Structure& operator=(const Structure& s);
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif // PLIST_STRUCTURE_H
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Uid.h
|
||||
* Uid node type for C++ binding
|
||||
*
|
||||
* Copyright (c) 2012 Nikias Bassen, All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef PLIST_UID_H
|
||||
#define PLIST_UID_H
|
||||
|
||||
#include <plist/Node.h>
|
||||
|
||||
namespace PList
|
||||
{
|
||||
|
||||
class Uid : public Node
|
||||
{
|
||||
public :
|
||||
Uid(Node* parent = NULL);
|
||||
Uid(plist_t node, Node* parent = NULL);
|
||||
Uid(const Uid& i);
|
||||
Uid& operator=(Uid& i);
|
||||
Uid(uint64_t i);
|
||||
virtual ~Uid();
|
||||
|
||||
Node* Clone() const;
|
||||
|
||||
void SetValue(uint64_t i);
|
||||
uint64_t GetValue() const;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif // PLIST_UID_H
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* plist++.h
|
||||
* Main include of libplist C++ binding
|
||||
*
|
||||
* Copyright (c) 2009 Jonathan Beck All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef LIBPLISTXX_H
|
||||
#define LIBPLISTXX_H
|
||||
|
||||
#include "plist.h"
|
||||
#include "Array.h"
|
||||
#include "Boolean.h"
|
||||
#include "Data.h"
|
||||
#include "Date.h"
|
||||
#include "Dictionary.h"
|
||||
#include "Integer.h"
|
||||
#include "Node.h"
|
||||
#include "Real.h"
|
||||
#include "Key.h"
|
||||
#include "Uid.h"
|
||||
#include "String.h"
|
||||
#include "Structure.h"
|
||||
|
||||
#endif
|
|
@ -0,0 +1,770 @@
|
|||
/**
|
||||
* @file plist/plist.h
|
||||
* @brief Main include of libplist
|
||||
* \internal
|
||||
*
|
||||
* Copyright (c) 2012-2019 Nikias Bassen, All Rights Reserved.
|
||||
* Copyright (c) 2008-2009 Jonathan Beck, All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef LIBPLIST_H
|
||||
#define LIBPLIST_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#if _MSC_VER && _MSC_VER < 1700
|
||||
typedef __int8 int8_t;
|
||||
typedef __int16 int16_t;
|
||||
typedef __int32 int32_t;
|
||||
typedef __int64 int64_t;
|
||||
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef unsigned __int16 uint16_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
#ifdef __llvm__
|
||||
#if defined(__has_extension)
|
||||
#if (__has_extension(attribute_deprecated_with_message))
|
||||
#ifndef PLIST_WARN_DEPRECATED
|
||||
#define PLIST_WARN_DEPRECATED(x) __attribute__((deprecated(x)))
|
||||
#endif
|
||||
#else
|
||||
#ifndef PLIST_WARN_DEPRECATED
|
||||
#define PLIST_WARN_DEPRECATED(x) __attribute__((deprecated))
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
#ifndef PLIST_WARN_DEPRECATED
|
||||
#define PLIST_WARN_DEPRECATED(x) __attribute__((deprecated))
|
||||
#endif
|
||||
#endif
|
||||
#elif (__GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ >= 5)))
|
||||
#ifndef PLIST_WARN_DEPRECATED
|
||||
#define PLIST_WARN_DEPRECATED(x) __attribute__((deprecated(x)))
|
||||
#endif
|
||||
#elif defined(_MSC_VER)
|
||||
#ifndef PLIST_WARN_DEPRECATED
|
||||
#define PLIST_WARN_DEPRECATED(x) __declspec(deprecated(x))
|
||||
#endif
|
||||
#else
|
||||
#define PLIST_WARN_DEPRECATED(x)
|
||||
#pragma message("WARNING: You need to implement DEPRECATED for this compiler")
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
/**
|
||||
* \mainpage libplist : A library to handle Apple Property Lists
|
||||
* \defgroup PublicAPI Public libplist API
|
||||
*/
|
||||
/*@{*/
|
||||
|
||||
|
||||
/**
|
||||
* The basic plist abstract data type.
|
||||
*/
|
||||
typedef void *plist_t;
|
||||
|
||||
/**
|
||||
* The plist dictionary iterator.
|
||||
*/
|
||||
typedef void* plist_dict_iter;
|
||||
|
||||
/**
|
||||
* The plist array iterator.
|
||||
*/
|
||||
typedef void* plist_array_iter;
|
||||
|
||||
/**
|
||||
* The enumeration of plist node types.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PLIST_BOOLEAN, /**< Boolean, scalar type */
|
||||
PLIST_UINT, /**< Unsigned integer, scalar type */
|
||||
PLIST_REAL, /**< Real, scalar type */
|
||||
PLIST_STRING, /**< ASCII string, scalar type */
|
||||
PLIST_ARRAY, /**< Ordered array, structured type */
|
||||
PLIST_DICT, /**< Unordered dictionary (key/value pair), structured type */
|
||||
PLIST_DATE, /**< Date, scalar type */
|
||||
PLIST_DATA, /**< Binary data, scalar type */
|
||||
PLIST_KEY, /**< Key in dictionaries (ASCII String), scalar type */
|
||||
PLIST_UID, /**< Special type used for 'keyed encoding' */
|
||||
PLIST_NONE /**< No type */
|
||||
} plist_type;
|
||||
|
||||
|
||||
/********************************************
|
||||
* *
|
||||
* Creation & Destruction *
|
||||
* *
|
||||
********************************************/
|
||||
|
||||
/**
|
||||
* Create a new root plist_t type #PLIST_DICT
|
||||
*
|
||||
* @return the created plist
|
||||
* @sa #plist_type
|
||||
*/
|
||||
plist_t plist_new_dict(void);
|
||||
|
||||
/**
|
||||
* Create a new root plist_t type #PLIST_ARRAY
|
||||
*
|
||||
* @return the created plist
|
||||
* @sa #plist_type
|
||||
*/
|
||||
plist_t plist_new_array(void);
|
||||
|
||||
/**
|
||||
* Create a new plist_t type #PLIST_STRING
|
||||
*
|
||||
* @param val the sting value, encoded in UTF8.
|
||||
* @return the created item
|
||||
* @sa #plist_type
|
||||
*/
|
||||
plist_t plist_new_string(const char *val);
|
||||
|
||||
/**
|
||||
* Create a new plist_t type #PLIST_BOOLEAN
|
||||
*
|
||||
* @param val the boolean value, 0 is false, other values are true.
|
||||
* @return the created item
|
||||
* @sa #plist_type
|
||||
*/
|
||||
plist_t plist_new_bool(uint8_t val);
|
||||
|
||||
/**
|
||||
* Create a new plist_t type #PLIST_UINT
|
||||
*
|
||||
* @param val the unsigned integer value
|
||||
* @return the created item
|
||||
* @sa #plist_type
|
||||
*/
|
||||
plist_t plist_new_uint(uint64_t val);
|
||||
|
||||
/**
|
||||
* Create a new plist_t type #PLIST_REAL
|
||||
*
|
||||
* @param val the real value
|
||||
* @return the created item
|
||||
* @sa #plist_type
|
||||
*/
|
||||
plist_t plist_new_real(double val);
|
||||
|
||||
/**
|
||||
* Create a new plist_t type #PLIST_DATA
|
||||
*
|
||||
* @param val the binary buffer
|
||||
* @param length the length of the buffer
|
||||
* @return the created item
|
||||
* @sa #plist_type
|
||||
*/
|
||||
plist_t plist_new_data(const char *val, uint64_t length);
|
||||
|
||||
/**
|
||||
* Create a new plist_t type #PLIST_DATE
|
||||
*
|
||||
* @param sec the number of seconds since 01/01/2001
|
||||
* @param usec the number of microseconds
|
||||
* @return the created item
|
||||
* @sa #plist_type
|
||||
*/
|
||||
plist_t plist_new_date(int32_t sec, int32_t usec);
|
||||
|
||||
/**
|
||||
* Create a new plist_t type #PLIST_UID
|
||||
*
|
||||
* @param val the unsigned integer value
|
||||
* @return the created item
|
||||
* @sa #plist_type
|
||||
*/
|
||||
plist_t plist_new_uid(uint64_t val);
|
||||
|
||||
/**
|
||||
* Destruct a plist_t node and all its children recursively
|
||||
*
|
||||
* @param plist the plist to free
|
||||
*/
|
||||
void plist_free(plist_t plist);
|
||||
|
||||
/**
|
||||
* Return a copy of passed node and it's children
|
||||
*
|
||||
* @param node the plist to copy
|
||||
* @return copied plist
|
||||
*/
|
||||
plist_t plist_copy(plist_t node);
|
||||
|
||||
|
||||
/********************************************
|
||||
* *
|
||||
* Array functions *
|
||||
* *
|
||||
********************************************/
|
||||
|
||||
/**
|
||||
* Get size of a #PLIST_ARRAY node.
|
||||
*
|
||||
* @param node the node of type #PLIST_ARRAY
|
||||
* @return size of the #PLIST_ARRAY node
|
||||
*/
|
||||
uint32_t plist_array_get_size(plist_t node);
|
||||
|
||||
/**
|
||||
* Get the nth item in a #PLIST_ARRAY node.
|
||||
*
|
||||
* @param node the node of type #PLIST_ARRAY
|
||||
* @param n the index of the item to get. Range is [0, array_size[
|
||||
* @return the nth item or NULL if node is not of type #PLIST_ARRAY
|
||||
*/
|
||||
plist_t plist_array_get_item(plist_t node, uint32_t n);
|
||||
|
||||
/**
|
||||
* Get the index of an item. item must be a member of a #PLIST_ARRAY node.
|
||||
*
|
||||
* @param node the node
|
||||
* @return the node index or UINT_MAX if node index can't be determined
|
||||
*/
|
||||
uint32_t plist_array_get_item_index(plist_t node);
|
||||
|
||||
/**
|
||||
* Set the nth item in a #PLIST_ARRAY node.
|
||||
* The previous item at index n will be freed using #plist_free
|
||||
*
|
||||
* @param node the node of type #PLIST_ARRAY
|
||||
* @param item the new item at index n. The array is responsible for freeing item when it is no longer needed.
|
||||
* @param n the index of the item to get. Range is [0, array_size[. Assert if n is not in range.
|
||||
*/
|
||||
void plist_array_set_item(plist_t node, plist_t item, uint32_t n);
|
||||
|
||||
/**
|
||||
* Append a new item at the end of a #PLIST_ARRAY node.
|
||||
*
|
||||
* @param node the node of type #PLIST_ARRAY
|
||||
* @param item the new item. The array is responsible for freeing item when it is no longer needed.
|
||||
*/
|
||||
void plist_array_append_item(plist_t node, plist_t item);
|
||||
|
||||
/**
|
||||
* Insert a new item at position n in a #PLIST_ARRAY node.
|
||||
*
|
||||
* @param node the node of type #PLIST_ARRAY
|
||||
* @param item the new item to insert. The array is responsible for freeing item when it is no longer needed.
|
||||
* @param n The position at which the node will be stored. Range is [0, array_size[. Assert if n is not in range.
|
||||
*/
|
||||
void plist_array_insert_item(plist_t node, plist_t item, uint32_t n);
|
||||
|
||||
/**
|
||||
* Remove an existing position in a #PLIST_ARRAY node.
|
||||
* Removed position will be freed using #plist_free.
|
||||
*
|
||||
* @param node the node of type #PLIST_ARRAY
|
||||
* @param n The position to remove. Range is [0, array_size[. Assert if n is not in range.
|
||||
*/
|
||||
void plist_array_remove_item(plist_t node, uint32_t n);
|
||||
|
||||
/**
|
||||
* Remove a node that is a child node of a #PLIST_ARRAY node.
|
||||
* node will be freed using #plist_free.
|
||||
*
|
||||
* @param node The node to be removed from its #PLIST_ARRAY parent.
|
||||
*/
|
||||
void plist_array_item_remove(plist_t node);
|
||||
|
||||
/**
|
||||
* Create an iterator of a #PLIST_ARRAY node.
|
||||
* The allocated iterator should be freed with the standard free function.
|
||||
*
|
||||
* @param node The node of type #PLIST_ARRAY
|
||||
* @param iter Location to store the iterator for the array.
|
||||
*/
|
||||
void plist_array_new_iter(plist_t node, plist_array_iter *iter);
|
||||
|
||||
/**
|
||||
* Increment iterator of a #PLIST_ARRAY node.
|
||||
*
|
||||
* @param node The node of type #PLIST_ARRAY.
|
||||
* @param iter Iterator of the array
|
||||
* @param item Location to store the item. The caller must *not* free the
|
||||
* returned item. Will be set to NULL when no more items are left
|
||||
* to iterate.
|
||||
*/
|
||||
void plist_array_next_item(plist_t node, plist_array_iter iter, plist_t *item);
|
||||
|
||||
|
||||
/********************************************
|
||||
* *
|
||||
* Dictionary functions *
|
||||
* *
|
||||
********************************************/
|
||||
|
||||
/**
|
||||
* Get size of a #PLIST_DICT node.
|
||||
*
|
||||
* @param node the node of type #PLIST_DICT
|
||||
* @return size of the #PLIST_DICT node
|
||||
*/
|
||||
uint32_t plist_dict_get_size(plist_t node);
|
||||
|
||||
/**
|
||||
* Create an iterator of a #PLIST_DICT node.
|
||||
* The allocated iterator should be freed with the standard free function.
|
||||
*
|
||||
* @param node The node of type #PLIST_DICT.
|
||||
* @param iter Location to store the iterator for the dictionary.
|
||||
*/
|
||||
void plist_dict_new_iter(plist_t node, plist_dict_iter *iter);
|
||||
|
||||
/**
|
||||
* Increment iterator of a #PLIST_DICT node.
|
||||
*
|
||||
* @param node The node of type #PLIST_DICT
|
||||
* @param iter Iterator of the dictionary
|
||||
* @param key Location to store the key, or NULL. The caller is responsible
|
||||
* for freeing the the returned string.
|
||||
* @param val Location to store the value, or NULL. The caller must *not*
|
||||
* free the returned value. Will be set to NULL when no more
|
||||
* key/value pairs are left to iterate.
|
||||
*/
|
||||
void plist_dict_next_item(plist_t node, plist_dict_iter iter, char **key, plist_t *val);
|
||||
|
||||
/**
|
||||
* Get key associated key to an item. Item must be member of a dictionary.
|
||||
*
|
||||
* @param node the item
|
||||
* @param key a location to store the key. The caller is responsible for freeing the returned string.
|
||||
*/
|
||||
void plist_dict_get_item_key(plist_t node, char **key);
|
||||
|
||||
/**
|
||||
* Get the nth item in a #PLIST_DICT node.
|
||||
*
|
||||
* @param node the node of type #PLIST_DICT
|
||||
* @param key the identifier of the item to get.
|
||||
* @return the item or NULL if node is not of type #PLIST_DICT. The caller should not free
|
||||
* the returned node.
|
||||
*/
|
||||
plist_t plist_dict_get_item(plist_t node, const char* key);
|
||||
|
||||
/**
|
||||
* Get key node associated to an item. Item must be member of a dictionary.
|
||||
*
|
||||
* @param node the item
|
||||
* @return the key node of the given item, or NULL.
|
||||
*/
|
||||
plist_t plist_dict_item_get_key(plist_t node);
|
||||
|
||||
/**
|
||||
* Set item identified by key in a #PLIST_DICT node.
|
||||
* The previous item identified by key will be freed using #plist_free.
|
||||
* If there is no item for the given key a new item will be inserted.
|
||||
*
|
||||
* @param node the node of type #PLIST_DICT
|
||||
* @param item the new item associated to key
|
||||
* @param key the identifier of the item to set.
|
||||
*/
|
||||
void plist_dict_set_item(plist_t node, const char* key, plist_t item);
|
||||
|
||||
/**
|
||||
* Insert a new item into a #PLIST_DICT node.
|
||||
*
|
||||
* @deprecated Deprecated. Use plist_dict_set_item instead.
|
||||
*
|
||||
* @param node the node of type #PLIST_DICT
|
||||
* @param item the new item to insert
|
||||
* @param key The identifier of the item to insert.
|
||||
*/
|
||||
PLIST_WARN_DEPRECATED("use plist_dict_set_item instead")
|
||||
void plist_dict_insert_item(plist_t node, const char* key, plist_t item);
|
||||
|
||||
/**
|
||||
* Remove an existing position in a #PLIST_DICT node.
|
||||
* Removed position will be freed using #plist_free
|
||||
*
|
||||
* @param node the node of type #PLIST_DICT
|
||||
* @param key The identifier of the item to remove. Assert if identifier is not present.
|
||||
*/
|
||||
void plist_dict_remove_item(plist_t node, const char* key);
|
||||
|
||||
/**
|
||||
* Merge a dictionary into another. This will add all key/value pairs
|
||||
* from the source dictionary to the target dictionary, overwriting
|
||||
* any existing key/value pairs that are already present in target.
|
||||
*
|
||||
* @param target pointer to an existing node of type #PLIST_DICT
|
||||
* @param source node of type #PLIST_DICT that should be merged into target
|
||||
*/
|
||||
void plist_dict_merge(plist_t *target, plist_t source);
|
||||
|
||||
|
||||
/********************************************
|
||||
* *
|
||||
* Getters *
|
||||
* *
|
||||
********************************************/
|
||||
|
||||
/**
|
||||
* Get the parent of a node
|
||||
*
|
||||
* @param node the parent (NULL if node is root)
|
||||
*/
|
||||
plist_t plist_get_parent(plist_t node);
|
||||
|
||||
/**
|
||||
* Get the #plist_type of a node.
|
||||
*
|
||||
* @param node the node
|
||||
* @return the type of the node
|
||||
*/
|
||||
plist_type plist_get_node_type(plist_t node);
|
||||
|
||||
/**
|
||||
* Get the value of a #PLIST_KEY node.
|
||||
* This function does nothing if node is not of type #PLIST_KEY
|
||||
*
|
||||
* @param node the node
|
||||
* @param val a pointer to a C-string. This function allocates the memory,
|
||||
* caller is responsible for freeing it.
|
||||
*/
|
||||
void plist_get_key_val(plist_t node, char **val);
|
||||
|
||||
/**
|
||||
* Get the value of a #PLIST_STRING node.
|
||||
* This function does nothing if node is not of type #PLIST_STRING
|
||||
*
|
||||
* @param node the node
|
||||
* @param val a pointer to a C-string. This function allocates the memory,
|
||||
* caller is responsible for freeing it. Data is UTF-8 encoded.
|
||||
*/
|
||||
void plist_get_string_val(plist_t node, char **val);
|
||||
|
||||
/**
|
||||
* Get a pointer to the buffer of a #PLIST_STRING node.
|
||||
*
|
||||
* @note DO NOT MODIFY the buffer. Mind that the buffer is only available
|
||||
* until the plist node gets freed. Make a copy if needed.
|
||||
*
|
||||
* @param node The node
|
||||
* @param length If non-NULL, will be set to the length of the string
|
||||
*
|
||||
* @return Pointer to the NULL-terminated buffer.
|
||||
*/
|
||||
const char* plist_get_string_ptr(plist_t node, uint64_t* length);
|
||||
|
||||
/**
|
||||
* Get the value of a #PLIST_BOOLEAN node.
|
||||
* This function does nothing if node is not of type #PLIST_BOOLEAN
|
||||
*
|
||||
* @param node the node
|
||||
* @param val a pointer to a uint8_t variable.
|
||||
*/
|
||||
void plist_get_bool_val(plist_t node, uint8_t * val);
|
||||
|
||||
/**
|
||||
* Get the value of a #PLIST_UINT node.
|
||||
* This function does nothing if node is not of type #PLIST_UINT
|
||||
*
|
||||
* @param node the node
|
||||
* @param val a pointer to a uint64_t variable.
|
||||
*/
|
||||
void plist_get_uint_val(plist_t node, uint64_t * val);
|
||||
|
||||
/**
|
||||
* Get the value of a #PLIST_REAL node.
|
||||
* This function does nothing if node is not of type #PLIST_REAL
|
||||
*
|
||||
* @param node the node
|
||||
* @param val a pointer to a double variable.
|
||||
*/
|
||||
void plist_get_real_val(plist_t node, double *val);
|
||||
|
||||
/**
|
||||
* Get the value of a #PLIST_DATA node.
|
||||
* This function does nothing if node is not of type #PLIST_DATA
|
||||
*
|
||||
* @param node the node
|
||||
* @param val a pointer to an unallocated char buffer. This function allocates the memory,
|
||||
* caller is responsible for freeing it.
|
||||
* @param length the length of the buffer
|
||||
*/
|
||||
void plist_get_data_val(plist_t node, char **val, uint64_t * length);
|
||||
|
||||
/**
|
||||
* Get a pointer to the data buffer of a #PLIST_DATA node.
|
||||
*
|
||||
* @note DO NOT MODIFY the buffer. Mind that the buffer is only available
|
||||
* until the plist node gets freed. Make a copy if needed.
|
||||
*
|
||||
* @param node The node
|
||||
* @param length Pointer to a uint64_t that will be set to the length of the buffer
|
||||
*
|
||||
* @return Pointer to the buffer
|
||||
*/
|
||||
const char* plist_get_data_ptr(plist_t node, uint64_t* length);
|
||||
|
||||
/**
|
||||
* Get the value of a #PLIST_DATE node.
|
||||
* This function does nothing if node is not of type #PLIST_DATE
|
||||
*
|
||||
* @param node the node
|
||||
* @param sec a pointer to an int32_t variable. Represents the number of seconds since 01/01/2001.
|
||||
* @param usec a pointer to an int32_t variable. Represents the number of microseconds
|
||||
*/
|
||||
void plist_get_date_val(plist_t node, int32_t * sec, int32_t * usec);
|
||||
|
||||
/**
|
||||
* Get the value of a #PLIST_UID node.
|
||||
* This function does nothing if node is not of type #PLIST_UID
|
||||
*
|
||||
* @param node the node
|
||||
* @param val a pointer to a uint64_t variable.
|
||||
*/
|
||||
void plist_get_uid_val(plist_t node, uint64_t * val);
|
||||
|
||||
|
||||
/********************************************
|
||||
* *
|
||||
* Setters *
|
||||
* *
|
||||
********************************************/
|
||||
|
||||
/**
|
||||
* Set the value of a node.
|
||||
* Forces type of node to #PLIST_KEY
|
||||
*
|
||||
* @param node the node
|
||||
* @param val the key value
|
||||
*/
|
||||
void plist_set_key_val(plist_t node, const char *val);
|
||||
|
||||
/**
|
||||
* Set the value of a node.
|
||||
* Forces type of node to #PLIST_STRING
|
||||
*
|
||||
* @param node the node
|
||||
* @param val the string value. The string is copied when set and will be
|
||||
* freed by the node.
|
||||
*/
|
||||
void plist_set_string_val(plist_t node, const char *val);
|
||||
|
||||
/**
|
||||
* Set the value of a node.
|
||||
* Forces type of node to #PLIST_BOOLEAN
|
||||
*
|
||||
* @param node the node
|
||||
* @param val the boolean value
|
||||
*/
|
||||
void plist_set_bool_val(plist_t node, uint8_t val);
|
||||
|
||||
/**
|
||||
* Set the value of a node.
|
||||
* Forces type of node to #PLIST_UINT
|
||||
*
|
||||
* @param node the node
|
||||
* @param val the unsigned integer value
|
||||
*/
|
||||
void plist_set_uint_val(plist_t node, uint64_t val);
|
||||
|
||||
/**
|
||||
* Set the value of a node.
|
||||
* Forces type of node to #PLIST_REAL
|
||||
*
|
||||
* @param node the node
|
||||
* @param val the real value
|
||||
*/
|
||||
void plist_set_real_val(plist_t node, double val);
|
||||
|
||||
/**
|
||||
* Set the value of a node.
|
||||
* Forces type of node to #PLIST_DATA
|
||||
*
|
||||
* @param node the node
|
||||
* @param val the binary buffer. The buffer is copied when set and will
|
||||
* be freed by the node.
|
||||
* @param length the length of the buffer
|
||||
*/
|
||||
void plist_set_data_val(plist_t node, const char *val, uint64_t length);
|
||||
|
||||
/**
|
||||
* Set the value of a node.
|
||||
* Forces type of node to #PLIST_DATE
|
||||
*
|
||||
* @param node the node
|
||||
* @param sec the number of seconds since 01/01/2001
|
||||
* @param usec the number of microseconds
|
||||
*/
|
||||
void plist_set_date_val(plist_t node, int32_t sec, int32_t usec);
|
||||
|
||||
/**
|
||||
* Set the value of a node.
|
||||
* Forces type of node to #PLIST_UID
|
||||
*
|
||||
* @param node the node
|
||||
* @param val the unsigned integer value
|
||||
*/
|
||||
void plist_set_uid_val(plist_t node, uint64_t val);
|
||||
|
||||
|
||||
/********************************************
|
||||
* *
|
||||
* Import & Export *
|
||||
* *
|
||||
********************************************/
|
||||
|
||||
/**
|
||||
* Export the #plist_t structure to XML format.
|
||||
*
|
||||
* @param plist the root node to export
|
||||
* @param plist_xml a pointer to a C-string. This function allocates the memory,
|
||||
* caller is responsible for freeing it. Data is UTF-8 encoded.
|
||||
* @param length a pointer to an uint32_t variable. Represents the length of the allocated buffer.
|
||||
*/
|
||||
void plist_to_xml(plist_t plist, char **plist_xml, uint32_t * length);
|
||||
|
||||
/**
|
||||
* Frees the memory allocated by plist_to_xml().
|
||||
*
|
||||
* @param plist_xml The buffer allocated by plist_to_xml().
|
||||
*/
|
||||
void plist_to_xml_free(char *plist_xml);
|
||||
|
||||
/**
|
||||
* Export the #plist_t structure to binary format.
|
||||
*
|
||||
* @param plist the root node to export
|
||||
* @param plist_bin a pointer to a char* buffer. This function allocates the memory,
|
||||
* caller is responsible for freeing it.
|
||||
* @param length a pointer to an uint32_t variable. Represents the length of the allocated buffer.
|
||||
*/
|
||||
void plist_to_bin(plist_t plist, char **plist_bin, uint32_t * length);
|
||||
|
||||
/**
|
||||
* Frees the memory allocated by plist_to_bin().
|
||||
*
|
||||
* @param plist_bin The buffer allocated by plist_to_bin().
|
||||
*/
|
||||
void plist_to_bin_free(char *plist_bin);
|
||||
|
||||
/**
|
||||
* Import the #plist_t structure from XML format.
|
||||
*
|
||||
* @param plist_xml a pointer to the xml buffer.
|
||||
* @param length length of the buffer to read.
|
||||
* @param plist a pointer to the imported plist.
|
||||
*/
|
||||
void plist_from_xml(const char *plist_xml, uint32_t length, plist_t * plist);
|
||||
|
||||
/**
|
||||
* Import the #plist_t structure from binary format.
|
||||
*
|
||||
* @param plist_bin a pointer to the xml buffer.
|
||||
* @param length length of the buffer to read.
|
||||
* @param plist a pointer to the imported plist.
|
||||
*/
|
||||
void plist_from_bin(const char *plist_bin, uint32_t length, plist_t * plist);
|
||||
|
||||
/**
|
||||
* Import the #plist_t structure from memory data.
|
||||
* This method will look at the first bytes of plist_data
|
||||
* to determine if plist_data contains a binary or XML plist.
|
||||
*
|
||||
* @param plist_data a pointer to the memory buffer containing plist data.
|
||||
* @param length length of the buffer to read.
|
||||
* @param plist a pointer to the imported plist.
|
||||
*/
|
||||
void plist_from_memory(const char *plist_data, uint32_t length, plist_t * plist);
|
||||
|
||||
/**
|
||||
* Test if in-memory plist data is binary or XML
|
||||
* This method will look at the first bytes of plist_data
|
||||
* to determine if plist_data contains a binary or XML plist.
|
||||
* This method is not validating the whole memory buffer to check if the
|
||||
* content is truly a plist, it's only using some heuristic on the first few
|
||||
* bytes of plist_data.
|
||||
*
|
||||
* @param plist_data a pointer to the memory buffer containing plist data.
|
||||
* @param length length of the buffer to read.
|
||||
* @return 1 if the buffer is a binary plist, 0 otherwise.
|
||||
*/
|
||||
int plist_is_binary(const char *plist_data, uint32_t length);
|
||||
|
||||
/********************************************
|
||||
* *
|
||||
* Utils *
|
||||
* *
|
||||
********************************************/
|
||||
|
||||
/**
|
||||
* Get a node from its path. Each path element depends on the associated father node type.
|
||||
* For Dictionaries, var args are casted to const char*, for arrays, var args are caster to uint32_t
|
||||
* Search is breath first order.
|
||||
*
|
||||
* @param plist the node to access result from.
|
||||
* @param length length of the path to access
|
||||
* @return the value to access.
|
||||
*/
|
||||
plist_t plist_access_path(plist_t plist, uint32_t length, ...);
|
||||
|
||||
/**
|
||||
* Variadic version of #plist_access_path.
|
||||
*
|
||||
* @param plist the node to access result from.
|
||||
* @param length length of the path to access
|
||||
* @param v list of array's index and dic'st key
|
||||
* @return the value to access.
|
||||
*/
|
||||
plist_t plist_access_pathv(plist_t plist, uint32_t length, va_list v);
|
||||
|
||||
/**
|
||||
* Compare two node values
|
||||
*
|
||||
* @param node_l left node to compare
|
||||
* @param node_r rigth node to compare
|
||||
* @return TRUE is type and value match, FALSE otherwise.
|
||||
*/
|
||||
char plist_compare_node_value(plist_t node_l, plist_t node_r);
|
||||
|
||||
#define _PLIST_IS_TYPE(__plist, __plist_type) (__plist && (plist_get_node_type(__plist) == PLIST_##__plist_type))
|
||||
|
||||
/* Helper macros for the different plist types */
|
||||
#define PLIST_IS_BOOLEAN(__plist) _PLIST_IS_TYPE(__plist, BOOLEAN)
|
||||
#define PLIST_IS_UINT(__plist) _PLIST_IS_TYPE(__plist, UINT)
|
||||
#define PLIST_IS_REAL(__plist) _PLIST_IS_TYPE(__plist, REAL)
|
||||
#define PLIST_IS_STRING(__plist) _PLIST_IS_TYPE(__plist, STRING)
|
||||
#define PLIST_IS_ARRAY(__plist) _PLIST_IS_TYPE(__plist, ARRAY)
|
||||
#define PLIST_IS_DICT(__plist) _PLIST_IS_TYPE(__plist, DICT)
|
||||
#define PLIST_IS_DATE(__plist) _PLIST_IS_TYPE(__plist, DATE)
|
||||
#define PLIST_IS_DATA(__plist) _PLIST_IS_TYPE(__plist, DATA)
|
||||
#define PLIST_IS_KEY(__plist) _PLIST_IS_TYPE(__plist, KEY)
|
||||
#define PLIST_IS_UID(__plist) _PLIST_IS_TYPE(__plist, UID)
|
||||
|
||||
/*@}*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
|
||||
$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
|
||||
if (socket_connect($sock, '192.168.0.104', 24864)) {
|
||||
$welcome = socket_read($sock, 4);
|
||||
var_dump($welcome);
|
||||
if ($welcome == "\x03WEL") {
|
||||
$i=0;
|
||||
while (true) {
|
||||
$data = str_repeat(chr($i), 93)."\0\0\0";
|
||||
socket_write($sock, chr(99).'LED'.$data);
|
||||
echo "\r$i ";
|
||||
$i += 20;
|
||||
$i &= 0xff;
|
||||
usleep(16000);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue