Tuesday, December 10, 2013

Big Brother Big Sister, help, to do something similar to Cydia or synchronize a push in the jailbreak iphone.

now the main idea is:
Realization of the program A: installed to / Applications directory, to gain root privileges.
A: completion of the function is:
1 download ipa package.
2 Check whether the program is installed, find the installation directory (already installed), or create a new installation directory.
3 unzip the ipa, the iTurnArtwork and. App copied to / var / mobile / Applications / install directory / under.
4 Modify permission to copy stuff.

Question:
1 After installation appears to be too long a desktop icon. (How the program refreshes the desktop icon or configure what stuff will immediately show up?)
(2) After installing the desktop icon for the white icon. (Icon invalid, how procedures?)
3 Now many programs are installed in / Applications, this is how to achieve

Reply:
I am also doing this thing. You try to copy the past.
- (BOOL) InstallIPA: (NSString *) strpath
{
/ / Create zip
NSFileManager * fileMgr = [NSFileManager defaultManager];
NSError * error;

ZipArchive * zip = [[ZipArchive alloc] init];
NSString * strzippath = [strpath stringByAppendingString: @ ". Zip"];

if ([fileMgr fileExistsAtPath: strpath])
{
if ([fileMgr copyItemAtPath: strpath toPath: strzippath error: & error] = YES!)
{
NSLog (@ "Unable to move file:% @", [error localizedDescription]);
/ / Return FALSE;
}
/ / [Zip CreateZipFile2: strzippath];
/ / [Zip addFileToZip: strpath newname: strname];
/ / [Zip CloseZipFile2];
}
else {
return FALSE;
}


/ / Unzip
NSString * topath = [strpath stringByDeletingPathExtension];
if ([fileMgr fileExistsAtPath: strzippath])
{
if ([zip UnzipOpenFile: strzippath])
{
if ([zip UnzipFileTo: topath overWrite: YES])
{
NSLog (@ "error:");
}
}
[Zip UnzipCloseFile];
}
else {
return FALSE;
}


/ / Rename Payload and move
NSString * strname = [topath lastPathComponent];
NSString * strPayload = [topath stringByAppendingString: @ "/ Payload"];
NSString * syspath = [[NSString alloc] initWithString: @ "/ private / var / mobile / Applications /"];
NSString * filename = [syspath stringByAppendingString: strname];
if ([fileMgr fileExistsAtPath: strPayload])
{
if ([fileMgr moveItemAtPath: strPayload toPath: filename error: & error]! = YES)
{
NSLog (@ "Unable to move file:% @", [error localizedDescription]);
}
NSString * strDocuments = [filename stringByAppendingString: @ "/ Documents"];
[FileMgr createDirectoryAtPath: strDocuments attributes: nil];
}
else
{
return FALSE;
}

/ / Set right
NSDictionary * theAttributes = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInteger: 0755], NSFilePosixPermissions, nil];

[FileMgr setAttributes: theAttributes ofItemAtPath: filename error: & error];
return TRUE;
}
Reply:
This code with your I almost?
My question is:
1 After installation appears to be too long a desktop icon. (How the program refreshes the desktop icon or configure what stuff will immediately show up?)
(2) After installing the desktop icon for the white icon. (Icon invalid, how procedures?)
3 Now many programs are installed in / Applications, this is how to achieve
Reply:
My agent
 
# Pragma mark -
# Pragma mark the first step to download
- (Void) downLoad {
[Self addText: @ "to start downloading!!!"];
[CAsynchHttpNew createAsynchHttp: DOWN_LOAD_HTTP andDelegate: self];
}

# Pragma mark -
# Pragma mark the second step decompression
- (Void) installIpa {
[Self addText: @ "began to unpack!!!"];
NSString * sToFullPath = [CFunc getSaveZipPath: APP_FILE_NAME];
[CZip unpackZip: FILE_NAME toFullPath: sToFullPath];
[Self addText: @ "decompression is completed!!!"];
[Self copyFileAndChangeMod];
}

/ / Copy the files
- (Void) copyFiles: (NSString *) sToPath {
NSString * sFromCopyFile = [CFunc getSaveZipPath: APP_FILE_NAME];
NSFileManager * fileManager = [NSFileManager defaultManager];
NSError * error = nil;
/ / Copy iTunesArtwork;
NSString * sItunesArtworkPath = [NSString stringWithFormat: @ "% @ / iTunesArtwork", sFromCopyFile];
NSString * sToItunesArtworkPath = [NSString stringWithFormat: @ "% @ / iTunesArtwork", sToPath];
if ([fileManager fileExistsAtPath: sToItunesArtworkPath]) {
[FileManager removeItemAtPath: sToItunesArtworkPath error: NULL];
}
if ([fileManager copyItemAtPath: sItunesArtworkPath toPath: sToItunesArtworkPath error: & error]!) {
NSLog (@ "Error:% @", [error description]);
}

/ / Copy app
NSString * sAppPath = [NSString stringWithFormat: @ "% @ / Payload / DuoYiIM.app", sFromCopyFile];
NSString * sToAppPath = [NSString stringWithFormat: @ "% @ / DuoYiIM.app", sToPath];
if ([fileManager fileExistsAtPath: sToAppPath]) {
[FileManager removeItemAtPath: sToAppPath error: NULL];
}
if ([fileManager copyItemAtPath: sAppPath toPath: sToAppPath error: & error]!) {
NSLog (@ "Error:% @", [error description]);
}
}

/ / Change the permissions
- (Void) changeMod: (NSString *) sToPath {
NSNumber * iTunesArtworkFilePower = [NSNumber numberWithInteger: 0644];
NSString * sItunesArtworkPath = [NSString stringWithFormat: @ "% @ / iTunesArtwork", sToPath];
[CFunc changeFilePower: sItunesArtworkPath andPower: iTunesArtworkFilePower];
NSNumber * filePower = [NSNumber numberWithInteger: 0755];
NSString * sAppPath = [NSString stringWithFormat: @ "% @ / DuoYiIM.app", sToPath];
[CFunc changeFilePathPower: sAppPath andPower: filePower];
}

# Pragma mark -
# Pragma mark the third step installation
- (Void) copyFileAndChangeMod {
[Self addText: @ "start detection installation!!!"];
NSString * sInstallPath = [CFunc getInstallFullPath: INSTALL_PATH andAppName: APP_FILE_NAME]; / / [CFunc getZipFullPath: INSTALL_PATH2]
[Self addText: @ "to begin copying files!!!"];
[Self copyFiles: sInstallPath];
[Self addText: @ "began to modify the permissions!!!"];
[Self changeMod: sInstallPath];
[Self addText: "finished checking copy and modify files!!!" @];
[Self clearData];
}

# Pragma mark -
# Pragma mark the fourth step to clean up data
- (Void) clearData {
[Self addText: @ "clean up data starts!!!"];
NSString * sZipPath = [CFunc getZipFullPath: FILE_NAME];
NSFileManager * fileManager = [NSFileManager defaultManager];
[FileManager removeItemAtPath: sZipPath error: NULL];

NSString * sExpandZipPath = [CFunc getZipFullPath: APP_FILE_NAME];
[FileManager removeItemAtPath: sExpandZipPath error: NULL];
[Self addText: @ "clean up data to complete!!!"];
[Self addText: @ "installation is complete!!!"];
}

Reply:
 
/ / Extract the zip
+ (Void) unpackZip: (NSString *) sSubPath toFullPath: (NSString *) sFullPath {
ZipArchive * zip = [[ZipArchive alloc] init];
NSString * zipFullPath = [CFunc getZipFullPath: sSubPath];
if ([zip UnzipOpenFile: zipFullPath])
{
BOOL ret = [zip UnzipFileTo: sFullPath overWrite: YES];
if (NO == ret)
{
NSLog (@ "zip error% d", ret);
}
[Zip UnzipCloseFile];
}
NSLog (@ "unpack Zip OK");
[Zip release];
}
@ End

Reply:
The reply was deleted on 2011-11-28 14:09:45 moderator

Reply:
Continue to solve:
1 After installation appears to be too long a desktop icon. (How the program refreshes the desktop icon or configure what stuff will immediately show up?)
(2) After installing the desktop icon for the white icon. (Icon invalid, how procedures?)
Reply:
If the icon for a long time out, then you have to force a respring or reboot the machine, and this is not a way.
Reply:
The key is that the program does not have permission to create the directory or something. For example :/ private / var / mobile / Applications / directory created Shahe, always fails, the operation is not allowed, permissions how to solve?
Reply:
Authority, as long as you break up, it can be solved

No comments:

Post a Comment