Skip to content

Commit

Permalink
0.5.16 updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
retsamknaps committed May 21, 2017
1 parent c0e13cc commit e6b67d5
Show file tree
Hide file tree
Showing 10 changed files with 150 additions and 32 deletions.
13 changes: 13 additions & 0 deletions deletetraces
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

rm in_*trace0*
rm in_*trace1*
rm in_*trace2*
rm in_*trace3*
rm in_*trace4*
rm in_*trace*
rm out_*trace0*
rm out_*trace1*
rm out_*trace2*
rm out_*trace3*
rm out_*trace4*
rm out_*trace*
69 changes: 46 additions & 23 deletions src/aktie/gui/NewMemberDialog.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package aktie.gui;

import java.io.IOException;
import java.util.Iterator;

import aktie.data.CObj;
import aktie.gui.table.AktieTableViewerColumn;
Expand All @@ -14,6 +15,8 @@
import org.apache.lucene.search.Sort;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Point;
Expand Down Expand Up @@ -56,6 +59,7 @@ public NewMemberDialog ( Shell parentShell, SWTApp a )

private String selectedIdentity;
private String selectedCommunity;
private String communityDisplayName;

private void selectIdentity ( String selid, String comid )
{
Expand Down Expand Up @@ -113,12 +117,12 @@ else if ( a > maxauth )

}

String comname = community.getPrivateDisplayName();
communityDisplayName = community.getPrivateDisplayName();
String identname = identity.getDisplayName();

if ( comname != null )
if ( communityDisplayName != null )
{
lblGrantMembershipFor.setText ( "Grant membership for community: " + comname );
lblGrantMembershipFor.setText ( "Grant membership for community: " + communityDisplayName );
}

if ( identname != null )
Expand Down Expand Up @@ -312,8 +316,6 @@ protected void cancelPressed()
@Override
protected void okPressed()
{
CObjList clst = ( CObjList ) table.getTableViewer().getInput();

if ( selectedIdentity != null && selectedCommunity != null )
{
long auth = 0;
Expand All @@ -333,30 +335,51 @@ protected void okPressed()
auth = CObj.MEMBER_SIMPLE;
}

int idx[] = table.getSelectionIndices();
IStructuredSelection ssel = table.getTableViewer().getSelection();

@SuppressWarnings ( "rawtypes" )
Iterator i = ssel.iterator();

for ( int c = 0; c < idx.length; c++ )
while ( i.hasNext() )
{
try

Object o = i.next();

if ( o instanceof CObjListArrayElement )
{
CObj ident = clst.get ( idx[c] );
CObj co = new CObj();
co.setType ( CObj.MEMBERSHIP );
co.pushString ( CObj.CREATOR, selectedIdentity );
co.pushPrivateNumber ( CObj.AUTHORITY, auth );
co.pushPrivate ( CObj.COMMUNITYID, selectedCommunity );
co.pushPrivate ( CObj.MEMBERID, ident.getId() );

if ( app != null )
CObjListArrayElement ce = ( CObjListArrayElement ) o;

if ( ce != null )
{
app.getNode().enqueue ( co );
}
CObj ident = ce.getCObj();

}
CObj co = new CObj();
co.setType ( CObj.MEMBERSHIP );
co.pushString ( CObj.CREATOR, selectedIdentity );
co.pushPrivateNumber ( CObj.AUTHORITY, auth );
co.pushPrivate ( CObj.COMMUNITYID, selectedCommunity );
co.pushPrivate ( CObj.MEMBERID, ident.getId() );

if ( app != null )
{
boolean doit = MessageDialog.openConfirm ( getParentShell(), "Confirm Membership",
"Are you sure you want to grant: " + ident.getDisplayName() + "\n" +
"membership to: " + communityDisplayName );

if ( doit )
{
app.getNode().enqueue ( co );
}

else
{
return;
}

}

}

catch ( IOException e )
{
e.printStackTrace();
}

}
Expand Down
6 changes: 3 additions & 3 deletions src/aktie/gui/Wrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ public class Wrapper
public static String VERSION_0418 = "version 0.4.18";
public static String VERSION_0505 = "version 0.5.5";
public static String VERSION_0506 = "version 0.5.6";
public static String VERSION_0515 = "version 0.5.15";
public static String VERSION_0516 = "version 0.5.16";

public static String VERSION = VERSION_0515;
public static String VERSION = VERSION_0516;

public static String VERSION_FILE = "version.txt";

Expand All @@ -44,7 +44,7 @@ public class Wrapper
//the upgrade file added to the network by the developer account.
//This keeps new installs from downloading the same version as
//an upgrade
public static long RELEASETIME = ( 1495329157L * 1000L ) + 3600000L;
public static long RELEASETIME = ( 1495390963L * 1000L ) + 3600000L;

//Hash cash payment values
public static long OLDPAYMENT_V0 = 0x0000004000000000L;
Expand Down
22 changes: 21 additions & 1 deletion src/aktie/net/ConnectionManager2.java
Original file line number Diff line number Diff line change
Expand Up @@ -1413,6 +1413,24 @@ public void closeDestinationConnections ( CObj id )

}

public void updateAllConnections ( CObj o )
{
List<DestinationThread> dl = new LinkedList<DestinationThread>();

synchronized ( destinations )
{
dl.addAll ( destinations.values() );

}

for ( DestinationThread dt : dl )
{
dt.update ( o );
}

}


public void closeAllConnections()
{
synchronized ( destinations )
Expand Down Expand Up @@ -1708,6 +1726,8 @@ private void decodeMemberships()

index.index ( m );

updateAllConnections ( m );

if ( callback != null )
{
callback.update ( m );
Expand Down Expand Up @@ -1815,6 +1835,7 @@ private void checkInvalidSubs()
}

index.index ( co );
updateAllConnections ( co );
}

}
Expand Down Expand Up @@ -1852,7 +1873,6 @@ public synchronized void kickConnections()
notifyAll();
}


private synchronized void delay()
{
try
Expand Down
6 changes: 6 additions & 0 deletions src/aktie/net/ConnectionThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -1999,6 +1999,12 @@ public void update ( Object o )
updateSubsAndFiles();
}

if ( CObj.MEMBERSHIP.equals ( co.getType() ) )
{
sendFirstMemSubs = true;
updateSubsAndFiles();
}

}

}
Expand Down
20 changes: 20 additions & 0 deletions src/aktie/net/DestinationThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,26 @@ public int numberConnection()

}

public void update ( CObj o )
{
List<ConnectionThread> tl = new LinkedList<ConnectionThread>();

synchronized ( connections )
{
for ( List<ConnectionThread> l : connections.values() )
{
tl.addAll ( l );
}

}

for ( ConnectionThread t : tl )
{
t.update ( o );
}

}

public void send ( CObj o )
{
List<ConnectionThread> tl = new LinkedList<ConnectionThread>();
Expand Down
1 change: 1 addition & 0 deletions src/aktie/user/NewSubscriptionProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ public boolean process ( CObj o )
if ( conMan != null )
{
conMan.resetAllConnections();
conMan.updateAllConnections ( o );
}

if ( "true".equals ( o.getString ( CObj.SUBSCRIBED ) ) )
Expand Down
8 changes: 8 additions & 0 deletions src/aktie/user/ShareManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,14 @@ private void checkHasFile ( CObj hf )

}

else
{
HasFileCreator.wtfHasFileWithoutfile ( hf );
hf.pushString ( CObj.STILLHASFILE, "false" );
hfc.createHasFile ( hf );
hfc.updateFileInfo ( hf );
}

}

private void crawlDirectory ( Path dlpath, Path nodepath, DirectoryShare s, File df )
Expand Down
35 changes: 31 additions & 4 deletions src/aktie/utils/HasFileCreator.java
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,15 @@ public void updateOnlyHasFile ( UpdateInterface up )

}

public static void wtfHasFileWithoutfile ( CObj o )
{
System.out.println ( "--------------------------------------------------" );
System.out.println ( "WTF? I think I have a file.. but I don't." );
System.out.println ( "Is there something odd with: " );
System.out.println ( o.toString() );
System.out.println ( "--------------------------------------------------" );
}

public boolean createHasFile ( CObj o )
{
//Set File sequence number for the community/creator
Expand Down Expand Up @@ -369,20 +378,37 @@ public boolean createHasFile ( CObj o )
if ( oldfile != null )
{
String oldlf = oldfile.getPrivate ( CObj.LOCALFILE );
File oldf = new File ( oldlf );
String oldsh = oldfile.getString ( CObj.STILLHASFILE );

if ( oldlf == null )
{
if ( "true".equals ( oldsh ) || oldlf != null )
{
wtfHasFileWithoutfile ( oldfile );
}

}

boolean oldfexists = false;

if ( oldlf != null )
{
File oldf = new File ( oldlf );
oldfexists = oldf.exists();
}

String newsh = o.getString ( CObj.STILLHASFILE );

log.info ( "Old hasfile found: " + oldlf + " name: " + oldfile.getString ( CObj.NAME ) +
" exists: " + oldf.exists() +
" exists: " + oldfexists +
" old stillhas: " + oldsh + " new stillhas: " + newsh );

//Can never re-use if stillhas is different
if ( oldsh != null && oldsh.equals ( newsh ) )
{
File lff = new File ( lf );

if ( lff.exists() && !oldf.exists() && "true".equals ( newsh ) )
if ( lff.exists() && !oldfexists && "true".equals ( newsh ) )
{
//The new file exists, the old one does not. Just
//update the localfile path of the old one to match this
Expand Down Expand Up @@ -437,7 +463,7 @@ public boolean createHasFile ( CObj o )

}

if ( ed == null && lff.exists() && oldf.exists() && "true".equals ( newsh ) )
if ( ed == null && lff.exists() && oldfexists && "true".equals ( newsh ) )
{
log.info ( "Creating duplicate for: " + lf );
CObj dp = new CObj();
Expand Down Expand Up @@ -466,6 +492,7 @@ public boolean createHasFile ( CObj o )
oldfile.makeCopy ( o );
return true;


}

}
Expand Down
2 changes: 1 addition & 1 deletion test/aktie/TestNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ public void testNode()

try
{
Thread.sleep ( 10L * 1000L );
Thread.sleep ( 20L * 1000L );
}

catch ( InterruptedException e )
Expand Down

0 comments on commit e6b67d5

Please sign in to comment.