summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/AFC.c57
-rw-r--r--src/Makefile.am2
-rw-r--r--src/NotificationProxy.h30
3 files changed, 88 insertions, 1 deletions
diff --git a/src/AFC.c b/src/AFC.c
index dc8fe20..af07b56 100644
--- a/src/AFC.c
+++ b/src/AFC.c
@@ -917,6 +917,63 @@ iphone_error_t iphone_afc_close_file(iphone_afc_client_t client, iphone_afc_file
917 return IPHONE_E_SUCCESS; 917 return IPHONE_E_SUCCESS;
918} 918}
919 919
920/** Locks or unlocks a file on the phone.
921 *
922 * makes use of flock, see
923 * http://developer.apple.com/documentation/Darwin/Reference/ManPages/man2/flock.2.html
924 *
925 * operation (same as in sys/file.h on linux):
926 *
927 * LOCK_SH 1 // shared lock
928 * LOCK_EX 2 // exclusive lock
929 * LOCK_NB 4 // don't block when locking
930 * LOCK_UN 8 // unlock
931 *
932 * @param client The client to close the file with.
933 * @param file A pointer to an AFCFile struct containing the file handle of the
934 * file to close.
935 * @operation the lock or unlock operation to perform.
936 */
937iphone_error_t iphone_afc_lock_file(iphone_afc_client_t client, iphone_afc_file_t file, int operation)
938{
939 if (!client || !file)
940 return IPHONE_E_INVALID_ARG;
941 char *buffer = malloc(16);
942 uint32 zero = 0;
943 int bytes = 0;
944 uint64_t op = operation;
945
946 afc_lock(client);
947
948 log_debug_msg("afc_lock_file: File handle %i\n", file->filehandle);
949
950 // Send command
951 memcpy(buffer, &file->filehandle, sizeof(uint32));
952 memcpy(buffer + sizeof(uint32), &zero, sizeof(zero));
953 memcpy(buffer + 8, &op, 8);
954
955 client->afc_packet->operation = AFC_FILE_LOCK;
956 client->afc_packet->entire_length = client->afc_packet->this_length = 0;
957 bytes = dispatch_AFC_packet(client, buffer, 15);
958 free(buffer);
959 buffer = NULL;
960
961 if (bytes <= 0) {
962 afc_unlock(client);
963 log_debug_msg("fuck\n");
964 return IPHONE_E_UNKNOWN_ERROR;
965 }
966 // Receive the response
967 bytes = receive_AFC_data(client, &buffer);
968 log_debug_msg("%s: receiving response (%d bytes)\n", __func__, bytes);
969 if (buffer) {
970 log_debug_buffer(buffer, bytes);
971 free(buffer);
972 }
973 afc_unlock(client);
974 return IPHONE_E_SUCCESS;
975}
976
920/** Seeks to a given position of a pre-opened file on the phone. 977/** Seeks to a given position of a pre-opened file on the phone.
921 * 978 *
922 * @param client The client to use to seek to the position. 979 * @param client The client to use to seek to the position.
diff --git a/src/Makefile.am b/src/Makefile.am
index 2661ed6..76b15ec 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -12,4 +12,4 @@ libiphone_initconf_LDFLAGS = $(libgthread2_LIBS) $(AM_LDFLAGS)
12 12
13 13
14lib_LTLIBRARIES = libiphone.la 14lib_LTLIBRARIES = libiphone.la
15libiphone_la_SOURCES = usbmux.c iphone.c plist.c lockdown.c AFC.c userpref.c utils.c 15libiphone_la_SOURCES = usbmux.c iphone.c plist.c lockdown.c AFC.c NotificationProxy.c userpref.c utils.c
diff --git a/src/NotificationProxy.h b/src/NotificationProxy.h
new file mode 100644
index 0000000..7b47346
--- /dev/null
+++ b/src/NotificationProxy.h
@@ -0,0 +1,30 @@
1/*
2 * NotificationProxy.h
3 * Notification Proxy header file.
4 *
5 * Copyright (c) 2009 Nikias Bassen, All Rights Reserved.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21#include "usbmux.h"
22#include "iphone.h"
23
24#include <glib.h>
25
26struct iphone_np_client_int {
27 iphone_umux_client_t connection;
28 GMutex *mutex;
29};
30