Skip to content

Commit

Permalink
Add postblits
Browse files Browse the repository at this point in the history
  • Loading branch information
Dadoum authored Nov 21, 2023
1 parent 533dca3 commit 60361b9
Showing 1 changed file with 30 additions and 14 deletions.
44 changes: 30 additions & 14 deletions lib/provision/adi.d
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,11 @@ public class ADI {
public ubyte[] machineIdentifier;
private ADI adi;

@disable this();
@disable this(this);
this(this) {
synchronizationResumeMetadata = synchronizationResumeMetadata.dup;
machineIdentifier = machineIdentifier.dup;
adi = null;
}

this(ADI adiInstance, ubyte* srm, uint srmLength, ubyte* mid, uint midLength) {
adi = adiInstance;
Expand All @@ -142,8 +145,10 @@ public class ADI {
}

~this() {
adi.dispose(synchronizationResumeMetadata.ptr);
adi.dispose(machineIdentifier.ptr);
if (adi) {
adi.dispose(synchronizationResumeMetadata.ptr);
adi.dispose(machineIdentifier.ptr);
}
}
}

Expand Down Expand Up @@ -185,8 +190,10 @@ public class ADI {
public uint session;
private ADI adi;

@disable this();
@disable this(this);
this(this) {
clientProvisioningIntermediateMetadata = clientProvisioningIntermediateMetadata.dup;
adi = null;
}

this(ADI adiInstance, ubyte* cpim, uint cpimLength, uint session) {
adi = adiInstance;
Expand All @@ -195,7 +202,9 @@ public class ADI {
}

~this() {
adi.dispose(clientProvisioningIntermediateMetadata.ptr);
if (adi) {
adi.dispose(clientProvisioningIntermediateMetadata.ptr);
}
}
}

Expand Down Expand Up @@ -237,8 +246,11 @@ public class ADI {
public ubyte[] machineIdentifier;
private ADI adi;

@disable this();
@disable this(this);
this(this) {
oneTimePassword = oneTimePassword.dup;
machineIdentifier = machineIdentifier.dup;
adi = null;
}

this(ADI adiInstance, ubyte* otp, uint otpLength, ubyte* mid, uint midLength) {
adi = adiInstance;
Expand All @@ -247,8 +259,10 @@ public class ADI {
}

~this() {
adi.dispose(oneTimePassword.ptr);
adi.dispose(machineIdentifier.ptr);
if (adi) {
adi.dispose(oneTimePassword.ptr);
adi.dispose(machineIdentifier.ptr);
}
}
}

Expand Down Expand Up @@ -295,9 +309,11 @@ public class Device {
// string romAddress;
// string machineSerialNumber;

bool initialized = false;
bool _initialized = false;
string path;

bool initialized() { return _initialized; }

this(string filePath) {
path = filePath;
if (file.exists(path)) {
Expand All @@ -307,7 +323,7 @@ public class Device {
serverFriendlyDescription = deviceFile[serverFriendlyDescriptionJson].str();
adiIdentifier = deviceFile[adiIdentifierJson].str();
localUserUUID = deviceFile[localUserUUIDJson].str();
initialized = true;
_initialized = true;
} catch (Throwable) { /+ do nothing +/ }
}
}
Expand All @@ -320,7 +336,7 @@ public class Device {
public void write() {
if (path) {
file.write(path, deviceData.toString());
initialized = true;
_initialized = true;
}
}
}
Expand Down

0 comments on commit 60361b9

Please sign in to comment.